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 " (tb_rate) (tb_size) (packet_length_adjust)\n"
732 " Add port tm node private shaper profile.\n\n"
734 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
735 " Delete port tm node private shaper profile.\n\n"
737 "add port tm node shared shaper (port_id) (shared_shaper_id)"
738 " (shaper_profile_id)\n"
739 " Add/update port tm node shared shaper.\n\n"
741 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
742 " Delete port tm node shared shaper.\n\n"
744 "set port tm node shaper profile (port_id) (node_id)"
745 " (shaper_profile_id)\n"
746 " Set port tm node shaper profile.\n\n"
748 "add port tm node wred profile (port_id) (wred_profile_id)"
749 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
750 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
751 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
752 " Add port tm node wred profile.\n\n"
754 "del port tm node wred profile (port_id) (wred_profile_id)\n"
755 " Delete port tm node wred profile.\n\n"
757 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
758 " (priority) (weight) (level_id) (shaper_profile_id)"
759 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
760 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
761 " Add port tm nonleaf node.\n\n"
763 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
764 " (priority) (weight) (level_id) (shaper_profile_id)"
765 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
766 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
767 " Add port tm leaf node.\n\n"
769 "del port tm node (port_id) (node_id)\n"
770 " Delete port tm node.\n\n"
772 "set port tm node parent (port_id) (node_id) (parent_node_id)"
773 " (priority) (weight)\n"
774 " Set port tm node parent.\n\n"
776 "suspend port tm node (port_id) (node_id)"
777 " Suspend tm node.\n\n"
779 "resume port tm node (port_id) (node_id)"
780 " Resume tm node.\n\n"
782 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
783 " Commit tm hierarchy.\n\n"
785 "vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
786 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
787 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
788 " Configure the VXLAN encapsulation for flows.\n\n"
790 "vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
791 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
792 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
793 " eth-dst (eth-dst)\n"
794 " Configure the VXLAN encapsulation for flows.\n\n"
796 "nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
797 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
799 " Configure the NVGRE encapsulation for flows.\n\n"
801 "nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
802 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
803 " eth-src (eth-src) eth-dst (eth-dst)\n"
804 " Configure the NVGRE encapsulation for flows.\n\n"
806 , list_pkt_forwarding_modes()
810 if (show_all || !strcmp(res->section, "ports")) {
816 "----------------\n\n"
818 "port start (port_id|all)\n"
819 " Start all ports or port_id.\n\n"
821 "port stop (port_id|all)\n"
822 " Stop all ports or port_id.\n\n"
824 "port close (port_id|all)\n"
825 " Close all ports or port_id.\n\n"
827 "port attach (ident)\n"
828 " Attach physical or virtual dev by pci address or virtual device name\n\n"
830 "port detach (port_id)\n"
831 " Detach physical or virtual dev by port_id\n\n"
833 "port config (port_id|all)"
834 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
835 " duplex (half|full|auto)\n"
836 " Set speed and duplex for all ports or port_id\n\n"
838 "port config (port_id|all) loopback (mode)\n"
839 " Set loopback mode for all ports or port_id\n\n"
841 "port config all (rxq|txq|rxd|txd) (value)\n"
842 " Set number for rxq/txq/rxd/txd.\n\n"
844 "port config all max-pkt-len (value)\n"
845 " Set the max packet length.\n\n"
847 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
848 "hw-vlan-strip|hw-vlan-extend|drop-en)"
850 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
853 "port config all rss (all|default|ip|tcp|udp|sctp|"
854 "ether|port|vxlan|geneve|nvgre|none|<flowtype_id>)\n"
855 " Set the RSS mode.\n\n"
857 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
858 " Set the RSS redirection table.\n\n"
860 "port config (port_id) dcb vt (on|off) (traffic_class)"
862 " Set the DCB mode.\n\n"
864 "port config all burst (value)\n"
865 " Set the number of packets per burst.\n\n"
867 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
869 " Set the ring prefetch/host/writeback threshold"
870 " for tx/rx queue.\n\n"
872 "port config all (txfreet|txrst|rxfreet) (value)\n"
873 " Set free threshold for rx/tx, or set"
874 " tx rs bit threshold.\n\n"
875 "port config mtu X value\n"
876 " Set the MTU of port X to a given value\n\n"
878 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
879 " Set a rx/tx queue's ring size configuration, the new"
880 " value will take effect after command that (re-)start the port"
881 " or command that setup the specific queue\n\n"
883 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
884 " Start/stop a rx/tx queue of port X. Only take effect"
885 " when port X is started\n\n"
887 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
888 " Switch on/off a deferred start of port X rx/tx queue. Only"
889 " take effect when port X is stopped.\n\n"
891 "port (port_id) (rxq|txq) (queue_id) setup\n"
892 " Setup a rx/tx queue of port X.\n\n"
894 "port config (port_id|all) l2-tunnel E-tag ether-type"
896 " Set the value of E-tag ether-type.\n\n"
898 "port config (port_id|all) l2-tunnel E-tag"
899 " (enable|disable)\n"
900 " Enable/disable the E-tag support.\n\n"
902 "port config (port_id) pctype mapping reset\n"
903 " Reset flow type to pctype mapping on a port\n\n"
905 "port config (port_id) pctype mapping update"
906 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
907 " Update a flow type to pctype mapping item on a port\n\n"
909 "port config (port_id) pctype (pctype_id) hash_inset|"
910 "fdir_inset|fdir_flx_inset get|set|clear field\n"
912 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
914 "port config (port_id) pctype (pctype_id) hash_inset|"
915 "fdir_inset|fdir_flx_inset clear all"
916 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
918 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
919 " Add/remove UDP tunnel port for tunneling offload\n\n"
923 if (show_all || !strcmp(res->section, "registers")) {
931 "read reg (port_id) (address)\n"
932 " Display value of a port register.\n\n"
934 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
935 " Display a port register bit field.\n\n"
937 "read regbit (port_id) (address) (bit_x)\n"
938 " Display a single port register bit.\n\n"
940 "write reg (port_id) (address) (value)\n"
941 " Set value of a port register.\n\n"
943 "write regfield (port_id) (address) (bit_x) (bit_y)"
945 " Set bit field of a port register.\n\n"
947 "write regbit (port_id) (address) (bit_x) (value)\n"
948 " Set single bit value of a port register.\n\n"
951 if (show_all || !strcmp(res->section, "filters")) {
959 "ethertype_filter (port_id) (add|del)"
960 " (mac_addr|mac_ignr) (mac_address) ethertype"
961 " (ether_type) (drop|fwd) queue (queue_id)\n"
962 " Add/Del an ethertype filter.\n\n"
964 "2tuple_filter (port_id) (add|del)"
965 " dst_port (dst_port_value) protocol (protocol_value)"
966 " mask (mask_value) tcp_flags (tcp_flags_value)"
967 " priority (prio_value) queue (queue_id)\n"
968 " Add/Del a 2tuple filter.\n\n"
970 "5tuple_filter (port_id) (add|del)"
971 " dst_ip (dst_address) src_ip (src_address)"
972 " dst_port (dst_port_value) src_port (src_port_value)"
973 " protocol (protocol_value)"
974 " mask (mask_value) tcp_flags (tcp_flags_value)"
975 " priority (prio_value) queue (queue_id)\n"
976 " Add/Del a 5tuple filter.\n\n"
978 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
979 " Add/Del syn filter.\n\n"
981 "flex_filter (port_id) (add|del) len (len_value)"
982 " bytes (bytes_value) mask (mask_value)"
983 " priority (prio_value) queue (queue_id)\n"
984 " Add/Del a flex filter.\n\n"
986 "flow_director_filter (port_id) mode IP (add|del|update)"
987 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
988 " src (src_ip_address) dst (dst_ip_address)"
989 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
990 " vlan (vlan_value) flexbytes (flexbytes_value)"
991 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
992 " fd_id (fd_id_value)\n"
993 " Add/Del an IP type flow director filter.\n\n"
995 "flow_director_filter (port_id) mode IP (add|del|update)"
996 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
997 " src (src_ip_address) (src_port)"
998 " dst (dst_ip_address) (dst_port)"
999 " tos (tos_value) ttl (ttl_value)"
1000 " vlan (vlan_value) flexbytes (flexbytes_value)"
1001 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
1002 " fd_id (fd_id_value)\n"
1003 " Add/Del an UDP/TCP type flow director filter.\n\n"
1005 "flow_director_filter (port_id) mode IP (add|del|update)"
1006 " flow (ipv4-sctp|ipv6-sctp)"
1007 " src (src_ip_address) (src_port)"
1008 " dst (dst_ip_address) (dst_port)"
1009 " tag (verification_tag) "
1010 " tos (tos_value) ttl (ttl_value)"
1011 " vlan (vlan_value)"
1012 " flexbytes (flexbytes_value) (drop|fwd)"
1013 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1014 " Add/Del a SCTP type flow director filter.\n\n"
1016 "flow_director_filter (port_id) mode IP (add|del|update)"
1017 " flow l2_payload ether (ethertype)"
1018 " flexbytes (flexbytes_value) (drop|fwd)"
1019 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1020 " Add/Del a l2 payload type flow director filter.\n\n"
1022 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1023 " mac (mac_address) vlan (vlan_value)"
1024 " flexbytes (flexbytes_value) (drop|fwd)"
1025 " queue (queue_id) fd_id (fd_id_value)\n"
1026 " Add/Del a MAC-VLAN flow director filter.\n\n"
1028 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1029 " mac (mac_address) vlan (vlan_value)"
1030 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1031 " flexbytes (flexbytes_value) (drop|fwd)"
1032 " queue (queue_id) fd_id (fd_id_value)\n"
1033 " Add/Del a Tunnel flow director filter.\n\n"
1035 "flow_director_filter (port_id) mode raw (add|del|update)"
1036 " flow (flow_id) (drop|fwd) queue (queue_id)"
1037 " fd_id (fd_id_value) packet (packet file name)\n"
1038 " Add/Del a raw type flow director filter.\n\n"
1040 "flush_flow_director (port_id)\n"
1041 " Flush all flow director entries of a device.\n\n"
1043 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1044 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1045 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1046 " Set flow director IP mask.\n\n"
1048 "flow_director_mask (port_id) mode MAC-VLAN"
1049 " vlan (vlan_value)\n"
1050 " Set flow director MAC-VLAN mask.\n\n"
1052 "flow_director_mask (port_id) mode Tunnel"
1053 " vlan (vlan_value) mac (mac_value)"
1054 " tunnel-type (tunnel_type_value)"
1055 " tunnel-id (tunnel_id_value)\n"
1056 " Set flow director Tunnel mask.\n\n"
1058 "flow_director_flex_mask (port_id)"
1059 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1060 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1062 " Configure mask of flex payload.\n\n"
1064 "flow_director_flex_payload (port_id)"
1065 " (raw|l2|l3|l4) (config)\n"
1066 " Configure flex payload selection.\n\n"
1068 "get_sym_hash_ena_per_port (port_id)\n"
1069 " get symmetric hash enable configuration per port.\n\n"
1071 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1072 " set symmetric hash enable configuration per port"
1073 " to enable or disable.\n\n"
1075 "get_hash_global_config (port_id)\n"
1076 " Get the global configurations of hash filters.\n\n"
1078 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1079 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1080 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1081 " (enable|disable)\n"
1082 " Set the global configurations of hash filters.\n\n"
1084 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1085 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1086 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1087 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1088 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1089 "ipv6-next-header|udp-src-port|udp-dst-port|"
1090 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1091 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1092 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1093 "fld-8th|none) (select|add)\n"
1094 " Set the input set for hash.\n\n"
1096 "set_fdir_input_set (port_id) "
1097 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1098 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1099 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1100 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1101 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1102 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1103 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1105 " Set the input set for FDir.\n\n"
1107 "flow validate {port_id}"
1108 " [group {group_id}] [priority {level}]"
1109 " [ingress] [egress]"
1110 " pattern {item} [/ {item} [...]] / end"
1111 " actions {action} [/ {action} [...]] / end\n"
1112 " Check whether a flow rule can be created.\n\n"
1114 "flow create {port_id}"
1115 " [group {group_id}] [priority {level}]"
1116 " [ingress] [egress]"
1117 " pattern {item} [/ {item} [...]] / end"
1118 " actions {action} [/ {action} [...]] / end\n"
1119 " Create a flow rule.\n\n"
1121 "flow destroy {port_id} rule {rule_id} [...]\n"
1122 " Destroy specific flow rules.\n\n"
1124 "flow flush {port_id}\n"
1125 " Destroy all flow rules.\n\n"
1127 "flow query {port_id} {rule_id} {action}\n"
1128 " Query an existing flow rule.\n\n"
1130 "flow list {port_id} [group {group_id}] [...]\n"
1131 " List existing flow rules sorted by priority,"
1132 " filtered by group identifiers.\n\n"
1134 "flow isolate {port_id} {boolean}\n"
1135 " Restrict ingress traffic to the defined"
1141 cmdline_parse_token_string_t cmd_help_long_help =
1142 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1144 cmdline_parse_token_string_t cmd_help_long_section =
1145 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1146 "all#control#display#config#"
1147 "ports#registers#filters");
1149 cmdline_parse_inst_t cmd_help_long = {
1150 .f = cmd_help_long_parsed,
1152 .help_str = "help all|control|display|config|ports|register|filters: "
1155 (void *)&cmd_help_long_help,
1156 (void *)&cmd_help_long_section,
1162 /* *** start/stop/close all ports *** */
1163 struct cmd_operate_port_result {
1164 cmdline_fixed_string_t keyword;
1165 cmdline_fixed_string_t name;
1166 cmdline_fixed_string_t value;
1169 static void cmd_operate_port_parsed(void *parsed_result,
1170 __attribute__((unused)) struct cmdline *cl,
1171 __attribute__((unused)) void *data)
1173 struct cmd_operate_port_result *res = parsed_result;
1175 if (!strcmp(res->name, "start"))
1176 start_port(RTE_PORT_ALL);
1177 else if (!strcmp(res->name, "stop"))
1178 stop_port(RTE_PORT_ALL);
1179 else if (!strcmp(res->name, "close"))
1180 close_port(RTE_PORT_ALL);
1181 else if (!strcmp(res->name, "reset"))
1182 reset_port(RTE_PORT_ALL);
1184 printf("Unknown parameter\n");
1187 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1188 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1190 cmdline_parse_token_string_t cmd_operate_port_all_port =
1191 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1192 "start#stop#close#reset");
1193 cmdline_parse_token_string_t cmd_operate_port_all_all =
1194 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1196 cmdline_parse_inst_t cmd_operate_port = {
1197 .f = cmd_operate_port_parsed,
1199 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1201 (void *)&cmd_operate_port_all_cmd,
1202 (void *)&cmd_operate_port_all_port,
1203 (void *)&cmd_operate_port_all_all,
1208 /* *** start/stop/close specific port *** */
1209 struct cmd_operate_specific_port_result {
1210 cmdline_fixed_string_t keyword;
1211 cmdline_fixed_string_t name;
1215 static void cmd_operate_specific_port_parsed(void *parsed_result,
1216 __attribute__((unused)) struct cmdline *cl,
1217 __attribute__((unused)) void *data)
1219 struct cmd_operate_specific_port_result *res = parsed_result;
1221 if (!strcmp(res->name, "start"))
1222 start_port(res->value);
1223 else if (!strcmp(res->name, "stop"))
1224 stop_port(res->value);
1225 else if (!strcmp(res->name, "close"))
1226 close_port(res->value);
1227 else if (!strcmp(res->name, "reset"))
1228 reset_port(res->value);
1230 printf("Unknown parameter\n");
1233 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1234 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1236 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1237 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1238 name, "start#stop#close#reset");
1239 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1240 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1243 cmdline_parse_inst_t cmd_operate_specific_port = {
1244 .f = cmd_operate_specific_port_parsed,
1246 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1248 (void *)&cmd_operate_specific_port_cmd,
1249 (void *)&cmd_operate_specific_port_port,
1250 (void *)&cmd_operate_specific_port_id,
1255 /* *** enable port setup (after attach) via iterator or event *** */
1256 struct cmd_set_port_setup_on_result {
1257 cmdline_fixed_string_t set;
1258 cmdline_fixed_string_t port;
1259 cmdline_fixed_string_t setup;
1260 cmdline_fixed_string_t on;
1261 cmdline_fixed_string_t mode;
1264 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1265 __attribute__((unused)) struct cmdline *cl,
1266 __attribute__((unused)) void *data)
1268 struct cmd_set_port_setup_on_result *res = parsed_result;
1270 if (strcmp(res->mode, "event") == 0)
1271 setup_on_probe_event = true;
1272 else if (strcmp(res->mode, "iterator") == 0)
1273 setup_on_probe_event = false;
1275 printf("Unknown mode\n");
1278 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1279 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1281 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1282 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1284 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1285 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1287 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1288 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1290 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1291 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1292 mode, "iterator#event");
1294 cmdline_parse_inst_t cmd_set_port_setup_on = {
1295 .f = cmd_set_port_setup_on_parsed,
1297 .help_str = "set port setup on iterator|event",
1299 (void *)&cmd_set_port_setup_on_set,
1300 (void *)&cmd_set_port_setup_on_port,
1301 (void *)&cmd_set_port_setup_on_setup,
1302 (void *)&cmd_set_port_setup_on_on,
1303 (void *)&cmd_set_port_setup_on_mode,
1308 /* *** attach a specified port *** */
1309 struct cmd_operate_attach_port_result {
1310 cmdline_fixed_string_t port;
1311 cmdline_fixed_string_t keyword;
1312 cmdline_fixed_string_t identifier;
1315 static void cmd_operate_attach_port_parsed(void *parsed_result,
1316 __attribute__((unused)) struct cmdline *cl,
1317 __attribute__((unused)) void *data)
1319 struct cmd_operate_attach_port_result *res = parsed_result;
1321 if (!strcmp(res->keyword, "attach"))
1322 attach_port(res->identifier);
1324 printf("Unknown parameter\n");
1327 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1328 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1330 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1331 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1333 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1334 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1337 cmdline_parse_inst_t cmd_operate_attach_port = {
1338 .f = cmd_operate_attach_port_parsed,
1340 .help_str = "port attach <identifier>: "
1341 "(identifier: pci address or virtual dev name)",
1343 (void *)&cmd_operate_attach_port_port,
1344 (void *)&cmd_operate_attach_port_keyword,
1345 (void *)&cmd_operate_attach_port_identifier,
1350 /* *** detach a specified port *** */
1351 struct cmd_operate_detach_port_result {
1352 cmdline_fixed_string_t port;
1353 cmdline_fixed_string_t keyword;
1357 static void cmd_operate_detach_port_parsed(void *parsed_result,
1358 __attribute__((unused)) struct cmdline *cl,
1359 __attribute__((unused)) void *data)
1361 struct cmd_operate_detach_port_result *res = parsed_result;
1363 if (!strcmp(res->keyword, "detach"))
1364 detach_port_device(res->port_id);
1366 printf("Unknown parameter\n");
1369 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1370 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1372 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1373 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1375 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1376 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1379 cmdline_parse_inst_t cmd_operate_detach_port = {
1380 .f = cmd_operate_detach_port_parsed,
1382 .help_str = "port detach <port_id>",
1384 (void *)&cmd_operate_detach_port_port,
1385 (void *)&cmd_operate_detach_port_keyword,
1386 (void *)&cmd_operate_detach_port_port_id,
1391 /* *** configure speed for all ports *** */
1392 struct cmd_config_speed_all {
1393 cmdline_fixed_string_t port;
1394 cmdline_fixed_string_t keyword;
1395 cmdline_fixed_string_t all;
1396 cmdline_fixed_string_t item1;
1397 cmdline_fixed_string_t item2;
1398 cmdline_fixed_string_t value1;
1399 cmdline_fixed_string_t value2;
1403 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1408 if (!strcmp(duplexstr, "half")) {
1409 duplex = ETH_LINK_HALF_DUPLEX;
1410 } else if (!strcmp(duplexstr, "full")) {
1411 duplex = ETH_LINK_FULL_DUPLEX;
1412 } else if (!strcmp(duplexstr, "auto")) {
1413 duplex = ETH_LINK_FULL_DUPLEX;
1415 printf("Unknown duplex parameter\n");
1419 if (!strcmp(speedstr, "10")) {
1420 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1421 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1422 } else if (!strcmp(speedstr, "100")) {
1423 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1424 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1426 if (duplex != ETH_LINK_FULL_DUPLEX) {
1427 printf("Invalid speed/duplex parameters\n");
1430 if (!strcmp(speedstr, "1000")) {
1431 *speed = ETH_LINK_SPEED_1G;
1432 } else if (!strcmp(speedstr, "10000")) {
1433 *speed = ETH_LINK_SPEED_10G;
1434 } else if (!strcmp(speedstr, "25000")) {
1435 *speed = ETH_LINK_SPEED_25G;
1436 } else if (!strcmp(speedstr, "40000")) {
1437 *speed = ETH_LINK_SPEED_40G;
1438 } else if (!strcmp(speedstr, "50000")) {
1439 *speed = ETH_LINK_SPEED_50G;
1440 } else if (!strcmp(speedstr, "100000")) {
1441 *speed = ETH_LINK_SPEED_100G;
1442 } else if (!strcmp(speedstr, "auto")) {
1443 *speed = ETH_LINK_SPEED_AUTONEG;
1445 printf("Unknown speed parameter\n");
1454 cmd_config_speed_all_parsed(void *parsed_result,
1455 __attribute__((unused)) struct cmdline *cl,
1456 __attribute__((unused)) void *data)
1458 struct cmd_config_speed_all *res = parsed_result;
1459 uint32_t link_speed;
1462 if (!all_ports_stopped()) {
1463 printf("Please stop all ports first\n");
1467 if (parse_and_check_speed_duplex(res->value1, res->value2,
1471 RTE_ETH_FOREACH_DEV(pid) {
1472 ports[pid].dev_conf.link_speeds = link_speed;
1475 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1478 cmdline_parse_token_string_t cmd_config_speed_all_port =
1479 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1480 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1481 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1483 cmdline_parse_token_string_t cmd_config_speed_all_all =
1484 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1485 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1486 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1487 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1488 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1489 "10#100#1000#10000#25000#40000#50000#100000#auto");
1490 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1491 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1492 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1493 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1496 cmdline_parse_inst_t cmd_config_speed_all = {
1497 .f = cmd_config_speed_all_parsed,
1499 .help_str = "port config all speed "
1500 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1503 (void *)&cmd_config_speed_all_port,
1504 (void *)&cmd_config_speed_all_keyword,
1505 (void *)&cmd_config_speed_all_all,
1506 (void *)&cmd_config_speed_all_item1,
1507 (void *)&cmd_config_speed_all_value1,
1508 (void *)&cmd_config_speed_all_item2,
1509 (void *)&cmd_config_speed_all_value2,
1514 /* *** configure speed for specific port *** */
1515 struct cmd_config_speed_specific {
1516 cmdline_fixed_string_t port;
1517 cmdline_fixed_string_t keyword;
1519 cmdline_fixed_string_t item1;
1520 cmdline_fixed_string_t item2;
1521 cmdline_fixed_string_t value1;
1522 cmdline_fixed_string_t value2;
1526 cmd_config_speed_specific_parsed(void *parsed_result,
1527 __attribute__((unused)) struct cmdline *cl,
1528 __attribute__((unused)) void *data)
1530 struct cmd_config_speed_specific *res = parsed_result;
1531 uint32_t link_speed;
1533 if (!all_ports_stopped()) {
1534 printf("Please stop all ports first\n");
1538 if (port_id_is_invalid(res->id, ENABLED_WARN))
1541 if (parse_and_check_speed_duplex(res->value1, res->value2,
1545 ports[res->id].dev_conf.link_speeds = link_speed;
1547 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1551 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1552 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1554 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1555 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1557 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1558 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1559 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1560 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1562 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1563 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1564 "10#100#1000#10000#25000#40000#50000#100000#auto");
1565 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1566 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1568 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1569 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1572 cmdline_parse_inst_t cmd_config_speed_specific = {
1573 .f = cmd_config_speed_specific_parsed,
1575 .help_str = "port config <port_id> speed "
1576 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1579 (void *)&cmd_config_speed_specific_port,
1580 (void *)&cmd_config_speed_specific_keyword,
1581 (void *)&cmd_config_speed_specific_id,
1582 (void *)&cmd_config_speed_specific_item1,
1583 (void *)&cmd_config_speed_specific_value1,
1584 (void *)&cmd_config_speed_specific_item2,
1585 (void *)&cmd_config_speed_specific_value2,
1590 /* *** configure loopback for all ports *** */
1591 struct cmd_config_loopback_all {
1592 cmdline_fixed_string_t port;
1593 cmdline_fixed_string_t keyword;
1594 cmdline_fixed_string_t all;
1595 cmdline_fixed_string_t item;
1600 cmd_config_loopback_all_parsed(void *parsed_result,
1601 __attribute__((unused)) struct cmdline *cl,
1602 __attribute__((unused)) void *data)
1604 struct cmd_config_loopback_all *res = parsed_result;
1607 if (!all_ports_stopped()) {
1608 printf("Please stop all ports first\n");
1612 RTE_ETH_FOREACH_DEV(pid) {
1613 ports[pid].dev_conf.lpbk_mode = res->mode;
1616 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1619 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1620 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1621 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1622 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1624 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1625 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1626 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1627 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1629 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1630 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1632 cmdline_parse_inst_t cmd_config_loopback_all = {
1633 .f = cmd_config_loopback_all_parsed,
1635 .help_str = "port config all loopback <mode>",
1637 (void *)&cmd_config_loopback_all_port,
1638 (void *)&cmd_config_loopback_all_keyword,
1639 (void *)&cmd_config_loopback_all_all,
1640 (void *)&cmd_config_loopback_all_item,
1641 (void *)&cmd_config_loopback_all_mode,
1646 /* *** configure loopback for specific port *** */
1647 struct cmd_config_loopback_specific {
1648 cmdline_fixed_string_t port;
1649 cmdline_fixed_string_t keyword;
1651 cmdline_fixed_string_t item;
1656 cmd_config_loopback_specific_parsed(void *parsed_result,
1657 __attribute__((unused)) struct cmdline *cl,
1658 __attribute__((unused)) void *data)
1660 struct cmd_config_loopback_specific *res = parsed_result;
1662 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1665 if (!port_is_stopped(res->port_id)) {
1666 printf("Please stop port %u first\n", res->port_id);
1670 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1672 cmd_reconfig_device_queue(res->port_id, 1, 1);
1676 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1677 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1679 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1680 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1682 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1683 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1685 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1686 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1688 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1689 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1692 cmdline_parse_inst_t cmd_config_loopback_specific = {
1693 .f = cmd_config_loopback_specific_parsed,
1695 .help_str = "port config <port_id> loopback <mode>",
1697 (void *)&cmd_config_loopback_specific_port,
1698 (void *)&cmd_config_loopback_specific_keyword,
1699 (void *)&cmd_config_loopback_specific_id,
1700 (void *)&cmd_config_loopback_specific_item,
1701 (void *)&cmd_config_loopback_specific_mode,
1706 /* *** configure txq/rxq, txd/rxd *** */
1707 struct cmd_config_rx_tx {
1708 cmdline_fixed_string_t port;
1709 cmdline_fixed_string_t keyword;
1710 cmdline_fixed_string_t all;
1711 cmdline_fixed_string_t name;
1716 cmd_config_rx_tx_parsed(void *parsed_result,
1717 __attribute__((unused)) struct cmdline *cl,
1718 __attribute__((unused)) void *data)
1720 struct cmd_config_rx_tx *res = parsed_result;
1722 if (!all_ports_stopped()) {
1723 printf("Please stop all ports first\n");
1726 if (!strcmp(res->name, "rxq")) {
1727 if (!res->value && !nb_txq) {
1728 printf("Warning: Either rx or tx queues should be non zero\n");
1731 if (check_nb_rxq(res->value) != 0)
1733 nb_rxq = res->value;
1735 else if (!strcmp(res->name, "txq")) {
1736 if (!res->value && !nb_rxq) {
1737 printf("Warning: Either rx or tx queues should be non zero\n");
1740 if (check_nb_txq(res->value) != 0)
1742 nb_txq = res->value;
1744 else if (!strcmp(res->name, "rxd")) {
1745 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1746 printf("rxd %d invalid - must be > 0 && <= %d\n",
1747 res->value, RTE_TEST_RX_DESC_MAX);
1750 nb_rxd = res->value;
1751 } else if (!strcmp(res->name, "txd")) {
1752 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1753 printf("txd %d invalid - must be > 0 && <= %d\n",
1754 res->value, RTE_TEST_TX_DESC_MAX);
1757 nb_txd = res->value;
1759 printf("Unknown parameter\n");
1767 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1770 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1771 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1772 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1773 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1774 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1775 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1776 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1777 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1779 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1780 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1782 cmdline_parse_inst_t cmd_config_rx_tx = {
1783 .f = cmd_config_rx_tx_parsed,
1785 .help_str = "port config all rxq|txq|rxd|txd <value>",
1787 (void *)&cmd_config_rx_tx_port,
1788 (void *)&cmd_config_rx_tx_keyword,
1789 (void *)&cmd_config_rx_tx_all,
1790 (void *)&cmd_config_rx_tx_name,
1791 (void *)&cmd_config_rx_tx_value,
1796 /* *** config max packet length *** */
1797 struct cmd_config_max_pkt_len_result {
1798 cmdline_fixed_string_t port;
1799 cmdline_fixed_string_t keyword;
1800 cmdline_fixed_string_t all;
1801 cmdline_fixed_string_t name;
1806 cmd_config_max_pkt_len_parsed(void *parsed_result,
1807 __attribute__((unused)) struct cmdline *cl,
1808 __attribute__((unused)) void *data)
1810 struct cmd_config_max_pkt_len_result *res = parsed_result;
1813 if (!all_ports_stopped()) {
1814 printf("Please stop all ports first\n");
1818 RTE_ETH_FOREACH_DEV(pid) {
1819 struct rte_port *port = &ports[pid];
1820 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1822 if (!strcmp(res->name, "max-pkt-len")) {
1823 if (res->value < ETHER_MIN_LEN) {
1824 printf("max-pkt-len can not be less than %d\n",
1828 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1831 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1832 if (res->value > ETHER_MAX_LEN)
1833 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1835 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1836 port->dev_conf.rxmode.offloads = rx_offloads;
1838 printf("Unknown parameter\n");
1845 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1848 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1849 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1851 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1852 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1854 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1855 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1857 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1858 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1860 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1861 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1864 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1865 .f = cmd_config_max_pkt_len_parsed,
1867 .help_str = "port config all max-pkt-len <value>",
1869 (void *)&cmd_config_max_pkt_len_port,
1870 (void *)&cmd_config_max_pkt_len_keyword,
1871 (void *)&cmd_config_max_pkt_len_all,
1872 (void *)&cmd_config_max_pkt_len_name,
1873 (void *)&cmd_config_max_pkt_len_value,
1878 /* *** configure port MTU *** */
1879 struct cmd_config_mtu_result {
1880 cmdline_fixed_string_t port;
1881 cmdline_fixed_string_t keyword;
1882 cmdline_fixed_string_t mtu;
1888 cmd_config_mtu_parsed(void *parsed_result,
1889 __attribute__((unused)) struct cmdline *cl,
1890 __attribute__((unused)) void *data)
1892 struct cmd_config_mtu_result *res = parsed_result;
1894 if (res->value < ETHER_MIN_LEN) {
1895 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1898 port_mtu_set(res->port_id, res->value);
1901 cmdline_parse_token_string_t cmd_config_mtu_port =
1902 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1904 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1905 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1907 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1908 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1910 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1911 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1912 cmdline_parse_token_num_t cmd_config_mtu_value =
1913 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1915 cmdline_parse_inst_t cmd_config_mtu = {
1916 .f = cmd_config_mtu_parsed,
1918 .help_str = "port config mtu <port_id> <value>",
1920 (void *)&cmd_config_mtu_port,
1921 (void *)&cmd_config_mtu_keyword,
1922 (void *)&cmd_config_mtu_mtu,
1923 (void *)&cmd_config_mtu_port_id,
1924 (void *)&cmd_config_mtu_value,
1929 /* *** configure rx mode *** */
1930 struct cmd_config_rx_mode_flag {
1931 cmdline_fixed_string_t port;
1932 cmdline_fixed_string_t keyword;
1933 cmdline_fixed_string_t all;
1934 cmdline_fixed_string_t name;
1935 cmdline_fixed_string_t value;
1939 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1940 __attribute__((unused)) struct cmdline *cl,
1941 __attribute__((unused)) void *data)
1943 struct cmd_config_rx_mode_flag *res = parsed_result;
1946 if (!all_ports_stopped()) {
1947 printf("Please stop all ports first\n");
1951 RTE_ETH_FOREACH_DEV(pid) {
1952 struct rte_port *port;
1953 uint64_t rx_offloads;
1956 rx_offloads = port->dev_conf.rxmode.offloads;
1957 if (!strcmp(res->name, "crc-strip")) {
1958 if (!strcmp(res->value, "on")) {
1959 rx_offloads &= ~DEV_RX_OFFLOAD_KEEP_CRC;
1960 } else if (!strcmp(res->value, "off")) {
1961 rx_offloads |= DEV_RX_OFFLOAD_KEEP_CRC;
1963 printf("Unknown parameter\n");
1966 } else if (!strcmp(res->name, "scatter")) {
1967 if (!strcmp(res->value, "on")) {
1968 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1969 } else if (!strcmp(res->value, "off")) {
1970 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1972 printf("Unknown parameter\n");
1975 } else if (!strcmp(res->name, "rx-cksum")) {
1976 if (!strcmp(res->value, "on"))
1977 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1978 else if (!strcmp(res->value, "off"))
1979 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1981 printf("Unknown parameter\n");
1984 } else if (!strcmp(res->name, "rx-timestamp")) {
1985 if (!strcmp(res->value, "on"))
1986 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1987 else if (!strcmp(res->value, "off"))
1988 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1990 printf("Unknown parameter\n");
1993 } else if (!strcmp(res->name, "hw-vlan")) {
1994 if (!strcmp(res->value, "on")) {
1995 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1996 DEV_RX_OFFLOAD_VLAN_STRIP);
1997 } else if (!strcmp(res->value, "off")) {
1998 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1999 DEV_RX_OFFLOAD_VLAN_STRIP);
2001 printf("Unknown parameter\n");
2004 } else if (!strcmp(res->name, "hw-vlan-filter")) {
2005 if (!strcmp(res->value, "on"))
2006 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
2007 else if (!strcmp(res->value, "off"))
2008 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
2010 printf("Unknown parameter\n");
2013 } else if (!strcmp(res->name, "hw-vlan-strip")) {
2014 if (!strcmp(res->value, "on"))
2015 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
2016 else if (!strcmp(res->value, "off"))
2017 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
2019 printf("Unknown parameter\n");
2022 } else if (!strcmp(res->name, "hw-vlan-extend")) {
2023 if (!strcmp(res->value, "on"))
2024 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
2025 else if (!strcmp(res->value, "off"))
2026 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
2028 printf("Unknown parameter\n");
2031 } else if (!strcmp(res->name, "drop-en")) {
2032 if (!strcmp(res->value, "on"))
2034 else if (!strcmp(res->value, "off"))
2037 printf("Unknown parameter\n");
2041 printf("Unknown parameter\n");
2044 port->dev_conf.rxmode.offloads = rx_offloads;
2049 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2052 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2053 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2054 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2055 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2057 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2058 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2059 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2060 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2061 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
2062 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
2063 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2064 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2067 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2068 .f = cmd_config_rx_mode_flag_parsed,
2070 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
2071 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
2073 (void *)&cmd_config_rx_mode_flag_port,
2074 (void *)&cmd_config_rx_mode_flag_keyword,
2075 (void *)&cmd_config_rx_mode_flag_all,
2076 (void *)&cmd_config_rx_mode_flag_name,
2077 (void *)&cmd_config_rx_mode_flag_value,
2082 /* *** configure rss *** */
2083 struct cmd_config_rss {
2084 cmdline_fixed_string_t port;
2085 cmdline_fixed_string_t keyword;
2086 cmdline_fixed_string_t all;
2087 cmdline_fixed_string_t name;
2088 cmdline_fixed_string_t value;
2092 cmd_config_rss_parsed(void *parsed_result,
2093 __attribute__((unused)) struct cmdline *cl,
2094 __attribute__((unused)) void *data)
2096 struct cmd_config_rss *res = parsed_result;
2097 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2098 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2099 int use_default = 0;
2100 int all_updated = 1;
2104 if (!strcmp(res->value, "all"))
2105 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2106 ETH_RSS_UDP | ETH_RSS_SCTP |
2108 else if (!strcmp(res->value, "ip"))
2109 rss_conf.rss_hf = ETH_RSS_IP;
2110 else if (!strcmp(res->value, "udp"))
2111 rss_conf.rss_hf = ETH_RSS_UDP;
2112 else if (!strcmp(res->value, "tcp"))
2113 rss_conf.rss_hf = ETH_RSS_TCP;
2114 else if (!strcmp(res->value, "sctp"))
2115 rss_conf.rss_hf = ETH_RSS_SCTP;
2116 else if (!strcmp(res->value, "ether"))
2117 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2118 else if (!strcmp(res->value, "port"))
2119 rss_conf.rss_hf = ETH_RSS_PORT;
2120 else if (!strcmp(res->value, "vxlan"))
2121 rss_conf.rss_hf = ETH_RSS_VXLAN;
2122 else if (!strcmp(res->value, "geneve"))
2123 rss_conf.rss_hf = ETH_RSS_GENEVE;
2124 else if (!strcmp(res->value, "nvgre"))
2125 rss_conf.rss_hf = ETH_RSS_NVGRE;
2126 else if (!strcmp(res->value, "none"))
2127 rss_conf.rss_hf = 0;
2128 else if (!strcmp(res->value, "default"))
2130 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2131 atoi(res->value) < 64)
2132 rss_conf.rss_hf = 1ULL << atoi(res->value);
2134 printf("Unknown parameter\n");
2137 rss_conf.rss_key = NULL;
2138 /* Update global configuration for RSS types. */
2139 RTE_ETH_FOREACH_DEV(i) {
2140 struct rte_eth_rss_conf local_rss_conf;
2142 rte_eth_dev_info_get(i, &dev_info);
2144 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2146 local_rss_conf = rss_conf;
2147 local_rss_conf.rss_hf = rss_conf.rss_hf &
2148 dev_info.flow_type_rss_offloads;
2149 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2150 printf("Port %u modified RSS hash function based on hardware support,"
2151 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2152 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2154 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2157 printf("Configuration of RSS hash at ethernet port %d "
2158 "failed with error (%d): %s.\n",
2159 i, -diag, strerror(-diag));
2162 if (all_updated && !use_default)
2163 rss_hf = rss_conf.rss_hf;
2166 cmdline_parse_token_string_t cmd_config_rss_port =
2167 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2168 cmdline_parse_token_string_t cmd_config_rss_keyword =
2169 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2170 cmdline_parse_token_string_t cmd_config_rss_all =
2171 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2172 cmdline_parse_token_string_t cmd_config_rss_name =
2173 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2174 cmdline_parse_token_string_t cmd_config_rss_value =
2175 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2177 cmdline_parse_inst_t cmd_config_rss = {
2178 .f = cmd_config_rss_parsed,
2180 .help_str = "port config all rss "
2181 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
2183 (void *)&cmd_config_rss_port,
2184 (void *)&cmd_config_rss_keyword,
2185 (void *)&cmd_config_rss_all,
2186 (void *)&cmd_config_rss_name,
2187 (void *)&cmd_config_rss_value,
2192 /* *** configure rss hash key *** */
2193 struct cmd_config_rss_hash_key {
2194 cmdline_fixed_string_t port;
2195 cmdline_fixed_string_t config;
2197 cmdline_fixed_string_t rss_hash_key;
2198 cmdline_fixed_string_t rss_type;
2199 cmdline_fixed_string_t key;
2203 hexa_digit_to_value(char hexa_digit)
2205 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2206 return (uint8_t) (hexa_digit - '0');
2207 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2208 return (uint8_t) ((hexa_digit - 'a') + 10);
2209 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2210 return (uint8_t) ((hexa_digit - 'A') + 10);
2211 /* Invalid hexa digit */
2216 parse_and_check_key_hexa_digit(char *key, int idx)
2220 hexa_v = hexa_digit_to_value(key[idx]);
2222 printf("invalid key: character %c at position %d is not a "
2223 "valid hexa digit\n", key[idx], idx);
2228 cmd_config_rss_hash_key_parsed(void *parsed_result,
2229 __attribute__((unused)) struct cmdline *cl,
2230 __attribute__((unused)) void *data)
2232 struct cmd_config_rss_hash_key *res = parsed_result;
2233 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2237 struct rte_eth_dev_info dev_info;
2238 uint8_t hash_key_size;
2241 memset(&dev_info, 0, sizeof(dev_info));
2242 rte_eth_dev_info_get(res->port_id, &dev_info);
2243 if (dev_info.hash_key_size > 0 &&
2244 dev_info.hash_key_size <= sizeof(hash_key))
2245 hash_key_size = dev_info.hash_key_size;
2247 printf("dev_info did not provide a valid hash key size\n");
2250 /* Check the length of the RSS hash key */
2251 key_len = strlen(res->key);
2252 if (key_len != (hash_key_size * 2)) {
2253 printf("key length: %d invalid - key must be a string of %d"
2254 " hexa-decimal numbers\n",
2255 (int) key_len, hash_key_size * 2);
2258 /* Translate RSS hash key into binary representation */
2259 for (i = 0; i < hash_key_size; i++) {
2260 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2263 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2266 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2268 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2272 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2273 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2274 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2275 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2277 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2278 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2279 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2280 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2281 rss_hash_key, "rss-hash-key");
2282 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2283 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2284 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2285 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2286 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2287 "ipv6-tcp-ex#ipv6-udp-ex");
2288 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2289 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2291 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2292 .f = cmd_config_rss_hash_key_parsed,
2294 .help_str = "port config <port_id> rss-hash-key "
2295 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2296 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2297 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2298 "<string of hex digits (variable length, NIC dependent)>",
2300 (void *)&cmd_config_rss_hash_key_port,
2301 (void *)&cmd_config_rss_hash_key_config,
2302 (void *)&cmd_config_rss_hash_key_port_id,
2303 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2304 (void *)&cmd_config_rss_hash_key_rss_type,
2305 (void *)&cmd_config_rss_hash_key_value,
2310 /* *** configure port rxq/txq ring size *** */
2311 struct cmd_config_rxtx_ring_size {
2312 cmdline_fixed_string_t port;
2313 cmdline_fixed_string_t config;
2315 cmdline_fixed_string_t rxtxq;
2317 cmdline_fixed_string_t rsize;
2322 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2323 __attribute__((unused)) struct cmdline *cl,
2324 __attribute__((unused)) void *data)
2326 struct cmd_config_rxtx_ring_size *res = parsed_result;
2327 struct rte_port *port;
2330 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2333 if (res->portid == (portid_t)RTE_PORT_ALL) {
2334 printf("Invalid port id\n");
2338 port = &ports[res->portid];
2340 if (!strcmp(res->rxtxq, "rxq"))
2342 else if (!strcmp(res->rxtxq, "txq"))
2345 printf("Unknown parameter\n");
2349 if (isrx && rx_queue_id_is_invalid(res->qid))
2351 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2354 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2355 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2361 port->nb_rx_desc[res->qid] = res->size;
2363 port->nb_tx_desc[res->qid] = res->size;
2365 cmd_reconfig_device_queue(res->portid, 0, 1);
2368 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2369 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2371 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2372 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2374 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2375 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2377 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2378 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2380 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2381 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2383 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2384 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2385 rsize, "ring_size");
2386 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2387 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2390 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2391 .f = cmd_config_rxtx_ring_size_parsed,
2393 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2395 (void *)&cmd_config_rxtx_ring_size_port,
2396 (void *)&cmd_config_rxtx_ring_size_config,
2397 (void *)&cmd_config_rxtx_ring_size_portid,
2398 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2399 (void *)&cmd_config_rxtx_ring_size_qid,
2400 (void *)&cmd_config_rxtx_ring_size_rsize,
2401 (void *)&cmd_config_rxtx_ring_size_size,
2406 /* *** configure port rxq/txq start/stop *** */
2407 struct cmd_config_rxtx_queue {
2408 cmdline_fixed_string_t port;
2410 cmdline_fixed_string_t rxtxq;
2412 cmdline_fixed_string_t opname;
2416 cmd_config_rxtx_queue_parsed(void *parsed_result,
2417 __attribute__((unused)) struct cmdline *cl,
2418 __attribute__((unused)) void *data)
2420 struct cmd_config_rxtx_queue *res = parsed_result;
2425 if (test_done == 0) {
2426 printf("Please stop forwarding first\n");
2430 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2433 if (port_is_started(res->portid) != 1) {
2434 printf("Please start port %u first\n", res->portid);
2438 if (!strcmp(res->rxtxq, "rxq"))
2440 else if (!strcmp(res->rxtxq, "txq"))
2443 printf("Unknown parameter\n");
2447 if (isrx && rx_queue_id_is_invalid(res->qid))
2449 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2452 if (!strcmp(res->opname, "start"))
2454 else if (!strcmp(res->opname, "stop"))
2457 printf("Unknown parameter\n");
2461 if (isstart && isrx)
2462 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2463 else if (!isstart && isrx)
2464 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2465 else if (isstart && !isrx)
2466 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2468 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2470 if (ret == -ENOTSUP)
2471 printf("Function not supported in PMD driver\n");
2474 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2475 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2476 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2477 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2478 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2479 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2480 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2481 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2482 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2483 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2486 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2487 .f = cmd_config_rxtx_queue_parsed,
2489 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2491 (void *)&cmd_config_rxtx_queue_port,
2492 (void *)&cmd_config_rxtx_queue_portid,
2493 (void *)&cmd_config_rxtx_queue_rxtxq,
2494 (void *)&cmd_config_rxtx_queue_qid,
2495 (void *)&cmd_config_rxtx_queue_opname,
2500 /* *** configure port rxq/txq deferred start on/off *** */
2501 struct cmd_config_deferred_start_rxtx_queue {
2502 cmdline_fixed_string_t port;
2504 cmdline_fixed_string_t rxtxq;
2506 cmdline_fixed_string_t opname;
2507 cmdline_fixed_string_t state;
2511 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2512 __attribute__((unused)) struct cmdline *cl,
2513 __attribute__((unused)) void *data)
2515 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2516 struct rte_port *port;
2519 uint8_t needreconfig = 0;
2521 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2524 if (port_is_started(res->port_id) != 0) {
2525 printf("Please stop port %u first\n", res->port_id);
2529 port = &ports[res->port_id];
2531 isrx = !strcmp(res->rxtxq, "rxq");
2533 if (isrx && rx_queue_id_is_invalid(res->qid))
2535 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2538 ison = !strcmp(res->state, "on");
2540 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2541 port->rx_conf[res->qid].rx_deferred_start = ison;
2543 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2544 port->tx_conf[res->qid].tx_deferred_start = ison;
2549 cmd_reconfig_device_queue(res->port_id, 0, 1);
2552 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2553 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2555 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2556 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2558 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2559 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2561 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2562 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2564 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2565 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2566 opname, "deferred_start");
2567 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2568 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2571 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2572 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2574 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2576 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2577 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2578 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2579 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2580 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2581 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2586 /* *** configure port rxq/txq setup *** */
2587 struct cmd_setup_rxtx_queue {
2588 cmdline_fixed_string_t port;
2590 cmdline_fixed_string_t rxtxq;
2592 cmdline_fixed_string_t setup;
2595 /* Common CLI fields for queue setup */
2596 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2597 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2598 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2599 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2600 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2601 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2602 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2603 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2604 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2605 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2608 cmd_setup_rxtx_queue_parsed(
2609 void *parsed_result,
2610 __attribute__((unused)) struct cmdline *cl,
2611 __attribute__((unused)) void *data)
2613 struct cmd_setup_rxtx_queue *res = parsed_result;
2614 struct rte_port *port;
2615 struct rte_mempool *mp;
2616 unsigned int socket_id;
2620 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2623 if (res->portid == (portid_t)RTE_PORT_ALL) {
2624 printf("Invalid port id\n");
2628 if (!strcmp(res->rxtxq, "rxq"))
2630 else if (!strcmp(res->rxtxq, "txq"))
2633 printf("Unknown parameter\n");
2637 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2638 printf("Invalid rx queue\n");
2640 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2641 printf("Invalid tx queue\n");
2645 port = &ports[res->portid];
2647 socket_id = rxring_numa[res->portid];
2648 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2649 socket_id = port->socket_id;
2651 mp = mbuf_pool_find(socket_id);
2653 printf("Failed to setup RX queue: "
2654 "No mempool allocation"
2655 " on the socket %d\n",
2656 rxring_numa[res->portid]);
2659 ret = rte_eth_rx_queue_setup(res->portid,
2661 port->nb_rx_desc[res->qid],
2663 &port->rx_conf[res->qid],
2666 printf("Failed to setup RX queue\n");
2668 socket_id = txring_numa[res->portid];
2669 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2670 socket_id = port->socket_id;
2672 ret = rte_eth_tx_queue_setup(res->portid,
2674 port->nb_tx_desc[res->qid],
2676 &port->tx_conf[res->qid]);
2678 printf("Failed to setup TX queue\n");
2682 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2683 .f = cmd_setup_rxtx_queue_parsed,
2685 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2687 (void *)&cmd_setup_rxtx_queue_port,
2688 (void *)&cmd_setup_rxtx_queue_portid,
2689 (void *)&cmd_setup_rxtx_queue_rxtxq,
2690 (void *)&cmd_setup_rxtx_queue_qid,
2691 (void *)&cmd_setup_rxtx_queue_setup,
2697 /* *** Configure RSS RETA *** */
2698 struct cmd_config_rss_reta {
2699 cmdline_fixed_string_t port;
2700 cmdline_fixed_string_t keyword;
2702 cmdline_fixed_string_t name;
2703 cmdline_fixed_string_t list_name;
2704 cmdline_fixed_string_t list_of_items;
2708 parse_reta_config(const char *str,
2709 struct rte_eth_rss_reta_entry64 *reta_conf,
2710 uint16_t nb_entries)
2714 uint16_t hash_index, idx, shift;
2717 const char *p, *p0 = str;
2724 unsigned long int_fld[_NUM_FLD];
2725 char *str_fld[_NUM_FLD];
2727 while ((p = strchr(p0,'(')) != NULL) {
2729 if((p0 = strchr(p,')')) == NULL)
2733 if(size >= sizeof(s))
2736 snprintf(s, sizeof(s), "%.*s", size, p);
2737 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2739 for (i = 0; i < _NUM_FLD; i++) {
2741 int_fld[i] = strtoul(str_fld[i], &end, 0);
2742 if (errno != 0 || end == str_fld[i] ||
2747 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2748 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2750 if (hash_index >= nb_entries) {
2751 printf("Invalid RETA hash index=%d\n", hash_index);
2755 idx = hash_index / RTE_RETA_GROUP_SIZE;
2756 shift = hash_index % RTE_RETA_GROUP_SIZE;
2757 reta_conf[idx].mask |= (1ULL << shift);
2758 reta_conf[idx].reta[shift] = nb_queue;
2765 cmd_set_rss_reta_parsed(void *parsed_result,
2766 __attribute__((unused)) struct cmdline *cl,
2767 __attribute__((unused)) void *data)
2770 struct rte_eth_dev_info dev_info;
2771 struct rte_eth_rss_reta_entry64 reta_conf[8];
2772 struct cmd_config_rss_reta *res = parsed_result;
2774 memset(&dev_info, 0, sizeof(dev_info));
2775 rte_eth_dev_info_get(res->port_id, &dev_info);
2776 if (dev_info.reta_size == 0) {
2777 printf("Redirection table size is 0 which is "
2778 "invalid for RSS\n");
2781 printf("The reta size of port %d is %u\n",
2782 res->port_id, dev_info.reta_size);
2783 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2784 printf("Currently do not support more than %u entries of "
2785 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2789 memset(reta_conf, 0, sizeof(reta_conf));
2790 if (!strcmp(res->list_name, "reta")) {
2791 if (parse_reta_config(res->list_of_items, reta_conf,
2792 dev_info.reta_size)) {
2793 printf("Invalid RSS Redirection Table "
2794 "config entered\n");
2797 ret = rte_eth_dev_rss_reta_update(res->port_id,
2798 reta_conf, dev_info.reta_size);
2800 printf("Bad redirection table parameter, "
2801 "return code = %d \n", ret);
2805 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2806 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2807 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2808 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2809 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2810 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2811 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2812 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2813 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2814 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2815 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2816 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2818 cmdline_parse_inst_t cmd_config_rss_reta = {
2819 .f = cmd_set_rss_reta_parsed,
2821 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2823 (void *)&cmd_config_rss_reta_port,
2824 (void *)&cmd_config_rss_reta_keyword,
2825 (void *)&cmd_config_rss_reta_port_id,
2826 (void *)&cmd_config_rss_reta_name,
2827 (void *)&cmd_config_rss_reta_list_name,
2828 (void *)&cmd_config_rss_reta_list_of_items,
2833 /* *** SHOW PORT RETA INFO *** */
2834 struct cmd_showport_reta {
2835 cmdline_fixed_string_t show;
2836 cmdline_fixed_string_t port;
2838 cmdline_fixed_string_t rss;
2839 cmdline_fixed_string_t reta;
2841 cmdline_fixed_string_t list_of_items;
2845 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2846 uint16_t nb_entries,
2850 const char *p, *p0 = str;
2855 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2856 RTE_RETA_GROUP_SIZE;
2859 p = strchr(p0, '(');
2863 p0 = strchr(p, ')');
2867 if (size >= sizeof(s)) {
2868 printf("The string size exceeds the internal buffer size\n");
2871 snprintf(s, sizeof(s), "%.*s", size, p);
2872 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2873 if (ret <= 0 || ret != num) {
2874 printf("The bits of masks do not match the number of "
2875 "reta entries: %u\n", num);
2878 for (i = 0; i < ret; i++)
2879 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2885 cmd_showport_reta_parsed(void *parsed_result,
2886 __attribute__((unused)) struct cmdline *cl,
2887 __attribute__((unused)) void *data)
2889 struct cmd_showport_reta *res = parsed_result;
2890 struct rte_eth_rss_reta_entry64 reta_conf[8];
2891 struct rte_eth_dev_info dev_info;
2892 uint16_t max_reta_size;
2894 memset(&dev_info, 0, sizeof(dev_info));
2895 rte_eth_dev_info_get(res->port_id, &dev_info);
2896 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2897 if (res->size == 0 || res->size > max_reta_size) {
2898 printf("Invalid redirection table size: %u (1-%u)\n",
2899 res->size, max_reta_size);
2903 memset(reta_conf, 0, sizeof(reta_conf));
2904 if (showport_parse_reta_config(reta_conf, res->size,
2905 res->list_of_items) < 0) {
2906 printf("Invalid string: %s for reta masks\n",
2907 res->list_of_items);
2910 port_rss_reta_info(res->port_id, reta_conf, res->size);
2913 cmdline_parse_token_string_t cmd_showport_reta_show =
2914 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2915 cmdline_parse_token_string_t cmd_showport_reta_port =
2916 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2917 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2918 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2919 cmdline_parse_token_string_t cmd_showport_reta_rss =
2920 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2921 cmdline_parse_token_string_t cmd_showport_reta_reta =
2922 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2923 cmdline_parse_token_num_t cmd_showport_reta_size =
2924 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2925 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2926 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2927 list_of_items, NULL);
2929 cmdline_parse_inst_t cmd_showport_reta = {
2930 .f = cmd_showport_reta_parsed,
2932 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2934 (void *)&cmd_showport_reta_show,
2935 (void *)&cmd_showport_reta_port,
2936 (void *)&cmd_showport_reta_port_id,
2937 (void *)&cmd_showport_reta_rss,
2938 (void *)&cmd_showport_reta_reta,
2939 (void *)&cmd_showport_reta_size,
2940 (void *)&cmd_showport_reta_list_of_items,
2945 /* *** Show RSS hash configuration *** */
2946 struct cmd_showport_rss_hash {
2947 cmdline_fixed_string_t show;
2948 cmdline_fixed_string_t port;
2950 cmdline_fixed_string_t rss_hash;
2951 cmdline_fixed_string_t rss_type;
2952 cmdline_fixed_string_t key; /* optional argument */
2955 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2956 __attribute__((unused)) struct cmdline *cl,
2959 struct cmd_showport_rss_hash *res = parsed_result;
2961 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
2964 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2965 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2966 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2967 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2968 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2969 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2970 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2971 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2973 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2974 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2976 cmdline_parse_inst_t cmd_showport_rss_hash = {
2977 .f = cmd_showport_rss_hash_parsed,
2979 .help_str = "show port <port_id> rss-hash",
2981 (void *)&cmd_showport_rss_hash_show,
2982 (void *)&cmd_showport_rss_hash_port,
2983 (void *)&cmd_showport_rss_hash_port_id,
2984 (void *)&cmd_showport_rss_hash_rss_hash,
2989 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2990 .f = cmd_showport_rss_hash_parsed,
2992 .help_str = "show port <port_id> rss-hash key",
2994 (void *)&cmd_showport_rss_hash_show,
2995 (void *)&cmd_showport_rss_hash_port,
2996 (void *)&cmd_showport_rss_hash_port_id,
2997 (void *)&cmd_showport_rss_hash_rss_hash,
2998 (void *)&cmd_showport_rss_hash_rss_key,
3003 /* *** Configure DCB *** */
3004 struct cmd_config_dcb {
3005 cmdline_fixed_string_t port;
3006 cmdline_fixed_string_t config;
3008 cmdline_fixed_string_t dcb;
3009 cmdline_fixed_string_t vt;
3010 cmdline_fixed_string_t vt_en;
3012 cmdline_fixed_string_t pfc;
3013 cmdline_fixed_string_t pfc_en;
3017 cmd_config_dcb_parsed(void *parsed_result,
3018 __attribute__((unused)) struct cmdline *cl,
3019 __attribute__((unused)) void *data)
3021 struct cmd_config_dcb *res = parsed_result;
3022 portid_t port_id = res->port_id;
3023 struct rte_port *port;
3027 port = &ports[port_id];
3028 /** Check if the port is not started **/
3029 if (port->port_status != RTE_PORT_STOPPED) {
3030 printf("Please stop port %d first\n", port_id);
3034 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3035 printf("The invalid number of traffic class,"
3036 " only 4 or 8 allowed.\n");
3040 if (nb_fwd_lcores < res->num_tcs) {
3041 printf("nb_cores shouldn't be less than number of TCs.\n");
3044 if (!strncmp(res->pfc_en, "on", 2))
3049 /* DCB in VT mode */
3050 if (!strncmp(res->vt_en, "on", 2))
3051 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3052 (enum rte_eth_nb_tcs)res->num_tcs,
3055 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3056 (enum rte_eth_nb_tcs)res->num_tcs,
3061 printf("Cannot initialize network ports.\n");
3065 cmd_reconfig_device_queue(port_id, 1, 1);
3068 cmdline_parse_token_string_t cmd_config_dcb_port =
3069 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3070 cmdline_parse_token_string_t cmd_config_dcb_config =
3071 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3072 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3073 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3074 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3075 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3076 cmdline_parse_token_string_t cmd_config_dcb_vt =
3077 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3078 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3079 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3080 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3081 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3082 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3083 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3084 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3085 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3087 cmdline_parse_inst_t cmd_config_dcb = {
3088 .f = cmd_config_dcb_parsed,
3090 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3092 (void *)&cmd_config_dcb_port,
3093 (void *)&cmd_config_dcb_config,
3094 (void *)&cmd_config_dcb_port_id,
3095 (void *)&cmd_config_dcb_dcb,
3096 (void *)&cmd_config_dcb_vt,
3097 (void *)&cmd_config_dcb_vt_en,
3098 (void *)&cmd_config_dcb_num_tcs,
3099 (void *)&cmd_config_dcb_pfc,
3100 (void *)&cmd_config_dcb_pfc_en,
3105 /* *** configure number of packets per burst *** */
3106 struct cmd_config_burst {
3107 cmdline_fixed_string_t port;
3108 cmdline_fixed_string_t keyword;
3109 cmdline_fixed_string_t all;
3110 cmdline_fixed_string_t name;
3115 cmd_config_burst_parsed(void *parsed_result,
3116 __attribute__((unused)) struct cmdline *cl,
3117 __attribute__((unused)) void *data)
3119 struct cmd_config_burst *res = parsed_result;
3120 struct rte_eth_dev_info dev_info;
3121 uint16_t rec_nb_pkts;
3123 if (!all_ports_stopped()) {
3124 printf("Please stop all ports first\n");
3128 if (!strcmp(res->name, "burst")) {
3129 if (res->value == 0) {
3130 /* If user gives a value of zero, query the PMD for
3131 * its recommended Rx burst size. Testpmd uses a single
3132 * size for all ports, so assume all ports are the same
3133 * NIC model and use the values from Port 0.
3135 rte_eth_dev_info_get(0, &dev_info);
3136 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3138 if (rec_nb_pkts == 0) {
3139 printf("PMD does not recommend a burst size.\n"
3140 "User provided value must be between"
3141 " 1 and %d\n", MAX_PKT_BURST);
3143 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3144 printf("PMD recommended burst size of %d"
3145 " exceeds maximum value of %d\n",
3146 rec_nb_pkts, MAX_PKT_BURST);
3149 printf("Using PMD-provided burst value of %d\n",
3151 nb_pkt_per_burst = rec_nb_pkts;
3152 } else if (res->value > MAX_PKT_BURST) {
3153 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3156 nb_pkt_per_burst = res->value;
3158 printf("Unknown parameter\n");
3164 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3167 cmdline_parse_token_string_t cmd_config_burst_port =
3168 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3169 cmdline_parse_token_string_t cmd_config_burst_keyword =
3170 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3171 cmdline_parse_token_string_t cmd_config_burst_all =
3172 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3173 cmdline_parse_token_string_t cmd_config_burst_name =
3174 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3175 cmdline_parse_token_num_t cmd_config_burst_value =
3176 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3178 cmdline_parse_inst_t cmd_config_burst = {
3179 .f = cmd_config_burst_parsed,
3181 .help_str = "port config all burst <value>",
3183 (void *)&cmd_config_burst_port,
3184 (void *)&cmd_config_burst_keyword,
3185 (void *)&cmd_config_burst_all,
3186 (void *)&cmd_config_burst_name,
3187 (void *)&cmd_config_burst_value,
3192 /* *** configure rx/tx queues *** */
3193 struct cmd_config_thresh {
3194 cmdline_fixed_string_t port;
3195 cmdline_fixed_string_t keyword;
3196 cmdline_fixed_string_t all;
3197 cmdline_fixed_string_t name;
3202 cmd_config_thresh_parsed(void *parsed_result,
3203 __attribute__((unused)) struct cmdline *cl,
3204 __attribute__((unused)) void *data)
3206 struct cmd_config_thresh *res = parsed_result;
3208 if (!all_ports_stopped()) {
3209 printf("Please stop all ports first\n");
3213 if (!strcmp(res->name, "txpt"))
3214 tx_pthresh = res->value;
3215 else if(!strcmp(res->name, "txht"))
3216 tx_hthresh = res->value;
3217 else if(!strcmp(res->name, "txwt"))
3218 tx_wthresh = res->value;
3219 else if(!strcmp(res->name, "rxpt"))
3220 rx_pthresh = res->value;
3221 else if(!strcmp(res->name, "rxht"))
3222 rx_hthresh = res->value;
3223 else if(!strcmp(res->name, "rxwt"))
3224 rx_wthresh = res->value;
3226 printf("Unknown parameter\n");
3232 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3235 cmdline_parse_token_string_t cmd_config_thresh_port =
3236 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3237 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3238 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3239 cmdline_parse_token_string_t cmd_config_thresh_all =
3240 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3241 cmdline_parse_token_string_t cmd_config_thresh_name =
3242 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3243 "txpt#txht#txwt#rxpt#rxht#rxwt");
3244 cmdline_parse_token_num_t cmd_config_thresh_value =
3245 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3247 cmdline_parse_inst_t cmd_config_thresh = {
3248 .f = cmd_config_thresh_parsed,
3250 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3252 (void *)&cmd_config_thresh_port,
3253 (void *)&cmd_config_thresh_keyword,
3254 (void *)&cmd_config_thresh_all,
3255 (void *)&cmd_config_thresh_name,
3256 (void *)&cmd_config_thresh_value,
3261 /* *** configure free/rs threshold *** */
3262 struct cmd_config_threshold {
3263 cmdline_fixed_string_t port;
3264 cmdline_fixed_string_t keyword;
3265 cmdline_fixed_string_t all;
3266 cmdline_fixed_string_t name;
3271 cmd_config_threshold_parsed(void *parsed_result,
3272 __attribute__((unused)) struct cmdline *cl,
3273 __attribute__((unused)) void *data)
3275 struct cmd_config_threshold *res = parsed_result;
3277 if (!all_ports_stopped()) {
3278 printf("Please stop all ports first\n");
3282 if (!strcmp(res->name, "txfreet"))
3283 tx_free_thresh = res->value;
3284 else if (!strcmp(res->name, "txrst"))
3285 tx_rs_thresh = res->value;
3286 else if (!strcmp(res->name, "rxfreet"))
3287 rx_free_thresh = res->value;
3289 printf("Unknown parameter\n");
3295 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3298 cmdline_parse_token_string_t cmd_config_threshold_port =
3299 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3300 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3301 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3303 cmdline_parse_token_string_t cmd_config_threshold_all =
3304 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3305 cmdline_parse_token_string_t cmd_config_threshold_name =
3306 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3307 "txfreet#txrst#rxfreet");
3308 cmdline_parse_token_num_t cmd_config_threshold_value =
3309 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3311 cmdline_parse_inst_t cmd_config_threshold = {
3312 .f = cmd_config_threshold_parsed,
3314 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3316 (void *)&cmd_config_threshold_port,
3317 (void *)&cmd_config_threshold_keyword,
3318 (void *)&cmd_config_threshold_all,
3319 (void *)&cmd_config_threshold_name,
3320 (void *)&cmd_config_threshold_value,
3326 struct cmd_stop_result {
3327 cmdline_fixed_string_t stop;
3330 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3331 __attribute__((unused)) struct cmdline *cl,
3332 __attribute__((unused)) void *data)
3334 stop_packet_forwarding();
3337 cmdline_parse_token_string_t cmd_stop_stop =
3338 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3340 cmdline_parse_inst_t cmd_stop = {
3341 .f = cmd_stop_parsed,
3343 .help_str = "stop: Stop packet forwarding",
3345 (void *)&cmd_stop_stop,
3350 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3353 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3354 unsigned int *parsed_items, int check_unique_values)
3356 unsigned int nb_item;
3364 * First parse all items in the list and store their value.
3369 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3371 if ((c >= '0') && (c <= '9')) {
3372 value = (unsigned int) (value * 10 + (c - '0'));
3377 printf("character %c is not a decimal digit\n", c);
3381 printf("No valid value before comma\n");
3384 if (nb_item < max_items) {
3385 parsed_items[nb_item] = value;
3391 if (nb_item >= max_items) {
3392 printf("Number of %s = %u > %u (maximum items)\n",
3393 item_name, nb_item + 1, max_items);
3396 parsed_items[nb_item++] = value;
3397 if (! check_unique_values)
3401 * Then, check that all values in the list are differents.
3402 * No optimization here...
3404 for (i = 0; i < nb_item; i++) {
3405 for (j = i + 1; j < nb_item; j++) {
3406 if (parsed_items[j] == parsed_items[i]) {
3407 printf("duplicated %s %u at index %u and %u\n",
3408 item_name, parsed_items[i], i, j);
3416 struct cmd_set_list_result {
3417 cmdline_fixed_string_t cmd_keyword;
3418 cmdline_fixed_string_t list_name;
3419 cmdline_fixed_string_t list_of_items;
3422 static void cmd_set_list_parsed(void *parsed_result,
3423 __attribute__((unused)) struct cmdline *cl,
3424 __attribute__((unused)) void *data)
3426 struct cmd_set_list_result *res;
3428 unsigned int lcorelist[RTE_MAX_LCORE];
3429 unsigned int portlist[RTE_MAX_ETHPORTS];
3431 unsigned int nb_item;
3433 if (test_done == 0) {
3434 printf("Please stop forwarding first\n");
3438 res = parsed_result;
3439 if (!strcmp(res->list_name, "corelist")) {
3440 nb_item = parse_item_list(res->list_of_items, "core",
3442 parsed_items.lcorelist, 1);
3444 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3449 if (!strcmp(res->list_name, "portlist")) {
3450 nb_item = parse_item_list(res->list_of_items, "port",
3452 parsed_items.portlist, 1);
3454 set_fwd_ports_list(parsed_items.portlist, nb_item);
3460 cmdline_parse_token_string_t cmd_set_list_keyword =
3461 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3463 cmdline_parse_token_string_t cmd_set_list_name =
3464 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3465 "corelist#portlist");
3466 cmdline_parse_token_string_t cmd_set_list_of_items =
3467 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3470 cmdline_parse_inst_t cmd_set_fwd_list = {
3471 .f = cmd_set_list_parsed,
3473 .help_str = "set corelist|portlist <list0[,list1]*>",
3475 (void *)&cmd_set_list_keyword,
3476 (void *)&cmd_set_list_name,
3477 (void *)&cmd_set_list_of_items,
3482 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3484 struct cmd_setmask_result {
3485 cmdline_fixed_string_t set;
3486 cmdline_fixed_string_t mask;
3490 static void cmd_set_mask_parsed(void *parsed_result,
3491 __attribute__((unused)) struct cmdline *cl,
3492 __attribute__((unused)) void *data)
3494 struct cmd_setmask_result *res = parsed_result;
3496 if (test_done == 0) {
3497 printf("Please stop forwarding first\n");
3500 if (!strcmp(res->mask, "coremask")) {
3501 set_fwd_lcores_mask(res->hexavalue);
3503 } else if (!strcmp(res->mask, "portmask")) {
3504 set_fwd_ports_mask(res->hexavalue);
3509 cmdline_parse_token_string_t cmd_setmask_set =
3510 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3511 cmdline_parse_token_string_t cmd_setmask_mask =
3512 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3513 "coremask#portmask");
3514 cmdline_parse_token_num_t cmd_setmask_value =
3515 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3517 cmdline_parse_inst_t cmd_set_fwd_mask = {
3518 .f = cmd_set_mask_parsed,
3520 .help_str = "set coremask|portmask <hexadecimal value>",
3522 (void *)&cmd_setmask_set,
3523 (void *)&cmd_setmask_mask,
3524 (void *)&cmd_setmask_value,
3530 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3532 struct cmd_set_result {
3533 cmdline_fixed_string_t set;
3534 cmdline_fixed_string_t what;
3538 static void cmd_set_parsed(void *parsed_result,
3539 __attribute__((unused)) struct cmdline *cl,
3540 __attribute__((unused)) void *data)
3542 struct cmd_set_result *res = parsed_result;
3543 if (!strcmp(res->what, "nbport")) {
3544 set_fwd_ports_number(res->value);
3546 } else if (!strcmp(res->what, "nbcore")) {
3547 set_fwd_lcores_number(res->value);
3549 } else if (!strcmp(res->what, "burst"))
3550 set_nb_pkt_per_burst(res->value);
3551 else if (!strcmp(res->what, "verbose"))
3552 set_verbose_level(res->value);
3555 cmdline_parse_token_string_t cmd_set_set =
3556 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3557 cmdline_parse_token_string_t cmd_set_what =
3558 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3559 "nbport#nbcore#burst#verbose");
3560 cmdline_parse_token_num_t cmd_set_value =
3561 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3563 cmdline_parse_inst_t cmd_set_numbers = {
3564 .f = cmd_set_parsed,
3566 .help_str = "set nbport|nbcore|burst|verbose <value>",
3568 (void *)&cmd_set_set,
3569 (void *)&cmd_set_what,
3570 (void *)&cmd_set_value,
3575 /* *** SET LOG LEVEL CONFIGURATION *** */
3577 struct cmd_set_log_result {
3578 cmdline_fixed_string_t set;
3579 cmdline_fixed_string_t log;
3580 cmdline_fixed_string_t type;
3585 cmd_set_log_parsed(void *parsed_result,
3586 __attribute__((unused)) struct cmdline *cl,
3587 __attribute__((unused)) void *data)
3589 struct cmd_set_log_result *res;
3592 res = parsed_result;
3593 if (!strcmp(res->type, "global"))
3594 rte_log_set_global_level(res->level);
3596 ret = rte_log_set_level_regexp(res->type, res->level);
3598 printf("Unable to set log level\n");
3602 cmdline_parse_token_string_t cmd_set_log_set =
3603 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3604 cmdline_parse_token_string_t cmd_set_log_log =
3605 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3606 cmdline_parse_token_string_t cmd_set_log_type =
3607 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3608 cmdline_parse_token_num_t cmd_set_log_level =
3609 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3611 cmdline_parse_inst_t cmd_set_log = {
3612 .f = cmd_set_log_parsed,
3614 .help_str = "set log global|<type> <level>",
3616 (void *)&cmd_set_log_set,
3617 (void *)&cmd_set_log_log,
3618 (void *)&cmd_set_log_type,
3619 (void *)&cmd_set_log_level,
3624 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3626 struct cmd_set_txpkts_result {
3627 cmdline_fixed_string_t cmd_keyword;
3628 cmdline_fixed_string_t txpkts;
3629 cmdline_fixed_string_t seg_lengths;
3633 cmd_set_txpkts_parsed(void *parsed_result,
3634 __attribute__((unused)) struct cmdline *cl,
3635 __attribute__((unused)) void *data)
3637 struct cmd_set_txpkts_result *res;
3638 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3639 unsigned int nb_segs;
3641 res = parsed_result;
3642 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3643 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3645 set_tx_pkt_segments(seg_lengths, nb_segs);
3648 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3649 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3650 cmd_keyword, "set");
3651 cmdline_parse_token_string_t cmd_set_txpkts_name =
3652 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3654 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3655 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3658 cmdline_parse_inst_t cmd_set_txpkts = {
3659 .f = cmd_set_txpkts_parsed,
3661 .help_str = "set txpkts <len0[,len1]*>",
3663 (void *)&cmd_set_txpkts_keyword,
3664 (void *)&cmd_set_txpkts_name,
3665 (void *)&cmd_set_txpkts_lengths,
3670 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3672 struct cmd_set_txsplit_result {
3673 cmdline_fixed_string_t cmd_keyword;
3674 cmdline_fixed_string_t txsplit;
3675 cmdline_fixed_string_t mode;
3679 cmd_set_txsplit_parsed(void *parsed_result,
3680 __attribute__((unused)) struct cmdline *cl,
3681 __attribute__((unused)) void *data)
3683 struct cmd_set_txsplit_result *res;
3685 res = parsed_result;
3686 set_tx_pkt_split(res->mode);
3689 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3690 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3691 cmd_keyword, "set");
3692 cmdline_parse_token_string_t cmd_set_txsplit_name =
3693 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3694 txsplit, "txsplit");
3695 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3696 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3699 cmdline_parse_inst_t cmd_set_txsplit = {
3700 .f = cmd_set_txsplit_parsed,
3702 .help_str = "set txsplit on|off|rand",
3704 (void *)&cmd_set_txsplit_keyword,
3705 (void *)&cmd_set_txsplit_name,
3706 (void *)&cmd_set_txsplit_mode,
3711 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3712 struct cmd_rx_vlan_filter_all_result {
3713 cmdline_fixed_string_t rx_vlan;
3714 cmdline_fixed_string_t what;
3715 cmdline_fixed_string_t all;
3720 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3721 __attribute__((unused)) struct cmdline *cl,
3722 __attribute__((unused)) void *data)
3724 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3726 if (!strcmp(res->what, "add"))
3727 rx_vlan_all_filter_set(res->port_id, 1);
3729 rx_vlan_all_filter_set(res->port_id, 0);
3732 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3733 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3734 rx_vlan, "rx_vlan");
3735 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3736 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3738 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3739 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3741 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3742 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3745 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3746 .f = cmd_rx_vlan_filter_all_parsed,
3748 .help_str = "rx_vlan add|rm all <port_id>: "
3749 "Add/Remove all identifiers to/from the set of VLAN "
3750 "identifiers filtered by a port",
3752 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3753 (void *)&cmd_rx_vlan_filter_all_what,
3754 (void *)&cmd_rx_vlan_filter_all_all,
3755 (void *)&cmd_rx_vlan_filter_all_portid,
3760 /* *** VLAN OFFLOAD SET ON A PORT *** */
3761 struct cmd_vlan_offload_result {
3762 cmdline_fixed_string_t vlan;
3763 cmdline_fixed_string_t set;
3764 cmdline_fixed_string_t vlan_type;
3765 cmdline_fixed_string_t what;
3766 cmdline_fixed_string_t on;
3767 cmdline_fixed_string_t port_id;
3771 cmd_vlan_offload_parsed(void *parsed_result,
3772 __attribute__((unused)) struct cmdline *cl,
3773 __attribute__((unused)) void *data)
3776 struct cmd_vlan_offload_result *res = parsed_result;
3779 portid_t port_id = 0;
3783 len = strnlen(str, STR_TOKEN_SIZE);
3785 /* Get port_id first */
3793 tmp = strtoul(str, NULL, 0);
3794 /* If port_id greater that what portid_t can represent, return */
3795 if(tmp >= RTE_MAX_ETHPORTS)
3797 port_id = (portid_t)tmp;
3799 if (!strcmp(res->on, "on"))
3804 if (!strcmp(res->what, "strip"))
3805 rx_vlan_strip_set(port_id, on);
3806 else if(!strcmp(res->what, "stripq")){
3807 uint16_t queue_id = 0;
3809 /* No queue_id, return */
3811 printf("must specify (port,queue_id)\n");
3814 tmp = strtoul(str + i + 1, NULL, 0);
3815 /* If queue_id greater that what 16-bits can represent, return */
3819 queue_id = (uint16_t)tmp;
3820 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3822 else if (!strcmp(res->what, "filter"))
3823 rx_vlan_filter_set(port_id, on);
3825 vlan_extend_set(port_id, on);
3830 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3831 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3833 cmdline_parse_token_string_t cmd_vlan_offload_set =
3834 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3836 cmdline_parse_token_string_t cmd_vlan_offload_what =
3837 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3838 what, "strip#filter#qinq#stripq");
3839 cmdline_parse_token_string_t cmd_vlan_offload_on =
3840 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3842 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3843 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3846 cmdline_parse_inst_t cmd_vlan_offload = {
3847 .f = cmd_vlan_offload_parsed,
3849 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3850 "<port_id[,queue_id]>: "
3851 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3853 (void *)&cmd_vlan_offload_vlan,
3854 (void *)&cmd_vlan_offload_set,
3855 (void *)&cmd_vlan_offload_what,
3856 (void *)&cmd_vlan_offload_on,
3857 (void *)&cmd_vlan_offload_portid,
3862 /* *** VLAN TPID SET ON A PORT *** */
3863 struct cmd_vlan_tpid_result {
3864 cmdline_fixed_string_t vlan;
3865 cmdline_fixed_string_t set;
3866 cmdline_fixed_string_t vlan_type;
3867 cmdline_fixed_string_t what;
3873 cmd_vlan_tpid_parsed(void *parsed_result,
3874 __attribute__((unused)) struct cmdline *cl,
3875 __attribute__((unused)) void *data)
3877 struct cmd_vlan_tpid_result *res = parsed_result;
3878 enum rte_vlan_type vlan_type;
3880 if (!strcmp(res->vlan_type, "inner"))
3881 vlan_type = ETH_VLAN_TYPE_INNER;
3882 else if (!strcmp(res->vlan_type, "outer"))
3883 vlan_type = ETH_VLAN_TYPE_OUTER;
3885 printf("Unknown vlan type\n");
3888 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3891 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3892 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3894 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3895 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3897 cmdline_parse_token_string_t cmd_vlan_type =
3898 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3899 vlan_type, "inner#outer");
3900 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3901 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3903 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3904 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3906 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3907 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3910 cmdline_parse_inst_t cmd_vlan_tpid = {
3911 .f = cmd_vlan_tpid_parsed,
3913 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3914 "Set the VLAN Ether type",
3916 (void *)&cmd_vlan_tpid_vlan,
3917 (void *)&cmd_vlan_tpid_set,
3918 (void *)&cmd_vlan_type,
3919 (void *)&cmd_vlan_tpid_what,
3920 (void *)&cmd_vlan_tpid_tpid,
3921 (void *)&cmd_vlan_tpid_portid,
3926 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3927 struct cmd_rx_vlan_filter_result {
3928 cmdline_fixed_string_t rx_vlan;
3929 cmdline_fixed_string_t what;
3935 cmd_rx_vlan_filter_parsed(void *parsed_result,
3936 __attribute__((unused)) struct cmdline *cl,
3937 __attribute__((unused)) void *data)
3939 struct cmd_rx_vlan_filter_result *res = parsed_result;
3941 if (!strcmp(res->what, "add"))
3942 rx_vft_set(res->port_id, res->vlan_id, 1);
3944 rx_vft_set(res->port_id, res->vlan_id, 0);
3947 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3948 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3949 rx_vlan, "rx_vlan");
3950 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3951 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3953 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3954 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3956 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3957 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3960 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3961 .f = cmd_rx_vlan_filter_parsed,
3963 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3964 "Add/Remove a VLAN identifier to/from the set of VLAN "
3965 "identifiers filtered by a port",
3967 (void *)&cmd_rx_vlan_filter_rx_vlan,
3968 (void *)&cmd_rx_vlan_filter_what,
3969 (void *)&cmd_rx_vlan_filter_vlanid,
3970 (void *)&cmd_rx_vlan_filter_portid,
3975 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3976 struct cmd_tx_vlan_set_result {
3977 cmdline_fixed_string_t tx_vlan;
3978 cmdline_fixed_string_t set;
3984 cmd_tx_vlan_set_parsed(void *parsed_result,
3985 __attribute__((unused)) struct cmdline *cl,
3986 __attribute__((unused)) void *data)
3988 struct cmd_tx_vlan_set_result *res = parsed_result;
3990 if (!port_is_stopped(res->port_id)) {
3991 printf("Please stop port %d first\n", res->port_id);
3995 tx_vlan_set(res->port_id, res->vlan_id);
3997 cmd_reconfig_device_queue(res->port_id, 1, 1);
4000 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4001 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4002 tx_vlan, "tx_vlan");
4003 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4004 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4006 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4007 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4009 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4010 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4013 cmdline_parse_inst_t cmd_tx_vlan_set = {
4014 .f = cmd_tx_vlan_set_parsed,
4016 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4017 "Enable hardware insertion of a single VLAN header "
4018 "with a given TAG Identifier in packets sent on a port",
4020 (void *)&cmd_tx_vlan_set_tx_vlan,
4021 (void *)&cmd_tx_vlan_set_set,
4022 (void *)&cmd_tx_vlan_set_portid,
4023 (void *)&cmd_tx_vlan_set_vlanid,
4028 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4029 struct cmd_tx_vlan_set_qinq_result {
4030 cmdline_fixed_string_t tx_vlan;
4031 cmdline_fixed_string_t set;
4034 uint16_t vlan_id_outer;
4038 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4039 __attribute__((unused)) struct cmdline *cl,
4040 __attribute__((unused)) void *data)
4042 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4044 if (!port_is_stopped(res->port_id)) {
4045 printf("Please stop port %d first\n", res->port_id);
4049 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4051 cmd_reconfig_device_queue(res->port_id, 1, 1);
4054 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4055 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4056 tx_vlan, "tx_vlan");
4057 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4058 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4060 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4061 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4063 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4064 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4066 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4067 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4068 vlan_id_outer, UINT16);
4070 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4071 .f = cmd_tx_vlan_set_qinq_parsed,
4073 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4074 "Enable hardware insertion of double VLAN header "
4075 "with given TAG Identifiers in packets sent on a port",
4077 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4078 (void *)&cmd_tx_vlan_set_qinq_set,
4079 (void *)&cmd_tx_vlan_set_qinq_portid,
4080 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4081 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4086 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4087 struct cmd_tx_vlan_set_pvid_result {
4088 cmdline_fixed_string_t tx_vlan;
4089 cmdline_fixed_string_t set;
4090 cmdline_fixed_string_t pvid;
4093 cmdline_fixed_string_t mode;
4097 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4098 __attribute__((unused)) struct cmdline *cl,
4099 __attribute__((unused)) void *data)
4101 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4103 if (strcmp(res->mode, "on") == 0)
4104 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4106 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4109 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4110 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4111 tx_vlan, "tx_vlan");
4112 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4113 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4115 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4116 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4118 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4119 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4121 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4122 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4124 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4125 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4128 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4129 .f = cmd_tx_vlan_set_pvid_parsed,
4131 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4133 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4134 (void *)&cmd_tx_vlan_set_pvid_set,
4135 (void *)&cmd_tx_vlan_set_pvid_pvid,
4136 (void *)&cmd_tx_vlan_set_pvid_port_id,
4137 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4138 (void *)&cmd_tx_vlan_set_pvid_mode,
4143 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4144 struct cmd_tx_vlan_reset_result {
4145 cmdline_fixed_string_t tx_vlan;
4146 cmdline_fixed_string_t reset;
4151 cmd_tx_vlan_reset_parsed(void *parsed_result,
4152 __attribute__((unused)) struct cmdline *cl,
4153 __attribute__((unused)) void *data)
4155 struct cmd_tx_vlan_reset_result *res = parsed_result;
4157 if (!port_is_stopped(res->port_id)) {
4158 printf("Please stop port %d first\n", res->port_id);
4162 tx_vlan_reset(res->port_id);
4164 cmd_reconfig_device_queue(res->port_id, 1, 1);
4167 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4168 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4169 tx_vlan, "tx_vlan");
4170 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4171 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4173 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4174 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4177 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4178 .f = cmd_tx_vlan_reset_parsed,
4180 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4181 "VLAN header in packets sent on a port",
4183 (void *)&cmd_tx_vlan_reset_tx_vlan,
4184 (void *)&cmd_tx_vlan_reset_reset,
4185 (void *)&cmd_tx_vlan_reset_portid,
4191 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4192 struct cmd_csum_result {
4193 cmdline_fixed_string_t csum;
4194 cmdline_fixed_string_t mode;
4195 cmdline_fixed_string_t proto;
4196 cmdline_fixed_string_t hwsw;
4201 csum_show(int port_id)
4203 struct rte_eth_dev_info dev_info;
4204 uint64_t tx_offloads;
4206 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4207 printf("Parse tunnel is %s\n",
4208 (ports[port_id].parse_tunnel) ? "on" : "off");
4209 printf("IP checksum offload is %s\n",
4210 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4211 printf("UDP checksum offload is %s\n",
4212 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4213 printf("TCP checksum offload is %s\n",
4214 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4215 printf("SCTP checksum offload is %s\n",
4216 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4217 printf("Outer-Ip checksum offload is %s\n",
4218 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4219 printf("Outer-Udp checksum offload is %s\n",
4220 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4222 /* display warnings if configuration is not supported by the NIC */
4223 rte_eth_dev_info_get(port_id, &dev_info);
4224 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4225 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4226 printf("Warning: hardware IP checksum enabled but not "
4227 "supported by port %d\n", port_id);
4229 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4230 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4231 printf("Warning: hardware UDP checksum enabled but not "
4232 "supported by port %d\n", port_id);
4234 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4235 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4236 printf("Warning: hardware TCP checksum enabled but not "
4237 "supported by port %d\n", port_id);
4239 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4240 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4241 printf("Warning: hardware SCTP checksum enabled but not "
4242 "supported by port %d\n", port_id);
4244 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4245 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4246 printf("Warning: hardware outer IP checksum enabled but not "
4247 "supported by port %d\n", port_id);
4249 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4250 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4252 printf("Warning: hardware outer UDP checksum enabled but not "
4253 "supported by port %d\n", port_id);
4258 cmd_csum_parsed(void *parsed_result,
4259 __attribute__((unused)) struct cmdline *cl,
4260 __attribute__((unused)) void *data)
4262 struct cmd_csum_result *res = parsed_result;
4264 uint64_t csum_offloads = 0;
4265 struct rte_eth_dev_info dev_info;
4267 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4268 printf("invalid port %d\n", res->port_id);
4271 if (!port_is_stopped(res->port_id)) {
4272 printf("Please stop port %d first\n", res->port_id);
4276 rte_eth_dev_info_get(res->port_id, &dev_info);
4277 if (!strcmp(res->mode, "set")) {
4279 if (!strcmp(res->hwsw, "hw"))
4282 if (!strcmp(res->proto, "ip")) {
4283 if (hw == 0 || (dev_info.tx_offload_capa &
4284 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4285 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4287 printf("IP checksum offload is not supported "
4288 "by port %u\n", res->port_id);
4290 } else if (!strcmp(res->proto, "udp")) {
4291 if (hw == 0 || (dev_info.tx_offload_capa &
4292 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4293 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4295 printf("UDP checksum offload is not supported "
4296 "by port %u\n", res->port_id);
4298 } else if (!strcmp(res->proto, "tcp")) {
4299 if (hw == 0 || (dev_info.tx_offload_capa &
4300 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4301 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4303 printf("TCP checksum offload is not supported "
4304 "by port %u\n", res->port_id);
4306 } else if (!strcmp(res->proto, "sctp")) {
4307 if (hw == 0 || (dev_info.tx_offload_capa &
4308 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4309 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4311 printf("SCTP checksum offload is not supported "
4312 "by port %u\n", res->port_id);
4314 } else if (!strcmp(res->proto, "outer-ip")) {
4315 if (hw == 0 || (dev_info.tx_offload_capa &
4316 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4318 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4320 printf("Outer IP checksum offload is not "
4321 "supported by port %u\n", res->port_id);
4323 } else if (!strcmp(res->proto, "outer-udp")) {
4324 if (hw == 0 || (dev_info.tx_offload_capa &
4325 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4327 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4329 printf("Outer UDP checksum offload is not "
4330 "supported by port %u\n", res->port_id);
4335 ports[res->port_id].dev_conf.txmode.offloads |=
4338 ports[res->port_id].dev_conf.txmode.offloads &=
4342 csum_show(res->port_id);
4344 cmd_reconfig_device_queue(res->port_id, 1, 1);
4347 cmdline_parse_token_string_t cmd_csum_csum =
4348 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4350 cmdline_parse_token_string_t cmd_csum_mode =
4351 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4353 cmdline_parse_token_string_t cmd_csum_proto =
4354 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4355 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4356 cmdline_parse_token_string_t cmd_csum_hwsw =
4357 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4359 cmdline_parse_token_num_t cmd_csum_portid =
4360 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4363 cmdline_parse_inst_t cmd_csum_set = {
4364 .f = cmd_csum_parsed,
4366 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4367 "Enable/Disable hardware calculation of L3/L4 checksum when "
4368 "using csum forward engine",
4370 (void *)&cmd_csum_csum,
4371 (void *)&cmd_csum_mode,
4372 (void *)&cmd_csum_proto,
4373 (void *)&cmd_csum_hwsw,
4374 (void *)&cmd_csum_portid,
4379 cmdline_parse_token_string_t cmd_csum_mode_show =
4380 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4383 cmdline_parse_inst_t cmd_csum_show = {
4384 .f = cmd_csum_parsed,
4386 .help_str = "csum show <port_id>: Show checksum offload configuration",
4388 (void *)&cmd_csum_csum,
4389 (void *)&cmd_csum_mode_show,
4390 (void *)&cmd_csum_portid,
4395 /* Enable/disable tunnel parsing */
4396 struct cmd_csum_tunnel_result {
4397 cmdline_fixed_string_t csum;
4398 cmdline_fixed_string_t parse;
4399 cmdline_fixed_string_t onoff;
4404 cmd_csum_tunnel_parsed(void *parsed_result,
4405 __attribute__((unused)) struct cmdline *cl,
4406 __attribute__((unused)) void *data)
4408 struct cmd_csum_tunnel_result *res = parsed_result;
4410 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4413 if (!strcmp(res->onoff, "on"))
4414 ports[res->port_id].parse_tunnel = 1;
4416 ports[res->port_id].parse_tunnel = 0;
4418 csum_show(res->port_id);
4421 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4422 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4424 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4425 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4426 parse, "parse-tunnel");
4427 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4428 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4430 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4431 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4434 cmdline_parse_inst_t cmd_csum_tunnel = {
4435 .f = cmd_csum_tunnel_parsed,
4437 .help_str = "csum parse-tunnel on|off <port_id>: "
4438 "Enable/Disable parsing of tunnels for csum engine",
4440 (void *)&cmd_csum_tunnel_csum,
4441 (void *)&cmd_csum_tunnel_parse,
4442 (void *)&cmd_csum_tunnel_onoff,
4443 (void *)&cmd_csum_tunnel_portid,
4448 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4449 struct cmd_tso_set_result {
4450 cmdline_fixed_string_t tso;
4451 cmdline_fixed_string_t mode;
4457 cmd_tso_set_parsed(void *parsed_result,
4458 __attribute__((unused)) struct cmdline *cl,
4459 __attribute__((unused)) void *data)
4461 struct cmd_tso_set_result *res = parsed_result;
4462 struct rte_eth_dev_info dev_info;
4464 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4466 if (!port_is_stopped(res->port_id)) {
4467 printf("Please stop port %d first\n", res->port_id);
4471 if (!strcmp(res->mode, "set"))
4472 ports[res->port_id].tso_segsz = res->tso_segsz;
4474 rte_eth_dev_info_get(res->port_id, &dev_info);
4475 if ((ports[res->port_id].tso_segsz != 0) &&
4476 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4477 printf("Error: TSO is not supported by port %d\n",
4482 if (ports[res->port_id].tso_segsz == 0) {
4483 ports[res->port_id].dev_conf.txmode.offloads &=
4484 ~DEV_TX_OFFLOAD_TCP_TSO;
4485 printf("TSO for non-tunneled packets is disabled\n");
4487 ports[res->port_id].dev_conf.txmode.offloads |=
4488 DEV_TX_OFFLOAD_TCP_TSO;
4489 printf("TSO segment size for non-tunneled packets is %d\n",
4490 ports[res->port_id].tso_segsz);
4493 /* display warnings if configuration is not supported by the NIC */
4494 rte_eth_dev_info_get(res->port_id, &dev_info);
4495 if ((ports[res->port_id].tso_segsz != 0) &&
4496 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4497 printf("Warning: TSO enabled but not "
4498 "supported by port %d\n", res->port_id);
4501 cmd_reconfig_device_queue(res->port_id, 1, 1);
4504 cmdline_parse_token_string_t cmd_tso_set_tso =
4505 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4507 cmdline_parse_token_string_t cmd_tso_set_mode =
4508 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4510 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4511 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4513 cmdline_parse_token_num_t cmd_tso_set_portid =
4514 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4517 cmdline_parse_inst_t cmd_tso_set = {
4518 .f = cmd_tso_set_parsed,
4520 .help_str = "tso set <tso_segsz> <port_id>: "
4521 "Set TSO segment size of non-tunneled packets for csum engine "
4524 (void *)&cmd_tso_set_tso,
4525 (void *)&cmd_tso_set_mode,
4526 (void *)&cmd_tso_set_tso_segsz,
4527 (void *)&cmd_tso_set_portid,
4532 cmdline_parse_token_string_t cmd_tso_show_mode =
4533 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4537 cmdline_parse_inst_t cmd_tso_show = {
4538 .f = cmd_tso_set_parsed,
4540 .help_str = "tso show <port_id>: "
4541 "Show TSO segment size of non-tunneled packets for csum engine",
4543 (void *)&cmd_tso_set_tso,
4544 (void *)&cmd_tso_show_mode,
4545 (void *)&cmd_tso_set_portid,
4550 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4551 struct cmd_tunnel_tso_set_result {
4552 cmdline_fixed_string_t tso;
4553 cmdline_fixed_string_t mode;
4558 static struct rte_eth_dev_info
4559 check_tunnel_tso_nic_support(portid_t port_id)
4561 struct rte_eth_dev_info dev_info;
4563 rte_eth_dev_info_get(port_id, &dev_info);
4564 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4565 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4566 "not enabled for port %d\n", port_id);
4567 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4568 printf("Warning: GRE TUNNEL TSO not supported therefore "
4569 "not enabled for port %d\n", port_id);
4570 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4571 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4572 "not enabled for port %d\n", port_id);
4573 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4574 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4575 "not enabled for port %d\n", port_id);
4576 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4577 printf("Warning: IP TUNNEL TSO not supported therefore "
4578 "not enabled for port %d\n", port_id);
4579 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4580 printf("Warning: UDP TUNNEL TSO not supported therefore "
4581 "not enabled for port %d\n", port_id);
4586 cmd_tunnel_tso_set_parsed(void *parsed_result,
4587 __attribute__((unused)) struct cmdline *cl,
4588 __attribute__((unused)) void *data)
4590 struct cmd_tunnel_tso_set_result *res = parsed_result;
4591 struct rte_eth_dev_info dev_info;
4593 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4595 if (!port_is_stopped(res->port_id)) {
4596 printf("Please stop port %d first\n", res->port_id);
4600 if (!strcmp(res->mode, "set"))
4601 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4603 dev_info = check_tunnel_tso_nic_support(res->port_id);
4604 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4605 ports[res->port_id].dev_conf.txmode.offloads &=
4606 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4607 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4608 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4609 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4610 DEV_TX_OFFLOAD_IP_TNL_TSO |
4611 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4612 printf("TSO for tunneled packets is disabled\n");
4614 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4615 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4616 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4617 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4618 DEV_TX_OFFLOAD_IP_TNL_TSO |
4619 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4621 ports[res->port_id].dev_conf.txmode.offloads |=
4622 (tso_offloads & dev_info.tx_offload_capa);
4623 printf("TSO segment size for tunneled packets is %d\n",
4624 ports[res->port_id].tunnel_tso_segsz);
4626 /* Below conditions are needed to make it work:
4627 * (1) tunnel TSO is supported by the NIC;
4628 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4630 * (3) for tunneled pkts with outer L3 of IPv4,
4631 * "csum set outer-ip" must be set to hw, because after tso,
4632 * total_len of outer IP header is changed, and the checksum
4633 * of outer IP header calculated by sw should be wrong; that
4634 * is not necessary for IPv6 tunneled pkts because there's no
4635 * checksum in IP header anymore.
4638 if (!ports[res->port_id].parse_tunnel)
4639 printf("Warning: csum parse_tunnel must be set "
4640 "so that tunneled packets are recognized\n");
4641 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4642 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4643 printf("Warning: csum set outer-ip must be set to hw "
4644 "if outer L3 is IPv4; not necessary for IPv6\n");
4647 cmd_reconfig_device_queue(res->port_id, 1, 1);
4650 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4651 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4653 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4654 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4656 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4657 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4659 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4660 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4663 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4664 .f = cmd_tunnel_tso_set_parsed,
4666 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4667 "Set TSO segment size of tunneled packets for csum engine "
4670 (void *)&cmd_tunnel_tso_set_tso,
4671 (void *)&cmd_tunnel_tso_set_mode,
4672 (void *)&cmd_tunnel_tso_set_tso_segsz,
4673 (void *)&cmd_tunnel_tso_set_portid,
4678 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4679 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4683 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4684 .f = cmd_tunnel_tso_set_parsed,
4686 .help_str = "tunnel_tso show <port_id> "
4687 "Show TSO segment size of tunneled packets for csum engine",
4689 (void *)&cmd_tunnel_tso_set_tso,
4690 (void *)&cmd_tunnel_tso_show_mode,
4691 (void *)&cmd_tunnel_tso_set_portid,
4696 /* *** SET GRO FOR A PORT *** */
4697 struct cmd_gro_enable_result {
4698 cmdline_fixed_string_t cmd_set;
4699 cmdline_fixed_string_t cmd_port;
4700 cmdline_fixed_string_t cmd_keyword;
4701 cmdline_fixed_string_t cmd_onoff;
4706 cmd_gro_enable_parsed(void *parsed_result,
4707 __attribute__((unused)) struct cmdline *cl,
4708 __attribute__((unused)) void *data)
4710 struct cmd_gro_enable_result *res;
4712 res = parsed_result;
4713 if (!strcmp(res->cmd_keyword, "gro"))
4714 setup_gro(res->cmd_onoff, res->cmd_pid);
4717 cmdline_parse_token_string_t cmd_gro_enable_set =
4718 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4720 cmdline_parse_token_string_t cmd_gro_enable_port =
4721 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4722 cmd_keyword, "port");
4723 cmdline_parse_token_num_t cmd_gro_enable_pid =
4724 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4726 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4727 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4728 cmd_keyword, "gro");
4729 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4730 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4731 cmd_onoff, "on#off");
4733 cmdline_parse_inst_t cmd_gro_enable = {
4734 .f = cmd_gro_enable_parsed,
4736 .help_str = "set port <port_id> gro on|off",
4738 (void *)&cmd_gro_enable_set,
4739 (void *)&cmd_gro_enable_port,
4740 (void *)&cmd_gro_enable_pid,
4741 (void *)&cmd_gro_enable_keyword,
4742 (void *)&cmd_gro_enable_onoff,
4747 /* *** DISPLAY GRO CONFIGURATION *** */
4748 struct cmd_gro_show_result {
4749 cmdline_fixed_string_t cmd_show;
4750 cmdline_fixed_string_t cmd_port;
4751 cmdline_fixed_string_t cmd_keyword;
4756 cmd_gro_show_parsed(void *parsed_result,
4757 __attribute__((unused)) struct cmdline *cl,
4758 __attribute__((unused)) void *data)
4760 struct cmd_gro_show_result *res;
4762 res = parsed_result;
4763 if (!strcmp(res->cmd_keyword, "gro"))
4764 show_gro(res->cmd_pid);
4767 cmdline_parse_token_string_t cmd_gro_show_show =
4768 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4770 cmdline_parse_token_string_t cmd_gro_show_port =
4771 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4773 cmdline_parse_token_num_t cmd_gro_show_pid =
4774 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4776 cmdline_parse_token_string_t cmd_gro_show_keyword =
4777 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4778 cmd_keyword, "gro");
4780 cmdline_parse_inst_t cmd_gro_show = {
4781 .f = cmd_gro_show_parsed,
4783 .help_str = "show port <port_id> gro",
4785 (void *)&cmd_gro_show_show,
4786 (void *)&cmd_gro_show_port,
4787 (void *)&cmd_gro_show_pid,
4788 (void *)&cmd_gro_show_keyword,
4793 /* *** SET FLUSH CYCLES FOR GRO *** */
4794 struct cmd_gro_flush_result {
4795 cmdline_fixed_string_t cmd_set;
4796 cmdline_fixed_string_t cmd_keyword;
4797 cmdline_fixed_string_t cmd_flush;
4802 cmd_gro_flush_parsed(void *parsed_result,
4803 __attribute__((unused)) struct cmdline *cl,
4804 __attribute__((unused)) void *data)
4806 struct cmd_gro_flush_result *res;
4808 res = parsed_result;
4809 if ((!strcmp(res->cmd_keyword, "gro")) &&
4810 (!strcmp(res->cmd_flush, "flush")))
4811 setup_gro_flush_cycles(res->cmd_cycles);
4814 cmdline_parse_token_string_t cmd_gro_flush_set =
4815 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4817 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4818 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4819 cmd_keyword, "gro");
4820 cmdline_parse_token_string_t cmd_gro_flush_flush =
4821 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4822 cmd_flush, "flush");
4823 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4824 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4827 cmdline_parse_inst_t cmd_gro_flush = {
4828 .f = cmd_gro_flush_parsed,
4830 .help_str = "set gro flush <cycles>",
4832 (void *)&cmd_gro_flush_set,
4833 (void *)&cmd_gro_flush_keyword,
4834 (void *)&cmd_gro_flush_flush,
4835 (void *)&cmd_gro_flush_cycles,
4840 /* *** ENABLE/DISABLE GSO *** */
4841 struct cmd_gso_enable_result {
4842 cmdline_fixed_string_t cmd_set;
4843 cmdline_fixed_string_t cmd_port;
4844 cmdline_fixed_string_t cmd_keyword;
4845 cmdline_fixed_string_t cmd_mode;
4850 cmd_gso_enable_parsed(void *parsed_result,
4851 __attribute__((unused)) struct cmdline *cl,
4852 __attribute__((unused)) void *data)
4854 struct cmd_gso_enable_result *res;
4856 res = parsed_result;
4857 if (!strcmp(res->cmd_keyword, "gso"))
4858 setup_gso(res->cmd_mode, res->cmd_pid);
4861 cmdline_parse_token_string_t cmd_gso_enable_set =
4862 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4864 cmdline_parse_token_string_t cmd_gso_enable_port =
4865 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4867 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4868 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4869 cmd_keyword, "gso");
4870 cmdline_parse_token_string_t cmd_gso_enable_mode =
4871 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4872 cmd_mode, "on#off");
4873 cmdline_parse_token_num_t cmd_gso_enable_pid =
4874 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4877 cmdline_parse_inst_t cmd_gso_enable = {
4878 .f = cmd_gso_enable_parsed,
4880 .help_str = "set port <port_id> gso on|off",
4882 (void *)&cmd_gso_enable_set,
4883 (void *)&cmd_gso_enable_port,
4884 (void *)&cmd_gso_enable_pid,
4885 (void *)&cmd_gso_enable_keyword,
4886 (void *)&cmd_gso_enable_mode,
4891 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4892 struct cmd_gso_size_result {
4893 cmdline_fixed_string_t cmd_set;
4894 cmdline_fixed_string_t cmd_keyword;
4895 cmdline_fixed_string_t cmd_segsz;
4900 cmd_gso_size_parsed(void *parsed_result,
4901 __attribute__((unused)) struct cmdline *cl,
4902 __attribute__((unused)) void *data)
4904 struct cmd_gso_size_result *res = parsed_result;
4906 if (test_done == 0) {
4907 printf("Before setting GSO segsz, please first"
4908 " stop fowarding\n");
4912 if (!strcmp(res->cmd_keyword, "gso") &&
4913 !strcmp(res->cmd_segsz, "segsz")) {
4914 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4915 printf("gso_size should be larger than %zu."
4916 " Please input a legal value\n",
4917 RTE_GSO_SEG_SIZE_MIN);
4919 gso_max_segment_size = res->cmd_size;
4923 cmdline_parse_token_string_t cmd_gso_size_set =
4924 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4926 cmdline_parse_token_string_t cmd_gso_size_keyword =
4927 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4928 cmd_keyword, "gso");
4929 cmdline_parse_token_string_t cmd_gso_size_segsz =
4930 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4931 cmd_segsz, "segsz");
4932 cmdline_parse_token_num_t cmd_gso_size_size =
4933 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4936 cmdline_parse_inst_t cmd_gso_size = {
4937 .f = cmd_gso_size_parsed,
4939 .help_str = "set gso segsz <length>",
4941 (void *)&cmd_gso_size_set,
4942 (void *)&cmd_gso_size_keyword,
4943 (void *)&cmd_gso_size_segsz,
4944 (void *)&cmd_gso_size_size,
4949 /* *** SHOW GSO CONFIGURATION *** */
4950 struct cmd_gso_show_result {
4951 cmdline_fixed_string_t cmd_show;
4952 cmdline_fixed_string_t cmd_port;
4953 cmdline_fixed_string_t cmd_keyword;
4958 cmd_gso_show_parsed(void *parsed_result,
4959 __attribute__((unused)) struct cmdline *cl,
4960 __attribute__((unused)) void *data)
4962 struct cmd_gso_show_result *res = parsed_result;
4964 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4965 printf("invalid port id %u\n", res->cmd_pid);
4968 if (!strcmp(res->cmd_keyword, "gso")) {
4969 if (gso_ports[res->cmd_pid].enable) {
4970 printf("Max GSO'd packet size: %uB\n"
4971 "Supported GSO types: TCP/IPv4, "
4972 "UDP/IPv4, VxLAN with inner "
4973 "TCP/IPv4 packet, GRE with inner "
4974 "TCP/IPv4 packet\n",
4975 gso_max_segment_size);
4977 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4981 cmdline_parse_token_string_t cmd_gso_show_show =
4982 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4984 cmdline_parse_token_string_t cmd_gso_show_port =
4985 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4987 cmdline_parse_token_string_t cmd_gso_show_keyword =
4988 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4989 cmd_keyword, "gso");
4990 cmdline_parse_token_num_t cmd_gso_show_pid =
4991 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4994 cmdline_parse_inst_t cmd_gso_show = {
4995 .f = cmd_gso_show_parsed,
4997 .help_str = "show port <port_id> gso",
4999 (void *)&cmd_gso_show_show,
5000 (void *)&cmd_gso_show_port,
5001 (void *)&cmd_gso_show_pid,
5002 (void *)&cmd_gso_show_keyword,
5007 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5008 struct cmd_set_flush_rx {
5009 cmdline_fixed_string_t set;
5010 cmdline_fixed_string_t flush_rx;
5011 cmdline_fixed_string_t mode;
5015 cmd_set_flush_rx_parsed(void *parsed_result,
5016 __attribute__((unused)) struct cmdline *cl,
5017 __attribute__((unused)) void *data)
5019 struct cmd_set_flush_rx *res = parsed_result;
5020 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5023 cmdline_parse_token_string_t cmd_setflushrx_set =
5024 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5026 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5027 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5028 flush_rx, "flush_rx");
5029 cmdline_parse_token_string_t cmd_setflushrx_mode =
5030 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5034 cmdline_parse_inst_t cmd_set_flush_rx = {
5035 .f = cmd_set_flush_rx_parsed,
5036 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5039 (void *)&cmd_setflushrx_set,
5040 (void *)&cmd_setflushrx_flush_rx,
5041 (void *)&cmd_setflushrx_mode,
5046 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5047 struct cmd_set_link_check {
5048 cmdline_fixed_string_t set;
5049 cmdline_fixed_string_t link_check;
5050 cmdline_fixed_string_t mode;
5054 cmd_set_link_check_parsed(void *parsed_result,
5055 __attribute__((unused)) struct cmdline *cl,
5056 __attribute__((unused)) void *data)
5058 struct cmd_set_link_check *res = parsed_result;
5059 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5062 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5063 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5065 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5066 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5067 link_check, "link_check");
5068 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5069 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5073 cmdline_parse_inst_t cmd_set_link_check = {
5074 .f = cmd_set_link_check_parsed,
5075 .help_str = "set link_check on|off: Enable/Disable link status check "
5076 "when starting/stopping a port",
5079 (void *)&cmd_setlinkcheck_set,
5080 (void *)&cmd_setlinkcheck_link_check,
5081 (void *)&cmd_setlinkcheck_mode,
5086 /* *** SET NIC BYPASS MODE *** */
5087 struct cmd_set_bypass_mode_result {
5088 cmdline_fixed_string_t set;
5089 cmdline_fixed_string_t bypass;
5090 cmdline_fixed_string_t mode;
5091 cmdline_fixed_string_t value;
5096 cmd_set_bypass_mode_parsed(void *parsed_result,
5097 __attribute__((unused)) struct cmdline *cl,
5098 __attribute__((unused)) void *data)
5100 struct cmd_set_bypass_mode_result *res = parsed_result;
5101 portid_t port_id = res->port_id;
5102 int32_t rc = -EINVAL;
5104 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5105 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5107 if (!strcmp(res->value, "bypass"))
5108 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5109 else if (!strcmp(res->value, "isolate"))
5110 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5112 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5114 /* Set the bypass mode for the relevant port. */
5115 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5118 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5121 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5122 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5124 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5125 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5127 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5128 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5130 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5131 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5132 value, "normal#bypass#isolate");
5133 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5134 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5137 cmdline_parse_inst_t cmd_set_bypass_mode = {
5138 .f = cmd_set_bypass_mode_parsed,
5139 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5140 "Set the NIC bypass mode for port_id",
5143 (void *)&cmd_setbypass_mode_set,
5144 (void *)&cmd_setbypass_mode_bypass,
5145 (void *)&cmd_setbypass_mode_mode,
5146 (void *)&cmd_setbypass_mode_value,
5147 (void *)&cmd_setbypass_mode_port,
5152 /* *** SET NIC BYPASS EVENT *** */
5153 struct cmd_set_bypass_event_result {
5154 cmdline_fixed_string_t set;
5155 cmdline_fixed_string_t bypass;
5156 cmdline_fixed_string_t event;
5157 cmdline_fixed_string_t event_value;
5158 cmdline_fixed_string_t mode;
5159 cmdline_fixed_string_t mode_value;
5164 cmd_set_bypass_event_parsed(void *parsed_result,
5165 __attribute__((unused)) struct cmdline *cl,
5166 __attribute__((unused)) void *data)
5168 int32_t rc = -EINVAL;
5169 struct cmd_set_bypass_event_result *res = parsed_result;
5170 portid_t port_id = res->port_id;
5172 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5173 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5174 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5176 if (!strcmp(res->event_value, "timeout"))
5177 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5178 else if (!strcmp(res->event_value, "os_on"))
5179 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5180 else if (!strcmp(res->event_value, "os_off"))
5181 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5182 else if (!strcmp(res->event_value, "power_on"))
5183 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5184 else if (!strcmp(res->event_value, "power_off"))
5185 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5187 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5189 if (!strcmp(res->mode_value, "bypass"))
5190 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5191 else if (!strcmp(res->mode_value, "isolate"))
5192 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5194 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5196 /* Set the watchdog timeout. */
5197 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5200 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5201 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5205 printf("Failed to set timeout value %u "
5206 "for port %d, errto code: %d.\n",
5207 bypass_timeout, port_id, rc);
5211 /* Set the bypass event to transition to bypass mode. */
5212 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5217 printf("\t Failed to set bypass event for port = %d.\n",
5221 cmdline_parse_token_string_t cmd_setbypass_event_set =
5222 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5224 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5225 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5227 cmdline_parse_token_string_t cmd_setbypass_event_event =
5228 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5230 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5231 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5232 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5233 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5234 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5236 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5237 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5238 mode_value, "normal#bypass#isolate");
5239 cmdline_parse_token_num_t cmd_setbypass_event_port =
5240 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5243 cmdline_parse_inst_t cmd_set_bypass_event = {
5244 .f = cmd_set_bypass_event_parsed,
5245 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5246 "power_off mode normal|bypass|isolate <port_id>: "
5247 "Set the NIC bypass event mode for port_id",
5250 (void *)&cmd_setbypass_event_set,
5251 (void *)&cmd_setbypass_event_bypass,
5252 (void *)&cmd_setbypass_event_event,
5253 (void *)&cmd_setbypass_event_event_value,
5254 (void *)&cmd_setbypass_event_mode,
5255 (void *)&cmd_setbypass_event_mode_value,
5256 (void *)&cmd_setbypass_event_port,
5262 /* *** SET NIC BYPASS TIMEOUT *** */
5263 struct cmd_set_bypass_timeout_result {
5264 cmdline_fixed_string_t set;
5265 cmdline_fixed_string_t bypass;
5266 cmdline_fixed_string_t timeout;
5267 cmdline_fixed_string_t value;
5271 cmd_set_bypass_timeout_parsed(void *parsed_result,
5272 __attribute__((unused)) struct cmdline *cl,
5273 __attribute__((unused)) void *data)
5275 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5277 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5278 if (!strcmp(res->value, "1.5"))
5279 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5280 else if (!strcmp(res->value, "2"))
5281 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5282 else if (!strcmp(res->value, "3"))
5283 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5284 else if (!strcmp(res->value, "4"))
5285 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5286 else if (!strcmp(res->value, "8"))
5287 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5288 else if (!strcmp(res->value, "16"))
5289 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5290 else if (!strcmp(res->value, "32"))
5291 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5293 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5297 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5298 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5300 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5301 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5303 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5304 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5305 timeout, "timeout");
5306 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5307 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5308 value, "0#1.5#2#3#4#8#16#32");
5310 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5311 .f = cmd_set_bypass_timeout_parsed,
5312 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5313 "Set the NIC bypass watchdog timeout in seconds",
5316 (void *)&cmd_setbypass_timeout_set,
5317 (void *)&cmd_setbypass_timeout_bypass,
5318 (void *)&cmd_setbypass_timeout_timeout,
5319 (void *)&cmd_setbypass_timeout_value,
5324 /* *** SHOW NIC BYPASS MODE *** */
5325 struct cmd_show_bypass_config_result {
5326 cmdline_fixed_string_t show;
5327 cmdline_fixed_string_t bypass;
5328 cmdline_fixed_string_t config;
5333 cmd_show_bypass_config_parsed(void *parsed_result,
5334 __attribute__((unused)) struct cmdline *cl,
5335 __attribute__((unused)) void *data)
5337 struct cmd_show_bypass_config_result *res = parsed_result;
5338 portid_t port_id = res->port_id;
5340 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5341 uint32_t event_mode;
5342 uint32_t bypass_mode;
5343 uint32_t timeout = bypass_timeout;
5346 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5347 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5348 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5349 {"UNKNOWN", "normal", "bypass", "isolate"};
5350 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5357 int num_events = (sizeof events) / (sizeof events[0]);
5359 /* Display the bypass mode.*/
5360 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5361 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5365 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5366 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5368 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5371 /* Display the bypass timeout.*/
5372 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5373 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5375 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5377 /* Display the bypass events and associated modes. */
5378 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5380 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5381 printf("\tFailed to get bypass mode for event = %s\n",
5384 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5385 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5387 printf("\tbypass event: %-16s = %s\n", events[i],
5393 printf("\tFailed to get bypass configuration for port = %d\n",
5397 cmdline_parse_token_string_t cmd_showbypass_config_show =
5398 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5400 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5401 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5403 cmdline_parse_token_string_t cmd_showbypass_config_config =
5404 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5406 cmdline_parse_token_num_t cmd_showbypass_config_port =
5407 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5410 cmdline_parse_inst_t cmd_show_bypass_config = {
5411 .f = cmd_show_bypass_config_parsed,
5412 .help_str = "show bypass config <port_id>: "
5413 "Show the NIC bypass config for port_id",
5416 (void *)&cmd_showbypass_config_show,
5417 (void *)&cmd_showbypass_config_bypass,
5418 (void *)&cmd_showbypass_config_config,
5419 (void *)&cmd_showbypass_config_port,
5424 #ifdef RTE_LIBRTE_PMD_BOND
5425 /* *** SET BONDING MODE *** */
5426 struct cmd_set_bonding_mode_result {
5427 cmdline_fixed_string_t set;
5428 cmdline_fixed_string_t bonding;
5429 cmdline_fixed_string_t mode;
5434 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5435 __attribute__((unused)) struct cmdline *cl,
5436 __attribute__((unused)) void *data)
5438 struct cmd_set_bonding_mode_result *res = parsed_result;
5439 portid_t port_id = res->port_id;
5441 /* Set the bonding mode for the relevant port. */
5442 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5443 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5446 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5447 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5449 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5450 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5451 bonding, "bonding");
5452 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5453 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5455 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5456 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5458 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5459 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5462 cmdline_parse_inst_t cmd_set_bonding_mode = {
5463 .f = cmd_set_bonding_mode_parsed,
5464 .help_str = "set bonding mode <mode_value> <port_id>: "
5465 "Set the bonding mode for port_id",
5468 (void *) &cmd_setbonding_mode_set,
5469 (void *) &cmd_setbonding_mode_bonding,
5470 (void *) &cmd_setbonding_mode_mode,
5471 (void *) &cmd_setbonding_mode_value,
5472 (void *) &cmd_setbonding_mode_port,
5477 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5478 struct cmd_set_bonding_lacp_dedicated_queues_result {
5479 cmdline_fixed_string_t set;
5480 cmdline_fixed_string_t bonding;
5481 cmdline_fixed_string_t lacp;
5482 cmdline_fixed_string_t dedicated_queues;
5484 cmdline_fixed_string_t mode;
5487 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5488 __attribute__((unused)) struct cmdline *cl,
5489 __attribute__((unused)) void *data)
5491 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5492 portid_t port_id = res->port_id;
5493 struct rte_port *port;
5495 port = &ports[port_id];
5497 /** Check if the port is not started **/
5498 if (port->port_status != RTE_PORT_STOPPED) {
5499 printf("Please stop port %d first\n", port_id);
5503 if (!strcmp(res->mode, "enable")) {
5504 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5505 printf("Dedicate queues for LACP control packets"
5508 printf("Enabling dedicate queues for LACP control "
5509 "packets on port %d failed\n", port_id);
5510 } else if (!strcmp(res->mode, "disable")) {
5511 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5512 printf("Dedicated queues for LACP control packets "
5515 printf("Disabling dedicated queues for LACP control "
5516 "traffic on port %d failed\n", port_id);
5520 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5521 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5523 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5524 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5525 bonding, "bonding");
5526 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5527 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5529 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5530 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5531 dedicated_queues, "dedicated_queues");
5532 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5533 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5535 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5536 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5537 mode, "enable#disable");
5539 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5540 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5541 .help_str = "set bonding lacp dedicated_queues <port_id> "
5543 "Enable/disable dedicated queues for LACP control traffic for port_id",
5546 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5547 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5548 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5549 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5550 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5551 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5556 /* *** SET BALANCE XMIT POLICY *** */
5557 struct cmd_set_bonding_balance_xmit_policy_result {
5558 cmdline_fixed_string_t set;
5559 cmdline_fixed_string_t bonding;
5560 cmdline_fixed_string_t balance_xmit_policy;
5562 cmdline_fixed_string_t policy;
5565 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5566 __attribute__((unused)) struct cmdline *cl,
5567 __attribute__((unused)) void *data)
5569 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5570 portid_t port_id = res->port_id;
5573 if (!strcmp(res->policy, "l2")) {
5574 policy = BALANCE_XMIT_POLICY_LAYER2;
5575 } else if (!strcmp(res->policy, "l23")) {
5576 policy = BALANCE_XMIT_POLICY_LAYER23;
5577 } else if (!strcmp(res->policy, "l34")) {
5578 policy = BALANCE_XMIT_POLICY_LAYER34;
5580 printf("\t Invalid xmit policy selection");
5584 /* Set the bonding mode for the relevant port. */
5585 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5586 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5591 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5592 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5594 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5595 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5596 bonding, "bonding");
5597 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5598 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5599 balance_xmit_policy, "balance_xmit_policy");
5600 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5601 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5603 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5604 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5605 policy, "l2#l23#l34");
5607 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5608 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5609 .help_str = "set bonding balance_xmit_policy <port_id> "
5611 "Set the bonding balance_xmit_policy for port_id",
5614 (void *)&cmd_setbonding_balance_xmit_policy_set,
5615 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5616 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5617 (void *)&cmd_setbonding_balance_xmit_policy_port,
5618 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5623 /* *** SHOW NIC BONDING CONFIGURATION *** */
5624 struct cmd_show_bonding_config_result {
5625 cmdline_fixed_string_t show;
5626 cmdline_fixed_string_t bonding;
5627 cmdline_fixed_string_t config;
5631 static void cmd_show_bonding_config_parsed(void *parsed_result,
5632 __attribute__((unused)) struct cmdline *cl,
5633 __attribute__((unused)) void *data)
5635 struct cmd_show_bonding_config_result *res = parsed_result;
5636 int bonding_mode, agg_mode;
5637 portid_t slaves[RTE_MAX_ETHPORTS];
5638 int num_slaves, num_active_slaves;
5641 portid_t port_id = res->port_id;
5643 /* Display the bonding mode.*/
5644 bonding_mode = rte_eth_bond_mode_get(port_id);
5645 if (bonding_mode < 0) {
5646 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5649 printf("\tBonding mode: %d\n", bonding_mode);
5651 if (bonding_mode == BONDING_MODE_BALANCE) {
5652 int balance_xmit_policy;
5654 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5655 if (balance_xmit_policy < 0) {
5656 printf("\tFailed to get balance xmit policy for port = %d\n",
5660 printf("\tBalance Xmit Policy: ");
5662 switch (balance_xmit_policy) {
5663 case BALANCE_XMIT_POLICY_LAYER2:
5664 printf("BALANCE_XMIT_POLICY_LAYER2");
5666 case BALANCE_XMIT_POLICY_LAYER23:
5667 printf("BALANCE_XMIT_POLICY_LAYER23");
5669 case BALANCE_XMIT_POLICY_LAYER34:
5670 printf("BALANCE_XMIT_POLICY_LAYER34");
5677 if (bonding_mode == BONDING_MODE_8023AD) {
5678 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5679 printf("\tIEEE802.3AD Aggregator Mode: ");
5682 printf("bandwidth");
5694 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5696 if (num_slaves < 0) {
5697 printf("\tFailed to get slave list for port = %d\n", port_id);
5700 if (num_slaves > 0) {
5701 printf("\tSlaves (%d): [", num_slaves);
5702 for (i = 0; i < num_slaves - 1; i++)
5703 printf("%d ", slaves[i]);
5705 printf("%d]\n", slaves[num_slaves - 1]);
5707 printf("\tSlaves: []\n");
5711 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5714 if (num_active_slaves < 0) {
5715 printf("\tFailed to get active slave list for port = %d\n", port_id);
5718 if (num_active_slaves > 0) {
5719 printf("\tActive Slaves (%d): [", num_active_slaves);
5720 for (i = 0; i < num_active_slaves - 1; i++)
5721 printf("%d ", slaves[i]);
5723 printf("%d]\n", slaves[num_active_slaves - 1]);
5726 printf("\tActive Slaves: []\n");
5730 primary_id = rte_eth_bond_primary_get(port_id);
5731 if (primary_id < 0) {
5732 printf("\tFailed to get primary slave for port = %d\n", port_id);
5735 printf("\tPrimary: [%d]\n", primary_id);
5739 cmdline_parse_token_string_t cmd_showbonding_config_show =
5740 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5742 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5743 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5744 bonding, "bonding");
5745 cmdline_parse_token_string_t cmd_showbonding_config_config =
5746 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5748 cmdline_parse_token_num_t cmd_showbonding_config_port =
5749 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5752 cmdline_parse_inst_t cmd_show_bonding_config = {
5753 .f = cmd_show_bonding_config_parsed,
5754 .help_str = "show bonding config <port_id>: "
5755 "Show the bonding config for port_id",
5758 (void *)&cmd_showbonding_config_show,
5759 (void *)&cmd_showbonding_config_bonding,
5760 (void *)&cmd_showbonding_config_config,
5761 (void *)&cmd_showbonding_config_port,
5766 /* *** SET BONDING PRIMARY *** */
5767 struct cmd_set_bonding_primary_result {
5768 cmdline_fixed_string_t set;
5769 cmdline_fixed_string_t bonding;
5770 cmdline_fixed_string_t primary;
5775 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5776 __attribute__((unused)) struct cmdline *cl,
5777 __attribute__((unused)) void *data)
5779 struct cmd_set_bonding_primary_result *res = parsed_result;
5780 portid_t master_port_id = res->port_id;
5781 portid_t slave_port_id = res->slave_id;
5783 /* Set the primary slave for a bonded device. */
5784 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5785 printf("\t Failed to set primary slave for port = %d.\n",
5792 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5793 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5795 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5796 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5797 bonding, "bonding");
5798 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5799 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5800 primary, "primary");
5801 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5802 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5804 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5805 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5808 cmdline_parse_inst_t cmd_set_bonding_primary = {
5809 .f = cmd_set_bonding_primary_parsed,
5810 .help_str = "set bonding primary <slave_id> <port_id>: "
5811 "Set the primary slave for port_id",
5814 (void *)&cmd_setbonding_primary_set,
5815 (void *)&cmd_setbonding_primary_bonding,
5816 (void *)&cmd_setbonding_primary_primary,
5817 (void *)&cmd_setbonding_primary_slave,
5818 (void *)&cmd_setbonding_primary_port,
5823 /* *** ADD SLAVE *** */
5824 struct cmd_add_bonding_slave_result {
5825 cmdline_fixed_string_t add;
5826 cmdline_fixed_string_t bonding;
5827 cmdline_fixed_string_t slave;
5832 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5833 __attribute__((unused)) struct cmdline *cl,
5834 __attribute__((unused)) void *data)
5836 struct cmd_add_bonding_slave_result *res = parsed_result;
5837 portid_t master_port_id = res->port_id;
5838 portid_t slave_port_id = res->slave_id;
5840 /* add the slave for a bonded device. */
5841 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5842 printf("\t Failed to add slave %d to master port = %d.\n",
5843 slave_port_id, master_port_id);
5847 set_port_slave_flag(slave_port_id);
5850 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5851 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5853 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5854 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5855 bonding, "bonding");
5856 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5857 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5859 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5860 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5862 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5863 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5866 cmdline_parse_inst_t cmd_add_bonding_slave = {
5867 .f = cmd_add_bonding_slave_parsed,
5868 .help_str = "add bonding slave <slave_id> <port_id>: "
5869 "Add a slave device to a bonded device",
5872 (void *)&cmd_addbonding_slave_add,
5873 (void *)&cmd_addbonding_slave_bonding,
5874 (void *)&cmd_addbonding_slave_slave,
5875 (void *)&cmd_addbonding_slave_slaveid,
5876 (void *)&cmd_addbonding_slave_port,
5881 /* *** REMOVE SLAVE *** */
5882 struct cmd_remove_bonding_slave_result {
5883 cmdline_fixed_string_t remove;
5884 cmdline_fixed_string_t bonding;
5885 cmdline_fixed_string_t slave;
5890 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5891 __attribute__((unused)) struct cmdline *cl,
5892 __attribute__((unused)) void *data)
5894 struct cmd_remove_bonding_slave_result *res = parsed_result;
5895 portid_t master_port_id = res->port_id;
5896 portid_t slave_port_id = res->slave_id;
5898 /* remove the slave from a bonded device. */
5899 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5900 printf("\t Failed to remove slave %d from master port = %d.\n",
5901 slave_port_id, master_port_id);
5905 clear_port_slave_flag(slave_port_id);
5908 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5909 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5911 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5912 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5913 bonding, "bonding");
5914 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5915 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5917 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5918 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5920 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5921 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5924 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5925 .f = cmd_remove_bonding_slave_parsed,
5926 .help_str = "remove bonding slave <slave_id> <port_id>: "
5927 "Remove a slave device from a bonded device",
5930 (void *)&cmd_removebonding_slave_remove,
5931 (void *)&cmd_removebonding_slave_bonding,
5932 (void *)&cmd_removebonding_slave_slave,
5933 (void *)&cmd_removebonding_slave_slaveid,
5934 (void *)&cmd_removebonding_slave_port,
5939 /* *** CREATE BONDED DEVICE *** */
5940 struct cmd_create_bonded_device_result {
5941 cmdline_fixed_string_t create;
5942 cmdline_fixed_string_t bonded;
5943 cmdline_fixed_string_t device;
5948 static int bond_dev_num = 0;
5950 static void cmd_create_bonded_device_parsed(void *parsed_result,
5951 __attribute__((unused)) struct cmdline *cl,
5952 __attribute__((unused)) void *data)
5954 struct cmd_create_bonded_device_result *res = parsed_result;
5955 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5958 if (test_done == 0) {
5959 printf("Please stop forwarding first\n");
5963 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5966 /* Create a new bonded device. */
5967 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5969 printf("\t Failed to create bonded device.\n");
5972 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5975 /* Update number of ports */
5976 nb_ports = rte_eth_dev_count_avail();
5977 reconfig(port_id, res->socket);
5978 rte_eth_promiscuous_enable(port_id);
5983 cmdline_parse_token_string_t cmd_createbonded_device_create =
5984 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5986 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5987 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5989 cmdline_parse_token_string_t cmd_createbonded_device_device =
5990 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5992 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5993 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5995 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5996 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5999 cmdline_parse_inst_t cmd_create_bonded_device = {
6000 .f = cmd_create_bonded_device_parsed,
6001 .help_str = "create bonded device <mode> <socket>: "
6002 "Create a new bonded device with specific bonding mode and socket",
6005 (void *)&cmd_createbonded_device_create,
6006 (void *)&cmd_createbonded_device_bonded,
6007 (void *)&cmd_createbonded_device_device,
6008 (void *)&cmd_createbonded_device_mode,
6009 (void *)&cmd_createbonded_device_socket,
6014 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6015 struct cmd_set_bond_mac_addr_result {
6016 cmdline_fixed_string_t set;
6017 cmdline_fixed_string_t bonding;
6018 cmdline_fixed_string_t mac_addr;
6020 struct ether_addr address;
6023 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6024 __attribute__((unused)) struct cmdline *cl,
6025 __attribute__((unused)) void *data)
6027 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6030 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6033 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6035 /* check the return value and print it if is < 0 */
6037 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6040 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6041 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6042 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6043 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6045 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6046 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6048 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6049 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6051 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6052 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6054 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6055 .f = cmd_set_bond_mac_addr_parsed,
6057 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6059 (void *)&cmd_set_bond_mac_addr_set,
6060 (void *)&cmd_set_bond_mac_addr_bonding,
6061 (void *)&cmd_set_bond_mac_addr_mac,
6062 (void *)&cmd_set_bond_mac_addr_portnum,
6063 (void *)&cmd_set_bond_mac_addr_addr,
6069 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6070 struct cmd_set_bond_mon_period_result {
6071 cmdline_fixed_string_t set;
6072 cmdline_fixed_string_t bonding;
6073 cmdline_fixed_string_t mon_period;
6078 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6079 __attribute__((unused)) struct cmdline *cl,
6080 __attribute__((unused)) void *data)
6082 struct cmd_set_bond_mon_period_result *res = parsed_result;
6085 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6087 /* check the return value and print it if is < 0 */
6089 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6092 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6093 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6095 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6096 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6097 bonding, "bonding");
6098 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6099 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6100 mon_period, "mon_period");
6101 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6102 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6104 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6105 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6108 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6109 .f = cmd_set_bond_mon_period_parsed,
6111 .help_str = "set bonding mon_period <port_id> <period_ms>",
6113 (void *)&cmd_set_bond_mon_period_set,
6114 (void *)&cmd_set_bond_mon_period_bonding,
6115 (void *)&cmd_set_bond_mon_period_mon_period,
6116 (void *)&cmd_set_bond_mon_period_portnum,
6117 (void *)&cmd_set_bond_mon_period_period_ms,
6124 struct cmd_set_bonding_agg_mode_policy_result {
6125 cmdline_fixed_string_t set;
6126 cmdline_fixed_string_t bonding;
6127 cmdline_fixed_string_t agg_mode;
6129 cmdline_fixed_string_t policy;
6134 cmd_set_bonding_agg_mode(void *parsed_result,
6135 __attribute__((unused)) struct cmdline *cl,
6136 __attribute__((unused)) void *data)
6138 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6139 uint8_t policy = AGG_BANDWIDTH;
6141 if (!strcmp(res->policy, "bandwidth"))
6142 policy = AGG_BANDWIDTH;
6143 else if (!strcmp(res->policy, "stable"))
6144 policy = AGG_STABLE;
6145 else if (!strcmp(res->policy, "count"))
6148 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6152 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6153 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6155 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6156 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6157 bonding, "bonding");
6159 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6160 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6161 agg_mode, "agg_mode");
6163 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6164 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6167 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6168 TOKEN_STRING_INITIALIZER(
6169 struct cmd_set_bonding_balance_xmit_policy_result,
6170 policy, "stable#bandwidth#count");
6172 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6173 .f = cmd_set_bonding_agg_mode,
6175 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6177 (void *)&cmd_set_bonding_agg_mode_set,
6178 (void *)&cmd_set_bonding_agg_mode_bonding,
6179 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6180 (void *)&cmd_set_bonding_agg_mode_portnum,
6181 (void *)&cmd_set_bonding_agg_mode_policy_string,
6187 #endif /* RTE_LIBRTE_PMD_BOND */
6189 /* *** SET FORWARDING MODE *** */
6190 struct cmd_set_fwd_mode_result {
6191 cmdline_fixed_string_t set;
6192 cmdline_fixed_string_t fwd;
6193 cmdline_fixed_string_t mode;
6196 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6197 __attribute__((unused)) struct cmdline *cl,
6198 __attribute__((unused)) void *data)
6200 struct cmd_set_fwd_mode_result *res = parsed_result;
6203 set_pkt_forwarding_mode(res->mode);
6206 cmdline_parse_token_string_t cmd_setfwd_set =
6207 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6208 cmdline_parse_token_string_t cmd_setfwd_fwd =
6209 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6210 cmdline_parse_token_string_t cmd_setfwd_mode =
6211 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6212 "" /* defined at init */);
6214 cmdline_parse_inst_t cmd_set_fwd_mode = {
6215 .f = cmd_set_fwd_mode_parsed,
6217 .help_str = NULL, /* defined at init */
6219 (void *)&cmd_setfwd_set,
6220 (void *)&cmd_setfwd_fwd,
6221 (void *)&cmd_setfwd_mode,
6226 static void cmd_set_fwd_mode_init(void)
6229 static char token[128];
6230 static char help[256];
6231 cmdline_parse_token_string_t *token_struct;
6233 modes = list_pkt_forwarding_modes();
6234 snprintf(help, sizeof(help), "set fwd %s: "
6235 "Set packet forwarding mode", modes);
6236 cmd_set_fwd_mode.help_str = help;
6238 /* string token separator is # */
6239 for (c = token; *modes != '\0'; modes++)
6244 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6245 token_struct->string_data.str = token;
6248 /* *** SET RETRY FORWARDING MODE *** */
6249 struct cmd_set_fwd_retry_mode_result {
6250 cmdline_fixed_string_t set;
6251 cmdline_fixed_string_t fwd;
6252 cmdline_fixed_string_t mode;
6253 cmdline_fixed_string_t retry;
6256 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6257 __attribute__((unused)) struct cmdline *cl,
6258 __attribute__((unused)) void *data)
6260 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6263 set_pkt_forwarding_mode(res->mode);
6266 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6267 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6269 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6270 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6272 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6273 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6275 "" /* defined at init */);
6276 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6277 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6280 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6281 .f = cmd_set_fwd_retry_mode_parsed,
6283 .help_str = NULL, /* defined at init */
6285 (void *)&cmd_setfwd_retry_set,
6286 (void *)&cmd_setfwd_retry_fwd,
6287 (void *)&cmd_setfwd_retry_mode,
6288 (void *)&cmd_setfwd_retry_retry,
6293 static void cmd_set_fwd_retry_mode_init(void)
6296 static char token[128];
6297 static char help[256];
6298 cmdline_parse_token_string_t *token_struct;
6300 modes = list_pkt_forwarding_retry_modes();
6301 snprintf(help, sizeof(help), "set fwd %s retry: "
6302 "Set packet forwarding mode with retry", modes);
6303 cmd_set_fwd_retry_mode.help_str = help;
6305 /* string token separator is # */
6306 for (c = token; *modes != '\0'; modes++)
6311 token_struct = (cmdline_parse_token_string_t *)
6312 cmd_set_fwd_retry_mode.tokens[2];
6313 token_struct->string_data.str = token;
6316 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6317 struct cmd_set_burst_tx_retry_result {
6318 cmdline_fixed_string_t set;
6319 cmdline_fixed_string_t burst;
6320 cmdline_fixed_string_t tx;
6321 cmdline_fixed_string_t delay;
6323 cmdline_fixed_string_t retry;
6327 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6328 __attribute__((unused)) struct cmdline *cl,
6329 __attribute__((unused)) void *data)
6331 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6333 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6334 && !strcmp(res->tx, "tx")) {
6335 if (!strcmp(res->delay, "delay"))
6336 burst_tx_delay_time = res->time;
6337 if (!strcmp(res->retry, "retry"))
6338 burst_tx_retry_num = res->retry_num;
6343 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6344 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6345 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6346 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6348 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6349 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6350 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6351 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6352 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6353 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6354 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6355 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6356 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6357 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6359 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6360 .f = cmd_set_burst_tx_retry_parsed,
6361 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6363 (void *)&cmd_set_burst_tx_retry_set,
6364 (void *)&cmd_set_burst_tx_retry_burst,
6365 (void *)&cmd_set_burst_tx_retry_tx,
6366 (void *)&cmd_set_burst_tx_retry_delay,
6367 (void *)&cmd_set_burst_tx_retry_time,
6368 (void *)&cmd_set_burst_tx_retry_retry,
6369 (void *)&cmd_set_burst_tx_retry_retry_num,
6374 /* *** SET PROMISC MODE *** */
6375 struct cmd_set_promisc_mode_result {
6376 cmdline_fixed_string_t set;
6377 cmdline_fixed_string_t promisc;
6378 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6379 uint16_t port_num; /* valid if "allports" argument == 0 */
6380 cmdline_fixed_string_t mode;
6383 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6384 __attribute__((unused)) struct cmdline *cl,
6387 struct cmd_set_promisc_mode_result *res = parsed_result;
6391 if (!strcmp(res->mode, "on"))
6398 RTE_ETH_FOREACH_DEV(i) {
6400 rte_eth_promiscuous_enable(i);
6402 rte_eth_promiscuous_disable(i);
6407 rte_eth_promiscuous_enable(res->port_num);
6409 rte_eth_promiscuous_disable(res->port_num);
6413 cmdline_parse_token_string_t cmd_setpromisc_set =
6414 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6415 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6416 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6418 cmdline_parse_token_string_t cmd_setpromisc_portall =
6419 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6421 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6422 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6424 cmdline_parse_token_string_t cmd_setpromisc_mode =
6425 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6428 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6429 .f = cmd_set_promisc_mode_parsed,
6431 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6433 (void *)&cmd_setpromisc_set,
6434 (void *)&cmd_setpromisc_promisc,
6435 (void *)&cmd_setpromisc_portall,
6436 (void *)&cmd_setpromisc_mode,
6441 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6442 .f = cmd_set_promisc_mode_parsed,
6444 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6446 (void *)&cmd_setpromisc_set,
6447 (void *)&cmd_setpromisc_promisc,
6448 (void *)&cmd_setpromisc_portnum,
6449 (void *)&cmd_setpromisc_mode,
6454 /* *** SET ALLMULTI MODE *** */
6455 struct cmd_set_allmulti_mode_result {
6456 cmdline_fixed_string_t set;
6457 cmdline_fixed_string_t allmulti;
6458 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6459 uint16_t port_num; /* valid if "allports" argument == 0 */
6460 cmdline_fixed_string_t mode;
6463 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6464 __attribute__((unused)) struct cmdline *cl,
6467 struct cmd_set_allmulti_mode_result *res = parsed_result;
6471 if (!strcmp(res->mode, "on"))
6478 RTE_ETH_FOREACH_DEV(i) {
6480 rte_eth_allmulticast_enable(i);
6482 rte_eth_allmulticast_disable(i);
6487 rte_eth_allmulticast_enable(res->port_num);
6489 rte_eth_allmulticast_disable(res->port_num);
6493 cmdline_parse_token_string_t cmd_setallmulti_set =
6494 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6495 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6496 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6498 cmdline_parse_token_string_t cmd_setallmulti_portall =
6499 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6501 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6502 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6504 cmdline_parse_token_string_t cmd_setallmulti_mode =
6505 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6508 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6509 .f = cmd_set_allmulti_mode_parsed,
6511 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6513 (void *)&cmd_setallmulti_set,
6514 (void *)&cmd_setallmulti_allmulti,
6515 (void *)&cmd_setallmulti_portall,
6516 (void *)&cmd_setallmulti_mode,
6521 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6522 .f = cmd_set_allmulti_mode_parsed,
6524 .help_str = "set allmulti <port_id> on|off: "
6525 "Set allmulti mode on port_id",
6527 (void *)&cmd_setallmulti_set,
6528 (void *)&cmd_setallmulti_allmulti,
6529 (void *)&cmd_setallmulti_portnum,
6530 (void *)&cmd_setallmulti_mode,
6535 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6536 struct cmd_link_flow_ctrl_set_result {
6537 cmdline_fixed_string_t set;
6538 cmdline_fixed_string_t flow_ctrl;
6539 cmdline_fixed_string_t rx;
6540 cmdline_fixed_string_t rx_lfc_mode;
6541 cmdline_fixed_string_t tx;
6542 cmdline_fixed_string_t tx_lfc_mode;
6543 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6544 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6545 cmdline_fixed_string_t autoneg_str;
6546 cmdline_fixed_string_t autoneg;
6547 cmdline_fixed_string_t hw_str;
6548 uint32_t high_water;
6549 cmdline_fixed_string_t lw_str;
6551 cmdline_fixed_string_t pt_str;
6552 uint16_t pause_time;
6553 cmdline_fixed_string_t xon_str;
6558 cmdline_parse_token_string_t cmd_lfc_set_set =
6559 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6561 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6562 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6563 flow_ctrl, "flow_ctrl");
6564 cmdline_parse_token_string_t cmd_lfc_set_rx =
6565 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6567 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6568 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6569 rx_lfc_mode, "on#off");
6570 cmdline_parse_token_string_t cmd_lfc_set_tx =
6571 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6573 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6574 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6575 tx_lfc_mode, "on#off");
6576 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6577 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6578 hw_str, "high_water");
6579 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6580 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6581 high_water, UINT32);
6582 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6583 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6584 lw_str, "low_water");
6585 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6586 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6588 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6589 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6590 pt_str, "pause_time");
6591 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6592 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6593 pause_time, UINT16);
6594 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6595 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6596 xon_str, "send_xon");
6597 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6598 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6600 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6601 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6602 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6603 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6604 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6605 mac_ctrl_frame_fwd_mode, "on#off");
6606 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6607 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6608 autoneg_str, "autoneg");
6609 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6610 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6612 cmdline_parse_token_num_t cmd_lfc_set_portid =
6613 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6616 /* forward declaration */
6618 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6621 cmdline_parse_inst_t cmd_link_flow_control_set = {
6622 .f = cmd_link_flow_ctrl_set_parsed,
6624 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6625 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6626 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6628 (void *)&cmd_lfc_set_set,
6629 (void *)&cmd_lfc_set_flow_ctrl,
6630 (void *)&cmd_lfc_set_rx,
6631 (void *)&cmd_lfc_set_rx_mode,
6632 (void *)&cmd_lfc_set_tx,
6633 (void *)&cmd_lfc_set_tx_mode,
6634 (void *)&cmd_lfc_set_high_water,
6635 (void *)&cmd_lfc_set_low_water,
6636 (void *)&cmd_lfc_set_pause_time,
6637 (void *)&cmd_lfc_set_send_xon,
6638 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6639 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6640 (void *)&cmd_lfc_set_autoneg_str,
6641 (void *)&cmd_lfc_set_autoneg,
6642 (void *)&cmd_lfc_set_portid,
6647 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6648 .f = cmd_link_flow_ctrl_set_parsed,
6649 .data = (void *)&cmd_link_flow_control_set_rx,
6650 .help_str = "set flow_ctrl rx on|off <port_id>: "
6651 "Change rx flow control parameter",
6653 (void *)&cmd_lfc_set_set,
6654 (void *)&cmd_lfc_set_flow_ctrl,
6655 (void *)&cmd_lfc_set_rx,
6656 (void *)&cmd_lfc_set_rx_mode,
6657 (void *)&cmd_lfc_set_portid,
6662 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6663 .f = cmd_link_flow_ctrl_set_parsed,
6664 .data = (void *)&cmd_link_flow_control_set_tx,
6665 .help_str = "set flow_ctrl tx on|off <port_id>: "
6666 "Change tx flow control parameter",
6668 (void *)&cmd_lfc_set_set,
6669 (void *)&cmd_lfc_set_flow_ctrl,
6670 (void *)&cmd_lfc_set_tx,
6671 (void *)&cmd_lfc_set_tx_mode,
6672 (void *)&cmd_lfc_set_portid,
6677 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6678 .f = cmd_link_flow_ctrl_set_parsed,
6679 .data = (void *)&cmd_link_flow_control_set_hw,
6680 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6681 "Change high water flow control parameter",
6683 (void *)&cmd_lfc_set_set,
6684 (void *)&cmd_lfc_set_flow_ctrl,
6685 (void *)&cmd_lfc_set_high_water_str,
6686 (void *)&cmd_lfc_set_high_water,
6687 (void *)&cmd_lfc_set_portid,
6692 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6693 .f = cmd_link_flow_ctrl_set_parsed,
6694 .data = (void *)&cmd_link_flow_control_set_lw,
6695 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6696 "Change low water flow control parameter",
6698 (void *)&cmd_lfc_set_set,
6699 (void *)&cmd_lfc_set_flow_ctrl,
6700 (void *)&cmd_lfc_set_low_water_str,
6701 (void *)&cmd_lfc_set_low_water,
6702 (void *)&cmd_lfc_set_portid,
6707 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6708 .f = cmd_link_flow_ctrl_set_parsed,
6709 .data = (void *)&cmd_link_flow_control_set_pt,
6710 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6711 "Change pause time flow control parameter",
6713 (void *)&cmd_lfc_set_set,
6714 (void *)&cmd_lfc_set_flow_ctrl,
6715 (void *)&cmd_lfc_set_pause_time_str,
6716 (void *)&cmd_lfc_set_pause_time,
6717 (void *)&cmd_lfc_set_portid,
6722 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6723 .f = cmd_link_flow_ctrl_set_parsed,
6724 .data = (void *)&cmd_link_flow_control_set_xon,
6725 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6726 "Change send_xon flow control parameter",
6728 (void *)&cmd_lfc_set_set,
6729 (void *)&cmd_lfc_set_flow_ctrl,
6730 (void *)&cmd_lfc_set_send_xon_str,
6731 (void *)&cmd_lfc_set_send_xon,
6732 (void *)&cmd_lfc_set_portid,
6737 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6738 .f = cmd_link_flow_ctrl_set_parsed,
6739 .data = (void *)&cmd_link_flow_control_set_macfwd,
6740 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6741 "Change mac ctrl fwd flow control parameter",
6743 (void *)&cmd_lfc_set_set,
6744 (void *)&cmd_lfc_set_flow_ctrl,
6745 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6746 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6747 (void *)&cmd_lfc_set_portid,
6752 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6753 .f = cmd_link_flow_ctrl_set_parsed,
6754 .data = (void *)&cmd_link_flow_control_set_autoneg,
6755 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6756 "Change autoneg flow control parameter",
6758 (void *)&cmd_lfc_set_set,
6759 (void *)&cmd_lfc_set_flow_ctrl,
6760 (void *)&cmd_lfc_set_autoneg_str,
6761 (void *)&cmd_lfc_set_autoneg,
6762 (void *)&cmd_lfc_set_portid,
6768 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6769 __attribute__((unused)) struct cmdline *cl,
6772 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6773 cmdline_parse_inst_t *cmd = data;
6774 struct rte_eth_fc_conf fc_conf;
6780 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6781 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6782 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6783 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6785 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6786 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6789 /* Partial command line, retrieve current configuration */
6791 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6793 printf("cannot get current flow ctrl parameters, return"
6794 "code = %d\n", ret);
6798 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6799 (fc_conf.mode == RTE_FC_FULL))
6801 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6802 (fc_conf.mode == RTE_FC_FULL))
6806 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6807 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6809 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6810 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6812 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6814 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6815 fc_conf.high_water = res->high_water;
6817 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6818 fc_conf.low_water = res->low_water;
6820 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6821 fc_conf.pause_time = res->pause_time;
6823 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6824 fc_conf.send_xon = res->send_xon;
6826 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6827 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6828 fc_conf.mac_ctrl_frame_fwd = 1;
6830 fc_conf.mac_ctrl_frame_fwd = 0;
6833 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6834 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6836 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6838 printf("bad flow contrl parameter, return code = %d \n", ret);
6841 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6842 struct cmd_priority_flow_ctrl_set_result {
6843 cmdline_fixed_string_t set;
6844 cmdline_fixed_string_t pfc_ctrl;
6845 cmdline_fixed_string_t rx;
6846 cmdline_fixed_string_t rx_pfc_mode;
6847 cmdline_fixed_string_t tx;
6848 cmdline_fixed_string_t tx_pfc_mode;
6849 uint32_t high_water;
6851 uint16_t pause_time;
6857 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6858 __attribute__((unused)) struct cmdline *cl,
6859 __attribute__((unused)) void *data)
6861 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6862 struct rte_eth_pfc_conf pfc_conf;
6863 int rx_fc_enable, tx_fc_enable;
6867 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6868 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6869 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6870 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6872 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6873 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6876 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6877 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6878 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6879 pfc_conf.fc.high_water = res->high_water;
6880 pfc_conf.fc.low_water = res->low_water;
6881 pfc_conf.fc.pause_time = res->pause_time;
6882 pfc_conf.priority = res->priority;
6884 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6886 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6889 cmdline_parse_token_string_t cmd_pfc_set_set =
6890 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6892 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6893 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6894 pfc_ctrl, "pfc_ctrl");
6895 cmdline_parse_token_string_t cmd_pfc_set_rx =
6896 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6898 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6899 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6900 rx_pfc_mode, "on#off");
6901 cmdline_parse_token_string_t cmd_pfc_set_tx =
6902 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6904 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6905 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6906 tx_pfc_mode, "on#off");
6907 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6908 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6909 high_water, UINT32);
6910 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6911 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6913 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6914 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6915 pause_time, UINT16);
6916 cmdline_parse_token_num_t cmd_pfc_set_priority =
6917 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6919 cmdline_parse_token_num_t cmd_pfc_set_portid =
6920 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6923 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6924 .f = cmd_priority_flow_ctrl_set_parsed,
6926 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6927 "<pause_time> <priority> <port_id>: "
6928 "Configure the Ethernet priority flow control",
6930 (void *)&cmd_pfc_set_set,
6931 (void *)&cmd_pfc_set_flow_ctrl,
6932 (void *)&cmd_pfc_set_rx,
6933 (void *)&cmd_pfc_set_rx_mode,
6934 (void *)&cmd_pfc_set_tx,
6935 (void *)&cmd_pfc_set_tx_mode,
6936 (void *)&cmd_pfc_set_high_water,
6937 (void *)&cmd_pfc_set_low_water,
6938 (void *)&cmd_pfc_set_pause_time,
6939 (void *)&cmd_pfc_set_priority,
6940 (void *)&cmd_pfc_set_portid,
6945 /* *** RESET CONFIGURATION *** */
6946 struct cmd_reset_result {
6947 cmdline_fixed_string_t reset;
6948 cmdline_fixed_string_t def;
6951 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6953 __attribute__((unused)) void *data)
6955 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6956 set_def_fwd_config();
6959 cmdline_parse_token_string_t cmd_reset_set =
6960 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6961 cmdline_parse_token_string_t cmd_reset_def =
6962 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6965 cmdline_parse_inst_t cmd_reset = {
6966 .f = cmd_reset_parsed,
6968 .help_str = "set default: Reset default forwarding configuration",
6970 (void *)&cmd_reset_set,
6971 (void *)&cmd_reset_def,
6976 /* *** START FORWARDING *** */
6977 struct cmd_start_result {
6978 cmdline_fixed_string_t start;
6981 cmdline_parse_token_string_t cmd_start_start =
6982 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6984 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6985 __attribute__((unused)) struct cmdline *cl,
6986 __attribute__((unused)) void *data)
6988 start_packet_forwarding(0);
6991 cmdline_parse_inst_t cmd_start = {
6992 .f = cmd_start_parsed,
6994 .help_str = "start: Start packet forwarding",
6996 (void *)&cmd_start_start,
7001 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7002 struct cmd_start_tx_first_result {
7003 cmdline_fixed_string_t start;
7004 cmdline_fixed_string_t tx_first;
7008 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
7009 __attribute__((unused)) struct cmdline *cl,
7010 __attribute__((unused)) void *data)
7012 start_packet_forwarding(1);
7015 cmdline_parse_token_string_t cmd_start_tx_first_start =
7016 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7018 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7019 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7020 tx_first, "tx_first");
7022 cmdline_parse_inst_t cmd_start_tx_first = {
7023 .f = cmd_start_tx_first_parsed,
7025 .help_str = "start tx_first: Start packet forwarding, "
7026 "after sending 1 burst of packets",
7028 (void *)&cmd_start_tx_first_start,
7029 (void *)&cmd_start_tx_first_tx_first,
7034 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7035 struct cmd_start_tx_first_n_result {
7036 cmdline_fixed_string_t start;
7037 cmdline_fixed_string_t tx_first;
7042 cmd_start_tx_first_n_parsed(void *parsed_result,
7043 __attribute__((unused)) struct cmdline *cl,
7044 __attribute__((unused)) void *data)
7046 struct cmd_start_tx_first_n_result *res = parsed_result;
7048 start_packet_forwarding(res->tx_num);
7051 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7052 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7054 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7055 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7056 tx_first, "tx_first");
7057 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7058 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7061 cmdline_parse_inst_t cmd_start_tx_first_n = {
7062 .f = cmd_start_tx_first_n_parsed,
7064 .help_str = "start tx_first <num>: "
7065 "packet forwarding, after sending <num> bursts of packets",
7067 (void *)&cmd_start_tx_first_n_start,
7068 (void *)&cmd_start_tx_first_n_tx_first,
7069 (void *)&cmd_start_tx_first_n_tx_num,
7074 /* *** SET LINK UP *** */
7075 struct cmd_set_link_up_result {
7076 cmdline_fixed_string_t set;
7077 cmdline_fixed_string_t link_up;
7078 cmdline_fixed_string_t port;
7082 cmdline_parse_token_string_t cmd_set_link_up_set =
7083 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7084 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7085 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7087 cmdline_parse_token_string_t cmd_set_link_up_port =
7088 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7089 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7090 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7092 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
7093 __attribute__((unused)) struct cmdline *cl,
7094 __attribute__((unused)) void *data)
7096 struct cmd_set_link_up_result *res = parsed_result;
7097 dev_set_link_up(res->port_id);
7100 cmdline_parse_inst_t cmd_set_link_up = {
7101 .f = cmd_set_link_up_parsed,
7103 .help_str = "set link-up port <port id>",
7105 (void *)&cmd_set_link_up_set,
7106 (void *)&cmd_set_link_up_link_up,
7107 (void *)&cmd_set_link_up_port,
7108 (void *)&cmd_set_link_up_port_id,
7113 /* *** SET LINK DOWN *** */
7114 struct cmd_set_link_down_result {
7115 cmdline_fixed_string_t set;
7116 cmdline_fixed_string_t link_down;
7117 cmdline_fixed_string_t port;
7121 cmdline_parse_token_string_t cmd_set_link_down_set =
7122 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7123 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7124 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7126 cmdline_parse_token_string_t cmd_set_link_down_port =
7127 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7128 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7129 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7131 static void cmd_set_link_down_parsed(
7132 __attribute__((unused)) void *parsed_result,
7133 __attribute__((unused)) struct cmdline *cl,
7134 __attribute__((unused)) void *data)
7136 struct cmd_set_link_down_result *res = parsed_result;
7137 dev_set_link_down(res->port_id);
7140 cmdline_parse_inst_t cmd_set_link_down = {
7141 .f = cmd_set_link_down_parsed,
7143 .help_str = "set link-down port <port id>",
7145 (void *)&cmd_set_link_down_set,
7146 (void *)&cmd_set_link_down_link_down,
7147 (void *)&cmd_set_link_down_port,
7148 (void *)&cmd_set_link_down_port_id,
7153 /* *** SHOW CFG *** */
7154 struct cmd_showcfg_result {
7155 cmdline_fixed_string_t show;
7156 cmdline_fixed_string_t cfg;
7157 cmdline_fixed_string_t what;
7160 static void cmd_showcfg_parsed(void *parsed_result,
7161 __attribute__((unused)) struct cmdline *cl,
7162 __attribute__((unused)) void *data)
7164 struct cmd_showcfg_result *res = parsed_result;
7165 if (!strcmp(res->what, "rxtx"))
7166 rxtx_config_display();
7167 else if (!strcmp(res->what, "cores"))
7168 fwd_lcores_config_display();
7169 else if (!strcmp(res->what, "fwd"))
7170 pkt_fwd_config_display(&cur_fwd_config);
7171 else if (!strcmp(res->what, "txpkts"))
7172 show_tx_pkt_segments();
7175 cmdline_parse_token_string_t cmd_showcfg_show =
7176 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7177 cmdline_parse_token_string_t cmd_showcfg_port =
7178 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7179 cmdline_parse_token_string_t cmd_showcfg_what =
7180 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7181 "rxtx#cores#fwd#txpkts");
7183 cmdline_parse_inst_t cmd_showcfg = {
7184 .f = cmd_showcfg_parsed,
7186 .help_str = "show config rxtx|cores|fwd|txpkts",
7188 (void *)&cmd_showcfg_show,
7189 (void *)&cmd_showcfg_port,
7190 (void *)&cmd_showcfg_what,
7195 /* *** SHOW ALL PORT INFO *** */
7196 struct cmd_showportall_result {
7197 cmdline_fixed_string_t show;
7198 cmdline_fixed_string_t port;
7199 cmdline_fixed_string_t what;
7200 cmdline_fixed_string_t all;
7203 static void cmd_showportall_parsed(void *parsed_result,
7204 __attribute__((unused)) struct cmdline *cl,
7205 __attribute__((unused)) void *data)
7209 struct cmd_showportall_result *res = parsed_result;
7210 if (!strcmp(res->show, "clear")) {
7211 if (!strcmp(res->what, "stats"))
7212 RTE_ETH_FOREACH_DEV(i)
7214 else if (!strcmp(res->what, "xstats"))
7215 RTE_ETH_FOREACH_DEV(i)
7216 nic_xstats_clear(i);
7217 } else if (!strcmp(res->what, "info"))
7218 RTE_ETH_FOREACH_DEV(i)
7219 port_infos_display(i);
7220 else if (!strcmp(res->what, "summary")) {
7221 port_summary_header_display();
7222 RTE_ETH_FOREACH_DEV(i)
7223 port_summary_display(i);
7225 else if (!strcmp(res->what, "stats"))
7226 RTE_ETH_FOREACH_DEV(i)
7227 nic_stats_display(i);
7228 else if (!strcmp(res->what, "xstats"))
7229 RTE_ETH_FOREACH_DEV(i)
7230 nic_xstats_display(i);
7231 else if (!strcmp(res->what, "fdir"))
7232 RTE_ETH_FOREACH_DEV(i)
7234 else if (!strcmp(res->what, "stat_qmap"))
7235 RTE_ETH_FOREACH_DEV(i)
7236 nic_stats_mapping_display(i);
7237 else if (!strcmp(res->what, "dcb_tc"))
7238 RTE_ETH_FOREACH_DEV(i)
7239 port_dcb_info_display(i);
7240 else if (!strcmp(res->what, "cap"))
7241 RTE_ETH_FOREACH_DEV(i)
7242 port_offload_cap_display(i);
7245 cmdline_parse_token_string_t cmd_showportall_show =
7246 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7248 cmdline_parse_token_string_t cmd_showportall_port =
7249 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7250 cmdline_parse_token_string_t cmd_showportall_what =
7251 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7252 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7253 cmdline_parse_token_string_t cmd_showportall_all =
7254 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7255 cmdline_parse_inst_t cmd_showportall = {
7256 .f = cmd_showportall_parsed,
7258 .help_str = "show|clear port "
7259 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7261 (void *)&cmd_showportall_show,
7262 (void *)&cmd_showportall_port,
7263 (void *)&cmd_showportall_what,
7264 (void *)&cmd_showportall_all,
7269 /* *** SHOW PORT INFO *** */
7270 struct cmd_showport_result {
7271 cmdline_fixed_string_t show;
7272 cmdline_fixed_string_t port;
7273 cmdline_fixed_string_t what;
7277 static void cmd_showport_parsed(void *parsed_result,
7278 __attribute__((unused)) struct cmdline *cl,
7279 __attribute__((unused)) void *data)
7281 struct cmd_showport_result *res = parsed_result;
7282 if (!strcmp(res->show, "clear")) {
7283 if (!strcmp(res->what, "stats"))
7284 nic_stats_clear(res->portnum);
7285 else if (!strcmp(res->what, "xstats"))
7286 nic_xstats_clear(res->portnum);
7287 } else if (!strcmp(res->what, "info"))
7288 port_infos_display(res->portnum);
7289 else if (!strcmp(res->what, "summary")) {
7290 port_summary_header_display();
7291 port_summary_display(res->portnum);
7293 else if (!strcmp(res->what, "stats"))
7294 nic_stats_display(res->portnum);
7295 else if (!strcmp(res->what, "xstats"))
7296 nic_xstats_display(res->portnum);
7297 else if (!strcmp(res->what, "fdir"))
7298 fdir_get_infos(res->portnum);
7299 else if (!strcmp(res->what, "stat_qmap"))
7300 nic_stats_mapping_display(res->portnum);
7301 else if (!strcmp(res->what, "dcb_tc"))
7302 port_dcb_info_display(res->portnum);
7303 else if (!strcmp(res->what, "cap"))
7304 port_offload_cap_display(res->portnum);
7307 cmdline_parse_token_string_t cmd_showport_show =
7308 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7310 cmdline_parse_token_string_t cmd_showport_port =
7311 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7312 cmdline_parse_token_string_t cmd_showport_what =
7313 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7314 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7315 cmdline_parse_token_num_t cmd_showport_portnum =
7316 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7318 cmdline_parse_inst_t cmd_showport = {
7319 .f = cmd_showport_parsed,
7321 .help_str = "show|clear port "
7322 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7325 (void *)&cmd_showport_show,
7326 (void *)&cmd_showport_port,
7327 (void *)&cmd_showport_what,
7328 (void *)&cmd_showport_portnum,
7333 /* *** SHOW QUEUE INFO *** */
7334 struct cmd_showqueue_result {
7335 cmdline_fixed_string_t show;
7336 cmdline_fixed_string_t type;
7337 cmdline_fixed_string_t what;
7343 cmd_showqueue_parsed(void *parsed_result,
7344 __attribute__((unused)) struct cmdline *cl,
7345 __attribute__((unused)) void *data)
7347 struct cmd_showqueue_result *res = parsed_result;
7349 if (!strcmp(res->type, "rxq"))
7350 rx_queue_infos_display(res->portnum, res->queuenum);
7351 else if (!strcmp(res->type, "txq"))
7352 tx_queue_infos_display(res->portnum, res->queuenum);
7355 cmdline_parse_token_string_t cmd_showqueue_show =
7356 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7357 cmdline_parse_token_string_t cmd_showqueue_type =
7358 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7359 cmdline_parse_token_string_t cmd_showqueue_what =
7360 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7361 cmdline_parse_token_num_t cmd_showqueue_portnum =
7362 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7363 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7364 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7366 cmdline_parse_inst_t cmd_showqueue = {
7367 .f = cmd_showqueue_parsed,
7369 .help_str = "show rxq|txq info <port_id> <queue_id>",
7371 (void *)&cmd_showqueue_show,
7372 (void *)&cmd_showqueue_type,
7373 (void *)&cmd_showqueue_what,
7374 (void *)&cmd_showqueue_portnum,
7375 (void *)&cmd_showqueue_queuenum,
7380 /* *** READ PORT REGISTER *** */
7381 struct cmd_read_reg_result {
7382 cmdline_fixed_string_t read;
7383 cmdline_fixed_string_t reg;
7389 cmd_read_reg_parsed(void *parsed_result,
7390 __attribute__((unused)) struct cmdline *cl,
7391 __attribute__((unused)) void *data)
7393 struct cmd_read_reg_result *res = parsed_result;
7394 port_reg_display(res->port_id, res->reg_off);
7397 cmdline_parse_token_string_t cmd_read_reg_read =
7398 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7399 cmdline_parse_token_string_t cmd_read_reg_reg =
7400 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7401 cmdline_parse_token_num_t cmd_read_reg_port_id =
7402 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7403 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7404 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7406 cmdline_parse_inst_t cmd_read_reg = {
7407 .f = cmd_read_reg_parsed,
7409 .help_str = "read reg <port_id> <reg_off>",
7411 (void *)&cmd_read_reg_read,
7412 (void *)&cmd_read_reg_reg,
7413 (void *)&cmd_read_reg_port_id,
7414 (void *)&cmd_read_reg_reg_off,
7419 /* *** READ PORT REGISTER BIT FIELD *** */
7420 struct cmd_read_reg_bit_field_result {
7421 cmdline_fixed_string_t read;
7422 cmdline_fixed_string_t regfield;
7430 cmd_read_reg_bit_field_parsed(void *parsed_result,
7431 __attribute__((unused)) struct cmdline *cl,
7432 __attribute__((unused)) void *data)
7434 struct cmd_read_reg_bit_field_result *res = parsed_result;
7435 port_reg_bit_field_display(res->port_id, res->reg_off,
7436 res->bit1_pos, res->bit2_pos);
7439 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7440 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7442 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7443 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7444 regfield, "regfield");
7445 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7446 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7448 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7449 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7451 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7452 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7454 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7455 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7458 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7459 .f = cmd_read_reg_bit_field_parsed,
7461 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7462 "Read register bit field between bit_x and bit_y included",
7464 (void *)&cmd_read_reg_bit_field_read,
7465 (void *)&cmd_read_reg_bit_field_regfield,
7466 (void *)&cmd_read_reg_bit_field_port_id,
7467 (void *)&cmd_read_reg_bit_field_reg_off,
7468 (void *)&cmd_read_reg_bit_field_bit1_pos,
7469 (void *)&cmd_read_reg_bit_field_bit2_pos,
7474 /* *** READ PORT REGISTER BIT *** */
7475 struct cmd_read_reg_bit_result {
7476 cmdline_fixed_string_t read;
7477 cmdline_fixed_string_t regbit;
7484 cmd_read_reg_bit_parsed(void *parsed_result,
7485 __attribute__((unused)) struct cmdline *cl,
7486 __attribute__((unused)) void *data)
7488 struct cmd_read_reg_bit_result *res = parsed_result;
7489 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7492 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7493 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7494 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7495 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7497 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7498 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7499 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7500 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7501 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7502 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7504 cmdline_parse_inst_t cmd_read_reg_bit = {
7505 .f = cmd_read_reg_bit_parsed,
7507 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7509 (void *)&cmd_read_reg_bit_read,
7510 (void *)&cmd_read_reg_bit_regbit,
7511 (void *)&cmd_read_reg_bit_port_id,
7512 (void *)&cmd_read_reg_bit_reg_off,
7513 (void *)&cmd_read_reg_bit_bit_pos,
7518 /* *** WRITE PORT REGISTER *** */
7519 struct cmd_write_reg_result {
7520 cmdline_fixed_string_t write;
7521 cmdline_fixed_string_t reg;
7528 cmd_write_reg_parsed(void *parsed_result,
7529 __attribute__((unused)) struct cmdline *cl,
7530 __attribute__((unused)) void *data)
7532 struct cmd_write_reg_result *res = parsed_result;
7533 port_reg_set(res->port_id, res->reg_off, res->value);
7536 cmdline_parse_token_string_t cmd_write_reg_write =
7537 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7538 cmdline_parse_token_string_t cmd_write_reg_reg =
7539 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7540 cmdline_parse_token_num_t cmd_write_reg_port_id =
7541 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7542 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7543 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7544 cmdline_parse_token_num_t cmd_write_reg_value =
7545 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7547 cmdline_parse_inst_t cmd_write_reg = {
7548 .f = cmd_write_reg_parsed,
7550 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7552 (void *)&cmd_write_reg_write,
7553 (void *)&cmd_write_reg_reg,
7554 (void *)&cmd_write_reg_port_id,
7555 (void *)&cmd_write_reg_reg_off,
7556 (void *)&cmd_write_reg_value,
7561 /* *** WRITE PORT REGISTER BIT FIELD *** */
7562 struct cmd_write_reg_bit_field_result {
7563 cmdline_fixed_string_t write;
7564 cmdline_fixed_string_t regfield;
7573 cmd_write_reg_bit_field_parsed(void *parsed_result,
7574 __attribute__((unused)) struct cmdline *cl,
7575 __attribute__((unused)) void *data)
7577 struct cmd_write_reg_bit_field_result *res = parsed_result;
7578 port_reg_bit_field_set(res->port_id, res->reg_off,
7579 res->bit1_pos, res->bit2_pos, res->value);
7582 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7583 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7585 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7586 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7587 regfield, "regfield");
7588 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7589 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7591 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7592 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7594 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7595 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7597 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7598 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7600 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7601 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7604 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7605 .f = cmd_write_reg_bit_field_parsed,
7607 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7609 "Set register bit field between bit_x and bit_y included",
7611 (void *)&cmd_write_reg_bit_field_write,
7612 (void *)&cmd_write_reg_bit_field_regfield,
7613 (void *)&cmd_write_reg_bit_field_port_id,
7614 (void *)&cmd_write_reg_bit_field_reg_off,
7615 (void *)&cmd_write_reg_bit_field_bit1_pos,
7616 (void *)&cmd_write_reg_bit_field_bit2_pos,
7617 (void *)&cmd_write_reg_bit_field_value,
7622 /* *** WRITE PORT REGISTER BIT *** */
7623 struct cmd_write_reg_bit_result {
7624 cmdline_fixed_string_t write;
7625 cmdline_fixed_string_t regbit;
7633 cmd_write_reg_bit_parsed(void *parsed_result,
7634 __attribute__((unused)) struct cmdline *cl,
7635 __attribute__((unused)) void *data)
7637 struct cmd_write_reg_bit_result *res = parsed_result;
7638 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7641 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7642 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7644 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7645 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7647 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7648 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7649 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7650 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7651 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7652 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7653 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7654 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7656 cmdline_parse_inst_t cmd_write_reg_bit = {
7657 .f = cmd_write_reg_bit_parsed,
7659 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7662 (void *)&cmd_write_reg_bit_write,
7663 (void *)&cmd_write_reg_bit_regbit,
7664 (void *)&cmd_write_reg_bit_port_id,
7665 (void *)&cmd_write_reg_bit_reg_off,
7666 (void *)&cmd_write_reg_bit_bit_pos,
7667 (void *)&cmd_write_reg_bit_value,
7672 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7673 struct cmd_read_rxd_txd_result {
7674 cmdline_fixed_string_t read;
7675 cmdline_fixed_string_t rxd_txd;
7682 cmd_read_rxd_txd_parsed(void *parsed_result,
7683 __attribute__((unused)) struct cmdline *cl,
7684 __attribute__((unused)) void *data)
7686 struct cmd_read_rxd_txd_result *res = parsed_result;
7688 if (!strcmp(res->rxd_txd, "rxd"))
7689 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7690 else if (!strcmp(res->rxd_txd, "txd"))
7691 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7694 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7695 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7696 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7697 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7699 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7700 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7701 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7702 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7703 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7704 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7706 cmdline_parse_inst_t cmd_read_rxd_txd = {
7707 .f = cmd_read_rxd_txd_parsed,
7709 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7711 (void *)&cmd_read_rxd_txd_read,
7712 (void *)&cmd_read_rxd_txd_rxd_txd,
7713 (void *)&cmd_read_rxd_txd_port_id,
7714 (void *)&cmd_read_rxd_txd_queue_id,
7715 (void *)&cmd_read_rxd_txd_desc_id,
7721 struct cmd_quit_result {
7722 cmdline_fixed_string_t quit;
7725 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7727 __attribute__((unused)) void *data)
7732 cmdline_parse_token_string_t cmd_quit_quit =
7733 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7735 cmdline_parse_inst_t cmd_quit = {
7736 .f = cmd_quit_parsed,
7738 .help_str = "quit: Exit application",
7740 (void *)&cmd_quit_quit,
7745 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7746 struct cmd_mac_addr_result {
7747 cmdline_fixed_string_t mac_addr_cmd;
7748 cmdline_fixed_string_t what;
7750 struct ether_addr address;
7753 static void cmd_mac_addr_parsed(void *parsed_result,
7754 __attribute__((unused)) struct cmdline *cl,
7755 __attribute__((unused)) void *data)
7757 struct cmd_mac_addr_result *res = parsed_result;
7760 if (strcmp(res->what, "add") == 0)
7761 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7762 else if (strcmp(res->what, "set") == 0)
7763 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7766 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7768 /* check the return value and print it if is < 0 */
7770 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7774 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7775 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7777 cmdline_parse_token_string_t cmd_mac_addr_what =
7778 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7780 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7781 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7783 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7784 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7786 cmdline_parse_inst_t cmd_mac_addr = {
7787 .f = cmd_mac_addr_parsed,
7789 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7790 "Add/Remove/Set MAC address on port_id",
7792 (void *)&cmd_mac_addr_cmd,
7793 (void *)&cmd_mac_addr_what,
7794 (void *)&cmd_mac_addr_portnum,
7795 (void *)&cmd_mac_addr_addr,
7800 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7801 struct cmd_eth_peer_result {
7802 cmdline_fixed_string_t set;
7803 cmdline_fixed_string_t eth_peer;
7805 cmdline_fixed_string_t peer_addr;
7808 static void cmd_set_eth_peer_parsed(void *parsed_result,
7809 __attribute__((unused)) struct cmdline *cl,
7810 __attribute__((unused)) void *data)
7812 struct cmd_eth_peer_result *res = parsed_result;
7814 if (test_done == 0) {
7815 printf("Please stop forwarding first\n");
7818 if (!strcmp(res->eth_peer, "eth-peer")) {
7819 set_fwd_eth_peer(res->port_id, res->peer_addr);
7823 cmdline_parse_token_string_t cmd_eth_peer_set =
7824 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7825 cmdline_parse_token_string_t cmd_eth_peer =
7826 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7827 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7828 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7829 cmdline_parse_token_string_t cmd_eth_peer_addr =
7830 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7832 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7833 .f = cmd_set_eth_peer_parsed,
7835 .help_str = "set eth-peer <port_id> <peer_mac>",
7837 (void *)&cmd_eth_peer_set,
7838 (void *)&cmd_eth_peer,
7839 (void *)&cmd_eth_peer_port_id,
7840 (void *)&cmd_eth_peer_addr,
7845 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7846 struct cmd_set_qmap_result {
7847 cmdline_fixed_string_t set;
7848 cmdline_fixed_string_t qmap;
7849 cmdline_fixed_string_t what;
7856 cmd_set_qmap_parsed(void *parsed_result,
7857 __attribute__((unused)) struct cmdline *cl,
7858 __attribute__((unused)) void *data)
7860 struct cmd_set_qmap_result *res = parsed_result;
7861 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7863 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7866 cmdline_parse_token_string_t cmd_setqmap_set =
7867 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7869 cmdline_parse_token_string_t cmd_setqmap_qmap =
7870 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7872 cmdline_parse_token_string_t cmd_setqmap_what =
7873 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7875 cmdline_parse_token_num_t cmd_setqmap_portid =
7876 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7878 cmdline_parse_token_num_t cmd_setqmap_queueid =
7879 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7881 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7882 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7885 cmdline_parse_inst_t cmd_set_qmap = {
7886 .f = cmd_set_qmap_parsed,
7888 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7889 "Set statistics mapping value on tx|rx queue_id of port_id",
7891 (void *)&cmd_setqmap_set,
7892 (void *)&cmd_setqmap_qmap,
7893 (void *)&cmd_setqmap_what,
7894 (void *)&cmd_setqmap_portid,
7895 (void *)&cmd_setqmap_queueid,
7896 (void *)&cmd_setqmap_mapvalue,
7901 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7902 struct cmd_set_xstats_hide_zero_result {
7903 cmdline_fixed_string_t keyword;
7904 cmdline_fixed_string_t name;
7905 cmdline_fixed_string_t on_off;
7909 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7910 __attribute__((unused)) struct cmdline *cl,
7911 __attribute__((unused)) void *data)
7913 struct cmd_set_xstats_hide_zero_result *res;
7914 uint16_t on_off = 0;
7916 res = parsed_result;
7917 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7918 set_xstats_hide_zero(on_off);
7921 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7922 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7924 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7925 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7926 name, "xstats-hide-zero");
7927 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7928 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7931 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7932 .f = cmd_set_xstats_hide_zero_parsed,
7934 .help_str = "set xstats-hide-zero on|off",
7936 (void *)&cmd_set_xstats_hide_zero_keyword,
7937 (void *)&cmd_set_xstats_hide_zero_name,
7938 (void *)&cmd_set_xstats_hide_zero_on_off,
7943 /* *** CONFIGURE UNICAST HASH TABLE *** */
7944 struct cmd_set_uc_hash_table {
7945 cmdline_fixed_string_t set;
7946 cmdline_fixed_string_t port;
7948 cmdline_fixed_string_t what;
7949 struct ether_addr address;
7950 cmdline_fixed_string_t mode;
7954 cmd_set_uc_hash_parsed(void *parsed_result,
7955 __attribute__((unused)) struct cmdline *cl,
7956 __attribute__((unused)) void *data)
7959 struct cmd_set_uc_hash_table *res = parsed_result;
7961 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7963 if (strcmp(res->what, "uta") == 0)
7964 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7965 &res->address,(uint8_t)is_on);
7967 printf("bad unicast hash table parameter, return code = %d \n", ret);
7971 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7972 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7974 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7975 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7977 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7978 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7980 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7981 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7983 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7984 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7986 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7987 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7990 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7991 .f = cmd_set_uc_hash_parsed,
7993 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7995 (void *)&cmd_set_uc_hash_set,
7996 (void *)&cmd_set_uc_hash_port,
7997 (void *)&cmd_set_uc_hash_portid,
7998 (void *)&cmd_set_uc_hash_what,
7999 (void *)&cmd_set_uc_hash_mac,
8000 (void *)&cmd_set_uc_hash_mode,
8005 struct cmd_set_uc_all_hash_table {
8006 cmdline_fixed_string_t set;
8007 cmdline_fixed_string_t port;
8009 cmdline_fixed_string_t what;
8010 cmdline_fixed_string_t value;
8011 cmdline_fixed_string_t mode;
8015 cmd_set_uc_all_hash_parsed(void *parsed_result,
8016 __attribute__((unused)) struct cmdline *cl,
8017 __attribute__((unused)) void *data)
8020 struct cmd_set_uc_all_hash_table *res = parsed_result;
8022 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8024 if ((strcmp(res->what, "uta") == 0) &&
8025 (strcmp(res->value, "all") == 0))
8026 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8028 printf("bad unicast hash table parameter,"
8029 "return code = %d \n", ret);
8032 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8033 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8035 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8036 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8038 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8039 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8041 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8042 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8044 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8045 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8047 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8048 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8051 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8052 .f = cmd_set_uc_all_hash_parsed,
8054 .help_str = "set port <port_id> uta all on|off",
8056 (void *)&cmd_set_uc_all_hash_set,
8057 (void *)&cmd_set_uc_all_hash_port,
8058 (void *)&cmd_set_uc_all_hash_portid,
8059 (void *)&cmd_set_uc_all_hash_what,
8060 (void *)&cmd_set_uc_all_hash_value,
8061 (void *)&cmd_set_uc_all_hash_mode,
8066 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8067 struct cmd_set_vf_macvlan_filter {
8068 cmdline_fixed_string_t set;
8069 cmdline_fixed_string_t port;
8071 cmdline_fixed_string_t vf;
8073 struct ether_addr address;
8074 cmdline_fixed_string_t filter_type;
8075 cmdline_fixed_string_t mode;
8079 cmd_set_vf_macvlan_parsed(void *parsed_result,
8080 __attribute__((unused)) struct cmdline *cl,
8081 __attribute__((unused)) void *data)
8084 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8085 struct rte_eth_mac_filter filter;
8087 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8089 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
8091 /* set VF MAC filter */
8095 filter.dst_id = res->vf_id;
8097 if (!strcmp(res->filter_type, "exact-mac"))
8098 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8099 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8100 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8101 else if (!strcmp(res->filter_type, "hashmac"))
8102 filter.filter_type = RTE_MAC_HASH_MATCH;
8103 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8104 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8106 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8109 ret = rte_eth_dev_filter_ctrl(res->port_id,
8110 RTE_ETH_FILTER_MACVLAN,
8114 ret = rte_eth_dev_filter_ctrl(res->port_id,
8115 RTE_ETH_FILTER_MACVLAN,
8116 RTE_ETH_FILTER_DELETE,
8120 printf("bad set MAC hash parameter, return code = %d\n", ret);
8124 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8125 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8127 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8128 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8130 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8131 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8133 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8134 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8136 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8137 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8139 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8140 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8142 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8143 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8144 filter_type, "exact-mac#exact-mac-vlan"
8145 "#hashmac#hashmac-vlan");
8146 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8147 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8150 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8151 .f = cmd_set_vf_macvlan_parsed,
8153 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8154 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8155 "Exact match rule: exact match of MAC or MAC and VLAN; "
8156 "hash match rule: hash match of MAC and exact match of VLAN",
8158 (void *)&cmd_set_vf_macvlan_set,
8159 (void *)&cmd_set_vf_macvlan_port,
8160 (void *)&cmd_set_vf_macvlan_portid,
8161 (void *)&cmd_set_vf_macvlan_vf,
8162 (void *)&cmd_set_vf_macvlan_vf_id,
8163 (void *)&cmd_set_vf_macvlan_mac,
8164 (void *)&cmd_set_vf_macvlan_filter_type,
8165 (void *)&cmd_set_vf_macvlan_mode,
8170 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8171 struct cmd_set_vf_traffic {
8172 cmdline_fixed_string_t set;
8173 cmdline_fixed_string_t port;
8175 cmdline_fixed_string_t vf;
8177 cmdline_fixed_string_t what;
8178 cmdline_fixed_string_t mode;
8182 cmd_set_vf_traffic_parsed(void *parsed_result,
8183 __attribute__((unused)) struct cmdline *cl,
8184 __attribute__((unused)) void *data)
8186 struct cmd_set_vf_traffic *res = parsed_result;
8187 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8188 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8190 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8193 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8194 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8196 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8197 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8199 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8200 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8202 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8203 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8205 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8206 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8208 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8209 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8211 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8212 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8215 cmdline_parse_inst_t cmd_set_vf_traffic = {
8216 .f = cmd_set_vf_traffic_parsed,
8218 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8220 (void *)&cmd_setvf_traffic_set,
8221 (void *)&cmd_setvf_traffic_port,
8222 (void *)&cmd_setvf_traffic_portid,
8223 (void *)&cmd_setvf_traffic_vf,
8224 (void *)&cmd_setvf_traffic_vfid,
8225 (void *)&cmd_setvf_traffic_what,
8226 (void *)&cmd_setvf_traffic_mode,
8231 /* *** CONFIGURE VF RECEIVE MODE *** */
8232 struct cmd_set_vf_rxmode {
8233 cmdline_fixed_string_t set;
8234 cmdline_fixed_string_t port;
8236 cmdline_fixed_string_t vf;
8238 cmdline_fixed_string_t what;
8239 cmdline_fixed_string_t mode;
8240 cmdline_fixed_string_t on;
8244 cmd_set_vf_rxmode_parsed(void *parsed_result,
8245 __attribute__((unused)) struct cmdline *cl,
8246 __attribute__((unused)) void *data)
8249 uint16_t rx_mode = 0;
8250 struct cmd_set_vf_rxmode *res = parsed_result;
8252 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8253 if (!strcmp(res->what,"rxmode")) {
8254 if (!strcmp(res->mode, "AUPE"))
8255 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
8256 else if (!strcmp(res->mode, "ROPE"))
8257 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
8258 else if (!strcmp(res->mode, "BAM"))
8259 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
8260 else if (!strncmp(res->mode, "MPE",3))
8261 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
8264 RTE_SET_USED(is_on);
8266 #ifdef RTE_LIBRTE_IXGBE_PMD
8267 if (ret == -ENOTSUP)
8268 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8269 rx_mode, (uint8_t)is_on);
8271 #ifdef RTE_LIBRTE_BNXT_PMD
8272 if (ret == -ENOTSUP)
8273 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8274 rx_mode, (uint8_t)is_on);
8277 printf("bad VF receive mode parameter, return code = %d \n",
8281 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8282 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8284 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8285 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8287 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8288 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8290 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8291 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8293 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8294 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8296 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8297 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8299 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8300 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8301 mode, "AUPE#ROPE#BAM#MPE");
8302 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8303 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8306 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8307 .f = cmd_set_vf_rxmode_parsed,
8309 .help_str = "set port <port_id> vf <vf_id> rxmode "
8310 "AUPE|ROPE|BAM|MPE on|off",
8312 (void *)&cmd_set_vf_rxmode_set,
8313 (void *)&cmd_set_vf_rxmode_port,
8314 (void *)&cmd_set_vf_rxmode_portid,
8315 (void *)&cmd_set_vf_rxmode_vf,
8316 (void *)&cmd_set_vf_rxmode_vfid,
8317 (void *)&cmd_set_vf_rxmode_what,
8318 (void *)&cmd_set_vf_rxmode_mode,
8319 (void *)&cmd_set_vf_rxmode_on,
8324 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8325 struct cmd_vf_mac_addr_result {
8326 cmdline_fixed_string_t mac_addr_cmd;
8327 cmdline_fixed_string_t what;
8328 cmdline_fixed_string_t port;
8330 cmdline_fixed_string_t vf;
8332 struct ether_addr address;
8335 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8336 __attribute__((unused)) struct cmdline *cl,
8337 __attribute__((unused)) void *data)
8339 struct cmd_vf_mac_addr_result *res = parsed_result;
8342 if (strcmp(res->what, "add") != 0)
8345 #ifdef RTE_LIBRTE_I40E_PMD
8346 if (ret == -ENOTSUP)
8347 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8350 #ifdef RTE_LIBRTE_BNXT_PMD
8351 if (ret == -ENOTSUP)
8352 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8357 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8361 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8362 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8363 mac_addr_cmd,"mac_addr");
8364 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8365 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8367 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8368 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8370 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8371 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8373 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8374 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8376 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8377 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8379 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8380 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8383 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8384 .f = cmd_vf_mac_addr_parsed,
8386 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8387 "Add MAC address filtering for a VF on port_id",
8389 (void *)&cmd_vf_mac_addr_cmd,
8390 (void *)&cmd_vf_mac_addr_what,
8391 (void *)&cmd_vf_mac_addr_port,
8392 (void *)&cmd_vf_mac_addr_portnum,
8393 (void *)&cmd_vf_mac_addr_vf,
8394 (void *)&cmd_vf_mac_addr_vfnum,
8395 (void *)&cmd_vf_mac_addr_addr,
8400 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8401 struct cmd_vf_rx_vlan_filter {
8402 cmdline_fixed_string_t rx_vlan;
8403 cmdline_fixed_string_t what;
8405 cmdline_fixed_string_t port;
8407 cmdline_fixed_string_t vf;
8412 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8413 __attribute__((unused)) struct cmdline *cl,
8414 __attribute__((unused)) void *data)
8416 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8419 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8421 #ifdef RTE_LIBRTE_IXGBE_PMD
8422 if (ret == -ENOTSUP)
8423 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8424 res->vlan_id, res->vf_mask, is_add);
8426 #ifdef RTE_LIBRTE_I40E_PMD
8427 if (ret == -ENOTSUP)
8428 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8429 res->vlan_id, res->vf_mask, is_add);
8431 #ifdef RTE_LIBRTE_BNXT_PMD
8432 if (ret == -ENOTSUP)
8433 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8434 res->vlan_id, res->vf_mask, is_add);
8441 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8442 res->vlan_id, res->vf_mask);
8445 printf("invalid port_id %d\n", res->port_id);
8448 printf("function not implemented or supported\n");
8451 printf("programming error: (%s)\n", strerror(-ret));
8455 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8456 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8457 rx_vlan, "rx_vlan");
8458 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8459 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8461 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8462 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8464 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8465 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8467 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8468 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8470 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8471 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8473 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8474 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8477 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8478 .f = cmd_vf_rx_vlan_filter_parsed,
8480 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8481 "(vf_mask = hexadecimal VF mask)",
8483 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8484 (void *)&cmd_vf_rx_vlan_filter_what,
8485 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8486 (void *)&cmd_vf_rx_vlan_filter_port,
8487 (void *)&cmd_vf_rx_vlan_filter_portid,
8488 (void *)&cmd_vf_rx_vlan_filter_vf,
8489 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8494 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8495 struct cmd_queue_rate_limit_result {
8496 cmdline_fixed_string_t set;
8497 cmdline_fixed_string_t port;
8499 cmdline_fixed_string_t queue;
8501 cmdline_fixed_string_t rate;
8505 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8506 __attribute__((unused)) struct cmdline *cl,
8507 __attribute__((unused)) void *data)
8509 struct cmd_queue_rate_limit_result *res = parsed_result;
8512 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8513 && (strcmp(res->queue, "queue") == 0)
8514 && (strcmp(res->rate, "rate") == 0))
8515 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8518 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8522 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8523 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8525 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8526 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8528 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8529 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8531 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8532 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8534 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8535 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8537 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8538 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8540 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8541 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8544 cmdline_parse_inst_t cmd_queue_rate_limit = {
8545 .f = cmd_queue_rate_limit_parsed,
8547 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8548 "Set rate limit for a queue on port_id",
8550 (void *)&cmd_queue_rate_limit_set,
8551 (void *)&cmd_queue_rate_limit_port,
8552 (void *)&cmd_queue_rate_limit_portnum,
8553 (void *)&cmd_queue_rate_limit_queue,
8554 (void *)&cmd_queue_rate_limit_queuenum,
8555 (void *)&cmd_queue_rate_limit_rate,
8556 (void *)&cmd_queue_rate_limit_ratenum,
8561 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8562 struct cmd_vf_rate_limit_result {
8563 cmdline_fixed_string_t set;
8564 cmdline_fixed_string_t port;
8566 cmdline_fixed_string_t vf;
8568 cmdline_fixed_string_t rate;
8570 cmdline_fixed_string_t q_msk;
8574 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8575 __attribute__((unused)) struct cmdline *cl,
8576 __attribute__((unused)) void *data)
8578 struct cmd_vf_rate_limit_result *res = parsed_result;
8581 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8582 && (strcmp(res->vf, "vf") == 0)
8583 && (strcmp(res->rate, "rate") == 0)
8584 && (strcmp(res->q_msk, "queue_mask") == 0))
8585 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8586 res->rate_num, res->q_msk_val);
8588 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8592 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8593 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8595 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8596 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8598 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8599 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8601 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8602 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8604 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8605 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8607 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8608 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8610 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8611 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8613 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8614 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8615 q_msk, "queue_mask");
8616 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8617 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8620 cmdline_parse_inst_t cmd_vf_rate_limit = {
8621 .f = cmd_vf_rate_limit_parsed,
8623 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8624 "queue_mask <queue_mask_value>: "
8625 "Set rate limit for queues of VF on port_id",
8627 (void *)&cmd_vf_rate_limit_set,
8628 (void *)&cmd_vf_rate_limit_port,
8629 (void *)&cmd_vf_rate_limit_portnum,
8630 (void *)&cmd_vf_rate_limit_vf,
8631 (void *)&cmd_vf_rate_limit_vfnum,
8632 (void *)&cmd_vf_rate_limit_rate,
8633 (void *)&cmd_vf_rate_limit_ratenum,
8634 (void *)&cmd_vf_rate_limit_q_msk,
8635 (void *)&cmd_vf_rate_limit_q_msk_val,
8640 /* *** ADD TUNNEL FILTER OF A PORT *** */
8641 struct cmd_tunnel_filter_result {
8642 cmdline_fixed_string_t cmd;
8643 cmdline_fixed_string_t what;
8645 struct ether_addr outer_mac;
8646 struct ether_addr inner_mac;
8647 cmdline_ipaddr_t ip_value;
8648 uint16_t inner_vlan;
8649 cmdline_fixed_string_t tunnel_type;
8650 cmdline_fixed_string_t filter_type;
8656 cmd_tunnel_filter_parsed(void *parsed_result,
8657 __attribute__((unused)) struct cmdline *cl,
8658 __attribute__((unused)) void *data)
8660 struct cmd_tunnel_filter_result *res = parsed_result;
8661 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8664 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8666 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8667 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8668 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8670 if (res->ip_value.family == AF_INET) {
8671 tunnel_filter_conf.ip_addr.ipv4_addr =
8672 res->ip_value.addr.ipv4.s_addr;
8673 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8675 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8676 &(res->ip_value.addr.ipv6),
8677 sizeof(struct in6_addr));
8678 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8681 if (!strcmp(res->filter_type, "imac-ivlan"))
8682 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8683 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8684 tunnel_filter_conf.filter_type =
8685 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8686 else if (!strcmp(res->filter_type, "imac-tenid"))
8687 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8688 else if (!strcmp(res->filter_type, "imac"))
8689 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8690 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8691 tunnel_filter_conf.filter_type =
8692 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8693 else if (!strcmp(res->filter_type, "oip"))
8694 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8695 else if (!strcmp(res->filter_type, "iip"))
8696 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8698 printf("The filter type is not supported");
8702 if (!strcmp(res->tunnel_type, "vxlan"))
8703 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8704 else if (!strcmp(res->tunnel_type, "nvgre"))
8705 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8706 else if (!strcmp(res->tunnel_type, "ipingre"))
8707 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8709 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8713 tunnel_filter_conf.tenant_id = res->tenant_id;
8714 tunnel_filter_conf.queue_id = res->queue_num;
8715 if (!strcmp(res->what, "add"))
8716 ret = rte_eth_dev_filter_ctrl(res->port_id,
8717 RTE_ETH_FILTER_TUNNEL,
8719 &tunnel_filter_conf);
8721 ret = rte_eth_dev_filter_ctrl(res->port_id,
8722 RTE_ETH_FILTER_TUNNEL,
8723 RTE_ETH_FILTER_DELETE,
8724 &tunnel_filter_conf);
8726 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8730 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8731 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8732 cmd, "tunnel_filter");
8733 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8734 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8736 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8737 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8739 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8740 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8742 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8743 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8745 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8746 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8747 inner_vlan, UINT16);
8748 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8749 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8751 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8752 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8753 tunnel_type, "vxlan#nvgre#ipingre");
8755 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8756 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8757 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8758 "imac#omac-imac-tenid");
8759 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8760 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8762 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8763 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8766 cmdline_parse_inst_t cmd_tunnel_filter = {
8767 .f = cmd_tunnel_filter_parsed,
8769 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8770 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8771 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8772 "<queue_id>: Add/Rm tunnel filter of a port",
8774 (void *)&cmd_tunnel_filter_cmd,
8775 (void *)&cmd_tunnel_filter_what,
8776 (void *)&cmd_tunnel_filter_port_id,
8777 (void *)&cmd_tunnel_filter_outer_mac,
8778 (void *)&cmd_tunnel_filter_inner_mac,
8779 (void *)&cmd_tunnel_filter_ip_value,
8780 (void *)&cmd_tunnel_filter_innner_vlan,
8781 (void *)&cmd_tunnel_filter_tunnel_type,
8782 (void *)&cmd_tunnel_filter_filter_type,
8783 (void *)&cmd_tunnel_filter_tenant_id,
8784 (void *)&cmd_tunnel_filter_queue_num,
8789 /* *** CONFIGURE TUNNEL UDP PORT *** */
8790 struct cmd_tunnel_udp_config {
8791 cmdline_fixed_string_t cmd;
8792 cmdline_fixed_string_t what;
8798 cmd_tunnel_udp_config_parsed(void *parsed_result,
8799 __attribute__((unused)) struct cmdline *cl,
8800 __attribute__((unused)) void *data)
8802 struct cmd_tunnel_udp_config *res = parsed_result;
8803 struct rte_eth_udp_tunnel tunnel_udp;
8806 tunnel_udp.udp_port = res->udp_port;
8808 if (!strcmp(res->cmd, "rx_vxlan_port"))
8809 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8811 if (!strcmp(res->what, "add"))
8812 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8815 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8819 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8822 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8823 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8824 cmd, "rx_vxlan_port");
8825 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8826 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8828 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8829 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8831 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8832 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8835 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8836 .f = cmd_tunnel_udp_config_parsed,
8838 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8839 "Add/Remove a tunneling UDP port filter",
8841 (void *)&cmd_tunnel_udp_config_cmd,
8842 (void *)&cmd_tunnel_udp_config_what,
8843 (void *)&cmd_tunnel_udp_config_udp_port,
8844 (void *)&cmd_tunnel_udp_config_port_id,
8849 struct cmd_config_tunnel_udp_port {
8850 cmdline_fixed_string_t port;
8851 cmdline_fixed_string_t config;
8853 cmdline_fixed_string_t udp_tunnel_port;
8854 cmdline_fixed_string_t action;
8855 cmdline_fixed_string_t tunnel_type;
8860 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8861 __attribute__((unused)) struct cmdline *cl,
8862 __attribute__((unused)) void *data)
8864 struct cmd_config_tunnel_udp_port *res = parsed_result;
8865 struct rte_eth_udp_tunnel tunnel_udp;
8868 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8871 tunnel_udp.udp_port = res->udp_port;
8873 if (!strcmp(res->tunnel_type, "vxlan")) {
8874 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8875 } else if (!strcmp(res->tunnel_type, "geneve")) {
8876 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
8878 printf("Invalid tunnel type\n");
8882 if (!strcmp(res->action, "add"))
8883 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8886 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8890 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
8893 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
8894 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
8896 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
8897 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
8899 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
8900 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
8902 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
8903 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
8906 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
8907 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
8909 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
8910 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
8912 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
8913 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
8916 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
8917 .f = cmd_cfg_tunnel_udp_port_parsed,
8919 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve <udp_port>",
8921 (void *)&cmd_config_tunnel_udp_port_port,
8922 (void *)&cmd_config_tunnel_udp_port_config,
8923 (void *)&cmd_config_tunnel_udp_port_port_id,
8924 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
8925 (void *)&cmd_config_tunnel_udp_port_action,
8926 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
8927 (void *)&cmd_config_tunnel_udp_port_value,
8932 /* *** GLOBAL CONFIG *** */
8933 struct cmd_global_config_result {
8934 cmdline_fixed_string_t cmd;
8936 cmdline_fixed_string_t cfg_type;
8941 cmd_global_config_parsed(void *parsed_result,
8942 __attribute__((unused)) struct cmdline *cl,
8943 __attribute__((unused)) void *data)
8945 struct cmd_global_config_result *res = parsed_result;
8946 struct rte_eth_global_cfg conf;
8949 memset(&conf, 0, sizeof(conf));
8950 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8951 conf.cfg.gre_key_len = res->len;
8952 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8953 RTE_ETH_FILTER_SET, &conf);
8955 printf("Global config error\n");
8958 cmdline_parse_token_string_t cmd_global_config_cmd =
8959 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8961 cmdline_parse_token_num_t cmd_global_config_port_id =
8962 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8964 cmdline_parse_token_string_t cmd_global_config_type =
8965 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8966 cfg_type, "gre-key-len");
8967 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8968 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8971 cmdline_parse_inst_t cmd_global_config = {
8972 .f = cmd_global_config_parsed,
8973 .data = (void *)NULL,
8974 .help_str = "global_config <port_id> gre-key-len <key_len>",
8976 (void *)&cmd_global_config_cmd,
8977 (void *)&cmd_global_config_port_id,
8978 (void *)&cmd_global_config_type,
8979 (void *)&cmd_global_config_gre_key_len,
8984 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8985 struct cmd_set_mirror_mask_result {
8986 cmdline_fixed_string_t set;
8987 cmdline_fixed_string_t port;
8989 cmdline_fixed_string_t mirror;
8991 cmdline_fixed_string_t what;
8992 cmdline_fixed_string_t value;
8993 cmdline_fixed_string_t dstpool;
8995 cmdline_fixed_string_t on;
8998 cmdline_parse_token_string_t cmd_mirror_mask_set =
8999 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9001 cmdline_parse_token_string_t cmd_mirror_mask_port =
9002 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9004 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9005 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9007 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9008 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9009 mirror, "mirror-rule");
9010 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9011 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9013 cmdline_parse_token_string_t cmd_mirror_mask_what =
9014 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9015 what, "pool-mirror-up#pool-mirror-down"
9017 cmdline_parse_token_string_t cmd_mirror_mask_value =
9018 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9020 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9021 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9022 dstpool, "dst-pool");
9023 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9024 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9026 cmdline_parse_token_string_t cmd_mirror_mask_on =
9027 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9031 cmd_set_mirror_mask_parsed(void *parsed_result,
9032 __attribute__((unused)) struct cmdline *cl,
9033 __attribute__((unused)) void *data)
9036 struct cmd_set_mirror_mask_result *res = parsed_result;
9037 struct rte_eth_mirror_conf mr_conf;
9039 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9041 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9043 mr_conf.dst_pool = res->dstpool_id;
9045 if (!strcmp(res->what, "pool-mirror-up")) {
9046 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9047 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9048 } else if (!strcmp(res->what, "pool-mirror-down")) {
9049 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9050 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9051 } else if (!strcmp(res->what, "vlan-mirror")) {
9052 mr_conf.rule_type = ETH_MIRROR_VLAN;
9053 nb_item = parse_item_list(res->value, "vlan",
9054 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9058 for (i = 0; i < nb_item; i++) {
9059 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
9060 printf("Invalid vlan_id: must be < 4096\n");
9064 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9065 mr_conf.vlan.vlan_mask |= 1ULL << i;
9069 if (!strcmp(res->on, "on"))
9070 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9073 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9076 printf("mirror rule add error: (%s)\n", strerror(-ret));
9079 cmdline_parse_inst_t cmd_set_mirror_mask = {
9080 .f = cmd_set_mirror_mask_parsed,
9082 .help_str = "set port <port_id> mirror-rule <rule_id> "
9083 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9084 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9086 (void *)&cmd_mirror_mask_set,
9087 (void *)&cmd_mirror_mask_port,
9088 (void *)&cmd_mirror_mask_portid,
9089 (void *)&cmd_mirror_mask_mirror,
9090 (void *)&cmd_mirror_mask_ruleid,
9091 (void *)&cmd_mirror_mask_what,
9092 (void *)&cmd_mirror_mask_value,
9093 (void *)&cmd_mirror_mask_dstpool,
9094 (void *)&cmd_mirror_mask_poolid,
9095 (void *)&cmd_mirror_mask_on,
9100 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9101 struct cmd_set_mirror_link_result {
9102 cmdline_fixed_string_t set;
9103 cmdline_fixed_string_t port;
9105 cmdline_fixed_string_t mirror;
9107 cmdline_fixed_string_t what;
9108 cmdline_fixed_string_t dstpool;
9110 cmdline_fixed_string_t on;
9113 cmdline_parse_token_string_t cmd_mirror_link_set =
9114 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9116 cmdline_parse_token_string_t cmd_mirror_link_port =
9117 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9119 cmdline_parse_token_num_t cmd_mirror_link_portid =
9120 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9122 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9123 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9124 mirror, "mirror-rule");
9125 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9126 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9128 cmdline_parse_token_string_t cmd_mirror_link_what =
9129 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9130 what, "uplink-mirror#downlink-mirror");
9131 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9132 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9133 dstpool, "dst-pool");
9134 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9135 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9137 cmdline_parse_token_string_t cmd_mirror_link_on =
9138 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9142 cmd_set_mirror_link_parsed(void *parsed_result,
9143 __attribute__((unused)) struct cmdline *cl,
9144 __attribute__((unused)) void *data)
9147 struct cmd_set_mirror_link_result *res = parsed_result;
9148 struct rte_eth_mirror_conf mr_conf;
9150 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9151 if (!strcmp(res->what, "uplink-mirror"))
9152 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9154 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9156 mr_conf.dst_pool = res->dstpool_id;
9158 if (!strcmp(res->on, "on"))
9159 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9162 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9165 /* check the return value and print it if is < 0 */
9167 printf("mirror rule add error: (%s)\n", strerror(-ret));
9171 cmdline_parse_inst_t cmd_set_mirror_link = {
9172 .f = cmd_set_mirror_link_parsed,
9174 .help_str = "set port <port_id> mirror-rule <rule_id> "
9175 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9177 (void *)&cmd_mirror_link_set,
9178 (void *)&cmd_mirror_link_port,
9179 (void *)&cmd_mirror_link_portid,
9180 (void *)&cmd_mirror_link_mirror,
9181 (void *)&cmd_mirror_link_ruleid,
9182 (void *)&cmd_mirror_link_what,
9183 (void *)&cmd_mirror_link_dstpool,
9184 (void *)&cmd_mirror_link_poolid,
9185 (void *)&cmd_mirror_link_on,
9190 /* *** RESET VM MIRROR RULE *** */
9191 struct cmd_rm_mirror_rule_result {
9192 cmdline_fixed_string_t reset;
9193 cmdline_fixed_string_t port;
9195 cmdline_fixed_string_t mirror;
9199 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9200 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9202 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9203 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9205 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9206 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9208 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9209 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9210 mirror, "mirror-rule");
9211 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9212 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9216 cmd_reset_mirror_rule_parsed(void *parsed_result,
9217 __attribute__((unused)) struct cmdline *cl,
9218 __attribute__((unused)) void *data)
9221 struct cmd_set_mirror_link_result *res = parsed_result;
9223 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9225 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9228 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9229 .f = cmd_reset_mirror_rule_parsed,
9231 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9233 (void *)&cmd_rm_mirror_rule_reset,
9234 (void *)&cmd_rm_mirror_rule_port,
9235 (void *)&cmd_rm_mirror_rule_portid,
9236 (void *)&cmd_rm_mirror_rule_mirror,
9237 (void *)&cmd_rm_mirror_rule_ruleid,
9242 /* ******************************************************************************** */
9244 struct cmd_dump_result {
9245 cmdline_fixed_string_t dump;
9249 dump_struct_sizes(void)
9251 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9252 DUMP_SIZE(struct rte_mbuf);
9253 DUMP_SIZE(struct rte_mempool);
9254 DUMP_SIZE(struct rte_ring);
9258 static void cmd_dump_parsed(void *parsed_result,
9259 __attribute__((unused)) struct cmdline *cl,
9260 __attribute__((unused)) void *data)
9262 struct cmd_dump_result *res = parsed_result;
9264 if (!strcmp(res->dump, "dump_physmem"))
9265 rte_dump_physmem_layout(stdout);
9266 else if (!strcmp(res->dump, "dump_memzone"))
9267 rte_memzone_dump(stdout);
9268 else if (!strcmp(res->dump, "dump_struct_sizes"))
9269 dump_struct_sizes();
9270 else if (!strcmp(res->dump, "dump_ring"))
9271 rte_ring_list_dump(stdout);
9272 else if (!strcmp(res->dump, "dump_mempool"))
9273 rte_mempool_list_dump(stdout);
9274 else if (!strcmp(res->dump, "dump_devargs"))
9275 rte_devargs_dump(stdout);
9276 else if (!strcmp(res->dump, "dump_log_types"))
9277 rte_log_dump(stdout);
9280 cmdline_parse_token_string_t cmd_dump_dump =
9281 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9284 "dump_struct_sizes#"
9290 cmdline_parse_inst_t cmd_dump = {
9291 .f = cmd_dump_parsed, /* function to call */
9292 .data = NULL, /* 2nd arg of func */
9293 .help_str = "Dump status",
9294 .tokens = { /* token list, NULL terminated */
9295 (void *)&cmd_dump_dump,
9300 /* ******************************************************************************** */
9302 struct cmd_dump_one_result {
9303 cmdline_fixed_string_t dump;
9304 cmdline_fixed_string_t name;
9307 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9308 __attribute__((unused)) void *data)
9310 struct cmd_dump_one_result *res = parsed_result;
9312 if (!strcmp(res->dump, "dump_ring")) {
9314 r = rte_ring_lookup(res->name);
9316 cmdline_printf(cl, "Cannot find ring\n");
9319 rte_ring_dump(stdout, r);
9320 } else if (!strcmp(res->dump, "dump_mempool")) {
9321 struct rte_mempool *mp;
9322 mp = rte_mempool_lookup(res->name);
9324 cmdline_printf(cl, "Cannot find mempool\n");
9327 rte_mempool_dump(stdout, mp);
9331 cmdline_parse_token_string_t cmd_dump_one_dump =
9332 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9333 "dump_ring#dump_mempool");
9335 cmdline_parse_token_string_t cmd_dump_one_name =
9336 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9338 cmdline_parse_inst_t cmd_dump_one = {
9339 .f = cmd_dump_one_parsed, /* function to call */
9340 .data = NULL, /* 2nd arg of func */
9341 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9342 .tokens = { /* token list, NULL terminated */
9343 (void *)&cmd_dump_one_dump,
9344 (void *)&cmd_dump_one_name,
9349 /* *** Add/Del syn filter *** */
9350 struct cmd_syn_filter_result {
9351 cmdline_fixed_string_t filter;
9353 cmdline_fixed_string_t ops;
9354 cmdline_fixed_string_t priority;
9355 cmdline_fixed_string_t high;
9356 cmdline_fixed_string_t queue;
9361 cmd_syn_filter_parsed(void *parsed_result,
9362 __attribute__((unused)) struct cmdline *cl,
9363 __attribute__((unused)) void *data)
9365 struct cmd_syn_filter_result *res = parsed_result;
9366 struct rte_eth_syn_filter syn_filter;
9369 ret = rte_eth_dev_filter_supported(res->port_id,
9370 RTE_ETH_FILTER_SYN);
9372 printf("syn filter is not supported on port %u.\n",
9377 memset(&syn_filter, 0, sizeof(syn_filter));
9379 if (!strcmp(res->ops, "add")) {
9380 if (!strcmp(res->high, "high"))
9381 syn_filter.hig_pri = 1;
9383 syn_filter.hig_pri = 0;
9385 syn_filter.queue = res->queue_id;
9386 ret = rte_eth_dev_filter_ctrl(res->port_id,
9391 ret = rte_eth_dev_filter_ctrl(res->port_id,
9393 RTE_ETH_FILTER_DELETE,
9397 printf("syn filter programming error: (%s)\n",
9401 cmdline_parse_token_string_t cmd_syn_filter_filter =
9402 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9403 filter, "syn_filter");
9404 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9405 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9407 cmdline_parse_token_string_t cmd_syn_filter_ops =
9408 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9410 cmdline_parse_token_string_t cmd_syn_filter_priority =
9411 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9412 priority, "priority");
9413 cmdline_parse_token_string_t cmd_syn_filter_high =
9414 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9416 cmdline_parse_token_string_t cmd_syn_filter_queue =
9417 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9419 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9420 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9423 cmdline_parse_inst_t cmd_syn_filter = {
9424 .f = cmd_syn_filter_parsed,
9426 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9427 "<queue_id>: Add/Delete syn filter",
9429 (void *)&cmd_syn_filter_filter,
9430 (void *)&cmd_syn_filter_port_id,
9431 (void *)&cmd_syn_filter_ops,
9432 (void *)&cmd_syn_filter_priority,
9433 (void *)&cmd_syn_filter_high,
9434 (void *)&cmd_syn_filter_queue,
9435 (void *)&cmd_syn_filter_queue_id,
9440 /* *** queue region set *** */
9441 struct cmd_queue_region_result {
9442 cmdline_fixed_string_t set;
9443 cmdline_fixed_string_t port;
9445 cmdline_fixed_string_t cmd;
9446 cmdline_fixed_string_t region;
9448 cmdline_fixed_string_t queue_start_index;
9450 cmdline_fixed_string_t queue_num;
9451 uint8_t queue_num_value;
9455 cmd_queue_region_parsed(void *parsed_result,
9456 __attribute__((unused)) struct cmdline *cl,
9457 __attribute__((unused)) void *data)
9459 struct cmd_queue_region_result *res = parsed_result;
9461 #ifdef RTE_LIBRTE_I40E_PMD
9462 struct rte_pmd_i40e_queue_region_conf region_conf;
9463 enum rte_pmd_i40e_queue_region_op op_type;
9466 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9469 #ifdef RTE_LIBRTE_I40E_PMD
9470 memset(®ion_conf, 0, sizeof(region_conf));
9471 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9472 region_conf.region_id = res->region_id;
9473 region_conf.queue_num = res->queue_num_value;
9474 region_conf.queue_start_index = res->queue_id;
9476 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9477 op_type, ®ion_conf);
9484 printf("function not implemented or supported\n");
9487 printf("queue region config error: (%s)\n", strerror(-ret));
9491 cmdline_parse_token_string_t cmd_queue_region_set =
9492 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9494 cmdline_parse_token_string_t cmd_queue_region_port =
9495 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9496 cmdline_parse_token_num_t cmd_queue_region_port_id =
9497 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9499 cmdline_parse_token_string_t cmd_queue_region_cmd =
9500 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9501 cmd, "queue-region");
9502 cmdline_parse_token_string_t cmd_queue_region_id =
9503 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9504 region, "region_id");
9505 cmdline_parse_token_num_t cmd_queue_region_index =
9506 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9508 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9509 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9510 queue_start_index, "queue_start_index");
9511 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9512 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9514 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9515 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9516 queue_num, "queue_num");
9517 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9518 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9519 queue_num_value, UINT8);
9521 cmdline_parse_inst_t cmd_queue_region = {
9522 .f = cmd_queue_region_parsed,
9524 .help_str = "set port <port_id> queue-region region_id <value> "
9525 "queue_start_index <value> queue_num <value>: Set a queue region",
9527 (void *)&cmd_queue_region_set,
9528 (void *)&cmd_queue_region_port,
9529 (void *)&cmd_queue_region_port_id,
9530 (void *)&cmd_queue_region_cmd,
9531 (void *)&cmd_queue_region_id,
9532 (void *)&cmd_queue_region_index,
9533 (void *)&cmd_queue_region_queue_start_index,
9534 (void *)&cmd_queue_region_queue_id,
9535 (void *)&cmd_queue_region_queue_num,
9536 (void *)&cmd_queue_region_queue_num_value,
9541 /* *** queue region and flowtype set *** */
9542 struct cmd_region_flowtype_result {
9543 cmdline_fixed_string_t set;
9544 cmdline_fixed_string_t port;
9546 cmdline_fixed_string_t cmd;
9547 cmdline_fixed_string_t region;
9549 cmdline_fixed_string_t flowtype;
9550 uint8_t flowtype_id;
9554 cmd_region_flowtype_parsed(void *parsed_result,
9555 __attribute__((unused)) struct cmdline *cl,
9556 __attribute__((unused)) void *data)
9558 struct cmd_region_flowtype_result *res = parsed_result;
9560 #ifdef RTE_LIBRTE_I40E_PMD
9561 struct rte_pmd_i40e_queue_region_conf region_conf;
9562 enum rte_pmd_i40e_queue_region_op op_type;
9565 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9568 #ifdef RTE_LIBRTE_I40E_PMD
9569 memset(®ion_conf, 0, sizeof(region_conf));
9571 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9572 region_conf.region_id = res->region_id;
9573 region_conf.hw_flowtype = res->flowtype_id;
9575 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9576 op_type, ®ion_conf);
9583 printf("function not implemented or supported\n");
9586 printf("region flowtype config error: (%s)\n", strerror(-ret));
9590 cmdline_parse_token_string_t cmd_region_flowtype_set =
9591 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9593 cmdline_parse_token_string_t cmd_region_flowtype_port =
9594 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9596 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9597 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9599 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9600 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9601 cmd, "queue-region");
9602 cmdline_parse_token_string_t cmd_region_flowtype_index =
9603 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9604 region, "region_id");
9605 cmdline_parse_token_num_t cmd_region_flowtype_id =
9606 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9608 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9609 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9610 flowtype, "flowtype");
9611 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9612 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9613 flowtype_id, UINT8);
9614 cmdline_parse_inst_t cmd_region_flowtype = {
9615 .f = cmd_region_flowtype_parsed,
9617 .help_str = "set port <port_id> queue-region region_id <value> "
9618 "flowtype <value>: Set a flowtype region index",
9620 (void *)&cmd_region_flowtype_set,
9621 (void *)&cmd_region_flowtype_port,
9622 (void *)&cmd_region_flowtype_port_index,
9623 (void *)&cmd_region_flowtype_cmd,
9624 (void *)&cmd_region_flowtype_index,
9625 (void *)&cmd_region_flowtype_id,
9626 (void *)&cmd_region_flowtype_flow_index,
9627 (void *)&cmd_region_flowtype_flow_id,
9632 /* *** User Priority (UP) to queue region (region_id) set *** */
9633 struct cmd_user_priority_region_result {
9634 cmdline_fixed_string_t set;
9635 cmdline_fixed_string_t port;
9637 cmdline_fixed_string_t cmd;
9638 cmdline_fixed_string_t user_priority;
9639 uint8_t user_priority_id;
9640 cmdline_fixed_string_t region;
9645 cmd_user_priority_region_parsed(void *parsed_result,
9646 __attribute__((unused)) struct cmdline *cl,
9647 __attribute__((unused)) void *data)
9649 struct cmd_user_priority_region_result *res = parsed_result;
9651 #ifdef RTE_LIBRTE_I40E_PMD
9652 struct rte_pmd_i40e_queue_region_conf region_conf;
9653 enum rte_pmd_i40e_queue_region_op op_type;
9656 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9659 #ifdef RTE_LIBRTE_I40E_PMD
9660 memset(®ion_conf, 0, sizeof(region_conf));
9661 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9662 region_conf.user_priority = res->user_priority_id;
9663 region_conf.region_id = res->region_id;
9665 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9666 op_type, ®ion_conf);
9673 printf("function not implemented or supported\n");
9676 printf("user_priority region config error: (%s)\n",
9681 cmdline_parse_token_string_t cmd_user_priority_region_set =
9682 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9684 cmdline_parse_token_string_t cmd_user_priority_region_port =
9685 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9687 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9688 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9690 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9691 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9692 cmd, "queue-region");
9693 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9694 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9695 user_priority, "UP");
9696 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9697 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9698 user_priority_id, UINT8);
9699 cmdline_parse_token_string_t cmd_user_priority_region_region =
9700 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9701 region, "region_id");
9702 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9703 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9706 cmdline_parse_inst_t cmd_user_priority_region = {
9707 .f = cmd_user_priority_region_parsed,
9709 .help_str = "set port <port_id> queue-region UP <value> "
9710 "region_id <value>: Set the mapping of User Priority (UP) "
9711 "to queue region (region_id) ",
9713 (void *)&cmd_user_priority_region_set,
9714 (void *)&cmd_user_priority_region_port,
9715 (void *)&cmd_user_priority_region_port_index,
9716 (void *)&cmd_user_priority_region_cmd,
9717 (void *)&cmd_user_priority_region_UP,
9718 (void *)&cmd_user_priority_region_UP_id,
9719 (void *)&cmd_user_priority_region_region,
9720 (void *)&cmd_user_priority_region_region_id,
9725 /* *** flush all queue region related configuration *** */
9726 struct cmd_flush_queue_region_result {
9727 cmdline_fixed_string_t set;
9728 cmdline_fixed_string_t port;
9730 cmdline_fixed_string_t cmd;
9731 cmdline_fixed_string_t flush;
9732 cmdline_fixed_string_t what;
9736 cmd_flush_queue_region_parsed(void *parsed_result,
9737 __attribute__((unused)) struct cmdline *cl,
9738 __attribute__((unused)) void *data)
9740 struct cmd_flush_queue_region_result *res = parsed_result;
9742 #ifdef RTE_LIBRTE_I40E_PMD
9743 struct rte_pmd_i40e_queue_region_conf region_conf;
9744 enum rte_pmd_i40e_queue_region_op op_type;
9747 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9750 #ifdef RTE_LIBRTE_I40E_PMD
9751 memset(®ion_conf, 0, sizeof(region_conf));
9753 if (strcmp(res->what, "on") == 0)
9754 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9756 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9758 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9759 op_type, ®ion_conf);
9766 printf("function not implemented or supported\n");
9769 printf("queue region config flush error: (%s)\n",
9774 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9775 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9777 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9778 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9780 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9781 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9783 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9784 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9785 cmd, "queue-region");
9786 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9787 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9789 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9790 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9793 cmdline_parse_inst_t cmd_flush_queue_region = {
9794 .f = cmd_flush_queue_region_parsed,
9796 .help_str = "set port <port_id> queue-region flush on|off"
9797 ": flush all queue region related configuration",
9799 (void *)&cmd_flush_queue_region_set,
9800 (void *)&cmd_flush_queue_region_port,
9801 (void *)&cmd_flush_queue_region_port_index,
9802 (void *)&cmd_flush_queue_region_cmd,
9803 (void *)&cmd_flush_queue_region_flush,
9804 (void *)&cmd_flush_queue_region_what,
9809 /* *** get all queue region related configuration info *** */
9810 struct cmd_show_queue_region_info {
9811 cmdline_fixed_string_t show;
9812 cmdline_fixed_string_t port;
9814 cmdline_fixed_string_t cmd;
9818 cmd_show_queue_region_info_parsed(void *parsed_result,
9819 __attribute__((unused)) struct cmdline *cl,
9820 __attribute__((unused)) void *data)
9822 struct cmd_show_queue_region_info *res = parsed_result;
9824 #ifdef RTE_LIBRTE_I40E_PMD
9825 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9826 enum rte_pmd_i40e_queue_region_op op_type;
9829 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9832 #ifdef RTE_LIBRTE_I40E_PMD
9833 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9835 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9837 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9838 op_type, &rte_pmd_regions);
9840 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9847 printf("function not implemented or supported\n");
9850 printf("queue region config info show error: (%s)\n",
9855 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9856 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9858 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9859 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9861 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9862 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9864 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9865 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9866 cmd, "queue-region");
9868 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9869 .f = cmd_show_queue_region_info_parsed,
9871 .help_str = "show port <port_id> queue-region"
9872 ": show all queue region related configuration info",
9874 (void *)&cmd_show_queue_region_info_get,
9875 (void *)&cmd_show_queue_region_info_port,
9876 (void *)&cmd_show_queue_region_info_port_index,
9877 (void *)&cmd_show_queue_region_info_cmd,
9882 /* *** ADD/REMOVE A 2tuple FILTER *** */
9883 struct cmd_2tuple_filter_result {
9884 cmdline_fixed_string_t filter;
9886 cmdline_fixed_string_t ops;
9887 cmdline_fixed_string_t dst_port;
9888 uint16_t dst_port_value;
9889 cmdline_fixed_string_t protocol;
9890 uint8_t protocol_value;
9891 cmdline_fixed_string_t mask;
9893 cmdline_fixed_string_t tcp_flags;
9894 uint8_t tcp_flags_value;
9895 cmdline_fixed_string_t priority;
9896 uint8_t priority_value;
9897 cmdline_fixed_string_t queue;
9902 cmd_2tuple_filter_parsed(void *parsed_result,
9903 __attribute__((unused)) struct cmdline *cl,
9904 __attribute__((unused)) void *data)
9906 struct rte_eth_ntuple_filter filter;
9907 struct cmd_2tuple_filter_result *res = parsed_result;
9910 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9912 printf("ntuple filter is not supported on port %u.\n",
9917 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9919 filter.flags = RTE_2TUPLE_FLAGS;
9920 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9921 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9922 filter.proto = res->protocol_value;
9923 filter.priority = res->priority_value;
9924 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9925 printf("nonzero tcp_flags is only meaningful"
9926 " when protocol is TCP.\n");
9929 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9930 printf("invalid TCP flags.\n");
9934 if (res->tcp_flags_value != 0) {
9935 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9936 filter.tcp_flags = res->tcp_flags_value;
9939 /* need convert to big endian. */
9940 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9941 filter.queue = res->queue_id;
9943 if (!strcmp(res->ops, "add"))
9944 ret = rte_eth_dev_filter_ctrl(res->port_id,
9945 RTE_ETH_FILTER_NTUPLE,
9949 ret = rte_eth_dev_filter_ctrl(res->port_id,
9950 RTE_ETH_FILTER_NTUPLE,
9951 RTE_ETH_FILTER_DELETE,
9954 printf("2tuple filter programming error: (%s)\n",
9959 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9960 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9961 filter, "2tuple_filter");
9962 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9963 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9965 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9966 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9968 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9969 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9970 dst_port, "dst_port");
9971 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9972 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9973 dst_port_value, UINT16);
9974 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9975 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9976 protocol, "protocol");
9977 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9978 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9979 protocol_value, UINT8);
9980 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9981 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9983 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9984 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9986 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9987 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9988 tcp_flags, "tcp_flags");
9989 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9990 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9991 tcp_flags_value, UINT8);
9992 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9993 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9994 priority, "priority");
9995 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9996 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9997 priority_value, UINT8);
9998 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9999 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10001 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10002 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10005 cmdline_parse_inst_t cmd_2tuple_filter = {
10006 .f = cmd_2tuple_filter_parsed,
10008 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10009 "<value> mask <value> tcp_flags <value> priority <value> queue "
10010 "<queue_id>: Add a 2tuple filter",
10012 (void *)&cmd_2tuple_filter_filter,
10013 (void *)&cmd_2tuple_filter_port_id,
10014 (void *)&cmd_2tuple_filter_ops,
10015 (void *)&cmd_2tuple_filter_dst_port,
10016 (void *)&cmd_2tuple_filter_dst_port_value,
10017 (void *)&cmd_2tuple_filter_protocol,
10018 (void *)&cmd_2tuple_filter_protocol_value,
10019 (void *)&cmd_2tuple_filter_mask,
10020 (void *)&cmd_2tuple_filter_mask_value,
10021 (void *)&cmd_2tuple_filter_tcp_flags,
10022 (void *)&cmd_2tuple_filter_tcp_flags_value,
10023 (void *)&cmd_2tuple_filter_priority,
10024 (void *)&cmd_2tuple_filter_priority_value,
10025 (void *)&cmd_2tuple_filter_queue,
10026 (void *)&cmd_2tuple_filter_queue_id,
10031 /* *** ADD/REMOVE A 5tuple FILTER *** */
10032 struct cmd_5tuple_filter_result {
10033 cmdline_fixed_string_t filter;
10035 cmdline_fixed_string_t ops;
10036 cmdline_fixed_string_t dst_ip;
10037 cmdline_ipaddr_t dst_ip_value;
10038 cmdline_fixed_string_t src_ip;
10039 cmdline_ipaddr_t src_ip_value;
10040 cmdline_fixed_string_t dst_port;
10041 uint16_t dst_port_value;
10042 cmdline_fixed_string_t src_port;
10043 uint16_t src_port_value;
10044 cmdline_fixed_string_t protocol;
10045 uint8_t protocol_value;
10046 cmdline_fixed_string_t mask;
10047 uint8_t mask_value;
10048 cmdline_fixed_string_t tcp_flags;
10049 uint8_t tcp_flags_value;
10050 cmdline_fixed_string_t priority;
10051 uint8_t priority_value;
10052 cmdline_fixed_string_t queue;
10057 cmd_5tuple_filter_parsed(void *parsed_result,
10058 __attribute__((unused)) struct cmdline *cl,
10059 __attribute__((unused)) void *data)
10061 struct rte_eth_ntuple_filter filter;
10062 struct cmd_5tuple_filter_result *res = parsed_result;
10065 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10067 printf("ntuple filter is not supported on port %u.\n",
10072 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10074 filter.flags = RTE_5TUPLE_FLAGS;
10075 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10076 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10077 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10078 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10079 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10080 filter.proto = res->protocol_value;
10081 filter.priority = res->priority_value;
10082 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10083 printf("nonzero tcp_flags is only meaningful"
10084 " when protocol is TCP.\n");
10087 if (res->tcp_flags_value > TCP_FLAG_ALL) {
10088 printf("invalid TCP flags.\n");
10092 if (res->tcp_flags_value != 0) {
10093 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10094 filter.tcp_flags = res->tcp_flags_value;
10097 if (res->dst_ip_value.family == AF_INET)
10098 /* no need to convert, already big endian. */
10099 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10101 if (filter.dst_ip_mask == 0) {
10102 printf("can not support ipv6 involved compare.\n");
10108 if (res->src_ip_value.family == AF_INET)
10109 /* no need to convert, already big endian. */
10110 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10112 if (filter.src_ip_mask == 0) {
10113 printf("can not support ipv6 involved compare.\n");
10118 /* need convert to big endian. */
10119 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10120 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10121 filter.queue = res->queue_id;
10123 if (!strcmp(res->ops, "add"))
10124 ret = rte_eth_dev_filter_ctrl(res->port_id,
10125 RTE_ETH_FILTER_NTUPLE,
10126 RTE_ETH_FILTER_ADD,
10129 ret = rte_eth_dev_filter_ctrl(res->port_id,
10130 RTE_ETH_FILTER_NTUPLE,
10131 RTE_ETH_FILTER_DELETE,
10134 printf("5tuple filter programming error: (%s)\n",
10138 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10139 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10140 filter, "5tuple_filter");
10141 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10142 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10144 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10145 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10147 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10148 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10150 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10151 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10153 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10154 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10156 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10157 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10159 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10160 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10161 dst_port, "dst_port");
10162 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10163 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10164 dst_port_value, UINT16);
10165 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10166 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10167 src_port, "src_port");
10168 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10169 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10170 src_port_value, UINT16);
10171 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10172 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10173 protocol, "protocol");
10174 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10175 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10176 protocol_value, UINT8);
10177 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10178 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10180 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10181 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10183 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10184 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10185 tcp_flags, "tcp_flags");
10186 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10187 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10188 tcp_flags_value, UINT8);
10189 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10190 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10191 priority, "priority");
10192 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10193 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10194 priority_value, UINT8);
10195 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10196 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10198 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10199 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10202 cmdline_parse_inst_t cmd_5tuple_filter = {
10203 .f = cmd_5tuple_filter_parsed,
10205 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10206 "src_ip <value> dst_port <value> src_port <value> "
10207 "protocol <value> mask <value> tcp_flags <value> "
10208 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10210 (void *)&cmd_5tuple_filter_filter,
10211 (void *)&cmd_5tuple_filter_port_id,
10212 (void *)&cmd_5tuple_filter_ops,
10213 (void *)&cmd_5tuple_filter_dst_ip,
10214 (void *)&cmd_5tuple_filter_dst_ip_value,
10215 (void *)&cmd_5tuple_filter_src_ip,
10216 (void *)&cmd_5tuple_filter_src_ip_value,
10217 (void *)&cmd_5tuple_filter_dst_port,
10218 (void *)&cmd_5tuple_filter_dst_port_value,
10219 (void *)&cmd_5tuple_filter_src_port,
10220 (void *)&cmd_5tuple_filter_src_port_value,
10221 (void *)&cmd_5tuple_filter_protocol,
10222 (void *)&cmd_5tuple_filter_protocol_value,
10223 (void *)&cmd_5tuple_filter_mask,
10224 (void *)&cmd_5tuple_filter_mask_value,
10225 (void *)&cmd_5tuple_filter_tcp_flags,
10226 (void *)&cmd_5tuple_filter_tcp_flags_value,
10227 (void *)&cmd_5tuple_filter_priority,
10228 (void *)&cmd_5tuple_filter_priority_value,
10229 (void *)&cmd_5tuple_filter_queue,
10230 (void *)&cmd_5tuple_filter_queue_id,
10235 /* *** ADD/REMOVE A flex FILTER *** */
10236 struct cmd_flex_filter_result {
10237 cmdline_fixed_string_t filter;
10238 cmdline_fixed_string_t ops;
10240 cmdline_fixed_string_t len;
10242 cmdline_fixed_string_t bytes;
10243 cmdline_fixed_string_t bytes_value;
10244 cmdline_fixed_string_t mask;
10245 cmdline_fixed_string_t mask_value;
10246 cmdline_fixed_string_t priority;
10247 uint8_t priority_value;
10248 cmdline_fixed_string_t queue;
10252 static int xdigit2val(unsigned char c)
10257 else if (isupper(c))
10258 val = c - 'A' + 10;
10260 val = c - 'a' + 10;
10265 cmd_flex_filter_parsed(void *parsed_result,
10266 __attribute__((unused)) struct cmdline *cl,
10267 __attribute__((unused)) void *data)
10270 struct rte_eth_flex_filter filter;
10271 struct cmd_flex_filter_result *res = parsed_result;
10272 char *bytes_ptr, *mask_ptr;
10273 uint16_t len, i, j = 0;
10278 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10279 printf("the len exceed the max length 128\n");
10282 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10283 filter.len = res->len_value;
10284 filter.priority = res->priority_value;
10285 filter.queue = res->queue_id;
10286 bytes_ptr = res->bytes_value;
10287 mask_ptr = res->mask_value;
10289 /* translate bytes string to array. */
10290 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10291 (bytes_ptr[1] == 'X')))
10293 len = strnlen(bytes_ptr, res->len_value * 2);
10294 if (len == 0 || (len % 8 != 0)) {
10295 printf("please check len and bytes input\n");
10298 for (i = 0; i < len; i++) {
10300 if (isxdigit(c) == 0) {
10301 /* invalid characters. */
10302 printf("invalid input\n");
10305 val = xdigit2val(c);
10308 filter.bytes[j] = byte;
10309 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10316 /* translate mask string to uint8_t array. */
10317 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10318 (mask_ptr[1] == 'X')))
10320 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10322 printf("invalid input\n");
10327 for (i = 0; i < len; i++) {
10329 if (isxdigit(c) == 0) {
10330 /* invalid characters. */
10331 printf("invalid input\n");
10334 val = xdigit2val(c);
10337 filter.mask[j] = byte;
10338 printf("mask[%d]:%02x ", j, filter.mask[j]);
10346 if (!strcmp(res->ops, "add"))
10347 ret = rte_eth_dev_filter_ctrl(res->port_id,
10348 RTE_ETH_FILTER_FLEXIBLE,
10349 RTE_ETH_FILTER_ADD,
10352 ret = rte_eth_dev_filter_ctrl(res->port_id,
10353 RTE_ETH_FILTER_FLEXIBLE,
10354 RTE_ETH_FILTER_DELETE,
10358 printf("flex filter setting error: (%s)\n", strerror(-ret));
10361 cmdline_parse_token_string_t cmd_flex_filter_filter =
10362 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10363 filter, "flex_filter");
10364 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10365 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10367 cmdline_parse_token_string_t cmd_flex_filter_ops =
10368 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10370 cmdline_parse_token_string_t cmd_flex_filter_len =
10371 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10373 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10374 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10376 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10377 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10379 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10380 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10381 bytes_value, NULL);
10382 cmdline_parse_token_string_t cmd_flex_filter_mask =
10383 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10385 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10386 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10388 cmdline_parse_token_string_t cmd_flex_filter_priority =
10389 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10390 priority, "priority");
10391 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10392 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10393 priority_value, UINT8);
10394 cmdline_parse_token_string_t cmd_flex_filter_queue =
10395 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10397 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10398 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10400 cmdline_parse_inst_t cmd_flex_filter = {
10401 .f = cmd_flex_filter_parsed,
10403 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10404 "<value> mask <value> priority <value> queue <queue_id>: "
10405 "Add/Del a flex filter",
10407 (void *)&cmd_flex_filter_filter,
10408 (void *)&cmd_flex_filter_port_id,
10409 (void *)&cmd_flex_filter_ops,
10410 (void *)&cmd_flex_filter_len,
10411 (void *)&cmd_flex_filter_len_value,
10412 (void *)&cmd_flex_filter_bytes,
10413 (void *)&cmd_flex_filter_bytes_value,
10414 (void *)&cmd_flex_filter_mask,
10415 (void *)&cmd_flex_filter_mask_value,
10416 (void *)&cmd_flex_filter_priority,
10417 (void *)&cmd_flex_filter_priority_value,
10418 (void *)&cmd_flex_filter_queue,
10419 (void *)&cmd_flex_filter_queue_id,
10424 /* *** Filters Control *** */
10426 /* *** deal with ethertype filter *** */
10427 struct cmd_ethertype_filter_result {
10428 cmdline_fixed_string_t filter;
10430 cmdline_fixed_string_t ops;
10431 cmdline_fixed_string_t mac;
10432 struct ether_addr mac_addr;
10433 cmdline_fixed_string_t ethertype;
10434 uint16_t ethertype_value;
10435 cmdline_fixed_string_t drop;
10436 cmdline_fixed_string_t queue;
10440 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10441 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10442 filter, "ethertype_filter");
10443 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10444 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10446 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10447 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10449 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10450 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10451 mac, "mac_addr#mac_ignr");
10452 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10453 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10455 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10456 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10457 ethertype, "ethertype");
10458 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10459 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10460 ethertype_value, UINT16);
10461 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10462 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10464 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10465 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10467 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10468 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10472 cmd_ethertype_filter_parsed(void *parsed_result,
10473 __attribute__((unused)) struct cmdline *cl,
10474 __attribute__((unused)) void *data)
10476 struct cmd_ethertype_filter_result *res = parsed_result;
10477 struct rte_eth_ethertype_filter filter;
10480 ret = rte_eth_dev_filter_supported(res->port_id,
10481 RTE_ETH_FILTER_ETHERTYPE);
10483 printf("ethertype filter is not supported on port %u.\n",
10488 memset(&filter, 0, sizeof(filter));
10489 if (!strcmp(res->mac, "mac_addr")) {
10490 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10491 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10492 sizeof(struct ether_addr));
10494 if (!strcmp(res->drop, "drop"))
10495 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10496 filter.ether_type = res->ethertype_value;
10497 filter.queue = res->queue_id;
10499 if (!strcmp(res->ops, "add"))
10500 ret = rte_eth_dev_filter_ctrl(res->port_id,
10501 RTE_ETH_FILTER_ETHERTYPE,
10502 RTE_ETH_FILTER_ADD,
10505 ret = rte_eth_dev_filter_ctrl(res->port_id,
10506 RTE_ETH_FILTER_ETHERTYPE,
10507 RTE_ETH_FILTER_DELETE,
10510 printf("ethertype filter programming error: (%s)\n",
10514 cmdline_parse_inst_t cmd_ethertype_filter = {
10515 .f = cmd_ethertype_filter_parsed,
10517 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10518 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10519 "Add or delete an ethertype filter entry",
10521 (void *)&cmd_ethertype_filter_filter,
10522 (void *)&cmd_ethertype_filter_port_id,
10523 (void *)&cmd_ethertype_filter_ops,
10524 (void *)&cmd_ethertype_filter_mac,
10525 (void *)&cmd_ethertype_filter_mac_addr,
10526 (void *)&cmd_ethertype_filter_ethertype,
10527 (void *)&cmd_ethertype_filter_ethertype_value,
10528 (void *)&cmd_ethertype_filter_drop,
10529 (void *)&cmd_ethertype_filter_queue,
10530 (void *)&cmd_ethertype_filter_queue_id,
10535 /* *** deal with flow director filter *** */
10536 struct cmd_flow_director_result {
10537 cmdline_fixed_string_t flow_director_filter;
10539 cmdline_fixed_string_t mode;
10540 cmdline_fixed_string_t mode_value;
10541 cmdline_fixed_string_t ops;
10542 cmdline_fixed_string_t flow;
10543 cmdline_fixed_string_t flow_type;
10544 cmdline_fixed_string_t ether;
10545 uint16_t ether_type;
10546 cmdline_fixed_string_t src;
10547 cmdline_ipaddr_t ip_src;
10549 cmdline_fixed_string_t dst;
10550 cmdline_ipaddr_t ip_dst;
10552 cmdline_fixed_string_t verify_tag;
10553 uint32_t verify_tag_value;
10554 cmdline_fixed_string_t tos;
10556 cmdline_fixed_string_t proto;
10557 uint8_t proto_value;
10558 cmdline_fixed_string_t ttl;
10560 cmdline_fixed_string_t vlan;
10561 uint16_t vlan_value;
10562 cmdline_fixed_string_t flexbytes;
10563 cmdline_fixed_string_t flexbytes_value;
10564 cmdline_fixed_string_t pf_vf;
10565 cmdline_fixed_string_t drop;
10566 cmdline_fixed_string_t queue;
10568 cmdline_fixed_string_t fd_id;
10569 uint32_t fd_id_value;
10570 cmdline_fixed_string_t mac;
10571 struct ether_addr mac_addr;
10572 cmdline_fixed_string_t tunnel;
10573 cmdline_fixed_string_t tunnel_type;
10574 cmdline_fixed_string_t tunnel_id;
10575 uint32_t tunnel_id_value;
10576 cmdline_fixed_string_t packet;
10581 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10584 const char *p, *p0 = q_arg;
10586 unsigned long int_fld;
10587 char *str_fld[max_num];
10592 p = strchr(p0, '(');
10596 p0 = strchr(p, ')');
10601 if (size >= sizeof(s))
10604 snprintf(s, sizeof(s), "%.*s", size, p);
10605 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10606 if (ret < 0 || ret > max_num)
10608 for (i = 0; i < ret; i++) {
10610 int_fld = strtoul(str_fld[i], &end, 0);
10611 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10613 flexbytes[i] = (uint8_t)int_fld;
10619 str2flowtype(char *string)
10622 static const struct {
10625 } flowtype_str[] = {
10626 {"raw", RTE_ETH_FLOW_RAW},
10627 {"ipv4", RTE_ETH_FLOW_IPV4},
10628 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10629 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10630 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10631 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10632 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10633 {"ipv6", RTE_ETH_FLOW_IPV6},
10634 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10635 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10636 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10637 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10638 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10639 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10642 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10643 if (!strcmp(flowtype_str[i].str, string))
10644 return flowtype_str[i].type;
10647 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10648 return (uint16_t)atoi(string);
10650 return RTE_ETH_FLOW_UNKNOWN;
10653 static enum rte_eth_fdir_tunnel_type
10654 str2fdir_tunneltype(char *string)
10658 static const struct {
10660 enum rte_eth_fdir_tunnel_type type;
10661 } tunneltype_str[] = {
10662 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10663 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10666 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10667 if (!strcmp(tunneltype_str[i].str, string))
10668 return tunneltype_str[i].type;
10670 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10673 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10675 if ((ip_addr).family == AF_INET) \
10676 (ip) = (ip_addr).addr.ipv4.s_addr; \
10678 printf("invalid parameter.\n"); \
10683 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10685 if ((ip_addr).family == AF_INET6) \
10686 rte_memcpy(&(ip), \
10687 &((ip_addr).addr.ipv6), \
10688 sizeof(struct in6_addr)); \
10690 printf("invalid parameter.\n"); \
10696 cmd_flow_director_filter_parsed(void *parsed_result,
10697 __attribute__((unused)) struct cmdline *cl,
10698 __attribute__((unused)) void *data)
10700 struct cmd_flow_director_result *res = parsed_result;
10701 struct rte_eth_fdir_filter entry;
10702 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10704 unsigned long vf_id;
10707 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10709 printf("flow director is not supported on port %u.\n",
10713 memset(flexbytes, 0, sizeof(flexbytes));
10714 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10716 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10717 if (strcmp(res->mode_value, "MAC-VLAN")) {
10718 printf("Please set mode to MAC-VLAN.\n");
10721 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10722 if (strcmp(res->mode_value, "Tunnel")) {
10723 printf("Please set mode to Tunnel.\n");
10727 if (!strcmp(res->mode_value, "raw")) {
10728 #ifdef RTE_LIBRTE_I40E_PMD
10729 struct rte_pmd_i40e_flow_type_mapping
10730 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10731 struct rte_pmd_i40e_pkt_template_conf conf;
10732 uint16_t flow_type = str2flowtype(res->flow_type);
10733 uint16_t i, port = res->port_id;
10736 memset(&conf, 0, sizeof(conf));
10738 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10739 printf("Invalid flow type specified.\n");
10742 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10746 if (mapping[flow_type].pctype == 0ULL) {
10747 printf("Invalid flow type specified.\n");
10750 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10751 if (mapping[flow_type].pctype & (1ULL << i)) {
10752 conf.input.pctype = i;
10757 conf.input.packet = open_file(res->filepath,
10758 &conf.input.length);
10759 if (!conf.input.packet)
10761 if (!strcmp(res->drop, "drop"))
10762 conf.action.behavior =
10763 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10765 conf.action.behavior =
10766 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10767 conf.action.report_status =
10768 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10769 conf.action.rx_queue = res->queue_id;
10770 conf.soft_id = res->fd_id_value;
10771 add = strcmp(res->ops, "del") ? 1 : 0;
10772 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10776 printf("flow director config error: (%s)\n",
10778 close_file(conf.input.packet);
10781 } else if (strcmp(res->mode_value, "IP")) {
10782 printf("Please set mode to IP or raw.\n");
10785 entry.input.flow_type = str2flowtype(res->flow_type);
10788 ret = parse_flexbytes(res->flexbytes_value,
10790 RTE_ETH_FDIR_MAX_FLEXLEN);
10792 printf("error: Cannot parse flexbytes input.\n");
10796 switch (entry.input.flow_type) {
10797 case RTE_ETH_FLOW_FRAG_IPV4:
10798 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10799 entry.input.flow.ip4_flow.proto = res->proto_value;
10801 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10802 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10803 IPV4_ADDR_TO_UINT(res->ip_dst,
10804 entry.input.flow.ip4_flow.dst_ip);
10805 IPV4_ADDR_TO_UINT(res->ip_src,
10806 entry.input.flow.ip4_flow.src_ip);
10807 entry.input.flow.ip4_flow.tos = res->tos_value;
10808 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10809 /* need convert to big endian. */
10810 entry.input.flow.udp4_flow.dst_port =
10811 rte_cpu_to_be_16(res->port_dst);
10812 entry.input.flow.udp4_flow.src_port =
10813 rte_cpu_to_be_16(res->port_src);
10815 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10816 IPV4_ADDR_TO_UINT(res->ip_dst,
10817 entry.input.flow.sctp4_flow.ip.dst_ip);
10818 IPV4_ADDR_TO_UINT(res->ip_src,
10819 entry.input.flow.sctp4_flow.ip.src_ip);
10820 entry.input.flow.ip4_flow.tos = res->tos_value;
10821 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10822 /* need convert to big endian. */
10823 entry.input.flow.sctp4_flow.dst_port =
10824 rte_cpu_to_be_16(res->port_dst);
10825 entry.input.flow.sctp4_flow.src_port =
10826 rte_cpu_to_be_16(res->port_src);
10827 entry.input.flow.sctp4_flow.verify_tag =
10828 rte_cpu_to_be_32(res->verify_tag_value);
10830 case RTE_ETH_FLOW_FRAG_IPV6:
10831 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10832 entry.input.flow.ipv6_flow.proto = res->proto_value;
10834 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10835 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10836 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10837 entry.input.flow.ipv6_flow.dst_ip);
10838 IPV6_ADDR_TO_ARRAY(res->ip_src,
10839 entry.input.flow.ipv6_flow.src_ip);
10840 entry.input.flow.ipv6_flow.tc = res->tos_value;
10841 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10842 /* need convert to big endian. */
10843 entry.input.flow.udp6_flow.dst_port =
10844 rte_cpu_to_be_16(res->port_dst);
10845 entry.input.flow.udp6_flow.src_port =
10846 rte_cpu_to_be_16(res->port_src);
10848 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10849 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10850 entry.input.flow.sctp6_flow.ip.dst_ip);
10851 IPV6_ADDR_TO_ARRAY(res->ip_src,
10852 entry.input.flow.sctp6_flow.ip.src_ip);
10853 entry.input.flow.ipv6_flow.tc = res->tos_value;
10854 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10855 /* need convert to big endian. */
10856 entry.input.flow.sctp6_flow.dst_port =
10857 rte_cpu_to_be_16(res->port_dst);
10858 entry.input.flow.sctp6_flow.src_port =
10859 rte_cpu_to_be_16(res->port_src);
10860 entry.input.flow.sctp6_flow.verify_tag =
10861 rte_cpu_to_be_32(res->verify_tag_value);
10863 case RTE_ETH_FLOW_L2_PAYLOAD:
10864 entry.input.flow.l2_flow.ether_type =
10865 rte_cpu_to_be_16(res->ether_type);
10871 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10872 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10874 sizeof(struct ether_addr));
10876 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10877 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10879 sizeof(struct ether_addr));
10880 entry.input.flow.tunnel_flow.tunnel_type =
10881 str2fdir_tunneltype(res->tunnel_type);
10882 entry.input.flow.tunnel_flow.tunnel_id =
10883 rte_cpu_to_be_32(res->tunnel_id_value);
10886 rte_memcpy(entry.input.flow_ext.flexbytes,
10888 RTE_ETH_FDIR_MAX_FLEXLEN);
10890 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10892 entry.action.flex_off = 0; /*use 0 by default */
10893 if (!strcmp(res->drop, "drop"))
10894 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10896 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10898 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10899 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10900 if (!strcmp(res->pf_vf, "pf"))
10901 entry.input.flow_ext.is_vf = 0;
10902 else if (!strncmp(res->pf_vf, "vf", 2)) {
10903 struct rte_eth_dev_info dev_info;
10905 memset(&dev_info, 0, sizeof(dev_info));
10906 rte_eth_dev_info_get(res->port_id, &dev_info);
10908 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10909 if (errno != 0 || *end != '\0' ||
10910 vf_id >= dev_info.max_vfs) {
10911 printf("invalid parameter %s.\n", res->pf_vf);
10914 entry.input.flow_ext.is_vf = 1;
10915 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10917 printf("invalid parameter %s.\n", res->pf_vf);
10922 /* set to report FD ID by default */
10923 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10924 entry.action.rx_queue = res->queue_id;
10925 entry.soft_id = res->fd_id_value;
10926 if (!strcmp(res->ops, "add"))
10927 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10928 RTE_ETH_FILTER_ADD, &entry);
10929 else if (!strcmp(res->ops, "del"))
10930 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10931 RTE_ETH_FILTER_DELETE, &entry);
10933 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10934 RTE_ETH_FILTER_UPDATE, &entry);
10936 printf("flow director programming error: (%s)\n",
10940 cmdline_parse_token_string_t cmd_flow_director_filter =
10941 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10942 flow_director_filter, "flow_director_filter");
10943 cmdline_parse_token_num_t cmd_flow_director_port_id =
10944 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10946 cmdline_parse_token_string_t cmd_flow_director_ops =
10947 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10948 ops, "add#del#update");
10949 cmdline_parse_token_string_t cmd_flow_director_flow =
10950 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10952 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10953 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10955 cmdline_parse_token_string_t cmd_flow_director_ether =
10956 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10958 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10959 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10960 ether_type, UINT16);
10961 cmdline_parse_token_string_t cmd_flow_director_src =
10962 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10964 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10965 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10967 cmdline_parse_token_num_t cmd_flow_director_port_src =
10968 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10970 cmdline_parse_token_string_t cmd_flow_director_dst =
10971 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10973 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10974 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10976 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10977 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10979 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10980 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10981 verify_tag, "verify_tag");
10982 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10983 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10984 verify_tag_value, UINT32);
10985 cmdline_parse_token_string_t cmd_flow_director_tos =
10986 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10988 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10989 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10991 cmdline_parse_token_string_t cmd_flow_director_proto =
10992 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10994 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10995 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10996 proto_value, UINT8);
10997 cmdline_parse_token_string_t cmd_flow_director_ttl =
10998 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11000 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11001 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11003 cmdline_parse_token_string_t cmd_flow_director_vlan =
11004 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11006 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11007 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11008 vlan_value, UINT16);
11009 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11010 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11011 flexbytes, "flexbytes");
11012 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11013 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11014 flexbytes_value, NULL);
11015 cmdline_parse_token_string_t cmd_flow_director_drop =
11016 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11018 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11019 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11021 cmdline_parse_token_string_t cmd_flow_director_queue =
11022 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11024 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11025 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11027 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11028 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11030 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11031 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11032 fd_id_value, UINT32);
11034 cmdline_parse_token_string_t cmd_flow_director_mode =
11035 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11037 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11038 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11040 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11041 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11042 mode_value, "MAC-VLAN");
11043 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11044 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11045 mode_value, "Tunnel");
11046 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11047 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11048 mode_value, "raw");
11049 cmdline_parse_token_string_t cmd_flow_director_mac =
11050 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11052 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11053 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11055 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11056 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11058 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11059 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11060 tunnel_type, "NVGRE#VxLAN");
11061 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11062 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11063 tunnel_id, "tunnel-id");
11064 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11065 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11066 tunnel_id_value, UINT32);
11067 cmdline_parse_token_string_t cmd_flow_director_packet =
11068 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11070 cmdline_parse_token_string_t cmd_flow_director_filepath =
11071 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11074 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11075 .f = cmd_flow_director_filter_parsed,
11077 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11078 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11079 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11080 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11081 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11082 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11083 "fd_id <fd_id_value>: "
11084 "Add or delete an ip flow director entry on NIC",
11086 (void *)&cmd_flow_director_filter,
11087 (void *)&cmd_flow_director_port_id,
11088 (void *)&cmd_flow_director_mode,
11089 (void *)&cmd_flow_director_mode_ip,
11090 (void *)&cmd_flow_director_ops,
11091 (void *)&cmd_flow_director_flow,
11092 (void *)&cmd_flow_director_flow_type,
11093 (void *)&cmd_flow_director_src,
11094 (void *)&cmd_flow_director_ip_src,
11095 (void *)&cmd_flow_director_dst,
11096 (void *)&cmd_flow_director_ip_dst,
11097 (void *)&cmd_flow_director_tos,
11098 (void *)&cmd_flow_director_tos_value,
11099 (void *)&cmd_flow_director_proto,
11100 (void *)&cmd_flow_director_proto_value,
11101 (void *)&cmd_flow_director_ttl,
11102 (void *)&cmd_flow_director_ttl_value,
11103 (void *)&cmd_flow_director_vlan,
11104 (void *)&cmd_flow_director_vlan_value,
11105 (void *)&cmd_flow_director_flexbytes,
11106 (void *)&cmd_flow_director_flexbytes_value,
11107 (void *)&cmd_flow_director_drop,
11108 (void *)&cmd_flow_director_pf_vf,
11109 (void *)&cmd_flow_director_queue,
11110 (void *)&cmd_flow_director_queue_id,
11111 (void *)&cmd_flow_director_fd_id,
11112 (void *)&cmd_flow_director_fd_id_value,
11117 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11118 .f = cmd_flow_director_filter_parsed,
11120 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11121 "director entry on NIC",
11123 (void *)&cmd_flow_director_filter,
11124 (void *)&cmd_flow_director_port_id,
11125 (void *)&cmd_flow_director_mode,
11126 (void *)&cmd_flow_director_mode_ip,
11127 (void *)&cmd_flow_director_ops,
11128 (void *)&cmd_flow_director_flow,
11129 (void *)&cmd_flow_director_flow_type,
11130 (void *)&cmd_flow_director_src,
11131 (void *)&cmd_flow_director_ip_src,
11132 (void *)&cmd_flow_director_port_src,
11133 (void *)&cmd_flow_director_dst,
11134 (void *)&cmd_flow_director_ip_dst,
11135 (void *)&cmd_flow_director_port_dst,
11136 (void *)&cmd_flow_director_tos,
11137 (void *)&cmd_flow_director_tos_value,
11138 (void *)&cmd_flow_director_ttl,
11139 (void *)&cmd_flow_director_ttl_value,
11140 (void *)&cmd_flow_director_vlan,
11141 (void *)&cmd_flow_director_vlan_value,
11142 (void *)&cmd_flow_director_flexbytes,
11143 (void *)&cmd_flow_director_flexbytes_value,
11144 (void *)&cmd_flow_director_drop,
11145 (void *)&cmd_flow_director_pf_vf,
11146 (void *)&cmd_flow_director_queue,
11147 (void *)&cmd_flow_director_queue_id,
11148 (void *)&cmd_flow_director_fd_id,
11149 (void *)&cmd_flow_director_fd_id_value,
11154 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11155 .f = cmd_flow_director_filter_parsed,
11157 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11158 "director entry on NIC",
11160 (void *)&cmd_flow_director_filter,
11161 (void *)&cmd_flow_director_port_id,
11162 (void *)&cmd_flow_director_mode,
11163 (void *)&cmd_flow_director_mode_ip,
11164 (void *)&cmd_flow_director_ops,
11165 (void *)&cmd_flow_director_flow,
11166 (void *)&cmd_flow_director_flow_type,
11167 (void *)&cmd_flow_director_src,
11168 (void *)&cmd_flow_director_ip_src,
11169 (void *)&cmd_flow_director_port_src,
11170 (void *)&cmd_flow_director_dst,
11171 (void *)&cmd_flow_director_ip_dst,
11172 (void *)&cmd_flow_director_port_dst,
11173 (void *)&cmd_flow_director_verify_tag,
11174 (void *)&cmd_flow_director_verify_tag_value,
11175 (void *)&cmd_flow_director_tos,
11176 (void *)&cmd_flow_director_tos_value,
11177 (void *)&cmd_flow_director_ttl,
11178 (void *)&cmd_flow_director_ttl_value,
11179 (void *)&cmd_flow_director_vlan,
11180 (void *)&cmd_flow_director_vlan_value,
11181 (void *)&cmd_flow_director_flexbytes,
11182 (void *)&cmd_flow_director_flexbytes_value,
11183 (void *)&cmd_flow_director_drop,
11184 (void *)&cmd_flow_director_pf_vf,
11185 (void *)&cmd_flow_director_queue,
11186 (void *)&cmd_flow_director_queue_id,
11187 (void *)&cmd_flow_director_fd_id,
11188 (void *)&cmd_flow_director_fd_id_value,
11193 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11194 .f = cmd_flow_director_filter_parsed,
11196 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11197 "director entry on NIC",
11199 (void *)&cmd_flow_director_filter,
11200 (void *)&cmd_flow_director_port_id,
11201 (void *)&cmd_flow_director_mode,
11202 (void *)&cmd_flow_director_mode_ip,
11203 (void *)&cmd_flow_director_ops,
11204 (void *)&cmd_flow_director_flow,
11205 (void *)&cmd_flow_director_flow_type,
11206 (void *)&cmd_flow_director_ether,
11207 (void *)&cmd_flow_director_ether_type,
11208 (void *)&cmd_flow_director_flexbytes,
11209 (void *)&cmd_flow_director_flexbytes_value,
11210 (void *)&cmd_flow_director_drop,
11211 (void *)&cmd_flow_director_pf_vf,
11212 (void *)&cmd_flow_director_queue,
11213 (void *)&cmd_flow_director_queue_id,
11214 (void *)&cmd_flow_director_fd_id,
11215 (void *)&cmd_flow_director_fd_id_value,
11220 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11221 .f = cmd_flow_director_filter_parsed,
11223 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11224 "director entry on NIC",
11226 (void *)&cmd_flow_director_filter,
11227 (void *)&cmd_flow_director_port_id,
11228 (void *)&cmd_flow_director_mode,
11229 (void *)&cmd_flow_director_mode_mac_vlan,
11230 (void *)&cmd_flow_director_ops,
11231 (void *)&cmd_flow_director_mac,
11232 (void *)&cmd_flow_director_mac_addr,
11233 (void *)&cmd_flow_director_vlan,
11234 (void *)&cmd_flow_director_vlan_value,
11235 (void *)&cmd_flow_director_flexbytes,
11236 (void *)&cmd_flow_director_flexbytes_value,
11237 (void *)&cmd_flow_director_drop,
11238 (void *)&cmd_flow_director_queue,
11239 (void *)&cmd_flow_director_queue_id,
11240 (void *)&cmd_flow_director_fd_id,
11241 (void *)&cmd_flow_director_fd_id_value,
11246 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11247 .f = cmd_flow_director_filter_parsed,
11249 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11250 "director entry on NIC",
11252 (void *)&cmd_flow_director_filter,
11253 (void *)&cmd_flow_director_port_id,
11254 (void *)&cmd_flow_director_mode,
11255 (void *)&cmd_flow_director_mode_tunnel,
11256 (void *)&cmd_flow_director_ops,
11257 (void *)&cmd_flow_director_mac,
11258 (void *)&cmd_flow_director_mac_addr,
11259 (void *)&cmd_flow_director_vlan,
11260 (void *)&cmd_flow_director_vlan_value,
11261 (void *)&cmd_flow_director_tunnel,
11262 (void *)&cmd_flow_director_tunnel_type,
11263 (void *)&cmd_flow_director_tunnel_id,
11264 (void *)&cmd_flow_director_tunnel_id_value,
11265 (void *)&cmd_flow_director_flexbytes,
11266 (void *)&cmd_flow_director_flexbytes_value,
11267 (void *)&cmd_flow_director_drop,
11268 (void *)&cmd_flow_director_queue,
11269 (void *)&cmd_flow_director_queue_id,
11270 (void *)&cmd_flow_director_fd_id,
11271 (void *)&cmd_flow_director_fd_id_value,
11276 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11277 .f = cmd_flow_director_filter_parsed,
11279 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11280 "director entry on NIC",
11282 (void *)&cmd_flow_director_filter,
11283 (void *)&cmd_flow_director_port_id,
11284 (void *)&cmd_flow_director_mode,
11285 (void *)&cmd_flow_director_mode_raw,
11286 (void *)&cmd_flow_director_ops,
11287 (void *)&cmd_flow_director_flow,
11288 (void *)&cmd_flow_director_flow_type,
11289 (void *)&cmd_flow_director_drop,
11290 (void *)&cmd_flow_director_queue,
11291 (void *)&cmd_flow_director_queue_id,
11292 (void *)&cmd_flow_director_fd_id,
11293 (void *)&cmd_flow_director_fd_id_value,
11294 (void *)&cmd_flow_director_packet,
11295 (void *)&cmd_flow_director_filepath,
11300 struct cmd_flush_flow_director_result {
11301 cmdline_fixed_string_t flush_flow_director;
11305 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11306 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11307 flush_flow_director, "flush_flow_director");
11308 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11309 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11313 cmd_flush_flow_director_parsed(void *parsed_result,
11314 __attribute__((unused)) struct cmdline *cl,
11315 __attribute__((unused)) void *data)
11317 struct cmd_flow_director_result *res = parsed_result;
11320 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11322 printf("flow director is not supported on port %u.\n",
11327 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11328 RTE_ETH_FILTER_FLUSH, NULL);
11330 printf("flow director table flushing error: (%s)\n",
11334 cmdline_parse_inst_t cmd_flush_flow_director = {
11335 .f = cmd_flush_flow_director_parsed,
11337 .help_str = "flush_flow_director <port_id>: "
11338 "Flush all flow director entries of a device on NIC",
11340 (void *)&cmd_flush_flow_director_flush,
11341 (void *)&cmd_flush_flow_director_port_id,
11346 /* *** deal with flow director mask *** */
11347 struct cmd_flow_director_mask_result {
11348 cmdline_fixed_string_t flow_director_mask;
11350 cmdline_fixed_string_t mode;
11351 cmdline_fixed_string_t mode_value;
11352 cmdline_fixed_string_t vlan;
11353 uint16_t vlan_mask;
11354 cmdline_fixed_string_t src_mask;
11355 cmdline_ipaddr_t ipv4_src;
11356 cmdline_ipaddr_t ipv6_src;
11358 cmdline_fixed_string_t dst_mask;
11359 cmdline_ipaddr_t ipv4_dst;
11360 cmdline_ipaddr_t ipv6_dst;
11362 cmdline_fixed_string_t mac;
11363 uint8_t mac_addr_byte_mask;
11364 cmdline_fixed_string_t tunnel_id;
11365 uint32_t tunnel_id_mask;
11366 cmdline_fixed_string_t tunnel_type;
11367 uint8_t tunnel_type_mask;
11371 cmd_flow_director_mask_parsed(void *parsed_result,
11372 __attribute__((unused)) struct cmdline *cl,
11373 __attribute__((unused)) void *data)
11375 struct cmd_flow_director_mask_result *res = parsed_result;
11376 struct rte_eth_fdir_masks *mask;
11377 struct rte_port *port;
11379 port = &ports[res->port_id];
11380 /** Check if the port is not started **/
11381 if (port->port_status != RTE_PORT_STOPPED) {
11382 printf("Please stop port %d first\n", res->port_id);
11386 mask = &port->dev_conf.fdir_conf.mask;
11388 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11389 if (strcmp(res->mode_value, "MAC-VLAN")) {
11390 printf("Please set mode to MAC-VLAN.\n");
11394 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11395 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11396 if (strcmp(res->mode_value, "Tunnel")) {
11397 printf("Please set mode to Tunnel.\n");
11401 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11402 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11403 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11404 mask->tunnel_type_mask = res->tunnel_type_mask;
11406 if (strcmp(res->mode_value, "IP")) {
11407 printf("Please set mode to IP.\n");
11411 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11412 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11413 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11414 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11415 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11416 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11417 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11420 cmd_reconfig_device_queue(res->port_id, 1, 1);
11423 cmdline_parse_token_string_t cmd_flow_director_mask =
11424 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11425 flow_director_mask, "flow_director_mask");
11426 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11427 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11429 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11430 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11432 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11433 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11434 vlan_mask, UINT16);
11435 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11436 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11437 src_mask, "src_mask");
11438 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11439 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11441 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11442 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11444 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11445 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11447 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11448 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11449 dst_mask, "dst_mask");
11450 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11451 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11453 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11454 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11456 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11457 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11460 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11461 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11463 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11464 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11466 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11467 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11468 mode_value, "MAC-VLAN");
11469 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11470 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11471 mode_value, "Tunnel");
11472 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11473 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11475 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11476 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11477 mac_addr_byte_mask, UINT8);
11478 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11479 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11480 tunnel_type, "tunnel-type");
11481 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11482 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11483 tunnel_type_mask, UINT8);
11484 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11485 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11486 tunnel_id, "tunnel-id");
11487 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11488 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11489 tunnel_id_mask, UINT32);
11491 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11492 .f = cmd_flow_director_mask_parsed,
11494 .help_str = "flow_director_mask ... : "
11495 "Set IP mode flow director's mask on NIC",
11497 (void *)&cmd_flow_director_mask,
11498 (void *)&cmd_flow_director_mask_port_id,
11499 (void *)&cmd_flow_director_mask_mode,
11500 (void *)&cmd_flow_director_mask_mode_ip,
11501 (void *)&cmd_flow_director_mask_vlan,
11502 (void *)&cmd_flow_director_mask_vlan_value,
11503 (void *)&cmd_flow_director_mask_src,
11504 (void *)&cmd_flow_director_mask_ipv4_src,
11505 (void *)&cmd_flow_director_mask_ipv6_src,
11506 (void *)&cmd_flow_director_mask_port_src,
11507 (void *)&cmd_flow_director_mask_dst,
11508 (void *)&cmd_flow_director_mask_ipv4_dst,
11509 (void *)&cmd_flow_director_mask_ipv6_dst,
11510 (void *)&cmd_flow_director_mask_port_dst,
11515 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11516 .f = cmd_flow_director_mask_parsed,
11518 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11519 "flow director's mask on NIC",
11521 (void *)&cmd_flow_director_mask,
11522 (void *)&cmd_flow_director_mask_port_id,
11523 (void *)&cmd_flow_director_mask_mode,
11524 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11525 (void *)&cmd_flow_director_mask_vlan,
11526 (void *)&cmd_flow_director_mask_vlan_value,
11531 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11532 .f = cmd_flow_director_mask_parsed,
11534 .help_str = "flow_director_mask ... : Set tunnel mode "
11535 "flow director's mask on NIC",
11537 (void *)&cmd_flow_director_mask,
11538 (void *)&cmd_flow_director_mask_port_id,
11539 (void *)&cmd_flow_director_mask_mode,
11540 (void *)&cmd_flow_director_mask_mode_tunnel,
11541 (void *)&cmd_flow_director_mask_vlan,
11542 (void *)&cmd_flow_director_mask_vlan_value,
11543 (void *)&cmd_flow_director_mask_mac,
11544 (void *)&cmd_flow_director_mask_mac_value,
11545 (void *)&cmd_flow_director_mask_tunnel_type,
11546 (void *)&cmd_flow_director_mask_tunnel_type_value,
11547 (void *)&cmd_flow_director_mask_tunnel_id,
11548 (void *)&cmd_flow_director_mask_tunnel_id_value,
11553 /* *** deal with flow director mask on flexible payload *** */
11554 struct cmd_flow_director_flex_mask_result {
11555 cmdline_fixed_string_t flow_director_flexmask;
11557 cmdline_fixed_string_t flow;
11558 cmdline_fixed_string_t flow_type;
11559 cmdline_fixed_string_t mask;
11563 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11564 __attribute__((unused)) struct cmdline *cl,
11565 __attribute__((unused)) void *data)
11567 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11568 struct rte_eth_fdir_info fdir_info;
11569 struct rte_eth_fdir_flex_mask flex_mask;
11570 struct rte_port *port;
11571 uint64_t flow_type_mask;
11575 port = &ports[res->port_id];
11576 /** Check if the port is not started **/
11577 if (port->port_status != RTE_PORT_STOPPED) {
11578 printf("Please stop port %d first\n", res->port_id);
11582 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11583 ret = parse_flexbytes(res->mask,
11585 RTE_ETH_FDIR_MAX_FLEXLEN);
11587 printf("error: Cannot parse mask input.\n");
11591 memset(&fdir_info, 0, sizeof(fdir_info));
11592 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11593 RTE_ETH_FILTER_INFO, &fdir_info);
11595 printf("Cannot get FDir filter info\n");
11599 if (!strcmp(res->flow_type, "none")) {
11600 /* means don't specify the flow type */
11601 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11602 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11603 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11604 0, sizeof(struct rte_eth_fdir_flex_mask));
11605 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11606 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11608 sizeof(struct rte_eth_fdir_flex_mask));
11609 cmd_reconfig_device_queue(res->port_id, 1, 1);
11612 flow_type_mask = fdir_info.flow_types_mask[0];
11613 if (!strcmp(res->flow_type, "all")) {
11614 if (!flow_type_mask) {
11615 printf("No flow type supported\n");
11618 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11619 if (flow_type_mask & (1ULL << i)) {
11620 flex_mask.flow_type = i;
11621 fdir_set_flex_mask(res->port_id, &flex_mask);
11624 cmd_reconfig_device_queue(res->port_id, 1, 1);
11627 flex_mask.flow_type = str2flowtype(res->flow_type);
11628 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11629 printf("Flow type %s not supported on port %d\n",
11630 res->flow_type, res->port_id);
11633 fdir_set_flex_mask(res->port_id, &flex_mask);
11634 cmd_reconfig_device_queue(res->port_id, 1, 1);
11637 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11638 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11639 flow_director_flexmask,
11640 "flow_director_flex_mask");
11641 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11642 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11644 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11645 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11647 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11648 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11649 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11650 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11651 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11652 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11655 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11656 .f = cmd_flow_director_flex_mask_parsed,
11658 .help_str = "flow_director_flex_mask ... : "
11659 "Set flow director's flex mask on NIC",
11661 (void *)&cmd_flow_director_flexmask,
11662 (void *)&cmd_flow_director_flexmask_port_id,
11663 (void *)&cmd_flow_director_flexmask_flow,
11664 (void *)&cmd_flow_director_flexmask_flow_type,
11665 (void *)&cmd_flow_director_flexmask_mask,
11670 /* *** deal with flow director flexible payload configuration *** */
11671 struct cmd_flow_director_flexpayload_result {
11672 cmdline_fixed_string_t flow_director_flexpayload;
11674 cmdline_fixed_string_t payload_layer;
11675 cmdline_fixed_string_t payload_cfg;
11679 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11682 const char *p, *p0 = q_arg;
11684 unsigned long int_fld;
11685 char *str_fld[max_num];
11690 p = strchr(p0, '(');
11694 p0 = strchr(p, ')');
11699 if (size >= sizeof(s))
11702 snprintf(s, sizeof(s), "%.*s", size, p);
11703 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11704 if (ret < 0 || ret > max_num)
11706 for (i = 0; i < ret; i++) {
11708 int_fld = strtoul(str_fld[i], &end, 0);
11709 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11711 offsets[i] = (uint16_t)int_fld;
11717 cmd_flow_director_flxpld_parsed(void *parsed_result,
11718 __attribute__((unused)) struct cmdline *cl,
11719 __attribute__((unused)) void *data)
11721 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11722 struct rte_eth_flex_payload_cfg flex_cfg;
11723 struct rte_port *port;
11726 port = &ports[res->port_id];
11727 /** Check if the port is not started **/
11728 if (port->port_status != RTE_PORT_STOPPED) {
11729 printf("Please stop port %d first\n", res->port_id);
11733 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11735 if (!strcmp(res->payload_layer, "raw"))
11736 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11737 else if (!strcmp(res->payload_layer, "l2"))
11738 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11739 else if (!strcmp(res->payload_layer, "l3"))
11740 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11741 else if (!strcmp(res->payload_layer, "l4"))
11742 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11744 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11745 RTE_ETH_FDIR_MAX_FLEXLEN);
11747 printf("error: Cannot parse flex payload input.\n");
11751 fdir_set_flex_payload(res->port_id, &flex_cfg);
11752 cmd_reconfig_device_queue(res->port_id, 1, 1);
11755 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11756 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11757 flow_director_flexpayload,
11758 "flow_director_flex_payload");
11759 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11760 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11762 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11763 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11764 payload_layer, "raw#l2#l3#l4");
11765 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11766 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11767 payload_cfg, NULL);
11769 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11770 .f = cmd_flow_director_flxpld_parsed,
11772 .help_str = "flow_director_flexpayload ... : "
11773 "Set flow director's flex payload on NIC",
11775 (void *)&cmd_flow_director_flexpayload,
11776 (void *)&cmd_flow_director_flexpayload_port_id,
11777 (void *)&cmd_flow_director_flexpayload_payload_layer,
11778 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11783 /* Generic flow interface command. */
11784 extern cmdline_parse_inst_t cmd_flow;
11786 /* *** Classification Filters Control *** */
11787 /* *** Get symmetric hash enable per port *** */
11788 struct cmd_get_sym_hash_ena_per_port_result {
11789 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11794 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11795 __rte_unused struct cmdline *cl,
11796 __rte_unused void *data)
11798 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11799 struct rte_eth_hash_filter_info info;
11802 if (rte_eth_dev_filter_supported(res->port_id,
11803 RTE_ETH_FILTER_HASH) < 0) {
11804 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11809 memset(&info, 0, sizeof(info));
11810 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11811 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11812 RTE_ETH_FILTER_GET, &info);
11815 printf("Cannot get symmetric hash enable per port "
11816 "on port %u\n", res->port_id);
11820 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11821 "enabled" : "disabled", res->port_id);
11824 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11825 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11826 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11827 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11828 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11831 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11832 .f = cmd_get_sym_hash_per_port_parsed,
11834 .help_str = "get_sym_hash_ena_per_port <port_id>",
11836 (void *)&cmd_get_sym_hash_ena_per_port_all,
11837 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11842 /* *** Set symmetric hash enable per port *** */
11843 struct cmd_set_sym_hash_ena_per_port_result {
11844 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11845 cmdline_fixed_string_t enable;
11850 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11851 __rte_unused struct cmdline *cl,
11852 __rte_unused void *data)
11854 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11855 struct rte_eth_hash_filter_info info;
11858 if (rte_eth_dev_filter_supported(res->port_id,
11859 RTE_ETH_FILTER_HASH) < 0) {
11860 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11865 memset(&info, 0, sizeof(info));
11866 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11867 if (!strcmp(res->enable, "enable"))
11868 info.info.enable = 1;
11869 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11870 RTE_ETH_FILTER_SET, &info);
11872 printf("Cannot set symmetric hash enable per port on "
11873 "port %u\n", res->port_id);
11876 printf("Symmetric hash has been set to %s on port %u\n",
11877 res->enable, res->port_id);
11880 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11881 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11882 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11883 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11884 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11886 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11887 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11888 enable, "enable#disable");
11890 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11891 .f = cmd_set_sym_hash_per_port_parsed,
11893 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11895 (void *)&cmd_set_sym_hash_ena_per_port_all,
11896 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11897 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11902 /* Get global config of hash function */
11903 struct cmd_get_hash_global_config_result {
11904 cmdline_fixed_string_t get_hash_global_config;
11909 flowtype_to_str(uint16_t ftype)
11915 } ftype_table[] = {
11916 {"ipv4", RTE_ETH_FLOW_IPV4},
11917 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11918 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11919 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11920 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11921 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11922 {"ipv6", RTE_ETH_FLOW_IPV6},
11923 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11924 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11925 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11926 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11927 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11928 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11929 {"port", RTE_ETH_FLOW_PORT},
11930 {"vxlan", RTE_ETH_FLOW_VXLAN},
11931 {"geneve", RTE_ETH_FLOW_GENEVE},
11932 {"nvgre", RTE_ETH_FLOW_NVGRE},
11935 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11936 if (ftype_table[i].ftype == ftype)
11937 return ftype_table[i].str;
11944 cmd_get_hash_global_config_parsed(void *parsed_result,
11945 __rte_unused struct cmdline *cl,
11946 __rte_unused void *data)
11948 struct cmd_get_hash_global_config_result *res = parsed_result;
11949 struct rte_eth_hash_filter_info info;
11950 uint32_t idx, offset;
11955 if (rte_eth_dev_filter_supported(res->port_id,
11956 RTE_ETH_FILTER_HASH) < 0) {
11957 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11962 memset(&info, 0, sizeof(info));
11963 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11964 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11965 RTE_ETH_FILTER_GET, &info);
11967 printf("Cannot get hash global configurations by port %d\n",
11972 switch (info.info.global_conf.hash_func) {
11973 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11974 printf("Hash function is Toeplitz\n");
11976 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11977 printf("Hash function is Simple XOR\n");
11980 printf("Unknown hash function\n");
11984 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11985 idx = i / UINT64_BIT;
11986 offset = i % UINT64_BIT;
11987 if (!(info.info.global_conf.valid_bit_mask[idx] &
11990 str = flowtype_to_str(i);
11993 printf("Symmetric hash is %s globally for flow type %s "
11995 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11996 (1ULL << offset)) ? "enabled" : "disabled"), str,
12001 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12002 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12003 get_hash_global_config, "get_hash_global_config");
12004 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12005 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12008 cmdline_parse_inst_t cmd_get_hash_global_config = {
12009 .f = cmd_get_hash_global_config_parsed,
12011 .help_str = "get_hash_global_config <port_id>",
12013 (void *)&cmd_get_hash_global_config_all,
12014 (void *)&cmd_get_hash_global_config_port_id,
12019 /* Set global config of hash function */
12020 struct cmd_set_hash_global_config_result {
12021 cmdline_fixed_string_t set_hash_global_config;
12023 cmdline_fixed_string_t hash_func;
12024 cmdline_fixed_string_t flow_type;
12025 cmdline_fixed_string_t enable;
12029 cmd_set_hash_global_config_parsed(void *parsed_result,
12030 __rte_unused struct cmdline *cl,
12031 __rte_unused void *data)
12033 struct cmd_set_hash_global_config_result *res = parsed_result;
12034 struct rte_eth_hash_filter_info info;
12035 uint32_t ftype, idx, offset;
12038 if (rte_eth_dev_filter_supported(res->port_id,
12039 RTE_ETH_FILTER_HASH) < 0) {
12040 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12044 memset(&info, 0, sizeof(info));
12045 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12046 if (!strcmp(res->hash_func, "toeplitz"))
12047 info.info.global_conf.hash_func =
12048 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12049 else if (!strcmp(res->hash_func, "simple_xor"))
12050 info.info.global_conf.hash_func =
12051 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12052 else if (!strcmp(res->hash_func, "default"))
12053 info.info.global_conf.hash_func =
12054 RTE_ETH_HASH_FUNCTION_DEFAULT;
12056 ftype = str2flowtype(res->flow_type);
12057 idx = ftype / UINT64_BIT;
12058 offset = ftype % UINT64_BIT;
12059 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12060 if (!strcmp(res->enable, "enable"))
12061 info.info.global_conf.sym_hash_enable_mask[idx] |=
12063 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12064 RTE_ETH_FILTER_SET, &info);
12066 printf("Cannot set global hash configurations by port %d\n",
12069 printf("Global hash configurations have been set "
12070 "succcessfully by port %d\n", res->port_id);
12073 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12074 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12075 set_hash_global_config, "set_hash_global_config");
12076 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12077 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12079 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12080 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12081 hash_func, "toeplitz#simple_xor#default");
12082 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12083 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12085 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12086 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12087 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12088 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12089 enable, "enable#disable");
12091 cmdline_parse_inst_t cmd_set_hash_global_config = {
12092 .f = cmd_set_hash_global_config_parsed,
12094 .help_str = "set_hash_global_config <port_id> "
12095 "toeplitz|simple_xor|default "
12096 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12097 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12098 "l2_payload enable|disable",
12100 (void *)&cmd_set_hash_global_config_all,
12101 (void *)&cmd_set_hash_global_config_port_id,
12102 (void *)&cmd_set_hash_global_config_hash_func,
12103 (void *)&cmd_set_hash_global_config_flow_type,
12104 (void *)&cmd_set_hash_global_config_enable,
12109 /* Set hash input set */
12110 struct cmd_set_hash_input_set_result {
12111 cmdline_fixed_string_t set_hash_input_set;
12113 cmdline_fixed_string_t flow_type;
12114 cmdline_fixed_string_t inset_field;
12115 cmdline_fixed_string_t select;
12118 static enum rte_eth_input_set_field
12119 str2inset(char *string)
12123 static const struct {
12125 enum rte_eth_input_set_field inset;
12126 } inset_table[] = {
12127 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12128 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12129 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12130 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12131 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12132 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12133 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12134 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12135 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12136 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12137 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12138 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12139 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12140 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12141 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12142 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12143 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12144 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12145 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12146 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12147 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12148 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12149 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12150 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12151 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12152 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12153 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12154 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12155 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12156 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12157 {"none", RTE_ETH_INPUT_SET_NONE},
12160 for (i = 0; i < RTE_DIM(inset_table); i++) {
12161 if (!strcmp(string, inset_table[i].str))
12162 return inset_table[i].inset;
12165 return RTE_ETH_INPUT_SET_UNKNOWN;
12169 cmd_set_hash_input_set_parsed(void *parsed_result,
12170 __rte_unused struct cmdline *cl,
12171 __rte_unused void *data)
12173 struct cmd_set_hash_input_set_result *res = parsed_result;
12174 struct rte_eth_hash_filter_info info;
12176 memset(&info, 0, sizeof(info));
12177 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12178 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12179 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12180 info.info.input_set_conf.inset_size = 1;
12181 if (!strcmp(res->select, "select"))
12182 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12183 else if (!strcmp(res->select, "add"))
12184 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12185 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12186 RTE_ETH_FILTER_SET, &info);
12189 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12190 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12191 set_hash_input_set, "set_hash_input_set");
12192 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12193 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12195 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12196 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12198 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12199 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12201 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12202 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12203 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12204 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12205 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12207 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12208 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12209 select, "select#add");
12211 cmdline_parse_inst_t cmd_set_hash_input_set = {
12212 .f = cmd_set_hash_input_set_parsed,
12214 .help_str = "set_hash_input_set <port_id> "
12215 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12216 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12217 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12218 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12219 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12220 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12221 "fld-7th|fld-8th|none select|add",
12223 (void *)&cmd_set_hash_input_set_cmd,
12224 (void *)&cmd_set_hash_input_set_port_id,
12225 (void *)&cmd_set_hash_input_set_flow_type,
12226 (void *)&cmd_set_hash_input_set_field,
12227 (void *)&cmd_set_hash_input_set_select,
12232 /* Set flow director input set */
12233 struct cmd_set_fdir_input_set_result {
12234 cmdline_fixed_string_t set_fdir_input_set;
12236 cmdline_fixed_string_t flow_type;
12237 cmdline_fixed_string_t inset_field;
12238 cmdline_fixed_string_t select;
12242 cmd_set_fdir_input_set_parsed(void *parsed_result,
12243 __rte_unused struct cmdline *cl,
12244 __rte_unused void *data)
12246 struct cmd_set_fdir_input_set_result *res = parsed_result;
12247 struct rte_eth_fdir_filter_info info;
12249 memset(&info, 0, sizeof(info));
12250 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12251 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12252 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12253 info.info.input_set_conf.inset_size = 1;
12254 if (!strcmp(res->select, "select"))
12255 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12256 else if (!strcmp(res->select, "add"))
12257 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12258 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12259 RTE_ETH_FILTER_SET, &info);
12262 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12263 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12264 set_fdir_input_set, "set_fdir_input_set");
12265 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12266 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12268 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12269 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12271 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12272 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12273 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12274 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12276 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12277 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12278 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12279 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12280 "sctp-veri-tag#none");
12281 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12282 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12283 select, "select#add");
12285 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12286 .f = cmd_set_fdir_input_set_parsed,
12288 .help_str = "set_fdir_input_set <port_id> "
12289 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12290 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12291 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12292 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12293 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12294 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12295 "sctp-veri-tag|none select|add",
12297 (void *)&cmd_set_fdir_input_set_cmd,
12298 (void *)&cmd_set_fdir_input_set_port_id,
12299 (void *)&cmd_set_fdir_input_set_flow_type,
12300 (void *)&cmd_set_fdir_input_set_field,
12301 (void *)&cmd_set_fdir_input_set_select,
12306 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12307 struct cmd_mcast_addr_result {
12308 cmdline_fixed_string_t mcast_addr_cmd;
12309 cmdline_fixed_string_t what;
12311 struct ether_addr mc_addr;
12314 static void cmd_mcast_addr_parsed(void *parsed_result,
12315 __attribute__((unused)) struct cmdline *cl,
12316 __attribute__((unused)) void *data)
12318 struct cmd_mcast_addr_result *res = parsed_result;
12320 if (!is_multicast_ether_addr(&res->mc_addr)) {
12321 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12322 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12323 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12324 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12327 if (strcmp(res->what, "add") == 0)
12328 mcast_addr_add(res->port_num, &res->mc_addr);
12330 mcast_addr_remove(res->port_num, &res->mc_addr);
12333 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12334 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12335 mcast_addr_cmd, "mcast_addr");
12336 cmdline_parse_token_string_t cmd_mcast_addr_what =
12337 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12339 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12340 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12341 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12342 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12344 cmdline_parse_inst_t cmd_mcast_addr = {
12345 .f = cmd_mcast_addr_parsed,
12347 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12348 "Add/Remove multicast MAC address on port_id",
12350 (void *)&cmd_mcast_addr_cmd,
12351 (void *)&cmd_mcast_addr_what,
12352 (void *)&cmd_mcast_addr_portnum,
12353 (void *)&cmd_mcast_addr_addr,
12358 /* l2 tunnel config
12359 * only support E-tag now.
12362 /* Ether type config */
12363 struct cmd_config_l2_tunnel_eth_type_result {
12364 cmdline_fixed_string_t port;
12365 cmdline_fixed_string_t config;
12366 cmdline_fixed_string_t all;
12368 cmdline_fixed_string_t l2_tunnel;
12369 cmdline_fixed_string_t l2_tunnel_type;
12370 cmdline_fixed_string_t eth_type;
12371 uint16_t eth_type_val;
12374 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12375 TOKEN_STRING_INITIALIZER
12376 (struct cmd_config_l2_tunnel_eth_type_result,
12378 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12379 TOKEN_STRING_INITIALIZER
12380 (struct cmd_config_l2_tunnel_eth_type_result,
12382 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12383 TOKEN_STRING_INITIALIZER
12384 (struct cmd_config_l2_tunnel_eth_type_result,
12386 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12387 TOKEN_NUM_INITIALIZER
12388 (struct cmd_config_l2_tunnel_eth_type_result,
12390 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12391 TOKEN_STRING_INITIALIZER
12392 (struct cmd_config_l2_tunnel_eth_type_result,
12393 l2_tunnel, "l2-tunnel");
12394 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12395 TOKEN_STRING_INITIALIZER
12396 (struct cmd_config_l2_tunnel_eth_type_result,
12397 l2_tunnel_type, "E-tag");
12398 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12399 TOKEN_STRING_INITIALIZER
12400 (struct cmd_config_l2_tunnel_eth_type_result,
12401 eth_type, "ether-type");
12402 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12403 TOKEN_NUM_INITIALIZER
12404 (struct cmd_config_l2_tunnel_eth_type_result,
12405 eth_type_val, UINT16);
12407 static enum rte_eth_tunnel_type
12408 str2fdir_l2_tunnel_type(char *string)
12412 static const struct {
12414 enum rte_eth_tunnel_type type;
12415 } l2_tunnel_type_str[] = {
12416 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12419 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12420 if (!strcmp(l2_tunnel_type_str[i].str, string))
12421 return l2_tunnel_type_str[i].type;
12423 return RTE_TUNNEL_TYPE_NONE;
12426 /* ether type config for all ports */
12428 cmd_config_l2_tunnel_eth_type_all_parsed
12429 (void *parsed_result,
12430 __attribute__((unused)) struct cmdline *cl,
12431 __attribute__((unused)) void *data)
12433 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12434 struct rte_eth_l2_tunnel_conf entry;
12437 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12438 entry.ether_type = res->eth_type_val;
12440 RTE_ETH_FOREACH_DEV(pid) {
12441 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12445 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12446 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12448 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12450 (void *)&cmd_config_l2_tunnel_eth_type_port,
12451 (void *)&cmd_config_l2_tunnel_eth_type_config,
12452 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12453 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12454 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12455 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12456 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12461 /* ether type config for a specific port */
12463 cmd_config_l2_tunnel_eth_type_specific_parsed(
12464 void *parsed_result,
12465 __attribute__((unused)) struct cmdline *cl,
12466 __attribute__((unused)) void *data)
12468 struct cmd_config_l2_tunnel_eth_type_result *res =
12470 struct rte_eth_l2_tunnel_conf entry;
12472 if (port_id_is_invalid(res->id, ENABLED_WARN))
12475 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12476 entry.ether_type = res->eth_type_val;
12478 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12481 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12482 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12484 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12486 (void *)&cmd_config_l2_tunnel_eth_type_port,
12487 (void *)&cmd_config_l2_tunnel_eth_type_config,
12488 (void *)&cmd_config_l2_tunnel_eth_type_id,
12489 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12490 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12491 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12492 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12497 /* Enable/disable l2 tunnel */
12498 struct cmd_config_l2_tunnel_en_dis_result {
12499 cmdline_fixed_string_t port;
12500 cmdline_fixed_string_t config;
12501 cmdline_fixed_string_t all;
12503 cmdline_fixed_string_t l2_tunnel;
12504 cmdline_fixed_string_t l2_tunnel_type;
12505 cmdline_fixed_string_t en_dis;
12508 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12509 TOKEN_STRING_INITIALIZER
12510 (struct cmd_config_l2_tunnel_en_dis_result,
12512 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12513 TOKEN_STRING_INITIALIZER
12514 (struct cmd_config_l2_tunnel_en_dis_result,
12516 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12517 TOKEN_STRING_INITIALIZER
12518 (struct cmd_config_l2_tunnel_en_dis_result,
12520 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12521 TOKEN_NUM_INITIALIZER
12522 (struct cmd_config_l2_tunnel_en_dis_result,
12524 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12525 TOKEN_STRING_INITIALIZER
12526 (struct cmd_config_l2_tunnel_en_dis_result,
12527 l2_tunnel, "l2-tunnel");
12528 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12529 TOKEN_STRING_INITIALIZER
12530 (struct cmd_config_l2_tunnel_en_dis_result,
12531 l2_tunnel_type, "E-tag");
12532 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12533 TOKEN_STRING_INITIALIZER
12534 (struct cmd_config_l2_tunnel_en_dis_result,
12535 en_dis, "enable#disable");
12537 /* enable/disable l2 tunnel for all ports */
12539 cmd_config_l2_tunnel_en_dis_all_parsed(
12540 void *parsed_result,
12541 __attribute__((unused)) struct cmdline *cl,
12542 __attribute__((unused)) void *data)
12544 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12545 struct rte_eth_l2_tunnel_conf entry;
12549 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12551 if (!strcmp("enable", res->en_dis))
12556 RTE_ETH_FOREACH_DEV(pid) {
12557 rte_eth_dev_l2_tunnel_offload_set(pid,
12559 ETH_L2_TUNNEL_ENABLE_MASK,
12564 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12565 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12567 .help_str = "port config all l2-tunnel E-tag enable|disable",
12569 (void *)&cmd_config_l2_tunnel_en_dis_port,
12570 (void *)&cmd_config_l2_tunnel_en_dis_config,
12571 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12572 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12573 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12574 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12579 /* enable/disable l2 tunnel for a port */
12581 cmd_config_l2_tunnel_en_dis_specific_parsed(
12582 void *parsed_result,
12583 __attribute__((unused)) struct cmdline *cl,
12584 __attribute__((unused)) void *data)
12586 struct cmd_config_l2_tunnel_en_dis_result *res =
12588 struct rte_eth_l2_tunnel_conf entry;
12590 if (port_id_is_invalid(res->id, ENABLED_WARN))
12593 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12595 if (!strcmp("enable", res->en_dis))
12596 rte_eth_dev_l2_tunnel_offload_set(res->id,
12598 ETH_L2_TUNNEL_ENABLE_MASK,
12601 rte_eth_dev_l2_tunnel_offload_set(res->id,
12603 ETH_L2_TUNNEL_ENABLE_MASK,
12607 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12608 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12610 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12612 (void *)&cmd_config_l2_tunnel_en_dis_port,
12613 (void *)&cmd_config_l2_tunnel_en_dis_config,
12614 (void *)&cmd_config_l2_tunnel_en_dis_id,
12615 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12616 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12617 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12622 /* E-tag configuration */
12624 /* Common result structure for all E-tag configuration */
12625 struct cmd_config_e_tag_result {
12626 cmdline_fixed_string_t e_tag;
12627 cmdline_fixed_string_t set;
12628 cmdline_fixed_string_t insertion;
12629 cmdline_fixed_string_t stripping;
12630 cmdline_fixed_string_t forwarding;
12631 cmdline_fixed_string_t filter;
12632 cmdline_fixed_string_t add;
12633 cmdline_fixed_string_t del;
12634 cmdline_fixed_string_t on;
12635 cmdline_fixed_string_t off;
12636 cmdline_fixed_string_t on_off;
12637 cmdline_fixed_string_t port_tag_id;
12638 uint32_t port_tag_id_val;
12639 cmdline_fixed_string_t e_tag_id;
12640 uint16_t e_tag_id_val;
12641 cmdline_fixed_string_t dst_pool;
12642 uint8_t dst_pool_val;
12643 cmdline_fixed_string_t port;
12645 cmdline_fixed_string_t vf;
12649 /* Common CLI fields for all E-tag configuration */
12650 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12651 TOKEN_STRING_INITIALIZER
12652 (struct cmd_config_e_tag_result,
12654 cmdline_parse_token_string_t cmd_config_e_tag_set =
12655 TOKEN_STRING_INITIALIZER
12656 (struct cmd_config_e_tag_result,
12658 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12659 TOKEN_STRING_INITIALIZER
12660 (struct cmd_config_e_tag_result,
12661 insertion, "insertion");
12662 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12663 TOKEN_STRING_INITIALIZER
12664 (struct cmd_config_e_tag_result,
12665 stripping, "stripping");
12666 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12667 TOKEN_STRING_INITIALIZER
12668 (struct cmd_config_e_tag_result,
12669 forwarding, "forwarding");
12670 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12671 TOKEN_STRING_INITIALIZER
12672 (struct cmd_config_e_tag_result,
12674 cmdline_parse_token_string_t cmd_config_e_tag_add =
12675 TOKEN_STRING_INITIALIZER
12676 (struct cmd_config_e_tag_result,
12678 cmdline_parse_token_string_t cmd_config_e_tag_del =
12679 TOKEN_STRING_INITIALIZER
12680 (struct cmd_config_e_tag_result,
12682 cmdline_parse_token_string_t cmd_config_e_tag_on =
12683 TOKEN_STRING_INITIALIZER
12684 (struct cmd_config_e_tag_result,
12686 cmdline_parse_token_string_t cmd_config_e_tag_off =
12687 TOKEN_STRING_INITIALIZER
12688 (struct cmd_config_e_tag_result,
12690 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12691 TOKEN_STRING_INITIALIZER
12692 (struct cmd_config_e_tag_result,
12694 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12695 TOKEN_STRING_INITIALIZER
12696 (struct cmd_config_e_tag_result,
12697 port_tag_id, "port-tag-id");
12698 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12699 TOKEN_NUM_INITIALIZER
12700 (struct cmd_config_e_tag_result,
12701 port_tag_id_val, UINT32);
12702 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12703 TOKEN_STRING_INITIALIZER
12704 (struct cmd_config_e_tag_result,
12705 e_tag_id, "e-tag-id");
12706 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12707 TOKEN_NUM_INITIALIZER
12708 (struct cmd_config_e_tag_result,
12709 e_tag_id_val, UINT16);
12710 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12711 TOKEN_STRING_INITIALIZER
12712 (struct cmd_config_e_tag_result,
12713 dst_pool, "dst-pool");
12714 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12715 TOKEN_NUM_INITIALIZER
12716 (struct cmd_config_e_tag_result,
12717 dst_pool_val, UINT8);
12718 cmdline_parse_token_string_t cmd_config_e_tag_port =
12719 TOKEN_STRING_INITIALIZER
12720 (struct cmd_config_e_tag_result,
12722 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12723 TOKEN_NUM_INITIALIZER
12724 (struct cmd_config_e_tag_result,
12726 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12727 TOKEN_STRING_INITIALIZER
12728 (struct cmd_config_e_tag_result,
12730 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12731 TOKEN_NUM_INITIALIZER
12732 (struct cmd_config_e_tag_result,
12735 /* E-tag insertion configuration */
12737 cmd_config_e_tag_insertion_en_parsed(
12738 void *parsed_result,
12739 __attribute__((unused)) struct cmdline *cl,
12740 __attribute__((unused)) void *data)
12742 struct cmd_config_e_tag_result *res =
12744 struct rte_eth_l2_tunnel_conf entry;
12746 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12749 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12750 entry.tunnel_id = res->port_tag_id_val;
12751 entry.vf_id = res->vf_id;
12752 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12754 ETH_L2_TUNNEL_INSERTION_MASK,
12759 cmd_config_e_tag_insertion_dis_parsed(
12760 void *parsed_result,
12761 __attribute__((unused)) struct cmdline *cl,
12762 __attribute__((unused)) void *data)
12764 struct cmd_config_e_tag_result *res =
12766 struct rte_eth_l2_tunnel_conf entry;
12768 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12771 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12772 entry.vf_id = res->vf_id;
12774 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12776 ETH_L2_TUNNEL_INSERTION_MASK,
12780 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12781 .f = cmd_config_e_tag_insertion_en_parsed,
12783 .help_str = "E-tag ... : E-tag insertion enable",
12785 (void *)&cmd_config_e_tag_e_tag,
12786 (void *)&cmd_config_e_tag_set,
12787 (void *)&cmd_config_e_tag_insertion,
12788 (void *)&cmd_config_e_tag_on,
12789 (void *)&cmd_config_e_tag_port_tag_id,
12790 (void *)&cmd_config_e_tag_port_tag_id_val,
12791 (void *)&cmd_config_e_tag_port,
12792 (void *)&cmd_config_e_tag_port_id,
12793 (void *)&cmd_config_e_tag_vf,
12794 (void *)&cmd_config_e_tag_vf_id,
12799 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12800 .f = cmd_config_e_tag_insertion_dis_parsed,
12802 .help_str = "E-tag ... : E-tag insertion disable",
12804 (void *)&cmd_config_e_tag_e_tag,
12805 (void *)&cmd_config_e_tag_set,
12806 (void *)&cmd_config_e_tag_insertion,
12807 (void *)&cmd_config_e_tag_off,
12808 (void *)&cmd_config_e_tag_port,
12809 (void *)&cmd_config_e_tag_port_id,
12810 (void *)&cmd_config_e_tag_vf,
12811 (void *)&cmd_config_e_tag_vf_id,
12816 /* E-tag stripping configuration */
12818 cmd_config_e_tag_stripping_parsed(
12819 void *parsed_result,
12820 __attribute__((unused)) struct cmdline *cl,
12821 __attribute__((unused)) void *data)
12823 struct cmd_config_e_tag_result *res =
12825 struct rte_eth_l2_tunnel_conf entry;
12827 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12830 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12832 if (!strcmp(res->on_off, "on"))
12833 rte_eth_dev_l2_tunnel_offload_set
12836 ETH_L2_TUNNEL_STRIPPING_MASK,
12839 rte_eth_dev_l2_tunnel_offload_set
12842 ETH_L2_TUNNEL_STRIPPING_MASK,
12846 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12847 .f = cmd_config_e_tag_stripping_parsed,
12849 .help_str = "E-tag ... : E-tag stripping enable/disable",
12851 (void *)&cmd_config_e_tag_e_tag,
12852 (void *)&cmd_config_e_tag_set,
12853 (void *)&cmd_config_e_tag_stripping,
12854 (void *)&cmd_config_e_tag_on_off,
12855 (void *)&cmd_config_e_tag_port,
12856 (void *)&cmd_config_e_tag_port_id,
12861 /* E-tag forwarding configuration */
12863 cmd_config_e_tag_forwarding_parsed(
12864 void *parsed_result,
12865 __attribute__((unused)) struct cmdline *cl,
12866 __attribute__((unused)) void *data)
12868 struct cmd_config_e_tag_result *res = parsed_result;
12869 struct rte_eth_l2_tunnel_conf entry;
12871 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12874 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12876 if (!strcmp(res->on_off, "on"))
12877 rte_eth_dev_l2_tunnel_offload_set
12880 ETH_L2_TUNNEL_FORWARDING_MASK,
12883 rte_eth_dev_l2_tunnel_offload_set
12886 ETH_L2_TUNNEL_FORWARDING_MASK,
12890 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12891 .f = cmd_config_e_tag_forwarding_parsed,
12893 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12895 (void *)&cmd_config_e_tag_e_tag,
12896 (void *)&cmd_config_e_tag_set,
12897 (void *)&cmd_config_e_tag_forwarding,
12898 (void *)&cmd_config_e_tag_on_off,
12899 (void *)&cmd_config_e_tag_port,
12900 (void *)&cmd_config_e_tag_port_id,
12905 /* E-tag filter configuration */
12907 cmd_config_e_tag_filter_add_parsed(
12908 void *parsed_result,
12909 __attribute__((unused)) struct cmdline *cl,
12910 __attribute__((unused)) void *data)
12912 struct cmd_config_e_tag_result *res = parsed_result;
12913 struct rte_eth_l2_tunnel_conf entry;
12916 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12919 if (res->e_tag_id_val > 0x3fff) {
12920 printf("e-tag-id must be equal or less than 0x3fff.\n");
12924 ret = rte_eth_dev_filter_supported(res->port_id,
12925 RTE_ETH_FILTER_L2_TUNNEL);
12927 printf("E-tag filter is not supported on port %u.\n",
12932 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12933 entry.tunnel_id = res->e_tag_id_val;
12934 entry.pool = res->dst_pool_val;
12936 ret = rte_eth_dev_filter_ctrl(res->port_id,
12937 RTE_ETH_FILTER_L2_TUNNEL,
12938 RTE_ETH_FILTER_ADD,
12941 printf("E-tag filter programming error: (%s)\n",
12945 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12946 .f = cmd_config_e_tag_filter_add_parsed,
12948 .help_str = "E-tag ... : E-tag filter add",
12950 (void *)&cmd_config_e_tag_e_tag,
12951 (void *)&cmd_config_e_tag_set,
12952 (void *)&cmd_config_e_tag_filter,
12953 (void *)&cmd_config_e_tag_add,
12954 (void *)&cmd_config_e_tag_e_tag_id,
12955 (void *)&cmd_config_e_tag_e_tag_id_val,
12956 (void *)&cmd_config_e_tag_dst_pool,
12957 (void *)&cmd_config_e_tag_dst_pool_val,
12958 (void *)&cmd_config_e_tag_port,
12959 (void *)&cmd_config_e_tag_port_id,
12965 cmd_config_e_tag_filter_del_parsed(
12966 void *parsed_result,
12967 __attribute__((unused)) struct cmdline *cl,
12968 __attribute__((unused)) void *data)
12970 struct cmd_config_e_tag_result *res = parsed_result;
12971 struct rte_eth_l2_tunnel_conf entry;
12974 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12977 if (res->e_tag_id_val > 0x3fff) {
12978 printf("e-tag-id must be less than 0x3fff.\n");
12982 ret = rte_eth_dev_filter_supported(res->port_id,
12983 RTE_ETH_FILTER_L2_TUNNEL);
12985 printf("E-tag filter is not supported on port %u.\n",
12990 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12991 entry.tunnel_id = res->e_tag_id_val;
12993 ret = rte_eth_dev_filter_ctrl(res->port_id,
12994 RTE_ETH_FILTER_L2_TUNNEL,
12995 RTE_ETH_FILTER_DELETE,
12998 printf("E-tag filter programming error: (%s)\n",
13002 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13003 .f = cmd_config_e_tag_filter_del_parsed,
13005 .help_str = "E-tag ... : E-tag filter delete",
13007 (void *)&cmd_config_e_tag_e_tag,
13008 (void *)&cmd_config_e_tag_set,
13009 (void *)&cmd_config_e_tag_filter,
13010 (void *)&cmd_config_e_tag_del,
13011 (void *)&cmd_config_e_tag_e_tag_id,
13012 (void *)&cmd_config_e_tag_e_tag_id_val,
13013 (void *)&cmd_config_e_tag_port,
13014 (void *)&cmd_config_e_tag_port_id,
13019 /* vf vlan anti spoof configuration */
13021 /* Common result structure for vf vlan anti spoof */
13022 struct cmd_vf_vlan_anti_spoof_result {
13023 cmdline_fixed_string_t set;
13024 cmdline_fixed_string_t vf;
13025 cmdline_fixed_string_t vlan;
13026 cmdline_fixed_string_t antispoof;
13029 cmdline_fixed_string_t on_off;
13032 /* Common CLI fields for vf vlan anti spoof enable disable */
13033 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13034 TOKEN_STRING_INITIALIZER
13035 (struct cmd_vf_vlan_anti_spoof_result,
13037 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13038 TOKEN_STRING_INITIALIZER
13039 (struct cmd_vf_vlan_anti_spoof_result,
13041 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13042 TOKEN_STRING_INITIALIZER
13043 (struct cmd_vf_vlan_anti_spoof_result,
13045 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13046 TOKEN_STRING_INITIALIZER
13047 (struct cmd_vf_vlan_anti_spoof_result,
13048 antispoof, "antispoof");
13049 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13050 TOKEN_NUM_INITIALIZER
13051 (struct cmd_vf_vlan_anti_spoof_result,
13053 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13054 TOKEN_NUM_INITIALIZER
13055 (struct cmd_vf_vlan_anti_spoof_result,
13057 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13058 TOKEN_STRING_INITIALIZER
13059 (struct cmd_vf_vlan_anti_spoof_result,
13063 cmd_set_vf_vlan_anti_spoof_parsed(
13064 void *parsed_result,
13065 __attribute__((unused)) struct cmdline *cl,
13066 __attribute__((unused)) void *data)
13068 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13069 int ret = -ENOTSUP;
13071 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13073 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13076 #ifdef RTE_LIBRTE_IXGBE_PMD
13077 if (ret == -ENOTSUP)
13078 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13079 res->vf_id, is_on);
13081 #ifdef RTE_LIBRTE_I40E_PMD
13082 if (ret == -ENOTSUP)
13083 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13084 res->vf_id, is_on);
13086 #ifdef RTE_LIBRTE_BNXT_PMD
13087 if (ret == -ENOTSUP)
13088 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13089 res->vf_id, is_on);
13096 printf("invalid vf_id %d\n", res->vf_id);
13099 printf("invalid port_id %d\n", res->port_id);
13102 printf("function not implemented\n");
13105 printf("programming error: (%s)\n", strerror(-ret));
13109 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13110 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13112 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13114 (void *)&cmd_vf_vlan_anti_spoof_set,
13115 (void *)&cmd_vf_vlan_anti_spoof_vf,
13116 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13117 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13118 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13119 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13120 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13125 /* vf mac anti spoof configuration */
13127 /* Common result structure for vf mac anti spoof */
13128 struct cmd_vf_mac_anti_spoof_result {
13129 cmdline_fixed_string_t set;
13130 cmdline_fixed_string_t vf;
13131 cmdline_fixed_string_t mac;
13132 cmdline_fixed_string_t antispoof;
13135 cmdline_fixed_string_t on_off;
13138 /* Common CLI fields for vf mac anti spoof enable disable */
13139 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13140 TOKEN_STRING_INITIALIZER
13141 (struct cmd_vf_mac_anti_spoof_result,
13143 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13144 TOKEN_STRING_INITIALIZER
13145 (struct cmd_vf_mac_anti_spoof_result,
13147 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13148 TOKEN_STRING_INITIALIZER
13149 (struct cmd_vf_mac_anti_spoof_result,
13151 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13152 TOKEN_STRING_INITIALIZER
13153 (struct cmd_vf_mac_anti_spoof_result,
13154 antispoof, "antispoof");
13155 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13156 TOKEN_NUM_INITIALIZER
13157 (struct cmd_vf_mac_anti_spoof_result,
13159 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13160 TOKEN_NUM_INITIALIZER
13161 (struct cmd_vf_mac_anti_spoof_result,
13163 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13164 TOKEN_STRING_INITIALIZER
13165 (struct cmd_vf_mac_anti_spoof_result,
13169 cmd_set_vf_mac_anti_spoof_parsed(
13170 void *parsed_result,
13171 __attribute__((unused)) struct cmdline *cl,
13172 __attribute__((unused)) void *data)
13174 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13175 int ret = -ENOTSUP;
13177 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13179 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13182 #ifdef RTE_LIBRTE_IXGBE_PMD
13183 if (ret == -ENOTSUP)
13184 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13185 res->vf_id, is_on);
13187 #ifdef RTE_LIBRTE_I40E_PMD
13188 if (ret == -ENOTSUP)
13189 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13190 res->vf_id, is_on);
13192 #ifdef RTE_LIBRTE_BNXT_PMD
13193 if (ret == -ENOTSUP)
13194 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13195 res->vf_id, is_on);
13202 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13205 printf("invalid port_id %d\n", res->port_id);
13208 printf("function not implemented\n");
13211 printf("programming error: (%s)\n", strerror(-ret));
13215 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13216 .f = cmd_set_vf_mac_anti_spoof_parsed,
13218 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13220 (void *)&cmd_vf_mac_anti_spoof_set,
13221 (void *)&cmd_vf_mac_anti_spoof_vf,
13222 (void *)&cmd_vf_mac_anti_spoof_mac,
13223 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13224 (void *)&cmd_vf_mac_anti_spoof_port_id,
13225 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13226 (void *)&cmd_vf_mac_anti_spoof_on_off,
13231 /* vf vlan strip queue configuration */
13233 /* Common result structure for vf mac anti spoof */
13234 struct cmd_vf_vlan_stripq_result {
13235 cmdline_fixed_string_t set;
13236 cmdline_fixed_string_t vf;
13237 cmdline_fixed_string_t vlan;
13238 cmdline_fixed_string_t stripq;
13241 cmdline_fixed_string_t on_off;
13244 /* Common CLI fields for vf vlan strip enable disable */
13245 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13246 TOKEN_STRING_INITIALIZER
13247 (struct cmd_vf_vlan_stripq_result,
13249 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13250 TOKEN_STRING_INITIALIZER
13251 (struct cmd_vf_vlan_stripq_result,
13253 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13254 TOKEN_STRING_INITIALIZER
13255 (struct cmd_vf_vlan_stripq_result,
13257 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13258 TOKEN_STRING_INITIALIZER
13259 (struct cmd_vf_vlan_stripq_result,
13261 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13262 TOKEN_NUM_INITIALIZER
13263 (struct cmd_vf_vlan_stripq_result,
13265 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13266 TOKEN_NUM_INITIALIZER
13267 (struct cmd_vf_vlan_stripq_result,
13269 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13270 TOKEN_STRING_INITIALIZER
13271 (struct cmd_vf_vlan_stripq_result,
13275 cmd_set_vf_vlan_stripq_parsed(
13276 void *parsed_result,
13277 __attribute__((unused)) struct cmdline *cl,
13278 __attribute__((unused)) void *data)
13280 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13281 int ret = -ENOTSUP;
13283 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13285 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13288 #ifdef RTE_LIBRTE_IXGBE_PMD
13289 if (ret == -ENOTSUP)
13290 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13291 res->vf_id, is_on);
13293 #ifdef RTE_LIBRTE_I40E_PMD
13294 if (ret == -ENOTSUP)
13295 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13296 res->vf_id, is_on);
13298 #ifdef RTE_LIBRTE_BNXT_PMD
13299 if (ret == -ENOTSUP)
13300 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13301 res->vf_id, is_on);
13308 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13311 printf("invalid port_id %d\n", res->port_id);
13314 printf("function not implemented\n");
13317 printf("programming error: (%s)\n", strerror(-ret));
13321 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13322 .f = cmd_set_vf_vlan_stripq_parsed,
13324 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13326 (void *)&cmd_vf_vlan_stripq_set,
13327 (void *)&cmd_vf_vlan_stripq_vf,
13328 (void *)&cmd_vf_vlan_stripq_vlan,
13329 (void *)&cmd_vf_vlan_stripq_stripq,
13330 (void *)&cmd_vf_vlan_stripq_port_id,
13331 (void *)&cmd_vf_vlan_stripq_vf_id,
13332 (void *)&cmd_vf_vlan_stripq_on_off,
13337 /* vf vlan insert configuration */
13339 /* Common result structure for vf vlan insert */
13340 struct cmd_vf_vlan_insert_result {
13341 cmdline_fixed_string_t set;
13342 cmdline_fixed_string_t vf;
13343 cmdline_fixed_string_t vlan;
13344 cmdline_fixed_string_t insert;
13350 /* Common CLI fields for vf vlan insert enable disable */
13351 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13352 TOKEN_STRING_INITIALIZER
13353 (struct cmd_vf_vlan_insert_result,
13355 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13356 TOKEN_STRING_INITIALIZER
13357 (struct cmd_vf_vlan_insert_result,
13359 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13360 TOKEN_STRING_INITIALIZER
13361 (struct cmd_vf_vlan_insert_result,
13363 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13364 TOKEN_STRING_INITIALIZER
13365 (struct cmd_vf_vlan_insert_result,
13367 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13368 TOKEN_NUM_INITIALIZER
13369 (struct cmd_vf_vlan_insert_result,
13371 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13372 TOKEN_NUM_INITIALIZER
13373 (struct cmd_vf_vlan_insert_result,
13375 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13376 TOKEN_NUM_INITIALIZER
13377 (struct cmd_vf_vlan_insert_result,
13381 cmd_set_vf_vlan_insert_parsed(
13382 void *parsed_result,
13383 __attribute__((unused)) struct cmdline *cl,
13384 __attribute__((unused)) void *data)
13386 struct cmd_vf_vlan_insert_result *res = parsed_result;
13387 int ret = -ENOTSUP;
13389 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13392 #ifdef RTE_LIBRTE_IXGBE_PMD
13393 if (ret == -ENOTSUP)
13394 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13397 #ifdef RTE_LIBRTE_I40E_PMD
13398 if (ret == -ENOTSUP)
13399 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13402 #ifdef RTE_LIBRTE_BNXT_PMD
13403 if (ret == -ENOTSUP)
13404 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13412 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13415 printf("invalid port_id %d\n", res->port_id);
13418 printf("function not implemented\n");
13421 printf("programming error: (%s)\n", strerror(-ret));
13425 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13426 .f = cmd_set_vf_vlan_insert_parsed,
13428 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13430 (void *)&cmd_vf_vlan_insert_set,
13431 (void *)&cmd_vf_vlan_insert_vf,
13432 (void *)&cmd_vf_vlan_insert_vlan,
13433 (void *)&cmd_vf_vlan_insert_insert,
13434 (void *)&cmd_vf_vlan_insert_port_id,
13435 (void *)&cmd_vf_vlan_insert_vf_id,
13436 (void *)&cmd_vf_vlan_insert_vlan_id,
13441 /* tx loopback configuration */
13443 /* Common result structure for tx loopback */
13444 struct cmd_tx_loopback_result {
13445 cmdline_fixed_string_t set;
13446 cmdline_fixed_string_t tx;
13447 cmdline_fixed_string_t loopback;
13449 cmdline_fixed_string_t on_off;
13452 /* Common CLI fields for tx loopback enable disable */
13453 cmdline_parse_token_string_t cmd_tx_loopback_set =
13454 TOKEN_STRING_INITIALIZER
13455 (struct cmd_tx_loopback_result,
13457 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13458 TOKEN_STRING_INITIALIZER
13459 (struct cmd_tx_loopback_result,
13461 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13462 TOKEN_STRING_INITIALIZER
13463 (struct cmd_tx_loopback_result,
13464 loopback, "loopback");
13465 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13466 TOKEN_NUM_INITIALIZER
13467 (struct cmd_tx_loopback_result,
13469 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13470 TOKEN_STRING_INITIALIZER
13471 (struct cmd_tx_loopback_result,
13475 cmd_set_tx_loopback_parsed(
13476 void *parsed_result,
13477 __attribute__((unused)) struct cmdline *cl,
13478 __attribute__((unused)) void *data)
13480 struct cmd_tx_loopback_result *res = parsed_result;
13481 int ret = -ENOTSUP;
13483 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13485 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13488 #ifdef RTE_LIBRTE_IXGBE_PMD
13489 if (ret == -ENOTSUP)
13490 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13492 #ifdef RTE_LIBRTE_I40E_PMD
13493 if (ret == -ENOTSUP)
13494 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13496 #ifdef RTE_LIBRTE_BNXT_PMD
13497 if (ret == -ENOTSUP)
13498 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13500 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13501 if (ret == -ENOTSUP)
13502 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13509 printf("invalid is_on %d\n", is_on);
13512 printf("invalid port_id %d\n", res->port_id);
13515 printf("function not implemented\n");
13518 printf("programming error: (%s)\n", strerror(-ret));
13522 cmdline_parse_inst_t cmd_set_tx_loopback = {
13523 .f = cmd_set_tx_loopback_parsed,
13525 .help_str = "set tx loopback <port_id> on|off",
13527 (void *)&cmd_tx_loopback_set,
13528 (void *)&cmd_tx_loopback_tx,
13529 (void *)&cmd_tx_loopback_loopback,
13530 (void *)&cmd_tx_loopback_port_id,
13531 (void *)&cmd_tx_loopback_on_off,
13536 /* all queues drop enable configuration */
13538 /* Common result structure for all queues drop enable */
13539 struct cmd_all_queues_drop_en_result {
13540 cmdline_fixed_string_t set;
13541 cmdline_fixed_string_t all;
13542 cmdline_fixed_string_t queues;
13543 cmdline_fixed_string_t drop;
13545 cmdline_fixed_string_t on_off;
13548 /* Common CLI fields for tx loopback enable disable */
13549 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13550 TOKEN_STRING_INITIALIZER
13551 (struct cmd_all_queues_drop_en_result,
13553 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13554 TOKEN_STRING_INITIALIZER
13555 (struct cmd_all_queues_drop_en_result,
13557 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13558 TOKEN_STRING_INITIALIZER
13559 (struct cmd_all_queues_drop_en_result,
13561 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13562 TOKEN_STRING_INITIALIZER
13563 (struct cmd_all_queues_drop_en_result,
13565 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13566 TOKEN_NUM_INITIALIZER
13567 (struct cmd_all_queues_drop_en_result,
13569 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13570 TOKEN_STRING_INITIALIZER
13571 (struct cmd_all_queues_drop_en_result,
13575 cmd_set_all_queues_drop_en_parsed(
13576 void *parsed_result,
13577 __attribute__((unused)) struct cmdline *cl,
13578 __attribute__((unused)) void *data)
13580 struct cmd_all_queues_drop_en_result *res = parsed_result;
13581 int ret = -ENOTSUP;
13582 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13584 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13587 #ifdef RTE_LIBRTE_IXGBE_PMD
13588 if (ret == -ENOTSUP)
13589 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13591 #ifdef RTE_LIBRTE_BNXT_PMD
13592 if (ret == -ENOTSUP)
13593 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13599 printf("invalid is_on %d\n", is_on);
13602 printf("invalid port_id %d\n", res->port_id);
13605 printf("function not implemented\n");
13608 printf("programming error: (%s)\n", strerror(-ret));
13612 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13613 .f = cmd_set_all_queues_drop_en_parsed,
13615 .help_str = "set all queues drop <port_id> on|off",
13617 (void *)&cmd_all_queues_drop_en_set,
13618 (void *)&cmd_all_queues_drop_en_all,
13619 (void *)&cmd_all_queues_drop_en_queues,
13620 (void *)&cmd_all_queues_drop_en_drop,
13621 (void *)&cmd_all_queues_drop_en_port_id,
13622 (void *)&cmd_all_queues_drop_en_on_off,
13627 /* vf split drop enable configuration */
13629 /* Common result structure for vf split drop enable */
13630 struct cmd_vf_split_drop_en_result {
13631 cmdline_fixed_string_t set;
13632 cmdline_fixed_string_t vf;
13633 cmdline_fixed_string_t split;
13634 cmdline_fixed_string_t drop;
13637 cmdline_fixed_string_t on_off;
13640 /* Common CLI fields for vf split drop enable disable */
13641 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13642 TOKEN_STRING_INITIALIZER
13643 (struct cmd_vf_split_drop_en_result,
13645 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13646 TOKEN_STRING_INITIALIZER
13647 (struct cmd_vf_split_drop_en_result,
13649 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13650 TOKEN_STRING_INITIALIZER
13651 (struct cmd_vf_split_drop_en_result,
13653 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13654 TOKEN_STRING_INITIALIZER
13655 (struct cmd_vf_split_drop_en_result,
13657 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13658 TOKEN_NUM_INITIALIZER
13659 (struct cmd_vf_split_drop_en_result,
13661 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13662 TOKEN_NUM_INITIALIZER
13663 (struct cmd_vf_split_drop_en_result,
13665 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13666 TOKEN_STRING_INITIALIZER
13667 (struct cmd_vf_split_drop_en_result,
13671 cmd_set_vf_split_drop_en_parsed(
13672 void *parsed_result,
13673 __attribute__((unused)) struct cmdline *cl,
13674 __attribute__((unused)) void *data)
13676 struct cmd_vf_split_drop_en_result *res = parsed_result;
13677 int ret = -ENOTSUP;
13678 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13680 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13683 #ifdef RTE_LIBRTE_IXGBE_PMD
13684 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13691 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13694 printf("invalid port_id %d\n", res->port_id);
13697 printf("not supported on port %d\n", res->port_id);
13700 printf("programming error: (%s)\n", strerror(-ret));
13704 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13705 .f = cmd_set_vf_split_drop_en_parsed,
13707 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13709 (void *)&cmd_vf_split_drop_en_set,
13710 (void *)&cmd_vf_split_drop_en_vf,
13711 (void *)&cmd_vf_split_drop_en_split,
13712 (void *)&cmd_vf_split_drop_en_drop,
13713 (void *)&cmd_vf_split_drop_en_port_id,
13714 (void *)&cmd_vf_split_drop_en_vf_id,
13715 (void *)&cmd_vf_split_drop_en_on_off,
13720 /* vf mac address configuration */
13722 /* Common result structure for vf mac address */
13723 struct cmd_set_vf_mac_addr_result {
13724 cmdline_fixed_string_t set;
13725 cmdline_fixed_string_t vf;
13726 cmdline_fixed_string_t mac;
13727 cmdline_fixed_string_t addr;
13730 struct ether_addr mac_addr;
13734 /* Common CLI fields for vf split drop enable disable */
13735 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13736 TOKEN_STRING_INITIALIZER
13737 (struct cmd_set_vf_mac_addr_result,
13739 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13740 TOKEN_STRING_INITIALIZER
13741 (struct cmd_set_vf_mac_addr_result,
13743 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13744 TOKEN_STRING_INITIALIZER
13745 (struct cmd_set_vf_mac_addr_result,
13747 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13748 TOKEN_STRING_INITIALIZER
13749 (struct cmd_set_vf_mac_addr_result,
13751 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13752 TOKEN_NUM_INITIALIZER
13753 (struct cmd_set_vf_mac_addr_result,
13755 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13756 TOKEN_NUM_INITIALIZER
13757 (struct cmd_set_vf_mac_addr_result,
13759 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13760 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13764 cmd_set_vf_mac_addr_parsed(
13765 void *parsed_result,
13766 __attribute__((unused)) struct cmdline *cl,
13767 __attribute__((unused)) void *data)
13769 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13770 int ret = -ENOTSUP;
13772 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13775 #ifdef RTE_LIBRTE_IXGBE_PMD
13776 if (ret == -ENOTSUP)
13777 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13780 #ifdef RTE_LIBRTE_I40E_PMD
13781 if (ret == -ENOTSUP)
13782 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13785 #ifdef RTE_LIBRTE_BNXT_PMD
13786 if (ret == -ENOTSUP)
13787 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13795 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13798 printf("invalid port_id %d\n", res->port_id);
13801 printf("function not implemented\n");
13804 printf("programming error: (%s)\n", strerror(-ret));
13808 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13809 .f = cmd_set_vf_mac_addr_parsed,
13811 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13813 (void *)&cmd_set_vf_mac_addr_set,
13814 (void *)&cmd_set_vf_mac_addr_vf,
13815 (void *)&cmd_set_vf_mac_addr_mac,
13816 (void *)&cmd_set_vf_mac_addr_addr,
13817 (void *)&cmd_set_vf_mac_addr_port_id,
13818 (void *)&cmd_set_vf_mac_addr_vf_id,
13819 (void *)&cmd_set_vf_mac_addr_mac_addr,
13824 /* MACsec configuration */
13826 /* Common result structure for MACsec offload enable */
13827 struct cmd_macsec_offload_on_result {
13828 cmdline_fixed_string_t set;
13829 cmdline_fixed_string_t macsec;
13830 cmdline_fixed_string_t offload;
13832 cmdline_fixed_string_t on;
13833 cmdline_fixed_string_t encrypt;
13834 cmdline_fixed_string_t en_on_off;
13835 cmdline_fixed_string_t replay_protect;
13836 cmdline_fixed_string_t rp_on_off;
13839 /* Common CLI fields for MACsec offload disable */
13840 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13841 TOKEN_STRING_INITIALIZER
13842 (struct cmd_macsec_offload_on_result,
13844 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13845 TOKEN_STRING_INITIALIZER
13846 (struct cmd_macsec_offload_on_result,
13848 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13849 TOKEN_STRING_INITIALIZER
13850 (struct cmd_macsec_offload_on_result,
13851 offload, "offload");
13852 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13853 TOKEN_NUM_INITIALIZER
13854 (struct cmd_macsec_offload_on_result,
13856 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13857 TOKEN_STRING_INITIALIZER
13858 (struct cmd_macsec_offload_on_result,
13860 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13861 TOKEN_STRING_INITIALIZER
13862 (struct cmd_macsec_offload_on_result,
13863 encrypt, "encrypt");
13864 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13865 TOKEN_STRING_INITIALIZER
13866 (struct cmd_macsec_offload_on_result,
13867 en_on_off, "on#off");
13868 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13869 TOKEN_STRING_INITIALIZER
13870 (struct cmd_macsec_offload_on_result,
13871 replay_protect, "replay-protect");
13872 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13873 TOKEN_STRING_INITIALIZER
13874 (struct cmd_macsec_offload_on_result,
13875 rp_on_off, "on#off");
13878 cmd_set_macsec_offload_on_parsed(
13879 void *parsed_result,
13880 __attribute__((unused)) struct cmdline *cl,
13881 __attribute__((unused)) void *data)
13883 struct cmd_macsec_offload_on_result *res = parsed_result;
13884 int ret = -ENOTSUP;
13885 portid_t port_id = res->port_id;
13886 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13887 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13888 struct rte_eth_dev_info dev_info;
13890 if (port_id_is_invalid(port_id, ENABLED_WARN))
13892 if (!port_is_stopped(port_id)) {
13893 printf("Please stop port %d first\n", port_id);
13897 rte_eth_dev_info_get(port_id, &dev_info);
13898 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13899 #ifdef RTE_LIBRTE_IXGBE_PMD
13900 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13908 ports[port_id].dev_conf.txmode.offloads |=
13909 DEV_TX_OFFLOAD_MACSEC_INSERT;
13910 cmd_reconfig_device_queue(port_id, 1, 1);
13913 printf("invalid port_id %d\n", port_id);
13916 printf("not supported on port %d\n", port_id);
13919 printf("programming error: (%s)\n", strerror(-ret));
13923 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13924 .f = cmd_set_macsec_offload_on_parsed,
13926 .help_str = "set macsec offload <port_id> on "
13927 "encrypt on|off replay-protect on|off",
13929 (void *)&cmd_macsec_offload_on_set,
13930 (void *)&cmd_macsec_offload_on_macsec,
13931 (void *)&cmd_macsec_offload_on_offload,
13932 (void *)&cmd_macsec_offload_on_port_id,
13933 (void *)&cmd_macsec_offload_on_on,
13934 (void *)&cmd_macsec_offload_on_encrypt,
13935 (void *)&cmd_macsec_offload_on_en_on_off,
13936 (void *)&cmd_macsec_offload_on_replay_protect,
13937 (void *)&cmd_macsec_offload_on_rp_on_off,
13942 /* Common result structure for MACsec offload disable */
13943 struct cmd_macsec_offload_off_result {
13944 cmdline_fixed_string_t set;
13945 cmdline_fixed_string_t macsec;
13946 cmdline_fixed_string_t offload;
13948 cmdline_fixed_string_t off;
13951 /* Common CLI fields for MACsec offload disable */
13952 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13953 TOKEN_STRING_INITIALIZER
13954 (struct cmd_macsec_offload_off_result,
13956 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13957 TOKEN_STRING_INITIALIZER
13958 (struct cmd_macsec_offload_off_result,
13960 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13961 TOKEN_STRING_INITIALIZER
13962 (struct cmd_macsec_offload_off_result,
13963 offload, "offload");
13964 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13965 TOKEN_NUM_INITIALIZER
13966 (struct cmd_macsec_offload_off_result,
13968 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13969 TOKEN_STRING_INITIALIZER
13970 (struct cmd_macsec_offload_off_result,
13974 cmd_set_macsec_offload_off_parsed(
13975 void *parsed_result,
13976 __attribute__((unused)) struct cmdline *cl,
13977 __attribute__((unused)) void *data)
13979 struct cmd_macsec_offload_off_result *res = parsed_result;
13980 int ret = -ENOTSUP;
13981 struct rte_eth_dev_info dev_info;
13982 portid_t port_id = res->port_id;
13984 if (port_id_is_invalid(port_id, ENABLED_WARN))
13986 if (!port_is_stopped(port_id)) {
13987 printf("Please stop port %d first\n", port_id);
13991 rte_eth_dev_info_get(port_id, &dev_info);
13992 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13993 #ifdef RTE_LIBRTE_IXGBE_PMD
13994 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13999 ports[port_id].dev_conf.txmode.offloads &=
14000 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14001 cmd_reconfig_device_queue(port_id, 1, 1);
14004 printf("invalid port_id %d\n", port_id);
14007 printf("not supported on port %d\n", port_id);
14010 printf("programming error: (%s)\n", strerror(-ret));
14014 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14015 .f = cmd_set_macsec_offload_off_parsed,
14017 .help_str = "set macsec offload <port_id> off",
14019 (void *)&cmd_macsec_offload_off_set,
14020 (void *)&cmd_macsec_offload_off_macsec,
14021 (void *)&cmd_macsec_offload_off_offload,
14022 (void *)&cmd_macsec_offload_off_port_id,
14023 (void *)&cmd_macsec_offload_off_off,
14028 /* Common result structure for MACsec secure connection configure */
14029 struct cmd_macsec_sc_result {
14030 cmdline_fixed_string_t set;
14031 cmdline_fixed_string_t macsec;
14032 cmdline_fixed_string_t sc;
14033 cmdline_fixed_string_t tx_rx;
14035 struct ether_addr mac;
14039 /* Common CLI fields for MACsec secure connection configure */
14040 cmdline_parse_token_string_t cmd_macsec_sc_set =
14041 TOKEN_STRING_INITIALIZER
14042 (struct cmd_macsec_sc_result,
14044 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14045 TOKEN_STRING_INITIALIZER
14046 (struct cmd_macsec_sc_result,
14048 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14049 TOKEN_STRING_INITIALIZER
14050 (struct cmd_macsec_sc_result,
14052 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14053 TOKEN_STRING_INITIALIZER
14054 (struct cmd_macsec_sc_result,
14056 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14057 TOKEN_NUM_INITIALIZER
14058 (struct cmd_macsec_sc_result,
14060 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14061 TOKEN_ETHERADDR_INITIALIZER
14062 (struct cmd_macsec_sc_result,
14064 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14065 TOKEN_NUM_INITIALIZER
14066 (struct cmd_macsec_sc_result,
14070 cmd_set_macsec_sc_parsed(
14071 void *parsed_result,
14072 __attribute__((unused)) struct cmdline *cl,
14073 __attribute__((unused)) void *data)
14075 struct cmd_macsec_sc_result *res = parsed_result;
14076 int ret = -ENOTSUP;
14077 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14079 #ifdef RTE_LIBRTE_IXGBE_PMD
14081 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14082 res->mac.addr_bytes) :
14083 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14084 res->mac.addr_bytes, res->pi);
14086 RTE_SET_USED(is_tx);
14092 printf("invalid port_id %d\n", res->port_id);
14095 printf("not supported on port %d\n", res->port_id);
14098 printf("programming error: (%s)\n", strerror(-ret));
14102 cmdline_parse_inst_t cmd_set_macsec_sc = {
14103 .f = cmd_set_macsec_sc_parsed,
14105 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14107 (void *)&cmd_macsec_sc_set,
14108 (void *)&cmd_macsec_sc_macsec,
14109 (void *)&cmd_macsec_sc_sc,
14110 (void *)&cmd_macsec_sc_tx_rx,
14111 (void *)&cmd_macsec_sc_port_id,
14112 (void *)&cmd_macsec_sc_mac,
14113 (void *)&cmd_macsec_sc_pi,
14118 /* Common result structure for MACsec secure connection configure */
14119 struct cmd_macsec_sa_result {
14120 cmdline_fixed_string_t set;
14121 cmdline_fixed_string_t macsec;
14122 cmdline_fixed_string_t sa;
14123 cmdline_fixed_string_t tx_rx;
14128 cmdline_fixed_string_t key;
14131 /* Common CLI fields for MACsec secure connection configure */
14132 cmdline_parse_token_string_t cmd_macsec_sa_set =
14133 TOKEN_STRING_INITIALIZER
14134 (struct cmd_macsec_sa_result,
14136 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14137 TOKEN_STRING_INITIALIZER
14138 (struct cmd_macsec_sa_result,
14140 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14141 TOKEN_STRING_INITIALIZER
14142 (struct cmd_macsec_sa_result,
14144 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14145 TOKEN_STRING_INITIALIZER
14146 (struct cmd_macsec_sa_result,
14148 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14149 TOKEN_NUM_INITIALIZER
14150 (struct cmd_macsec_sa_result,
14152 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14153 TOKEN_NUM_INITIALIZER
14154 (struct cmd_macsec_sa_result,
14156 cmdline_parse_token_num_t cmd_macsec_sa_an =
14157 TOKEN_NUM_INITIALIZER
14158 (struct cmd_macsec_sa_result,
14160 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14161 TOKEN_NUM_INITIALIZER
14162 (struct cmd_macsec_sa_result,
14164 cmdline_parse_token_string_t cmd_macsec_sa_key =
14165 TOKEN_STRING_INITIALIZER
14166 (struct cmd_macsec_sa_result,
14170 cmd_set_macsec_sa_parsed(
14171 void *parsed_result,
14172 __attribute__((unused)) struct cmdline *cl,
14173 __attribute__((unused)) void *data)
14175 struct cmd_macsec_sa_result *res = parsed_result;
14176 int ret = -ENOTSUP;
14177 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14178 uint8_t key[16] = { 0 };
14184 key_len = strlen(res->key) / 2;
14188 for (i = 0; i < key_len; i++) {
14189 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14192 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14195 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14198 #ifdef RTE_LIBRTE_IXGBE_PMD
14200 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14201 res->idx, res->an, res->pn, key) :
14202 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14203 res->idx, res->an, res->pn, key);
14205 RTE_SET_USED(is_tx);
14212 printf("invalid idx %d or an %d\n", res->idx, res->an);
14215 printf("invalid port_id %d\n", res->port_id);
14218 printf("not supported on port %d\n", res->port_id);
14221 printf("programming error: (%s)\n", strerror(-ret));
14225 cmdline_parse_inst_t cmd_set_macsec_sa = {
14226 .f = cmd_set_macsec_sa_parsed,
14228 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14230 (void *)&cmd_macsec_sa_set,
14231 (void *)&cmd_macsec_sa_macsec,
14232 (void *)&cmd_macsec_sa_sa,
14233 (void *)&cmd_macsec_sa_tx_rx,
14234 (void *)&cmd_macsec_sa_port_id,
14235 (void *)&cmd_macsec_sa_idx,
14236 (void *)&cmd_macsec_sa_an,
14237 (void *)&cmd_macsec_sa_pn,
14238 (void *)&cmd_macsec_sa_key,
14243 /* VF unicast promiscuous mode configuration */
14245 /* Common result structure for VF unicast promiscuous mode */
14246 struct cmd_vf_promisc_result {
14247 cmdline_fixed_string_t set;
14248 cmdline_fixed_string_t vf;
14249 cmdline_fixed_string_t promisc;
14252 cmdline_fixed_string_t on_off;
14255 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14256 cmdline_parse_token_string_t cmd_vf_promisc_set =
14257 TOKEN_STRING_INITIALIZER
14258 (struct cmd_vf_promisc_result,
14260 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14261 TOKEN_STRING_INITIALIZER
14262 (struct cmd_vf_promisc_result,
14264 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14265 TOKEN_STRING_INITIALIZER
14266 (struct cmd_vf_promisc_result,
14267 promisc, "promisc");
14268 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14269 TOKEN_NUM_INITIALIZER
14270 (struct cmd_vf_promisc_result,
14272 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14273 TOKEN_NUM_INITIALIZER
14274 (struct cmd_vf_promisc_result,
14276 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14277 TOKEN_STRING_INITIALIZER
14278 (struct cmd_vf_promisc_result,
14282 cmd_set_vf_promisc_parsed(
14283 void *parsed_result,
14284 __attribute__((unused)) struct cmdline *cl,
14285 __attribute__((unused)) void *data)
14287 struct cmd_vf_promisc_result *res = parsed_result;
14288 int ret = -ENOTSUP;
14290 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14292 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14295 #ifdef RTE_LIBRTE_I40E_PMD
14296 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14297 res->vf_id, is_on);
14304 printf("invalid vf_id %d\n", res->vf_id);
14307 printf("invalid port_id %d\n", res->port_id);
14310 printf("function not implemented\n");
14313 printf("programming error: (%s)\n", strerror(-ret));
14317 cmdline_parse_inst_t cmd_set_vf_promisc = {
14318 .f = cmd_set_vf_promisc_parsed,
14320 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14321 "Set unicast promiscuous mode for a VF from the PF",
14323 (void *)&cmd_vf_promisc_set,
14324 (void *)&cmd_vf_promisc_vf,
14325 (void *)&cmd_vf_promisc_promisc,
14326 (void *)&cmd_vf_promisc_port_id,
14327 (void *)&cmd_vf_promisc_vf_id,
14328 (void *)&cmd_vf_promisc_on_off,
14333 /* VF multicast promiscuous mode configuration */
14335 /* Common result structure for VF multicast promiscuous mode */
14336 struct cmd_vf_allmulti_result {
14337 cmdline_fixed_string_t set;
14338 cmdline_fixed_string_t vf;
14339 cmdline_fixed_string_t allmulti;
14342 cmdline_fixed_string_t on_off;
14345 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14346 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14347 TOKEN_STRING_INITIALIZER
14348 (struct cmd_vf_allmulti_result,
14350 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14351 TOKEN_STRING_INITIALIZER
14352 (struct cmd_vf_allmulti_result,
14354 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14355 TOKEN_STRING_INITIALIZER
14356 (struct cmd_vf_allmulti_result,
14357 allmulti, "allmulti");
14358 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14359 TOKEN_NUM_INITIALIZER
14360 (struct cmd_vf_allmulti_result,
14362 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14363 TOKEN_NUM_INITIALIZER
14364 (struct cmd_vf_allmulti_result,
14366 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14367 TOKEN_STRING_INITIALIZER
14368 (struct cmd_vf_allmulti_result,
14372 cmd_set_vf_allmulti_parsed(
14373 void *parsed_result,
14374 __attribute__((unused)) struct cmdline *cl,
14375 __attribute__((unused)) void *data)
14377 struct cmd_vf_allmulti_result *res = parsed_result;
14378 int ret = -ENOTSUP;
14380 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14382 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14385 #ifdef RTE_LIBRTE_I40E_PMD
14386 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14387 res->vf_id, is_on);
14394 printf("invalid vf_id %d\n", res->vf_id);
14397 printf("invalid port_id %d\n", res->port_id);
14400 printf("function not implemented\n");
14403 printf("programming error: (%s)\n", strerror(-ret));
14407 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14408 .f = cmd_set_vf_allmulti_parsed,
14410 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14411 "Set multicast promiscuous mode for a VF from the PF",
14413 (void *)&cmd_vf_allmulti_set,
14414 (void *)&cmd_vf_allmulti_vf,
14415 (void *)&cmd_vf_allmulti_allmulti,
14416 (void *)&cmd_vf_allmulti_port_id,
14417 (void *)&cmd_vf_allmulti_vf_id,
14418 (void *)&cmd_vf_allmulti_on_off,
14423 /* vf broadcast mode configuration */
14425 /* Common result structure for vf broadcast */
14426 struct cmd_set_vf_broadcast_result {
14427 cmdline_fixed_string_t set;
14428 cmdline_fixed_string_t vf;
14429 cmdline_fixed_string_t broadcast;
14432 cmdline_fixed_string_t on_off;
14435 /* Common CLI fields for vf broadcast enable disable */
14436 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14437 TOKEN_STRING_INITIALIZER
14438 (struct cmd_set_vf_broadcast_result,
14440 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14441 TOKEN_STRING_INITIALIZER
14442 (struct cmd_set_vf_broadcast_result,
14444 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14445 TOKEN_STRING_INITIALIZER
14446 (struct cmd_set_vf_broadcast_result,
14447 broadcast, "broadcast");
14448 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14449 TOKEN_NUM_INITIALIZER
14450 (struct cmd_set_vf_broadcast_result,
14452 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14453 TOKEN_NUM_INITIALIZER
14454 (struct cmd_set_vf_broadcast_result,
14456 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14457 TOKEN_STRING_INITIALIZER
14458 (struct cmd_set_vf_broadcast_result,
14462 cmd_set_vf_broadcast_parsed(
14463 void *parsed_result,
14464 __attribute__((unused)) struct cmdline *cl,
14465 __attribute__((unused)) void *data)
14467 struct cmd_set_vf_broadcast_result *res = parsed_result;
14468 int ret = -ENOTSUP;
14470 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14472 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14475 #ifdef RTE_LIBRTE_I40E_PMD
14476 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14477 res->vf_id, is_on);
14484 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14487 printf("invalid port_id %d\n", res->port_id);
14490 printf("function not implemented\n");
14493 printf("programming error: (%s)\n", strerror(-ret));
14497 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14498 .f = cmd_set_vf_broadcast_parsed,
14500 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14502 (void *)&cmd_set_vf_broadcast_set,
14503 (void *)&cmd_set_vf_broadcast_vf,
14504 (void *)&cmd_set_vf_broadcast_broadcast,
14505 (void *)&cmd_set_vf_broadcast_port_id,
14506 (void *)&cmd_set_vf_broadcast_vf_id,
14507 (void *)&cmd_set_vf_broadcast_on_off,
14512 /* vf vlan tag configuration */
14514 /* Common result structure for vf vlan tag */
14515 struct cmd_set_vf_vlan_tag_result {
14516 cmdline_fixed_string_t set;
14517 cmdline_fixed_string_t vf;
14518 cmdline_fixed_string_t vlan;
14519 cmdline_fixed_string_t tag;
14522 cmdline_fixed_string_t on_off;
14525 /* Common CLI fields for vf vlan tag enable disable */
14526 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14527 TOKEN_STRING_INITIALIZER
14528 (struct cmd_set_vf_vlan_tag_result,
14530 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14531 TOKEN_STRING_INITIALIZER
14532 (struct cmd_set_vf_vlan_tag_result,
14534 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14535 TOKEN_STRING_INITIALIZER
14536 (struct cmd_set_vf_vlan_tag_result,
14538 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14539 TOKEN_STRING_INITIALIZER
14540 (struct cmd_set_vf_vlan_tag_result,
14542 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14543 TOKEN_NUM_INITIALIZER
14544 (struct cmd_set_vf_vlan_tag_result,
14546 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14547 TOKEN_NUM_INITIALIZER
14548 (struct cmd_set_vf_vlan_tag_result,
14550 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14551 TOKEN_STRING_INITIALIZER
14552 (struct cmd_set_vf_vlan_tag_result,
14556 cmd_set_vf_vlan_tag_parsed(
14557 void *parsed_result,
14558 __attribute__((unused)) struct cmdline *cl,
14559 __attribute__((unused)) void *data)
14561 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14562 int ret = -ENOTSUP;
14564 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14566 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14569 #ifdef RTE_LIBRTE_I40E_PMD
14570 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14571 res->vf_id, is_on);
14578 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14581 printf("invalid port_id %d\n", res->port_id);
14584 printf("function not implemented\n");
14587 printf("programming error: (%s)\n", strerror(-ret));
14591 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14592 .f = cmd_set_vf_vlan_tag_parsed,
14594 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14596 (void *)&cmd_set_vf_vlan_tag_set,
14597 (void *)&cmd_set_vf_vlan_tag_vf,
14598 (void *)&cmd_set_vf_vlan_tag_vlan,
14599 (void *)&cmd_set_vf_vlan_tag_tag,
14600 (void *)&cmd_set_vf_vlan_tag_port_id,
14601 (void *)&cmd_set_vf_vlan_tag_vf_id,
14602 (void *)&cmd_set_vf_vlan_tag_on_off,
14607 /* Common definition of VF and TC TX bandwidth configuration */
14608 struct cmd_vf_tc_bw_result {
14609 cmdline_fixed_string_t set;
14610 cmdline_fixed_string_t vf;
14611 cmdline_fixed_string_t tc;
14612 cmdline_fixed_string_t tx;
14613 cmdline_fixed_string_t min_bw;
14614 cmdline_fixed_string_t max_bw;
14615 cmdline_fixed_string_t strict_link_prio;
14620 cmdline_fixed_string_t bw_list;
14624 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14625 TOKEN_STRING_INITIALIZER
14626 (struct cmd_vf_tc_bw_result,
14628 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14629 TOKEN_STRING_INITIALIZER
14630 (struct cmd_vf_tc_bw_result,
14632 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14633 TOKEN_STRING_INITIALIZER
14634 (struct cmd_vf_tc_bw_result,
14636 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14637 TOKEN_STRING_INITIALIZER
14638 (struct cmd_vf_tc_bw_result,
14640 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14641 TOKEN_STRING_INITIALIZER
14642 (struct cmd_vf_tc_bw_result,
14643 strict_link_prio, "strict-link-priority");
14644 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14645 TOKEN_STRING_INITIALIZER
14646 (struct cmd_vf_tc_bw_result,
14647 min_bw, "min-bandwidth");
14648 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14649 TOKEN_STRING_INITIALIZER
14650 (struct cmd_vf_tc_bw_result,
14651 max_bw, "max-bandwidth");
14652 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14653 TOKEN_NUM_INITIALIZER
14654 (struct cmd_vf_tc_bw_result,
14656 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14657 TOKEN_NUM_INITIALIZER
14658 (struct cmd_vf_tc_bw_result,
14660 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14661 TOKEN_NUM_INITIALIZER
14662 (struct cmd_vf_tc_bw_result,
14664 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14665 TOKEN_NUM_INITIALIZER
14666 (struct cmd_vf_tc_bw_result,
14668 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14669 TOKEN_STRING_INITIALIZER
14670 (struct cmd_vf_tc_bw_result,
14672 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14673 TOKEN_NUM_INITIALIZER
14674 (struct cmd_vf_tc_bw_result,
14677 /* VF max bandwidth setting */
14679 cmd_vf_max_bw_parsed(
14680 void *parsed_result,
14681 __attribute__((unused)) struct cmdline *cl,
14682 __attribute__((unused)) void *data)
14684 struct cmd_vf_tc_bw_result *res = parsed_result;
14685 int ret = -ENOTSUP;
14687 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14690 #ifdef RTE_LIBRTE_I40E_PMD
14691 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14692 res->vf_id, res->bw);
14699 printf("invalid vf_id %d or bandwidth %d\n",
14700 res->vf_id, res->bw);
14703 printf("invalid port_id %d\n", res->port_id);
14706 printf("function not implemented\n");
14709 printf("programming error: (%s)\n", strerror(-ret));
14713 cmdline_parse_inst_t cmd_vf_max_bw = {
14714 .f = cmd_vf_max_bw_parsed,
14716 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14718 (void *)&cmd_vf_tc_bw_set,
14719 (void *)&cmd_vf_tc_bw_vf,
14720 (void *)&cmd_vf_tc_bw_tx,
14721 (void *)&cmd_vf_tc_bw_max_bw,
14722 (void *)&cmd_vf_tc_bw_port_id,
14723 (void *)&cmd_vf_tc_bw_vf_id,
14724 (void *)&cmd_vf_tc_bw_bw,
14730 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14735 const char *p, *p0 = str;
14742 p = strchr(p0, '(');
14744 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14748 p0 = strchr(p, ')');
14750 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14754 if (size >= sizeof(s)) {
14755 printf("The string size exceeds the internal buffer size\n");
14758 snprintf(s, sizeof(s), "%.*s", size, p);
14759 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14761 printf("Failed to get the bandwidth list. ");
14765 for (i = 0; i < ret; i++)
14766 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14771 /* TC min bandwidth setting */
14773 cmd_vf_tc_min_bw_parsed(
14774 void *parsed_result,
14775 __attribute__((unused)) struct cmdline *cl,
14776 __attribute__((unused)) void *data)
14778 struct cmd_vf_tc_bw_result *res = parsed_result;
14781 int ret = -ENOTSUP;
14783 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14786 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14790 #ifdef RTE_LIBRTE_I40E_PMD
14791 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14799 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14802 printf("invalid port_id %d\n", res->port_id);
14805 printf("function not implemented\n");
14808 printf("programming error: (%s)\n", strerror(-ret));
14812 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14813 .f = cmd_vf_tc_min_bw_parsed,
14815 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14816 " <bw1, bw2, ...>",
14818 (void *)&cmd_vf_tc_bw_set,
14819 (void *)&cmd_vf_tc_bw_vf,
14820 (void *)&cmd_vf_tc_bw_tc,
14821 (void *)&cmd_vf_tc_bw_tx,
14822 (void *)&cmd_vf_tc_bw_min_bw,
14823 (void *)&cmd_vf_tc_bw_port_id,
14824 (void *)&cmd_vf_tc_bw_vf_id,
14825 (void *)&cmd_vf_tc_bw_bw_list,
14831 cmd_tc_min_bw_parsed(
14832 void *parsed_result,
14833 __attribute__((unused)) struct cmdline *cl,
14834 __attribute__((unused)) void *data)
14836 struct cmd_vf_tc_bw_result *res = parsed_result;
14837 struct rte_port *port;
14840 int ret = -ENOTSUP;
14842 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14845 port = &ports[res->port_id];
14846 /** Check if the port is not started **/
14847 if (port->port_status != RTE_PORT_STOPPED) {
14848 printf("Please stop port %d first\n", res->port_id);
14852 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14856 #ifdef RTE_LIBRTE_IXGBE_PMD
14857 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14864 printf("invalid bandwidth\n");
14867 printf("invalid port_id %d\n", res->port_id);
14870 printf("function not implemented\n");
14873 printf("programming error: (%s)\n", strerror(-ret));
14877 cmdline_parse_inst_t cmd_tc_min_bw = {
14878 .f = cmd_tc_min_bw_parsed,
14880 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14882 (void *)&cmd_vf_tc_bw_set,
14883 (void *)&cmd_vf_tc_bw_tc,
14884 (void *)&cmd_vf_tc_bw_tx,
14885 (void *)&cmd_vf_tc_bw_min_bw,
14886 (void *)&cmd_vf_tc_bw_port_id,
14887 (void *)&cmd_vf_tc_bw_bw_list,
14892 /* TC max bandwidth setting */
14894 cmd_vf_tc_max_bw_parsed(
14895 void *parsed_result,
14896 __attribute__((unused)) struct cmdline *cl,
14897 __attribute__((unused)) void *data)
14899 struct cmd_vf_tc_bw_result *res = parsed_result;
14900 int ret = -ENOTSUP;
14902 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14905 #ifdef RTE_LIBRTE_I40E_PMD
14906 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14907 res->tc_no, res->bw);
14914 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14915 res->vf_id, res->tc_no, res->bw);
14918 printf("invalid port_id %d\n", res->port_id);
14921 printf("function not implemented\n");
14924 printf("programming error: (%s)\n", strerror(-ret));
14928 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14929 .f = cmd_vf_tc_max_bw_parsed,
14931 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14934 (void *)&cmd_vf_tc_bw_set,
14935 (void *)&cmd_vf_tc_bw_vf,
14936 (void *)&cmd_vf_tc_bw_tc,
14937 (void *)&cmd_vf_tc_bw_tx,
14938 (void *)&cmd_vf_tc_bw_max_bw,
14939 (void *)&cmd_vf_tc_bw_port_id,
14940 (void *)&cmd_vf_tc_bw_vf_id,
14941 (void *)&cmd_vf_tc_bw_tc_no,
14942 (void *)&cmd_vf_tc_bw_bw,
14948 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14950 /* *** Set Port default Traffic Management Hierarchy *** */
14951 struct cmd_set_port_tm_hierarchy_default_result {
14952 cmdline_fixed_string_t set;
14953 cmdline_fixed_string_t port;
14954 cmdline_fixed_string_t tm;
14955 cmdline_fixed_string_t hierarchy;
14956 cmdline_fixed_string_t def;
14960 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14961 TOKEN_STRING_INITIALIZER(
14962 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14963 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14964 TOKEN_STRING_INITIALIZER(
14965 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14966 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14967 TOKEN_STRING_INITIALIZER(
14968 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14969 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14970 TOKEN_STRING_INITIALIZER(
14971 struct cmd_set_port_tm_hierarchy_default_result,
14972 hierarchy, "hierarchy");
14973 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14974 TOKEN_STRING_INITIALIZER(
14975 struct cmd_set_port_tm_hierarchy_default_result,
14977 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14978 TOKEN_NUM_INITIALIZER(
14979 struct cmd_set_port_tm_hierarchy_default_result,
14982 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14983 __attribute__((unused)) struct cmdline *cl,
14984 __attribute__((unused)) void *data)
14986 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14987 struct rte_port *p;
14988 portid_t port_id = res->port_id;
14990 if (port_id_is_invalid(port_id, ENABLED_WARN))
14993 p = &ports[port_id];
14995 /* Forward mode: tm */
14996 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
14997 printf(" softnicfwd mode not enabled(error)\n");
15001 /* Set the default tm hierarchy */
15002 p->softport.default_tm_hierarchy_enable = 1;
15005 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15006 .f = cmd_set_port_tm_hierarchy_default_parsed,
15008 .help_str = "set port tm hierarchy default <port_id>",
15010 (void *)&cmd_set_port_tm_hierarchy_default_set,
15011 (void *)&cmd_set_port_tm_hierarchy_default_port,
15012 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15013 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15014 (void *)&cmd_set_port_tm_hierarchy_default_default,
15015 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15021 /** Set VXLAN encapsulation details */
15022 struct cmd_set_vxlan_result {
15023 cmdline_fixed_string_t set;
15024 cmdline_fixed_string_t vxlan;
15025 cmdline_fixed_string_t pos_token;
15026 cmdline_fixed_string_t ip_version;
15027 uint32_t vlan_present:1;
15031 cmdline_ipaddr_t ip_src;
15032 cmdline_ipaddr_t ip_dst;
15034 struct ether_addr eth_src;
15035 struct ether_addr eth_dst;
15038 cmdline_parse_token_string_t cmd_set_vxlan_set =
15039 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15040 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15041 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15042 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15043 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15044 "vxlan-with-vlan");
15045 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15046 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15048 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15049 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15051 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15052 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15054 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15055 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15056 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15057 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15059 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15060 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15061 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15062 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15064 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15065 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15066 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15067 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15069 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15070 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15071 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15072 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15074 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15075 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15076 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15077 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15079 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15080 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15081 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15082 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15084 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15085 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15086 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15087 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15089 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15090 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15092 static void cmd_set_vxlan_parsed(void *parsed_result,
15093 __attribute__((unused)) struct cmdline *cl,
15094 __attribute__((unused)) void *data)
15096 struct cmd_set_vxlan_result *res = parsed_result;
15101 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15104 if (strcmp(res->vxlan, "vxlan") == 0)
15105 vxlan_encap_conf.select_vlan = 0;
15106 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15107 vxlan_encap_conf.select_vlan = 1;
15108 if (strcmp(res->ip_version, "ipv4") == 0)
15109 vxlan_encap_conf.select_ipv4 = 1;
15110 else if (strcmp(res->ip_version, "ipv6") == 0)
15111 vxlan_encap_conf.select_ipv4 = 0;
15114 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15115 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15116 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15117 if (vxlan_encap_conf.select_ipv4) {
15118 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15119 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15121 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15122 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15124 if (vxlan_encap_conf.select_vlan)
15125 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15126 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15128 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15132 cmdline_parse_inst_t cmd_set_vxlan = {
15133 .f = cmd_set_vxlan_parsed,
15135 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15136 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15137 " eth-src <eth-src> eth-dst <eth-dst>",
15139 (void *)&cmd_set_vxlan_set,
15140 (void *)&cmd_set_vxlan_vxlan,
15141 (void *)&cmd_set_vxlan_ip_version,
15142 (void *)&cmd_set_vxlan_ip_version_value,
15143 (void *)&cmd_set_vxlan_vni,
15144 (void *)&cmd_set_vxlan_vni_value,
15145 (void *)&cmd_set_vxlan_udp_src,
15146 (void *)&cmd_set_vxlan_udp_src_value,
15147 (void *)&cmd_set_vxlan_udp_dst,
15148 (void *)&cmd_set_vxlan_udp_dst_value,
15149 (void *)&cmd_set_vxlan_ip_src,
15150 (void *)&cmd_set_vxlan_ip_src_value,
15151 (void *)&cmd_set_vxlan_ip_dst,
15152 (void *)&cmd_set_vxlan_ip_dst_value,
15153 (void *)&cmd_set_vxlan_eth_src,
15154 (void *)&cmd_set_vxlan_eth_src_value,
15155 (void *)&cmd_set_vxlan_eth_dst,
15156 (void *)&cmd_set_vxlan_eth_dst_value,
15161 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15162 .f = cmd_set_vxlan_parsed,
15164 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15165 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15166 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15169 (void *)&cmd_set_vxlan_set,
15170 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15171 (void *)&cmd_set_vxlan_ip_version,
15172 (void *)&cmd_set_vxlan_ip_version_value,
15173 (void *)&cmd_set_vxlan_vni,
15174 (void *)&cmd_set_vxlan_vni_value,
15175 (void *)&cmd_set_vxlan_udp_src,
15176 (void *)&cmd_set_vxlan_udp_src_value,
15177 (void *)&cmd_set_vxlan_udp_dst,
15178 (void *)&cmd_set_vxlan_udp_dst_value,
15179 (void *)&cmd_set_vxlan_ip_src,
15180 (void *)&cmd_set_vxlan_ip_src_value,
15181 (void *)&cmd_set_vxlan_ip_dst,
15182 (void *)&cmd_set_vxlan_ip_dst_value,
15183 (void *)&cmd_set_vxlan_vlan,
15184 (void *)&cmd_set_vxlan_vlan_value,
15185 (void *)&cmd_set_vxlan_eth_src,
15186 (void *)&cmd_set_vxlan_eth_src_value,
15187 (void *)&cmd_set_vxlan_eth_dst,
15188 (void *)&cmd_set_vxlan_eth_dst_value,
15193 /** Set NVGRE encapsulation details */
15194 struct cmd_set_nvgre_result {
15195 cmdline_fixed_string_t set;
15196 cmdline_fixed_string_t nvgre;
15197 cmdline_fixed_string_t pos_token;
15198 cmdline_fixed_string_t ip_version;
15200 cmdline_ipaddr_t ip_src;
15201 cmdline_ipaddr_t ip_dst;
15203 struct ether_addr eth_src;
15204 struct ether_addr eth_dst;
15207 cmdline_parse_token_string_t cmd_set_nvgre_set =
15208 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15209 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15210 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15211 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15212 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15213 "nvgre-with-vlan");
15214 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15215 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15217 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15218 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15220 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15221 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15223 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15224 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15225 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15226 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15228 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15229 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15230 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15231 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15233 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15234 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15235 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15236 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15238 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15239 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15240 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15241 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15243 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15244 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15245 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15246 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15248 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15249 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15251 static void cmd_set_nvgre_parsed(void *parsed_result,
15252 __attribute__((unused)) struct cmdline *cl,
15253 __attribute__((unused)) void *data)
15255 struct cmd_set_nvgre_result *res = parsed_result;
15257 uint32_t nvgre_tni;
15260 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15263 if (strcmp(res->nvgre, "nvgre") == 0)
15264 nvgre_encap_conf.select_vlan = 0;
15265 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15266 nvgre_encap_conf.select_vlan = 1;
15267 if (strcmp(res->ip_version, "ipv4") == 0)
15268 nvgre_encap_conf.select_ipv4 = 1;
15269 else if (strcmp(res->ip_version, "ipv6") == 0)
15270 nvgre_encap_conf.select_ipv4 = 0;
15273 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15274 if (nvgre_encap_conf.select_ipv4) {
15275 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15276 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15278 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15279 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15281 if (nvgre_encap_conf.select_vlan)
15282 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15283 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15285 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15289 cmdline_parse_inst_t cmd_set_nvgre = {
15290 .f = cmd_set_nvgre_parsed,
15292 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15293 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15294 " eth-dst <eth-dst>",
15296 (void *)&cmd_set_nvgre_set,
15297 (void *)&cmd_set_nvgre_nvgre,
15298 (void *)&cmd_set_nvgre_ip_version,
15299 (void *)&cmd_set_nvgre_ip_version_value,
15300 (void *)&cmd_set_nvgre_tni,
15301 (void *)&cmd_set_nvgre_tni_value,
15302 (void *)&cmd_set_nvgre_ip_src,
15303 (void *)&cmd_set_nvgre_ip_src_value,
15304 (void *)&cmd_set_nvgre_ip_dst,
15305 (void *)&cmd_set_nvgre_ip_dst_value,
15306 (void *)&cmd_set_nvgre_eth_src,
15307 (void *)&cmd_set_nvgre_eth_src_value,
15308 (void *)&cmd_set_nvgre_eth_dst,
15309 (void *)&cmd_set_nvgre_eth_dst_value,
15314 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15315 .f = cmd_set_nvgre_parsed,
15317 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15318 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15319 " eth-src <eth-src> eth-dst <eth-dst>",
15321 (void *)&cmd_set_nvgre_set,
15322 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15323 (void *)&cmd_set_nvgre_ip_version,
15324 (void *)&cmd_set_nvgre_ip_version_value,
15325 (void *)&cmd_set_nvgre_tni,
15326 (void *)&cmd_set_nvgre_tni_value,
15327 (void *)&cmd_set_nvgre_ip_src,
15328 (void *)&cmd_set_nvgre_ip_src_value,
15329 (void *)&cmd_set_nvgre_ip_dst,
15330 (void *)&cmd_set_nvgre_ip_dst_value,
15331 (void *)&cmd_set_nvgre_vlan,
15332 (void *)&cmd_set_nvgre_vlan_value,
15333 (void *)&cmd_set_nvgre_eth_src,
15334 (void *)&cmd_set_nvgre_eth_src_value,
15335 (void *)&cmd_set_nvgre_eth_dst,
15336 (void *)&cmd_set_nvgre_eth_dst_value,
15341 /** Set L2 encapsulation details */
15342 struct cmd_set_l2_encap_result {
15343 cmdline_fixed_string_t set;
15344 cmdline_fixed_string_t l2_encap;
15345 cmdline_fixed_string_t pos_token;
15346 cmdline_fixed_string_t ip_version;
15347 uint32_t vlan_present:1;
15349 struct ether_addr eth_src;
15350 struct ether_addr eth_dst;
15353 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15354 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15355 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15356 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15357 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15358 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15359 "l2_encap-with-vlan");
15360 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15361 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15363 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15364 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15366 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15367 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15369 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15370 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15371 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15372 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15374 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15375 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15376 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15377 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15379 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15380 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15382 static void cmd_set_l2_encap_parsed(void *parsed_result,
15383 __attribute__((unused)) struct cmdline *cl,
15384 __attribute__((unused)) void *data)
15386 struct cmd_set_l2_encap_result *res = parsed_result;
15388 if (strcmp(res->l2_encap, "l2_encap") == 0)
15389 l2_encap_conf.select_vlan = 0;
15390 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15391 l2_encap_conf.select_vlan = 1;
15392 if (strcmp(res->ip_version, "ipv4") == 0)
15393 l2_encap_conf.select_ipv4 = 1;
15394 else if (strcmp(res->ip_version, "ipv6") == 0)
15395 l2_encap_conf.select_ipv4 = 0;
15398 if (l2_encap_conf.select_vlan)
15399 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15400 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15402 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15406 cmdline_parse_inst_t cmd_set_l2_encap = {
15407 .f = cmd_set_l2_encap_parsed,
15409 .help_str = "set l2_encap ip-version ipv4|ipv6"
15410 " eth-src <eth-src> eth-dst <eth-dst>",
15412 (void *)&cmd_set_l2_encap_set,
15413 (void *)&cmd_set_l2_encap_l2_encap,
15414 (void *)&cmd_set_l2_encap_ip_version,
15415 (void *)&cmd_set_l2_encap_ip_version_value,
15416 (void *)&cmd_set_l2_encap_eth_src,
15417 (void *)&cmd_set_l2_encap_eth_src_value,
15418 (void *)&cmd_set_l2_encap_eth_dst,
15419 (void *)&cmd_set_l2_encap_eth_dst_value,
15424 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15425 .f = cmd_set_l2_encap_parsed,
15427 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15428 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15430 (void *)&cmd_set_l2_encap_set,
15431 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15432 (void *)&cmd_set_l2_encap_ip_version,
15433 (void *)&cmd_set_l2_encap_ip_version_value,
15434 (void *)&cmd_set_l2_encap_vlan,
15435 (void *)&cmd_set_l2_encap_vlan_value,
15436 (void *)&cmd_set_l2_encap_eth_src,
15437 (void *)&cmd_set_l2_encap_eth_src_value,
15438 (void *)&cmd_set_l2_encap_eth_dst,
15439 (void *)&cmd_set_l2_encap_eth_dst_value,
15444 /** Set L2 decapsulation details */
15445 struct cmd_set_l2_decap_result {
15446 cmdline_fixed_string_t set;
15447 cmdline_fixed_string_t l2_decap;
15448 cmdline_fixed_string_t pos_token;
15449 uint32_t vlan_present:1;
15452 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15453 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15454 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15455 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15457 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15458 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15459 "l2_decap-with-vlan");
15461 static void cmd_set_l2_decap_parsed(void *parsed_result,
15462 __attribute__((unused)) struct cmdline *cl,
15463 __attribute__((unused)) void *data)
15465 struct cmd_set_l2_decap_result *res = parsed_result;
15467 if (strcmp(res->l2_decap, "l2_decap") == 0)
15468 l2_decap_conf.select_vlan = 0;
15469 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15470 l2_decap_conf.select_vlan = 1;
15473 cmdline_parse_inst_t cmd_set_l2_decap = {
15474 .f = cmd_set_l2_decap_parsed,
15476 .help_str = "set l2_decap",
15478 (void *)&cmd_set_l2_decap_set,
15479 (void *)&cmd_set_l2_decap_l2_decap,
15484 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15485 .f = cmd_set_l2_decap_parsed,
15487 .help_str = "set l2_decap-with-vlan",
15489 (void *)&cmd_set_l2_decap_set,
15490 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15495 /** Set MPLSoGRE encapsulation details */
15496 struct cmd_set_mplsogre_encap_result {
15497 cmdline_fixed_string_t set;
15498 cmdline_fixed_string_t mplsogre;
15499 cmdline_fixed_string_t pos_token;
15500 cmdline_fixed_string_t ip_version;
15501 uint32_t vlan_present:1;
15503 cmdline_ipaddr_t ip_src;
15504 cmdline_ipaddr_t ip_dst;
15506 struct ether_addr eth_src;
15507 struct ether_addr eth_dst;
15510 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15511 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15513 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15514 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15516 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15517 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15518 mplsogre, "mplsogre_encap-with-vlan");
15519 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15520 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15521 pos_token, "ip-version");
15522 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15523 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15524 ip_version, "ipv4#ipv6");
15525 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15526 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15527 pos_token, "label");
15528 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15529 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15531 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15532 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15533 pos_token, "ip-src");
15534 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15535 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15536 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15537 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15538 pos_token, "ip-dst");
15539 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15540 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15541 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15542 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15543 pos_token, "vlan-tci");
15544 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15545 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15547 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15548 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15549 pos_token, "eth-src");
15550 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15551 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15553 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15554 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15555 pos_token, "eth-dst");
15556 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15557 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15560 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15561 __attribute__((unused)) struct cmdline *cl,
15562 __attribute__((unused)) void *data)
15564 struct cmd_set_mplsogre_encap_result *res = parsed_result;
15566 uint32_t mplsogre_label;
15570 rte_cpu_to_be_32(res->label) & RTE_BE32(0x00ffffff),
15573 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15574 mplsogre_encap_conf.select_vlan = 0;
15575 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15576 mplsogre_encap_conf.select_vlan = 1;
15577 if (strcmp(res->ip_version, "ipv4") == 0)
15578 mplsogre_encap_conf.select_ipv4 = 1;
15579 else if (strcmp(res->ip_version, "ipv6") == 0)
15580 mplsogre_encap_conf.select_ipv4 = 0;
15583 rte_memcpy(mplsogre_encap_conf.label, &id.label[1], 3);
15584 if (mplsogre_encap_conf.select_ipv4) {
15585 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15586 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15588 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15589 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15591 if (mplsogre_encap_conf.select_vlan)
15592 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15593 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15595 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15599 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15600 .f = cmd_set_mplsogre_encap_parsed,
15602 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15603 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15604 " eth-dst <eth-dst>",
15606 (void *)&cmd_set_mplsogre_encap_set,
15607 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15608 (void *)&cmd_set_mplsogre_encap_ip_version,
15609 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15610 (void *)&cmd_set_mplsogre_encap_label,
15611 (void *)&cmd_set_mplsogre_encap_label_value,
15612 (void *)&cmd_set_mplsogre_encap_ip_src,
15613 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15614 (void *)&cmd_set_mplsogre_encap_ip_dst,
15615 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15616 (void *)&cmd_set_mplsogre_encap_eth_src,
15617 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15618 (void *)&cmd_set_mplsogre_encap_eth_dst,
15619 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15624 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
15625 .f = cmd_set_mplsogre_encap_parsed,
15627 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
15628 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
15629 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15631 (void *)&cmd_set_mplsogre_encap_set,
15632 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
15633 (void *)&cmd_set_mplsogre_encap_ip_version,
15634 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15635 (void *)&cmd_set_mplsogre_encap_label,
15636 (void *)&cmd_set_mplsogre_encap_label_value,
15637 (void *)&cmd_set_mplsogre_encap_ip_src,
15638 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15639 (void *)&cmd_set_mplsogre_encap_ip_dst,
15640 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15641 (void *)&cmd_set_mplsogre_encap_vlan,
15642 (void *)&cmd_set_mplsogre_encap_vlan_value,
15643 (void *)&cmd_set_mplsogre_encap_eth_src,
15644 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15645 (void *)&cmd_set_mplsogre_encap_eth_dst,
15646 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15651 /** Set MPLSoGRE decapsulation details */
15652 struct cmd_set_mplsogre_decap_result {
15653 cmdline_fixed_string_t set;
15654 cmdline_fixed_string_t mplsogre;
15655 cmdline_fixed_string_t pos_token;
15656 cmdline_fixed_string_t ip_version;
15657 uint32_t vlan_present:1;
15660 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
15661 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
15663 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
15664 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
15666 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
15667 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15668 mplsogre, "mplsogre_decap-with-vlan");
15669 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
15670 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15671 pos_token, "ip-version");
15672 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
15673 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15674 ip_version, "ipv4#ipv6");
15676 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
15677 __attribute__((unused)) struct cmdline *cl,
15678 __attribute__((unused)) void *data)
15680 struct cmd_set_mplsogre_decap_result *res = parsed_result;
15682 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
15683 mplsogre_decap_conf.select_vlan = 0;
15684 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
15685 mplsogre_decap_conf.select_vlan = 1;
15686 if (strcmp(res->ip_version, "ipv4") == 0)
15687 mplsogre_decap_conf.select_ipv4 = 1;
15688 else if (strcmp(res->ip_version, "ipv6") == 0)
15689 mplsogre_decap_conf.select_ipv4 = 0;
15692 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
15693 .f = cmd_set_mplsogre_decap_parsed,
15695 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
15697 (void *)&cmd_set_mplsogre_decap_set,
15698 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
15699 (void *)&cmd_set_mplsogre_decap_ip_version,
15700 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15705 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
15706 .f = cmd_set_mplsogre_decap_parsed,
15708 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
15710 (void *)&cmd_set_mplsogre_decap_set,
15711 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
15712 (void *)&cmd_set_mplsogre_decap_ip_version,
15713 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15718 /** Set MPLSoUDP encapsulation details */
15719 struct cmd_set_mplsoudp_encap_result {
15720 cmdline_fixed_string_t set;
15721 cmdline_fixed_string_t mplsoudp;
15722 cmdline_fixed_string_t pos_token;
15723 cmdline_fixed_string_t ip_version;
15724 uint32_t vlan_present:1;
15728 cmdline_ipaddr_t ip_src;
15729 cmdline_ipaddr_t ip_dst;
15731 struct ether_addr eth_src;
15732 struct ether_addr eth_dst;
15735 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
15736 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
15738 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
15739 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
15741 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
15742 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15743 mplsoudp, "mplsoudp_encap-with-vlan");
15744 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
15745 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15746 pos_token, "ip-version");
15747 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
15748 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15749 ip_version, "ipv4#ipv6");
15750 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
15751 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15752 pos_token, "label");
15753 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
15754 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
15756 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
15757 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15758 pos_token, "udp-src");
15759 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
15760 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
15762 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
15763 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15764 pos_token, "udp-dst");
15765 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
15766 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
15768 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
15769 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15770 pos_token, "ip-src");
15771 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
15772 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
15773 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
15774 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15775 pos_token, "ip-dst");
15776 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
15777 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
15778 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
15779 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15780 pos_token, "vlan-tci");
15781 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
15782 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
15784 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
15785 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15786 pos_token, "eth-src");
15787 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
15788 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15790 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
15791 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15792 pos_token, "eth-dst");
15793 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
15794 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15797 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
15798 __attribute__((unused)) struct cmdline *cl,
15799 __attribute__((unused)) void *data)
15801 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
15803 uint32_t mplsoudp_label;
15807 rte_cpu_to_be_32(res->label) & RTE_BE32(0x00ffffff),
15810 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
15811 mplsoudp_encap_conf.select_vlan = 0;
15812 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
15813 mplsoudp_encap_conf.select_vlan = 1;
15814 if (strcmp(res->ip_version, "ipv4") == 0)
15815 mplsoudp_encap_conf.select_ipv4 = 1;
15816 else if (strcmp(res->ip_version, "ipv6") == 0)
15817 mplsoudp_encap_conf.select_ipv4 = 0;
15820 rte_memcpy(mplsoudp_encap_conf.label, &id.label[1], 3);
15821 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15822 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15823 if (mplsoudp_encap_conf.select_ipv4) {
15824 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
15825 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
15827 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
15828 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
15830 if (mplsoudp_encap_conf.select_vlan)
15831 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15832 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
15834 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15838 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
15839 .f = cmd_set_mplsoudp_encap_parsed,
15841 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
15842 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
15843 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
15845 (void *)&cmd_set_mplsoudp_encap_set,
15846 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
15847 (void *)&cmd_set_mplsoudp_encap_ip_version,
15848 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
15849 (void *)&cmd_set_mplsoudp_encap_label,
15850 (void *)&cmd_set_mplsoudp_encap_label_value,
15851 (void *)&cmd_set_mplsoudp_encap_udp_src,
15852 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
15853 (void *)&cmd_set_mplsoudp_encap_udp_dst,
15854 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
15855 (void *)&cmd_set_mplsoudp_encap_ip_src,
15856 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
15857 (void *)&cmd_set_mplsoudp_encap_ip_dst,
15858 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
15859 (void *)&cmd_set_mplsoudp_encap_eth_src,
15860 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
15861 (void *)&cmd_set_mplsoudp_encap_eth_dst,
15862 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
15867 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
15868 .f = cmd_set_mplsoudp_encap_parsed,
15870 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
15871 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
15872 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15873 " eth-src <eth-src> eth-dst <eth-dst>",
15875 (void *)&cmd_set_mplsoudp_encap_set,
15876 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
15877 (void *)&cmd_set_mplsoudp_encap_ip_version,
15878 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
15879 (void *)&cmd_set_mplsoudp_encap_label,
15880 (void *)&cmd_set_mplsoudp_encap_label_value,
15881 (void *)&cmd_set_mplsoudp_encap_udp_src,
15882 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
15883 (void *)&cmd_set_mplsoudp_encap_udp_dst,
15884 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
15885 (void *)&cmd_set_mplsoudp_encap_ip_src,
15886 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
15887 (void *)&cmd_set_mplsoudp_encap_ip_dst,
15888 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
15889 (void *)&cmd_set_mplsoudp_encap_vlan,
15890 (void *)&cmd_set_mplsoudp_encap_vlan_value,
15891 (void *)&cmd_set_mplsoudp_encap_eth_src,
15892 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
15893 (void *)&cmd_set_mplsoudp_encap_eth_dst,
15894 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
15899 /** Set MPLSoUDP decapsulation details */
15900 struct cmd_set_mplsoudp_decap_result {
15901 cmdline_fixed_string_t set;
15902 cmdline_fixed_string_t mplsoudp;
15903 cmdline_fixed_string_t pos_token;
15904 cmdline_fixed_string_t ip_version;
15905 uint32_t vlan_present:1;
15908 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
15909 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
15911 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
15912 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
15914 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
15915 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
15916 mplsoudp, "mplsoudp_decap-with-vlan");
15917 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
15918 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
15919 pos_token, "ip-version");
15920 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
15921 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
15922 ip_version, "ipv4#ipv6");
15924 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
15925 __attribute__((unused)) struct cmdline *cl,
15926 __attribute__((unused)) void *data)
15928 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
15930 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
15931 mplsoudp_decap_conf.select_vlan = 0;
15932 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
15933 mplsoudp_decap_conf.select_vlan = 1;
15934 if (strcmp(res->ip_version, "ipv4") == 0)
15935 mplsoudp_decap_conf.select_ipv4 = 1;
15936 else if (strcmp(res->ip_version, "ipv6") == 0)
15937 mplsoudp_decap_conf.select_ipv4 = 0;
15940 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
15941 .f = cmd_set_mplsoudp_decap_parsed,
15943 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
15945 (void *)&cmd_set_mplsoudp_decap_set,
15946 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
15947 (void *)&cmd_set_mplsoudp_decap_ip_version,
15948 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
15953 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
15954 .f = cmd_set_mplsoudp_decap_parsed,
15956 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
15958 (void *)&cmd_set_mplsoudp_decap_set,
15959 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
15960 (void *)&cmd_set_mplsoudp_decap_ip_version,
15961 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
15966 /* Strict link priority scheduling mode setting */
15968 cmd_strict_link_prio_parsed(
15969 void *parsed_result,
15970 __attribute__((unused)) struct cmdline *cl,
15971 __attribute__((unused)) void *data)
15973 struct cmd_vf_tc_bw_result *res = parsed_result;
15974 int ret = -ENOTSUP;
15976 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15979 #ifdef RTE_LIBRTE_I40E_PMD
15980 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
15987 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
15990 printf("invalid port_id %d\n", res->port_id);
15993 printf("function not implemented\n");
15996 printf("programming error: (%s)\n", strerror(-ret));
16000 cmdline_parse_inst_t cmd_strict_link_prio = {
16001 .f = cmd_strict_link_prio_parsed,
16003 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16005 (void *)&cmd_vf_tc_bw_set,
16006 (void *)&cmd_vf_tc_bw_tx,
16007 (void *)&cmd_vf_tc_bw_strict_link_prio,
16008 (void *)&cmd_vf_tc_bw_port_id,
16009 (void *)&cmd_vf_tc_bw_tc_map,
16014 /* Load dynamic device personalization*/
16015 struct cmd_ddp_add_result {
16016 cmdline_fixed_string_t ddp;
16017 cmdline_fixed_string_t add;
16022 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16023 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16024 cmdline_parse_token_string_t cmd_ddp_add_add =
16025 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16026 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16027 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16028 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16029 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16032 cmd_ddp_add_parsed(
16033 void *parsed_result,
16034 __attribute__((unused)) struct cmdline *cl,
16035 __attribute__((unused)) void *data)
16037 struct cmd_ddp_add_result *res = parsed_result;
16043 int ret = -ENOTSUP;
16045 if (!all_ports_stopped()) {
16046 printf("Please stop all ports first\n");
16050 filepath = strdup(res->filepath);
16051 if (filepath == NULL) {
16052 printf("Failed to allocate memory\n");
16055 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16057 buff = open_file(file_fld[0], &size);
16059 free((void *)filepath);
16063 #ifdef RTE_LIBRTE_I40E_PMD
16064 if (ret == -ENOTSUP)
16065 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16067 RTE_PMD_I40E_PKG_OP_WR_ADD);
16070 if (ret == -EEXIST)
16071 printf("Profile has already existed.\n");
16073 printf("Failed to load profile.\n");
16074 else if (file_num == 2)
16075 save_file(file_fld[1], buff, size);
16078 free((void *)filepath);
16081 cmdline_parse_inst_t cmd_ddp_add = {
16082 .f = cmd_ddp_add_parsed,
16084 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16086 (void *)&cmd_ddp_add_ddp,
16087 (void *)&cmd_ddp_add_add,
16088 (void *)&cmd_ddp_add_port_id,
16089 (void *)&cmd_ddp_add_filepath,
16094 /* Delete dynamic device personalization*/
16095 struct cmd_ddp_del_result {
16096 cmdline_fixed_string_t ddp;
16097 cmdline_fixed_string_t del;
16102 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16103 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16104 cmdline_parse_token_string_t cmd_ddp_del_del =
16105 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16106 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16107 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16108 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16109 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16112 cmd_ddp_del_parsed(
16113 void *parsed_result,
16114 __attribute__((unused)) struct cmdline *cl,
16115 __attribute__((unused)) void *data)
16117 struct cmd_ddp_del_result *res = parsed_result;
16120 int ret = -ENOTSUP;
16122 if (!all_ports_stopped()) {
16123 printf("Please stop all ports first\n");
16127 buff = open_file(res->filepath, &size);
16131 #ifdef RTE_LIBRTE_I40E_PMD
16132 if (ret == -ENOTSUP)
16133 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16135 RTE_PMD_I40E_PKG_OP_WR_DEL);
16138 if (ret == -EACCES)
16139 printf("Profile does not exist.\n");
16141 printf("Failed to delete profile.\n");
16146 cmdline_parse_inst_t cmd_ddp_del = {
16147 .f = cmd_ddp_del_parsed,
16149 .help_str = "ddp del <port_id> <backup_profile_path>",
16151 (void *)&cmd_ddp_del_ddp,
16152 (void *)&cmd_ddp_del_del,
16153 (void *)&cmd_ddp_del_port_id,
16154 (void *)&cmd_ddp_del_filepath,
16159 /* Get dynamic device personalization profile info */
16160 struct cmd_ddp_info_result {
16161 cmdline_fixed_string_t ddp;
16162 cmdline_fixed_string_t get;
16163 cmdline_fixed_string_t info;
16167 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16168 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16169 cmdline_parse_token_string_t cmd_ddp_info_get =
16170 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16171 cmdline_parse_token_string_t cmd_ddp_info_info =
16172 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16173 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16174 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16177 cmd_ddp_info_parsed(
16178 void *parsed_result,
16179 __attribute__((unused)) struct cmdline *cl,
16180 __attribute__((unused)) void *data)
16182 struct cmd_ddp_info_result *res = parsed_result;
16185 int ret = -ENOTSUP;
16186 #ifdef RTE_LIBRTE_I40E_PMD
16189 uint32_t buff_size = 0;
16190 struct rte_pmd_i40e_profile_info info;
16191 uint32_t dev_num = 0;
16192 struct rte_pmd_i40e_ddp_device_id *devs;
16193 uint32_t proto_num = 0;
16194 struct rte_pmd_i40e_proto_info *proto = NULL;
16195 uint32_t pctype_num = 0;
16196 struct rte_pmd_i40e_ptype_info *pctype;
16197 uint32_t ptype_num = 0;
16198 struct rte_pmd_i40e_ptype_info *ptype;
16203 pkg = open_file(res->filepath, &pkg_size);
16207 #ifdef RTE_LIBRTE_I40E_PMD
16208 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16209 (uint8_t *)&info, sizeof(info),
16210 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16212 printf("Global Track id: 0x%x\n", info.track_id);
16213 printf("Global Version: %d.%d.%d.%d\n",
16214 info.version.major,
16215 info.version.minor,
16216 info.version.update,
16217 info.version.draft);
16218 printf("Global Package name: %s\n\n", info.name);
16221 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16222 (uint8_t *)&info, sizeof(info),
16223 RTE_PMD_I40E_PKG_INFO_HEADER);
16225 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16226 printf("i40e Profile Version: %d.%d.%d.%d\n",
16227 info.version.major,
16228 info.version.minor,
16229 info.version.update,
16230 info.version.draft);
16231 printf("i40e Profile name: %s\n\n", info.name);
16234 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16235 (uint8_t *)&buff_size, sizeof(buff_size),
16236 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16237 if (!ret && buff_size) {
16238 buff = (uint8_t *)malloc(buff_size);
16240 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16242 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16244 printf("Package Notes:\n%s\n\n", buff);
16249 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16250 (uint8_t *)&dev_num, sizeof(dev_num),
16251 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16252 if (!ret && dev_num) {
16253 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16254 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16256 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16257 (uint8_t *)devs, buff_size,
16258 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16260 printf("List of supported devices:\n");
16261 for (i = 0; i < dev_num; i++) {
16262 printf(" %04X:%04X %04X:%04X\n",
16263 devs[i].vendor_dev_id >> 16,
16264 devs[i].vendor_dev_id & 0xFFFF,
16265 devs[i].sub_vendor_dev_id >> 16,
16266 devs[i].sub_vendor_dev_id & 0xFFFF);
16274 /* get information about protocols and packet types */
16275 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16276 (uint8_t *)&proto_num, sizeof(proto_num),
16277 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16278 if (ret || !proto_num)
16279 goto no_print_return;
16281 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16282 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16284 goto no_print_return;
16286 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16288 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16290 printf("List of used protocols:\n");
16291 for (i = 0; i < proto_num; i++)
16292 printf(" %2u: %s\n", proto[i].proto_id,
16296 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16297 (uint8_t *)&pctype_num, sizeof(pctype_num),
16298 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16299 if (ret || !pctype_num)
16300 goto no_print_pctypes;
16302 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16303 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16305 goto no_print_pctypes;
16307 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16309 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16312 goto no_print_pctypes;
16315 printf("List of defined packet classification types:\n");
16316 for (i = 0; i < pctype_num; i++) {
16317 printf(" %2u:", pctype[i].ptype_id);
16318 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16319 proto_id = pctype[i].protocols[j];
16320 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16321 for (n = 0; n < proto_num; n++) {
16322 if (proto[n].proto_id == proto_id) {
16323 printf(" %s", proto[n].name);
16336 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16338 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16339 if (ret || !ptype_num)
16340 goto no_print_return;
16342 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16343 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16345 goto no_print_return;
16347 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16349 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16352 goto no_print_return;
16354 printf("List of defined packet types:\n");
16355 for (i = 0; i < ptype_num; i++) {
16356 printf(" %2u:", ptype[i].ptype_id);
16357 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16358 proto_id = ptype[i].protocols[j];
16359 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16360 for (n = 0; n < proto_num; n++) {
16361 if (proto[n].proto_id == proto_id) {
16362 printf(" %s", proto[n].name);
16378 if (ret == -ENOTSUP)
16379 printf("Function not supported in PMD driver\n");
16383 cmdline_parse_inst_t cmd_ddp_get_info = {
16384 .f = cmd_ddp_info_parsed,
16386 .help_str = "ddp get info <profile_path>",
16388 (void *)&cmd_ddp_info_ddp,
16389 (void *)&cmd_ddp_info_get,
16390 (void *)&cmd_ddp_info_info,
16391 (void *)&cmd_ddp_info_filepath,
16396 /* Get dynamic device personalization profile info list*/
16397 #define PROFILE_INFO_SIZE 48
16398 #define MAX_PROFILE_NUM 16
16400 struct cmd_ddp_get_list_result {
16401 cmdline_fixed_string_t ddp;
16402 cmdline_fixed_string_t get;
16403 cmdline_fixed_string_t list;
16407 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16408 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16409 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16410 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16411 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16412 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16413 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16414 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16417 cmd_ddp_get_list_parsed(
16418 __attribute__((unused)) void *parsed_result,
16419 __attribute__((unused)) struct cmdline *cl,
16420 __attribute__((unused)) void *data)
16422 #ifdef RTE_LIBRTE_I40E_PMD
16423 struct cmd_ddp_get_list_result *res = parsed_result;
16424 struct rte_pmd_i40e_profile_list *p_list;
16425 struct rte_pmd_i40e_profile_info *p_info;
16430 int ret = -ENOTSUP;
16432 #ifdef RTE_LIBRTE_I40E_PMD
16433 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16434 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16436 printf("%s: Failed to malloc buffer\n", __func__);
16438 if (ret == -ENOTSUP)
16439 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16440 (uint8_t *)p_list, size);
16443 p_num = p_list->p_count;
16444 printf("Profile number is: %d\n\n", p_num);
16446 for (i = 0; i < p_num; i++) {
16447 p_info = &p_list->p_info[i];
16448 printf("Profile %d:\n", i);
16449 printf("Track id: 0x%x\n", p_info->track_id);
16450 printf("Version: %d.%d.%d.%d\n",
16451 p_info->version.major,
16452 p_info->version.minor,
16453 p_info->version.update,
16454 p_info->version.draft);
16455 printf("Profile name: %s\n\n", p_info->name);
16463 printf("Failed to get ddp list\n");
16466 cmdline_parse_inst_t cmd_ddp_get_list = {
16467 .f = cmd_ddp_get_list_parsed,
16469 .help_str = "ddp get list <port_id>",
16471 (void *)&cmd_ddp_get_list_ddp,
16472 (void *)&cmd_ddp_get_list_get,
16473 (void *)&cmd_ddp_get_list_list,
16474 (void *)&cmd_ddp_get_list_port_id,
16479 /* Configure input set */
16480 struct cmd_cfg_input_set_result {
16481 cmdline_fixed_string_t port;
16482 cmdline_fixed_string_t cfg;
16484 cmdline_fixed_string_t pctype;
16486 cmdline_fixed_string_t inset_type;
16487 cmdline_fixed_string_t opt;
16488 cmdline_fixed_string_t field;
16493 cmd_cfg_input_set_parsed(
16494 __attribute__((unused)) void *parsed_result,
16495 __attribute__((unused)) struct cmdline *cl,
16496 __attribute__((unused)) void *data)
16498 #ifdef RTE_LIBRTE_I40E_PMD
16499 struct cmd_cfg_input_set_result *res = parsed_result;
16500 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16501 struct rte_pmd_i40e_inset inset;
16503 int ret = -ENOTSUP;
16505 if (!all_ports_stopped()) {
16506 printf("Please stop all ports first\n");
16510 #ifdef RTE_LIBRTE_I40E_PMD
16511 if (!strcmp(res->inset_type, "hash_inset"))
16512 inset_type = INSET_HASH;
16513 else if (!strcmp(res->inset_type, "fdir_inset"))
16514 inset_type = INSET_FDIR;
16515 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16516 inset_type = INSET_FDIR_FLX;
16517 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16518 &inset, inset_type);
16520 printf("Failed to get input set.\n");
16524 if (!strcmp(res->opt, "get")) {
16525 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16528 printf("Field index %d is enabled.\n", res->field_idx);
16530 printf("Field index %d is disabled.\n", res->field_idx);
16532 } else if (!strcmp(res->opt, "set"))
16533 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16535 else if (!strcmp(res->opt, "clear"))
16536 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16539 printf("Failed to configure input set field.\n");
16543 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16544 &inset, inset_type);
16546 printf("Failed to set input set.\n");
16551 if (ret == -ENOTSUP)
16552 printf("Function not supported\n");
16555 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16556 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16558 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16559 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16561 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16562 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16564 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16565 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16567 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16568 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16570 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16571 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16573 "hash_inset#fdir_inset#fdir_flx_inset");
16574 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16575 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16576 opt, "get#set#clear");
16577 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16578 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16580 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16581 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16584 cmdline_parse_inst_t cmd_cfg_input_set = {
16585 .f = cmd_cfg_input_set_parsed,
16587 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16588 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16590 (void *)&cmd_cfg_input_set_port,
16591 (void *)&cmd_cfg_input_set_cfg,
16592 (void *)&cmd_cfg_input_set_port_id,
16593 (void *)&cmd_cfg_input_set_pctype,
16594 (void *)&cmd_cfg_input_set_pctype_id,
16595 (void *)&cmd_cfg_input_set_inset_type,
16596 (void *)&cmd_cfg_input_set_opt,
16597 (void *)&cmd_cfg_input_set_field,
16598 (void *)&cmd_cfg_input_set_field_idx,
16603 /* Clear input set */
16604 struct cmd_clear_input_set_result {
16605 cmdline_fixed_string_t port;
16606 cmdline_fixed_string_t cfg;
16608 cmdline_fixed_string_t pctype;
16610 cmdline_fixed_string_t inset_type;
16611 cmdline_fixed_string_t clear;
16612 cmdline_fixed_string_t all;
16616 cmd_clear_input_set_parsed(
16617 __attribute__((unused)) void *parsed_result,
16618 __attribute__((unused)) struct cmdline *cl,
16619 __attribute__((unused)) void *data)
16621 #ifdef RTE_LIBRTE_I40E_PMD
16622 struct cmd_clear_input_set_result *res = parsed_result;
16623 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16624 struct rte_pmd_i40e_inset inset;
16626 int ret = -ENOTSUP;
16628 if (!all_ports_stopped()) {
16629 printf("Please stop all ports first\n");
16633 #ifdef RTE_LIBRTE_I40E_PMD
16634 if (!strcmp(res->inset_type, "hash_inset"))
16635 inset_type = INSET_HASH;
16636 else if (!strcmp(res->inset_type, "fdir_inset"))
16637 inset_type = INSET_FDIR;
16638 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16639 inset_type = INSET_FDIR_FLX;
16641 memset(&inset, 0, sizeof(inset));
16643 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16644 &inset, inset_type);
16646 printf("Failed to clear input set.\n");
16652 if (ret == -ENOTSUP)
16653 printf("Function not supported\n");
16656 cmdline_parse_token_string_t cmd_clear_input_set_port =
16657 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16659 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
16660 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16662 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
16663 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16665 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
16666 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16668 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
16669 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16671 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
16672 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16674 "hash_inset#fdir_inset#fdir_flx_inset");
16675 cmdline_parse_token_string_t cmd_clear_input_set_clear =
16676 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16678 cmdline_parse_token_string_t cmd_clear_input_set_all =
16679 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16682 cmdline_parse_inst_t cmd_clear_input_set = {
16683 .f = cmd_clear_input_set_parsed,
16685 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16686 "fdir_inset|fdir_flx_inset clear all",
16688 (void *)&cmd_clear_input_set_port,
16689 (void *)&cmd_clear_input_set_cfg,
16690 (void *)&cmd_clear_input_set_port_id,
16691 (void *)&cmd_clear_input_set_pctype,
16692 (void *)&cmd_clear_input_set_pctype_id,
16693 (void *)&cmd_clear_input_set_inset_type,
16694 (void *)&cmd_clear_input_set_clear,
16695 (void *)&cmd_clear_input_set_all,
16700 /* show vf stats */
16702 /* Common result structure for show vf stats */
16703 struct cmd_show_vf_stats_result {
16704 cmdline_fixed_string_t show;
16705 cmdline_fixed_string_t vf;
16706 cmdline_fixed_string_t stats;
16711 /* Common CLI fields show vf stats*/
16712 cmdline_parse_token_string_t cmd_show_vf_stats_show =
16713 TOKEN_STRING_INITIALIZER
16714 (struct cmd_show_vf_stats_result,
16716 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
16717 TOKEN_STRING_INITIALIZER
16718 (struct cmd_show_vf_stats_result,
16720 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
16721 TOKEN_STRING_INITIALIZER
16722 (struct cmd_show_vf_stats_result,
16724 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
16725 TOKEN_NUM_INITIALIZER
16726 (struct cmd_show_vf_stats_result,
16728 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
16729 TOKEN_NUM_INITIALIZER
16730 (struct cmd_show_vf_stats_result,
16734 cmd_show_vf_stats_parsed(
16735 void *parsed_result,
16736 __attribute__((unused)) struct cmdline *cl,
16737 __attribute__((unused)) void *data)
16739 struct cmd_show_vf_stats_result *res = parsed_result;
16740 struct rte_eth_stats stats;
16741 int ret = -ENOTSUP;
16742 static const char *nic_stats_border = "########################";
16744 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16747 memset(&stats, 0, sizeof(stats));
16749 #ifdef RTE_LIBRTE_I40E_PMD
16750 if (ret == -ENOTSUP)
16751 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
16755 #ifdef RTE_LIBRTE_BNXT_PMD
16756 if (ret == -ENOTSUP)
16757 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
16766 printf("invalid vf_id %d\n", res->vf_id);
16769 printf("invalid port_id %d\n", res->port_id);
16772 printf("function not implemented\n");
16775 printf("programming error: (%s)\n", strerror(-ret));
16778 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
16779 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
16781 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
16783 stats.ipackets, stats.imissed, stats.ibytes);
16784 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
16785 printf(" RX-nombuf: %-10"PRIu64"\n",
16787 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
16789 stats.opackets, stats.oerrors, stats.obytes);
16791 printf(" %s############################%s\n",
16792 nic_stats_border, nic_stats_border);
16795 cmdline_parse_inst_t cmd_show_vf_stats = {
16796 .f = cmd_show_vf_stats_parsed,
16798 .help_str = "show vf stats <port_id> <vf_id>",
16800 (void *)&cmd_show_vf_stats_show,
16801 (void *)&cmd_show_vf_stats_vf,
16802 (void *)&cmd_show_vf_stats_stats,
16803 (void *)&cmd_show_vf_stats_port_id,
16804 (void *)&cmd_show_vf_stats_vf_id,
16809 /* clear vf stats */
16811 /* Common result structure for clear vf stats */
16812 struct cmd_clear_vf_stats_result {
16813 cmdline_fixed_string_t clear;
16814 cmdline_fixed_string_t vf;
16815 cmdline_fixed_string_t stats;
16820 /* Common CLI fields clear vf stats*/
16821 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
16822 TOKEN_STRING_INITIALIZER
16823 (struct cmd_clear_vf_stats_result,
16825 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
16826 TOKEN_STRING_INITIALIZER
16827 (struct cmd_clear_vf_stats_result,
16829 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
16830 TOKEN_STRING_INITIALIZER
16831 (struct cmd_clear_vf_stats_result,
16833 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
16834 TOKEN_NUM_INITIALIZER
16835 (struct cmd_clear_vf_stats_result,
16837 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
16838 TOKEN_NUM_INITIALIZER
16839 (struct cmd_clear_vf_stats_result,
16843 cmd_clear_vf_stats_parsed(
16844 void *parsed_result,
16845 __attribute__((unused)) struct cmdline *cl,
16846 __attribute__((unused)) void *data)
16848 struct cmd_clear_vf_stats_result *res = parsed_result;
16849 int ret = -ENOTSUP;
16851 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16854 #ifdef RTE_LIBRTE_I40E_PMD
16855 if (ret == -ENOTSUP)
16856 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
16859 #ifdef RTE_LIBRTE_BNXT_PMD
16860 if (ret == -ENOTSUP)
16861 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
16869 printf("invalid vf_id %d\n", res->vf_id);
16872 printf("invalid port_id %d\n", res->port_id);
16875 printf("function not implemented\n");
16878 printf("programming error: (%s)\n", strerror(-ret));
16882 cmdline_parse_inst_t cmd_clear_vf_stats = {
16883 .f = cmd_clear_vf_stats_parsed,
16885 .help_str = "clear vf stats <port_id> <vf_id>",
16887 (void *)&cmd_clear_vf_stats_clear,
16888 (void *)&cmd_clear_vf_stats_vf,
16889 (void *)&cmd_clear_vf_stats_stats,
16890 (void *)&cmd_clear_vf_stats_port_id,
16891 (void *)&cmd_clear_vf_stats_vf_id,
16896 /* port config pctype mapping reset */
16898 /* Common result structure for port config pctype mapping reset */
16899 struct cmd_pctype_mapping_reset_result {
16900 cmdline_fixed_string_t port;
16901 cmdline_fixed_string_t config;
16903 cmdline_fixed_string_t pctype;
16904 cmdline_fixed_string_t mapping;
16905 cmdline_fixed_string_t reset;
16908 /* Common CLI fields for port config pctype mapping reset*/
16909 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
16910 TOKEN_STRING_INITIALIZER
16911 (struct cmd_pctype_mapping_reset_result,
16913 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
16914 TOKEN_STRING_INITIALIZER
16915 (struct cmd_pctype_mapping_reset_result,
16917 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
16918 TOKEN_NUM_INITIALIZER
16919 (struct cmd_pctype_mapping_reset_result,
16921 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
16922 TOKEN_STRING_INITIALIZER
16923 (struct cmd_pctype_mapping_reset_result,
16925 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
16926 TOKEN_STRING_INITIALIZER
16927 (struct cmd_pctype_mapping_reset_result,
16928 mapping, "mapping");
16929 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
16930 TOKEN_STRING_INITIALIZER
16931 (struct cmd_pctype_mapping_reset_result,
16935 cmd_pctype_mapping_reset_parsed(
16936 void *parsed_result,
16937 __attribute__((unused)) struct cmdline *cl,
16938 __attribute__((unused)) void *data)
16940 struct cmd_pctype_mapping_reset_result *res = parsed_result;
16941 int ret = -ENOTSUP;
16943 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16946 #ifdef RTE_LIBRTE_I40E_PMD
16947 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
16954 printf("invalid port_id %d\n", res->port_id);
16957 printf("function not implemented\n");
16960 printf("programming error: (%s)\n", strerror(-ret));
16964 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
16965 .f = cmd_pctype_mapping_reset_parsed,
16967 .help_str = "port config <port_id> pctype mapping reset",
16969 (void *)&cmd_pctype_mapping_reset_port,
16970 (void *)&cmd_pctype_mapping_reset_config,
16971 (void *)&cmd_pctype_mapping_reset_port_id,
16972 (void *)&cmd_pctype_mapping_reset_pctype,
16973 (void *)&cmd_pctype_mapping_reset_mapping,
16974 (void *)&cmd_pctype_mapping_reset_reset,
16979 /* show port pctype mapping */
16981 /* Common result structure for show port pctype mapping */
16982 struct cmd_pctype_mapping_get_result {
16983 cmdline_fixed_string_t show;
16984 cmdline_fixed_string_t port;
16986 cmdline_fixed_string_t pctype;
16987 cmdline_fixed_string_t mapping;
16990 /* Common CLI fields for pctype mapping get */
16991 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
16992 TOKEN_STRING_INITIALIZER
16993 (struct cmd_pctype_mapping_get_result,
16995 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
16996 TOKEN_STRING_INITIALIZER
16997 (struct cmd_pctype_mapping_get_result,
16999 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17000 TOKEN_NUM_INITIALIZER
17001 (struct cmd_pctype_mapping_get_result,
17003 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17004 TOKEN_STRING_INITIALIZER
17005 (struct cmd_pctype_mapping_get_result,
17007 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17008 TOKEN_STRING_INITIALIZER
17009 (struct cmd_pctype_mapping_get_result,
17010 mapping, "mapping");
17013 cmd_pctype_mapping_get_parsed(
17014 void *parsed_result,
17015 __attribute__((unused)) struct cmdline *cl,
17016 __attribute__((unused)) void *data)
17018 struct cmd_pctype_mapping_get_result *res = parsed_result;
17019 int ret = -ENOTSUP;
17020 #ifdef RTE_LIBRTE_I40E_PMD
17021 struct rte_pmd_i40e_flow_type_mapping
17022 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17023 int i, j, first_pctype;
17026 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17029 #ifdef RTE_LIBRTE_I40E_PMD
17030 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17037 printf("invalid port_id %d\n", res->port_id);
17040 printf("function not implemented\n");
17043 printf("programming error: (%s)\n", strerror(-ret));
17047 #ifdef RTE_LIBRTE_I40E_PMD
17048 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17049 if (mapping[i].pctype != 0ULL) {
17052 printf("pctype: ");
17053 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17054 if (mapping[i].pctype & (1ULL << j)) {
17055 printf(first_pctype ?
17056 "%02d" : ",%02d", j);
17060 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17066 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17067 .f = cmd_pctype_mapping_get_parsed,
17069 .help_str = "show port <port_id> pctype mapping",
17071 (void *)&cmd_pctype_mapping_get_show,
17072 (void *)&cmd_pctype_mapping_get_port,
17073 (void *)&cmd_pctype_mapping_get_port_id,
17074 (void *)&cmd_pctype_mapping_get_pctype,
17075 (void *)&cmd_pctype_mapping_get_mapping,
17080 /* port config pctype mapping update */
17082 /* Common result structure for port config pctype mapping update */
17083 struct cmd_pctype_mapping_update_result {
17084 cmdline_fixed_string_t port;
17085 cmdline_fixed_string_t config;
17087 cmdline_fixed_string_t pctype;
17088 cmdline_fixed_string_t mapping;
17089 cmdline_fixed_string_t update;
17090 cmdline_fixed_string_t pctype_list;
17091 uint16_t flow_type;
17094 /* Common CLI fields for pctype mapping update*/
17095 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17096 TOKEN_STRING_INITIALIZER
17097 (struct cmd_pctype_mapping_update_result,
17099 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17100 TOKEN_STRING_INITIALIZER
17101 (struct cmd_pctype_mapping_update_result,
17103 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17104 TOKEN_NUM_INITIALIZER
17105 (struct cmd_pctype_mapping_update_result,
17107 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17108 TOKEN_STRING_INITIALIZER
17109 (struct cmd_pctype_mapping_update_result,
17111 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17112 TOKEN_STRING_INITIALIZER
17113 (struct cmd_pctype_mapping_update_result,
17114 mapping, "mapping");
17115 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17116 TOKEN_STRING_INITIALIZER
17117 (struct cmd_pctype_mapping_update_result,
17119 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17120 TOKEN_STRING_INITIALIZER
17121 (struct cmd_pctype_mapping_update_result,
17122 pctype_list, NULL);
17123 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17124 TOKEN_NUM_INITIALIZER
17125 (struct cmd_pctype_mapping_update_result,
17126 flow_type, UINT16);
17129 cmd_pctype_mapping_update_parsed(
17130 void *parsed_result,
17131 __attribute__((unused)) struct cmdline *cl,
17132 __attribute__((unused)) void *data)
17134 struct cmd_pctype_mapping_update_result *res = parsed_result;
17135 int ret = -ENOTSUP;
17136 #ifdef RTE_LIBRTE_I40E_PMD
17137 struct rte_pmd_i40e_flow_type_mapping mapping;
17139 unsigned int nb_item;
17140 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17143 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17146 #ifdef RTE_LIBRTE_I40E_PMD
17147 nb_item = parse_item_list(res->pctype_list, "pctypes",
17148 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17149 mapping.flow_type = res->flow_type;
17150 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17151 mapping.pctype |= (1ULL << pctype_list[i]);
17152 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17162 printf("invalid pctype or flow type\n");
17165 printf("invalid port_id %d\n", res->port_id);
17168 printf("function not implemented\n");
17171 printf("programming error: (%s)\n", strerror(-ret));
17175 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17176 .f = cmd_pctype_mapping_update_parsed,
17178 .help_str = "port config <port_id> pctype mapping update"
17179 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17181 (void *)&cmd_pctype_mapping_update_port,
17182 (void *)&cmd_pctype_mapping_update_config,
17183 (void *)&cmd_pctype_mapping_update_port_id,
17184 (void *)&cmd_pctype_mapping_update_pctype,
17185 (void *)&cmd_pctype_mapping_update_mapping,
17186 (void *)&cmd_pctype_mapping_update_update,
17187 (void *)&cmd_pctype_mapping_update_pc_type,
17188 (void *)&cmd_pctype_mapping_update_flow_type,
17193 /* ptype mapping get */
17195 /* Common result structure for ptype mapping get */
17196 struct cmd_ptype_mapping_get_result {
17197 cmdline_fixed_string_t ptype;
17198 cmdline_fixed_string_t mapping;
17199 cmdline_fixed_string_t get;
17201 uint8_t valid_only;
17204 /* Common CLI fields for ptype mapping get */
17205 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17206 TOKEN_STRING_INITIALIZER
17207 (struct cmd_ptype_mapping_get_result,
17209 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17210 TOKEN_STRING_INITIALIZER
17211 (struct cmd_ptype_mapping_get_result,
17212 mapping, "mapping");
17213 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17214 TOKEN_STRING_INITIALIZER
17215 (struct cmd_ptype_mapping_get_result,
17217 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17218 TOKEN_NUM_INITIALIZER
17219 (struct cmd_ptype_mapping_get_result,
17221 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17222 TOKEN_NUM_INITIALIZER
17223 (struct cmd_ptype_mapping_get_result,
17224 valid_only, UINT8);
17227 cmd_ptype_mapping_get_parsed(
17228 void *parsed_result,
17229 __attribute__((unused)) struct cmdline *cl,
17230 __attribute__((unused)) void *data)
17232 struct cmd_ptype_mapping_get_result *res = parsed_result;
17233 int ret = -ENOTSUP;
17234 #ifdef RTE_LIBRTE_I40E_PMD
17235 int max_ptype_num = 256;
17236 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17241 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17244 #ifdef RTE_LIBRTE_I40E_PMD
17245 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17256 printf("invalid port_id %d\n", res->port_id);
17259 printf("function not implemented\n");
17262 printf("programming error: (%s)\n", strerror(-ret));
17265 #ifdef RTE_LIBRTE_I40E_PMD
17267 for (i = 0; i < count; i++)
17268 printf("%3d\t0x%08x\n",
17269 mapping[i].hw_ptype, mapping[i].sw_ptype);
17274 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17275 .f = cmd_ptype_mapping_get_parsed,
17277 .help_str = "ptype mapping get <port_id> <valid_only>",
17279 (void *)&cmd_ptype_mapping_get_ptype,
17280 (void *)&cmd_ptype_mapping_get_mapping,
17281 (void *)&cmd_ptype_mapping_get_get,
17282 (void *)&cmd_ptype_mapping_get_port_id,
17283 (void *)&cmd_ptype_mapping_get_valid_only,
17288 /* ptype mapping replace */
17290 /* Common result structure for ptype mapping replace */
17291 struct cmd_ptype_mapping_replace_result {
17292 cmdline_fixed_string_t ptype;
17293 cmdline_fixed_string_t mapping;
17294 cmdline_fixed_string_t replace;
17301 /* Common CLI fields for ptype mapping replace */
17302 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17303 TOKEN_STRING_INITIALIZER
17304 (struct cmd_ptype_mapping_replace_result,
17306 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17307 TOKEN_STRING_INITIALIZER
17308 (struct cmd_ptype_mapping_replace_result,
17309 mapping, "mapping");
17310 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17311 TOKEN_STRING_INITIALIZER
17312 (struct cmd_ptype_mapping_replace_result,
17313 replace, "replace");
17314 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17315 TOKEN_NUM_INITIALIZER
17316 (struct cmd_ptype_mapping_replace_result,
17318 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17319 TOKEN_NUM_INITIALIZER
17320 (struct cmd_ptype_mapping_replace_result,
17322 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17323 TOKEN_NUM_INITIALIZER
17324 (struct cmd_ptype_mapping_replace_result,
17326 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17327 TOKEN_NUM_INITIALIZER
17328 (struct cmd_ptype_mapping_replace_result,
17332 cmd_ptype_mapping_replace_parsed(
17333 void *parsed_result,
17334 __attribute__((unused)) struct cmdline *cl,
17335 __attribute__((unused)) void *data)
17337 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17338 int ret = -ENOTSUP;
17340 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17343 #ifdef RTE_LIBRTE_I40E_PMD
17344 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17354 printf("invalid ptype 0x%8x or 0x%8x\n",
17355 res->target, res->pkt_type);
17358 printf("invalid port_id %d\n", res->port_id);
17361 printf("function not implemented\n");
17364 printf("programming error: (%s)\n", strerror(-ret));
17368 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17369 .f = cmd_ptype_mapping_replace_parsed,
17372 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17374 (void *)&cmd_ptype_mapping_replace_ptype,
17375 (void *)&cmd_ptype_mapping_replace_mapping,
17376 (void *)&cmd_ptype_mapping_replace_replace,
17377 (void *)&cmd_ptype_mapping_replace_port_id,
17378 (void *)&cmd_ptype_mapping_replace_target,
17379 (void *)&cmd_ptype_mapping_replace_mask,
17380 (void *)&cmd_ptype_mapping_replace_pkt_type,
17385 /* ptype mapping reset */
17387 /* Common result structure for ptype mapping reset */
17388 struct cmd_ptype_mapping_reset_result {
17389 cmdline_fixed_string_t ptype;
17390 cmdline_fixed_string_t mapping;
17391 cmdline_fixed_string_t reset;
17395 /* Common CLI fields for ptype mapping reset*/
17396 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17397 TOKEN_STRING_INITIALIZER
17398 (struct cmd_ptype_mapping_reset_result,
17400 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17401 TOKEN_STRING_INITIALIZER
17402 (struct cmd_ptype_mapping_reset_result,
17403 mapping, "mapping");
17404 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17405 TOKEN_STRING_INITIALIZER
17406 (struct cmd_ptype_mapping_reset_result,
17408 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17409 TOKEN_NUM_INITIALIZER
17410 (struct cmd_ptype_mapping_reset_result,
17414 cmd_ptype_mapping_reset_parsed(
17415 void *parsed_result,
17416 __attribute__((unused)) struct cmdline *cl,
17417 __attribute__((unused)) void *data)
17419 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17420 int ret = -ENOTSUP;
17422 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17425 #ifdef RTE_LIBRTE_I40E_PMD
17426 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17433 printf("invalid port_id %d\n", res->port_id);
17436 printf("function not implemented\n");
17439 printf("programming error: (%s)\n", strerror(-ret));
17443 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17444 .f = cmd_ptype_mapping_reset_parsed,
17446 .help_str = "ptype mapping reset <port_id>",
17448 (void *)&cmd_ptype_mapping_reset_ptype,
17449 (void *)&cmd_ptype_mapping_reset_mapping,
17450 (void *)&cmd_ptype_mapping_reset_reset,
17451 (void *)&cmd_ptype_mapping_reset_port_id,
17456 /* ptype mapping update */
17458 /* Common result structure for ptype mapping update */
17459 struct cmd_ptype_mapping_update_result {
17460 cmdline_fixed_string_t ptype;
17461 cmdline_fixed_string_t mapping;
17462 cmdline_fixed_string_t reset;
17468 /* Common CLI fields for ptype mapping update*/
17469 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17470 TOKEN_STRING_INITIALIZER
17471 (struct cmd_ptype_mapping_update_result,
17473 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17474 TOKEN_STRING_INITIALIZER
17475 (struct cmd_ptype_mapping_update_result,
17476 mapping, "mapping");
17477 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17478 TOKEN_STRING_INITIALIZER
17479 (struct cmd_ptype_mapping_update_result,
17481 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17482 TOKEN_NUM_INITIALIZER
17483 (struct cmd_ptype_mapping_update_result,
17485 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17486 TOKEN_NUM_INITIALIZER
17487 (struct cmd_ptype_mapping_update_result,
17489 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17490 TOKEN_NUM_INITIALIZER
17491 (struct cmd_ptype_mapping_update_result,
17495 cmd_ptype_mapping_update_parsed(
17496 void *parsed_result,
17497 __attribute__((unused)) struct cmdline *cl,
17498 __attribute__((unused)) void *data)
17500 struct cmd_ptype_mapping_update_result *res = parsed_result;
17501 int ret = -ENOTSUP;
17502 #ifdef RTE_LIBRTE_I40E_PMD
17503 struct rte_pmd_i40e_ptype_mapping mapping;
17505 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17508 #ifdef RTE_LIBRTE_I40E_PMD
17509 mapping.hw_ptype = res->hw_ptype;
17510 mapping.sw_ptype = res->sw_ptype;
17511 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17521 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17524 printf("invalid port_id %d\n", res->port_id);
17527 printf("function not implemented\n");
17530 printf("programming error: (%s)\n", strerror(-ret));
17534 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17535 .f = cmd_ptype_mapping_update_parsed,
17537 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17539 (void *)&cmd_ptype_mapping_update_ptype,
17540 (void *)&cmd_ptype_mapping_update_mapping,
17541 (void *)&cmd_ptype_mapping_update_update,
17542 (void *)&cmd_ptype_mapping_update_port_id,
17543 (void *)&cmd_ptype_mapping_update_hw_ptype,
17544 (void *)&cmd_ptype_mapping_update_sw_ptype,
17549 /* Common result structure for file commands */
17550 struct cmd_cmdfile_result {
17551 cmdline_fixed_string_t load;
17552 cmdline_fixed_string_t filename;
17555 /* Common CLI fields for file commands */
17556 cmdline_parse_token_string_t cmd_load_cmdfile =
17557 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17558 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17559 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17562 cmd_load_from_file_parsed(
17563 void *parsed_result,
17564 __attribute__((unused)) struct cmdline *cl,
17565 __attribute__((unused)) void *data)
17567 struct cmd_cmdfile_result *res = parsed_result;
17569 cmdline_read_from_file(res->filename);
17572 cmdline_parse_inst_t cmd_load_from_file = {
17573 .f = cmd_load_from_file_parsed,
17575 .help_str = "load <filename>",
17577 (void *)&cmd_load_cmdfile,
17578 (void *)&cmd_load_cmdfile_filename,
17583 /* Get Rx offloads capabilities */
17584 struct cmd_rx_offload_get_capa_result {
17585 cmdline_fixed_string_t show;
17586 cmdline_fixed_string_t port;
17588 cmdline_fixed_string_t rx_offload;
17589 cmdline_fixed_string_t capabilities;
17592 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17593 TOKEN_STRING_INITIALIZER
17594 (struct cmd_rx_offload_get_capa_result,
17596 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17597 TOKEN_STRING_INITIALIZER
17598 (struct cmd_rx_offload_get_capa_result,
17600 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17601 TOKEN_NUM_INITIALIZER
17602 (struct cmd_rx_offload_get_capa_result,
17604 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17605 TOKEN_STRING_INITIALIZER
17606 (struct cmd_rx_offload_get_capa_result,
17607 rx_offload, "rx_offload");
17608 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17609 TOKEN_STRING_INITIALIZER
17610 (struct cmd_rx_offload_get_capa_result,
17611 capabilities, "capabilities");
17614 print_rx_offloads(uint64_t offloads)
17616 uint64_t single_offload;
17624 begin = __builtin_ctzll(offloads);
17625 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17627 single_offload = 1 << begin;
17628 for (bit = begin; bit < end; bit++) {
17629 if (offloads & single_offload)
17631 rte_eth_dev_rx_offload_name(single_offload));
17632 single_offload <<= 1;
17637 cmd_rx_offload_get_capa_parsed(
17638 void *parsed_result,
17639 __attribute__((unused)) struct cmdline *cl,
17640 __attribute__((unused)) void *data)
17642 struct cmd_rx_offload_get_capa_result *res = parsed_result;
17643 struct rte_eth_dev_info dev_info;
17644 portid_t port_id = res->port_id;
17645 uint64_t queue_offloads;
17646 uint64_t port_offloads;
17648 rte_eth_dev_info_get(port_id, &dev_info);
17649 queue_offloads = dev_info.rx_queue_offload_capa;
17650 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
17652 printf("Rx Offloading Capabilities of port %d :\n", port_id);
17653 printf(" Per Queue :");
17654 print_rx_offloads(queue_offloads);
17657 printf(" Per Port :");
17658 print_rx_offloads(port_offloads);
17662 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
17663 .f = cmd_rx_offload_get_capa_parsed,
17665 .help_str = "show port <port_id> rx_offload capabilities",
17667 (void *)&cmd_rx_offload_get_capa_show,
17668 (void *)&cmd_rx_offload_get_capa_port,
17669 (void *)&cmd_rx_offload_get_capa_port_id,
17670 (void *)&cmd_rx_offload_get_capa_rx_offload,
17671 (void *)&cmd_rx_offload_get_capa_capabilities,
17676 /* Get Rx offloads configuration */
17677 struct cmd_rx_offload_get_configuration_result {
17678 cmdline_fixed_string_t show;
17679 cmdline_fixed_string_t port;
17681 cmdline_fixed_string_t rx_offload;
17682 cmdline_fixed_string_t configuration;
17685 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
17686 TOKEN_STRING_INITIALIZER
17687 (struct cmd_rx_offload_get_configuration_result,
17689 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
17690 TOKEN_STRING_INITIALIZER
17691 (struct cmd_rx_offload_get_configuration_result,
17693 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
17694 TOKEN_NUM_INITIALIZER
17695 (struct cmd_rx_offload_get_configuration_result,
17697 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
17698 TOKEN_STRING_INITIALIZER
17699 (struct cmd_rx_offload_get_configuration_result,
17700 rx_offload, "rx_offload");
17701 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
17702 TOKEN_STRING_INITIALIZER
17703 (struct cmd_rx_offload_get_configuration_result,
17704 configuration, "configuration");
17707 cmd_rx_offload_get_configuration_parsed(
17708 void *parsed_result,
17709 __attribute__((unused)) struct cmdline *cl,
17710 __attribute__((unused)) void *data)
17712 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
17713 struct rte_eth_dev_info dev_info;
17714 portid_t port_id = res->port_id;
17715 struct rte_port *port = &ports[port_id];
17716 uint64_t port_offloads;
17717 uint64_t queue_offloads;
17718 uint16_t nb_rx_queues;
17721 printf("Rx Offloading Configuration of port %d :\n", port_id);
17723 port_offloads = port->dev_conf.rxmode.offloads;
17725 print_rx_offloads(port_offloads);
17728 rte_eth_dev_info_get(port_id, &dev_info);
17729 nb_rx_queues = dev_info.nb_rx_queues;
17730 for (q = 0; q < nb_rx_queues; q++) {
17731 queue_offloads = port->rx_conf[q].offloads;
17732 printf(" Queue[%2d] :", q);
17733 print_rx_offloads(queue_offloads);
17739 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
17740 .f = cmd_rx_offload_get_configuration_parsed,
17742 .help_str = "show port <port_id> rx_offload configuration",
17744 (void *)&cmd_rx_offload_get_configuration_show,
17745 (void *)&cmd_rx_offload_get_configuration_port,
17746 (void *)&cmd_rx_offload_get_configuration_port_id,
17747 (void *)&cmd_rx_offload_get_configuration_rx_offload,
17748 (void *)&cmd_rx_offload_get_configuration_configuration,
17753 /* Enable/Disable a per port offloading */
17754 struct cmd_config_per_port_rx_offload_result {
17755 cmdline_fixed_string_t port;
17756 cmdline_fixed_string_t config;
17758 cmdline_fixed_string_t rx_offload;
17759 cmdline_fixed_string_t offload;
17760 cmdline_fixed_string_t on_off;
17763 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
17764 TOKEN_STRING_INITIALIZER
17765 (struct cmd_config_per_port_rx_offload_result,
17767 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
17768 TOKEN_STRING_INITIALIZER
17769 (struct cmd_config_per_port_rx_offload_result,
17771 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
17772 TOKEN_NUM_INITIALIZER
17773 (struct cmd_config_per_port_rx_offload_result,
17775 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
17776 TOKEN_STRING_INITIALIZER
17777 (struct cmd_config_per_port_rx_offload_result,
17778 rx_offload, "rx_offload");
17779 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
17780 TOKEN_STRING_INITIALIZER
17781 (struct cmd_config_per_port_rx_offload_result,
17782 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
17783 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
17784 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
17785 "crc_strip#scatter#timestamp#security#keep_crc");
17786 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
17787 TOKEN_STRING_INITIALIZER
17788 (struct cmd_config_per_port_rx_offload_result,
17792 search_rx_offload(const char *name)
17794 uint64_t single_offload;
17795 const char *single_name;
17799 single_offload = 1;
17800 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
17801 single_name = rte_eth_dev_rx_offload_name(single_offload);
17802 if (!strcasecmp(single_name, name)) {
17805 } else if (!strcasecmp(single_name, "UNKNOWN"))
17807 else if (single_name == NULL)
17809 single_offload <<= 1;
17813 return single_offload;
17819 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
17820 __attribute__((unused)) struct cmdline *cl,
17821 __attribute__((unused)) void *data)
17823 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
17824 portid_t port_id = res->port_id;
17825 struct rte_eth_dev_info dev_info;
17826 struct rte_port *port = &ports[port_id];
17827 uint64_t single_offload;
17828 uint16_t nb_rx_queues;
17831 if (port->port_status != RTE_PORT_STOPPED) {
17832 printf("Error: Can't config offload when Port %d "
17833 "is not stopped\n", port_id);
17837 single_offload = search_rx_offload(res->offload);
17838 if (single_offload == 0) {
17839 printf("Unknown offload name: %s\n", res->offload);
17843 rte_eth_dev_info_get(port_id, &dev_info);
17844 nb_rx_queues = dev_info.nb_rx_queues;
17845 if (!strcmp(res->on_off, "on")) {
17846 port->dev_conf.rxmode.offloads |= single_offload;
17847 for (q = 0; q < nb_rx_queues; q++)
17848 port->rx_conf[q].offloads |= single_offload;
17850 port->dev_conf.rxmode.offloads &= ~single_offload;
17851 for (q = 0; q < nb_rx_queues; q++)
17852 port->rx_conf[q].offloads &= ~single_offload;
17855 cmd_reconfig_device_queue(port_id, 1, 1);
17858 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
17859 .f = cmd_config_per_port_rx_offload_parsed,
17861 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
17862 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
17863 "macsec_strip|header_split|vlan_filter|vlan_extend|"
17864 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
17867 (void *)&cmd_config_per_port_rx_offload_result_port,
17868 (void *)&cmd_config_per_port_rx_offload_result_config,
17869 (void *)&cmd_config_per_port_rx_offload_result_port_id,
17870 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
17871 (void *)&cmd_config_per_port_rx_offload_result_offload,
17872 (void *)&cmd_config_per_port_rx_offload_result_on_off,
17877 /* Enable/Disable a per queue offloading */
17878 struct cmd_config_per_queue_rx_offload_result {
17879 cmdline_fixed_string_t port;
17881 cmdline_fixed_string_t rxq;
17883 cmdline_fixed_string_t rx_offload;
17884 cmdline_fixed_string_t offload;
17885 cmdline_fixed_string_t on_off;
17888 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
17889 TOKEN_STRING_INITIALIZER
17890 (struct cmd_config_per_queue_rx_offload_result,
17892 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
17893 TOKEN_NUM_INITIALIZER
17894 (struct cmd_config_per_queue_rx_offload_result,
17896 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
17897 TOKEN_STRING_INITIALIZER
17898 (struct cmd_config_per_queue_rx_offload_result,
17900 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
17901 TOKEN_NUM_INITIALIZER
17902 (struct cmd_config_per_queue_rx_offload_result,
17904 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
17905 TOKEN_STRING_INITIALIZER
17906 (struct cmd_config_per_queue_rx_offload_result,
17907 rx_offload, "rx_offload");
17908 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
17909 TOKEN_STRING_INITIALIZER
17910 (struct cmd_config_per_queue_rx_offload_result,
17911 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
17912 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
17913 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
17914 "crc_strip#scatter#timestamp#security#keep_crc");
17915 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
17916 TOKEN_STRING_INITIALIZER
17917 (struct cmd_config_per_queue_rx_offload_result,
17921 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
17922 __attribute__((unused)) struct cmdline *cl,
17923 __attribute__((unused)) void *data)
17925 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
17926 struct rte_eth_dev_info dev_info;
17927 portid_t port_id = res->port_id;
17928 uint16_t queue_id = res->queue_id;
17929 struct rte_port *port = &ports[port_id];
17930 uint64_t single_offload;
17932 if (port->port_status != RTE_PORT_STOPPED) {
17933 printf("Error: Can't config offload when Port %d "
17934 "is not stopped\n", port_id);
17938 rte_eth_dev_info_get(port_id, &dev_info);
17939 if (queue_id >= dev_info.nb_rx_queues) {
17940 printf("Error: input queue_id should be 0 ... "
17941 "%d\n", dev_info.nb_rx_queues - 1);
17945 single_offload = search_rx_offload(res->offload);
17946 if (single_offload == 0) {
17947 printf("Unknown offload name: %s\n", res->offload);
17951 if (!strcmp(res->on_off, "on"))
17952 port->rx_conf[queue_id].offloads |= single_offload;
17954 port->rx_conf[queue_id].offloads &= ~single_offload;
17956 cmd_reconfig_device_queue(port_id, 1, 1);
17959 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
17960 .f = cmd_config_per_queue_rx_offload_parsed,
17962 .help_str = "port <port_id> rxq <queue_id> rx_offload "
17963 "vlan_strip|ipv4_cksum|"
17964 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
17965 "macsec_strip|header_split|vlan_filter|vlan_extend|"
17966 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
17969 (void *)&cmd_config_per_queue_rx_offload_result_port,
17970 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
17971 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
17972 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
17973 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
17974 (void *)&cmd_config_per_queue_rx_offload_result_offload,
17975 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
17980 /* Get Tx offloads capabilities */
17981 struct cmd_tx_offload_get_capa_result {
17982 cmdline_fixed_string_t show;
17983 cmdline_fixed_string_t port;
17985 cmdline_fixed_string_t tx_offload;
17986 cmdline_fixed_string_t capabilities;
17989 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
17990 TOKEN_STRING_INITIALIZER
17991 (struct cmd_tx_offload_get_capa_result,
17993 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
17994 TOKEN_STRING_INITIALIZER
17995 (struct cmd_tx_offload_get_capa_result,
17997 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
17998 TOKEN_NUM_INITIALIZER
17999 (struct cmd_tx_offload_get_capa_result,
18001 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18002 TOKEN_STRING_INITIALIZER
18003 (struct cmd_tx_offload_get_capa_result,
18004 tx_offload, "tx_offload");
18005 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18006 TOKEN_STRING_INITIALIZER
18007 (struct cmd_tx_offload_get_capa_result,
18008 capabilities, "capabilities");
18011 print_tx_offloads(uint64_t offloads)
18013 uint64_t single_offload;
18021 begin = __builtin_ctzll(offloads);
18022 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18024 single_offload = 1 << begin;
18025 for (bit = begin; bit < end; bit++) {
18026 if (offloads & single_offload)
18028 rte_eth_dev_tx_offload_name(single_offload));
18029 single_offload <<= 1;
18034 cmd_tx_offload_get_capa_parsed(
18035 void *parsed_result,
18036 __attribute__((unused)) struct cmdline *cl,
18037 __attribute__((unused)) void *data)
18039 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18040 struct rte_eth_dev_info dev_info;
18041 portid_t port_id = res->port_id;
18042 uint64_t queue_offloads;
18043 uint64_t port_offloads;
18045 rte_eth_dev_info_get(port_id, &dev_info);
18046 queue_offloads = dev_info.tx_queue_offload_capa;
18047 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18049 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18050 printf(" Per Queue :");
18051 print_tx_offloads(queue_offloads);
18054 printf(" Per Port :");
18055 print_tx_offloads(port_offloads);
18059 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18060 .f = cmd_tx_offload_get_capa_parsed,
18062 .help_str = "show port <port_id> tx_offload capabilities",
18064 (void *)&cmd_tx_offload_get_capa_show,
18065 (void *)&cmd_tx_offload_get_capa_port,
18066 (void *)&cmd_tx_offload_get_capa_port_id,
18067 (void *)&cmd_tx_offload_get_capa_tx_offload,
18068 (void *)&cmd_tx_offload_get_capa_capabilities,
18073 /* Get Tx offloads configuration */
18074 struct cmd_tx_offload_get_configuration_result {
18075 cmdline_fixed_string_t show;
18076 cmdline_fixed_string_t port;
18078 cmdline_fixed_string_t tx_offload;
18079 cmdline_fixed_string_t configuration;
18082 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18083 TOKEN_STRING_INITIALIZER
18084 (struct cmd_tx_offload_get_configuration_result,
18086 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18087 TOKEN_STRING_INITIALIZER
18088 (struct cmd_tx_offload_get_configuration_result,
18090 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18091 TOKEN_NUM_INITIALIZER
18092 (struct cmd_tx_offload_get_configuration_result,
18094 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18095 TOKEN_STRING_INITIALIZER
18096 (struct cmd_tx_offload_get_configuration_result,
18097 tx_offload, "tx_offload");
18098 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18099 TOKEN_STRING_INITIALIZER
18100 (struct cmd_tx_offload_get_configuration_result,
18101 configuration, "configuration");
18104 cmd_tx_offload_get_configuration_parsed(
18105 void *parsed_result,
18106 __attribute__((unused)) struct cmdline *cl,
18107 __attribute__((unused)) void *data)
18109 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18110 struct rte_eth_dev_info dev_info;
18111 portid_t port_id = res->port_id;
18112 struct rte_port *port = &ports[port_id];
18113 uint64_t port_offloads;
18114 uint64_t queue_offloads;
18115 uint16_t nb_tx_queues;
18118 printf("Tx Offloading Configuration of port %d :\n", port_id);
18120 port_offloads = port->dev_conf.txmode.offloads;
18122 print_tx_offloads(port_offloads);
18125 rte_eth_dev_info_get(port_id, &dev_info);
18126 nb_tx_queues = dev_info.nb_tx_queues;
18127 for (q = 0; q < nb_tx_queues; q++) {
18128 queue_offloads = port->tx_conf[q].offloads;
18129 printf(" Queue[%2d] :", q);
18130 print_tx_offloads(queue_offloads);
18136 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18137 .f = cmd_tx_offload_get_configuration_parsed,
18139 .help_str = "show port <port_id> tx_offload configuration",
18141 (void *)&cmd_tx_offload_get_configuration_show,
18142 (void *)&cmd_tx_offload_get_configuration_port,
18143 (void *)&cmd_tx_offload_get_configuration_port_id,
18144 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18145 (void *)&cmd_tx_offload_get_configuration_configuration,
18150 /* Enable/Disable a per port offloading */
18151 struct cmd_config_per_port_tx_offload_result {
18152 cmdline_fixed_string_t port;
18153 cmdline_fixed_string_t config;
18155 cmdline_fixed_string_t tx_offload;
18156 cmdline_fixed_string_t offload;
18157 cmdline_fixed_string_t on_off;
18160 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18161 TOKEN_STRING_INITIALIZER
18162 (struct cmd_config_per_port_tx_offload_result,
18164 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18165 TOKEN_STRING_INITIALIZER
18166 (struct cmd_config_per_port_tx_offload_result,
18168 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18169 TOKEN_NUM_INITIALIZER
18170 (struct cmd_config_per_port_tx_offload_result,
18172 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18173 TOKEN_STRING_INITIALIZER
18174 (struct cmd_config_per_port_tx_offload_result,
18175 tx_offload, "tx_offload");
18176 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18177 TOKEN_STRING_INITIALIZER
18178 (struct cmd_config_per_port_tx_offload_result,
18179 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18180 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18181 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18182 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18183 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18185 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18186 TOKEN_STRING_INITIALIZER
18187 (struct cmd_config_per_port_tx_offload_result,
18191 search_tx_offload(const char *name)
18193 uint64_t single_offload;
18194 const char *single_name;
18198 single_offload = 1;
18199 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18200 single_name = rte_eth_dev_tx_offload_name(single_offload);
18201 if (!strcasecmp(single_name, name)) {
18204 } else if (!strcasecmp(single_name, "UNKNOWN"))
18206 else if (single_name == NULL)
18208 single_offload <<= 1;
18212 return single_offload;
18218 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18219 __attribute__((unused)) struct cmdline *cl,
18220 __attribute__((unused)) void *data)
18222 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18223 portid_t port_id = res->port_id;
18224 struct rte_eth_dev_info dev_info;
18225 struct rte_port *port = &ports[port_id];
18226 uint64_t single_offload;
18227 uint16_t nb_tx_queues;
18230 if (port->port_status != RTE_PORT_STOPPED) {
18231 printf("Error: Can't config offload when Port %d "
18232 "is not stopped\n", port_id);
18236 single_offload = search_tx_offload(res->offload);
18237 if (single_offload == 0) {
18238 printf("Unknown offload name: %s\n", res->offload);
18242 rte_eth_dev_info_get(port_id, &dev_info);
18243 nb_tx_queues = dev_info.nb_tx_queues;
18244 if (!strcmp(res->on_off, "on")) {
18245 port->dev_conf.txmode.offloads |= single_offload;
18246 for (q = 0; q < nb_tx_queues; q++)
18247 port->tx_conf[q].offloads |= single_offload;
18249 port->dev_conf.txmode.offloads &= ~single_offload;
18250 for (q = 0; q < nb_tx_queues; q++)
18251 port->tx_conf[q].offloads &= ~single_offload;
18254 cmd_reconfig_device_queue(port_id, 1, 1);
18257 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18258 .f = cmd_config_per_port_tx_offload_parsed,
18260 .help_str = "port config <port_id> tx_offload "
18261 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18262 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18263 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18264 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18265 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18266 "match_metadata on|off",
18268 (void *)&cmd_config_per_port_tx_offload_result_port,
18269 (void *)&cmd_config_per_port_tx_offload_result_config,
18270 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18271 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18272 (void *)&cmd_config_per_port_tx_offload_result_offload,
18273 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18278 /* Enable/Disable a per queue offloading */
18279 struct cmd_config_per_queue_tx_offload_result {
18280 cmdline_fixed_string_t port;
18282 cmdline_fixed_string_t txq;
18284 cmdline_fixed_string_t tx_offload;
18285 cmdline_fixed_string_t offload;
18286 cmdline_fixed_string_t on_off;
18289 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18290 TOKEN_STRING_INITIALIZER
18291 (struct cmd_config_per_queue_tx_offload_result,
18293 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18294 TOKEN_NUM_INITIALIZER
18295 (struct cmd_config_per_queue_tx_offload_result,
18297 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18298 TOKEN_STRING_INITIALIZER
18299 (struct cmd_config_per_queue_tx_offload_result,
18301 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18302 TOKEN_NUM_INITIALIZER
18303 (struct cmd_config_per_queue_tx_offload_result,
18305 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18306 TOKEN_STRING_INITIALIZER
18307 (struct cmd_config_per_queue_tx_offload_result,
18308 tx_offload, "tx_offload");
18309 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18310 TOKEN_STRING_INITIALIZER
18311 (struct cmd_config_per_queue_tx_offload_result,
18312 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18313 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18314 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18315 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18316 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18317 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18318 TOKEN_STRING_INITIALIZER
18319 (struct cmd_config_per_queue_tx_offload_result,
18323 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18324 __attribute__((unused)) struct cmdline *cl,
18325 __attribute__((unused)) void *data)
18327 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18328 struct rte_eth_dev_info dev_info;
18329 portid_t port_id = res->port_id;
18330 uint16_t queue_id = res->queue_id;
18331 struct rte_port *port = &ports[port_id];
18332 uint64_t single_offload;
18334 if (port->port_status != RTE_PORT_STOPPED) {
18335 printf("Error: Can't config offload when Port %d "
18336 "is not stopped\n", port_id);
18340 rte_eth_dev_info_get(port_id, &dev_info);
18341 if (queue_id >= dev_info.nb_tx_queues) {
18342 printf("Error: input queue_id should be 0 ... "
18343 "%d\n", dev_info.nb_tx_queues - 1);
18347 single_offload = search_tx_offload(res->offload);
18348 if (single_offload == 0) {
18349 printf("Unknown offload name: %s\n", res->offload);
18353 if (!strcmp(res->on_off, "on"))
18354 port->tx_conf[queue_id].offloads |= single_offload;
18356 port->tx_conf[queue_id].offloads &= ~single_offload;
18358 cmd_reconfig_device_queue(port_id, 1, 1);
18361 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18362 .f = cmd_config_per_queue_tx_offload_parsed,
18364 .help_str = "port <port_id> txq <queue_id> tx_offload "
18365 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18366 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18367 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18368 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18369 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18372 (void *)&cmd_config_per_queue_tx_offload_result_port,
18373 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18374 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18375 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18376 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18377 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18378 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18383 /* *** configure tx_metadata for specific port *** */
18384 struct cmd_config_tx_metadata_specific_result {
18385 cmdline_fixed_string_t port;
18386 cmdline_fixed_string_t keyword;
18388 cmdline_fixed_string_t item;
18393 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18394 __attribute__((unused)) struct cmdline *cl,
18395 __attribute__((unused)) void *data)
18397 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18399 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18401 ports[res->port_id].tx_metadata = rte_cpu_to_be_32(res->value);
18402 /* Add/remove callback to insert valid metadata in every Tx packet. */
18403 if (ports[res->port_id].tx_metadata)
18404 add_tx_md_callback(res->port_id);
18406 remove_tx_md_callback(res->port_id);
18409 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18410 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18412 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18413 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18414 keyword, "config");
18415 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18416 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18418 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18419 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18420 item, "tx_metadata");
18421 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18422 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18425 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18426 .f = cmd_config_tx_metadata_specific_parsed,
18428 .help_str = "port config <port_id> tx_metadata <value>",
18430 (void *)&cmd_config_tx_metadata_specific_port,
18431 (void *)&cmd_config_tx_metadata_specific_keyword,
18432 (void *)&cmd_config_tx_metadata_specific_id,
18433 (void *)&cmd_config_tx_metadata_specific_item,
18434 (void *)&cmd_config_tx_metadata_specific_value,
18439 /* *** display tx_metadata per port configuration *** */
18440 struct cmd_show_tx_metadata_result {
18441 cmdline_fixed_string_t cmd_show;
18442 cmdline_fixed_string_t cmd_port;
18443 cmdline_fixed_string_t cmd_keyword;
18448 cmd_show_tx_metadata_parsed(void *parsed_result,
18449 __attribute__((unused)) struct cmdline *cl,
18450 __attribute__((unused)) void *data)
18452 struct cmd_show_tx_metadata_result *res = parsed_result;
18454 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18455 printf("invalid port id %u\n", res->cmd_pid);
18458 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18459 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18460 ports[res->cmd_pid].tx_metadata);
18464 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18465 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18467 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18468 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18470 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18471 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18473 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18474 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18475 cmd_keyword, "tx_metadata");
18477 cmdline_parse_inst_t cmd_show_tx_metadata = {
18478 .f = cmd_show_tx_metadata_parsed,
18480 .help_str = "show port <port_id> tx_metadata",
18482 (void *)&cmd_show_tx_metadata_show,
18483 (void *)&cmd_show_tx_metadata_port,
18484 (void *)&cmd_show_tx_metadata_pid,
18485 (void *)&cmd_show_tx_metadata_keyword,
18490 /* ******************************************************************************** */
18492 /* list of instructions */
18493 cmdline_parse_ctx_t main_ctx[] = {
18494 (cmdline_parse_inst_t *)&cmd_help_brief,
18495 (cmdline_parse_inst_t *)&cmd_help_long,
18496 (cmdline_parse_inst_t *)&cmd_quit,
18497 (cmdline_parse_inst_t *)&cmd_load_from_file,
18498 (cmdline_parse_inst_t *)&cmd_showport,
18499 (cmdline_parse_inst_t *)&cmd_showqueue,
18500 (cmdline_parse_inst_t *)&cmd_showportall,
18501 (cmdline_parse_inst_t *)&cmd_showcfg,
18502 (cmdline_parse_inst_t *)&cmd_start,
18503 (cmdline_parse_inst_t *)&cmd_start_tx_first,
18504 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
18505 (cmdline_parse_inst_t *)&cmd_set_link_up,
18506 (cmdline_parse_inst_t *)&cmd_set_link_down,
18507 (cmdline_parse_inst_t *)&cmd_reset,
18508 (cmdline_parse_inst_t *)&cmd_set_numbers,
18509 (cmdline_parse_inst_t *)&cmd_set_log,
18510 (cmdline_parse_inst_t *)&cmd_set_txpkts,
18511 (cmdline_parse_inst_t *)&cmd_set_txsplit,
18512 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
18513 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
18514 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
18515 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
18516 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
18517 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
18518 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
18519 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
18520 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
18521 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
18522 (cmdline_parse_inst_t *)&cmd_set_link_check,
18523 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
18524 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
18525 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
18526 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
18527 #ifdef RTE_LIBRTE_PMD_BOND
18528 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
18529 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
18530 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
18531 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
18532 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
18533 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
18534 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
18535 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
18536 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
18537 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
18538 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
18540 (cmdline_parse_inst_t *)&cmd_vlan_offload,
18541 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
18542 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
18543 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
18544 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
18545 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
18546 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
18547 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
18548 (cmdline_parse_inst_t *)&cmd_csum_set,
18549 (cmdline_parse_inst_t *)&cmd_csum_show,
18550 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
18551 (cmdline_parse_inst_t *)&cmd_tso_set,
18552 (cmdline_parse_inst_t *)&cmd_tso_show,
18553 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
18554 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
18555 (cmdline_parse_inst_t *)&cmd_gro_enable,
18556 (cmdline_parse_inst_t *)&cmd_gro_flush,
18557 (cmdline_parse_inst_t *)&cmd_gro_show,
18558 (cmdline_parse_inst_t *)&cmd_gso_enable,
18559 (cmdline_parse_inst_t *)&cmd_gso_size,
18560 (cmdline_parse_inst_t *)&cmd_gso_show,
18561 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
18562 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
18563 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
18564 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
18565 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
18566 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
18567 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
18568 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
18569 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
18570 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
18571 (cmdline_parse_inst_t *)&cmd_config_dcb,
18572 (cmdline_parse_inst_t *)&cmd_read_reg,
18573 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
18574 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
18575 (cmdline_parse_inst_t *)&cmd_write_reg,
18576 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
18577 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
18578 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
18579 (cmdline_parse_inst_t *)&cmd_stop,
18580 (cmdline_parse_inst_t *)&cmd_mac_addr,
18581 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
18582 (cmdline_parse_inst_t *)&cmd_set_qmap,
18583 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
18584 (cmdline_parse_inst_t *)&cmd_operate_port,
18585 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
18586 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
18587 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
18588 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
18589 (cmdline_parse_inst_t *)&cmd_config_speed_all,
18590 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
18591 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
18592 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
18593 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
18594 (cmdline_parse_inst_t *)&cmd_config_mtu,
18595 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
18596 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
18597 (cmdline_parse_inst_t *)&cmd_config_rss,
18598 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
18599 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
18600 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
18601 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
18602 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
18603 (cmdline_parse_inst_t *)&cmd_showport_reta,
18604 (cmdline_parse_inst_t *)&cmd_config_burst,
18605 (cmdline_parse_inst_t *)&cmd_config_thresh,
18606 (cmdline_parse_inst_t *)&cmd_config_threshold,
18607 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
18608 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
18609 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
18610 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
18611 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
18612 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
18613 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
18614 (cmdline_parse_inst_t *)&cmd_global_config,
18615 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
18616 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
18617 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
18618 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
18619 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
18620 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
18621 (cmdline_parse_inst_t *)&cmd_dump,
18622 (cmdline_parse_inst_t *)&cmd_dump_one,
18623 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
18624 (cmdline_parse_inst_t *)&cmd_syn_filter,
18625 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
18626 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
18627 (cmdline_parse_inst_t *)&cmd_flex_filter,
18628 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
18629 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
18630 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
18631 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
18632 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
18633 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
18634 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
18635 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
18636 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
18637 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
18638 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
18639 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
18640 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
18641 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
18642 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
18643 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
18644 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
18645 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
18646 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
18647 (cmdline_parse_inst_t *)&cmd_flow,
18648 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
18649 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
18650 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
18651 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
18652 (cmdline_parse_inst_t *)&cmd_create_port_meter,
18653 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
18654 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
18655 (cmdline_parse_inst_t *)&cmd_del_port_meter,
18656 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
18657 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
18658 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
18659 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
18660 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
18661 (cmdline_parse_inst_t *)&cmd_mcast_addr,
18662 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
18663 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
18664 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
18665 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
18666 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
18667 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
18668 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
18669 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
18670 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
18671 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
18672 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
18673 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
18674 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
18675 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
18676 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
18677 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
18678 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
18679 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
18680 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
18681 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
18682 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
18683 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
18684 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
18685 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
18686 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
18687 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
18688 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
18689 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
18690 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
18691 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
18692 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
18693 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
18694 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
18695 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
18696 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
18697 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
18698 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
18700 (cmdline_parse_inst_t *)&cmd_set_vxlan,
18701 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
18702 (cmdline_parse_inst_t *)&cmd_set_nvgre,
18703 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
18704 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
18705 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
18706 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
18707 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
18708 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
18709 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
18710 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
18711 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
18712 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
18713 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
18714 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
18715 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
18716 (cmdline_parse_inst_t *)&cmd_ddp_add,
18717 (cmdline_parse_inst_t *)&cmd_ddp_del,
18718 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
18719 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
18720 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
18721 (cmdline_parse_inst_t *)&cmd_clear_input_set,
18722 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
18723 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
18724 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
18725 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
18726 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
18727 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
18729 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
18730 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
18731 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
18732 (cmdline_parse_inst_t *)&cmd_queue_region,
18733 (cmdline_parse_inst_t *)&cmd_region_flowtype,
18734 (cmdline_parse_inst_t *)&cmd_user_priority_region,
18735 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
18736 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
18737 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
18738 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
18739 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
18740 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
18741 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
18742 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
18743 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
18744 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
18745 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
18746 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
18747 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
18748 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
18749 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
18750 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
18751 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
18752 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
18753 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
18754 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
18755 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
18756 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
18757 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
18758 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
18759 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
18760 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
18761 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
18762 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
18763 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
18764 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
18765 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
18766 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
18767 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
18768 #ifdef RTE_LIBRTE_BPF
18769 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
18770 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
18772 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
18773 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
18777 /* read cmdline commands from file */
18779 cmdline_read_from_file(const char *filename)
18781 struct cmdline *cl;
18783 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
18785 printf("Failed to create file based cmdline context: %s\n",
18790 cmdline_interact(cl);
18795 printf("Read CLI commands from %s\n", filename);
18798 /* prompt function, called from main on MASTER lcore */
18802 /* initialize non-constant commands */
18803 cmd_set_fwd_mode_init();
18804 cmd_set_fwd_retry_mode_init();
18806 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
18807 if (testpmd_cl == NULL)
18809 cmdline_interact(testpmd_cl);
18810 cmdline_stdin_exit(testpmd_cl);
18816 if (testpmd_cl != NULL)
18817 cmdline_quit(testpmd_cl);
18821 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
18823 if (id == (portid_t)RTE_PORT_ALL) {
18826 RTE_ETH_FOREACH_DEV(pid) {
18827 /* check if need_reconfig has been set to 1 */
18828 if (ports[pid].need_reconfig == 0)
18829 ports[pid].need_reconfig = dev;
18830 /* check if need_reconfig_queues has been set to 1 */
18831 if (ports[pid].need_reconfig_queues == 0)
18832 ports[pid].need_reconfig_queues = queue;
18834 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
18835 /* check if need_reconfig has been set to 1 */
18836 if (ports[id].need_reconfig == 0)
18837 ports[id].need_reconfig = dev;
18838 /* check if need_reconfig_queues has been set to 1 */
18839 if (ports[id].need_reconfig_queues == 0)
18840 ports[id].need_reconfig_queues = queue;