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|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 tx loopback (port_id) (on|off)\n"
284 " Enable or disable tx loopback.\n\n"
286 "set all queues drop (port_id) (on|off)\n"
287 " Set drop enable bit for all queues.\n\n"
289 "set vf split drop (port_id) (vf_id) (on|off)\n"
290 " Set split drop enable bit for a VF from the PF.\n\n"
292 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
293 " Set MAC antispoof for a VF from the PF.\n\n"
295 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
296 " Enable MACsec offload.\n\n"
298 "set macsec offload (port_id) off\n"
299 " Disable MACsec offload.\n\n"
301 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
302 " Configure MACsec secure connection (SC).\n\n"
304 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
305 " Configure MACsec secure association (SA).\n\n"
307 "set vf broadcast (port_id) (vf_id) (on|off)\n"
308 " Set VF broadcast for a VF from the PF.\n\n"
310 "vlan set strip (on|off) (port_id)\n"
311 " Set the VLAN strip on a port.\n\n"
313 "vlan set stripq (on|off) (port_id,queue_id)\n"
314 " Set the VLAN strip for a queue on a port.\n\n"
316 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
317 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
319 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
320 " Set VLAN insert for a VF from the PF.\n\n"
322 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
323 " Set VLAN antispoof for a VF from the PF.\n\n"
325 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
326 " Set VLAN tag for a VF from the PF.\n\n"
328 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
329 " Set a VF's max bandwidth(Mbps).\n\n"
331 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
332 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
334 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
335 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
337 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
338 " Set some TCs' strict link priority mode on a physical port.\n\n"
340 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
341 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
343 "vlan set filter (on|off) (port_id)\n"
344 " Set the VLAN filter on a port.\n\n"
346 "vlan set qinq (on|off) (port_id)\n"
347 " Set the VLAN QinQ (extended queue in queue)"
350 "vlan set (inner|outer) tpid (value) (port_id)\n"
351 " Set the VLAN TPID for Packet Filtering on"
354 "rx_vlan add (vlan_id|all) (port_id)\n"
355 " Add a vlan_id, or all identifiers, to the set"
356 " of VLAN identifiers filtered by port_id.\n\n"
358 "rx_vlan rm (vlan_id|all) (port_id)\n"
359 " Remove a vlan_id, or all identifiers, from the set"
360 " of VLAN identifiers filtered by port_id.\n\n"
362 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
363 " Add a vlan_id, to the set of VLAN identifiers"
364 "filtered for VF(s) from port_id.\n\n"
366 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
367 " Remove a vlan_id, to the set of VLAN identifiers"
368 "filtered for VF(s) from port_id.\n\n"
370 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
371 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
372 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
373 " add a tunnel filter of a port.\n\n"
375 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
376 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
377 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
378 " remove a tunnel filter of a port.\n\n"
380 "rx_vxlan_port add (udp_port) (port_id)\n"
381 " Add an UDP port for VXLAN packet filter on a port\n\n"
383 "rx_vxlan_port rm (udp_port) (port_id)\n"
384 " Remove an UDP port for VXLAN packet filter on a port\n\n"
386 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
387 " Set hardware insertion of VLAN IDs (single or double VLAN "
388 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
390 "tx_vlan set pvid port_id vlan_id (on|off)\n"
391 " Set port based TX VLAN insertion.\n\n"
393 "tx_vlan reset (port_id)\n"
394 " Disable hardware insertion of a VLAN header in"
395 " packets sent on a port.\n\n"
397 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
398 " Select hardware or software calculation of the"
399 " checksum when transmitting a packet using the"
400 " csum forward engine.\n"
401 " ip|udp|tcp|sctp always concern the inner layer.\n"
402 " outer-ip concerns the outer IP layer in"
403 " case the packet is recognized as a tunnel packet by"
404 " the forward engine (vxlan, gre and ipip are supported)\n"
405 " Please check the NIC datasheet for HW limits.\n\n"
407 "csum parse-tunnel (on|off) (tx_port_id)\n"
408 " If disabled, treat tunnel packets as non-tunneled"
409 " packets (treat inner headers as payload). The port\n"
410 " argument is the port used for TX in csum forward"
413 "csum show (port_id)\n"
414 " Display tx checksum offload configuration\n\n"
416 "tso set (segsize) (portid)\n"
417 " Enable TCP Segmentation Offload in csum forward"
419 " Please check the NIC datasheet for HW limits.\n\n"
422 " Display the status of TCP Segmentation Offload.\n\n"
424 "set port (port_id) gro on|off\n"
425 " Enable or disable Generic Receive Offload in"
426 " csum forwarding engine.\n\n"
428 "show port (port_id) gro\n"
429 " Display GRO configuration.\n\n"
431 "set gro flush (cycles)\n"
432 " Set the cycle to flush GROed packets from"
433 " reassembly tables.\n\n"
435 "set port (port_id) gso (on|off)"
436 " Enable or disable Generic Segmentation Offload in"
437 " csum forwarding engine.\n\n"
439 "set gso segsz (length)\n"
440 " Set max packet length for output GSO segments,"
441 " including packet header and payload.\n\n"
443 "show port (port_id) gso\n"
444 " Show GSO configuration.\n\n"
447 " Set packet forwarding mode.\n\n"
449 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
450 " Add a MAC address on port_id.\n\n"
452 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
453 " Remove a MAC address from port_id.\n\n"
455 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
456 " Set the default MAC address for port_id.\n\n"
458 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
459 " Add a MAC address for a VF on the port.\n\n"
461 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
462 " Set the MAC address for a VF from the PF.\n\n"
464 "set eth-peer (port_id) (peer_addr)\n"
465 " set the peer address for certain port.\n\n"
467 "set port (port_id) uta (mac_address|all) (on|off)\n"
468 " Add/Remove a or all unicast hash filter(s)"
471 "set promisc (port_id|all) (on|off)\n"
472 " Set the promiscuous mode on port_id, or all.\n\n"
474 "set allmulti (port_id|all) (on|off)\n"
475 " Set the allmulti mode on port_id, or all.\n\n"
477 "set vf promisc (port_id) (vf_id) (on|off)\n"
478 " Set unicast promiscuous mode for a VF from the PF.\n\n"
480 "set vf allmulti (port_id) (vf_id) (on|off)\n"
481 " Set multicast promiscuous mode for a VF from the PF.\n\n"
483 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
484 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
485 " (on|off) autoneg (on|off) (port_id)\n"
486 "set flow_ctrl rx (on|off) (portid)\n"
487 "set flow_ctrl tx (on|off) (portid)\n"
488 "set flow_ctrl high_water (high_water) (portid)\n"
489 "set flow_ctrl low_water (low_water) (portid)\n"
490 "set flow_ctrl pause_time (pause_time) (portid)\n"
491 "set flow_ctrl send_xon (send_xon) (portid)\n"
492 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
493 "set flow_ctrl autoneg (on|off) (port_id)\n"
494 " Set the link flow control parameter on a port.\n\n"
496 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
497 " (low_water) (pause_time) (priority) (port_id)\n"
498 " Set the priority flow control parameter on a"
501 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
502 " Set statistics mapping (qmapping 0..15) for RX/TX"
504 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
505 " on port 0 to mapping 5.\n\n"
507 "set xstats-hide-zero on|off\n"
508 " Set the option to hide the zero values"
509 " for xstats display.\n"
511 "set port (port_id) vf (vf_id) rx|tx on|off\n"
512 " Enable/Disable a VF receive/tranmit from a port\n\n"
514 "set port (port_id) vf (vf_id) (mac_addr)"
515 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
516 " Add/Remove unicast or multicast MAC addr filter"
519 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
521 " AUPE:accepts untagged VLAN;"
522 "ROPE:accept unicast hash\n\n"
523 " BAM:accepts broadcast packets;"
524 "MPE:accepts all multicast packets\n\n"
525 " Enable/Disable a VF receive mode of a port\n\n"
527 "set port (port_id) queue (queue_id) rate (rate_num)\n"
528 " Set rate limit for a queue of a port\n\n"
530 "set port (port_id) vf (vf_id) rate (rate_num) "
531 "queue_mask (queue_mask_value)\n"
532 " Set rate limit for queues in VF of a port\n\n"
534 "set port (port_id) mirror-rule (rule_id)"
535 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
536 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
537 " Set pool or vlan type mirror rule on a port.\n"
538 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
539 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
542 "set port (port_id) mirror-rule (rule_id)"
543 " (uplink-mirror|downlink-mirror) dst-pool"
544 " (pool_id) (on|off)\n"
545 " Set uplink or downlink type mirror rule on a port.\n"
546 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
547 " 0 on' enable mirror income traffic to pool 0.\n\n"
549 "reset port (port_id) mirror-rule (rule_id)\n"
550 " Reset a mirror rule.\n\n"
552 "set flush_rx (on|off)\n"
553 " Flush (default) or don't flush RX streams before"
554 " forwarding. Mainly used with PCAP drivers.\n\n"
556 "set bypass mode (normal|bypass|isolate) (port_id)\n"
557 " Set the bypass mode for the lowest port on bypass enabled"
560 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
561 "mode (normal|bypass|isolate) (port_id)\n"
562 " Set the event required to initiate specified bypass mode for"
563 " the lowest port on a bypass enabled NIC where:\n"
564 " timeout = enable bypass after watchdog timeout.\n"
565 " os_on = enable bypass when OS/board is powered on.\n"
566 " os_off = enable bypass when OS/board is powered off.\n"
567 " power_on = enable bypass when power supply is turned on.\n"
568 " power_off = enable bypass when power supply is turned off."
571 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
572 " Set the bypass watchdog timeout to 'n' seconds"
573 " where 0 = instant.\n\n"
575 "show bypass config (port_id)\n"
576 " Show the bypass configuration for a bypass enabled NIC"
577 " using the lowest port on the NIC.\n\n"
579 #ifdef RTE_LIBRTE_PMD_BOND
580 "create bonded device (mode) (socket)\n"
581 " Create a new bonded device with specific bonding mode and socket.\n\n"
583 "add bonding slave (slave_id) (port_id)\n"
584 " Add a slave device to a bonded device.\n\n"
586 "remove bonding slave (slave_id) (port_id)\n"
587 " Remove a slave device from a bonded device.\n\n"
589 "set bonding mode (value) (port_id)\n"
590 " Set the bonding mode on a bonded device.\n\n"
592 "set bonding primary (slave_id) (port_id)\n"
593 " Set the primary slave for a bonded device.\n\n"
595 "show bonding config (port_id)\n"
596 " Show the bonding config for port_id.\n\n"
598 "set bonding mac_addr (port_id) (address)\n"
599 " Set the MAC address of a bonded device.\n\n"
601 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
602 " Set Aggregation mode for IEEE802.3AD (mode 4)"
604 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
605 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
607 "set bonding mon_period (port_id) (value)\n"
608 " Set the bonding link status monitoring polling period in ms.\n\n"
610 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
611 " Enable/disable dedicated queues for LACP control traffic.\n\n"
614 "set link-up port (port_id)\n"
615 " Set link up for a port.\n\n"
617 "set link-down port (port_id)\n"
618 " Set link down for a port.\n\n"
620 "E-tag set insertion on port-tag-id (value)"
621 " port (port_id) vf (vf_id)\n"
622 " Enable E-tag insertion for a VF on a port\n\n"
624 "E-tag set insertion off port (port_id) vf (vf_id)\n"
625 " Disable E-tag insertion for a VF on a port\n\n"
627 "E-tag set stripping (on|off) port (port_id)\n"
628 " Enable/disable E-tag stripping on a port\n\n"
630 "E-tag set forwarding (on|off) port (port_id)\n"
631 " Enable/disable E-tag based forwarding"
634 "E-tag set filter add e-tag-id (value) dst-pool"
635 " (pool_id) port (port_id)\n"
636 " Add an E-tag forwarding filter on a port\n\n"
638 "E-tag set filter del e-tag-id (value) port (port_id)\n"
639 " Delete an E-tag forwarding filter on a port\n\n"
641 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
642 "set port tm hierarchy default (port_id)\n"
643 " Set default traffic Management hierarchy on a port\n\n"
646 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
647 " Load a profile package on a port\n\n"
649 "ddp del (port_id) (backup_profile_path)\n"
650 " Delete a profile package from a port\n\n"
652 "ptype mapping get (port_id) (valid_only)\n"
653 " Get ptype mapping on a port\n\n"
655 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
656 " Replace target with the pkt_type in ptype mapping\n\n"
658 "ptype mapping reset (port_id)\n"
659 " Reset ptype mapping on a port\n\n"
661 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
662 " Update a ptype mapping item on a port\n\n"
664 "set port (port_id) queue-region region_id (value) "
665 "queue_start_index (value) queue_num (value)\n"
666 " Set a queue region on a port\n\n"
668 "set port (port_id) queue-region region_id (value) "
670 " Set a flowtype region index on a port\n\n"
672 "set port (port_id) queue-region UP (value) region_id (value)\n"
673 " Set the mapping of User Priority to "
674 "queue region on a port\n\n"
676 "set port (port_id) queue-region flush (on|off)\n"
677 " flush all queue region related configuration\n\n"
679 "show port meter cap (port_id)\n"
680 " Show port meter capability information\n\n"
682 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
683 " meter profile add - srtcm rfc 2697\n\n"
685 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
686 " meter profile add - trtcm rfc 2698\n\n"
688 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
689 " meter profile add - trtcm rfc 4115\n\n"
691 "del port meter profile (port_id) (profile_id)\n"
692 " meter profile delete\n\n"
694 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
695 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
696 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
697 "(dscp_tbl_entry63)]\n"
700 "enable port meter (port_id) (mtr_id)\n"
703 "disable port meter (port_id) (mtr_id)\n"
706 "del port meter (port_id) (mtr_id)\n"
709 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
710 " meter update meter profile\n\n"
712 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
713 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
714 " update meter dscp table entries\n\n"
716 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
717 "(action0) [(action1) (action2)]\n"
718 " meter update policer action\n\n"
720 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
721 " meter update stats\n\n"
723 "show port (port_id) queue-region\n"
724 " show all queue region related configuration info\n\n"
726 "add port tm node shaper profile (port_id) (shaper_profile_id)"
727 " (tb_rate) (tb_size) (packet_length_adjust)\n"
728 " Add port tm node private shaper profile.\n\n"
730 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
731 " Delete port tm node private shaper profile.\n\n"
733 "add port tm node shared shaper (port_id) (shared_shaper_id)"
734 " (shaper_profile_id)\n"
735 " Add/update port tm node shared shaper.\n\n"
737 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
738 " Delete port tm node shared shaper.\n\n"
740 "set port tm node shaper profile (port_id) (node_id)"
741 " (shaper_profile_id)\n"
742 " Set port tm node shaper profile.\n\n"
744 "add port tm node wred profile (port_id) (wred_profile_id)"
745 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
746 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
747 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
748 " Add port tm node wred profile.\n\n"
750 "del port tm node wred profile (port_id) (wred_profile_id)\n"
751 " Delete port tm node wred profile.\n\n"
753 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
754 " (priority) (weight) (level_id) (shaper_profile_id)"
755 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
756 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
757 " Add port tm nonleaf node.\n\n"
759 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
760 " (priority) (weight) (level_id) (shaper_profile_id)"
761 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
762 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
763 " Add port tm leaf node.\n\n"
765 "del port tm node (port_id) (node_id)\n"
766 " Delete port tm node.\n\n"
768 "set port tm node parent (port_id) (node_id) (parent_node_id)"
769 " (priority) (weight)\n"
770 " Set port tm node parent.\n\n"
772 "suspend port tm node (port_id) (node_id)"
773 " Suspend tm node.\n\n"
775 "resume port tm node (port_id) (node_id)"
776 " Resume tm node.\n\n"
778 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
779 " Commit tm hierarchy.\n\n"
781 "vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
782 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
783 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
784 " Configure the VXLAN encapsulation for flows.\n\n"
786 "vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
787 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
788 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
789 " eth-dst (eth-dst)\n"
790 " Configure the VXLAN encapsulation for flows.\n\n"
792 "nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
793 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
795 " Configure the NVGRE encapsulation for flows.\n\n"
797 "nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
798 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
799 " eth-src (eth-src) eth-dst (eth-dst)\n"
800 " Configure the NVGRE encapsulation for flows.\n\n"
802 , list_pkt_forwarding_modes()
806 if (show_all || !strcmp(res->section, "ports")) {
812 "----------------\n\n"
814 "port start (port_id|all)\n"
815 " Start all ports or port_id.\n\n"
817 "port stop (port_id|all)\n"
818 " Stop all ports or port_id.\n\n"
820 "port close (port_id|all)\n"
821 " Close all ports or port_id.\n\n"
823 "port attach (ident)\n"
824 " Attach physical or virtual dev by pci address or virtual device name\n\n"
826 "port detach (port_id)\n"
827 " Detach physical or virtual dev by port_id\n\n"
829 "port config (port_id|all)"
830 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
831 " duplex (half|full|auto)\n"
832 " Set speed and duplex for all ports or port_id\n\n"
834 "port config (port_id|all) loopback (mode)\n"
835 " Set loopback mode for all ports or port_id\n\n"
837 "port config all (rxq|txq|rxd|txd) (value)\n"
838 " Set number for rxq/txq/rxd/txd.\n\n"
840 "port config all max-pkt-len (value)\n"
841 " Set the max packet length.\n\n"
843 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
844 "hw-vlan-strip|hw-vlan-extend|drop-en)"
846 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
849 "port config all rss (all|default|ip|tcp|udp|sctp|"
850 "ether|port|vxlan|geneve|nvgre|none|<flowtype_id>)\n"
851 " Set the RSS mode.\n\n"
853 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
854 " Set the RSS redirection table.\n\n"
856 "port config (port_id) dcb vt (on|off) (traffic_class)"
858 " Set the DCB mode.\n\n"
860 "port config all burst (value)\n"
861 " Set the number of packets per burst.\n\n"
863 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
865 " Set the ring prefetch/host/writeback threshold"
866 " for tx/rx queue.\n\n"
868 "port config all (txfreet|txrst|rxfreet) (value)\n"
869 " Set free threshold for rx/tx, or set"
870 " tx rs bit threshold.\n\n"
871 "port config mtu X value\n"
872 " Set the MTU of port X to a given value\n\n"
874 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
875 " Set a rx/tx queue's ring size configuration, the new"
876 " value will take effect after command that (re-)start the port"
877 " or command that setup the specific queue\n\n"
879 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
880 " Start/stop a rx/tx queue of port X. Only take effect"
881 " when port X is started\n\n"
883 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
884 " Switch on/off a deferred start of port X rx/tx queue. Only"
885 " take effect when port X is stopped.\n\n"
887 "port (port_id) (rxq|txq) (queue_id) setup\n"
888 " Setup a rx/tx queue of port X.\n\n"
890 "port config (port_id|all) l2-tunnel E-tag ether-type"
892 " Set the value of E-tag ether-type.\n\n"
894 "port config (port_id|all) l2-tunnel E-tag"
895 " (enable|disable)\n"
896 " Enable/disable the E-tag support.\n\n"
898 "port config (port_id) pctype mapping reset\n"
899 " Reset flow type to pctype mapping on a port\n\n"
901 "port config (port_id) pctype mapping update"
902 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
903 " Update a flow type to pctype mapping item on a port\n\n"
905 "port config (port_id) pctype (pctype_id) hash_inset|"
906 "fdir_inset|fdir_flx_inset get|set|clear field\n"
908 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
910 "port config (port_id) pctype (pctype_id) hash_inset|"
911 "fdir_inset|fdir_flx_inset clear all"
912 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
914 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
915 " Add/remove UDP tunnel port for tunneling offload\n\n"
919 if (show_all || !strcmp(res->section, "registers")) {
927 "read reg (port_id) (address)\n"
928 " Display value of a port register.\n\n"
930 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
931 " Display a port register bit field.\n\n"
933 "read regbit (port_id) (address) (bit_x)\n"
934 " Display a single port register bit.\n\n"
936 "write reg (port_id) (address) (value)\n"
937 " Set value of a port register.\n\n"
939 "write regfield (port_id) (address) (bit_x) (bit_y)"
941 " Set bit field of a port register.\n\n"
943 "write regbit (port_id) (address) (bit_x) (value)\n"
944 " Set single bit value of a port register.\n\n"
947 if (show_all || !strcmp(res->section, "filters")) {
955 "ethertype_filter (port_id) (add|del)"
956 " (mac_addr|mac_ignr) (mac_address) ethertype"
957 " (ether_type) (drop|fwd) queue (queue_id)\n"
958 " Add/Del an ethertype filter.\n\n"
960 "2tuple_filter (port_id) (add|del)"
961 " dst_port (dst_port_value) protocol (protocol_value)"
962 " mask (mask_value) tcp_flags (tcp_flags_value)"
963 " priority (prio_value) queue (queue_id)\n"
964 " Add/Del a 2tuple filter.\n\n"
966 "5tuple_filter (port_id) (add|del)"
967 " dst_ip (dst_address) src_ip (src_address)"
968 " dst_port (dst_port_value) src_port (src_port_value)"
969 " protocol (protocol_value)"
970 " mask (mask_value) tcp_flags (tcp_flags_value)"
971 " priority (prio_value) queue (queue_id)\n"
972 " Add/Del a 5tuple filter.\n\n"
974 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
975 " Add/Del syn filter.\n\n"
977 "flex_filter (port_id) (add|del) len (len_value)"
978 " bytes (bytes_value) mask (mask_value)"
979 " priority (prio_value) queue (queue_id)\n"
980 " Add/Del a flex filter.\n\n"
982 "flow_director_filter (port_id) mode IP (add|del|update)"
983 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
984 " src (src_ip_address) dst (dst_ip_address)"
985 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
986 " vlan (vlan_value) flexbytes (flexbytes_value)"
987 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
988 " fd_id (fd_id_value)\n"
989 " Add/Del an IP type flow director filter.\n\n"
991 "flow_director_filter (port_id) mode IP (add|del|update)"
992 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
993 " src (src_ip_address) (src_port)"
994 " dst (dst_ip_address) (dst_port)"
995 " tos (tos_value) ttl (ttl_value)"
996 " vlan (vlan_value) flexbytes (flexbytes_value)"
997 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
998 " fd_id (fd_id_value)\n"
999 " Add/Del an UDP/TCP type flow director filter.\n\n"
1001 "flow_director_filter (port_id) mode IP (add|del|update)"
1002 " flow (ipv4-sctp|ipv6-sctp)"
1003 " src (src_ip_address) (src_port)"
1004 " dst (dst_ip_address) (dst_port)"
1005 " tag (verification_tag) "
1006 " tos (tos_value) ttl (ttl_value)"
1007 " vlan (vlan_value)"
1008 " flexbytes (flexbytes_value) (drop|fwd)"
1009 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1010 " Add/Del a SCTP type flow director filter.\n\n"
1012 "flow_director_filter (port_id) mode IP (add|del|update)"
1013 " flow l2_payload ether (ethertype)"
1014 " flexbytes (flexbytes_value) (drop|fwd)"
1015 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1016 " Add/Del a l2 payload type flow director filter.\n\n"
1018 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1019 " mac (mac_address) vlan (vlan_value)"
1020 " flexbytes (flexbytes_value) (drop|fwd)"
1021 " queue (queue_id) fd_id (fd_id_value)\n"
1022 " Add/Del a MAC-VLAN flow director filter.\n\n"
1024 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1025 " mac (mac_address) vlan (vlan_value)"
1026 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1027 " flexbytes (flexbytes_value) (drop|fwd)"
1028 " queue (queue_id) fd_id (fd_id_value)\n"
1029 " Add/Del a Tunnel flow director filter.\n\n"
1031 "flow_director_filter (port_id) mode raw (add|del|update)"
1032 " flow (flow_id) (drop|fwd) queue (queue_id)"
1033 " fd_id (fd_id_value) packet (packet file name)\n"
1034 " Add/Del a raw type flow director filter.\n\n"
1036 "flush_flow_director (port_id)\n"
1037 " Flush all flow director entries of a device.\n\n"
1039 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1040 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1041 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1042 " Set flow director IP mask.\n\n"
1044 "flow_director_mask (port_id) mode MAC-VLAN"
1045 " vlan (vlan_value)\n"
1046 " Set flow director MAC-VLAN mask.\n\n"
1048 "flow_director_mask (port_id) mode Tunnel"
1049 " vlan (vlan_value) mac (mac_value)"
1050 " tunnel-type (tunnel_type_value)"
1051 " tunnel-id (tunnel_id_value)\n"
1052 " Set flow director Tunnel mask.\n\n"
1054 "flow_director_flex_mask (port_id)"
1055 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1056 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1058 " Configure mask of flex payload.\n\n"
1060 "flow_director_flex_payload (port_id)"
1061 " (raw|l2|l3|l4) (config)\n"
1062 " Configure flex payload selection.\n\n"
1064 "get_sym_hash_ena_per_port (port_id)\n"
1065 " get symmetric hash enable configuration per port.\n\n"
1067 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1068 " set symmetric hash enable configuration per port"
1069 " to enable or disable.\n\n"
1071 "get_hash_global_config (port_id)\n"
1072 " Get the global configurations of hash filters.\n\n"
1074 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1075 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1076 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1077 " (enable|disable)\n"
1078 " Set the global configurations of hash filters.\n\n"
1080 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1081 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1082 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1083 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1084 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1085 "ipv6-next-header|udp-src-port|udp-dst-port|"
1086 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1087 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1088 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1089 "fld-8th|none) (select|add)\n"
1090 " Set the input set for hash.\n\n"
1092 "set_fdir_input_set (port_id) "
1093 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1094 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1095 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1096 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1097 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1098 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1099 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1101 " Set the input set for FDir.\n\n"
1103 "flow validate {port_id}"
1104 " [group {group_id}] [priority {level}]"
1105 " [ingress] [egress]"
1106 " pattern {item} [/ {item} [...]] / end"
1107 " actions {action} [/ {action} [...]] / end\n"
1108 " Check whether a flow rule can be created.\n\n"
1110 "flow create {port_id}"
1111 " [group {group_id}] [priority {level}]"
1112 " [ingress] [egress]"
1113 " pattern {item} [/ {item} [...]] / end"
1114 " actions {action} [/ {action} [...]] / end\n"
1115 " Create a flow rule.\n\n"
1117 "flow destroy {port_id} rule {rule_id} [...]\n"
1118 " Destroy specific flow rules.\n\n"
1120 "flow flush {port_id}\n"
1121 " Destroy all flow rules.\n\n"
1123 "flow query {port_id} {rule_id} {action}\n"
1124 " Query an existing flow rule.\n\n"
1126 "flow list {port_id} [group {group_id}] [...]\n"
1127 " List existing flow rules sorted by priority,"
1128 " filtered by group identifiers.\n\n"
1130 "flow isolate {port_id} {boolean}\n"
1131 " Restrict ingress traffic to the defined"
1137 cmdline_parse_token_string_t cmd_help_long_help =
1138 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1140 cmdline_parse_token_string_t cmd_help_long_section =
1141 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1142 "all#control#display#config#"
1143 "ports#registers#filters");
1145 cmdline_parse_inst_t cmd_help_long = {
1146 .f = cmd_help_long_parsed,
1148 .help_str = "help all|control|display|config|ports|register|filters: "
1151 (void *)&cmd_help_long_help,
1152 (void *)&cmd_help_long_section,
1158 /* *** start/stop/close all ports *** */
1159 struct cmd_operate_port_result {
1160 cmdline_fixed_string_t keyword;
1161 cmdline_fixed_string_t name;
1162 cmdline_fixed_string_t value;
1165 static void cmd_operate_port_parsed(void *parsed_result,
1166 __attribute__((unused)) struct cmdline *cl,
1167 __attribute__((unused)) void *data)
1169 struct cmd_operate_port_result *res = parsed_result;
1171 if (!strcmp(res->name, "start"))
1172 start_port(RTE_PORT_ALL);
1173 else if (!strcmp(res->name, "stop"))
1174 stop_port(RTE_PORT_ALL);
1175 else if (!strcmp(res->name, "close"))
1176 close_port(RTE_PORT_ALL);
1177 else if (!strcmp(res->name, "reset"))
1178 reset_port(RTE_PORT_ALL);
1180 printf("Unknown parameter\n");
1183 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1184 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1186 cmdline_parse_token_string_t cmd_operate_port_all_port =
1187 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1188 "start#stop#close#reset");
1189 cmdline_parse_token_string_t cmd_operate_port_all_all =
1190 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1192 cmdline_parse_inst_t cmd_operate_port = {
1193 .f = cmd_operate_port_parsed,
1195 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1197 (void *)&cmd_operate_port_all_cmd,
1198 (void *)&cmd_operate_port_all_port,
1199 (void *)&cmd_operate_port_all_all,
1204 /* *** start/stop/close specific port *** */
1205 struct cmd_operate_specific_port_result {
1206 cmdline_fixed_string_t keyword;
1207 cmdline_fixed_string_t name;
1211 static void cmd_operate_specific_port_parsed(void *parsed_result,
1212 __attribute__((unused)) struct cmdline *cl,
1213 __attribute__((unused)) void *data)
1215 struct cmd_operate_specific_port_result *res = parsed_result;
1217 if (!strcmp(res->name, "start"))
1218 start_port(res->value);
1219 else if (!strcmp(res->name, "stop"))
1220 stop_port(res->value);
1221 else if (!strcmp(res->name, "close"))
1222 close_port(res->value);
1223 else if (!strcmp(res->name, "reset"))
1224 reset_port(res->value);
1226 printf("Unknown parameter\n");
1229 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1230 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1232 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1233 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1234 name, "start#stop#close#reset");
1235 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1236 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1239 cmdline_parse_inst_t cmd_operate_specific_port = {
1240 .f = cmd_operate_specific_port_parsed,
1242 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1244 (void *)&cmd_operate_specific_port_cmd,
1245 (void *)&cmd_operate_specific_port_port,
1246 (void *)&cmd_operate_specific_port_id,
1251 /* *** attach a specified port *** */
1252 struct cmd_operate_attach_port_result {
1253 cmdline_fixed_string_t port;
1254 cmdline_fixed_string_t keyword;
1255 cmdline_fixed_string_t identifier;
1258 static void cmd_operate_attach_port_parsed(void *parsed_result,
1259 __attribute__((unused)) struct cmdline *cl,
1260 __attribute__((unused)) void *data)
1262 struct cmd_operate_attach_port_result *res = parsed_result;
1264 if (!strcmp(res->keyword, "attach"))
1265 attach_port(res->identifier);
1267 printf("Unknown parameter\n");
1270 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1271 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1273 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1274 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1276 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1277 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1280 cmdline_parse_inst_t cmd_operate_attach_port = {
1281 .f = cmd_operate_attach_port_parsed,
1283 .help_str = "port attach <identifier>: "
1284 "(identifier: pci address or virtual dev name)",
1286 (void *)&cmd_operate_attach_port_port,
1287 (void *)&cmd_operate_attach_port_keyword,
1288 (void *)&cmd_operate_attach_port_identifier,
1293 /* *** detach a specified port *** */
1294 struct cmd_operate_detach_port_result {
1295 cmdline_fixed_string_t port;
1296 cmdline_fixed_string_t keyword;
1300 static void cmd_operate_detach_port_parsed(void *parsed_result,
1301 __attribute__((unused)) struct cmdline *cl,
1302 __attribute__((unused)) void *data)
1304 struct cmd_operate_detach_port_result *res = parsed_result;
1306 if (!strcmp(res->keyword, "detach"))
1307 detach_port(res->port_id);
1309 printf("Unknown parameter\n");
1312 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1313 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1315 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1316 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1318 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1319 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1322 cmdline_parse_inst_t cmd_operate_detach_port = {
1323 .f = cmd_operate_detach_port_parsed,
1325 .help_str = "port detach <port_id>",
1327 (void *)&cmd_operate_detach_port_port,
1328 (void *)&cmd_operate_detach_port_keyword,
1329 (void *)&cmd_operate_detach_port_port_id,
1334 /* *** configure speed for all ports *** */
1335 struct cmd_config_speed_all {
1336 cmdline_fixed_string_t port;
1337 cmdline_fixed_string_t keyword;
1338 cmdline_fixed_string_t all;
1339 cmdline_fixed_string_t item1;
1340 cmdline_fixed_string_t item2;
1341 cmdline_fixed_string_t value1;
1342 cmdline_fixed_string_t value2;
1346 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1351 if (!strcmp(duplexstr, "half")) {
1352 duplex = ETH_LINK_HALF_DUPLEX;
1353 } else if (!strcmp(duplexstr, "full")) {
1354 duplex = ETH_LINK_FULL_DUPLEX;
1355 } else if (!strcmp(duplexstr, "auto")) {
1356 duplex = ETH_LINK_FULL_DUPLEX;
1358 printf("Unknown duplex parameter\n");
1362 if (!strcmp(speedstr, "10")) {
1363 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1364 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1365 } else if (!strcmp(speedstr, "100")) {
1366 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1367 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1369 if (duplex != ETH_LINK_FULL_DUPLEX) {
1370 printf("Invalid speed/duplex parameters\n");
1373 if (!strcmp(speedstr, "1000")) {
1374 *speed = ETH_LINK_SPEED_1G;
1375 } else if (!strcmp(speedstr, "10000")) {
1376 *speed = ETH_LINK_SPEED_10G;
1377 } else if (!strcmp(speedstr, "25000")) {
1378 *speed = ETH_LINK_SPEED_25G;
1379 } else if (!strcmp(speedstr, "40000")) {
1380 *speed = ETH_LINK_SPEED_40G;
1381 } else if (!strcmp(speedstr, "50000")) {
1382 *speed = ETH_LINK_SPEED_50G;
1383 } else if (!strcmp(speedstr, "100000")) {
1384 *speed = ETH_LINK_SPEED_100G;
1385 } else if (!strcmp(speedstr, "auto")) {
1386 *speed = ETH_LINK_SPEED_AUTONEG;
1388 printf("Unknown speed parameter\n");
1397 cmd_config_speed_all_parsed(void *parsed_result,
1398 __attribute__((unused)) struct cmdline *cl,
1399 __attribute__((unused)) void *data)
1401 struct cmd_config_speed_all *res = parsed_result;
1402 uint32_t link_speed;
1405 if (!all_ports_stopped()) {
1406 printf("Please stop all ports first\n");
1410 if (parse_and_check_speed_duplex(res->value1, res->value2,
1414 RTE_ETH_FOREACH_DEV(pid) {
1415 ports[pid].dev_conf.link_speeds = link_speed;
1418 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1421 cmdline_parse_token_string_t cmd_config_speed_all_port =
1422 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1423 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1424 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1426 cmdline_parse_token_string_t cmd_config_speed_all_all =
1427 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1428 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1429 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1430 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1431 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1432 "10#100#1000#10000#25000#40000#50000#100000#auto");
1433 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1434 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1435 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1436 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1439 cmdline_parse_inst_t cmd_config_speed_all = {
1440 .f = cmd_config_speed_all_parsed,
1442 .help_str = "port config all speed "
1443 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1446 (void *)&cmd_config_speed_all_port,
1447 (void *)&cmd_config_speed_all_keyword,
1448 (void *)&cmd_config_speed_all_all,
1449 (void *)&cmd_config_speed_all_item1,
1450 (void *)&cmd_config_speed_all_value1,
1451 (void *)&cmd_config_speed_all_item2,
1452 (void *)&cmd_config_speed_all_value2,
1457 /* *** configure speed for specific port *** */
1458 struct cmd_config_speed_specific {
1459 cmdline_fixed_string_t port;
1460 cmdline_fixed_string_t keyword;
1462 cmdline_fixed_string_t item1;
1463 cmdline_fixed_string_t item2;
1464 cmdline_fixed_string_t value1;
1465 cmdline_fixed_string_t value2;
1469 cmd_config_speed_specific_parsed(void *parsed_result,
1470 __attribute__((unused)) struct cmdline *cl,
1471 __attribute__((unused)) void *data)
1473 struct cmd_config_speed_specific *res = parsed_result;
1474 uint32_t link_speed;
1476 if (!all_ports_stopped()) {
1477 printf("Please stop all ports first\n");
1481 if (port_id_is_invalid(res->id, ENABLED_WARN))
1484 if (parse_and_check_speed_duplex(res->value1, res->value2,
1488 ports[res->id].dev_conf.link_speeds = link_speed;
1490 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1494 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1495 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1497 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1498 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1500 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1501 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1502 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1503 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1505 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1506 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1507 "10#100#1000#10000#25000#40000#50000#100000#auto");
1508 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1509 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1511 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1512 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1515 cmdline_parse_inst_t cmd_config_speed_specific = {
1516 .f = cmd_config_speed_specific_parsed,
1518 .help_str = "port config <port_id> speed "
1519 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1522 (void *)&cmd_config_speed_specific_port,
1523 (void *)&cmd_config_speed_specific_keyword,
1524 (void *)&cmd_config_speed_specific_id,
1525 (void *)&cmd_config_speed_specific_item1,
1526 (void *)&cmd_config_speed_specific_value1,
1527 (void *)&cmd_config_speed_specific_item2,
1528 (void *)&cmd_config_speed_specific_value2,
1533 /* *** configure loopback for all ports *** */
1534 struct cmd_config_loopback_all {
1535 cmdline_fixed_string_t port;
1536 cmdline_fixed_string_t keyword;
1537 cmdline_fixed_string_t all;
1538 cmdline_fixed_string_t item;
1543 cmd_config_loopback_all_parsed(void *parsed_result,
1544 __attribute__((unused)) struct cmdline *cl,
1545 __attribute__((unused)) void *data)
1547 struct cmd_config_loopback_all *res = parsed_result;
1550 if (!all_ports_stopped()) {
1551 printf("Please stop all ports first\n");
1555 RTE_ETH_FOREACH_DEV(pid) {
1556 ports[pid].dev_conf.lpbk_mode = res->mode;
1559 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1562 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1563 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1564 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1565 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1567 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1568 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1569 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1570 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1572 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1573 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1575 cmdline_parse_inst_t cmd_config_loopback_all = {
1576 .f = cmd_config_loopback_all_parsed,
1578 .help_str = "port config all loopback <mode>",
1580 (void *)&cmd_config_loopback_all_port,
1581 (void *)&cmd_config_loopback_all_keyword,
1582 (void *)&cmd_config_loopback_all_all,
1583 (void *)&cmd_config_loopback_all_item,
1584 (void *)&cmd_config_loopback_all_mode,
1589 /* *** configure loopback for specific port *** */
1590 struct cmd_config_loopback_specific {
1591 cmdline_fixed_string_t port;
1592 cmdline_fixed_string_t keyword;
1594 cmdline_fixed_string_t item;
1599 cmd_config_loopback_specific_parsed(void *parsed_result,
1600 __attribute__((unused)) struct cmdline *cl,
1601 __attribute__((unused)) void *data)
1603 struct cmd_config_loopback_specific *res = parsed_result;
1605 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1608 if (!port_is_stopped(res->port_id)) {
1609 printf("Please stop port %u first\n", res->port_id);
1613 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1615 cmd_reconfig_device_queue(res->port_id, 1, 1);
1619 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1620 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1622 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1623 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1625 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1626 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1628 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1629 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1631 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1632 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1635 cmdline_parse_inst_t cmd_config_loopback_specific = {
1636 .f = cmd_config_loopback_specific_parsed,
1638 .help_str = "port config <port_id> loopback <mode>",
1640 (void *)&cmd_config_loopback_specific_port,
1641 (void *)&cmd_config_loopback_specific_keyword,
1642 (void *)&cmd_config_loopback_specific_id,
1643 (void *)&cmd_config_loopback_specific_item,
1644 (void *)&cmd_config_loopback_specific_mode,
1649 /* *** configure txq/rxq, txd/rxd *** */
1650 struct cmd_config_rx_tx {
1651 cmdline_fixed_string_t port;
1652 cmdline_fixed_string_t keyword;
1653 cmdline_fixed_string_t all;
1654 cmdline_fixed_string_t name;
1659 cmd_config_rx_tx_parsed(void *parsed_result,
1660 __attribute__((unused)) struct cmdline *cl,
1661 __attribute__((unused)) void *data)
1663 struct cmd_config_rx_tx *res = parsed_result;
1665 if (!all_ports_stopped()) {
1666 printf("Please stop all ports first\n");
1669 if (!strcmp(res->name, "rxq")) {
1670 if (!res->value && !nb_txq) {
1671 printf("Warning: Either rx or tx queues should be non zero\n");
1674 if (check_nb_rxq(res->value) != 0)
1676 nb_rxq = res->value;
1678 else if (!strcmp(res->name, "txq")) {
1679 if (!res->value && !nb_rxq) {
1680 printf("Warning: Either rx or tx queues should be non zero\n");
1683 if (check_nb_txq(res->value) != 0)
1685 nb_txq = res->value;
1687 else if (!strcmp(res->name, "rxd")) {
1688 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1689 printf("rxd %d invalid - must be > 0 && <= %d\n",
1690 res->value, RTE_TEST_RX_DESC_MAX);
1693 nb_rxd = res->value;
1694 } else if (!strcmp(res->name, "txd")) {
1695 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1696 printf("txd %d invalid - must be > 0 && <= %d\n",
1697 res->value, RTE_TEST_TX_DESC_MAX);
1700 nb_txd = res->value;
1702 printf("Unknown parameter\n");
1710 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1713 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1714 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1715 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1716 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1717 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1718 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1719 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1720 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1722 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1723 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1725 cmdline_parse_inst_t cmd_config_rx_tx = {
1726 .f = cmd_config_rx_tx_parsed,
1728 .help_str = "port config all rxq|txq|rxd|txd <value>",
1730 (void *)&cmd_config_rx_tx_port,
1731 (void *)&cmd_config_rx_tx_keyword,
1732 (void *)&cmd_config_rx_tx_all,
1733 (void *)&cmd_config_rx_tx_name,
1734 (void *)&cmd_config_rx_tx_value,
1739 /* *** config max packet length *** */
1740 struct cmd_config_max_pkt_len_result {
1741 cmdline_fixed_string_t port;
1742 cmdline_fixed_string_t keyword;
1743 cmdline_fixed_string_t all;
1744 cmdline_fixed_string_t name;
1749 cmd_config_max_pkt_len_parsed(void *parsed_result,
1750 __attribute__((unused)) struct cmdline *cl,
1751 __attribute__((unused)) void *data)
1753 struct cmd_config_max_pkt_len_result *res = parsed_result;
1756 if (!all_ports_stopped()) {
1757 printf("Please stop all ports first\n");
1761 RTE_ETH_FOREACH_DEV(pid) {
1762 struct rte_port *port = &ports[pid];
1763 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1765 if (!strcmp(res->name, "max-pkt-len")) {
1766 if (res->value < ETHER_MIN_LEN) {
1767 printf("max-pkt-len can not be less than %d\n",
1771 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1774 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1775 if (res->value > ETHER_MAX_LEN)
1776 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1778 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1779 port->dev_conf.rxmode.offloads = rx_offloads;
1781 printf("Unknown parameter\n");
1788 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1791 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1792 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1794 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1795 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1797 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1798 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1800 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1801 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1803 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1804 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1807 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1808 .f = cmd_config_max_pkt_len_parsed,
1810 .help_str = "port config all max-pkt-len <value>",
1812 (void *)&cmd_config_max_pkt_len_port,
1813 (void *)&cmd_config_max_pkt_len_keyword,
1814 (void *)&cmd_config_max_pkt_len_all,
1815 (void *)&cmd_config_max_pkt_len_name,
1816 (void *)&cmd_config_max_pkt_len_value,
1821 /* *** configure port MTU *** */
1822 struct cmd_config_mtu_result {
1823 cmdline_fixed_string_t port;
1824 cmdline_fixed_string_t keyword;
1825 cmdline_fixed_string_t mtu;
1831 cmd_config_mtu_parsed(void *parsed_result,
1832 __attribute__((unused)) struct cmdline *cl,
1833 __attribute__((unused)) void *data)
1835 struct cmd_config_mtu_result *res = parsed_result;
1837 if (res->value < ETHER_MIN_LEN) {
1838 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1841 port_mtu_set(res->port_id, res->value);
1844 cmdline_parse_token_string_t cmd_config_mtu_port =
1845 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1847 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1848 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1850 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1851 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1853 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1854 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1855 cmdline_parse_token_num_t cmd_config_mtu_value =
1856 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1858 cmdline_parse_inst_t cmd_config_mtu = {
1859 .f = cmd_config_mtu_parsed,
1861 .help_str = "port config mtu <port_id> <value>",
1863 (void *)&cmd_config_mtu_port,
1864 (void *)&cmd_config_mtu_keyword,
1865 (void *)&cmd_config_mtu_mtu,
1866 (void *)&cmd_config_mtu_port_id,
1867 (void *)&cmd_config_mtu_value,
1872 /* *** configure rx mode *** */
1873 struct cmd_config_rx_mode_flag {
1874 cmdline_fixed_string_t port;
1875 cmdline_fixed_string_t keyword;
1876 cmdline_fixed_string_t all;
1877 cmdline_fixed_string_t name;
1878 cmdline_fixed_string_t value;
1882 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1883 __attribute__((unused)) struct cmdline *cl,
1884 __attribute__((unused)) void *data)
1886 struct cmd_config_rx_mode_flag *res = parsed_result;
1889 if (!all_ports_stopped()) {
1890 printf("Please stop all ports first\n");
1894 RTE_ETH_FOREACH_DEV(pid) {
1895 struct rte_port *port;
1896 uint64_t rx_offloads;
1899 rx_offloads = port->dev_conf.rxmode.offloads;
1900 if (!strcmp(res->name, "crc-strip")) {
1901 if (!strcmp(res->value, "on")) {
1902 rx_offloads &= ~DEV_RX_OFFLOAD_KEEP_CRC;
1903 } else if (!strcmp(res->value, "off")) {
1904 rx_offloads |= DEV_RX_OFFLOAD_KEEP_CRC;
1906 printf("Unknown parameter\n");
1909 } else if (!strcmp(res->name, "scatter")) {
1910 if (!strcmp(res->value, "on")) {
1911 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1912 } else if (!strcmp(res->value, "off")) {
1913 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1915 printf("Unknown parameter\n");
1918 } else if (!strcmp(res->name, "rx-cksum")) {
1919 if (!strcmp(res->value, "on"))
1920 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1921 else if (!strcmp(res->value, "off"))
1922 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1924 printf("Unknown parameter\n");
1927 } else if (!strcmp(res->name, "rx-timestamp")) {
1928 if (!strcmp(res->value, "on"))
1929 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1930 else if (!strcmp(res->value, "off"))
1931 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1933 printf("Unknown parameter\n");
1936 } else if (!strcmp(res->name, "hw-vlan")) {
1937 if (!strcmp(res->value, "on")) {
1938 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1939 DEV_RX_OFFLOAD_VLAN_STRIP);
1940 } else if (!strcmp(res->value, "off")) {
1941 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1942 DEV_RX_OFFLOAD_VLAN_STRIP);
1944 printf("Unknown parameter\n");
1947 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1948 if (!strcmp(res->value, "on"))
1949 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1950 else if (!strcmp(res->value, "off"))
1951 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1953 printf("Unknown parameter\n");
1956 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1957 if (!strcmp(res->value, "on"))
1958 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1959 else if (!strcmp(res->value, "off"))
1960 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1962 printf("Unknown parameter\n");
1965 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1966 if (!strcmp(res->value, "on"))
1967 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1968 else if (!strcmp(res->value, "off"))
1969 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1971 printf("Unknown parameter\n");
1974 } else if (!strcmp(res->name, "drop-en")) {
1975 if (!strcmp(res->value, "on"))
1977 else if (!strcmp(res->value, "off"))
1980 printf("Unknown parameter\n");
1984 printf("Unknown parameter\n");
1987 port->dev_conf.rxmode.offloads = rx_offloads;
1992 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1995 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1996 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1997 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1998 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2000 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2001 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2002 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2003 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2004 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
2005 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
2006 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2007 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2010 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2011 .f = cmd_config_rx_mode_flag_parsed,
2013 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
2014 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
2016 (void *)&cmd_config_rx_mode_flag_port,
2017 (void *)&cmd_config_rx_mode_flag_keyword,
2018 (void *)&cmd_config_rx_mode_flag_all,
2019 (void *)&cmd_config_rx_mode_flag_name,
2020 (void *)&cmd_config_rx_mode_flag_value,
2025 /* *** configure rss *** */
2026 struct cmd_config_rss {
2027 cmdline_fixed_string_t port;
2028 cmdline_fixed_string_t keyword;
2029 cmdline_fixed_string_t all;
2030 cmdline_fixed_string_t name;
2031 cmdline_fixed_string_t value;
2035 cmd_config_rss_parsed(void *parsed_result,
2036 __attribute__((unused)) struct cmdline *cl,
2037 __attribute__((unused)) void *data)
2039 struct cmd_config_rss *res = parsed_result;
2040 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2041 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2042 int use_default = 0;
2043 int all_updated = 1;
2047 if (!strcmp(res->value, "all"))
2048 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2049 ETH_RSS_UDP | ETH_RSS_SCTP |
2051 else if (!strcmp(res->value, "ip"))
2052 rss_conf.rss_hf = ETH_RSS_IP;
2053 else if (!strcmp(res->value, "udp"))
2054 rss_conf.rss_hf = ETH_RSS_UDP;
2055 else if (!strcmp(res->value, "tcp"))
2056 rss_conf.rss_hf = ETH_RSS_TCP;
2057 else if (!strcmp(res->value, "sctp"))
2058 rss_conf.rss_hf = ETH_RSS_SCTP;
2059 else if (!strcmp(res->value, "ether"))
2060 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2061 else if (!strcmp(res->value, "port"))
2062 rss_conf.rss_hf = ETH_RSS_PORT;
2063 else if (!strcmp(res->value, "vxlan"))
2064 rss_conf.rss_hf = ETH_RSS_VXLAN;
2065 else if (!strcmp(res->value, "geneve"))
2066 rss_conf.rss_hf = ETH_RSS_GENEVE;
2067 else if (!strcmp(res->value, "nvgre"))
2068 rss_conf.rss_hf = ETH_RSS_NVGRE;
2069 else if (!strcmp(res->value, "none"))
2070 rss_conf.rss_hf = 0;
2071 else if (!strcmp(res->value, "default"))
2073 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2074 atoi(res->value) < 64)
2075 rss_conf.rss_hf = 1ULL << atoi(res->value);
2077 printf("Unknown parameter\n");
2080 rss_conf.rss_key = NULL;
2081 /* Update global configuration for RSS types. */
2082 RTE_ETH_FOREACH_DEV(i) {
2083 struct rte_eth_rss_conf local_rss_conf;
2085 rte_eth_dev_info_get(i, &dev_info);
2087 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2089 local_rss_conf = rss_conf;
2090 local_rss_conf.rss_hf = rss_conf.rss_hf &
2091 dev_info.flow_type_rss_offloads;
2092 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2093 printf("Port %u modified RSS hash function based on hardware support,"
2094 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2095 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2097 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2100 printf("Configuration of RSS hash at ethernet port %d "
2101 "failed with error (%d): %s.\n",
2102 i, -diag, strerror(-diag));
2105 if (all_updated && !use_default)
2106 rss_hf = rss_conf.rss_hf;
2109 cmdline_parse_token_string_t cmd_config_rss_port =
2110 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2111 cmdline_parse_token_string_t cmd_config_rss_keyword =
2112 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2113 cmdline_parse_token_string_t cmd_config_rss_all =
2114 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2115 cmdline_parse_token_string_t cmd_config_rss_name =
2116 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2117 cmdline_parse_token_string_t cmd_config_rss_value =
2118 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2120 cmdline_parse_inst_t cmd_config_rss = {
2121 .f = cmd_config_rss_parsed,
2123 .help_str = "port config all rss "
2124 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
2126 (void *)&cmd_config_rss_port,
2127 (void *)&cmd_config_rss_keyword,
2128 (void *)&cmd_config_rss_all,
2129 (void *)&cmd_config_rss_name,
2130 (void *)&cmd_config_rss_value,
2135 /* *** configure rss hash key *** */
2136 struct cmd_config_rss_hash_key {
2137 cmdline_fixed_string_t port;
2138 cmdline_fixed_string_t config;
2140 cmdline_fixed_string_t rss_hash_key;
2141 cmdline_fixed_string_t rss_type;
2142 cmdline_fixed_string_t key;
2146 hexa_digit_to_value(char hexa_digit)
2148 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2149 return (uint8_t) (hexa_digit - '0');
2150 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2151 return (uint8_t) ((hexa_digit - 'a') + 10);
2152 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2153 return (uint8_t) ((hexa_digit - 'A') + 10);
2154 /* Invalid hexa digit */
2159 parse_and_check_key_hexa_digit(char *key, int idx)
2163 hexa_v = hexa_digit_to_value(key[idx]);
2165 printf("invalid key: character %c at position %d is not a "
2166 "valid hexa digit\n", key[idx], idx);
2171 cmd_config_rss_hash_key_parsed(void *parsed_result,
2172 __attribute__((unused)) struct cmdline *cl,
2173 __attribute__((unused)) void *data)
2175 struct cmd_config_rss_hash_key *res = parsed_result;
2176 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2180 struct rte_eth_dev_info dev_info;
2181 uint8_t hash_key_size;
2184 memset(&dev_info, 0, sizeof(dev_info));
2185 rte_eth_dev_info_get(res->port_id, &dev_info);
2186 if (dev_info.hash_key_size > 0 &&
2187 dev_info.hash_key_size <= sizeof(hash_key))
2188 hash_key_size = dev_info.hash_key_size;
2190 printf("dev_info did not provide a valid hash key size\n");
2193 /* Check the length of the RSS hash key */
2194 key_len = strlen(res->key);
2195 if (key_len != (hash_key_size * 2)) {
2196 printf("key length: %d invalid - key must be a string of %d"
2197 " hexa-decimal numbers\n",
2198 (int) key_len, hash_key_size * 2);
2201 /* Translate RSS hash key into binary representation */
2202 for (i = 0; i < hash_key_size; i++) {
2203 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2206 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2209 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2211 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2215 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2216 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2217 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2218 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2220 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2221 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2222 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2223 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2224 rss_hash_key, "rss-hash-key");
2225 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2226 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2227 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2228 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2229 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2230 "ipv6-tcp-ex#ipv6-udp-ex");
2231 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2232 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2234 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2235 .f = cmd_config_rss_hash_key_parsed,
2237 .help_str = "port config <port_id> rss-hash-key "
2238 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2239 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2240 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2241 "<string of hex digits (variable length, NIC dependent)>",
2243 (void *)&cmd_config_rss_hash_key_port,
2244 (void *)&cmd_config_rss_hash_key_config,
2245 (void *)&cmd_config_rss_hash_key_port_id,
2246 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2247 (void *)&cmd_config_rss_hash_key_rss_type,
2248 (void *)&cmd_config_rss_hash_key_value,
2253 /* *** configure port rxq/txq ring size *** */
2254 struct cmd_config_rxtx_ring_size {
2255 cmdline_fixed_string_t port;
2256 cmdline_fixed_string_t config;
2258 cmdline_fixed_string_t rxtxq;
2260 cmdline_fixed_string_t rsize;
2265 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2266 __attribute__((unused)) struct cmdline *cl,
2267 __attribute__((unused)) void *data)
2269 struct cmd_config_rxtx_ring_size *res = parsed_result;
2270 struct rte_port *port;
2273 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2276 if (res->portid == (portid_t)RTE_PORT_ALL) {
2277 printf("Invalid port id\n");
2281 port = &ports[res->portid];
2283 if (!strcmp(res->rxtxq, "rxq"))
2285 else if (!strcmp(res->rxtxq, "txq"))
2288 printf("Unknown parameter\n");
2292 if (isrx && rx_queue_id_is_invalid(res->qid))
2294 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2297 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2298 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2304 port->nb_rx_desc[res->qid] = res->size;
2306 port->nb_tx_desc[res->qid] = res->size;
2308 cmd_reconfig_device_queue(res->portid, 0, 1);
2311 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2312 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2314 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2315 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2317 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2318 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2320 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2321 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2323 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2324 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2326 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2327 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2328 rsize, "ring_size");
2329 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2330 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2333 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2334 .f = cmd_config_rxtx_ring_size_parsed,
2336 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2338 (void *)&cmd_config_rxtx_ring_size_port,
2339 (void *)&cmd_config_rxtx_ring_size_config,
2340 (void *)&cmd_config_rxtx_ring_size_portid,
2341 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2342 (void *)&cmd_config_rxtx_ring_size_qid,
2343 (void *)&cmd_config_rxtx_ring_size_rsize,
2344 (void *)&cmd_config_rxtx_ring_size_size,
2349 /* *** configure port rxq/txq start/stop *** */
2350 struct cmd_config_rxtx_queue {
2351 cmdline_fixed_string_t port;
2353 cmdline_fixed_string_t rxtxq;
2355 cmdline_fixed_string_t opname;
2359 cmd_config_rxtx_queue_parsed(void *parsed_result,
2360 __attribute__((unused)) struct cmdline *cl,
2361 __attribute__((unused)) void *data)
2363 struct cmd_config_rxtx_queue *res = parsed_result;
2368 if (test_done == 0) {
2369 printf("Please stop forwarding first\n");
2373 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2376 if (port_is_started(res->portid) != 1) {
2377 printf("Please start port %u first\n", res->portid);
2381 if (!strcmp(res->rxtxq, "rxq"))
2383 else if (!strcmp(res->rxtxq, "txq"))
2386 printf("Unknown parameter\n");
2390 if (isrx && rx_queue_id_is_invalid(res->qid))
2392 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2395 if (!strcmp(res->opname, "start"))
2397 else if (!strcmp(res->opname, "stop"))
2400 printf("Unknown parameter\n");
2404 if (isstart && isrx)
2405 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2406 else if (!isstart && isrx)
2407 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2408 else if (isstart && !isrx)
2409 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2411 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2413 if (ret == -ENOTSUP)
2414 printf("Function not supported in PMD driver\n");
2417 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2418 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2419 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2420 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2421 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2422 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2423 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2424 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2425 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2426 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2429 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2430 .f = cmd_config_rxtx_queue_parsed,
2432 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2434 (void *)&cmd_config_rxtx_queue_port,
2435 (void *)&cmd_config_rxtx_queue_portid,
2436 (void *)&cmd_config_rxtx_queue_rxtxq,
2437 (void *)&cmd_config_rxtx_queue_qid,
2438 (void *)&cmd_config_rxtx_queue_opname,
2443 /* *** configure port rxq/txq deferred start on/off *** */
2444 struct cmd_config_deferred_start_rxtx_queue {
2445 cmdline_fixed_string_t port;
2447 cmdline_fixed_string_t rxtxq;
2449 cmdline_fixed_string_t opname;
2450 cmdline_fixed_string_t state;
2454 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2455 __attribute__((unused)) struct cmdline *cl,
2456 __attribute__((unused)) void *data)
2458 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2459 struct rte_port *port;
2462 uint8_t needreconfig = 0;
2464 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2467 if (port_is_started(res->port_id) != 0) {
2468 printf("Please stop port %u first\n", res->port_id);
2472 port = &ports[res->port_id];
2474 isrx = !strcmp(res->rxtxq, "rxq");
2476 if (isrx && rx_queue_id_is_invalid(res->qid))
2478 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2481 ison = !strcmp(res->state, "on");
2483 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2484 port->rx_conf[res->qid].rx_deferred_start = ison;
2486 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2487 port->tx_conf[res->qid].tx_deferred_start = ison;
2492 cmd_reconfig_device_queue(res->port_id, 0, 1);
2495 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2496 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2498 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2499 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2501 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2502 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2504 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2505 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2507 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2508 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2509 opname, "deferred_start");
2510 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2511 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2514 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2515 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2517 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2519 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2520 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2521 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2522 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2523 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2524 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2529 /* *** configure port rxq/txq setup *** */
2530 struct cmd_setup_rxtx_queue {
2531 cmdline_fixed_string_t port;
2533 cmdline_fixed_string_t rxtxq;
2535 cmdline_fixed_string_t setup;
2538 /* Common CLI fields for queue setup */
2539 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2540 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2541 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2542 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2543 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2544 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2545 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2546 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2547 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2548 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2551 cmd_setup_rxtx_queue_parsed(
2552 void *parsed_result,
2553 __attribute__((unused)) struct cmdline *cl,
2554 __attribute__((unused)) void *data)
2556 struct cmd_setup_rxtx_queue *res = parsed_result;
2557 struct rte_port *port;
2558 struct rte_mempool *mp;
2559 unsigned int socket_id;
2563 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2566 if (res->portid == (portid_t)RTE_PORT_ALL) {
2567 printf("Invalid port id\n");
2571 if (!strcmp(res->rxtxq, "rxq"))
2573 else if (!strcmp(res->rxtxq, "txq"))
2576 printf("Unknown parameter\n");
2580 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2581 printf("Invalid rx queue\n");
2583 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2584 printf("Invalid tx queue\n");
2588 port = &ports[res->portid];
2590 socket_id = rxring_numa[res->portid];
2591 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2592 socket_id = port->socket_id;
2594 mp = mbuf_pool_find(socket_id);
2596 printf("Failed to setup RX queue: "
2597 "No mempool allocation"
2598 " on the socket %d\n",
2599 rxring_numa[res->portid]);
2602 ret = rte_eth_rx_queue_setup(res->portid,
2604 port->nb_rx_desc[res->qid],
2606 &port->rx_conf[res->qid],
2609 printf("Failed to setup RX queue\n");
2611 socket_id = txring_numa[res->portid];
2612 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2613 socket_id = port->socket_id;
2615 ret = rte_eth_tx_queue_setup(res->portid,
2617 port->nb_tx_desc[res->qid],
2619 &port->tx_conf[res->qid]);
2621 printf("Failed to setup TX queue\n");
2625 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2626 .f = cmd_setup_rxtx_queue_parsed,
2628 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2630 (void *)&cmd_setup_rxtx_queue_port,
2631 (void *)&cmd_setup_rxtx_queue_portid,
2632 (void *)&cmd_setup_rxtx_queue_rxtxq,
2633 (void *)&cmd_setup_rxtx_queue_qid,
2634 (void *)&cmd_setup_rxtx_queue_setup,
2640 /* *** Configure RSS RETA *** */
2641 struct cmd_config_rss_reta {
2642 cmdline_fixed_string_t port;
2643 cmdline_fixed_string_t keyword;
2645 cmdline_fixed_string_t name;
2646 cmdline_fixed_string_t list_name;
2647 cmdline_fixed_string_t list_of_items;
2651 parse_reta_config(const char *str,
2652 struct rte_eth_rss_reta_entry64 *reta_conf,
2653 uint16_t nb_entries)
2657 uint16_t hash_index, idx, shift;
2660 const char *p, *p0 = str;
2667 unsigned long int_fld[_NUM_FLD];
2668 char *str_fld[_NUM_FLD];
2670 while ((p = strchr(p0,'(')) != NULL) {
2672 if((p0 = strchr(p,')')) == NULL)
2676 if(size >= sizeof(s))
2679 snprintf(s, sizeof(s), "%.*s", size, p);
2680 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2682 for (i = 0; i < _NUM_FLD; i++) {
2684 int_fld[i] = strtoul(str_fld[i], &end, 0);
2685 if (errno != 0 || end == str_fld[i] ||
2690 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2691 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2693 if (hash_index >= nb_entries) {
2694 printf("Invalid RETA hash index=%d\n", hash_index);
2698 idx = hash_index / RTE_RETA_GROUP_SIZE;
2699 shift = hash_index % RTE_RETA_GROUP_SIZE;
2700 reta_conf[idx].mask |= (1ULL << shift);
2701 reta_conf[idx].reta[shift] = nb_queue;
2708 cmd_set_rss_reta_parsed(void *parsed_result,
2709 __attribute__((unused)) struct cmdline *cl,
2710 __attribute__((unused)) void *data)
2713 struct rte_eth_dev_info dev_info;
2714 struct rte_eth_rss_reta_entry64 reta_conf[8];
2715 struct cmd_config_rss_reta *res = parsed_result;
2717 memset(&dev_info, 0, sizeof(dev_info));
2718 rte_eth_dev_info_get(res->port_id, &dev_info);
2719 if (dev_info.reta_size == 0) {
2720 printf("Redirection table size is 0 which is "
2721 "invalid for RSS\n");
2724 printf("The reta size of port %d is %u\n",
2725 res->port_id, dev_info.reta_size);
2726 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2727 printf("Currently do not support more than %u entries of "
2728 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2732 memset(reta_conf, 0, sizeof(reta_conf));
2733 if (!strcmp(res->list_name, "reta")) {
2734 if (parse_reta_config(res->list_of_items, reta_conf,
2735 dev_info.reta_size)) {
2736 printf("Invalid RSS Redirection Table "
2737 "config entered\n");
2740 ret = rte_eth_dev_rss_reta_update(res->port_id,
2741 reta_conf, dev_info.reta_size);
2743 printf("Bad redirection table parameter, "
2744 "return code = %d \n", ret);
2748 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2749 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2750 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2751 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2752 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2753 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2754 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2755 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2756 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2757 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2758 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2759 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2761 cmdline_parse_inst_t cmd_config_rss_reta = {
2762 .f = cmd_set_rss_reta_parsed,
2764 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2766 (void *)&cmd_config_rss_reta_port,
2767 (void *)&cmd_config_rss_reta_keyword,
2768 (void *)&cmd_config_rss_reta_port_id,
2769 (void *)&cmd_config_rss_reta_name,
2770 (void *)&cmd_config_rss_reta_list_name,
2771 (void *)&cmd_config_rss_reta_list_of_items,
2776 /* *** SHOW PORT RETA INFO *** */
2777 struct cmd_showport_reta {
2778 cmdline_fixed_string_t show;
2779 cmdline_fixed_string_t port;
2781 cmdline_fixed_string_t rss;
2782 cmdline_fixed_string_t reta;
2784 cmdline_fixed_string_t list_of_items;
2788 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2789 uint16_t nb_entries,
2793 const char *p, *p0 = str;
2798 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2799 RTE_RETA_GROUP_SIZE;
2802 p = strchr(p0, '(');
2806 p0 = strchr(p, ')');
2810 if (size >= sizeof(s)) {
2811 printf("The string size exceeds the internal buffer size\n");
2814 snprintf(s, sizeof(s), "%.*s", size, p);
2815 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2816 if (ret <= 0 || ret != num) {
2817 printf("The bits of masks do not match the number of "
2818 "reta entries: %u\n", num);
2821 for (i = 0; i < ret; i++)
2822 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2828 cmd_showport_reta_parsed(void *parsed_result,
2829 __attribute__((unused)) struct cmdline *cl,
2830 __attribute__((unused)) void *data)
2832 struct cmd_showport_reta *res = parsed_result;
2833 struct rte_eth_rss_reta_entry64 reta_conf[8];
2834 struct rte_eth_dev_info dev_info;
2835 uint16_t max_reta_size;
2837 memset(&dev_info, 0, sizeof(dev_info));
2838 rte_eth_dev_info_get(res->port_id, &dev_info);
2839 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2840 if (res->size == 0 || res->size > max_reta_size) {
2841 printf("Invalid redirection table size: %u (1-%u)\n",
2842 res->size, max_reta_size);
2846 memset(reta_conf, 0, sizeof(reta_conf));
2847 if (showport_parse_reta_config(reta_conf, res->size,
2848 res->list_of_items) < 0) {
2849 printf("Invalid string: %s for reta masks\n",
2850 res->list_of_items);
2853 port_rss_reta_info(res->port_id, reta_conf, res->size);
2856 cmdline_parse_token_string_t cmd_showport_reta_show =
2857 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2858 cmdline_parse_token_string_t cmd_showport_reta_port =
2859 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2860 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2861 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2862 cmdline_parse_token_string_t cmd_showport_reta_rss =
2863 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2864 cmdline_parse_token_string_t cmd_showport_reta_reta =
2865 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2866 cmdline_parse_token_num_t cmd_showport_reta_size =
2867 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2868 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2869 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2870 list_of_items, NULL);
2872 cmdline_parse_inst_t cmd_showport_reta = {
2873 .f = cmd_showport_reta_parsed,
2875 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2877 (void *)&cmd_showport_reta_show,
2878 (void *)&cmd_showport_reta_port,
2879 (void *)&cmd_showport_reta_port_id,
2880 (void *)&cmd_showport_reta_rss,
2881 (void *)&cmd_showport_reta_reta,
2882 (void *)&cmd_showport_reta_size,
2883 (void *)&cmd_showport_reta_list_of_items,
2888 /* *** Show RSS hash configuration *** */
2889 struct cmd_showport_rss_hash {
2890 cmdline_fixed_string_t show;
2891 cmdline_fixed_string_t port;
2893 cmdline_fixed_string_t rss_hash;
2894 cmdline_fixed_string_t rss_type;
2895 cmdline_fixed_string_t key; /* optional argument */
2898 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2899 __attribute__((unused)) struct cmdline *cl,
2902 struct cmd_showport_rss_hash *res = parsed_result;
2904 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
2907 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2908 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2909 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2910 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2911 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2912 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2913 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2914 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2916 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2917 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2919 cmdline_parse_inst_t cmd_showport_rss_hash = {
2920 .f = cmd_showport_rss_hash_parsed,
2922 .help_str = "show port <port_id> rss-hash",
2924 (void *)&cmd_showport_rss_hash_show,
2925 (void *)&cmd_showport_rss_hash_port,
2926 (void *)&cmd_showport_rss_hash_port_id,
2927 (void *)&cmd_showport_rss_hash_rss_hash,
2932 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2933 .f = cmd_showport_rss_hash_parsed,
2935 .help_str = "show port <port_id> rss-hash key",
2937 (void *)&cmd_showport_rss_hash_show,
2938 (void *)&cmd_showport_rss_hash_port,
2939 (void *)&cmd_showport_rss_hash_port_id,
2940 (void *)&cmd_showport_rss_hash_rss_hash,
2941 (void *)&cmd_showport_rss_hash_rss_key,
2946 /* *** Configure DCB *** */
2947 struct cmd_config_dcb {
2948 cmdline_fixed_string_t port;
2949 cmdline_fixed_string_t config;
2951 cmdline_fixed_string_t dcb;
2952 cmdline_fixed_string_t vt;
2953 cmdline_fixed_string_t vt_en;
2955 cmdline_fixed_string_t pfc;
2956 cmdline_fixed_string_t pfc_en;
2960 cmd_config_dcb_parsed(void *parsed_result,
2961 __attribute__((unused)) struct cmdline *cl,
2962 __attribute__((unused)) void *data)
2964 struct cmd_config_dcb *res = parsed_result;
2965 portid_t port_id = res->port_id;
2966 struct rte_port *port;
2970 port = &ports[port_id];
2971 /** Check if the port is not started **/
2972 if (port->port_status != RTE_PORT_STOPPED) {
2973 printf("Please stop port %d first\n", port_id);
2977 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2978 printf("The invalid number of traffic class,"
2979 " only 4 or 8 allowed.\n");
2983 if (nb_fwd_lcores < res->num_tcs) {
2984 printf("nb_cores shouldn't be less than number of TCs.\n");
2987 if (!strncmp(res->pfc_en, "on", 2))
2992 /* DCB in VT mode */
2993 if (!strncmp(res->vt_en, "on", 2))
2994 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2995 (enum rte_eth_nb_tcs)res->num_tcs,
2998 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2999 (enum rte_eth_nb_tcs)res->num_tcs,
3004 printf("Cannot initialize network ports.\n");
3008 cmd_reconfig_device_queue(port_id, 1, 1);
3011 cmdline_parse_token_string_t cmd_config_dcb_port =
3012 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3013 cmdline_parse_token_string_t cmd_config_dcb_config =
3014 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3015 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3016 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3017 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3018 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3019 cmdline_parse_token_string_t cmd_config_dcb_vt =
3020 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3021 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3022 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3023 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3024 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3025 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3026 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3027 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3028 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3030 cmdline_parse_inst_t cmd_config_dcb = {
3031 .f = cmd_config_dcb_parsed,
3033 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3035 (void *)&cmd_config_dcb_port,
3036 (void *)&cmd_config_dcb_config,
3037 (void *)&cmd_config_dcb_port_id,
3038 (void *)&cmd_config_dcb_dcb,
3039 (void *)&cmd_config_dcb_vt,
3040 (void *)&cmd_config_dcb_vt_en,
3041 (void *)&cmd_config_dcb_num_tcs,
3042 (void *)&cmd_config_dcb_pfc,
3043 (void *)&cmd_config_dcb_pfc_en,
3048 /* *** configure number of packets per burst *** */
3049 struct cmd_config_burst {
3050 cmdline_fixed_string_t port;
3051 cmdline_fixed_string_t keyword;
3052 cmdline_fixed_string_t all;
3053 cmdline_fixed_string_t name;
3058 cmd_config_burst_parsed(void *parsed_result,
3059 __attribute__((unused)) struct cmdline *cl,
3060 __attribute__((unused)) void *data)
3062 struct cmd_config_burst *res = parsed_result;
3063 struct rte_eth_dev_info dev_info;
3064 uint16_t rec_nb_pkts;
3066 if (!all_ports_stopped()) {
3067 printf("Please stop all ports first\n");
3071 if (!strcmp(res->name, "burst")) {
3072 if (res->value == 0) {
3073 /* If user gives a value of zero, query the PMD for
3074 * its recommended Rx burst size. Testpmd uses a single
3075 * size for all ports, so assume all ports are the same
3076 * NIC model and use the values from Port 0.
3078 rte_eth_dev_info_get(0, &dev_info);
3079 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3081 if (rec_nb_pkts == 0) {
3082 printf("PMD does not recommend a burst size.\n"
3083 "User provided value must be between"
3084 " 1 and %d\n", MAX_PKT_BURST);
3086 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3087 printf("PMD recommended burst size of %d"
3088 " exceeds maximum value of %d\n",
3089 rec_nb_pkts, MAX_PKT_BURST);
3092 printf("Using PMD-provided burst value of %d\n",
3094 nb_pkt_per_burst = rec_nb_pkts;
3095 } else if (res->value > MAX_PKT_BURST) {
3096 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3099 nb_pkt_per_burst = res->value;
3101 printf("Unknown parameter\n");
3107 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3110 cmdline_parse_token_string_t cmd_config_burst_port =
3111 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3112 cmdline_parse_token_string_t cmd_config_burst_keyword =
3113 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3114 cmdline_parse_token_string_t cmd_config_burst_all =
3115 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3116 cmdline_parse_token_string_t cmd_config_burst_name =
3117 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3118 cmdline_parse_token_num_t cmd_config_burst_value =
3119 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3121 cmdline_parse_inst_t cmd_config_burst = {
3122 .f = cmd_config_burst_parsed,
3124 .help_str = "port config all burst <value>",
3126 (void *)&cmd_config_burst_port,
3127 (void *)&cmd_config_burst_keyword,
3128 (void *)&cmd_config_burst_all,
3129 (void *)&cmd_config_burst_name,
3130 (void *)&cmd_config_burst_value,
3135 /* *** configure rx/tx queues *** */
3136 struct cmd_config_thresh {
3137 cmdline_fixed_string_t port;
3138 cmdline_fixed_string_t keyword;
3139 cmdline_fixed_string_t all;
3140 cmdline_fixed_string_t name;
3145 cmd_config_thresh_parsed(void *parsed_result,
3146 __attribute__((unused)) struct cmdline *cl,
3147 __attribute__((unused)) void *data)
3149 struct cmd_config_thresh *res = parsed_result;
3151 if (!all_ports_stopped()) {
3152 printf("Please stop all ports first\n");
3156 if (!strcmp(res->name, "txpt"))
3157 tx_pthresh = res->value;
3158 else if(!strcmp(res->name, "txht"))
3159 tx_hthresh = res->value;
3160 else if(!strcmp(res->name, "txwt"))
3161 tx_wthresh = res->value;
3162 else if(!strcmp(res->name, "rxpt"))
3163 rx_pthresh = res->value;
3164 else if(!strcmp(res->name, "rxht"))
3165 rx_hthresh = res->value;
3166 else if(!strcmp(res->name, "rxwt"))
3167 rx_wthresh = res->value;
3169 printf("Unknown parameter\n");
3175 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3178 cmdline_parse_token_string_t cmd_config_thresh_port =
3179 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3180 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3181 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3182 cmdline_parse_token_string_t cmd_config_thresh_all =
3183 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3184 cmdline_parse_token_string_t cmd_config_thresh_name =
3185 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3186 "txpt#txht#txwt#rxpt#rxht#rxwt");
3187 cmdline_parse_token_num_t cmd_config_thresh_value =
3188 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3190 cmdline_parse_inst_t cmd_config_thresh = {
3191 .f = cmd_config_thresh_parsed,
3193 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3195 (void *)&cmd_config_thresh_port,
3196 (void *)&cmd_config_thresh_keyword,
3197 (void *)&cmd_config_thresh_all,
3198 (void *)&cmd_config_thresh_name,
3199 (void *)&cmd_config_thresh_value,
3204 /* *** configure free/rs threshold *** */
3205 struct cmd_config_threshold {
3206 cmdline_fixed_string_t port;
3207 cmdline_fixed_string_t keyword;
3208 cmdline_fixed_string_t all;
3209 cmdline_fixed_string_t name;
3214 cmd_config_threshold_parsed(void *parsed_result,
3215 __attribute__((unused)) struct cmdline *cl,
3216 __attribute__((unused)) void *data)
3218 struct cmd_config_threshold *res = parsed_result;
3220 if (!all_ports_stopped()) {
3221 printf("Please stop all ports first\n");
3225 if (!strcmp(res->name, "txfreet"))
3226 tx_free_thresh = res->value;
3227 else if (!strcmp(res->name, "txrst"))
3228 tx_rs_thresh = res->value;
3229 else if (!strcmp(res->name, "rxfreet"))
3230 rx_free_thresh = res->value;
3232 printf("Unknown parameter\n");
3238 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3241 cmdline_parse_token_string_t cmd_config_threshold_port =
3242 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3243 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3244 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3246 cmdline_parse_token_string_t cmd_config_threshold_all =
3247 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3248 cmdline_parse_token_string_t cmd_config_threshold_name =
3249 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3250 "txfreet#txrst#rxfreet");
3251 cmdline_parse_token_num_t cmd_config_threshold_value =
3252 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3254 cmdline_parse_inst_t cmd_config_threshold = {
3255 .f = cmd_config_threshold_parsed,
3257 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3259 (void *)&cmd_config_threshold_port,
3260 (void *)&cmd_config_threshold_keyword,
3261 (void *)&cmd_config_threshold_all,
3262 (void *)&cmd_config_threshold_name,
3263 (void *)&cmd_config_threshold_value,
3269 struct cmd_stop_result {
3270 cmdline_fixed_string_t stop;
3273 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3274 __attribute__((unused)) struct cmdline *cl,
3275 __attribute__((unused)) void *data)
3277 stop_packet_forwarding();
3280 cmdline_parse_token_string_t cmd_stop_stop =
3281 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3283 cmdline_parse_inst_t cmd_stop = {
3284 .f = cmd_stop_parsed,
3286 .help_str = "stop: Stop packet forwarding",
3288 (void *)&cmd_stop_stop,
3293 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3296 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3297 unsigned int *parsed_items, int check_unique_values)
3299 unsigned int nb_item;
3307 * First parse all items in the list and store their value.
3312 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3314 if ((c >= '0') && (c <= '9')) {
3315 value = (unsigned int) (value * 10 + (c - '0'));
3320 printf("character %c is not a decimal digit\n", c);
3324 printf("No valid value before comma\n");
3327 if (nb_item < max_items) {
3328 parsed_items[nb_item] = value;
3334 if (nb_item >= max_items) {
3335 printf("Number of %s = %u > %u (maximum items)\n",
3336 item_name, nb_item + 1, max_items);
3339 parsed_items[nb_item++] = value;
3340 if (! check_unique_values)
3344 * Then, check that all values in the list are differents.
3345 * No optimization here...
3347 for (i = 0; i < nb_item; i++) {
3348 for (j = i + 1; j < nb_item; j++) {
3349 if (parsed_items[j] == parsed_items[i]) {
3350 printf("duplicated %s %u at index %u and %u\n",
3351 item_name, parsed_items[i], i, j);
3359 struct cmd_set_list_result {
3360 cmdline_fixed_string_t cmd_keyword;
3361 cmdline_fixed_string_t list_name;
3362 cmdline_fixed_string_t list_of_items;
3365 static void cmd_set_list_parsed(void *parsed_result,
3366 __attribute__((unused)) struct cmdline *cl,
3367 __attribute__((unused)) void *data)
3369 struct cmd_set_list_result *res;
3371 unsigned int lcorelist[RTE_MAX_LCORE];
3372 unsigned int portlist[RTE_MAX_ETHPORTS];
3374 unsigned int nb_item;
3376 if (test_done == 0) {
3377 printf("Please stop forwarding first\n");
3381 res = parsed_result;
3382 if (!strcmp(res->list_name, "corelist")) {
3383 nb_item = parse_item_list(res->list_of_items, "core",
3385 parsed_items.lcorelist, 1);
3387 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3392 if (!strcmp(res->list_name, "portlist")) {
3393 nb_item = parse_item_list(res->list_of_items, "port",
3395 parsed_items.portlist, 1);
3397 set_fwd_ports_list(parsed_items.portlist, nb_item);
3403 cmdline_parse_token_string_t cmd_set_list_keyword =
3404 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3406 cmdline_parse_token_string_t cmd_set_list_name =
3407 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3408 "corelist#portlist");
3409 cmdline_parse_token_string_t cmd_set_list_of_items =
3410 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3413 cmdline_parse_inst_t cmd_set_fwd_list = {
3414 .f = cmd_set_list_parsed,
3416 .help_str = "set corelist|portlist <list0[,list1]*>",
3418 (void *)&cmd_set_list_keyword,
3419 (void *)&cmd_set_list_name,
3420 (void *)&cmd_set_list_of_items,
3425 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3427 struct cmd_setmask_result {
3428 cmdline_fixed_string_t set;
3429 cmdline_fixed_string_t mask;
3433 static void cmd_set_mask_parsed(void *parsed_result,
3434 __attribute__((unused)) struct cmdline *cl,
3435 __attribute__((unused)) void *data)
3437 struct cmd_setmask_result *res = parsed_result;
3439 if (test_done == 0) {
3440 printf("Please stop forwarding first\n");
3443 if (!strcmp(res->mask, "coremask")) {
3444 set_fwd_lcores_mask(res->hexavalue);
3446 } else if (!strcmp(res->mask, "portmask")) {
3447 set_fwd_ports_mask(res->hexavalue);
3452 cmdline_parse_token_string_t cmd_setmask_set =
3453 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3454 cmdline_parse_token_string_t cmd_setmask_mask =
3455 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3456 "coremask#portmask");
3457 cmdline_parse_token_num_t cmd_setmask_value =
3458 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3460 cmdline_parse_inst_t cmd_set_fwd_mask = {
3461 .f = cmd_set_mask_parsed,
3463 .help_str = "set coremask|portmask <hexadecimal value>",
3465 (void *)&cmd_setmask_set,
3466 (void *)&cmd_setmask_mask,
3467 (void *)&cmd_setmask_value,
3473 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3475 struct cmd_set_result {
3476 cmdline_fixed_string_t set;
3477 cmdline_fixed_string_t what;
3481 static void cmd_set_parsed(void *parsed_result,
3482 __attribute__((unused)) struct cmdline *cl,
3483 __attribute__((unused)) void *data)
3485 struct cmd_set_result *res = parsed_result;
3486 if (!strcmp(res->what, "nbport")) {
3487 set_fwd_ports_number(res->value);
3489 } else if (!strcmp(res->what, "nbcore")) {
3490 set_fwd_lcores_number(res->value);
3492 } else if (!strcmp(res->what, "burst"))
3493 set_nb_pkt_per_burst(res->value);
3494 else if (!strcmp(res->what, "verbose"))
3495 set_verbose_level(res->value);
3498 cmdline_parse_token_string_t cmd_set_set =
3499 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3500 cmdline_parse_token_string_t cmd_set_what =
3501 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3502 "nbport#nbcore#burst#verbose");
3503 cmdline_parse_token_num_t cmd_set_value =
3504 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3506 cmdline_parse_inst_t cmd_set_numbers = {
3507 .f = cmd_set_parsed,
3509 .help_str = "set nbport|nbcore|burst|verbose <value>",
3511 (void *)&cmd_set_set,
3512 (void *)&cmd_set_what,
3513 (void *)&cmd_set_value,
3518 /* *** SET LOG LEVEL CONFIGURATION *** */
3520 struct cmd_set_log_result {
3521 cmdline_fixed_string_t set;
3522 cmdline_fixed_string_t log;
3523 cmdline_fixed_string_t type;
3528 cmd_set_log_parsed(void *parsed_result,
3529 __attribute__((unused)) struct cmdline *cl,
3530 __attribute__((unused)) void *data)
3532 struct cmd_set_log_result *res;
3535 res = parsed_result;
3536 if (!strcmp(res->type, "global"))
3537 rte_log_set_global_level(res->level);
3539 ret = rte_log_set_level_regexp(res->type, res->level);
3541 printf("Unable to set log level\n");
3545 cmdline_parse_token_string_t cmd_set_log_set =
3546 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3547 cmdline_parse_token_string_t cmd_set_log_log =
3548 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3549 cmdline_parse_token_string_t cmd_set_log_type =
3550 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3551 cmdline_parse_token_num_t cmd_set_log_level =
3552 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3554 cmdline_parse_inst_t cmd_set_log = {
3555 .f = cmd_set_log_parsed,
3557 .help_str = "set log global|<type> <level>",
3559 (void *)&cmd_set_log_set,
3560 (void *)&cmd_set_log_log,
3561 (void *)&cmd_set_log_type,
3562 (void *)&cmd_set_log_level,
3567 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3569 struct cmd_set_txpkts_result {
3570 cmdline_fixed_string_t cmd_keyword;
3571 cmdline_fixed_string_t txpkts;
3572 cmdline_fixed_string_t seg_lengths;
3576 cmd_set_txpkts_parsed(void *parsed_result,
3577 __attribute__((unused)) struct cmdline *cl,
3578 __attribute__((unused)) void *data)
3580 struct cmd_set_txpkts_result *res;
3581 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3582 unsigned int nb_segs;
3584 res = parsed_result;
3585 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3586 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3588 set_tx_pkt_segments(seg_lengths, nb_segs);
3591 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3592 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3593 cmd_keyword, "set");
3594 cmdline_parse_token_string_t cmd_set_txpkts_name =
3595 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3597 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3598 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3601 cmdline_parse_inst_t cmd_set_txpkts = {
3602 .f = cmd_set_txpkts_parsed,
3604 .help_str = "set txpkts <len0[,len1]*>",
3606 (void *)&cmd_set_txpkts_keyword,
3607 (void *)&cmd_set_txpkts_name,
3608 (void *)&cmd_set_txpkts_lengths,
3613 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3615 struct cmd_set_txsplit_result {
3616 cmdline_fixed_string_t cmd_keyword;
3617 cmdline_fixed_string_t txsplit;
3618 cmdline_fixed_string_t mode;
3622 cmd_set_txsplit_parsed(void *parsed_result,
3623 __attribute__((unused)) struct cmdline *cl,
3624 __attribute__((unused)) void *data)
3626 struct cmd_set_txsplit_result *res;
3628 res = parsed_result;
3629 set_tx_pkt_split(res->mode);
3632 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3633 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3634 cmd_keyword, "set");
3635 cmdline_parse_token_string_t cmd_set_txsplit_name =
3636 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3637 txsplit, "txsplit");
3638 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3639 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3642 cmdline_parse_inst_t cmd_set_txsplit = {
3643 .f = cmd_set_txsplit_parsed,
3645 .help_str = "set txsplit on|off|rand",
3647 (void *)&cmd_set_txsplit_keyword,
3648 (void *)&cmd_set_txsplit_name,
3649 (void *)&cmd_set_txsplit_mode,
3654 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3655 struct cmd_rx_vlan_filter_all_result {
3656 cmdline_fixed_string_t rx_vlan;
3657 cmdline_fixed_string_t what;
3658 cmdline_fixed_string_t all;
3663 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3664 __attribute__((unused)) struct cmdline *cl,
3665 __attribute__((unused)) void *data)
3667 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3669 if (!strcmp(res->what, "add"))
3670 rx_vlan_all_filter_set(res->port_id, 1);
3672 rx_vlan_all_filter_set(res->port_id, 0);
3675 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3676 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3677 rx_vlan, "rx_vlan");
3678 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3679 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3681 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3682 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3684 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3685 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3688 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3689 .f = cmd_rx_vlan_filter_all_parsed,
3691 .help_str = "rx_vlan add|rm all <port_id>: "
3692 "Add/Remove all identifiers to/from the set of VLAN "
3693 "identifiers filtered by a port",
3695 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3696 (void *)&cmd_rx_vlan_filter_all_what,
3697 (void *)&cmd_rx_vlan_filter_all_all,
3698 (void *)&cmd_rx_vlan_filter_all_portid,
3703 /* *** VLAN OFFLOAD SET ON A PORT *** */
3704 struct cmd_vlan_offload_result {
3705 cmdline_fixed_string_t vlan;
3706 cmdline_fixed_string_t set;
3707 cmdline_fixed_string_t vlan_type;
3708 cmdline_fixed_string_t what;
3709 cmdline_fixed_string_t on;
3710 cmdline_fixed_string_t port_id;
3714 cmd_vlan_offload_parsed(void *parsed_result,
3715 __attribute__((unused)) struct cmdline *cl,
3716 __attribute__((unused)) void *data)
3719 struct cmd_vlan_offload_result *res = parsed_result;
3722 portid_t port_id = 0;
3726 len = strnlen(str, STR_TOKEN_SIZE);
3728 /* Get port_id first */
3736 tmp = strtoul(str, NULL, 0);
3737 /* If port_id greater that what portid_t can represent, return */
3738 if(tmp >= RTE_MAX_ETHPORTS)
3740 port_id = (portid_t)tmp;
3742 if (!strcmp(res->on, "on"))
3747 if (!strcmp(res->what, "strip"))
3748 rx_vlan_strip_set(port_id, on);
3749 else if(!strcmp(res->what, "stripq")){
3750 uint16_t queue_id = 0;
3752 /* No queue_id, return */
3754 printf("must specify (port,queue_id)\n");
3757 tmp = strtoul(str + i + 1, NULL, 0);
3758 /* If queue_id greater that what 16-bits can represent, return */
3762 queue_id = (uint16_t)tmp;
3763 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3765 else if (!strcmp(res->what, "filter"))
3766 rx_vlan_filter_set(port_id, on);
3768 vlan_extend_set(port_id, on);
3773 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3774 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3776 cmdline_parse_token_string_t cmd_vlan_offload_set =
3777 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3779 cmdline_parse_token_string_t cmd_vlan_offload_what =
3780 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3781 what, "strip#filter#qinq#stripq");
3782 cmdline_parse_token_string_t cmd_vlan_offload_on =
3783 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3785 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3786 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3789 cmdline_parse_inst_t cmd_vlan_offload = {
3790 .f = cmd_vlan_offload_parsed,
3792 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3793 "<port_id[,queue_id]>: "
3794 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3796 (void *)&cmd_vlan_offload_vlan,
3797 (void *)&cmd_vlan_offload_set,
3798 (void *)&cmd_vlan_offload_what,
3799 (void *)&cmd_vlan_offload_on,
3800 (void *)&cmd_vlan_offload_portid,
3805 /* *** VLAN TPID SET ON A PORT *** */
3806 struct cmd_vlan_tpid_result {
3807 cmdline_fixed_string_t vlan;
3808 cmdline_fixed_string_t set;
3809 cmdline_fixed_string_t vlan_type;
3810 cmdline_fixed_string_t what;
3816 cmd_vlan_tpid_parsed(void *parsed_result,
3817 __attribute__((unused)) struct cmdline *cl,
3818 __attribute__((unused)) void *data)
3820 struct cmd_vlan_tpid_result *res = parsed_result;
3821 enum rte_vlan_type vlan_type;
3823 if (!strcmp(res->vlan_type, "inner"))
3824 vlan_type = ETH_VLAN_TYPE_INNER;
3825 else if (!strcmp(res->vlan_type, "outer"))
3826 vlan_type = ETH_VLAN_TYPE_OUTER;
3828 printf("Unknown vlan type\n");
3831 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3834 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3835 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3837 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3838 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3840 cmdline_parse_token_string_t cmd_vlan_type =
3841 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3842 vlan_type, "inner#outer");
3843 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3844 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3846 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3847 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3849 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3850 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3853 cmdline_parse_inst_t cmd_vlan_tpid = {
3854 .f = cmd_vlan_tpid_parsed,
3856 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3857 "Set the VLAN Ether type",
3859 (void *)&cmd_vlan_tpid_vlan,
3860 (void *)&cmd_vlan_tpid_set,
3861 (void *)&cmd_vlan_type,
3862 (void *)&cmd_vlan_tpid_what,
3863 (void *)&cmd_vlan_tpid_tpid,
3864 (void *)&cmd_vlan_tpid_portid,
3869 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3870 struct cmd_rx_vlan_filter_result {
3871 cmdline_fixed_string_t rx_vlan;
3872 cmdline_fixed_string_t what;
3878 cmd_rx_vlan_filter_parsed(void *parsed_result,
3879 __attribute__((unused)) struct cmdline *cl,
3880 __attribute__((unused)) void *data)
3882 struct cmd_rx_vlan_filter_result *res = parsed_result;
3884 if (!strcmp(res->what, "add"))
3885 rx_vft_set(res->port_id, res->vlan_id, 1);
3887 rx_vft_set(res->port_id, res->vlan_id, 0);
3890 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3891 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3892 rx_vlan, "rx_vlan");
3893 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3894 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3896 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3897 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3899 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3900 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3903 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3904 .f = cmd_rx_vlan_filter_parsed,
3906 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3907 "Add/Remove a VLAN identifier to/from the set of VLAN "
3908 "identifiers filtered by a port",
3910 (void *)&cmd_rx_vlan_filter_rx_vlan,
3911 (void *)&cmd_rx_vlan_filter_what,
3912 (void *)&cmd_rx_vlan_filter_vlanid,
3913 (void *)&cmd_rx_vlan_filter_portid,
3918 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3919 struct cmd_tx_vlan_set_result {
3920 cmdline_fixed_string_t tx_vlan;
3921 cmdline_fixed_string_t set;
3927 cmd_tx_vlan_set_parsed(void *parsed_result,
3928 __attribute__((unused)) struct cmdline *cl,
3929 __attribute__((unused)) void *data)
3931 struct cmd_tx_vlan_set_result *res = parsed_result;
3933 if (!port_is_stopped(res->port_id)) {
3934 printf("Please stop port %d first\n", res->port_id);
3938 tx_vlan_set(res->port_id, res->vlan_id);
3940 cmd_reconfig_device_queue(res->port_id, 1, 1);
3943 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3944 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3945 tx_vlan, "tx_vlan");
3946 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3947 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3949 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3950 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3952 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3953 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3956 cmdline_parse_inst_t cmd_tx_vlan_set = {
3957 .f = cmd_tx_vlan_set_parsed,
3959 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3960 "Enable hardware insertion of a single VLAN header "
3961 "with a given TAG Identifier in packets sent on a port",
3963 (void *)&cmd_tx_vlan_set_tx_vlan,
3964 (void *)&cmd_tx_vlan_set_set,
3965 (void *)&cmd_tx_vlan_set_portid,
3966 (void *)&cmd_tx_vlan_set_vlanid,
3971 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3972 struct cmd_tx_vlan_set_qinq_result {
3973 cmdline_fixed_string_t tx_vlan;
3974 cmdline_fixed_string_t set;
3977 uint16_t vlan_id_outer;
3981 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3982 __attribute__((unused)) struct cmdline *cl,
3983 __attribute__((unused)) void *data)
3985 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3987 if (!port_is_stopped(res->port_id)) {
3988 printf("Please stop port %d first\n", res->port_id);
3992 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3994 cmd_reconfig_device_queue(res->port_id, 1, 1);
3997 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3998 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3999 tx_vlan, "tx_vlan");
4000 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4001 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4003 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4004 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4006 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4007 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4009 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4010 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4011 vlan_id_outer, UINT16);
4013 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4014 .f = cmd_tx_vlan_set_qinq_parsed,
4016 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4017 "Enable hardware insertion of double VLAN header "
4018 "with given TAG Identifiers in packets sent on a port",
4020 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4021 (void *)&cmd_tx_vlan_set_qinq_set,
4022 (void *)&cmd_tx_vlan_set_qinq_portid,
4023 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4024 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4029 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4030 struct cmd_tx_vlan_set_pvid_result {
4031 cmdline_fixed_string_t tx_vlan;
4032 cmdline_fixed_string_t set;
4033 cmdline_fixed_string_t pvid;
4036 cmdline_fixed_string_t mode;
4040 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4041 __attribute__((unused)) struct cmdline *cl,
4042 __attribute__((unused)) void *data)
4044 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4046 if (strcmp(res->mode, "on") == 0)
4047 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4049 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4052 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4053 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4054 tx_vlan, "tx_vlan");
4055 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4056 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4058 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4059 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4061 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4062 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4064 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4065 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4067 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4068 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4071 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4072 .f = cmd_tx_vlan_set_pvid_parsed,
4074 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4076 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4077 (void *)&cmd_tx_vlan_set_pvid_set,
4078 (void *)&cmd_tx_vlan_set_pvid_pvid,
4079 (void *)&cmd_tx_vlan_set_pvid_port_id,
4080 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4081 (void *)&cmd_tx_vlan_set_pvid_mode,
4086 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4087 struct cmd_tx_vlan_reset_result {
4088 cmdline_fixed_string_t tx_vlan;
4089 cmdline_fixed_string_t reset;
4094 cmd_tx_vlan_reset_parsed(void *parsed_result,
4095 __attribute__((unused)) struct cmdline *cl,
4096 __attribute__((unused)) void *data)
4098 struct cmd_tx_vlan_reset_result *res = parsed_result;
4100 if (!port_is_stopped(res->port_id)) {
4101 printf("Please stop port %d first\n", res->port_id);
4105 tx_vlan_reset(res->port_id);
4107 cmd_reconfig_device_queue(res->port_id, 1, 1);
4110 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4111 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4112 tx_vlan, "tx_vlan");
4113 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4114 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4116 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4117 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4120 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4121 .f = cmd_tx_vlan_reset_parsed,
4123 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4124 "VLAN header in packets sent on a port",
4126 (void *)&cmd_tx_vlan_reset_tx_vlan,
4127 (void *)&cmd_tx_vlan_reset_reset,
4128 (void *)&cmd_tx_vlan_reset_portid,
4134 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4135 struct cmd_csum_result {
4136 cmdline_fixed_string_t csum;
4137 cmdline_fixed_string_t mode;
4138 cmdline_fixed_string_t proto;
4139 cmdline_fixed_string_t hwsw;
4144 csum_show(int port_id)
4146 struct rte_eth_dev_info dev_info;
4147 uint64_t tx_offloads;
4149 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4150 printf("Parse tunnel is %s\n",
4151 (ports[port_id].parse_tunnel) ? "on" : "off");
4152 printf("IP checksum offload is %s\n",
4153 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4154 printf("UDP checksum offload is %s\n",
4155 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4156 printf("TCP checksum offload is %s\n",
4157 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4158 printf("SCTP checksum offload is %s\n",
4159 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4160 printf("Outer-Ip checksum offload is %s\n",
4161 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4163 /* display warnings if configuration is not supported by the NIC */
4164 rte_eth_dev_info_get(port_id, &dev_info);
4165 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4166 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4167 printf("Warning: hardware IP checksum enabled but not "
4168 "supported by port %d\n", port_id);
4170 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4171 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4172 printf("Warning: hardware UDP checksum enabled but not "
4173 "supported by port %d\n", port_id);
4175 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4176 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4177 printf("Warning: hardware TCP checksum enabled but not "
4178 "supported by port %d\n", port_id);
4180 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4181 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4182 printf("Warning: hardware SCTP checksum enabled but not "
4183 "supported by port %d\n", port_id);
4185 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4186 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4187 printf("Warning: hardware outer IP checksum enabled but not "
4188 "supported by port %d\n", port_id);
4193 cmd_csum_parsed(void *parsed_result,
4194 __attribute__((unused)) struct cmdline *cl,
4195 __attribute__((unused)) void *data)
4197 struct cmd_csum_result *res = parsed_result;
4199 uint64_t csum_offloads = 0;
4200 struct rte_eth_dev_info dev_info;
4202 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4203 printf("invalid port %d\n", res->port_id);
4206 if (!port_is_stopped(res->port_id)) {
4207 printf("Please stop port %d first\n", res->port_id);
4211 rte_eth_dev_info_get(res->port_id, &dev_info);
4212 if (!strcmp(res->mode, "set")) {
4214 if (!strcmp(res->hwsw, "hw"))
4217 if (!strcmp(res->proto, "ip")) {
4218 if (hw == 0 || (dev_info.tx_offload_capa &
4219 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4220 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4222 printf("IP checksum offload is not supported "
4223 "by port %u\n", res->port_id);
4225 } else if (!strcmp(res->proto, "udp")) {
4226 if (hw == 0 || (dev_info.tx_offload_capa &
4227 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4228 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4230 printf("UDP checksum offload is not supported "
4231 "by port %u\n", res->port_id);
4233 } else if (!strcmp(res->proto, "tcp")) {
4234 if (hw == 0 || (dev_info.tx_offload_capa &
4235 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4236 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4238 printf("TCP checksum offload is not supported "
4239 "by port %u\n", res->port_id);
4241 } else if (!strcmp(res->proto, "sctp")) {
4242 if (hw == 0 || (dev_info.tx_offload_capa &
4243 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4244 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4246 printf("SCTP checksum offload is not supported "
4247 "by port %u\n", res->port_id);
4249 } else if (!strcmp(res->proto, "outer-ip")) {
4250 if (hw == 0 || (dev_info.tx_offload_capa &
4251 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4253 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4255 printf("Outer IP checksum offload is not "
4256 "supported by port %u\n", res->port_id);
4261 ports[res->port_id].dev_conf.txmode.offloads |=
4264 ports[res->port_id].dev_conf.txmode.offloads &=
4268 csum_show(res->port_id);
4270 cmd_reconfig_device_queue(res->port_id, 1, 1);
4273 cmdline_parse_token_string_t cmd_csum_csum =
4274 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4276 cmdline_parse_token_string_t cmd_csum_mode =
4277 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4279 cmdline_parse_token_string_t cmd_csum_proto =
4280 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4281 proto, "ip#tcp#udp#sctp#outer-ip");
4282 cmdline_parse_token_string_t cmd_csum_hwsw =
4283 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4285 cmdline_parse_token_num_t cmd_csum_portid =
4286 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4289 cmdline_parse_inst_t cmd_csum_set = {
4290 .f = cmd_csum_parsed,
4292 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
4293 "Enable/Disable hardware calculation of L3/L4 checksum when "
4294 "using csum forward engine",
4296 (void *)&cmd_csum_csum,
4297 (void *)&cmd_csum_mode,
4298 (void *)&cmd_csum_proto,
4299 (void *)&cmd_csum_hwsw,
4300 (void *)&cmd_csum_portid,
4305 cmdline_parse_token_string_t cmd_csum_mode_show =
4306 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4309 cmdline_parse_inst_t cmd_csum_show = {
4310 .f = cmd_csum_parsed,
4312 .help_str = "csum show <port_id>: Show checksum offload configuration",
4314 (void *)&cmd_csum_csum,
4315 (void *)&cmd_csum_mode_show,
4316 (void *)&cmd_csum_portid,
4321 /* Enable/disable tunnel parsing */
4322 struct cmd_csum_tunnel_result {
4323 cmdline_fixed_string_t csum;
4324 cmdline_fixed_string_t parse;
4325 cmdline_fixed_string_t onoff;
4330 cmd_csum_tunnel_parsed(void *parsed_result,
4331 __attribute__((unused)) struct cmdline *cl,
4332 __attribute__((unused)) void *data)
4334 struct cmd_csum_tunnel_result *res = parsed_result;
4336 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4339 if (!strcmp(res->onoff, "on"))
4340 ports[res->port_id].parse_tunnel = 1;
4342 ports[res->port_id].parse_tunnel = 0;
4344 csum_show(res->port_id);
4347 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4348 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4350 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4351 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4352 parse, "parse-tunnel");
4353 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4354 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4356 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4357 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4360 cmdline_parse_inst_t cmd_csum_tunnel = {
4361 .f = cmd_csum_tunnel_parsed,
4363 .help_str = "csum parse-tunnel on|off <port_id>: "
4364 "Enable/Disable parsing of tunnels for csum engine",
4366 (void *)&cmd_csum_tunnel_csum,
4367 (void *)&cmd_csum_tunnel_parse,
4368 (void *)&cmd_csum_tunnel_onoff,
4369 (void *)&cmd_csum_tunnel_portid,
4374 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4375 struct cmd_tso_set_result {
4376 cmdline_fixed_string_t tso;
4377 cmdline_fixed_string_t mode;
4383 cmd_tso_set_parsed(void *parsed_result,
4384 __attribute__((unused)) struct cmdline *cl,
4385 __attribute__((unused)) void *data)
4387 struct cmd_tso_set_result *res = parsed_result;
4388 struct rte_eth_dev_info dev_info;
4390 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4392 if (!port_is_stopped(res->port_id)) {
4393 printf("Please stop port %d first\n", res->port_id);
4397 if (!strcmp(res->mode, "set"))
4398 ports[res->port_id].tso_segsz = res->tso_segsz;
4400 rte_eth_dev_info_get(res->port_id, &dev_info);
4401 if ((ports[res->port_id].tso_segsz != 0) &&
4402 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4403 printf("Error: TSO is not supported by port %d\n",
4408 if (ports[res->port_id].tso_segsz == 0) {
4409 ports[res->port_id].dev_conf.txmode.offloads &=
4410 ~DEV_TX_OFFLOAD_TCP_TSO;
4411 printf("TSO for non-tunneled packets is disabled\n");
4413 ports[res->port_id].dev_conf.txmode.offloads |=
4414 DEV_TX_OFFLOAD_TCP_TSO;
4415 printf("TSO segment size for non-tunneled packets is %d\n",
4416 ports[res->port_id].tso_segsz);
4419 /* display warnings if configuration is not supported by the NIC */
4420 rte_eth_dev_info_get(res->port_id, &dev_info);
4421 if ((ports[res->port_id].tso_segsz != 0) &&
4422 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4423 printf("Warning: TSO enabled but not "
4424 "supported by port %d\n", res->port_id);
4427 cmd_reconfig_device_queue(res->port_id, 1, 1);
4430 cmdline_parse_token_string_t cmd_tso_set_tso =
4431 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4433 cmdline_parse_token_string_t cmd_tso_set_mode =
4434 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4436 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4437 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4439 cmdline_parse_token_num_t cmd_tso_set_portid =
4440 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4443 cmdline_parse_inst_t cmd_tso_set = {
4444 .f = cmd_tso_set_parsed,
4446 .help_str = "tso set <tso_segsz> <port_id>: "
4447 "Set TSO segment size of non-tunneled packets for csum engine "
4450 (void *)&cmd_tso_set_tso,
4451 (void *)&cmd_tso_set_mode,
4452 (void *)&cmd_tso_set_tso_segsz,
4453 (void *)&cmd_tso_set_portid,
4458 cmdline_parse_token_string_t cmd_tso_show_mode =
4459 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4463 cmdline_parse_inst_t cmd_tso_show = {
4464 .f = cmd_tso_set_parsed,
4466 .help_str = "tso show <port_id>: "
4467 "Show TSO segment size of non-tunneled packets for csum engine",
4469 (void *)&cmd_tso_set_tso,
4470 (void *)&cmd_tso_show_mode,
4471 (void *)&cmd_tso_set_portid,
4476 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4477 struct cmd_tunnel_tso_set_result {
4478 cmdline_fixed_string_t tso;
4479 cmdline_fixed_string_t mode;
4484 static struct rte_eth_dev_info
4485 check_tunnel_tso_nic_support(portid_t port_id)
4487 struct rte_eth_dev_info dev_info;
4489 rte_eth_dev_info_get(port_id, &dev_info);
4490 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4491 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4492 "not enabled for port %d\n", port_id);
4493 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4494 printf("Warning: GRE TUNNEL TSO not supported therefore "
4495 "not enabled for port %d\n", port_id);
4496 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4497 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4498 "not enabled for port %d\n", port_id);
4499 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4500 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4501 "not enabled for port %d\n", port_id);
4502 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4503 printf("Warning: IP TUNNEL TSO not supported therefore "
4504 "not enabled for port %d\n", port_id);
4505 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4506 printf("Warning: UDP TUNNEL TSO not supported therefore "
4507 "not enabled for port %d\n", port_id);
4512 cmd_tunnel_tso_set_parsed(void *parsed_result,
4513 __attribute__((unused)) struct cmdline *cl,
4514 __attribute__((unused)) void *data)
4516 struct cmd_tunnel_tso_set_result *res = parsed_result;
4517 struct rte_eth_dev_info dev_info;
4519 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4521 if (!port_is_stopped(res->port_id)) {
4522 printf("Please stop port %d first\n", res->port_id);
4526 if (!strcmp(res->mode, "set"))
4527 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4529 dev_info = check_tunnel_tso_nic_support(res->port_id);
4530 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4531 ports[res->port_id].dev_conf.txmode.offloads &=
4532 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4533 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4534 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4535 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4536 DEV_TX_OFFLOAD_IP_TNL_TSO |
4537 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4538 printf("TSO for tunneled packets is disabled\n");
4540 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4541 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4542 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4543 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4544 DEV_TX_OFFLOAD_IP_TNL_TSO |
4545 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4547 ports[res->port_id].dev_conf.txmode.offloads |=
4548 (tso_offloads & dev_info.tx_offload_capa);
4549 printf("TSO segment size for tunneled packets is %d\n",
4550 ports[res->port_id].tunnel_tso_segsz);
4552 /* Below conditions are needed to make it work:
4553 * (1) tunnel TSO is supported by the NIC;
4554 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4556 * (3) for tunneled pkts with outer L3 of IPv4,
4557 * "csum set outer-ip" must be set to hw, because after tso,
4558 * total_len of outer IP header is changed, and the checksum
4559 * of outer IP header calculated by sw should be wrong; that
4560 * is not necessary for IPv6 tunneled pkts because there's no
4561 * checksum in IP header anymore.
4564 if (!ports[res->port_id].parse_tunnel)
4565 printf("Warning: csum parse_tunnel must be set "
4566 "so that tunneled packets are recognized\n");
4567 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4568 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4569 printf("Warning: csum set outer-ip must be set to hw "
4570 "if outer L3 is IPv4; not necessary for IPv6\n");
4573 cmd_reconfig_device_queue(res->port_id, 1, 1);
4576 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4577 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4579 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4580 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4582 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4583 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4585 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4586 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4589 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4590 .f = cmd_tunnel_tso_set_parsed,
4592 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4593 "Set TSO segment size of tunneled packets for csum engine "
4596 (void *)&cmd_tunnel_tso_set_tso,
4597 (void *)&cmd_tunnel_tso_set_mode,
4598 (void *)&cmd_tunnel_tso_set_tso_segsz,
4599 (void *)&cmd_tunnel_tso_set_portid,
4604 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4605 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4609 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4610 .f = cmd_tunnel_tso_set_parsed,
4612 .help_str = "tunnel_tso show <port_id> "
4613 "Show TSO segment size of tunneled packets for csum engine",
4615 (void *)&cmd_tunnel_tso_set_tso,
4616 (void *)&cmd_tunnel_tso_show_mode,
4617 (void *)&cmd_tunnel_tso_set_portid,
4622 /* *** SET GRO FOR A PORT *** */
4623 struct cmd_gro_enable_result {
4624 cmdline_fixed_string_t cmd_set;
4625 cmdline_fixed_string_t cmd_port;
4626 cmdline_fixed_string_t cmd_keyword;
4627 cmdline_fixed_string_t cmd_onoff;
4632 cmd_gro_enable_parsed(void *parsed_result,
4633 __attribute__((unused)) struct cmdline *cl,
4634 __attribute__((unused)) void *data)
4636 struct cmd_gro_enable_result *res;
4638 res = parsed_result;
4639 if (!strcmp(res->cmd_keyword, "gro"))
4640 setup_gro(res->cmd_onoff, res->cmd_pid);
4643 cmdline_parse_token_string_t cmd_gro_enable_set =
4644 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4646 cmdline_parse_token_string_t cmd_gro_enable_port =
4647 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4648 cmd_keyword, "port");
4649 cmdline_parse_token_num_t cmd_gro_enable_pid =
4650 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4652 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4653 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4654 cmd_keyword, "gro");
4655 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4656 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4657 cmd_onoff, "on#off");
4659 cmdline_parse_inst_t cmd_gro_enable = {
4660 .f = cmd_gro_enable_parsed,
4662 .help_str = "set port <port_id> gro on|off",
4664 (void *)&cmd_gro_enable_set,
4665 (void *)&cmd_gro_enable_port,
4666 (void *)&cmd_gro_enable_pid,
4667 (void *)&cmd_gro_enable_keyword,
4668 (void *)&cmd_gro_enable_onoff,
4673 /* *** DISPLAY GRO CONFIGURATION *** */
4674 struct cmd_gro_show_result {
4675 cmdline_fixed_string_t cmd_show;
4676 cmdline_fixed_string_t cmd_port;
4677 cmdline_fixed_string_t cmd_keyword;
4682 cmd_gro_show_parsed(void *parsed_result,
4683 __attribute__((unused)) struct cmdline *cl,
4684 __attribute__((unused)) void *data)
4686 struct cmd_gro_show_result *res;
4688 res = parsed_result;
4689 if (!strcmp(res->cmd_keyword, "gro"))
4690 show_gro(res->cmd_pid);
4693 cmdline_parse_token_string_t cmd_gro_show_show =
4694 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4696 cmdline_parse_token_string_t cmd_gro_show_port =
4697 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4699 cmdline_parse_token_num_t cmd_gro_show_pid =
4700 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4702 cmdline_parse_token_string_t cmd_gro_show_keyword =
4703 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4704 cmd_keyword, "gro");
4706 cmdline_parse_inst_t cmd_gro_show = {
4707 .f = cmd_gro_show_parsed,
4709 .help_str = "show port <port_id> gro",
4711 (void *)&cmd_gro_show_show,
4712 (void *)&cmd_gro_show_port,
4713 (void *)&cmd_gro_show_pid,
4714 (void *)&cmd_gro_show_keyword,
4719 /* *** SET FLUSH CYCLES FOR GRO *** */
4720 struct cmd_gro_flush_result {
4721 cmdline_fixed_string_t cmd_set;
4722 cmdline_fixed_string_t cmd_keyword;
4723 cmdline_fixed_string_t cmd_flush;
4728 cmd_gro_flush_parsed(void *parsed_result,
4729 __attribute__((unused)) struct cmdline *cl,
4730 __attribute__((unused)) void *data)
4732 struct cmd_gro_flush_result *res;
4734 res = parsed_result;
4735 if ((!strcmp(res->cmd_keyword, "gro")) &&
4736 (!strcmp(res->cmd_flush, "flush")))
4737 setup_gro_flush_cycles(res->cmd_cycles);
4740 cmdline_parse_token_string_t cmd_gro_flush_set =
4741 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4743 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4744 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4745 cmd_keyword, "gro");
4746 cmdline_parse_token_string_t cmd_gro_flush_flush =
4747 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4748 cmd_flush, "flush");
4749 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4750 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4753 cmdline_parse_inst_t cmd_gro_flush = {
4754 .f = cmd_gro_flush_parsed,
4756 .help_str = "set gro flush <cycles>",
4758 (void *)&cmd_gro_flush_set,
4759 (void *)&cmd_gro_flush_keyword,
4760 (void *)&cmd_gro_flush_flush,
4761 (void *)&cmd_gro_flush_cycles,
4766 /* *** ENABLE/DISABLE GSO *** */
4767 struct cmd_gso_enable_result {
4768 cmdline_fixed_string_t cmd_set;
4769 cmdline_fixed_string_t cmd_port;
4770 cmdline_fixed_string_t cmd_keyword;
4771 cmdline_fixed_string_t cmd_mode;
4776 cmd_gso_enable_parsed(void *parsed_result,
4777 __attribute__((unused)) struct cmdline *cl,
4778 __attribute__((unused)) void *data)
4780 struct cmd_gso_enable_result *res;
4782 res = parsed_result;
4783 if (!strcmp(res->cmd_keyword, "gso"))
4784 setup_gso(res->cmd_mode, res->cmd_pid);
4787 cmdline_parse_token_string_t cmd_gso_enable_set =
4788 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4790 cmdline_parse_token_string_t cmd_gso_enable_port =
4791 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4793 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4794 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4795 cmd_keyword, "gso");
4796 cmdline_parse_token_string_t cmd_gso_enable_mode =
4797 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4798 cmd_mode, "on#off");
4799 cmdline_parse_token_num_t cmd_gso_enable_pid =
4800 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4803 cmdline_parse_inst_t cmd_gso_enable = {
4804 .f = cmd_gso_enable_parsed,
4806 .help_str = "set port <port_id> gso on|off",
4808 (void *)&cmd_gso_enable_set,
4809 (void *)&cmd_gso_enable_port,
4810 (void *)&cmd_gso_enable_pid,
4811 (void *)&cmd_gso_enable_keyword,
4812 (void *)&cmd_gso_enable_mode,
4817 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4818 struct cmd_gso_size_result {
4819 cmdline_fixed_string_t cmd_set;
4820 cmdline_fixed_string_t cmd_keyword;
4821 cmdline_fixed_string_t cmd_segsz;
4826 cmd_gso_size_parsed(void *parsed_result,
4827 __attribute__((unused)) struct cmdline *cl,
4828 __attribute__((unused)) void *data)
4830 struct cmd_gso_size_result *res = parsed_result;
4832 if (test_done == 0) {
4833 printf("Before setting GSO segsz, please first"
4834 " stop fowarding\n");
4838 if (!strcmp(res->cmd_keyword, "gso") &&
4839 !strcmp(res->cmd_segsz, "segsz")) {
4840 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4841 printf("gso_size should be larger than %zu."
4842 " Please input a legal value\n",
4843 RTE_GSO_SEG_SIZE_MIN);
4845 gso_max_segment_size = res->cmd_size;
4849 cmdline_parse_token_string_t cmd_gso_size_set =
4850 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4852 cmdline_parse_token_string_t cmd_gso_size_keyword =
4853 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4854 cmd_keyword, "gso");
4855 cmdline_parse_token_string_t cmd_gso_size_segsz =
4856 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4857 cmd_segsz, "segsz");
4858 cmdline_parse_token_num_t cmd_gso_size_size =
4859 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4862 cmdline_parse_inst_t cmd_gso_size = {
4863 .f = cmd_gso_size_parsed,
4865 .help_str = "set gso segsz <length>",
4867 (void *)&cmd_gso_size_set,
4868 (void *)&cmd_gso_size_keyword,
4869 (void *)&cmd_gso_size_segsz,
4870 (void *)&cmd_gso_size_size,
4875 /* *** SHOW GSO CONFIGURATION *** */
4876 struct cmd_gso_show_result {
4877 cmdline_fixed_string_t cmd_show;
4878 cmdline_fixed_string_t cmd_port;
4879 cmdline_fixed_string_t cmd_keyword;
4884 cmd_gso_show_parsed(void *parsed_result,
4885 __attribute__((unused)) struct cmdline *cl,
4886 __attribute__((unused)) void *data)
4888 struct cmd_gso_show_result *res = parsed_result;
4890 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4891 printf("invalid port id %u\n", res->cmd_pid);
4894 if (!strcmp(res->cmd_keyword, "gso")) {
4895 if (gso_ports[res->cmd_pid].enable) {
4896 printf("Max GSO'd packet size: %uB\n"
4897 "Supported GSO types: TCP/IPv4, "
4898 "UDP/IPv4, VxLAN with inner "
4899 "TCP/IPv4 packet, GRE with inner "
4900 "TCP/IPv4 packet\n",
4901 gso_max_segment_size);
4903 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4907 cmdline_parse_token_string_t cmd_gso_show_show =
4908 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4910 cmdline_parse_token_string_t cmd_gso_show_port =
4911 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4913 cmdline_parse_token_string_t cmd_gso_show_keyword =
4914 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4915 cmd_keyword, "gso");
4916 cmdline_parse_token_num_t cmd_gso_show_pid =
4917 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4920 cmdline_parse_inst_t cmd_gso_show = {
4921 .f = cmd_gso_show_parsed,
4923 .help_str = "show port <port_id> gso",
4925 (void *)&cmd_gso_show_show,
4926 (void *)&cmd_gso_show_port,
4927 (void *)&cmd_gso_show_pid,
4928 (void *)&cmd_gso_show_keyword,
4933 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4934 struct cmd_set_flush_rx {
4935 cmdline_fixed_string_t set;
4936 cmdline_fixed_string_t flush_rx;
4937 cmdline_fixed_string_t mode;
4941 cmd_set_flush_rx_parsed(void *parsed_result,
4942 __attribute__((unused)) struct cmdline *cl,
4943 __attribute__((unused)) void *data)
4945 struct cmd_set_flush_rx *res = parsed_result;
4946 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4949 cmdline_parse_token_string_t cmd_setflushrx_set =
4950 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4952 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4953 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4954 flush_rx, "flush_rx");
4955 cmdline_parse_token_string_t cmd_setflushrx_mode =
4956 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4960 cmdline_parse_inst_t cmd_set_flush_rx = {
4961 .f = cmd_set_flush_rx_parsed,
4962 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4965 (void *)&cmd_setflushrx_set,
4966 (void *)&cmd_setflushrx_flush_rx,
4967 (void *)&cmd_setflushrx_mode,
4972 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4973 struct cmd_set_link_check {
4974 cmdline_fixed_string_t set;
4975 cmdline_fixed_string_t link_check;
4976 cmdline_fixed_string_t mode;
4980 cmd_set_link_check_parsed(void *parsed_result,
4981 __attribute__((unused)) struct cmdline *cl,
4982 __attribute__((unused)) void *data)
4984 struct cmd_set_link_check *res = parsed_result;
4985 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4988 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4989 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4991 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4992 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4993 link_check, "link_check");
4994 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4995 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4999 cmdline_parse_inst_t cmd_set_link_check = {
5000 .f = cmd_set_link_check_parsed,
5001 .help_str = "set link_check on|off: Enable/Disable link status check "
5002 "when starting/stopping a port",
5005 (void *)&cmd_setlinkcheck_set,
5006 (void *)&cmd_setlinkcheck_link_check,
5007 (void *)&cmd_setlinkcheck_mode,
5012 /* *** SET NIC BYPASS MODE *** */
5013 struct cmd_set_bypass_mode_result {
5014 cmdline_fixed_string_t set;
5015 cmdline_fixed_string_t bypass;
5016 cmdline_fixed_string_t mode;
5017 cmdline_fixed_string_t value;
5022 cmd_set_bypass_mode_parsed(void *parsed_result,
5023 __attribute__((unused)) struct cmdline *cl,
5024 __attribute__((unused)) void *data)
5026 struct cmd_set_bypass_mode_result *res = parsed_result;
5027 portid_t port_id = res->port_id;
5028 int32_t rc = -EINVAL;
5030 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5031 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5033 if (!strcmp(res->value, "bypass"))
5034 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5035 else if (!strcmp(res->value, "isolate"))
5036 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5038 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5040 /* Set the bypass mode for the relevant port. */
5041 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5044 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5047 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5048 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5050 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5051 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5053 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5054 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5056 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5057 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5058 value, "normal#bypass#isolate");
5059 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5060 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5063 cmdline_parse_inst_t cmd_set_bypass_mode = {
5064 .f = cmd_set_bypass_mode_parsed,
5065 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5066 "Set the NIC bypass mode for port_id",
5069 (void *)&cmd_setbypass_mode_set,
5070 (void *)&cmd_setbypass_mode_bypass,
5071 (void *)&cmd_setbypass_mode_mode,
5072 (void *)&cmd_setbypass_mode_value,
5073 (void *)&cmd_setbypass_mode_port,
5078 /* *** SET NIC BYPASS EVENT *** */
5079 struct cmd_set_bypass_event_result {
5080 cmdline_fixed_string_t set;
5081 cmdline_fixed_string_t bypass;
5082 cmdline_fixed_string_t event;
5083 cmdline_fixed_string_t event_value;
5084 cmdline_fixed_string_t mode;
5085 cmdline_fixed_string_t mode_value;
5090 cmd_set_bypass_event_parsed(void *parsed_result,
5091 __attribute__((unused)) struct cmdline *cl,
5092 __attribute__((unused)) void *data)
5094 int32_t rc = -EINVAL;
5095 struct cmd_set_bypass_event_result *res = parsed_result;
5096 portid_t port_id = res->port_id;
5098 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5099 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5100 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5102 if (!strcmp(res->event_value, "timeout"))
5103 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5104 else if (!strcmp(res->event_value, "os_on"))
5105 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5106 else if (!strcmp(res->event_value, "os_off"))
5107 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5108 else if (!strcmp(res->event_value, "power_on"))
5109 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5110 else if (!strcmp(res->event_value, "power_off"))
5111 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5113 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5115 if (!strcmp(res->mode_value, "bypass"))
5116 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5117 else if (!strcmp(res->mode_value, "isolate"))
5118 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5120 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5122 /* Set the watchdog timeout. */
5123 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5126 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5127 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5131 printf("Failed to set timeout value %u "
5132 "for port %d, errto code: %d.\n",
5133 bypass_timeout, port_id, rc);
5137 /* Set the bypass event to transition to bypass mode. */
5138 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5143 printf("\t Failed to set bypass event for port = %d.\n",
5147 cmdline_parse_token_string_t cmd_setbypass_event_set =
5148 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5150 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5151 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5153 cmdline_parse_token_string_t cmd_setbypass_event_event =
5154 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5156 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5157 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5158 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5159 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5160 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5162 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5163 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5164 mode_value, "normal#bypass#isolate");
5165 cmdline_parse_token_num_t cmd_setbypass_event_port =
5166 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5169 cmdline_parse_inst_t cmd_set_bypass_event = {
5170 .f = cmd_set_bypass_event_parsed,
5171 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5172 "power_off mode normal|bypass|isolate <port_id>: "
5173 "Set the NIC bypass event mode for port_id",
5176 (void *)&cmd_setbypass_event_set,
5177 (void *)&cmd_setbypass_event_bypass,
5178 (void *)&cmd_setbypass_event_event,
5179 (void *)&cmd_setbypass_event_event_value,
5180 (void *)&cmd_setbypass_event_mode,
5181 (void *)&cmd_setbypass_event_mode_value,
5182 (void *)&cmd_setbypass_event_port,
5188 /* *** SET NIC BYPASS TIMEOUT *** */
5189 struct cmd_set_bypass_timeout_result {
5190 cmdline_fixed_string_t set;
5191 cmdline_fixed_string_t bypass;
5192 cmdline_fixed_string_t timeout;
5193 cmdline_fixed_string_t value;
5197 cmd_set_bypass_timeout_parsed(void *parsed_result,
5198 __attribute__((unused)) struct cmdline *cl,
5199 __attribute__((unused)) void *data)
5201 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5203 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5204 if (!strcmp(res->value, "1.5"))
5205 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5206 else if (!strcmp(res->value, "2"))
5207 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5208 else if (!strcmp(res->value, "3"))
5209 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5210 else if (!strcmp(res->value, "4"))
5211 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5212 else if (!strcmp(res->value, "8"))
5213 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5214 else if (!strcmp(res->value, "16"))
5215 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5216 else if (!strcmp(res->value, "32"))
5217 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5219 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5223 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5224 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5226 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5227 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5229 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5230 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5231 timeout, "timeout");
5232 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5233 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5234 value, "0#1.5#2#3#4#8#16#32");
5236 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5237 .f = cmd_set_bypass_timeout_parsed,
5238 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5239 "Set the NIC bypass watchdog timeout in seconds",
5242 (void *)&cmd_setbypass_timeout_set,
5243 (void *)&cmd_setbypass_timeout_bypass,
5244 (void *)&cmd_setbypass_timeout_timeout,
5245 (void *)&cmd_setbypass_timeout_value,
5250 /* *** SHOW NIC BYPASS MODE *** */
5251 struct cmd_show_bypass_config_result {
5252 cmdline_fixed_string_t show;
5253 cmdline_fixed_string_t bypass;
5254 cmdline_fixed_string_t config;
5259 cmd_show_bypass_config_parsed(void *parsed_result,
5260 __attribute__((unused)) struct cmdline *cl,
5261 __attribute__((unused)) void *data)
5263 struct cmd_show_bypass_config_result *res = parsed_result;
5264 portid_t port_id = res->port_id;
5266 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5267 uint32_t event_mode;
5268 uint32_t bypass_mode;
5269 uint32_t timeout = bypass_timeout;
5272 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5273 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5274 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5275 {"UNKNOWN", "normal", "bypass", "isolate"};
5276 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5283 int num_events = (sizeof events) / (sizeof events[0]);
5285 /* Display the bypass mode.*/
5286 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5287 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5291 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5292 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5294 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5297 /* Display the bypass timeout.*/
5298 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5299 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5301 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5303 /* Display the bypass events and associated modes. */
5304 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5306 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5307 printf("\tFailed to get bypass mode for event = %s\n",
5310 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5311 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5313 printf("\tbypass event: %-16s = %s\n", events[i],
5319 printf("\tFailed to get bypass configuration for port = %d\n",
5323 cmdline_parse_token_string_t cmd_showbypass_config_show =
5324 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5326 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5327 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5329 cmdline_parse_token_string_t cmd_showbypass_config_config =
5330 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5332 cmdline_parse_token_num_t cmd_showbypass_config_port =
5333 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5336 cmdline_parse_inst_t cmd_show_bypass_config = {
5337 .f = cmd_show_bypass_config_parsed,
5338 .help_str = "show bypass config <port_id>: "
5339 "Show the NIC bypass config for port_id",
5342 (void *)&cmd_showbypass_config_show,
5343 (void *)&cmd_showbypass_config_bypass,
5344 (void *)&cmd_showbypass_config_config,
5345 (void *)&cmd_showbypass_config_port,
5350 #ifdef RTE_LIBRTE_PMD_BOND
5351 /* *** SET BONDING MODE *** */
5352 struct cmd_set_bonding_mode_result {
5353 cmdline_fixed_string_t set;
5354 cmdline_fixed_string_t bonding;
5355 cmdline_fixed_string_t mode;
5360 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5361 __attribute__((unused)) struct cmdline *cl,
5362 __attribute__((unused)) void *data)
5364 struct cmd_set_bonding_mode_result *res = parsed_result;
5365 portid_t port_id = res->port_id;
5367 /* Set the bonding mode for the relevant port. */
5368 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5369 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5372 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5373 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5375 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5376 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5377 bonding, "bonding");
5378 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5379 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5381 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5382 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5384 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5385 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5388 cmdline_parse_inst_t cmd_set_bonding_mode = {
5389 .f = cmd_set_bonding_mode_parsed,
5390 .help_str = "set bonding mode <mode_value> <port_id>: "
5391 "Set the bonding mode for port_id",
5394 (void *) &cmd_setbonding_mode_set,
5395 (void *) &cmd_setbonding_mode_bonding,
5396 (void *) &cmd_setbonding_mode_mode,
5397 (void *) &cmd_setbonding_mode_value,
5398 (void *) &cmd_setbonding_mode_port,
5403 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5404 struct cmd_set_bonding_lacp_dedicated_queues_result {
5405 cmdline_fixed_string_t set;
5406 cmdline_fixed_string_t bonding;
5407 cmdline_fixed_string_t lacp;
5408 cmdline_fixed_string_t dedicated_queues;
5410 cmdline_fixed_string_t mode;
5413 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5414 __attribute__((unused)) struct cmdline *cl,
5415 __attribute__((unused)) void *data)
5417 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5418 portid_t port_id = res->port_id;
5419 struct rte_port *port;
5421 port = &ports[port_id];
5423 /** Check if the port is not started **/
5424 if (port->port_status != RTE_PORT_STOPPED) {
5425 printf("Please stop port %d first\n", port_id);
5429 if (!strcmp(res->mode, "enable")) {
5430 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5431 printf("Dedicate queues for LACP control packets"
5434 printf("Enabling dedicate queues for LACP control "
5435 "packets on port %d failed\n", port_id);
5436 } else if (!strcmp(res->mode, "disable")) {
5437 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5438 printf("Dedicated queues for LACP control packets "
5441 printf("Disabling dedicated queues for LACP control "
5442 "traffic on port %d failed\n", port_id);
5446 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5447 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5449 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5450 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5451 bonding, "bonding");
5452 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5453 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5455 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5456 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5457 dedicated_queues, "dedicated_queues");
5458 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5459 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5461 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5462 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5463 mode, "enable#disable");
5465 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5466 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5467 .help_str = "set bonding lacp dedicated_queues <port_id> "
5469 "Enable/disable dedicated queues for LACP control traffic for port_id",
5472 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5473 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5474 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5475 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5476 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5477 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5482 /* *** SET BALANCE XMIT POLICY *** */
5483 struct cmd_set_bonding_balance_xmit_policy_result {
5484 cmdline_fixed_string_t set;
5485 cmdline_fixed_string_t bonding;
5486 cmdline_fixed_string_t balance_xmit_policy;
5488 cmdline_fixed_string_t policy;
5491 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5492 __attribute__((unused)) struct cmdline *cl,
5493 __attribute__((unused)) void *data)
5495 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5496 portid_t port_id = res->port_id;
5499 if (!strcmp(res->policy, "l2")) {
5500 policy = BALANCE_XMIT_POLICY_LAYER2;
5501 } else if (!strcmp(res->policy, "l23")) {
5502 policy = BALANCE_XMIT_POLICY_LAYER23;
5503 } else if (!strcmp(res->policy, "l34")) {
5504 policy = BALANCE_XMIT_POLICY_LAYER34;
5506 printf("\t Invalid xmit policy selection");
5510 /* Set the bonding mode for the relevant port. */
5511 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5512 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5517 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5518 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5520 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5521 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5522 bonding, "bonding");
5523 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5524 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5525 balance_xmit_policy, "balance_xmit_policy");
5526 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5527 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5529 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5530 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5531 policy, "l2#l23#l34");
5533 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5534 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5535 .help_str = "set bonding balance_xmit_policy <port_id> "
5537 "Set the bonding balance_xmit_policy for port_id",
5540 (void *)&cmd_setbonding_balance_xmit_policy_set,
5541 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5542 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5543 (void *)&cmd_setbonding_balance_xmit_policy_port,
5544 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5549 /* *** SHOW NIC BONDING CONFIGURATION *** */
5550 struct cmd_show_bonding_config_result {
5551 cmdline_fixed_string_t show;
5552 cmdline_fixed_string_t bonding;
5553 cmdline_fixed_string_t config;
5557 static void cmd_show_bonding_config_parsed(void *parsed_result,
5558 __attribute__((unused)) struct cmdline *cl,
5559 __attribute__((unused)) void *data)
5561 struct cmd_show_bonding_config_result *res = parsed_result;
5562 int bonding_mode, agg_mode;
5563 portid_t slaves[RTE_MAX_ETHPORTS];
5564 int num_slaves, num_active_slaves;
5567 portid_t port_id = res->port_id;
5569 /* Display the bonding mode.*/
5570 bonding_mode = rte_eth_bond_mode_get(port_id);
5571 if (bonding_mode < 0) {
5572 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5575 printf("\tBonding mode: %d\n", bonding_mode);
5577 if (bonding_mode == BONDING_MODE_BALANCE) {
5578 int balance_xmit_policy;
5580 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5581 if (balance_xmit_policy < 0) {
5582 printf("\tFailed to get balance xmit policy for port = %d\n",
5586 printf("\tBalance Xmit Policy: ");
5588 switch (balance_xmit_policy) {
5589 case BALANCE_XMIT_POLICY_LAYER2:
5590 printf("BALANCE_XMIT_POLICY_LAYER2");
5592 case BALANCE_XMIT_POLICY_LAYER23:
5593 printf("BALANCE_XMIT_POLICY_LAYER23");
5595 case BALANCE_XMIT_POLICY_LAYER34:
5596 printf("BALANCE_XMIT_POLICY_LAYER34");
5603 if (bonding_mode == BONDING_MODE_8023AD) {
5604 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5605 printf("\tIEEE802.3AD Aggregator Mode: ");
5608 printf("bandwidth");
5620 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5622 if (num_slaves < 0) {
5623 printf("\tFailed to get slave list for port = %d\n", port_id);
5626 if (num_slaves > 0) {
5627 printf("\tSlaves (%d): [", num_slaves);
5628 for (i = 0; i < num_slaves - 1; i++)
5629 printf("%d ", slaves[i]);
5631 printf("%d]\n", slaves[num_slaves - 1]);
5633 printf("\tSlaves: []\n");
5637 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5640 if (num_active_slaves < 0) {
5641 printf("\tFailed to get active slave list for port = %d\n", port_id);
5644 if (num_active_slaves > 0) {
5645 printf("\tActive Slaves (%d): [", num_active_slaves);
5646 for (i = 0; i < num_active_slaves - 1; i++)
5647 printf("%d ", slaves[i]);
5649 printf("%d]\n", slaves[num_active_slaves - 1]);
5652 printf("\tActive Slaves: []\n");
5656 primary_id = rte_eth_bond_primary_get(port_id);
5657 if (primary_id < 0) {
5658 printf("\tFailed to get primary slave for port = %d\n", port_id);
5661 printf("\tPrimary: [%d]\n", primary_id);
5665 cmdline_parse_token_string_t cmd_showbonding_config_show =
5666 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5668 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5669 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5670 bonding, "bonding");
5671 cmdline_parse_token_string_t cmd_showbonding_config_config =
5672 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5674 cmdline_parse_token_num_t cmd_showbonding_config_port =
5675 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5678 cmdline_parse_inst_t cmd_show_bonding_config = {
5679 .f = cmd_show_bonding_config_parsed,
5680 .help_str = "show bonding config <port_id>: "
5681 "Show the bonding config for port_id",
5684 (void *)&cmd_showbonding_config_show,
5685 (void *)&cmd_showbonding_config_bonding,
5686 (void *)&cmd_showbonding_config_config,
5687 (void *)&cmd_showbonding_config_port,
5692 /* *** SET BONDING PRIMARY *** */
5693 struct cmd_set_bonding_primary_result {
5694 cmdline_fixed_string_t set;
5695 cmdline_fixed_string_t bonding;
5696 cmdline_fixed_string_t primary;
5701 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5702 __attribute__((unused)) struct cmdline *cl,
5703 __attribute__((unused)) void *data)
5705 struct cmd_set_bonding_primary_result *res = parsed_result;
5706 portid_t master_port_id = res->port_id;
5707 portid_t slave_port_id = res->slave_id;
5709 /* Set the primary slave for a bonded device. */
5710 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5711 printf("\t Failed to set primary slave for port = %d.\n",
5718 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5719 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5721 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5722 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5723 bonding, "bonding");
5724 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5725 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5726 primary, "primary");
5727 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5728 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5730 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5731 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5734 cmdline_parse_inst_t cmd_set_bonding_primary = {
5735 .f = cmd_set_bonding_primary_parsed,
5736 .help_str = "set bonding primary <slave_id> <port_id>: "
5737 "Set the primary slave for port_id",
5740 (void *)&cmd_setbonding_primary_set,
5741 (void *)&cmd_setbonding_primary_bonding,
5742 (void *)&cmd_setbonding_primary_primary,
5743 (void *)&cmd_setbonding_primary_slave,
5744 (void *)&cmd_setbonding_primary_port,
5749 /* *** ADD SLAVE *** */
5750 struct cmd_add_bonding_slave_result {
5751 cmdline_fixed_string_t add;
5752 cmdline_fixed_string_t bonding;
5753 cmdline_fixed_string_t slave;
5758 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5759 __attribute__((unused)) struct cmdline *cl,
5760 __attribute__((unused)) void *data)
5762 struct cmd_add_bonding_slave_result *res = parsed_result;
5763 portid_t master_port_id = res->port_id;
5764 portid_t slave_port_id = res->slave_id;
5766 /* add the slave for a bonded device. */
5767 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5768 printf("\t Failed to add slave %d to master port = %d.\n",
5769 slave_port_id, master_port_id);
5773 set_port_slave_flag(slave_port_id);
5776 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5777 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5779 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5780 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5781 bonding, "bonding");
5782 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5783 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5785 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5786 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5788 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5789 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5792 cmdline_parse_inst_t cmd_add_bonding_slave = {
5793 .f = cmd_add_bonding_slave_parsed,
5794 .help_str = "add bonding slave <slave_id> <port_id>: "
5795 "Add a slave device to a bonded device",
5798 (void *)&cmd_addbonding_slave_add,
5799 (void *)&cmd_addbonding_slave_bonding,
5800 (void *)&cmd_addbonding_slave_slave,
5801 (void *)&cmd_addbonding_slave_slaveid,
5802 (void *)&cmd_addbonding_slave_port,
5807 /* *** REMOVE SLAVE *** */
5808 struct cmd_remove_bonding_slave_result {
5809 cmdline_fixed_string_t remove;
5810 cmdline_fixed_string_t bonding;
5811 cmdline_fixed_string_t slave;
5816 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5817 __attribute__((unused)) struct cmdline *cl,
5818 __attribute__((unused)) void *data)
5820 struct cmd_remove_bonding_slave_result *res = parsed_result;
5821 portid_t master_port_id = res->port_id;
5822 portid_t slave_port_id = res->slave_id;
5824 /* remove the slave from a bonded device. */
5825 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5826 printf("\t Failed to remove slave %d from master port = %d.\n",
5827 slave_port_id, master_port_id);
5831 clear_port_slave_flag(slave_port_id);
5834 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5835 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5837 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5838 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5839 bonding, "bonding");
5840 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5841 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5843 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5844 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5846 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5847 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5850 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5851 .f = cmd_remove_bonding_slave_parsed,
5852 .help_str = "remove bonding slave <slave_id> <port_id>: "
5853 "Remove a slave device from a bonded device",
5856 (void *)&cmd_removebonding_slave_remove,
5857 (void *)&cmd_removebonding_slave_bonding,
5858 (void *)&cmd_removebonding_slave_slave,
5859 (void *)&cmd_removebonding_slave_slaveid,
5860 (void *)&cmd_removebonding_slave_port,
5865 /* *** CREATE BONDED DEVICE *** */
5866 struct cmd_create_bonded_device_result {
5867 cmdline_fixed_string_t create;
5868 cmdline_fixed_string_t bonded;
5869 cmdline_fixed_string_t device;
5874 static int bond_dev_num = 0;
5876 static void cmd_create_bonded_device_parsed(void *parsed_result,
5877 __attribute__((unused)) struct cmdline *cl,
5878 __attribute__((unused)) void *data)
5880 struct cmd_create_bonded_device_result *res = parsed_result;
5881 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5884 if (test_done == 0) {
5885 printf("Please stop forwarding first\n");
5889 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5892 /* Create a new bonded device. */
5893 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5895 printf("\t Failed to create bonded device.\n");
5898 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5901 /* Update number of ports */
5902 nb_ports = rte_eth_dev_count_avail();
5903 reconfig(port_id, res->socket);
5904 rte_eth_promiscuous_enable(port_id);
5909 cmdline_parse_token_string_t cmd_createbonded_device_create =
5910 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5912 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5913 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5915 cmdline_parse_token_string_t cmd_createbonded_device_device =
5916 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5918 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5919 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5921 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5922 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5925 cmdline_parse_inst_t cmd_create_bonded_device = {
5926 .f = cmd_create_bonded_device_parsed,
5927 .help_str = "create bonded device <mode> <socket>: "
5928 "Create a new bonded device with specific bonding mode and socket",
5931 (void *)&cmd_createbonded_device_create,
5932 (void *)&cmd_createbonded_device_bonded,
5933 (void *)&cmd_createbonded_device_device,
5934 (void *)&cmd_createbonded_device_mode,
5935 (void *)&cmd_createbonded_device_socket,
5940 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5941 struct cmd_set_bond_mac_addr_result {
5942 cmdline_fixed_string_t set;
5943 cmdline_fixed_string_t bonding;
5944 cmdline_fixed_string_t mac_addr;
5946 struct ether_addr address;
5949 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5950 __attribute__((unused)) struct cmdline *cl,
5951 __attribute__((unused)) void *data)
5953 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5956 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5959 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5961 /* check the return value and print it if is < 0 */
5963 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5966 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5967 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5968 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5969 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5971 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5972 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5974 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5975 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5977 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5978 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5980 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5981 .f = cmd_set_bond_mac_addr_parsed,
5983 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5985 (void *)&cmd_set_bond_mac_addr_set,
5986 (void *)&cmd_set_bond_mac_addr_bonding,
5987 (void *)&cmd_set_bond_mac_addr_mac,
5988 (void *)&cmd_set_bond_mac_addr_portnum,
5989 (void *)&cmd_set_bond_mac_addr_addr,
5995 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5996 struct cmd_set_bond_mon_period_result {
5997 cmdline_fixed_string_t set;
5998 cmdline_fixed_string_t bonding;
5999 cmdline_fixed_string_t mon_period;
6004 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6005 __attribute__((unused)) struct cmdline *cl,
6006 __attribute__((unused)) void *data)
6008 struct cmd_set_bond_mon_period_result *res = parsed_result;
6011 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6013 /* check the return value and print it if is < 0 */
6015 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6018 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6019 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6021 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6022 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6023 bonding, "bonding");
6024 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6025 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6026 mon_period, "mon_period");
6027 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6028 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6030 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6031 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6034 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6035 .f = cmd_set_bond_mon_period_parsed,
6037 .help_str = "set bonding mon_period <port_id> <period_ms>",
6039 (void *)&cmd_set_bond_mon_period_set,
6040 (void *)&cmd_set_bond_mon_period_bonding,
6041 (void *)&cmd_set_bond_mon_period_mon_period,
6042 (void *)&cmd_set_bond_mon_period_portnum,
6043 (void *)&cmd_set_bond_mon_period_period_ms,
6050 struct cmd_set_bonding_agg_mode_policy_result {
6051 cmdline_fixed_string_t set;
6052 cmdline_fixed_string_t bonding;
6053 cmdline_fixed_string_t agg_mode;
6055 cmdline_fixed_string_t policy;
6060 cmd_set_bonding_agg_mode(void *parsed_result,
6061 __attribute__((unused)) struct cmdline *cl,
6062 __attribute__((unused)) void *data)
6064 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6065 uint8_t policy = AGG_BANDWIDTH;
6067 if (!strcmp(res->policy, "bandwidth"))
6068 policy = AGG_BANDWIDTH;
6069 else if (!strcmp(res->policy, "stable"))
6070 policy = AGG_STABLE;
6071 else if (!strcmp(res->policy, "count"))
6074 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6078 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6079 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6081 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6082 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6083 bonding, "bonding");
6085 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6086 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6087 agg_mode, "agg_mode");
6089 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6090 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6093 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6094 TOKEN_STRING_INITIALIZER(
6095 struct cmd_set_bonding_balance_xmit_policy_result,
6096 policy, "stable#bandwidth#count");
6098 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6099 .f = cmd_set_bonding_agg_mode,
6101 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6103 (void *)&cmd_set_bonding_agg_mode_set,
6104 (void *)&cmd_set_bonding_agg_mode_bonding,
6105 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6106 (void *)&cmd_set_bonding_agg_mode_portnum,
6107 (void *)&cmd_set_bonding_agg_mode_policy_string,
6113 #endif /* RTE_LIBRTE_PMD_BOND */
6115 /* *** SET FORWARDING MODE *** */
6116 struct cmd_set_fwd_mode_result {
6117 cmdline_fixed_string_t set;
6118 cmdline_fixed_string_t fwd;
6119 cmdline_fixed_string_t mode;
6122 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6123 __attribute__((unused)) struct cmdline *cl,
6124 __attribute__((unused)) void *data)
6126 struct cmd_set_fwd_mode_result *res = parsed_result;
6129 set_pkt_forwarding_mode(res->mode);
6132 cmdline_parse_token_string_t cmd_setfwd_set =
6133 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6134 cmdline_parse_token_string_t cmd_setfwd_fwd =
6135 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6136 cmdline_parse_token_string_t cmd_setfwd_mode =
6137 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6138 "" /* defined at init */);
6140 cmdline_parse_inst_t cmd_set_fwd_mode = {
6141 .f = cmd_set_fwd_mode_parsed,
6143 .help_str = NULL, /* defined at init */
6145 (void *)&cmd_setfwd_set,
6146 (void *)&cmd_setfwd_fwd,
6147 (void *)&cmd_setfwd_mode,
6152 static void cmd_set_fwd_mode_init(void)
6155 static char token[128];
6156 static char help[256];
6157 cmdline_parse_token_string_t *token_struct;
6159 modes = list_pkt_forwarding_modes();
6160 snprintf(help, sizeof(help), "set fwd %s: "
6161 "Set packet forwarding mode", modes);
6162 cmd_set_fwd_mode.help_str = help;
6164 /* string token separator is # */
6165 for (c = token; *modes != '\0'; modes++)
6170 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6171 token_struct->string_data.str = token;
6174 /* *** SET RETRY FORWARDING MODE *** */
6175 struct cmd_set_fwd_retry_mode_result {
6176 cmdline_fixed_string_t set;
6177 cmdline_fixed_string_t fwd;
6178 cmdline_fixed_string_t mode;
6179 cmdline_fixed_string_t retry;
6182 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6183 __attribute__((unused)) struct cmdline *cl,
6184 __attribute__((unused)) void *data)
6186 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6189 set_pkt_forwarding_mode(res->mode);
6192 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6193 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6195 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6196 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6198 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6199 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6201 "" /* defined at init */);
6202 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6203 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6206 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6207 .f = cmd_set_fwd_retry_mode_parsed,
6209 .help_str = NULL, /* defined at init */
6211 (void *)&cmd_setfwd_retry_set,
6212 (void *)&cmd_setfwd_retry_fwd,
6213 (void *)&cmd_setfwd_retry_mode,
6214 (void *)&cmd_setfwd_retry_retry,
6219 static void cmd_set_fwd_retry_mode_init(void)
6222 static char token[128];
6223 static char help[256];
6224 cmdline_parse_token_string_t *token_struct;
6226 modes = list_pkt_forwarding_retry_modes();
6227 snprintf(help, sizeof(help), "set fwd %s retry: "
6228 "Set packet forwarding mode with retry", modes);
6229 cmd_set_fwd_retry_mode.help_str = help;
6231 /* string token separator is # */
6232 for (c = token; *modes != '\0'; modes++)
6237 token_struct = (cmdline_parse_token_string_t *)
6238 cmd_set_fwd_retry_mode.tokens[2];
6239 token_struct->string_data.str = token;
6242 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6243 struct cmd_set_burst_tx_retry_result {
6244 cmdline_fixed_string_t set;
6245 cmdline_fixed_string_t burst;
6246 cmdline_fixed_string_t tx;
6247 cmdline_fixed_string_t delay;
6249 cmdline_fixed_string_t retry;
6253 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6254 __attribute__((unused)) struct cmdline *cl,
6255 __attribute__((unused)) void *data)
6257 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6259 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6260 && !strcmp(res->tx, "tx")) {
6261 if (!strcmp(res->delay, "delay"))
6262 burst_tx_delay_time = res->time;
6263 if (!strcmp(res->retry, "retry"))
6264 burst_tx_retry_num = res->retry_num;
6269 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6270 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6271 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6272 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6274 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6275 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6276 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6277 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6278 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6279 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6280 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6281 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6282 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6283 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6285 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6286 .f = cmd_set_burst_tx_retry_parsed,
6287 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6289 (void *)&cmd_set_burst_tx_retry_set,
6290 (void *)&cmd_set_burst_tx_retry_burst,
6291 (void *)&cmd_set_burst_tx_retry_tx,
6292 (void *)&cmd_set_burst_tx_retry_delay,
6293 (void *)&cmd_set_burst_tx_retry_time,
6294 (void *)&cmd_set_burst_tx_retry_retry,
6295 (void *)&cmd_set_burst_tx_retry_retry_num,
6300 /* *** SET PROMISC MODE *** */
6301 struct cmd_set_promisc_mode_result {
6302 cmdline_fixed_string_t set;
6303 cmdline_fixed_string_t promisc;
6304 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6305 uint16_t port_num; /* valid if "allports" argument == 0 */
6306 cmdline_fixed_string_t mode;
6309 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6310 __attribute__((unused)) struct cmdline *cl,
6313 struct cmd_set_promisc_mode_result *res = parsed_result;
6317 if (!strcmp(res->mode, "on"))
6324 RTE_ETH_FOREACH_DEV(i) {
6326 rte_eth_promiscuous_enable(i);
6328 rte_eth_promiscuous_disable(i);
6333 rte_eth_promiscuous_enable(res->port_num);
6335 rte_eth_promiscuous_disable(res->port_num);
6339 cmdline_parse_token_string_t cmd_setpromisc_set =
6340 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6341 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6342 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6344 cmdline_parse_token_string_t cmd_setpromisc_portall =
6345 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6347 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6348 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6350 cmdline_parse_token_string_t cmd_setpromisc_mode =
6351 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6354 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6355 .f = cmd_set_promisc_mode_parsed,
6357 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6359 (void *)&cmd_setpromisc_set,
6360 (void *)&cmd_setpromisc_promisc,
6361 (void *)&cmd_setpromisc_portall,
6362 (void *)&cmd_setpromisc_mode,
6367 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6368 .f = cmd_set_promisc_mode_parsed,
6370 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6372 (void *)&cmd_setpromisc_set,
6373 (void *)&cmd_setpromisc_promisc,
6374 (void *)&cmd_setpromisc_portnum,
6375 (void *)&cmd_setpromisc_mode,
6380 /* *** SET ALLMULTI MODE *** */
6381 struct cmd_set_allmulti_mode_result {
6382 cmdline_fixed_string_t set;
6383 cmdline_fixed_string_t allmulti;
6384 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6385 uint16_t port_num; /* valid if "allports" argument == 0 */
6386 cmdline_fixed_string_t mode;
6389 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6390 __attribute__((unused)) struct cmdline *cl,
6393 struct cmd_set_allmulti_mode_result *res = parsed_result;
6397 if (!strcmp(res->mode, "on"))
6404 RTE_ETH_FOREACH_DEV(i) {
6406 rte_eth_allmulticast_enable(i);
6408 rte_eth_allmulticast_disable(i);
6413 rte_eth_allmulticast_enable(res->port_num);
6415 rte_eth_allmulticast_disable(res->port_num);
6419 cmdline_parse_token_string_t cmd_setallmulti_set =
6420 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6421 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6422 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6424 cmdline_parse_token_string_t cmd_setallmulti_portall =
6425 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6427 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6428 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6430 cmdline_parse_token_string_t cmd_setallmulti_mode =
6431 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6434 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6435 .f = cmd_set_allmulti_mode_parsed,
6437 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6439 (void *)&cmd_setallmulti_set,
6440 (void *)&cmd_setallmulti_allmulti,
6441 (void *)&cmd_setallmulti_portall,
6442 (void *)&cmd_setallmulti_mode,
6447 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6448 .f = cmd_set_allmulti_mode_parsed,
6450 .help_str = "set allmulti <port_id> on|off: "
6451 "Set allmulti mode on port_id",
6453 (void *)&cmd_setallmulti_set,
6454 (void *)&cmd_setallmulti_allmulti,
6455 (void *)&cmd_setallmulti_portnum,
6456 (void *)&cmd_setallmulti_mode,
6461 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6462 struct cmd_link_flow_ctrl_set_result {
6463 cmdline_fixed_string_t set;
6464 cmdline_fixed_string_t flow_ctrl;
6465 cmdline_fixed_string_t rx;
6466 cmdline_fixed_string_t rx_lfc_mode;
6467 cmdline_fixed_string_t tx;
6468 cmdline_fixed_string_t tx_lfc_mode;
6469 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6470 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6471 cmdline_fixed_string_t autoneg_str;
6472 cmdline_fixed_string_t autoneg;
6473 cmdline_fixed_string_t hw_str;
6474 uint32_t high_water;
6475 cmdline_fixed_string_t lw_str;
6477 cmdline_fixed_string_t pt_str;
6478 uint16_t pause_time;
6479 cmdline_fixed_string_t xon_str;
6484 cmdline_parse_token_string_t cmd_lfc_set_set =
6485 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6487 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6488 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6489 flow_ctrl, "flow_ctrl");
6490 cmdline_parse_token_string_t cmd_lfc_set_rx =
6491 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6493 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6494 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6495 rx_lfc_mode, "on#off");
6496 cmdline_parse_token_string_t cmd_lfc_set_tx =
6497 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6499 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6500 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6501 tx_lfc_mode, "on#off");
6502 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6503 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6504 hw_str, "high_water");
6505 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6506 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6507 high_water, UINT32);
6508 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6509 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6510 lw_str, "low_water");
6511 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6512 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6514 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6515 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6516 pt_str, "pause_time");
6517 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6518 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6519 pause_time, UINT16);
6520 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6521 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6522 xon_str, "send_xon");
6523 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6524 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6526 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6527 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6528 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6529 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6530 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6531 mac_ctrl_frame_fwd_mode, "on#off");
6532 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6533 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6534 autoneg_str, "autoneg");
6535 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6536 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6538 cmdline_parse_token_num_t cmd_lfc_set_portid =
6539 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6542 /* forward declaration */
6544 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6547 cmdline_parse_inst_t cmd_link_flow_control_set = {
6548 .f = cmd_link_flow_ctrl_set_parsed,
6550 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6551 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6552 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6554 (void *)&cmd_lfc_set_set,
6555 (void *)&cmd_lfc_set_flow_ctrl,
6556 (void *)&cmd_lfc_set_rx,
6557 (void *)&cmd_lfc_set_rx_mode,
6558 (void *)&cmd_lfc_set_tx,
6559 (void *)&cmd_lfc_set_tx_mode,
6560 (void *)&cmd_lfc_set_high_water,
6561 (void *)&cmd_lfc_set_low_water,
6562 (void *)&cmd_lfc_set_pause_time,
6563 (void *)&cmd_lfc_set_send_xon,
6564 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6565 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6566 (void *)&cmd_lfc_set_autoneg_str,
6567 (void *)&cmd_lfc_set_autoneg,
6568 (void *)&cmd_lfc_set_portid,
6573 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6574 .f = cmd_link_flow_ctrl_set_parsed,
6575 .data = (void *)&cmd_link_flow_control_set_rx,
6576 .help_str = "set flow_ctrl rx on|off <port_id>: "
6577 "Change rx flow control parameter",
6579 (void *)&cmd_lfc_set_set,
6580 (void *)&cmd_lfc_set_flow_ctrl,
6581 (void *)&cmd_lfc_set_rx,
6582 (void *)&cmd_lfc_set_rx_mode,
6583 (void *)&cmd_lfc_set_portid,
6588 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6589 .f = cmd_link_flow_ctrl_set_parsed,
6590 .data = (void *)&cmd_link_flow_control_set_tx,
6591 .help_str = "set flow_ctrl tx on|off <port_id>: "
6592 "Change tx flow control parameter",
6594 (void *)&cmd_lfc_set_set,
6595 (void *)&cmd_lfc_set_flow_ctrl,
6596 (void *)&cmd_lfc_set_tx,
6597 (void *)&cmd_lfc_set_tx_mode,
6598 (void *)&cmd_lfc_set_portid,
6603 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6604 .f = cmd_link_flow_ctrl_set_parsed,
6605 .data = (void *)&cmd_link_flow_control_set_hw,
6606 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6607 "Change high water flow control parameter",
6609 (void *)&cmd_lfc_set_set,
6610 (void *)&cmd_lfc_set_flow_ctrl,
6611 (void *)&cmd_lfc_set_high_water_str,
6612 (void *)&cmd_lfc_set_high_water,
6613 (void *)&cmd_lfc_set_portid,
6618 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6619 .f = cmd_link_flow_ctrl_set_parsed,
6620 .data = (void *)&cmd_link_flow_control_set_lw,
6621 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6622 "Change low water flow control parameter",
6624 (void *)&cmd_lfc_set_set,
6625 (void *)&cmd_lfc_set_flow_ctrl,
6626 (void *)&cmd_lfc_set_low_water_str,
6627 (void *)&cmd_lfc_set_low_water,
6628 (void *)&cmd_lfc_set_portid,
6633 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6634 .f = cmd_link_flow_ctrl_set_parsed,
6635 .data = (void *)&cmd_link_flow_control_set_pt,
6636 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6637 "Change pause time flow control parameter",
6639 (void *)&cmd_lfc_set_set,
6640 (void *)&cmd_lfc_set_flow_ctrl,
6641 (void *)&cmd_lfc_set_pause_time_str,
6642 (void *)&cmd_lfc_set_pause_time,
6643 (void *)&cmd_lfc_set_portid,
6648 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6649 .f = cmd_link_flow_ctrl_set_parsed,
6650 .data = (void *)&cmd_link_flow_control_set_xon,
6651 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6652 "Change send_xon flow control parameter",
6654 (void *)&cmd_lfc_set_set,
6655 (void *)&cmd_lfc_set_flow_ctrl,
6656 (void *)&cmd_lfc_set_send_xon_str,
6657 (void *)&cmd_lfc_set_send_xon,
6658 (void *)&cmd_lfc_set_portid,
6663 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6664 .f = cmd_link_flow_ctrl_set_parsed,
6665 .data = (void *)&cmd_link_flow_control_set_macfwd,
6666 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6667 "Change mac ctrl fwd flow control parameter",
6669 (void *)&cmd_lfc_set_set,
6670 (void *)&cmd_lfc_set_flow_ctrl,
6671 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6672 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6673 (void *)&cmd_lfc_set_portid,
6678 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6679 .f = cmd_link_flow_ctrl_set_parsed,
6680 .data = (void *)&cmd_link_flow_control_set_autoneg,
6681 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6682 "Change autoneg flow control parameter",
6684 (void *)&cmd_lfc_set_set,
6685 (void *)&cmd_lfc_set_flow_ctrl,
6686 (void *)&cmd_lfc_set_autoneg_str,
6687 (void *)&cmd_lfc_set_autoneg,
6688 (void *)&cmd_lfc_set_portid,
6694 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6695 __attribute__((unused)) struct cmdline *cl,
6698 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6699 cmdline_parse_inst_t *cmd = data;
6700 struct rte_eth_fc_conf fc_conf;
6706 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6707 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6708 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6709 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6711 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6712 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6715 /* Partial command line, retrieve current configuration */
6717 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6719 printf("cannot get current flow ctrl parameters, return"
6720 "code = %d\n", ret);
6724 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6725 (fc_conf.mode == RTE_FC_FULL))
6727 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6728 (fc_conf.mode == RTE_FC_FULL))
6732 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6733 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6735 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6736 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6738 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6740 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6741 fc_conf.high_water = res->high_water;
6743 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6744 fc_conf.low_water = res->low_water;
6746 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6747 fc_conf.pause_time = res->pause_time;
6749 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6750 fc_conf.send_xon = res->send_xon;
6752 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6753 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6754 fc_conf.mac_ctrl_frame_fwd = 1;
6756 fc_conf.mac_ctrl_frame_fwd = 0;
6759 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6760 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6762 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6764 printf("bad flow contrl parameter, return code = %d \n", ret);
6767 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6768 struct cmd_priority_flow_ctrl_set_result {
6769 cmdline_fixed_string_t set;
6770 cmdline_fixed_string_t pfc_ctrl;
6771 cmdline_fixed_string_t rx;
6772 cmdline_fixed_string_t rx_pfc_mode;
6773 cmdline_fixed_string_t tx;
6774 cmdline_fixed_string_t tx_pfc_mode;
6775 uint32_t high_water;
6777 uint16_t pause_time;
6783 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6784 __attribute__((unused)) struct cmdline *cl,
6785 __attribute__((unused)) void *data)
6787 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6788 struct rte_eth_pfc_conf pfc_conf;
6789 int rx_fc_enable, tx_fc_enable;
6793 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6794 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6795 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6796 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6798 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6799 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6802 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6803 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6804 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6805 pfc_conf.fc.high_water = res->high_water;
6806 pfc_conf.fc.low_water = res->low_water;
6807 pfc_conf.fc.pause_time = res->pause_time;
6808 pfc_conf.priority = res->priority;
6810 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6812 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6815 cmdline_parse_token_string_t cmd_pfc_set_set =
6816 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6818 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6819 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6820 pfc_ctrl, "pfc_ctrl");
6821 cmdline_parse_token_string_t cmd_pfc_set_rx =
6822 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6824 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6825 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6826 rx_pfc_mode, "on#off");
6827 cmdline_parse_token_string_t cmd_pfc_set_tx =
6828 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6830 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6831 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6832 tx_pfc_mode, "on#off");
6833 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6834 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6835 high_water, UINT32);
6836 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6837 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6839 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6840 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6841 pause_time, UINT16);
6842 cmdline_parse_token_num_t cmd_pfc_set_priority =
6843 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6845 cmdline_parse_token_num_t cmd_pfc_set_portid =
6846 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6849 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6850 .f = cmd_priority_flow_ctrl_set_parsed,
6852 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6853 "<pause_time> <priority> <port_id>: "
6854 "Configure the Ethernet priority flow control",
6856 (void *)&cmd_pfc_set_set,
6857 (void *)&cmd_pfc_set_flow_ctrl,
6858 (void *)&cmd_pfc_set_rx,
6859 (void *)&cmd_pfc_set_rx_mode,
6860 (void *)&cmd_pfc_set_tx,
6861 (void *)&cmd_pfc_set_tx_mode,
6862 (void *)&cmd_pfc_set_high_water,
6863 (void *)&cmd_pfc_set_low_water,
6864 (void *)&cmd_pfc_set_pause_time,
6865 (void *)&cmd_pfc_set_priority,
6866 (void *)&cmd_pfc_set_portid,
6871 /* *** RESET CONFIGURATION *** */
6872 struct cmd_reset_result {
6873 cmdline_fixed_string_t reset;
6874 cmdline_fixed_string_t def;
6877 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6879 __attribute__((unused)) void *data)
6881 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6882 set_def_fwd_config();
6885 cmdline_parse_token_string_t cmd_reset_set =
6886 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6887 cmdline_parse_token_string_t cmd_reset_def =
6888 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6891 cmdline_parse_inst_t cmd_reset = {
6892 .f = cmd_reset_parsed,
6894 .help_str = "set default: Reset default forwarding configuration",
6896 (void *)&cmd_reset_set,
6897 (void *)&cmd_reset_def,
6902 /* *** START FORWARDING *** */
6903 struct cmd_start_result {
6904 cmdline_fixed_string_t start;
6907 cmdline_parse_token_string_t cmd_start_start =
6908 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6910 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6911 __attribute__((unused)) struct cmdline *cl,
6912 __attribute__((unused)) void *data)
6914 start_packet_forwarding(0);
6917 cmdline_parse_inst_t cmd_start = {
6918 .f = cmd_start_parsed,
6920 .help_str = "start: Start packet forwarding",
6922 (void *)&cmd_start_start,
6927 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6928 struct cmd_start_tx_first_result {
6929 cmdline_fixed_string_t start;
6930 cmdline_fixed_string_t tx_first;
6934 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6935 __attribute__((unused)) struct cmdline *cl,
6936 __attribute__((unused)) void *data)
6938 start_packet_forwarding(1);
6941 cmdline_parse_token_string_t cmd_start_tx_first_start =
6942 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6944 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6945 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6946 tx_first, "tx_first");
6948 cmdline_parse_inst_t cmd_start_tx_first = {
6949 .f = cmd_start_tx_first_parsed,
6951 .help_str = "start tx_first: Start packet forwarding, "
6952 "after sending 1 burst of packets",
6954 (void *)&cmd_start_tx_first_start,
6955 (void *)&cmd_start_tx_first_tx_first,
6960 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6961 struct cmd_start_tx_first_n_result {
6962 cmdline_fixed_string_t start;
6963 cmdline_fixed_string_t tx_first;
6968 cmd_start_tx_first_n_parsed(void *parsed_result,
6969 __attribute__((unused)) struct cmdline *cl,
6970 __attribute__((unused)) void *data)
6972 struct cmd_start_tx_first_n_result *res = parsed_result;
6974 start_packet_forwarding(res->tx_num);
6977 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6978 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6980 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6981 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6982 tx_first, "tx_first");
6983 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6984 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6987 cmdline_parse_inst_t cmd_start_tx_first_n = {
6988 .f = cmd_start_tx_first_n_parsed,
6990 .help_str = "start tx_first <num>: "
6991 "packet forwarding, after sending <num> bursts of packets",
6993 (void *)&cmd_start_tx_first_n_start,
6994 (void *)&cmd_start_tx_first_n_tx_first,
6995 (void *)&cmd_start_tx_first_n_tx_num,
7000 /* *** SET LINK UP *** */
7001 struct cmd_set_link_up_result {
7002 cmdline_fixed_string_t set;
7003 cmdline_fixed_string_t link_up;
7004 cmdline_fixed_string_t port;
7008 cmdline_parse_token_string_t cmd_set_link_up_set =
7009 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7010 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7011 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7013 cmdline_parse_token_string_t cmd_set_link_up_port =
7014 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7015 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7016 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7018 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
7019 __attribute__((unused)) struct cmdline *cl,
7020 __attribute__((unused)) void *data)
7022 struct cmd_set_link_up_result *res = parsed_result;
7023 dev_set_link_up(res->port_id);
7026 cmdline_parse_inst_t cmd_set_link_up = {
7027 .f = cmd_set_link_up_parsed,
7029 .help_str = "set link-up port <port id>",
7031 (void *)&cmd_set_link_up_set,
7032 (void *)&cmd_set_link_up_link_up,
7033 (void *)&cmd_set_link_up_port,
7034 (void *)&cmd_set_link_up_port_id,
7039 /* *** SET LINK DOWN *** */
7040 struct cmd_set_link_down_result {
7041 cmdline_fixed_string_t set;
7042 cmdline_fixed_string_t link_down;
7043 cmdline_fixed_string_t port;
7047 cmdline_parse_token_string_t cmd_set_link_down_set =
7048 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7049 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7050 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7052 cmdline_parse_token_string_t cmd_set_link_down_port =
7053 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7054 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7055 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7057 static void cmd_set_link_down_parsed(
7058 __attribute__((unused)) void *parsed_result,
7059 __attribute__((unused)) struct cmdline *cl,
7060 __attribute__((unused)) void *data)
7062 struct cmd_set_link_down_result *res = parsed_result;
7063 dev_set_link_down(res->port_id);
7066 cmdline_parse_inst_t cmd_set_link_down = {
7067 .f = cmd_set_link_down_parsed,
7069 .help_str = "set link-down port <port id>",
7071 (void *)&cmd_set_link_down_set,
7072 (void *)&cmd_set_link_down_link_down,
7073 (void *)&cmd_set_link_down_port,
7074 (void *)&cmd_set_link_down_port_id,
7079 /* *** SHOW CFG *** */
7080 struct cmd_showcfg_result {
7081 cmdline_fixed_string_t show;
7082 cmdline_fixed_string_t cfg;
7083 cmdline_fixed_string_t what;
7086 static void cmd_showcfg_parsed(void *parsed_result,
7087 __attribute__((unused)) struct cmdline *cl,
7088 __attribute__((unused)) void *data)
7090 struct cmd_showcfg_result *res = parsed_result;
7091 if (!strcmp(res->what, "rxtx"))
7092 rxtx_config_display();
7093 else if (!strcmp(res->what, "cores"))
7094 fwd_lcores_config_display();
7095 else if (!strcmp(res->what, "fwd"))
7096 pkt_fwd_config_display(&cur_fwd_config);
7097 else if (!strcmp(res->what, "txpkts"))
7098 show_tx_pkt_segments();
7101 cmdline_parse_token_string_t cmd_showcfg_show =
7102 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7103 cmdline_parse_token_string_t cmd_showcfg_port =
7104 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7105 cmdline_parse_token_string_t cmd_showcfg_what =
7106 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7107 "rxtx#cores#fwd#txpkts");
7109 cmdline_parse_inst_t cmd_showcfg = {
7110 .f = cmd_showcfg_parsed,
7112 .help_str = "show config rxtx|cores|fwd|txpkts",
7114 (void *)&cmd_showcfg_show,
7115 (void *)&cmd_showcfg_port,
7116 (void *)&cmd_showcfg_what,
7121 /* *** SHOW ALL PORT INFO *** */
7122 struct cmd_showportall_result {
7123 cmdline_fixed_string_t show;
7124 cmdline_fixed_string_t port;
7125 cmdline_fixed_string_t what;
7126 cmdline_fixed_string_t all;
7129 static void cmd_showportall_parsed(void *parsed_result,
7130 __attribute__((unused)) struct cmdline *cl,
7131 __attribute__((unused)) void *data)
7135 struct cmd_showportall_result *res = parsed_result;
7136 if (!strcmp(res->show, "clear")) {
7137 if (!strcmp(res->what, "stats"))
7138 RTE_ETH_FOREACH_DEV(i)
7140 else if (!strcmp(res->what, "xstats"))
7141 RTE_ETH_FOREACH_DEV(i)
7142 nic_xstats_clear(i);
7143 } else if (!strcmp(res->what, "info"))
7144 RTE_ETH_FOREACH_DEV(i)
7145 port_infos_display(i);
7146 else if (!strcmp(res->what, "stats"))
7147 RTE_ETH_FOREACH_DEV(i)
7148 nic_stats_display(i);
7149 else if (!strcmp(res->what, "xstats"))
7150 RTE_ETH_FOREACH_DEV(i)
7151 nic_xstats_display(i);
7152 else if (!strcmp(res->what, "fdir"))
7153 RTE_ETH_FOREACH_DEV(i)
7155 else if (!strcmp(res->what, "stat_qmap"))
7156 RTE_ETH_FOREACH_DEV(i)
7157 nic_stats_mapping_display(i);
7158 else if (!strcmp(res->what, "dcb_tc"))
7159 RTE_ETH_FOREACH_DEV(i)
7160 port_dcb_info_display(i);
7161 else if (!strcmp(res->what, "cap"))
7162 RTE_ETH_FOREACH_DEV(i)
7163 port_offload_cap_display(i);
7166 cmdline_parse_token_string_t cmd_showportall_show =
7167 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7169 cmdline_parse_token_string_t cmd_showportall_port =
7170 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7171 cmdline_parse_token_string_t cmd_showportall_what =
7172 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7173 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7174 cmdline_parse_token_string_t cmd_showportall_all =
7175 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7176 cmdline_parse_inst_t cmd_showportall = {
7177 .f = cmd_showportall_parsed,
7179 .help_str = "show|clear port "
7180 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7182 (void *)&cmd_showportall_show,
7183 (void *)&cmd_showportall_port,
7184 (void *)&cmd_showportall_what,
7185 (void *)&cmd_showportall_all,
7190 /* *** SHOW PORT INFO *** */
7191 struct cmd_showport_result {
7192 cmdline_fixed_string_t show;
7193 cmdline_fixed_string_t port;
7194 cmdline_fixed_string_t what;
7198 static void cmd_showport_parsed(void *parsed_result,
7199 __attribute__((unused)) struct cmdline *cl,
7200 __attribute__((unused)) void *data)
7202 struct cmd_showport_result *res = parsed_result;
7203 if (!strcmp(res->show, "clear")) {
7204 if (!strcmp(res->what, "stats"))
7205 nic_stats_clear(res->portnum);
7206 else if (!strcmp(res->what, "xstats"))
7207 nic_xstats_clear(res->portnum);
7208 } else if (!strcmp(res->what, "info"))
7209 port_infos_display(res->portnum);
7210 else if (!strcmp(res->what, "stats"))
7211 nic_stats_display(res->portnum);
7212 else if (!strcmp(res->what, "xstats"))
7213 nic_xstats_display(res->portnum);
7214 else if (!strcmp(res->what, "fdir"))
7215 fdir_get_infos(res->portnum);
7216 else if (!strcmp(res->what, "stat_qmap"))
7217 nic_stats_mapping_display(res->portnum);
7218 else if (!strcmp(res->what, "dcb_tc"))
7219 port_dcb_info_display(res->portnum);
7220 else if (!strcmp(res->what, "cap"))
7221 port_offload_cap_display(res->portnum);
7224 cmdline_parse_token_string_t cmd_showport_show =
7225 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7227 cmdline_parse_token_string_t cmd_showport_port =
7228 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7229 cmdline_parse_token_string_t cmd_showport_what =
7230 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7231 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7232 cmdline_parse_token_num_t cmd_showport_portnum =
7233 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7235 cmdline_parse_inst_t cmd_showport = {
7236 .f = cmd_showport_parsed,
7238 .help_str = "show|clear port "
7239 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7242 (void *)&cmd_showport_show,
7243 (void *)&cmd_showport_port,
7244 (void *)&cmd_showport_what,
7245 (void *)&cmd_showport_portnum,
7250 /* *** SHOW QUEUE INFO *** */
7251 struct cmd_showqueue_result {
7252 cmdline_fixed_string_t show;
7253 cmdline_fixed_string_t type;
7254 cmdline_fixed_string_t what;
7260 cmd_showqueue_parsed(void *parsed_result,
7261 __attribute__((unused)) struct cmdline *cl,
7262 __attribute__((unused)) void *data)
7264 struct cmd_showqueue_result *res = parsed_result;
7266 if (!strcmp(res->type, "rxq"))
7267 rx_queue_infos_display(res->portnum, res->queuenum);
7268 else if (!strcmp(res->type, "txq"))
7269 tx_queue_infos_display(res->portnum, res->queuenum);
7272 cmdline_parse_token_string_t cmd_showqueue_show =
7273 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7274 cmdline_parse_token_string_t cmd_showqueue_type =
7275 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7276 cmdline_parse_token_string_t cmd_showqueue_what =
7277 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7278 cmdline_parse_token_num_t cmd_showqueue_portnum =
7279 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7280 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7281 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7283 cmdline_parse_inst_t cmd_showqueue = {
7284 .f = cmd_showqueue_parsed,
7286 .help_str = "show rxq|txq info <port_id> <queue_id>",
7288 (void *)&cmd_showqueue_show,
7289 (void *)&cmd_showqueue_type,
7290 (void *)&cmd_showqueue_what,
7291 (void *)&cmd_showqueue_portnum,
7292 (void *)&cmd_showqueue_queuenum,
7297 /* *** READ PORT REGISTER *** */
7298 struct cmd_read_reg_result {
7299 cmdline_fixed_string_t read;
7300 cmdline_fixed_string_t reg;
7306 cmd_read_reg_parsed(void *parsed_result,
7307 __attribute__((unused)) struct cmdline *cl,
7308 __attribute__((unused)) void *data)
7310 struct cmd_read_reg_result *res = parsed_result;
7311 port_reg_display(res->port_id, res->reg_off);
7314 cmdline_parse_token_string_t cmd_read_reg_read =
7315 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7316 cmdline_parse_token_string_t cmd_read_reg_reg =
7317 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7318 cmdline_parse_token_num_t cmd_read_reg_port_id =
7319 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7320 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7321 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7323 cmdline_parse_inst_t cmd_read_reg = {
7324 .f = cmd_read_reg_parsed,
7326 .help_str = "read reg <port_id> <reg_off>",
7328 (void *)&cmd_read_reg_read,
7329 (void *)&cmd_read_reg_reg,
7330 (void *)&cmd_read_reg_port_id,
7331 (void *)&cmd_read_reg_reg_off,
7336 /* *** READ PORT REGISTER BIT FIELD *** */
7337 struct cmd_read_reg_bit_field_result {
7338 cmdline_fixed_string_t read;
7339 cmdline_fixed_string_t regfield;
7347 cmd_read_reg_bit_field_parsed(void *parsed_result,
7348 __attribute__((unused)) struct cmdline *cl,
7349 __attribute__((unused)) void *data)
7351 struct cmd_read_reg_bit_field_result *res = parsed_result;
7352 port_reg_bit_field_display(res->port_id, res->reg_off,
7353 res->bit1_pos, res->bit2_pos);
7356 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7357 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7359 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7360 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7361 regfield, "regfield");
7362 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7363 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7365 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7366 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7368 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7369 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7371 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7372 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7375 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7376 .f = cmd_read_reg_bit_field_parsed,
7378 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7379 "Read register bit field between bit_x and bit_y included",
7381 (void *)&cmd_read_reg_bit_field_read,
7382 (void *)&cmd_read_reg_bit_field_regfield,
7383 (void *)&cmd_read_reg_bit_field_port_id,
7384 (void *)&cmd_read_reg_bit_field_reg_off,
7385 (void *)&cmd_read_reg_bit_field_bit1_pos,
7386 (void *)&cmd_read_reg_bit_field_bit2_pos,
7391 /* *** READ PORT REGISTER BIT *** */
7392 struct cmd_read_reg_bit_result {
7393 cmdline_fixed_string_t read;
7394 cmdline_fixed_string_t regbit;
7401 cmd_read_reg_bit_parsed(void *parsed_result,
7402 __attribute__((unused)) struct cmdline *cl,
7403 __attribute__((unused)) void *data)
7405 struct cmd_read_reg_bit_result *res = parsed_result;
7406 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7409 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7410 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7411 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7412 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7414 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7415 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7416 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7417 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7418 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7419 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7421 cmdline_parse_inst_t cmd_read_reg_bit = {
7422 .f = cmd_read_reg_bit_parsed,
7424 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7426 (void *)&cmd_read_reg_bit_read,
7427 (void *)&cmd_read_reg_bit_regbit,
7428 (void *)&cmd_read_reg_bit_port_id,
7429 (void *)&cmd_read_reg_bit_reg_off,
7430 (void *)&cmd_read_reg_bit_bit_pos,
7435 /* *** WRITE PORT REGISTER *** */
7436 struct cmd_write_reg_result {
7437 cmdline_fixed_string_t write;
7438 cmdline_fixed_string_t reg;
7445 cmd_write_reg_parsed(void *parsed_result,
7446 __attribute__((unused)) struct cmdline *cl,
7447 __attribute__((unused)) void *data)
7449 struct cmd_write_reg_result *res = parsed_result;
7450 port_reg_set(res->port_id, res->reg_off, res->value);
7453 cmdline_parse_token_string_t cmd_write_reg_write =
7454 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7455 cmdline_parse_token_string_t cmd_write_reg_reg =
7456 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7457 cmdline_parse_token_num_t cmd_write_reg_port_id =
7458 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7459 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7460 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7461 cmdline_parse_token_num_t cmd_write_reg_value =
7462 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7464 cmdline_parse_inst_t cmd_write_reg = {
7465 .f = cmd_write_reg_parsed,
7467 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7469 (void *)&cmd_write_reg_write,
7470 (void *)&cmd_write_reg_reg,
7471 (void *)&cmd_write_reg_port_id,
7472 (void *)&cmd_write_reg_reg_off,
7473 (void *)&cmd_write_reg_value,
7478 /* *** WRITE PORT REGISTER BIT FIELD *** */
7479 struct cmd_write_reg_bit_field_result {
7480 cmdline_fixed_string_t write;
7481 cmdline_fixed_string_t regfield;
7490 cmd_write_reg_bit_field_parsed(void *parsed_result,
7491 __attribute__((unused)) struct cmdline *cl,
7492 __attribute__((unused)) void *data)
7494 struct cmd_write_reg_bit_field_result *res = parsed_result;
7495 port_reg_bit_field_set(res->port_id, res->reg_off,
7496 res->bit1_pos, res->bit2_pos, res->value);
7499 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7500 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7502 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7503 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7504 regfield, "regfield");
7505 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7506 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7508 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7509 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7511 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7512 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7514 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7515 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7517 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7518 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7521 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7522 .f = cmd_write_reg_bit_field_parsed,
7524 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7526 "Set register bit field between bit_x and bit_y included",
7528 (void *)&cmd_write_reg_bit_field_write,
7529 (void *)&cmd_write_reg_bit_field_regfield,
7530 (void *)&cmd_write_reg_bit_field_port_id,
7531 (void *)&cmd_write_reg_bit_field_reg_off,
7532 (void *)&cmd_write_reg_bit_field_bit1_pos,
7533 (void *)&cmd_write_reg_bit_field_bit2_pos,
7534 (void *)&cmd_write_reg_bit_field_value,
7539 /* *** WRITE PORT REGISTER BIT *** */
7540 struct cmd_write_reg_bit_result {
7541 cmdline_fixed_string_t write;
7542 cmdline_fixed_string_t regbit;
7550 cmd_write_reg_bit_parsed(void *parsed_result,
7551 __attribute__((unused)) struct cmdline *cl,
7552 __attribute__((unused)) void *data)
7554 struct cmd_write_reg_bit_result *res = parsed_result;
7555 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7558 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7559 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7561 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7562 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7564 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7565 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7566 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7567 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7568 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7569 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7570 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7571 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7573 cmdline_parse_inst_t cmd_write_reg_bit = {
7574 .f = cmd_write_reg_bit_parsed,
7576 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7579 (void *)&cmd_write_reg_bit_write,
7580 (void *)&cmd_write_reg_bit_regbit,
7581 (void *)&cmd_write_reg_bit_port_id,
7582 (void *)&cmd_write_reg_bit_reg_off,
7583 (void *)&cmd_write_reg_bit_bit_pos,
7584 (void *)&cmd_write_reg_bit_value,
7589 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7590 struct cmd_read_rxd_txd_result {
7591 cmdline_fixed_string_t read;
7592 cmdline_fixed_string_t rxd_txd;
7599 cmd_read_rxd_txd_parsed(void *parsed_result,
7600 __attribute__((unused)) struct cmdline *cl,
7601 __attribute__((unused)) void *data)
7603 struct cmd_read_rxd_txd_result *res = parsed_result;
7605 if (!strcmp(res->rxd_txd, "rxd"))
7606 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7607 else if (!strcmp(res->rxd_txd, "txd"))
7608 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7611 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7612 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7613 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7614 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7616 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7617 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7618 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7619 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7620 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7621 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7623 cmdline_parse_inst_t cmd_read_rxd_txd = {
7624 .f = cmd_read_rxd_txd_parsed,
7626 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7628 (void *)&cmd_read_rxd_txd_read,
7629 (void *)&cmd_read_rxd_txd_rxd_txd,
7630 (void *)&cmd_read_rxd_txd_port_id,
7631 (void *)&cmd_read_rxd_txd_queue_id,
7632 (void *)&cmd_read_rxd_txd_desc_id,
7638 struct cmd_quit_result {
7639 cmdline_fixed_string_t quit;
7642 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7644 __attribute__((unused)) void *data)
7650 cmdline_parse_token_string_t cmd_quit_quit =
7651 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7653 cmdline_parse_inst_t cmd_quit = {
7654 .f = cmd_quit_parsed,
7656 .help_str = "quit: Exit application",
7658 (void *)&cmd_quit_quit,
7663 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7664 struct cmd_mac_addr_result {
7665 cmdline_fixed_string_t mac_addr_cmd;
7666 cmdline_fixed_string_t what;
7668 struct ether_addr address;
7671 static void cmd_mac_addr_parsed(void *parsed_result,
7672 __attribute__((unused)) struct cmdline *cl,
7673 __attribute__((unused)) void *data)
7675 struct cmd_mac_addr_result *res = parsed_result;
7678 if (strcmp(res->what, "add") == 0)
7679 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7680 else if (strcmp(res->what, "set") == 0)
7681 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7684 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7686 /* check the return value and print it if is < 0 */
7688 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7692 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7693 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7695 cmdline_parse_token_string_t cmd_mac_addr_what =
7696 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7698 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7699 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7701 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7702 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7704 cmdline_parse_inst_t cmd_mac_addr = {
7705 .f = cmd_mac_addr_parsed,
7707 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7708 "Add/Remove/Set MAC address on port_id",
7710 (void *)&cmd_mac_addr_cmd,
7711 (void *)&cmd_mac_addr_what,
7712 (void *)&cmd_mac_addr_portnum,
7713 (void *)&cmd_mac_addr_addr,
7718 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7719 struct cmd_eth_peer_result {
7720 cmdline_fixed_string_t set;
7721 cmdline_fixed_string_t eth_peer;
7723 cmdline_fixed_string_t peer_addr;
7726 static void cmd_set_eth_peer_parsed(void *parsed_result,
7727 __attribute__((unused)) struct cmdline *cl,
7728 __attribute__((unused)) void *data)
7730 struct cmd_eth_peer_result *res = parsed_result;
7732 if (test_done == 0) {
7733 printf("Please stop forwarding first\n");
7736 if (!strcmp(res->eth_peer, "eth-peer")) {
7737 set_fwd_eth_peer(res->port_id, res->peer_addr);
7741 cmdline_parse_token_string_t cmd_eth_peer_set =
7742 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7743 cmdline_parse_token_string_t cmd_eth_peer =
7744 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7745 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7746 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7747 cmdline_parse_token_string_t cmd_eth_peer_addr =
7748 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7750 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7751 .f = cmd_set_eth_peer_parsed,
7753 .help_str = "set eth-peer <port_id> <peer_mac>",
7755 (void *)&cmd_eth_peer_set,
7756 (void *)&cmd_eth_peer,
7757 (void *)&cmd_eth_peer_port_id,
7758 (void *)&cmd_eth_peer_addr,
7763 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7764 struct cmd_set_qmap_result {
7765 cmdline_fixed_string_t set;
7766 cmdline_fixed_string_t qmap;
7767 cmdline_fixed_string_t what;
7774 cmd_set_qmap_parsed(void *parsed_result,
7775 __attribute__((unused)) struct cmdline *cl,
7776 __attribute__((unused)) void *data)
7778 struct cmd_set_qmap_result *res = parsed_result;
7779 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7781 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7784 cmdline_parse_token_string_t cmd_setqmap_set =
7785 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7787 cmdline_parse_token_string_t cmd_setqmap_qmap =
7788 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7790 cmdline_parse_token_string_t cmd_setqmap_what =
7791 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7793 cmdline_parse_token_num_t cmd_setqmap_portid =
7794 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7796 cmdline_parse_token_num_t cmd_setqmap_queueid =
7797 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7799 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7800 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7803 cmdline_parse_inst_t cmd_set_qmap = {
7804 .f = cmd_set_qmap_parsed,
7806 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7807 "Set statistics mapping value on tx|rx queue_id of port_id",
7809 (void *)&cmd_setqmap_set,
7810 (void *)&cmd_setqmap_qmap,
7811 (void *)&cmd_setqmap_what,
7812 (void *)&cmd_setqmap_portid,
7813 (void *)&cmd_setqmap_queueid,
7814 (void *)&cmd_setqmap_mapvalue,
7819 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7820 struct cmd_set_xstats_hide_zero_result {
7821 cmdline_fixed_string_t keyword;
7822 cmdline_fixed_string_t name;
7823 cmdline_fixed_string_t on_off;
7827 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7828 __attribute__((unused)) struct cmdline *cl,
7829 __attribute__((unused)) void *data)
7831 struct cmd_set_xstats_hide_zero_result *res;
7832 uint16_t on_off = 0;
7834 res = parsed_result;
7835 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7836 set_xstats_hide_zero(on_off);
7839 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7840 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7842 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7843 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7844 name, "xstats-hide-zero");
7845 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7846 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7849 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7850 .f = cmd_set_xstats_hide_zero_parsed,
7852 .help_str = "set xstats-hide-zero on|off",
7854 (void *)&cmd_set_xstats_hide_zero_keyword,
7855 (void *)&cmd_set_xstats_hide_zero_name,
7856 (void *)&cmd_set_xstats_hide_zero_on_off,
7861 /* *** CONFIGURE UNICAST HASH TABLE *** */
7862 struct cmd_set_uc_hash_table {
7863 cmdline_fixed_string_t set;
7864 cmdline_fixed_string_t port;
7866 cmdline_fixed_string_t what;
7867 struct ether_addr address;
7868 cmdline_fixed_string_t mode;
7872 cmd_set_uc_hash_parsed(void *parsed_result,
7873 __attribute__((unused)) struct cmdline *cl,
7874 __attribute__((unused)) void *data)
7877 struct cmd_set_uc_hash_table *res = parsed_result;
7879 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7881 if (strcmp(res->what, "uta") == 0)
7882 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7883 &res->address,(uint8_t)is_on);
7885 printf("bad unicast hash table parameter, return code = %d \n", ret);
7889 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7890 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7892 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7893 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7895 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7896 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7898 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7899 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7901 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7902 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7904 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7905 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7908 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7909 .f = cmd_set_uc_hash_parsed,
7911 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7913 (void *)&cmd_set_uc_hash_set,
7914 (void *)&cmd_set_uc_hash_port,
7915 (void *)&cmd_set_uc_hash_portid,
7916 (void *)&cmd_set_uc_hash_what,
7917 (void *)&cmd_set_uc_hash_mac,
7918 (void *)&cmd_set_uc_hash_mode,
7923 struct cmd_set_uc_all_hash_table {
7924 cmdline_fixed_string_t set;
7925 cmdline_fixed_string_t port;
7927 cmdline_fixed_string_t what;
7928 cmdline_fixed_string_t value;
7929 cmdline_fixed_string_t mode;
7933 cmd_set_uc_all_hash_parsed(void *parsed_result,
7934 __attribute__((unused)) struct cmdline *cl,
7935 __attribute__((unused)) void *data)
7938 struct cmd_set_uc_all_hash_table *res = parsed_result;
7940 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7942 if ((strcmp(res->what, "uta") == 0) &&
7943 (strcmp(res->value, "all") == 0))
7944 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7946 printf("bad unicast hash table parameter,"
7947 "return code = %d \n", ret);
7950 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7951 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7953 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7954 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7956 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7957 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7959 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7960 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7962 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7963 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7965 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7966 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7969 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7970 .f = cmd_set_uc_all_hash_parsed,
7972 .help_str = "set port <port_id> uta all on|off",
7974 (void *)&cmd_set_uc_all_hash_set,
7975 (void *)&cmd_set_uc_all_hash_port,
7976 (void *)&cmd_set_uc_all_hash_portid,
7977 (void *)&cmd_set_uc_all_hash_what,
7978 (void *)&cmd_set_uc_all_hash_value,
7979 (void *)&cmd_set_uc_all_hash_mode,
7984 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7985 struct cmd_set_vf_macvlan_filter {
7986 cmdline_fixed_string_t set;
7987 cmdline_fixed_string_t port;
7989 cmdline_fixed_string_t vf;
7991 struct ether_addr address;
7992 cmdline_fixed_string_t filter_type;
7993 cmdline_fixed_string_t mode;
7997 cmd_set_vf_macvlan_parsed(void *parsed_result,
7998 __attribute__((unused)) struct cmdline *cl,
7999 __attribute__((unused)) void *data)
8002 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8003 struct rte_eth_mac_filter filter;
8005 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8007 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
8009 /* set VF MAC filter */
8013 filter.dst_id = res->vf_id;
8015 if (!strcmp(res->filter_type, "exact-mac"))
8016 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8017 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8018 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8019 else if (!strcmp(res->filter_type, "hashmac"))
8020 filter.filter_type = RTE_MAC_HASH_MATCH;
8021 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8022 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8024 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8027 ret = rte_eth_dev_filter_ctrl(res->port_id,
8028 RTE_ETH_FILTER_MACVLAN,
8032 ret = rte_eth_dev_filter_ctrl(res->port_id,
8033 RTE_ETH_FILTER_MACVLAN,
8034 RTE_ETH_FILTER_DELETE,
8038 printf("bad set MAC hash parameter, return code = %d\n", ret);
8042 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8043 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8045 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8046 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8048 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8049 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8051 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8052 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8054 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8055 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8057 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8058 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8060 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8061 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8062 filter_type, "exact-mac#exact-mac-vlan"
8063 "#hashmac#hashmac-vlan");
8064 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8065 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8068 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8069 .f = cmd_set_vf_macvlan_parsed,
8071 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8072 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8073 "Exact match rule: exact match of MAC or MAC and VLAN; "
8074 "hash match rule: hash match of MAC and exact match of VLAN",
8076 (void *)&cmd_set_vf_macvlan_set,
8077 (void *)&cmd_set_vf_macvlan_port,
8078 (void *)&cmd_set_vf_macvlan_portid,
8079 (void *)&cmd_set_vf_macvlan_vf,
8080 (void *)&cmd_set_vf_macvlan_vf_id,
8081 (void *)&cmd_set_vf_macvlan_mac,
8082 (void *)&cmd_set_vf_macvlan_filter_type,
8083 (void *)&cmd_set_vf_macvlan_mode,
8088 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8089 struct cmd_set_vf_traffic {
8090 cmdline_fixed_string_t set;
8091 cmdline_fixed_string_t port;
8093 cmdline_fixed_string_t vf;
8095 cmdline_fixed_string_t what;
8096 cmdline_fixed_string_t mode;
8100 cmd_set_vf_traffic_parsed(void *parsed_result,
8101 __attribute__((unused)) struct cmdline *cl,
8102 __attribute__((unused)) void *data)
8104 struct cmd_set_vf_traffic *res = parsed_result;
8105 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8106 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8108 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8111 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8112 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8114 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8115 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8117 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8118 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8120 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8121 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8123 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8124 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8126 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8127 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8129 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8130 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8133 cmdline_parse_inst_t cmd_set_vf_traffic = {
8134 .f = cmd_set_vf_traffic_parsed,
8136 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8138 (void *)&cmd_setvf_traffic_set,
8139 (void *)&cmd_setvf_traffic_port,
8140 (void *)&cmd_setvf_traffic_portid,
8141 (void *)&cmd_setvf_traffic_vf,
8142 (void *)&cmd_setvf_traffic_vfid,
8143 (void *)&cmd_setvf_traffic_what,
8144 (void *)&cmd_setvf_traffic_mode,
8149 /* *** CONFIGURE VF RECEIVE MODE *** */
8150 struct cmd_set_vf_rxmode {
8151 cmdline_fixed_string_t set;
8152 cmdline_fixed_string_t port;
8154 cmdline_fixed_string_t vf;
8156 cmdline_fixed_string_t what;
8157 cmdline_fixed_string_t mode;
8158 cmdline_fixed_string_t on;
8162 cmd_set_vf_rxmode_parsed(void *parsed_result,
8163 __attribute__((unused)) struct cmdline *cl,
8164 __attribute__((unused)) void *data)
8167 uint16_t rx_mode = 0;
8168 struct cmd_set_vf_rxmode *res = parsed_result;
8170 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8171 if (!strcmp(res->what,"rxmode")) {
8172 if (!strcmp(res->mode, "AUPE"))
8173 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
8174 else if (!strcmp(res->mode, "ROPE"))
8175 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
8176 else if (!strcmp(res->mode, "BAM"))
8177 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
8178 else if (!strncmp(res->mode, "MPE",3))
8179 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
8182 RTE_SET_USED(is_on);
8184 #ifdef RTE_LIBRTE_IXGBE_PMD
8185 if (ret == -ENOTSUP)
8186 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8187 rx_mode, (uint8_t)is_on);
8189 #ifdef RTE_LIBRTE_BNXT_PMD
8190 if (ret == -ENOTSUP)
8191 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8192 rx_mode, (uint8_t)is_on);
8195 printf("bad VF receive mode parameter, return code = %d \n",
8199 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8200 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8202 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8203 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8205 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8206 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8208 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8209 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8211 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8212 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8214 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8215 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8217 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8218 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8219 mode, "AUPE#ROPE#BAM#MPE");
8220 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8221 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8224 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8225 .f = cmd_set_vf_rxmode_parsed,
8227 .help_str = "set port <port_id> vf <vf_id> rxmode "
8228 "AUPE|ROPE|BAM|MPE on|off",
8230 (void *)&cmd_set_vf_rxmode_set,
8231 (void *)&cmd_set_vf_rxmode_port,
8232 (void *)&cmd_set_vf_rxmode_portid,
8233 (void *)&cmd_set_vf_rxmode_vf,
8234 (void *)&cmd_set_vf_rxmode_vfid,
8235 (void *)&cmd_set_vf_rxmode_what,
8236 (void *)&cmd_set_vf_rxmode_mode,
8237 (void *)&cmd_set_vf_rxmode_on,
8242 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8243 struct cmd_vf_mac_addr_result {
8244 cmdline_fixed_string_t mac_addr_cmd;
8245 cmdline_fixed_string_t what;
8246 cmdline_fixed_string_t port;
8248 cmdline_fixed_string_t vf;
8250 struct ether_addr address;
8253 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8254 __attribute__((unused)) struct cmdline *cl,
8255 __attribute__((unused)) void *data)
8257 struct cmd_vf_mac_addr_result *res = parsed_result;
8260 if (strcmp(res->what, "add") != 0)
8263 #ifdef RTE_LIBRTE_I40E_PMD
8264 if (ret == -ENOTSUP)
8265 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8268 #ifdef RTE_LIBRTE_BNXT_PMD
8269 if (ret == -ENOTSUP)
8270 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8275 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8279 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8280 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8281 mac_addr_cmd,"mac_addr");
8282 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8283 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8285 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8286 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8288 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8289 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8291 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8292 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8294 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8295 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8297 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8298 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8301 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8302 .f = cmd_vf_mac_addr_parsed,
8304 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8305 "Add MAC address filtering for a VF on port_id",
8307 (void *)&cmd_vf_mac_addr_cmd,
8308 (void *)&cmd_vf_mac_addr_what,
8309 (void *)&cmd_vf_mac_addr_port,
8310 (void *)&cmd_vf_mac_addr_portnum,
8311 (void *)&cmd_vf_mac_addr_vf,
8312 (void *)&cmd_vf_mac_addr_vfnum,
8313 (void *)&cmd_vf_mac_addr_addr,
8318 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8319 struct cmd_vf_rx_vlan_filter {
8320 cmdline_fixed_string_t rx_vlan;
8321 cmdline_fixed_string_t what;
8323 cmdline_fixed_string_t port;
8325 cmdline_fixed_string_t vf;
8330 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8331 __attribute__((unused)) struct cmdline *cl,
8332 __attribute__((unused)) void *data)
8334 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8337 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8339 #ifdef RTE_LIBRTE_IXGBE_PMD
8340 if (ret == -ENOTSUP)
8341 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8342 res->vlan_id, res->vf_mask, is_add);
8344 #ifdef RTE_LIBRTE_I40E_PMD
8345 if (ret == -ENOTSUP)
8346 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8347 res->vlan_id, res->vf_mask, is_add);
8349 #ifdef RTE_LIBRTE_BNXT_PMD
8350 if (ret == -ENOTSUP)
8351 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8352 res->vlan_id, res->vf_mask, is_add);
8359 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8360 res->vlan_id, res->vf_mask);
8363 printf("invalid port_id %d\n", res->port_id);
8366 printf("function not implemented or supported\n");
8369 printf("programming error: (%s)\n", strerror(-ret));
8373 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8374 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8375 rx_vlan, "rx_vlan");
8376 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8377 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8379 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8380 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8382 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8383 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8385 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8386 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8388 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8389 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8391 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8392 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8395 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8396 .f = cmd_vf_rx_vlan_filter_parsed,
8398 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8399 "(vf_mask = hexadecimal VF mask)",
8401 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8402 (void *)&cmd_vf_rx_vlan_filter_what,
8403 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8404 (void *)&cmd_vf_rx_vlan_filter_port,
8405 (void *)&cmd_vf_rx_vlan_filter_portid,
8406 (void *)&cmd_vf_rx_vlan_filter_vf,
8407 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8412 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8413 struct cmd_queue_rate_limit_result {
8414 cmdline_fixed_string_t set;
8415 cmdline_fixed_string_t port;
8417 cmdline_fixed_string_t queue;
8419 cmdline_fixed_string_t rate;
8423 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8424 __attribute__((unused)) struct cmdline *cl,
8425 __attribute__((unused)) void *data)
8427 struct cmd_queue_rate_limit_result *res = parsed_result;
8430 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8431 && (strcmp(res->queue, "queue") == 0)
8432 && (strcmp(res->rate, "rate") == 0))
8433 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8436 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8440 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8441 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8443 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8444 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8446 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8447 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8449 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8450 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8452 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8453 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8455 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8456 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8458 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8459 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8462 cmdline_parse_inst_t cmd_queue_rate_limit = {
8463 .f = cmd_queue_rate_limit_parsed,
8465 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8466 "Set rate limit for a queue on port_id",
8468 (void *)&cmd_queue_rate_limit_set,
8469 (void *)&cmd_queue_rate_limit_port,
8470 (void *)&cmd_queue_rate_limit_portnum,
8471 (void *)&cmd_queue_rate_limit_queue,
8472 (void *)&cmd_queue_rate_limit_queuenum,
8473 (void *)&cmd_queue_rate_limit_rate,
8474 (void *)&cmd_queue_rate_limit_ratenum,
8479 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8480 struct cmd_vf_rate_limit_result {
8481 cmdline_fixed_string_t set;
8482 cmdline_fixed_string_t port;
8484 cmdline_fixed_string_t vf;
8486 cmdline_fixed_string_t rate;
8488 cmdline_fixed_string_t q_msk;
8492 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8493 __attribute__((unused)) struct cmdline *cl,
8494 __attribute__((unused)) void *data)
8496 struct cmd_vf_rate_limit_result *res = parsed_result;
8499 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8500 && (strcmp(res->vf, "vf") == 0)
8501 && (strcmp(res->rate, "rate") == 0)
8502 && (strcmp(res->q_msk, "queue_mask") == 0))
8503 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8504 res->rate_num, res->q_msk_val);
8506 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8510 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8511 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8513 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8514 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8516 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8517 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8519 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8520 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8522 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8523 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8525 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8526 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8528 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8529 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8531 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8532 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8533 q_msk, "queue_mask");
8534 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8535 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8538 cmdline_parse_inst_t cmd_vf_rate_limit = {
8539 .f = cmd_vf_rate_limit_parsed,
8541 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8542 "queue_mask <queue_mask_value>: "
8543 "Set rate limit for queues of VF on port_id",
8545 (void *)&cmd_vf_rate_limit_set,
8546 (void *)&cmd_vf_rate_limit_port,
8547 (void *)&cmd_vf_rate_limit_portnum,
8548 (void *)&cmd_vf_rate_limit_vf,
8549 (void *)&cmd_vf_rate_limit_vfnum,
8550 (void *)&cmd_vf_rate_limit_rate,
8551 (void *)&cmd_vf_rate_limit_ratenum,
8552 (void *)&cmd_vf_rate_limit_q_msk,
8553 (void *)&cmd_vf_rate_limit_q_msk_val,
8558 /* *** ADD TUNNEL FILTER OF A PORT *** */
8559 struct cmd_tunnel_filter_result {
8560 cmdline_fixed_string_t cmd;
8561 cmdline_fixed_string_t what;
8563 struct ether_addr outer_mac;
8564 struct ether_addr inner_mac;
8565 cmdline_ipaddr_t ip_value;
8566 uint16_t inner_vlan;
8567 cmdline_fixed_string_t tunnel_type;
8568 cmdline_fixed_string_t filter_type;
8574 cmd_tunnel_filter_parsed(void *parsed_result,
8575 __attribute__((unused)) struct cmdline *cl,
8576 __attribute__((unused)) void *data)
8578 struct cmd_tunnel_filter_result *res = parsed_result;
8579 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8582 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8584 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8585 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8586 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8588 if (res->ip_value.family == AF_INET) {
8589 tunnel_filter_conf.ip_addr.ipv4_addr =
8590 res->ip_value.addr.ipv4.s_addr;
8591 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8593 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8594 &(res->ip_value.addr.ipv6),
8595 sizeof(struct in6_addr));
8596 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8599 if (!strcmp(res->filter_type, "imac-ivlan"))
8600 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8601 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8602 tunnel_filter_conf.filter_type =
8603 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8604 else if (!strcmp(res->filter_type, "imac-tenid"))
8605 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8606 else if (!strcmp(res->filter_type, "imac"))
8607 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8608 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8609 tunnel_filter_conf.filter_type =
8610 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8611 else if (!strcmp(res->filter_type, "oip"))
8612 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8613 else if (!strcmp(res->filter_type, "iip"))
8614 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8616 printf("The filter type is not supported");
8620 if (!strcmp(res->tunnel_type, "vxlan"))
8621 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8622 else if (!strcmp(res->tunnel_type, "nvgre"))
8623 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8624 else if (!strcmp(res->tunnel_type, "ipingre"))
8625 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8627 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8631 tunnel_filter_conf.tenant_id = res->tenant_id;
8632 tunnel_filter_conf.queue_id = res->queue_num;
8633 if (!strcmp(res->what, "add"))
8634 ret = rte_eth_dev_filter_ctrl(res->port_id,
8635 RTE_ETH_FILTER_TUNNEL,
8637 &tunnel_filter_conf);
8639 ret = rte_eth_dev_filter_ctrl(res->port_id,
8640 RTE_ETH_FILTER_TUNNEL,
8641 RTE_ETH_FILTER_DELETE,
8642 &tunnel_filter_conf);
8644 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8648 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8649 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8650 cmd, "tunnel_filter");
8651 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8652 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8654 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8655 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8657 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8658 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8660 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8661 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8663 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8664 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8665 inner_vlan, UINT16);
8666 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8667 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8669 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8670 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8671 tunnel_type, "vxlan#nvgre#ipingre");
8673 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8674 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8675 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8676 "imac#omac-imac-tenid");
8677 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8678 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8680 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8681 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8684 cmdline_parse_inst_t cmd_tunnel_filter = {
8685 .f = cmd_tunnel_filter_parsed,
8687 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8688 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8689 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8690 "<queue_id>: Add/Rm tunnel filter of a port",
8692 (void *)&cmd_tunnel_filter_cmd,
8693 (void *)&cmd_tunnel_filter_what,
8694 (void *)&cmd_tunnel_filter_port_id,
8695 (void *)&cmd_tunnel_filter_outer_mac,
8696 (void *)&cmd_tunnel_filter_inner_mac,
8697 (void *)&cmd_tunnel_filter_ip_value,
8698 (void *)&cmd_tunnel_filter_innner_vlan,
8699 (void *)&cmd_tunnel_filter_tunnel_type,
8700 (void *)&cmd_tunnel_filter_filter_type,
8701 (void *)&cmd_tunnel_filter_tenant_id,
8702 (void *)&cmd_tunnel_filter_queue_num,
8707 /* *** CONFIGURE TUNNEL UDP PORT *** */
8708 struct cmd_tunnel_udp_config {
8709 cmdline_fixed_string_t cmd;
8710 cmdline_fixed_string_t what;
8716 cmd_tunnel_udp_config_parsed(void *parsed_result,
8717 __attribute__((unused)) struct cmdline *cl,
8718 __attribute__((unused)) void *data)
8720 struct cmd_tunnel_udp_config *res = parsed_result;
8721 struct rte_eth_udp_tunnel tunnel_udp;
8724 tunnel_udp.udp_port = res->udp_port;
8726 if (!strcmp(res->cmd, "rx_vxlan_port"))
8727 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8729 if (!strcmp(res->what, "add"))
8730 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8733 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8737 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8740 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8741 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8742 cmd, "rx_vxlan_port");
8743 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8744 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8746 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8747 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8749 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8750 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8753 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8754 .f = cmd_tunnel_udp_config_parsed,
8756 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8757 "Add/Remove a tunneling UDP port filter",
8759 (void *)&cmd_tunnel_udp_config_cmd,
8760 (void *)&cmd_tunnel_udp_config_what,
8761 (void *)&cmd_tunnel_udp_config_udp_port,
8762 (void *)&cmd_tunnel_udp_config_port_id,
8767 struct cmd_config_tunnel_udp_port {
8768 cmdline_fixed_string_t port;
8769 cmdline_fixed_string_t config;
8771 cmdline_fixed_string_t udp_tunnel_port;
8772 cmdline_fixed_string_t action;
8773 cmdline_fixed_string_t tunnel_type;
8778 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8779 __attribute__((unused)) struct cmdline *cl,
8780 __attribute__((unused)) void *data)
8782 struct cmd_config_tunnel_udp_port *res = parsed_result;
8783 struct rte_eth_udp_tunnel tunnel_udp;
8786 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8789 tunnel_udp.udp_port = res->udp_port;
8791 if (!strcmp(res->tunnel_type, "vxlan")) {
8792 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8793 } else if (!strcmp(res->tunnel_type, "geneve")) {
8794 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
8796 printf("Invalid tunnel type\n");
8800 if (!strcmp(res->action, "add"))
8801 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8804 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8808 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
8811 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
8812 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
8814 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
8815 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
8817 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
8818 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
8820 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
8821 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
8824 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
8825 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
8827 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
8828 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
8830 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
8831 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
8834 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
8835 .f = cmd_cfg_tunnel_udp_port_parsed,
8837 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve <udp_port>",
8839 (void *)&cmd_config_tunnel_udp_port_port,
8840 (void *)&cmd_config_tunnel_udp_port_config,
8841 (void *)&cmd_config_tunnel_udp_port_port_id,
8842 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
8843 (void *)&cmd_config_tunnel_udp_port_action,
8844 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
8845 (void *)&cmd_config_tunnel_udp_port_value,
8850 /* *** GLOBAL CONFIG *** */
8851 struct cmd_global_config_result {
8852 cmdline_fixed_string_t cmd;
8854 cmdline_fixed_string_t cfg_type;
8859 cmd_global_config_parsed(void *parsed_result,
8860 __attribute__((unused)) struct cmdline *cl,
8861 __attribute__((unused)) void *data)
8863 struct cmd_global_config_result *res = parsed_result;
8864 struct rte_eth_global_cfg conf;
8867 memset(&conf, 0, sizeof(conf));
8868 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8869 conf.cfg.gre_key_len = res->len;
8870 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8871 RTE_ETH_FILTER_SET, &conf);
8873 printf("Global config error\n");
8876 cmdline_parse_token_string_t cmd_global_config_cmd =
8877 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8879 cmdline_parse_token_num_t cmd_global_config_port_id =
8880 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8882 cmdline_parse_token_string_t cmd_global_config_type =
8883 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8884 cfg_type, "gre-key-len");
8885 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8886 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8889 cmdline_parse_inst_t cmd_global_config = {
8890 .f = cmd_global_config_parsed,
8891 .data = (void *)NULL,
8892 .help_str = "global_config <port_id> gre-key-len <key_len>",
8894 (void *)&cmd_global_config_cmd,
8895 (void *)&cmd_global_config_port_id,
8896 (void *)&cmd_global_config_type,
8897 (void *)&cmd_global_config_gre_key_len,
8902 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8903 struct cmd_set_mirror_mask_result {
8904 cmdline_fixed_string_t set;
8905 cmdline_fixed_string_t port;
8907 cmdline_fixed_string_t mirror;
8909 cmdline_fixed_string_t what;
8910 cmdline_fixed_string_t value;
8911 cmdline_fixed_string_t dstpool;
8913 cmdline_fixed_string_t on;
8916 cmdline_parse_token_string_t cmd_mirror_mask_set =
8917 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8919 cmdline_parse_token_string_t cmd_mirror_mask_port =
8920 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8922 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8923 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8925 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8926 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8927 mirror, "mirror-rule");
8928 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8929 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8931 cmdline_parse_token_string_t cmd_mirror_mask_what =
8932 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8933 what, "pool-mirror-up#pool-mirror-down"
8935 cmdline_parse_token_string_t cmd_mirror_mask_value =
8936 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8938 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8939 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8940 dstpool, "dst-pool");
8941 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8942 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8944 cmdline_parse_token_string_t cmd_mirror_mask_on =
8945 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8949 cmd_set_mirror_mask_parsed(void *parsed_result,
8950 __attribute__((unused)) struct cmdline *cl,
8951 __attribute__((unused)) void *data)
8954 struct cmd_set_mirror_mask_result *res = parsed_result;
8955 struct rte_eth_mirror_conf mr_conf;
8957 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8959 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8961 mr_conf.dst_pool = res->dstpool_id;
8963 if (!strcmp(res->what, "pool-mirror-up")) {
8964 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8965 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8966 } else if (!strcmp(res->what, "pool-mirror-down")) {
8967 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8968 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8969 } else if (!strcmp(res->what, "vlan-mirror")) {
8970 mr_conf.rule_type = ETH_MIRROR_VLAN;
8971 nb_item = parse_item_list(res->value, "vlan",
8972 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8976 for (i = 0; i < nb_item; i++) {
8977 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8978 printf("Invalid vlan_id: must be < 4096\n");
8982 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8983 mr_conf.vlan.vlan_mask |= 1ULL << i;
8987 if (!strcmp(res->on, "on"))
8988 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8991 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8994 printf("mirror rule add error: (%s)\n", strerror(-ret));
8997 cmdline_parse_inst_t cmd_set_mirror_mask = {
8998 .f = cmd_set_mirror_mask_parsed,
9000 .help_str = "set port <port_id> mirror-rule <rule_id> "
9001 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9002 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9004 (void *)&cmd_mirror_mask_set,
9005 (void *)&cmd_mirror_mask_port,
9006 (void *)&cmd_mirror_mask_portid,
9007 (void *)&cmd_mirror_mask_mirror,
9008 (void *)&cmd_mirror_mask_ruleid,
9009 (void *)&cmd_mirror_mask_what,
9010 (void *)&cmd_mirror_mask_value,
9011 (void *)&cmd_mirror_mask_dstpool,
9012 (void *)&cmd_mirror_mask_poolid,
9013 (void *)&cmd_mirror_mask_on,
9018 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9019 struct cmd_set_mirror_link_result {
9020 cmdline_fixed_string_t set;
9021 cmdline_fixed_string_t port;
9023 cmdline_fixed_string_t mirror;
9025 cmdline_fixed_string_t what;
9026 cmdline_fixed_string_t dstpool;
9028 cmdline_fixed_string_t on;
9031 cmdline_parse_token_string_t cmd_mirror_link_set =
9032 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9034 cmdline_parse_token_string_t cmd_mirror_link_port =
9035 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9037 cmdline_parse_token_num_t cmd_mirror_link_portid =
9038 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9040 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9041 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9042 mirror, "mirror-rule");
9043 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9044 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9046 cmdline_parse_token_string_t cmd_mirror_link_what =
9047 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9048 what, "uplink-mirror#downlink-mirror");
9049 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9050 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9051 dstpool, "dst-pool");
9052 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9053 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9055 cmdline_parse_token_string_t cmd_mirror_link_on =
9056 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9060 cmd_set_mirror_link_parsed(void *parsed_result,
9061 __attribute__((unused)) struct cmdline *cl,
9062 __attribute__((unused)) void *data)
9065 struct cmd_set_mirror_link_result *res = parsed_result;
9066 struct rte_eth_mirror_conf mr_conf;
9068 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9069 if (!strcmp(res->what, "uplink-mirror"))
9070 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9072 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9074 mr_conf.dst_pool = res->dstpool_id;
9076 if (!strcmp(res->on, "on"))
9077 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9080 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9083 /* check the return value and print it if is < 0 */
9085 printf("mirror rule add error: (%s)\n", strerror(-ret));
9089 cmdline_parse_inst_t cmd_set_mirror_link = {
9090 .f = cmd_set_mirror_link_parsed,
9092 .help_str = "set port <port_id> mirror-rule <rule_id> "
9093 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9095 (void *)&cmd_mirror_link_set,
9096 (void *)&cmd_mirror_link_port,
9097 (void *)&cmd_mirror_link_portid,
9098 (void *)&cmd_mirror_link_mirror,
9099 (void *)&cmd_mirror_link_ruleid,
9100 (void *)&cmd_mirror_link_what,
9101 (void *)&cmd_mirror_link_dstpool,
9102 (void *)&cmd_mirror_link_poolid,
9103 (void *)&cmd_mirror_link_on,
9108 /* *** RESET VM MIRROR RULE *** */
9109 struct cmd_rm_mirror_rule_result {
9110 cmdline_fixed_string_t reset;
9111 cmdline_fixed_string_t port;
9113 cmdline_fixed_string_t mirror;
9117 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9118 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9120 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9121 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9123 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9124 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9126 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9127 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9128 mirror, "mirror-rule");
9129 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9130 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9134 cmd_reset_mirror_rule_parsed(void *parsed_result,
9135 __attribute__((unused)) struct cmdline *cl,
9136 __attribute__((unused)) void *data)
9139 struct cmd_set_mirror_link_result *res = parsed_result;
9141 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9143 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9146 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9147 .f = cmd_reset_mirror_rule_parsed,
9149 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9151 (void *)&cmd_rm_mirror_rule_reset,
9152 (void *)&cmd_rm_mirror_rule_port,
9153 (void *)&cmd_rm_mirror_rule_portid,
9154 (void *)&cmd_rm_mirror_rule_mirror,
9155 (void *)&cmd_rm_mirror_rule_ruleid,
9160 /* ******************************************************************************** */
9162 struct cmd_dump_result {
9163 cmdline_fixed_string_t dump;
9167 dump_struct_sizes(void)
9169 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9170 DUMP_SIZE(struct rte_mbuf);
9171 DUMP_SIZE(struct rte_mempool);
9172 DUMP_SIZE(struct rte_ring);
9176 static void cmd_dump_parsed(void *parsed_result,
9177 __attribute__((unused)) struct cmdline *cl,
9178 __attribute__((unused)) void *data)
9180 struct cmd_dump_result *res = parsed_result;
9182 if (!strcmp(res->dump, "dump_physmem"))
9183 rte_dump_physmem_layout(stdout);
9184 else if (!strcmp(res->dump, "dump_memzone"))
9185 rte_memzone_dump(stdout);
9186 else if (!strcmp(res->dump, "dump_struct_sizes"))
9187 dump_struct_sizes();
9188 else if (!strcmp(res->dump, "dump_ring"))
9189 rte_ring_list_dump(stdout);
9190 else if (!strcmp(res->dump, "dump_mempool"))
9191 rte_mempool_list_dump(stdout);
9192 else if (!strcmp(res->dump, "dump_devargs"))
9193 rte_devargs_dump(stdout);
9194 else if (!strcmp(res->dump, "dump_log_types"))
9195 rte_log_dump(stdout);
9198 cmdline_parse_token_string_t cmd_dump_dump =
9199 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9202 "dump_struct_sizes#"
9208 cmdline_parse_inst_t cmd_dump = {
9209 .f = cmd_dump_parsed, /* function to call */
9210 .data = NULL, /* 2nd arg of func */
9211 .help_str = "Dump status",
9212 .tokens = { /* token list, NULL terminated */
9213 (void *)&cmd_dump_dump,
9218 /* ******************************************************************************** */
9220 struct cmd_dump_one_result {
9221 cmdline_fixed_string_t dump;
9222 cmdline_fixed_string_t name;
9225 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9226 __attribute__((unused)) void *data)
9228 struct cmd_dump_one_result *res = parsed_result;
9230 if (!strcmp(res->dump, "dump_ring")) {
9232 r = rte_ring_lookup(res->name);
9234 cmdline_printf(cl, "Cannot find ring\n");
9237 rte_ring_dump(stdout, r);
9238 } else if (!strcmp(res->dump, "dump_mempool")) {
9239 struct rte_mempool *mp;
9240 mp = rte_mempool_lookup(res->name);
9242 cmdline_printf(cl, "Cannot find mempool\n");
9245 rte_mempool_dump(stdout, mp);
9249 cmdline_parse_token_string_t cmd_dump_one_dump =
9250 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9251 "dump_ring#dump_mempool");
9253 cmdline_parse_token_string_t cmd_dump_one_name =
9254 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9256 cmdline_parse_inst_t cmd_dump_one = {
9257 .f = cmd_dump_one_parsed, /* function to call */
9258 .data = NULL, /* 2nd arg of func */
9259 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9260 .tokens = { /* token list, NULL terminated */
9261 (void *)&cmd_dump_one_dump,
9262 (void *)&cmd_dump_one_name,
9267 /* *** Add/Del syn filter *** */
9268 struct cmd_syn_filter_result {
9269 cmdline_fixed_string_t filter;
9271 cmdline_fixed_string_t ops;
9272 cmdline_fixed_string_t priority;
9273 cmdline_fixed_string_t high;
9274 cmdline_fixed_string_t queue;
9279 cmd_syn_filter_parsed(void *parsed_result,
9280 __attribute__((unused)) struct cmdline *cl,
9281 __attribute__((unused)) void *data)
9283 struct cmd_syn_filter_result *res = parsed_result;
9284 struct rte_eth_syn_filter syn_filter;
9287 ret = rte_eth_dev_filter_supported(res->port_id,
9288 RTE_ETH_FILTER_SYN);
9290 printf("syn filter is not supported on port %u.\n",
9295 memset(&syn_filter, 0, sizeof(syn_filter));
9297 if (!strcmp(res->ops, "add")) {
9298 if (!strcmp(res->high, "high"))
9299 syn_filter.hig_pri = 1;
9301 syn_filter.hig_pri = 0;
9303 syn_filter.queue = res->queue_id;
9304 ret = rte_eth_dev_filter_ctrl(res->port_id,
9309 ret = rte_eth_dev_filter_ctrl(res->port_id,
9311 RTE_ETH_FILTER_DELETE,
9315 printf("syn filter programming error: (%s)\n",
9319 cmdline_parse_token_string_t cmd_syn_filter_filter =
9320 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9321 filter, "syn_filter");
9322 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9323 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9325 cmdline_parse_token_string_t cmd_syn_filter_ops =
9326 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9328 cmdline_parse_token_string_t cmd_syn_filter_priority =
9329 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9330 priority, "priority");
9331 cmdline_parse_token_string_t cmd_syn_filter_high =
9332 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9334 cmdline_parse_token_string_t cmd_syn_filter_queue =
9335 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9337 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9338 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9341 cmdline_parse_inst_t cmd_syn_filter = {
9342 .f = cmd_syn_filter_parsed,
9344 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9345 "<queue_id>: Add/Delete syn filter",
9347 (void *)&cmd_syn_filter_filter,
9348 (void *)&cmd_syn_filter_port_id,
9349 (void *)&cmd_syn_filter_ops,
9350 (void *)&cmd_syn_filter_priority,
9351 (void *)&cmd_syn_filter_high,
9352 (void *)&cmd_syn_filter_queue,
9353 (void *)&cmd_syn_filter_queue_id,
9358 /* *** queue region set *** */
9359 struct cmd_queue_region_result {
9360 cmdline_fixed_string_t set;
9361 cmdline_fixed_string_t port;
9363 cmdline_fixed_string_t cmd;
9364 cmdline_fixed_string_t region;
9366 cmdline_fixed_string_t queue_start_index;
9368 cmdline_fixed_string_t queue_num;
9369 uint8_t queue_num_value;
9373 cmd_queue_region_parsed(void *parsed_result,
9374 __attribute__((unused)) struct cmdline *cl,
9375 __attribute__((unused)) void *data)
9377 struct cmd_queue_region_result *res = parsed_result;
9379 #ifdef RTE_LIBRTE_I40E_PMD
9380 struct rte_pmd_i40e_queue_region_conf region_conf;
9381 enum rte_pmd_i40e_queue_region_op op_type;
9384 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9387 #ifdef RTE_LIBRTE_I40E_PMD
9388 memset(®ion_conf, 0, sizeof(region_conf));
9389 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9390 region_conf.region_id = res->region_id;
9391 region_conf.queue_num = res->queue_num_value;
9392 region_conf.queue_start_index = res->queue_id;
9394 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9395 op_type, ®ion_conf);
9402 printf("function not implemented or supported\n");
9405 printf("queue region config error: (%s)\n", strerror(-ret));
9409 cmdline_parse_token_string_t cmd_queue_region_set =
9410 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9412 cmdline_parse_token_string_t cmd_queue_region_port =
9413 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9414 cmdline_parse_token_num_t cmd_queue_region_port_id =
9415 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9417 cmdline_parse_token_string_t cmd_queue_region_cmd =
9418 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9419 cmd, "queue-region");
9420 cmdline_parse_token_string_t cmd_queue_region_id =
9421 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9422 region, "region_id");
9423 cmdline_parse_token_num_t cmd_queue_region_index =
9424 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9426 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9427 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9428 queue_start_index, "queue_start_index");
9429 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9430 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9432 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9433 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9434 queue_num, "queue_num");
9435 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9436 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9437 queue_num_value, UINT8);
9439 cmdline_parse_inst_t cmd_queue_region = {
9440 .f = cmd_queue_region_parsed,
9442 .help_str = "set port <port_id> queue-region region_id <value> "
9443 "queue_start_index <value> queue_num <value>: Set a queue region",
9445 (void *)&cmd_queue_region_set,
9446 (void *)&cmd_queue_region_port,
9447 (void *)&cmd_queue_region_port_id,
9448 (void *)&cmd_queue_region_cmd,
9449 (void *)&cmd_queue_region_id,
9450 (void *)&cmd_queue_region_index,
9451 (void *)&cmd_queue_region_queue_start_index,
9452 (void *)&cmd_queue_region_queue_id,
9453 (void *)&cmd_queue_region_queue_num,
9454 (void *)&cmd_queue_region_queue_num_value,
9459 /* *** queue region and flowtype set *** */
9460 struct cmd_region_flowtype_result {
9461 cmdline_fixed_string_t set;
9462 cmdline_fixed_string_t port;
9464 cmdline_fixed_string_t cmd;
9465 cmdline_fixed_string_t region;
9467 cmdline_fixed_string_t flowtype;
9468 uint8_t flowtype_id;
9472 cmd_region_flowtype_parsed(void *parsed_result,
9473 __attribute__((unused)) struct cmdline *cl,
9474 __attribute__((unused)) void *data)
9476 struct cmd_region_flowtype_result *res = parsed_result;
9478 #ifdef RTE_LIBRTE_I40E_PMD
9479 struct rte_pmd_i40e_queue_region_conf region_conf;
9480 enum rte_pmd_i40e_queue_region_op op_type;
9483 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9486 #ifdef RTE_LIBRTE_I40E_PMD
9487 memset(®ion_conf, 0, sizeof(region_conf));
9489 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9490 region_conf.region_id = res->region_id;
9491 region_conf.hw_flowtype = res->flowtype_id;
9493 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9494 op_type, ®ion_conf);
9501 printf("function not implemented or supported\n");
9504 printf("region flowtype config error: (%s)\n", strerror(-ret));
9508 cmdline_parse_token_string_t cmd_region_flowtype_set =
9509 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9511 cmdline_parse_token_string_t cmd_region_flowtype_port =
9512 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9514 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9515 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9517 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9518 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9519 cmd, "queue-region");
9520 cmdline_parse_token_string_t cmd_region_flowtype_index =
9521 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9522 region, "region_id");
9523 cmdline_parse_token_num_t cmd_region_flowtype_id =
9524 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9526 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9527 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9528 flowtype, "flowtype");
9529 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9530 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9531 flowtype_id, UINT8);
9532 cmdline_parse_inst_t cmd_region_flowtype = {
9533 .f = cmd_region_flowtype_parsed,
9535 .help_str = "set port <port_id> queue-region region_id <value> "
9536 "flowtype <value>: Set a flowtype region index",
9538 (void *)&cmd_region_flowtype_set,
9539 (void *)&cmd_region_flowtype_port,
9540 (void *)&cmd_region_flowtype_port_index,
9541 (void *)&cmd_region_flowtype_cmd,
9542 (void *)&cmd_region_flowtype_index,
9543 (void *)&cmd_region_flowtype_id,
9544 (void *)&cmd_region_flowtype_flow_index,
9545 (void *)&cmd_region_flowtype_flow_id,
9550 /* *** User Priority (UP) to queue region (region_id) set *** */
9551 struct cmd_user_priority_region_result {
9552 cmdline_fixed_string_t set;
9553 cmdline_fixed_string_t port;
9555 cmdline_fixed_string_t cmd;
9556 cmdline_fixed_string_t user_priority;
9557 uint8_t user_priority_id;
9558 cmdline_fixed_string_t region;
9563 cmd_user_priority_region_parsed(void *parsed_result,
9564 __attribute__((unused)) struct cmdline *cl,
9565 __attribute__((unused)) void *data)
9567 struct cmd_user_priority_region_result *res = parsed_result;
9569 #ifdef RTE_LIBRTE_I40E_PMD
9570 struct rte_pmd_i40e_queue_region_conf region_conf;
9571 enum rte_pmd_i40e_queue_region_op op_type;
9574 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9577 #ifdef RTE_LIBRTE_I40E_PMD
9578 memset(®ion_conf, 0, sizeof(region_conf));
9579 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9580 region_conf.user_priority = res->user_priority_id;
9581 region_conf.region_id = res->region_id;
9583 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9584 op_type, ®ion_conf);
9591 printf("function not implemented or supported\n");
9594 printf("user_priority region config error: (%s)\n",
9599 cmdline_parse_token_string_t cmd_user_priority_region_set =
9600 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9602 cmdline_parse_token_string_t cmd_user_priority_region_port =
9603 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9605 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9606 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9608 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9609 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9610 cmd, "queue-region");
9611 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9612 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9613 user_priority, "UP");
9614 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9615 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9616 user_priority_id, UINT8);
9617 cmdline_parse_token_string_t cmd_user_priority_region_region =
9618 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9619 region, "region_id");
9620 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9621 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9624 cmdline_parse_inst_t cmd_user_priority_region = {
9625 .f = cmd_user_priority_region_parsed,
9627 .help_str = "set port <port_id> queue-region UP <value> "
9628 "region_id <value>: Set the mapping of User Priority (UP) "
9629 "to queue region (region_id) ",
9631 (void *)&cmd_user_priority_region_set,
9632 (void *)&cmd_user_priority_region_port,
9633 (void *)&cmd_user_priority_region_port_index,
9634 (void *)&cmd_user_priority_region_cmd,
9635 (void *)&cmd_user_priority_region_UP,
9636 (void *)&cmd_user_priority_region_UP_id,
9637 (void *)&cmd_user_priority_region_region,
9638 (void *)&cmd_user_priority_region_region_id,
9643 /* *** flush all queue region related configuration *** */
9644 struct cmd_flush_queue_region_result {
9645 cmdline_fixed_string_t set;
9646 cmdline_fixed_string_t port;
9648 cmdline_fixed_string_t cmd;
9649 cmdline_fixed_string_t flush;
9650 cmdline_fixed_string_t what;
9654 cmd_flush_queue_region_parsed(void *parsed_result,
9655 __attribute__((unused)) struct cmdline *cl,
9656 __attribute__((unused)) void *data)
9658 struct cmd_flush_queue_region_result *res = parsed_result;
9660 #ifdef RTE_LIBRTE_I40E_PMD
9661 struct rte_pmd_i40e_queue_region_conf region_conf;
9662 enum rte_pmd_i40e_queue_region_op op_type;
9665 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9668 #ifdef RTE_LIBRTE_I40E_PMD
9669 memset(®ion_conf, 0, sizeof(region_conf));
9671 if (strcmp(res->what, "on") == 0)
9672 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9674 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9676 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9677 op_type, ®ion_conf);
9684 printf("function not implemented or supported\n");
9687 printf("queue region config flush error: (%s)\n",
9692 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9693 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9695 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9696 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9698 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9699 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9701 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9702 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9703 cmd, "queue-region");
9704 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9705 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9707 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9708 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9711 cmdline_parse_inst_t cmd_flush_queue_region = {
9712 .f = cmd_flush_queue_region_parsed,
9714 .help_str = "set port <port_id> queue-region flush on|off"
9715 ": flush all queue region related configuration",
9717 (void *)&cmd_flush_queue_region_set,
9718 (void *)&cmd_flush_queue_region_port,
9719 (void *)&cmd_flush_queue_region_port_index,
9720 (void *)&cmd_flush_queue_region_cmd,
9721 (void *)&cmd_flush_queue_region_flush,
9722 (void *)&cmd_flush_queue_region_what,
9727 /* *** get all queue region related configuration info *** */
9728 struct cmd_show_queue_region_info {
9729 cmdline_fixed_string_t show;
9730 cmdline_fixed_string_t port;
9732 cmdline_fixed_string_t cmd;
9736 cmd_show_queue_region_info_parsed(void *parsed_result,
9737 __attribute__((unused)) struct cmdline *cl,
9738 __attribute__((unused)) void *data)
9740 struct cmd_show_queue_region_info *res = parsed_result;
9742 #ifdef RTE_LIBRTE_I40E_PMD
9743 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
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(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9753 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9755 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9756 op_type, &rte_pmd_regions);
9758 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9765 printf("function not implemented or supported\n");
9768 printf("queue region config info show error: (%s)\n",
9773 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9774 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9776 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9777 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9779 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9780 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9782 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9783 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9784 cmd, "queue-region");
9786 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9787 .f = cmd_show_queue_region_info_parsed,
9789 .help_str = "show port <port_id> queue-region"
9790 ": show all queue region related configuration info",
9792 (void *)&cmd_show_queue_region_info_get,
9793 (void *)&cmd_show_queue_region_info_port,
9794 (void *)&cmd_show_queue_region_info_port_index,
9795 (void *)&cmd_show_queue_region_info_cmd,
9800 /* *** ADD/REMOVE A 2tuple FILTER *** */
9801 struct cmd_2tuple_filter_result {
9802 cmdline_fixed_string_t filter;
9804 cmdline_fixed_string_t ops;
9805 cmdline_fixed_string_t dst_port;
9806 uint16_t dst_port_value;
9807 cmdline_fixed_string_t protocol;
9808 uint8_t protocol_value;
9809 cmdline_fixed_string_t mask;
9811 cmdline_fixed_string_t tcp_flags;
9812 uint8_t tcp_flags_value;
9813 cmdline_fixed_string_t priority;
9814 uint8_t priority_value;
9815 cmdline_fixed_string_t queue;
9820 cmd_2tuple_filter_parsed(void *parsed_result,
9821 __attribute__((unused)) struct cmdline *cl,
9822 __attribute__((unused)) void *data)
9824 struct rte_eth_ntuple_filter filter;
9825 struct cmd_2tuple_filter_result *res = parsed_result;
9828 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9830 printf("ntuple filter is not supported on port %u.\n",
9835 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9837 filter.flags = RTE_2TUPLE_FLAGS;
9838 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9839 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9840 filter.proto = res->protocol_value;
9841 filter.priority = res->priority_value;
9842 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9843 printf("nonzero tcp_flags is only meaningful"
9844 " when protocol is TCP.\n");
9847 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9848 printf("invalid TCP flags.\n");
9852 if (res->tcp_flags_value != 0) {
9853 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9854 filter.tcp_flags = res->tcp_flags_value;
9857 /* need convert to big endian. */
9858 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9859 filter.queue = res->queue_id;
9861 if (!strcmp(res->ops, "add"))
9862 ret = rte_eth_dev_filter_ctrl(res->port_id,
9863 RTE_ETH_FILTER_NTUPLE,
9867 ret = rte_eth_dev_filter_ctrl(res->port_id,
9868 RTE_ETH_FILTER_NTUPLE,
9869 RTE_ETH_FILTER_DELETE,
9872 printf("2tuple filter programming error: (%s)\n",
9877 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9878 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9879 filter, "2tuple_filter");
9880 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9881 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9883 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9884 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9886 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9887 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9888 dst_port, "dst_port");
9889 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9890 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9891 dst_port_value, UINT16);
9892 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9893 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9894 protocol, "protocol");
9895 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9896 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9897 protocol_value, UINT8);
9898 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9899 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9901 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9902 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9904 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9905 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9906 tcp_flags, "tcp_flags");
9907 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9908 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9909 tcp_flags_value, UINT8);
9910 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9911 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9912 priority, "priority");
9913 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9914 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9915 priority_value, UINT8);
9916 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9917 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9919 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9920 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9923 cmdline_parse_inst_t cmd_2tuple_filter = {
9924 .f = cmd_2tuple_filter_parsed,
9926 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9927 "<value> mask <value> tcp_flags <value> priority <value> queue "
9928 "<queue_id>: Add a 2tuple filter",
9930 (void *)&cmd_2tuple_filter_filter,
9931 (void *)&cmd_2tuple_filter_port_id,
9932 (void *)&cmd_2tuple_filter_ops,
9933 (void *)&cmd_2tuple_filter_dst_port,
9934 (void *)&cmd_2tuple_filter_dst_port_value,
9935 (void *)&cmd_2tuple_filter_protocol,
9936 (void *)&cmd_2tuple_filter_protocol_value,
9937 (void *)&cmd_2tuple_filter_mask,
9938 (void *)&cmd_2tuple_filter_mask_value,
9939 (void *)&cmd_2tuple_filter_tcp_flags,
9940 (void *)&cmd_2tuple_filter_tcp_flags_value,
9941 (void *)&cmd_2tuple_filter_priority,
9942 (void *)&cmd_2tuple_filter_priority_value,
9943 (void *)&cmd_2tuple_filter_queue,
9944 (void *)&cmd_2tuple_filter_queue_id,
9949 /* *** ADD/REMOVE A 5tuple FILTER *** */
9950 struct cmd_5tuple_filter_result {
9951 cmdline_fixed_string_t filter;
9953 cmdline_fixed_string_t ops;
9954 cmdline_fixed_string_t dst_ip;
9955 cmdline_ipaddr_t dst_ip_value;
9956 cmdline_fixed_string_t src_ip;
9957 cmdline_ipaddr_t src_ip_value;
9958 cmdline_fixed_string_t dst_port;
9959 uint16_t dst_port_value;
9960 cmdline_fixed_string_t src_port;
9961 uint16_t src_port_value;
9962 cmdline_fixed_string_t protocol;
9963 uint8_t protocol_value;
9964 cmdline_fixed_string_t mask;
9966 cmdline_fixed_string_t tcp_flags;
9967 uint8_t tcp_flags_value;
9968 cmdline_fixed_string_t priority;
9969 uint8_t priority_value;
9970 cmdline_fixed_string_t queue;
9975 cmd_5tuple_filter_parsed(void *parsed_result,
9976 __attribute__((unused)) struct cmdline *cl,
9977 __attribute__((unused)) void *data)
9979 struct rte_eth_ntuple_filter filter;
9980 struct cmd_5tuple_filter_result *res = parsed_result;
9983 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9985 printf("ntuple filter is not supported on port %u.\n",
9990 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9992 filter.flags = RTE_5TUPLE_FLAGS;
9993 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9994 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9995 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9996 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9997 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9998 filter.proto = res->protocol_value;
9999 filter.priority = res->priority_value;
10000 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10001 printf("nonzero tcp_flags is only meaningful"
10002 " when protocol is TCP.\n");
10005 if (res->tcp_flags_value > TCP_FLAG_ALL) {
10006 printf("invalid TCP flags.\n");
10010 if (res->tcp_flags_value != 0) {
10011 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10012 filter.tcp_flags = res->tcp_flags_value;
10015 if (res->dst_ip_value.family == AF_INET)
10016 /* no need to convert, already big endian. */
10017 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10019 if (filter.dst_ip_mask == 0) {
10020 printf("can not support ipv6 involved compare.\n");
10026 if (res->src_ip_value.family == AF_INET)
10027 /* no need to convert, already big endian. */
10028 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10030 if (filter.src_ip_mask == 0) {
10031 printf("can not support ipv6 involved compare.\n");
10036 /* need convert to big endian. */
10037 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10038 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10039 filter.queue = res->queue_id;
10041 if (!strcmp(res->ops, "add"))
10042 ret = rte_eth_dev_filter_ctrl(res->port_id,
10043 RTE_ETH_FILTER_NTUPLE,
10044 RTE_ETH_FILTER_ADD,
10047 ret = rte_eth_dev_filter_ctrl(res->port_id,
10048 RTE_ETH_FILTER_NTUPLE,
10049 RTE_ETH_FILTER_DELETE,
10052 printf("5tuple filter programming error: (%s)\n",
10056 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10057 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10058 filter, "5tuple_filter");
10059 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10060 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10062 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10063 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10065 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10066 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10068 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10069 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10071 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10072 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10074 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10075 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10077 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10078 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10079 dst_port, "dst_port");
10080 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10081 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10082 dst_port_value, UINT16);
10083 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10084 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10085 src_port, "src_port");
10086 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10087 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10088 src_port_value, UINT16);
10089 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10090 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10091 protocol, "protocol");
10092 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10093 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10094 protocol_value, UINT8);
10095 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10096 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10098 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10099 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10101 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10102 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10103 tcp_flags, "tcp_flags");
10104 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10105 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10106 tcp_flags_value, UINT8);
10107 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10108 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10109 priority, "priority");
10110 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10111 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10112 priority_value, UINT8);
10113 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10114 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10116 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10117 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10120 cmdline_parse_inst_t cmd_5tuple_filter = {
10121 .f = cmd_5tuple_filter_parsed,
10123 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10124 "src_ip <value> dst_port <value> src_port <value> "
10125 "protocol <value> mask <value> tcp_flags <value> "
10126 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10128 (void *)&cmd_5tuple_filter_filter,
10129 (void *)&cmd_5tuple_filter_port_id,
10130 (void *)&cmd_5tuple_filter_ops,
10131 (void *)&cmd_5tuple_filter_dst_ip,
10132 (void *)&cmd_5tuple_filter_dst_ip_value,
10133 (void *)&cmd_5tuple_filter_src_ip,
10134 (void *)&cmd_5tuple_filter_src_ip_value,
10135 (void *)&cmd_5tuple_filter_dst_port,
10136 (void *)&cmd_5tuple_filter_dst_port_value,
10137 (void *)&cmd_5tuple_filter_src_port,
10138 (void *)&cmd_5tuple_filter_src_port_value,
10139 (void *)&cmd_5tuple_filter_protocol,
10140 (void *)&cmd_5tuple_filter_protocol_value,
10141 (void *)&cmd_5tuple_filter_mask,
10142 (void *)&cmd_5tuple_filter_mask_value,
10143 (void *)&cmd_5tuple_filter_tcp_flags,
10144 (void *)&cmd_5tuple_filter_tcp_flags_value,
10145 (void *)&cmd_5tuple_filter_priority,
10146 (void *)&cmd_5tuple_filter_priority_value,
10147 (void *)&cmd_5tuple_filter_queue,
10148 (void *)&cmd_5tuple_filter_queue_id,
10153 /* *** ADD/REMOVE A flex FILTER *** */
10154 struct cmd_flex_filter_result {
10155 cmdline_fixed_string_t filter;
10156 cmdline_fixed_string_t ops;
10158 cmdline_fixed_string_t len;
10160 cmdline_fixed_string_t bytes;
10161 cmdline_fixed_string_t bytes_value;
10162 cmdline_fixed_string_t mask;
10163 cmdline_fixed_string_t mask_value;
10164 cmdline_fixed_string_t priority;
10165 uint8_t priority_value;
10166 cmdline_fixed_string_t queue;
10170 static int xdigit2val(unsigned char c)
10175 else if (isupper(c))
10176 val = c - 'A' + 10;
10178 val = c - 'a' + 10;
10183 cmd_flex_filter_parsed(void *parsed_result,
10184 __attribute__((unused)) struct cmdline *cl,
10185 __attribute__((unused)) void *data)
10188 struct rte_eth_flex_filter filter;
10189 struct cmd_flex_filter_result *res = parsed_result;
10190 char *bytes_ptr, *mask_ptr;
10191 uint16_t len, i, j = 0;
10196 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10197 printf("the len exceed the max length 128\n");
10200 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10201 filter.len = res->len_value;
10202 filter.priority = res->priority_value;
10203 filter.queue = res->queue_id;
10204 bytes_ptr = res->bytes_value;
10205 mask_ptr = res->mask_value;
10207 /* translate bytes string to array. */
10208 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10209 (bytes_ptr[1] == 'X')))
10211 len = strnlen(bytes_ptr, res->len_value * 2);
10212 if (len == 0 || (len % 8 != 0)) {
10213 printf("please check len and bytes input\n");
10216 for (i = 0; i < len; i++) {
10218 if (isxdigit(c) == 0) {
10219 /* invalid characters. */
10220 printf("invalid input\n");
10223 val = xdigit2val(c);
10226 filter.bytes[j] = byte;
10227 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10234 /* translate mask string to uint8_t array. */
10235 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10236 (mask_ptr[1] == 'X')))
10238 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10240 printf("invalid input\n");
10245 for (i = 0; i < len; i++) {
10247 if (isxdigit(c) == 0) {
10248 /* invalid characters. */
10249 printf("invalid input\n");
10252 val = xdigit2val(c);
10255 filter.mask[j] = byte;
10256 printf("mask[%d]:%02x ", j, filter.mask[j]);
10264 if (!strcmp(res->ops, "add"))
10265 ret = rte_eth_dev_filter_ctrl(res->port_id,
10266 RTE_ETH_FILTER_FLEXIBLE,
10267 RTE_ETH_FILTER_ADD,
10270 ret = rte_eth_dev_filter_ctrl(res->port_id,
10271 RTE_ETH_FILTER_FLEXIBLE,
10272 RTE_ETH_FILTER_DELETE,
10276 printf("flex filter setting error: (%s)\n", strerror(-ret));
10279 cmdline_parse_token_string_t cmd_flex_filter_filter =
10280 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10281 filter, "flex_filter");
10282 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10283 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10285 cmdline_parse_token_string_t cmd_flex_filter_ops =
10286 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10288 cmdline_parse_token_string_t cmd_flex_filter_len =
10289 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10291 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10292 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10294 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10295 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10297 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10298 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10299 bytes_value, NULL);
10300 cmdline_parse_token_string_t cmd_flex_filter_mask =
10301 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10303 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10304 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10306 cmdline_parse_token_string_t cmd_flex_filter_priority =
10307 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10308 priority, "priority");
10309 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10310 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10311 priority_value, UINT8);
10312 cmdline_parse_token_string_t cmd_flex_filter_queue =
10313 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10315 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10316 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10318 cmdline_parse_inst_t cmd_flex_filter = {
10319 .f = cmd_flex_filter_parsed,
10321 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10322 "<value> mask <value> priority <value> queue <queue_id>: "
10323 "Add/Del a flex filter",
10325 (void *)&cmd_flex_filter_filter,
10326 (void *)&cmd_flex_filter_port_id,
10327 (void *)&cmd_flex_filter_ops,
10328 (void *)&cmd_flex_filter_len,
10329 (void *)&cmd_flex_filter_len_value,
10330 (void *)&cmd_flex_filter_bytes,
10331 (void *)&cmd_flex_filter_bytes_value,
10332 (void *)&cmd_flex_filter_mask,
10333 (void *)&cmd_flex_filter_mask_value,
10334 (void *)&cmd_flex_filter_priority,
10335 (void *)&cmd_flex_filter_priority_value,
10336 (void *)&cmd_flex_filter_queue,
10337 (void *)&cmd_flex_filter_queue_id,
10342 /* *** Filters Control *** */
10344 /* *** deal with ethertype filter *** */
10345 struct cmd_ethertype_filter_result {
10346 cmdline_fixed_string_t filter;
10348 cmdline_fixed_string_t ops;
10349 cmdline_fixed_string_t mac;
10350 struct ether_addr mac_addr;
10351 cmdline_fixed_string_t ethertype;
10352 uint16_t ethertype_value;
10353 cmdline_fixed_string_t drop;
10354 cmdline_fixed_string_t queue;
10358 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10359 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10360 filter, "ethertype_filter");
10361 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10362 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10364 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10365 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10367 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10368 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10369 mac, "mac_addr#mac_ignr");
10370 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10371 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10373 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10374 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10375 ethertype, "ethertype");
10376 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10377 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10378 ethertype_value, UINT16);
10379 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10380 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10382 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10383 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10385 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10386 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10390 cmd_ethertype_filter_parsed(void *parsed_result,
10391 __attribute__((unused)) struct cmdline *cl,
10392 __attribute__((unused)) void *data)
10394 struct cmd_ethertype_filter_result *res = parsed_result;
10395 struct rte_eth_ethertype_filter filter;
10398 ret = rte_eth_dev_filter_supported(res->port_id,
10399 RTE_ETH_FILTER_ETHERTYPE);
10401 printf("ethertype filter is not supported on port %u.\n",
10406 memset(&filter, 0, sizeof(filter));
10407 if (!strcmp(res->mac, "mac_addr")) {
10408 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10409 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10410 sizeof(struct ether_addr));
10412 if (!strcmp(res->drop, "drop"))
10413 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10414 filter.ether_type = res->ethertype_value;
10415 filter.queue = res->queue_id;
10417 if (!strcmp(res->ops, "add"))
10418 ret = rte_eth_dev_filter_ctrl(res->port_id,
10419 RTE_ETH_FILTER_ETHERTYPE,
10420 RTE_ETH_FILTER_ADD,
10423 ret = rte_eth_dev_filter_ctrl(res->port_id,
10424 RTE_ETH_FILTER_ETHERTYPE,
10425 RTE_ETH_FILTER_DELETE,
10428 printf("ethertype filter programming error: (%s)\n",
10432 cmdline_parse_inst_t cmd_ethertype_filter = {
10433 .f = cmd_ethertype_filter_parsed,
10435 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10436 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10437 "Add or delete an ethertype filter entry",
10439 (void *)&cmd_ethertype_filter_filter,
10440 (void *)&cmd_ethertype_filter_port_id,
10441 (void *)&cmd_ethertype_filter_ops,
10442 (void *)&cmd_ethertype_filter_mac,
10443 (void *)&cmd_ethertype_filter_mac_addr,
10444 (void *)&cmd_ethertype_filter_ethertype,
10445 (void *)&cmd_ethertype_filter_ethertype_value,
10446 (void *)&cmd_ethertype_filter_drop,
10447 (void *)&cmd_ethertype_filter_queue,
10448 (void *)&cmd_ethertype_filter_queue_id,
10453 /* *** deal with flow director filter *** */
10454 struct cmd_flow_director_result {
10455 cmdline_fixed_string_t flow_director_filter;
10457 cmdline_fixed_string_t mode;
10458 cmdline_fixed_string_t mode_value;
10459 cmdline_fixed_string_t ops;
10460 cmdline_fixed_string_t flow;
10461 cmdline_fixed_string_t flow_type;
10462 cmdline_fixed_string_t ether;
10463 uint16_t ether_type;
10464 cmdline_fixed_string_t src;
10465 cmdline_ipaddr_t ip_src;
10467 cmdline_fixed_string_t dst;
10468 cmdline_ipaddr_t ip_dst;
10470 cmdline_fixed_string_t verify_tag;
10471 uint32_t verify_tag_value;
10472 cmdline_fixed_string_t tos;
10474 cmdline_fixed_string_t proto;
10475 uint8_t proto_value;
10476 cmdline_fixed_string_t ttl;
10478 cmdline_fixed_string_t vlan;
10479 uint16_t vlan_value;
10480 cmdline_fixed_string_t flexbytes;
10481 cmdline_fixed_string_t flexbytes_value;
10482 cmdline_fixed_string_t pf_vf;
10483 cmdline_fixed_string_t drop;
10484 cmdline_fixed_string_t queue;
10486 cmdline_fixed_string_t fd_id;
10487 uint32_t fd_id_value;
10488 cmdline_fixed_string_t mac;
10489 struct ether_addr mac_addr;
10490 cmdline_fixed_string_t tunnel;
10491 cmdline_fixed_string_t tunnel_type;
10492 cmdline_fixed_string_t tunnel_id;
10493 uint32_t tunnel_id_value;
10494 cmdline_fixed_string_t packet;
10499 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10502 const char *p, *p0 = q_arg;
10504 unsigned long int_fld;
10505 char *str_fld[max_num];
10510 p = strchr(p0, '(');
10514 p0 = strchr(p, ')');
10519 if (size >= sizeof(s))
10522 snprintf(s, sizeof(s), "%.*s", size, p);
10523 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10524 if (ret < 0 || ret > max_num)
10526 for (i = 0; i < ret; i++) {
10528 int_fld = strtoul(str_fld[i], &end, 0);
10529 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10531 flexbytes[i] = (uint8_t)int_fld;
10537 str2flowtype(char *string)
10540 static const struct {
10543 } flowtype_str[] = {
10544 {"raw", RTE_ETH_FLOW_RAW},
10545 {"ipv4", RTE_ETH_FLOW_IPV4},
10546 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10547 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10548 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10549 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10550 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10551 {"ipv6", RTE_ETH_FLOW_IPV6},
10552 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10553 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10554 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10555 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10556 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10557 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10560 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10561 if (!strcmp(flowtype_str[i].str, string))
10562 return flowtype_str[i].type;
10565 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10566 return (uint16_t)atoi(string);
10568 return RTE_ETH_FLOW_UNKNOWN;
10571 static enum rte_eth_fdir_tunnel_type
10572 str2fdir_tunneltype(char *string)
10576 static const struct {
10578 enum rte_eth_fdir_tunnel_type type;
10579 } tunneltype_str[] = {
10580 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10581 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10584 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10585 if (!strcmp(tunneltype_str[i].str, string))
10586 return tunneltype_str[i].type;
10588 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10591 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10593 if ((ip_addr).family == AF_INET) \
10594 (ip) = (ip_addr).addr.ipv4.s_addr; \
10596 printf("invalid parameter.\n"); \
10601 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10603 if ((ip_addr).family == AF_INET6) \
10604 rte_memcpy(&(ip), \
10605 &((ip_addr).addr.ipv6), \
10606 sizeof(struct in6_addr)); \
10608 printf("invalid parameter.\n"); \
10614 cmd_flow_director_filter_parsed(void *parsed_result,
10615 __attribute__((unused)) struct cmdline *cl,
10616 __attribute__((unused)) void *data)
10618 struct cmd_flow_director_result *res = parsed_result;
10619 struct rte_eth_fdir_filter entry;
10620 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10622 unsigned long vf_id;
10625 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10627 printf("flow director is not supported on port %u.\n",
10631 memset(flexbytes, 0, sizeof(flexbytes));
10632 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10634 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10635 if (strcmp(res->mode_value, "MAC-VLAN")) {
10636 printf("Please set mode to MAC-VLAN.\n");
10639 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10640 if (strcmp(res->mode_value, "Tunnel")) {
10641 printf("Please set mode to Tunnel.\n");
10645 if (!strcmp(res->mode_value, "raw")) {
10646 #ifdef RTE_LIBRTE_I40E_PMD
10647 struct rte_pmd_i40e_flow_type_mapping
10648 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10649 struct rte_pmd_i40e_pkt_template_conf conf;
10650 uint16_t flow_type = str2flowtype(res->flow_type);
10651 uint16_t i, port = res->port_id;
10654 memset(&conf, 0, sizeof(conf));
10656 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10657 printf("Invalid flow type specified.\n");
10660 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10664 if (mapping[flow_type].pctype == 0ULL) {
10665 printf("Invalid flow type specified.\n");
10668 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10669 if (mapping[flow_type].pctype & (1ULL << i)) {
10670 conf.input.pctype = i;
10675 conf.input.packet = open_file(res->filepath,
10676 &conf.input.length);
10677 if (!conf.input.packet)
10679 if (!strcmp(res->drop, "drop"))
10680 conf.action.behavior =
10681 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10683 conf.action.behavior =
10684 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10685 conf.action.report_status =
10686 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10687 conf.action.rx_queue = res->queue_id;
10688 conf.soft_id = res->fd_id_value;
10689 add = strcmp(res->ops, "del") ? 1 : 0;
10690 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10694 printf("flow director config error: (%s)\n",
10696 close_file(conf.input.packet);
10699 } else if (strcmp(res->mode_value, "IP")) {
10700 printf("Please set mode to IP or raw.\n");
10703 entry.input.flow_type = str2flowtype(res->flow_type);
10706 ret = parse_flexbytes(res->flexbytes_value,
10708 RTE_ETH_FDIR_MAX_FLEXLEN);
10710 printf("error: Cannot parse flexbytes input.\n");
10714 switch (entry.input.flow_type) {
10715 case RTE_ETH_FLOW_FRAG_IPV4:
10716 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10717 entry.input.flow.ip4_flow.proto = res->proto_value;
10719 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10720 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10721 IPV4_ADDR_TO_UINT(res->ip_dst,
10722 entry.input.flow.ip4_flow.dst_ip);
10723 IPV4_ADDR_TO_UINT(res->ip_src,
10724 entry.input.flow.ip4_flow.src_ip);
10725 entry.input.flow.ip4_flow.tos = res->tos_value;
10726 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10727 /* need convert to big endian. */
10728 entry.input.flow.udp4_flow.dst_port =
10729 rte_cpu_to_be_16(res->port_dst);
10730 entry.input.flow.udp4_flow.src_port =
10731 rte_cpu_to_be_16(res->port_src);
10733 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10734 IPV4_ADDR_TO_UINT(res->ip_dst,
10735 entry.input.flow.sctp4_flow.ip.dst_ip);
10736 IPV4_ADDR_TO_UINT(res->ip_src,
10737 entry.input.flow.sctp4_flow.ip.src_ip);
10738 entry.input.flow.ip4_flow.tos = res->tos_value;
10739 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10740 /* need convert to big endian. */
10741 entry.input.flow.sctp4_flow.dst_port =
10742 rte_cpu_to_be_16(res->port_dst);
10743 entry.input.flow.sctp4_flow.src_port =
10744 rte_cpu_to_be_16(res->port_src);
10745 entry.input.flow.sctp4_flow.verify_tag =
10746 rte_cpu_to_be_32(res->verify_tag_value);
10748 case RTE_ETH_FLOW_FRAG_IPV6:
10749 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10750 entry.input.flow.ipv6_flow.proto = res->proto_value;
10752 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10753 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10754 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10755 entry.input.flow.ipv6_flow.dst_ip);
10756 IPV6_ADDR_TO_ARRAY(res->ip_src,
10757 entry.input.flow.ipv6_flow.src_ip);
10758 entry.input.flow.ipv6_flow.tc = res->tos_value;
10759 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10760 /* need convert to big endian. */
10761 entry.input.flow.udp6_flow.dst_port =
10762 rte_cpu_to_be_16(res->port_dst);
10763 entry.input.flow.udp6_flow.src_port =
10764 rte_cpu_to_be_16(res->port_src);
10766 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10767 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10768 entry.input.flow.sctp6_flow.ip.dst_ip);
10769 IPV6_ADDR_TO_ARRAY(res->ip_src,
10770 entry.input.flow.sctp6_flow.ip.src_ip);
10771 entry.input.flow.ipv6_flow.tc = res->tos_value;
10772 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10773 /* need convert to big endian. */
10774 entry.input.flow.sctp6_flow.dst_port =
10775 rte_cpu_to_be_16(res->port_dst);
10776 entry.input.flow.sctp6_flow.src_port =
10777 rte_cpu_to_be_16(res->port_src);
10778 entry.input.flow.sctp6_flow.verify_tag =
10779 rte_cpu_to_be_32(res->verify_tag_value);
10781 case RTE_ETH_FLOW_L2_PAYLOAD:
10782 entry.input.flow.l2_flow.ether_type =
10783 rte_cpu_to_be_16(res->ether_type);
10789 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10790 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10792 sizeof(struct ether_addr));
10794 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10795 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10797 sizeof(struct ether_addr));
10798 entry.input.flow.tunnel_flow.tunnel_type =
10799 str2fdir_tunneltype(res->tunnel_type);
10800 entry.input.flow.tunnel_flow.tunnel_id =
10801 rte_cpu_to_be_32(res->tunnel_id_value);
10804 rte_memcpy(entry.input.flow_ext.flexbytes,
10806 RTE_ETH_FDIR_MAX_FLEXLEN);
10808 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10810 entry.action.flex_off = 0; /*use 0 by default */
10811 if (!strcmp(res->drop, "drop"))
10812 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10814 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10816 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10817 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10818 if (!strcmp(res->pf_vf, "pf"))
10819 entry.input.flow_ext.is_vf = 0;
10820 else if (!strncmp(res->pf_vf, "vf", 2)) {
10821 struct rte_eth_dev_info dev_info;
10823 memset(&dev_info, 0, sizeof(dev_info));
10824 rte_eth_dev_info_get(res->port_id, &dev_info);
10826 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10827 if (errno != 0 || *end != '\0' ||
10828 vf_id >= dev_info.max_vfs) {
10829 printf("invalid parameter %s.\n", res->pf_vf);
10832 entry.input.flow_ext.is_vf = 1;
10833 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10835 printf("invalid parameter %s.\n", res->pf_vf);
10840 /* set to report FD ID by default */
10841 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10842 entry.action.rx_queue = res->queue_id;
10843 entry.soft_id = res->fd_id_value;
10844 if (!strcmp(res->ops, "add"))
10845 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10846 RTE_ETH_FILTER_ADD, &entry);
10847 else if (!strcmp(res->ops, "del"))
10848 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10849 RTE_ETH_FILTER_DELETE, &entry);
10851 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10852 RTE_ETH_FILTER_UPDATE, &entry);
10854 printf("flow director programming error: (%s)\n",
10858 cmdline_parse_token_string_t cmd_flow_director_filter =
10859 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10860 flow_director_filter, "flow_director_filter");
10861 cmdline_parse_token_num_t cmd_flow_director_port_id =
10862 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10864 cmdline_parse_token_string_t cmd_flow_director_ops =
10865 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10866 ops, "add#del#update");
10867 cmdline_parse_token_string_t cmd_flow_director_flow =
10868 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10870 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10871 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10873 cmdline_parse_token_string_t cmd_flow_director_ether =
10874 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10876 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10877 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10878 ether_type, UINT16);
10879 cmdline_parse_token_string_t cmd_flow_director_src =
10880 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10882 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10883 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10885 cmdline_parse_token_num_t cmd_flow_director_port_src =
10886 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10888 cmdline_parse_token_string_t cmd_flow_director_dst =
10889 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10891 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10892 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10894 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10895 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10897 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10898 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10899 verify_tag, "verify_tag");
10900 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10901 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10902 verify_tag_value, UINT32);
10903 cmdline_parse_token_string_t cmd_flow_director_tos =
10904 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10906 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10907 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10909 cmdline_parse_token_string_t cmd_flow_director_proto =
10910 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10912 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10913 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10914 proto_value, UINT8);
10915 cmdline_parse_token_string_t cmd_flow_director_ttl =
10916 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10918 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10919 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10921 cmdline_parse_token_string_t cmd_flow_director_vlan =
10922 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10924 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10925 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10926 vlan_value, UINT16);
10927 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10928 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10929 flexbytes, "flexbytes");
10930 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10931 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10932 flexbytes_value, NULL);
10933 cmdline_parse_token_string_t cmd_flow_director_drop =
10934 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10936 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10937 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10939 cmdline_parse_token_string_t cmd_flow_director_queue =
10940 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10942 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10943 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10945 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10946 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10948 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10949 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10950 fd_id_value, UINT32);
10952 cmdline_parse_token_string_t cmd_flow_director_mode =
10953 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10955 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10956 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10958 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10959 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10960 mode_value, "MAC-VLAN");
10961 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10962 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10963 mode_value, "Tunnel");
10964 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10965 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10966 mode_value, "raw");
10967 cmdline_parse_token_string_t cmd_flow_director_mac =
10968 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10970 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10971 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10973 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10974 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10976 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10977 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10978 tunnel_type, "NVGRE#VxLAN");
10979 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10980 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10981 tunnel_id, "tunnel-id");
10982 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10983 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10984 tunnel_id_value, UINT32);
10985 cmdline_parse_token_string_t cmd_flow_director_packet =
10986 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10988 cmdline_parse_token_string_t cmd_flow_director_filepath =
10989 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10992 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10993 .f = cmd_flow_director_filter_parsed,
10995 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10996 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10997 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10998 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10999 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11000 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11001 "fd_id <fd_id_value>: "
11002 "Add or delete an ip flow director entry on NIC",
11004 (void *)&cmd_flow_director_filter,
11005 (void *)&cmd_flow_director_port_id,
11006 (void *)&cmd_flow_director_mode,
11007 (void *)&cmd_flow_director_mode_ip,
11008 (void *)&cmd_flow_director_ops,
11009 (void *)&cmd_flow_director_flow,
11010 (void *)&cmd_flow_director_flow_type,
11011 (void *)&cmd_flow_director_src,
11012 (void *)&cmd_flow_director_ip_src,
11013 (void *)&cmd_flow_director_dst,
11014 (void *)&cmd_flow_director_ip_dst,
11015 (void *)&cmd_flow_director_tos,
11016 (void *)&cmd_flow_director_tos_value,
11017 (void *)&cmd_flow_director_proto,
11018 (void *)&cmd_flow_director_proto_value,
11019 (void *)&cmd_flow_director_ttl,
11020 (void *)&cmd_flow_director_ttl_value,
11021 (void *)&cmd_flow_director_vlan,
11022 (void *)&cmd_flow_director_vlan_value,
11023 (void *)&cmd_flow_director_flexbytes,
11024 (void *)&cmd_flow_director_flexbytes_value,
11025 (void *)&cmd_flow_director_drop,
11026 (void *)&cmd_flow_director_pf_vf,
11027 (void *)&cmd_flow_director_queue,
11028 (void *)&cmd_flow_director_queue_id,
11029 (void *)&cmd_flow_director_fd_id,
11030 (void *)&cmd_flow_director_fd_id_value,
11035 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11036 .f = cmd_flow_director_filter_parsed,
11038 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11039 "director entry on NIC",
11041 (void *)&cmd_flow_director_filter,
11042 (void *)&cmd_flow_director_port_id,
11043 (void *)&cmd_flow_director_mode,
11044 (void *)&cmd_flow_director_mode_ip,
11045 (void *)&cmd_flow_director_ops,
11046 (void *)&cmd_flow_director_flow,
11047 (void *)&cmd_flow_director_flow_type,
11048 (void *)&cmd_flow_director_src,
11049 (void *)&cmd_flow_director_ip_src,
11050 (void *)&cmd_flow_director_port_src,
11051 (void *)&cmd_flow_director_dst,
11052 (void *)&cmd_flow_director_ip_dst,
11053 (void *)&cmd_flow_director_port_dst,
11054 (void *)&cmd_flow_director_tos,
11055 (void *)&cmd_flow_director_tos_value,
11056 (void *)&cmd_flow_director_ttl,
11057 (void *)&cmd_flow_director_ttl_value,
11058 (void *)&cmd_flow_director_vlan,
11059 (void *)&cmd_flow_director_vlan_value,
11060 (void *)&cmd_flow_director_flexbytes,
11061 (void *)&cmd_flow_director_flexbytes_value,
11062 (void *)&cmd_flow_director_drop,
11063 (void *)&cmd_flow_director_pf_vf,
11064 (void *)&cmd_flow_director_queue,
11065 (void *)&cmd_flow_director_queue_id,
11066 (void *)&cmd_flow_director_fd_id,
11067 (void *)&cmd_flow_director_fd_id_value,
11072 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11073 .f = cmd_flow_director_filter_parsed,
11075 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11076 "director entry on NIC",
11078 (void *)&cmd_flow_director_filter,
11079 (void *)&cmd_flow_director_port_id,
11080 (void *)&cmd_flow_director_mode,
11081 (void *)&cmd_flow_director_mode_ip,
11082 (void *)&cmd_flow_director_ops,
11083 (void *)&cmd_flow_director_flow,
11084 (void *)&cmd_flow_director_flow_type,
11085 (void *)&cmd_flow_director_src,
11086 (void *)&cmd_flow_director_ip_src,
11087 (void *)&cmd_flow_director_port_src,
11088 (void *)&cmd_flow_director_dst,
11089 (void *)&cmd_flow_director_ip_dst,
11090 (void *)&cmd_flow_director_port_dst,
11091 (void *)&cmd_flow_director_verify_tag,
11092 (void *)&cmd_flow_director_verify_tag_value,
11093 (void *)&cmd_flow_director_tos,
11094 (void *)&cmd_flow_director_tos_value,
11095 (void *)&cmd_flow_director_ttl,
11096 (void *)&cmd_flow_director_ttl_value,
11097 (void *)&cmd_flow_director_vlan,
11098 (void *)&cmd_flow_director_vlan_value,
11099 (void *)&cmd_flow_director_flexbytes,
11100 (void *)&cmd_flow_director_flexbytes_value,
11101 (void *)&cmd_flow_director_drop,
11102 (void *)&cmd_flow_director_pf_vf,
11103 (void *)&cmd_flow_director_queue,
11104 (void *)&cmd_flow_director_queue_id,
11105 (void *)&cmd_flow_director_fd_id,
11106 (void *)&cmd_flow_director_fd_id_value,
11111 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11112 .f = cmd_flow_director_filter_parsed,
11114 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11115 "director entry on NIC",
11117 (void *)&cmd_flow_director_filter,
11118 (void *)&cmd_flow_director_port_id,
11119 (void *)&cmd_flow_director_mode,
11120 (void *)&cmd_flow_director_mode_ip,
11121 (void *)&cmd_flow_director_ops,
11122 (void *)&cmd_flow_director_flow,
11123 (void *)&cmd_flow_director_flow_type,
11124 (void *)&cmd_flow_director_ether,
11125 (void *)&cmd_flow_director_ether_type,
11126 (void *)&cmd_flow_director_flexbytes,
11127 (void *)&cmd_flow_director_flexbytes_value,
11128 (void *)&cmd_flow_director_drop,
11129 (void *)&cmd_flow_director_pf_vf,
11130 (void *)&cmd_flow_director_queue,
11131 (void *)&cmd_flow_director_queue_id,
11132 (void *)&cmd_flow_director_fd_id,
11133 (void *)&cmd_flow_director_fd_id_value,
11138 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11139 .f = cmd_flow_director_filter_parsed,
11141 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11142 "director entry on NIC",
11144 (void *)&cmd_flow_director_filter,
11145 (void *)&cmd_flow_director_port_id,
11146 (void *)&cmd_flow_director_mode,
11147 (void *)&cmd_flow_director_mode_mac_vlan,
11148 (void *)&cmd_flow_director_ops,
11149 (void *)&cmd_flow_director_mac,
11150 (void *)&cmd_flow_director_mac_addr,
11151 (void *)&cmd_flow_director_vlan,
11152 (void *)&cmd_flow_director_vlan_value,
11153 (void *)&cmd_flow_director_flexbytes,
11154 (void *)&cmd_flow_director_flexbytes_value,
11155 (void *)&cmd_flow_director_drop,
11156 (void *)&cmd_flow_director_queue,
11157 (void *)&cmd_flow_director_queue_id,
11158 (void *)&cmd_flow_director_fd_id,
11159 (void *)&cmd_flow_director_fd_id_value,
11164 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11165 .f = cmd_flow_director_filter_parsed,
11167 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11168 "director entry on NIC",
11170 (void *)&cmd_flow_director_filter,
11171 (void *)&cmd_flow_director_port_id,
11172 (void *)&cmd_flow_director_mode,
11173 (void *)&cmd_flow_director_mode_tunnel,
11174 (void *)&cmd_flow_director_ops,
11175 (void *)&cmd_flow_director_mac,
11176 (void *)&cmd_flow_director_mac_addr,
11177 (void *)&cmd_flow_director_vlan,
11178 (void *)&cmd_flow_director_vlan_value,
11179 (void *)&cmd_flow_director_tunnel,
11180 (void *)&cmd_flow_director_tunnel_type,
11181 (void *)&cmd_flow_director_tunnel_id,
11182 (void *)&cmd_flow_director_tunnel_id_value,
11183 (void *)&cmd_flow_director_flexbytes,
11184 (void *)&cmd_flow_director_flexbytes_value,
11185 (void *)&cmd_flow_director_drop,
11186 (void *)&cmd_flow_director_queue,
11187 (void *)&cmd_flow_director_queue_id,
11188 (void *)&cmd_flow_director_fd_id,
11189 (void *)&cmd_flow_director_fd_id_value,
11194 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11195 .f = cmd_flow_director_filter_parsed,
11197 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11198 "director entry on NIC",
11200 (void *)&cmd_flow_director_filter,
11201 (void *)&cmd_flow_director_port_id,
11202 (void *)&cmd_flow_director_mode,
11203 (void *)&cmd_flow_director_mode_raw,
11204 (void *)&cmd_flow_director_ops,
11205 (void *)&cmd_flow_director_flow,
11206 (void *)&cmd_flow_director_flow_type,
11207 (void *)&cmd_flow_director_drop,
11208 (void *)&cmd_flow_director_queue,
11209 (void *)&cmd_flow_director_queue_id,
11210 (void *)&cmd_flow_director_fd_id,
11211 (void *)&cmd_flow_director_fd_id_value,
11212 (void *)&cmd_flow_director_packet,
11213 (void *)&cmd_flow_director_filepath,
11218 struct cmd_flush_flow_director_result {
11219 cmdline_fixed_string_t flush_flow_director;
11223 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11224 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11225 flush_flow_director, "flush_flow_director");
11226 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11227 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11231 cmd_flush_flow_director_parsed(void *parsed_result,
11232 __attribute__((unused)) struct cmdline *cl,
11233 __attribute__((unused)) void *data)
11235 struct cmd_flow_director_result *res = parsed_result;
11238 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11240 printf("flow director is not supported on port %u.\n",
11245 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11246 RTE_ETH_FILTER_FLUSH, NULL);
11248 printf("flow director table flushing error: (%s)\n",
11252 cmdline_parse_inst_t cmd_flush_flow_director = {
11253 .f = cmd_flush_flow_director_parsed,
11255 .help_str = "flush_flow_director <port_id>: "
11256 "Flush all flow director entries of a device on NIC",
11258 (void *)&cmd_flush_flow_director_flush,
11259 (void *)&cmd_flush_flow_director_port_id,
11264 /* *** deal with flow director mask *** */
11265 struct cmd_flow_director_mask_result {
11266 cmdline_fixed_string_t flow_director_mask;
11268 cmdline_fixed_string_t mode;
11269 cmdline_fixed_string_t mode_value;
11270 cmdline_fixed_string_t vlan;
11271 uint16_t vlan_mask;
11272 cmdline_fixed_string_t src_mask;
11273 cmdline_ipaddr_t ipv4_src;
11274 cmdline_ipaddr_t ipv6_src;
11276 cmdline_fixed_string_t dst_mask;
11277 cmdline_ipaddr_t ipv4_dst;
11278 cmdline_ipaddr_t ipv6_dst;
11280 cmdline_fixed_string_t mac;
11281 uint8_t mac_addr_byte_mask;
11282 cmdline_fixed_string_t tunnel_id;
11283 uint32_t tunnel_id_mask;
11284 cmdline_fixed_string_t tunnel_type;
11285 uint8_t tunnel_type_mask;
11289 cmd_flow_director_mask_parsed(void *parsed_result,
11290 __attribute__((unused)) struct cmdline *cl,
11291 __attribute__((unused)) void *data)
11293 struct cmd_flow_director_mask_result *res = parsed_result;
11294 struct rte_eth_fdir_masks *mask;
11295 struct rte_port *port;
11297 port = &ports[res->port_id];
11298 /** Check if the port is not started **/
11299 if (port->port_status != RTE_PORT_STOPPED) {
11300 printf("Please stop port %d first\n", res->port_id);
11304 mask = &port->dev_conf.fdir_conf.mask;
11306 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11307 if (strcmp(res->mode_value, "MAC-VLAN")) {
11308 printf("Please set mode to MAC-VLAN.\n");
11312 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11313 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11314 if (strcmp(res->mode_value, "Tunnel")) {
11315 printf("Please set mode to Tunnel.\n");
11319 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11320 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11321 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11322 mask->tunnel_type_mask = res->tunnel_type_mask;
11324 if (strcmp(res->mode_value, "IP")) {
11325 printf("Please set mode to IP.\n");
11329 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11330 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11331 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11332 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11333 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11334 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11335 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11338 cmd_reconfig_device_queue(res->port_id, 1, 1);
11341 cmdline_parse_token_string_t cmd_flow_director_mask =
11342 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11343 flow_director_mask, "flow_director_mask");
11344 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11345 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11347 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11348 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11350 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11351 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11352 vlan_mask, UINT16);
11353 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11354 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11355 src_mask, "src_mask");
11356 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11357 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11359 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11360 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11362 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11363 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11365 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11366 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11367 dst_mask, "dst_mask");
11368 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11369 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11371 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11372 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11374 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11375 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11378 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11379 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11381 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11382 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11384 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11385 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11386 mode_value, "MAC-VLAN");
11387 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11388 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11389 mode_value, "Tunnel");
11390 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11391 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11393 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11394 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11395 mac_addr_byte_mask, UINT8);
11396 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11397 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11398 tunnel_type, "tunnel-type");
11399 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11400 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11401 tunnel_type_mask, UINT8);
11402 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11403 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11404 tunnel_id, "tunnel-id");
11405 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11406 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11407 tunnel_id_mask, UINT32);
11409 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11410 .f = cmd_flow_director_mask_parsed,
11412 .help_str = "flow_director_mask ... : "
11413 "Set IP mode flow director's mask on NIC",
11415 (void *)&cmd_flow_director_mask,
11416 (void *)&cmd_flow_director_mask_port_id,
11417 (void *)&cmd_flow_director_mask_mode,
11418 (void *)&cmd_flow_director_mask_mode_ip,
11419 (void *)&cmd_flow_director_mask_vlan,
11420 (void *)&cmd_flow_director_mask_vlan_value,
11421 (void *)&cmd_flow_director_mask_src,
11422 (void *)&cmd_flow_director_mask_ipv4_src,
11423 (void *)&cmd_flow_director_mask_ipv6_src,
11424 (void *)&cmd_flow_director_mask_port_src,
11425 (void *)&cmd_flow_director_mask_dst,
11426 (void *)&cmd_flow_director_mask_ipv4_dst,
11427 (void *)&cmd_flow_director_mask_ipv6_dst,
11428 (void *)&cmd_flow_director_mask_port_dst,
11433 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11434 .f = cmd_flow_director_mask_parsed,
11436 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11437 "flow director's mask on NIC",
11439 (void *)&cmd_flow_director_mask,
11440 (void *)&cmd_flow_director_mask_port_id,
11441 (void *)&cmd_flow_director_mask_mode,
11442 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11443 (void *)&cmd_flow_director_mask_vlan,
11444 (void *)&cmd_flow_director_mask_vlan_value,
11449 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11450 .f = cmd_flow_director_mask_parsed,
11452 .help_str = "flow_director_mask ... : Set tunnel mode "
11453 "flow director's mask on NIC",
11455 (void *)&cmd_flow_director_mask,
11456 (void *)&cmd_flow_director_mask_port_id,
11457 (void *)&cmd_flow_director_mask_mode,
11458 (void *)&cmd_flow_director_mask_mode_tunnel,
11459 (void *)&cmd_flow_director_mask_vlan,
11460 (void *)&cmd_flow_director_mask_vlan_value,
11461 (void *)&cmd_flow_director_mask_mac,
11462 (void *)&cmd_flow_director_mask_mac_value,
11463 (void *)&cmd_flow_director_mask_tunnel_type,
11464 (void *)&cmd_flow_director_mask_tunnel_type_value,
11465 (void *)&cmd_flow_director_mask_tunnel_id,
11466 (void *)&cmd_flow_director_mask_tunnel_id_value,
11471 /* *** deal with flow director mask on flexible payload *** */
11472 struct cmd_flow_director_flex_mask_result {
11473 cmdline_fixed_string_t flow_director_flexmask;
11475 cmdline_fixed_string_t flow;
11476 cmdline_fixed_string_t flow_type;
11477 cmdline_fixed_string_t mask;
11481 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11482 __attribute__((unused)) struct cmdline *cl,
11483 __attribute__((unused)) void *data)
11485 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11486 struct rte_eth_fdir_info fdir_info;
11487 struct rte_eth_fdir_flex_mask flex_mask;
11488 struct rte_port *port;
11489 uint64_t flow_type_mask;
11493 port = &ports[res->port_id];
11494 /** Check if the port is not started **/
11495 if (port->port_status != RTE_PORT_STOPPED) {
11496 printf("Please stop port %d first\n", res->port_id);
11500 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11501 ret = parse_flexbytes(res->mask,
11503 RTE_ETH_FDIR_MAX_FLEXLEN);
11505 printf("error: Cannot parse mask input.\n");
11509 memset(&fdir_info, 0, sizeof(fdir_info));
11510 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11511 RTE_ETH_FILTER_INFO, &fdir_info);
11513 printf("Cannot get FDir filter info\n");
11517 if (!strcmp(res->flow_type, "none")) {
11518 /* means don't specify the flow type */
11519 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11520 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11521 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11522 0, sizeof(struct rte_eth_fdir_flex_mask));
11523 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11524 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11526 sizeof(struct rte_eth_fdir_flex_mask));
11527 cmd_reconfig_device_queue(res->port_id, 1, 1);
11530 flow_type_mask = fdir_info.flow_types_mask[0];
11531 if (!strcmp(res->flow_type, "all")) {
11532 if (!flow_type_mask) {
11533 printf("No flow type supported\n");
11536 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11537 if (flow_type_mask & (1ULL << i)) {
11538 flex_mask.flow_type = i;
11539 fdir_set_flex_mask(res->port_id, &flex_mask);
11542 cmd_reconfig_device_queue(res->port_id, 1, 1);
11545 flex_mask.flow_type = str2flowtype(res->flow_type);
11546 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11547 printf("Flow type %s not supported on port %d\n",
11548 res->flow_type, res->port_id);
11551 fdir_set_flex_mask(res->port_id, &flex_mask);
11552 cmd_reconfig_device_queue(res->port_id, 1, 1);
11555 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11556 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11557 flow_director_flexmask,
11558 "flow_director_flex_mask");
11559 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11560 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11562 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11563 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11565 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11566 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11567 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11568 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11569 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11570 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11573 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11574 .f = cmd_flow_director_flex_mask_parsed,
11576 .help_str = "flow_director_flex_mask ... : "
11577 "Set flow director's flex mask on NIC",
11579 (void *)&cmd_flow_director_flexmask,
11580 (void *)&cmd_flow_director_flexmask_port_id,
11581 (void *)&cmd_flow_director_flexmask_flow,
11582 (void *)&cmd_flow_director_flexmask_flow_type,
11583 (void *)&cmd_flow_director_flexmask_mask,
11588 /* *** deal with flow director flexible payload configuration *** */
11589 struct cmd_flow_director_flexpayload_result {
11590 cmdline_fixed_string_t flow_director_flexpayload;
11592 cmdline_fixed_string_t payload_layer;
11593 cmdline_fixed_string_t payload_cfg;
11597 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11600 const char *p, *p0 = q_arg;
11602 unsigned long int_fld;
11603 char *str_fld[max_num];
11608 p = strchr(p0, '(');
11612 p0 = strchr(p, ')');
11617 if (size >= sizeof(s))
11620 snprintf(s, sizeof(s), "%.*s", size, p);
11621 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11622 if (ret < 0 || ret > max_num)
11624 for (i = 0; i < ret; i++) {
11626 int_fld = strtoul(str_fld[i], &end, 0);
11627 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11629 offsets[i] = (uint16_t)int_fld;
11635 cmd_flow_director_flxpld_parsed(void *parsed_result,
11636 __attribute__((unused)) struct cmdline *cl,
11637 __attribute__((unused)) void *data)
11639 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11640 struct rte_eth_flex_payload_cfg flex_cfg;
11641 struct rte_port *port;
11644 port = &ports[res->port_id];
11645 /** Check if the port is not started **/
11646 if (port->port_status != RTE_PORT_STOPPED) {
11647 printf("Please stop port %d first\n", res->port_id);
11651 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11653 if (!strcmp(res->payload_layer, "raw"))
11654 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11655 else if (!strcmp(res->payload_layer, "l2"))
11656 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11657 else if (!strcmp(res->payload_layer, "l3"))
11658 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11659 else if (!strcmp(res->payload_layer, "l4"))
11660 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11662 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11663 RTE_ETH_FDIR_MAX_FLEXLEN);
11665 printf("error: Cannot parse flex payload input.\n");
11669 fdir_set_flex_payload(res->port_id, &flex_cfg);
11670 cmd_reconfig_device_queue(res->port_id, 1, 1);
11673 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11674 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11675 flow_director_flexpayload,
11676 "flow_director_flex_payload");
11677 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11678 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11680 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11681 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11682 payload_layer, "raw#l2#l3#l4");
11683 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11684 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11685 payload_cfg, NULL);
11687 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11688 .f = cmd_flow_director_flxpld_parsed,
11690 .help_str = "flow_director_flexpayload ... : "
11691 "Set flow director's flex payload on NIC",
11693 (void *)&cmd_flow_director_flexpayload,
11694 (void *)&cmd_flow_director_flexpayload_port_id,
11695 (void *)&cmd_flow_director_flexpayload_payload_layer,
11696 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11701 /* Generic flow interface command. */
11702 extern cmdline_parse_inst_t cmd_flow;
11704 /* *** Classification Filters Control *** */
11705 /* *** Get symmetric hash enable per port *** */
11706 struct cmd_get_sym_hash_ena_per_port_result {
11707 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11712 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11713 __rte_unused struct cmdline *cl,
11714 __rte_unused void *data)
11716 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11717 struct rte_eth_hash_filter_info info;
11720 if (rte_eth_dev_filter_supported(res->port_id,
11721 RTE_ETH_FILTER_HASH) < 0) {
11722 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11727 memset(&info, 0, sizeof(info));
11728 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11729 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11730 RTE_ETH_FILTER_GET, &info);
11733 printf("Cannot get symmetric hash enable per port "
11734 "on port %u\n", res->port_id);
11738 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11739 "enabled" : "disabled", res->port_id);
11742 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11743 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11744 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11745 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11746 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11749 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11750 .f = cmd_get_sym_hash_per_port_parsed,
11752 .help_str = "get_sym_hash_ena_per_port <port_id>",
11754 (void *)&cmd_get_sym_hash_ena_per_port_all,
11755 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11760 /* *** Set symmetric hash enable per port *** */
11761 struct cmd_set_sym_hash_ena_per_port_result {
11762 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11763 cmdline_fixed_string_t enable;
11768 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11769 __rte_unused struct cmdline *cl,
11770 __rte_unused void *data)
11772 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11773 struct rte_eth_hash_filter_info info;
11776 if (rte_eth_dev_filter_supported(res->port_id,
11777 RTE_ETH_FILTER_HASH) < 0) {
11778 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11783 memset(&info, 0, sizeof(info));
11784 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11785 if (!strcmp(res->enable, "enable"))
11786 info.info.enable = 1;
11787 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11788 RTE_ETH_FILTER_SET, &info);
11790 printf("Cannot set symmetric hash enable per port on "
11791 "port %u\n", res->port_id);
11794 printf("Symmetric hash has been set to %s on port %u\n",
11795 res->enable, res->port_id);
11798 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11799 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11800 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11801 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11802 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11804 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11805 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11806 enable, "enable#disable");
11808 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11809 .f = cmd_set_sym_hash_per_port_parsed,
11811 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11813 (void *)&cmd_set_sym_hash_ena_per_port_all,
11814 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11815 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11820 /* Get global config of hash function */
11821 struct cmd_get_hash_global_config_result {
11822 cmdline_fixed_string_t get_hash_global_config;
11827 flowtype_to_str(uint16_t ftype)
11833 } ftype_table[] = {
11834 {"ipv4", RTE_ETH_FLOW_IPV4},
11835 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11836 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11837 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11838 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11839 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11840 {"ipv6", RTE_ETH_FLOW_IPV6},
11841 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11842 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11843 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11844 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11845 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11846 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11847 {"port", RTE_ETH_FLOW_PORT},
11848 {"vxlan", RTE_ETH_FLOW_VXLAN},
11849 {"geneve", RTE_ETH_FLOW_GENEVE},
11850 {"nvgre", RTE_ETH_FLOW_NVGRE},
11853 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11854 if (ftype_table[i].ftype == ftype)
11855 return ftype_table[i].str;
11862 cmd_get_hash_global_config_parsed(void *parsed_result,
11863 __rte_unused struct cmdline *cl,
11864 __rte_unused void *data)
11866 struct cmd_get_hash_global_config_result *res = parsed_result;
11867 struct rte_eth_hash_filter_info info;
11868 uint32_t idx, offset;
11873 if (rte_eth_dev_filter_supported(res->port_id,
11874 RTE_ETH_FILTER_HASH) < 0) {
11875 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11880 memset(&info, 0, sizeof(info));
11881 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11882 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11883 RTE_ETH_FILTER_GET, &info);
11885 printf("Cannot get hash global configurations by port %d\n",
11890 switch (info.info.global_conf.hash_func) {
11891 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11892 printf("Hash function is Toeplitz\n");
11894 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11895 printf("Hash function is Simple XOR\n");
11898 printf("Unknown hash function\n");
11902 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11903 idx = i / UINT64_BIT;
11904 offset = i % UINT64_BIT;
11905 if (!(info.info.global_conf.valid_bit_mask[idx] &
11908 str = flowtype_to_str(i);
11911 printf("Symmetric hash is %s globally for flow type %s "
11913 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11914 (1ULL << offset)) ? "enabled" : "disabled"), str,
11919 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11920 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11921 get_hash_global_config, "get_hash_global_config");
11922 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11923 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11926 cmdline_parse_inst_t cmd_get_hash_global_config = {
11927 .f = cmd_get_hash_global_config_parsed,
11929 .help_str = "get_hash_global_config <port_id>",
11931 (void *)&cmd_get_hash_global_config_all,
11932 (void *)&cmd_get_hash_global_config_port_id,
11937 /* Set global config of hash function */
11938 struct cmd_set_hash_global_config_result {
11939 cmdline_fixed_string_t set_hash_global_config;
11941 cmdline_fixed_string_t hash_func;
11942 cmdline_fixed_string_t flow_type;
11943 cmdline_fixed_string_t enable;
11947 cmd_set_hash_global_config_parsed(void *parsed_result,
11948 __rte_unused struct cmdline *cl,
11949 __rte_unused void *data)
11951 struct cmd_set_hash_global_config_result *res = parsed_result;
11952 struct rte_eth_hash_filter_info info;
11953 uint32_t ftype, idx, offset;
11956 if (rte_eth_dev_filter_supported(res->port_id,
11957 RTE_ETH_FILTER_HASH) < 0) {
11958 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 if (!strcmp(res->hash_func, "toeplitz"))
11965 info.info.global_conf.hash_func =
11966 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11967 else if (!strcmp(res->hash_func, "simple_xor"))
11968 info.info.global_conf.hash_func =
11969 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11970 else if (!strcmp(res->hash_func, "default"))
11971 info.info.global_conf.hash_func =
11972 RTE_ETH_HASH_FUNCTION_DEFAULT;
11974 ftype = str2flowtype(res->flow_type);
11975 idx = ftype / UINT64_BIT;
11976 offset = ftype % UINT64_BIT;
11977 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
11978 if (!strcmp(res->enable, "enable"))
11979 info.info.global_conf.sym_hash_enable_mask[idx] |=
11981 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11982 RTE_ETH_FILTER_SET, &info);
11984 printf("Cannot set global hash configurations by port %d\n",
11987 printf("Global hash configurations have been set "
11988 "succcessfully by port %d\n", res->port_id);
11991 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11992 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11993 set_hash_global_config, "set_hash_global_config");
11994 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11995 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11997 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11998 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11999 hash_func, "toeplitz#simple_xor#default");
12000 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12001 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12003 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12004 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12005 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12006 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12007 enable, "enable#disable");
12009 cmdline_parse_inst_t cmd_set_hash_global_config = {
12010 .f = cmd_set_hash_global_config_parsed,
12012 .help_str = "set_hash_global_config <port_id> "
12013 "toeplitz|simple_xor|default "
12014 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12015 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12016 "l2_payload enable|disable",
12018 (void *)&cmd_set_hash_global_config_all,
12019 (void *)&cmd_set_hash_global_config_port_id,
12020 (void *)&cmd_set_hash_global_config_hash_func,
12021 (void *)&cmd_set_hash_global_config_flow_type,
12022 (void *)&cmd_set_hash_global_config_enable,
12027 /* Set hash input set */
12028 struct cmd_set_hash_input_set_result {
12029 cmdline_fixed_string_t set_hash_input_set;
12031 cmdline_fixed_string_t flow_type;
12032 cmdline_fixed_string_t inset_field;
12033 cmdline_fixed_string_t select;
12036 static enum rte_eth_input_set_field
12037 str2inset(char *string)
12041 static const struct {
12043 enum rte_eth_input_set_field inset;
12044 } inset_table[] = {
12045 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12046 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12047 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12048 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12049 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12050 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12051 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12052 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12053 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12054 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12055 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12056 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12057 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12058 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12059 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12060 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12061 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12062 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12063 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12064 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12065 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12066 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12067 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12068 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12069 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12070 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12071 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12072 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12073 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12074 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12075 {"none", RTE_ETH_INPUT_SET_NONE},
12078 for (i = 0; i < RTE_DIM(inset_table); i++) {
12079 if (!strcmp(string, inset_table[i].str))
12080 return inset_table[i].inset;
12083 return RTE_ETH_INPUT_SET_UNKNOWN;
12087 cmd_set_hash_input_set_parsed(void *parsed_result,
12088 __rte_unused struct cmdline *cl,
12089 __rte_unused void *data)
12091 struct cmd_set_hash_input_set_result *res = parsed_result;
12092 struct rte_eth_hash_filter_info info;
12094 memset(&info, 0, sizeof(info));
12095 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12096 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12097 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12098 info.info.input_set_conf.inset_size = 1;
12099 if (!strcmp(res->select, "select"))
12100 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12101 else if (!strcmp(res->select, "add"))
12102 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12103 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12104 RTE_ETH_FILTER_SET, &info);
12107 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12108 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12109 set_hash_input_set, "set_hash_input_set");
12110 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12111 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12113 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12114 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12116 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12117 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12119 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12120 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12121 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12122 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12123 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12125 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12126 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12127 select, "select#add");
12129 cmdline_parse_inst_t cmd_set_hash_input_set = {
12130 .f = cmd_set_hash_input_set_parsed,
12132 .help_str = "set_hash_input_set <port_id> "
12133 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12134 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12135 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12136 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12137 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12138 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12139 "fld-7th|fld-8th|none select|add",
12141 (void *)&cmd_set_hash_input_set_cmd,
12142 (void *)&cmd_set_hash_input_set_port_id,
12143 (void *)&cmd_set_hash_input_set_flow_type,
12144 (void *)&cmd_set_hash_input_set_field,
12145 (void *)&cmd_set_hash_input_set_select,
12150 /* Set flow director input set */
12151 struct cmd_set_fdir_input_set_result {
12152 cmdline_fixed_string_t set_fdir_input_set;
12154 cmdline_fixed_string_t flow_type;
12155 cmdline_fixed_string_t inset_field;
12156 cmdline_fixed_string_t select;
12160 cmd_set_fdir_input_set_parsed(void *parsed_result,
12161 __rte_unused struct cmdline *cl,
12162 __rte_unused void *data)
12164 struct cmd_set_fdir_input_set_result *res = parsed_result;
12165 struct rte_eth_fdir_filter_info info;
12167 memset(&info, 0, sizeof(info));
12168 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12169 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12170 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12171 info.info.input_set_conf.inset_size = 1;
12172 if (!strcmp(res->select, "select"))
12173 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12174 else if (!strcmp(res->select, "add"))
12175 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12176 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12177 RTE_ETH_FILTER_SET, &info);
12180 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12181 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12182 set_fdir_input_set, "set_fdir_input_set");
12183 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12184 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12186 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12187 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12189 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12190 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12191 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12192 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12194 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12195 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12196 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12197 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12198 "sctp-veri-tag#none");
12199 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12200 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12201 select, "select#add");
12203 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12204 .f = cmd_set_fdir_input_set_parsed,
12206 .help_str = "set_fdir_input_set <port_id> "
12207 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12208 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12209 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12210 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12211 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12212 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12213 "sctp-veri-tag|none select|add",
12215 (void *)&cmd_set_fdir_input_set_cmd,
12216 (void *)&cmd_set_fdir_input_set_port_id,
12217 (void *)&cmd_set_fdir_input_set_flow_type,
12218 (void *)&cmd_set_fdir_input_set_field,
12219 (void *)&cmd_set_fdir_input_set_select,
12224 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12225 struct cmd_mcast_addr_result {
12226 cmdline_fixed_string_t mcast_addr_cmd;
12227 cmdline_fixed_string_t what;
12229 struct ether_addr mc_addr;
12232 static void cmd_mcast_addr_parsed(void *parsed_result,
12233 __attribute__((unused)) struct cmdline *cl,
12234 __attribute__((unused)) void *data)
12236 struct cmd_mcast_addr_result *res = parsed_result;
12238 if (!is_multicast_ether_addr(&res->mc_addr)) {
12239 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12240 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12241 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12242 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12245 if (strcmp(res->what, "add") == 0)
12246 mcast_addr_add(res->port_num, &res->mc_addr);
12248 mcast_addr_remove(res->port_num, &res->mc_addr);
12251 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12252 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12253 mcast_addr_cmd, "mcast_addr");
12254 cmdline_parse_token_string_t cmd_mcast_addr_what =
12255 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12257 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12258 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12259 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12260 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12262 cmdline_parse_inst_t cmd_mcast_addr = {
12263 .f = cmd_mcast_addr_parsed,
12265 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12266 "Add/Remove multicast MAC address on port_id",
12268 (void *)&cmd_mcast_addr_cmd,
12269 (void *)&cmd_mcast_addr_what,
12270 (void *)&cmd_mcast_addr_portnum,
12271 (void *)&cmd_mcast_addr_addr,
12276 /* l2 tunnel config
12277 * only support E-tag now.
12280 /* Ether type config */
12281 struct cmd_config_l2_tunnel_eth_type_result {
12282 cmdline_fixed_string_t port;
12283 cmdline_fixed_string_t config;
12284 cmdline_fixed_string_t all;
12286 cmdline_fixed_string_t l2_tunnel;
12287 cmdline_fixed_string_t l2_tunnel_type;
12288 cmdline_fixed_string_t eth_type;
12289 uint16_t eth_type_val;
12292 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12293 TOKEN_STRING_INITIALIZER
12294 (struct cmd_config_l2_tunnel_eth_type_result,
12296 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12297 TOKEN_STRING_INITIALIZER
12298 (struct cmd_config_l2_tunnel_eth_type_result,
12300 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12301 TOKEN_STRING_INITIALIZER
12302 (struct cmd_config_l2_tunnel_eth_type_result,
12304 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12305 TOKEN_NUM_INITIALIZER
12306 (struct cmd_config_l2_tunnel_eth_type_result,
12308 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12309 TOKEN_STRING_INITIALIZER
12310 (struct cmd_config_l2_tunnel_eth_type_result,
12311 l2_tunnel, "l2-tunnel");
12312 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12313 TOKEN_STRING_INITIALIZER
12314 (struct cmd_config_l2_tunnel_eth_type_result,
12315 l2_tunnel_type, "E-tag");
12316 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12317 TOKEN_STRING_INITIALIZER
12318 (struct cmd_config_l2_tunnel_eth_type_result,
12319 eth_type, "ether-type");
12320 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12321 TOKEN_NUM_INITIALIZER
12322 (struct cmd_config_l2_tunnel_eth_type_result,
12323 eth_type_val, UINT16);
12325 static enum rte_eth_tunnel_type
12326 str2fdir_l2_tunnel_type(char *string)
12330 static const struct {
12332 enum rte_eth_tunnel_type type;
12333 } l2_tunnel_type_str[] = {
12334 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12337 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12338 if (!strcmp(l2_tunnel_type_str[i].str, string))
12339 return l2_tunnel_type_str[i].type;
12341 return RTE_TUNNEL_TYPE_NONE;
12344 /* ether type config for all ports */
12346 cmd_config_l2_tunnel_eth_type_all_parsed
12347 (void *parsed_result,
12348 __attribute__((unused)) struct cmdline *cl,
12349 __attribute__((unused)) void *data)
12351 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12352 struct rte_eth_l2_tunnel_conf entry;
12355 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12356 entry.ether_type = res->eth_type_val;
12358 RTE_ETH_FOREACH_DEV(pid) {
12359 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12363 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12364 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12366 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12368 (void *)&cmd_config_l2_tunnel_eth_type_port,
12369 (void *)&cmd_config_l2_tunnel_eth_type_config,
12370 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12371 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12372 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12373 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12374 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12379 /* ether type config for a specific port */
12381 cmd_config_l2_tunnel_eth_type_specific_parsed(
12382 void *parsed_result,
12383 __attribute__((unused)) struct cmdline *cl,
12384 __attribute__((unused)) void *data)
12386 struct cmd_config_l2_tunnel_eth_type_result *res =
12388 struct rte_eth_l2_tunnel_conf entry;
12390 if (port_id_is_invalid(res->id, ENABLED_WARN))
12393 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12394 entry.ether_type = res->eth_type_val;
12396 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12399 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12400 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12402 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12404 (void *)&cmd_config_l2_tunnel_eth_type_port,
12405 (void *)&cmd_config_l2_tunnel_eth_type_config,
12406 (void *)&cmd_config_l2_tunnel_eth_type_id,
12407 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12408 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12409 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12410 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12415 /* Enable/disable l2 tunnel */
12416 struct cmd_config_l2_tunnel_en_dis_result {
12417 cmdline_fixed_string_t port;
12418 cmdline_fixed_string_t config;
12419 cmdline_fixed_string_t all;
12421 cmdline_fixed_string_t l2_tunnel;
12422 cmdline_fixed_string_t l2_tunnel_type;
12423 cmdline_fixed_string_t en_dis;
12426 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12427 TOKEN_STRING_INITIALIZER
12428 (struct cmd_config_l2_tunnel_en_dis_result,
12430 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12431 TOKEN_STRING_INITIALIZER
12432 (struct cmd_config_l2_tunnel_en_dis_result,
12434 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12435 TOKEN_STRING_INITIALIZER
12436 (struct cmd_config_l2_tunnel_en_dis_result,
12438 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12439 TOKEN_NUM_INITIALIZER
12440 (struct cmd_config_l2_tunnel_en_dis_result,
12442 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12443 TOKEN_STRING_INITIALIZER
12444 (struct cmd_config_l2_tunnel_en_dis_result,
12445 l2_tunnel, "l2-tunnel");
12446 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12447 TOKEN_STRING_INITIALIZER
12448 (struct cmd_config_l2_tunnel_en_dis_result,
12449 l2_tunnel_type, "E-tag");
12450 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12451 TOKEN_STRING_INITIALIZER
12452 (struct cmd_config_l2_tunnel_en_dis_result,
12453 en_dis, "enable#disable");
12455 /* enable/disable l2 tunnel for all ports */
12457 cmd_config_l2_tunnel_en_dis_all_parsed(
12458 void *parsed_result,
12459 __attribute__((unused)) struct cmdline *cl,
12460 __attribute__((unused)) void *data)
12462 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12463 struct rte_eth_l2_tunnel_conf entry;
12467 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12469 if (!strcmp("enable", res->en_dis))
12474 RTE_ETH_FOREACH_DEV(pid) {
12475 rte_eth_dev_l2_tunnel_offload_set(pid,
12477 ETH_L2_TUNNEL_ENABLE_MASK,
12482 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12483 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12485 .help_str = "port config all l2-tunnel E-tag enable|disable",
12487 (void *)&cmd_config_l2_tunnel_en_dis_port,
12488 (void *)&cmd_config_l2_tunnel_en_dis_config,
12489 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12490 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12491 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12492 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12497 /* enable/disable l2 tunnel for a port */
12499 cmd_config_l2_tunnel_en_dis_specific_parsed(
12500 void *parsed_result,
12501 __attribute__((unused)) struct cmdline *cl,
12502 __attribute__((unused)) void *data)
12504 struct cmd_config_l2_tunnel_en_dis_result *res =
12506 struct rte_eth_l2_tunnel_conf entry;
12508 if (port_id_is_invalid(res->id, ENABLED_WARN))
12511 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12513 if (!strcmp("enable", res->en_dis))
12514 rte_eth_dev_l2_tunnel_offload_set(res->id,
12516 ETH_L2_TUNNEL_ENABLE_MASK,
12519 rte_eth_dev_l2_tunnel_offload_set(res->id,
12521 ETH_L2_TUNNEL_ENABLE_MASK,
12525 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12526 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12528 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12530 (void *)&cmd_config_l2_tunnel_en_dis_port,
12531 (void *)&cmd_config_l2_tunnel_en_dis_config,
12532 (void *)&cmd_config_l2_tunnel_en_dis_id,
12533 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12534 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12535 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12540 /* E-tag configuration */
12542 /* Common result structure for all E-tag configuration */
12543 struct cmd_config_e_tag_result {
12544 cmdline_fixed_string_t e_tag;
12545 cmdline_fixed_string_t set;
12546 cmdline_fixed_string_t insertion;
12547 cmdline_fixed_string_t stripping;
12548 cmdline_fixed_string_t forwarding;
12549 cmdline_fixed_string_t filter;
12550 cmdline_fixed_string_t add;
12551 cmdline_fixed_string_t del;
12552 cmdline_fixed_string_t on;
12553 cmdline_fixed_string_t off;
12554 cmdline_fixed_string_t on_off;
12555 cmdline_fixed_string_t port_tag_id;
12556 uint32_t port_tag_id_val;
12557 cmdline_fixed_string_t e_tag_id;
12558 uint16_t e_tag_id_val;
12559 cmdline_fixed_string_t dst_pool;
12560 uint8_t dst_pool_val;
12561 cmdline_fixed_string_t port;
12563 cmdline_fixed_string_t vf;
12567 /* Common CLI fields for all E-tag configuration */
12568 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12569 TOKEN_STRING_INITIALIZER
12570 (struct cmd_config_e_tag_result,
12572 cmdline_parse_token_string_t cmd_config_e_tag_set =
12573 TOKEN_STRING_INITIALIZER
12574 (struct cmd_config_e_tag_result,
12576 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12577 TOKEN_STRING_INITIALIZER
12578 (struct cmd_config_e_tag_result,
12579 insertion, "insertion");
12580 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12581 TOKEN_STRING_INITIALIZER
12582 (struct cmd_config_e_tag_result,
12583 stripping, "stripping");
12584 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12585 TOKEN_STRING_INITIALIZER
12586 (struct cmd_config_e_tag_result,
12587 forwarding, "forwarding");
12588 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12589 TOKEN_STRING_INITIALIZER
12590 (struct cmd_config_e_tag_result,
12592 cmdline_parse_token_string_t cmd_config_e_tag_add =
12593 TOKEN_STRING_INITIALIZER
12594 (struct cmd_config_e_tag_result,
12596 cmdline_parse_token_string_t cmd_config_e_tag_del =
12597 TOKEN_STRING_INITIALIZER
12598 (struct cmd_config_e_tag_result,
12600 cmdline_parse_token_string_t cmd_config_e_tag_on =
12601 TOKEN_STRING_INITIALIZER
12602 (struct cmd_config_e_tag_result,
12604 cmdline_parse_token_string_t cmd_config_e_tag_off =
12605 TOKEN_STRING_INITIALIZER
12606 (struct cmd_config_e_tag_result,
12608 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12609 TOKEN_STRING_INITIALIZER
12610 (struct cmd_config_e_tag_result,
12612 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12613 TOKEN_STRING_INITIALIZER
12614 (struct cmd_config_e_tag_result,
12615 port_tag_id, "port-tag-id");
12616 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12617 TOKEN_NUM_INITIALIZER
12618 (struct cmd_config_e_tag_result,
12619 port_tag_id_val, UINT32);
12620 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12621 TOKEN_STRING_INITIALIZER
12622 (struct cmd_config_e_tag_result,
12623 e_tag_id, "e-tag-id");
12624 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12625 TOKEN_NUM_INITIALIZER
12626 (struct cmd_config_e_tag_result,
12627 e_tag_id_val, UINT16);
12628 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12629 TOKEN_STRING_INITIALIZER
12630 (struct cmd_config_e_tag_result,
12631 dst_pool, "dst-pool");
12632 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12633 TOKEN_NUM_INITIALIZER
12634 (struct cmd_config_e_tag_result,
12635 dst_pool_val, UINT8);
12636 cmdline_parse_token_string_t cmd_config_e_tag_port =
12637 TOKEN_STRING_INITIALIZER
12638 (struct cmd_config_e_tag_result,
12640 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12641 TOKEN_NUM_INITIALIZER
12642 (struct cmd_config_e_tag_result,
12644 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12645 TOKEN_STRING_INITIALIZER
12646 (struct cmd_config_e_tag_result,
12648 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12649 TOKEN_NUM_INITIALIZER
12650 (struct cmd_config_e_tag_result,
12653 /* E-tag insertion configuration */
12655 cmd_config_e_tag_insertion_en_parsed(
12656 void *parsed_result,
12657 __attribute__((unused)) struct cmdline *cl,
12658 __attribute__((unused)) void *data)
12660 struct cmd_config_e_tag_result *res =
12662 struct rte_eth_l2_tunnel_conf entry;
12664 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12667 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12668 entry.tunnel_id = res->port_tag_id_val;
12669 entry.vf_id = res->vf_id;
12670 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12672 ETH_L2_TUNNEL_INSERTION_MASK,
12677 cmd_config_e_tag_insertion_dis_parsed(
12678 void *parsed_result,
12679 __attribute__((unused)) struct cmdline *cl,
12680 __attribute__((unused)) void *data)
12682 struct cmd_config_e_tag_result *res =
12684 struct rte_eth_l2_tunnel_conf entry;
12686 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12689 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12690 entry.vf_id = res->vf_id;
12692 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12694 ETH_L2_TUNNEL_INSERTION_MASK,
12698 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12699 .f = cmd_config_e_tag_insertion_en_parsed,
12701 .help_str = "E-tag ... : E-tag insertion enable",
12703 (void *)&cmd_config_e_tag_e_tag,
12704 (void *)&cmd_config_e_tag_set,
12705 (void *)&cmd_config_e_tag_insertion,
12706 (void *)&cmd_config_e_tag_on,
12707 (void *)&cmd_config_e_tag_port_tag_id,
12708 (void *)&cmd_config_e_tag_port_tag_id_val,
12709 (void *)&cmd_config_e_tag_port,
12710 (void *)&cmd_config_e_tag_port_id,
12711 (void *)&cmd_config_e_tag_vf,
12712 (void *)&cmd_config_e_tag_vf_id,
12717 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12718 .f = cmd_config_e_tag_insertion_dis_parsed,
12720 .help_str = "E-tag ... : E-tag insertion disable",
12722 (void *)&cmd_config_e_tag_e_tag,
12723 (void *)&cmd_config_e_tag_set,
12724 (void *)&cmd_config_e_tag_insertion,
12725 (void *)&cmd_config_e_tag_off,
12726 (void *)&cmd_config_e_tag_port,
12727 (void *)&cmd_config_e_tag_port_id,
12728 (void *)&cmd_config_e_tag_vf,
12729 (void *)&cmd_config_e_tag_vf_id,
12734 /* E-tag stripping configuration */
12736 cmd_config_e_tag_stripping_parsed(
12737 void *parsed_result,
12738 __attribute__((unused)) struct cmdline *cl,
12739 __attribute__((unused)) void *data)
12741 struct cmd_config_e_tag_result *res =
12743 struct rte_eth_l2_tunnel_conf entry;
12745 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12748 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12750 if (!strcmp(res->on_off, "on"))
12751 rte_eth_dev_l2_tunnel_offload_set
12754 ETH_L2_TUNNEL_STRIPPING_MASK,
12757 rte_eth_dev_l2_tunnel_offload_set
12760 ETH_L2_TUNNEL_STRIPPING_MASK,
12764 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12765 .f = cmd_config_e_tag_stripping_parsed,
12767 .help_str = "E-tag ... : E-tag stripping enable/disable",
12769 (void *)&cmd_config_e_tag_e_tag,
12770 (void *)&cmd_config_e_tag_set,
12771 (void *)&cmd_config_e_tag_stripping,
12772 (void *)&cmd_config_e_tag_on_off,
12773 (void *)&cmd_config_e_tag_port,
12774 (void *)&cmd_config_e_tag_port_id,
12779 /* E-tag forwarding configuration */
12781 cmd_config_e_tag_forwarding_parsed(
12782 void *parsed_result,
12783 __attribute__((unused)) struct cmdline *cl,
12784 __attribute__((unused)) void *data)
12786 struct cmd_config_e_tag_result *res = parsed_result;
12787 struct rte_eth_l2_tunnel_conf entry;
12789 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12792 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12794 if (!strcmp(res->on_off, "on"))
12795 rte_eth_dev_l2_tunnel_offload_set
12798 ETH_L2_TUNNEL_FORWARDING_MASK,
12801 rte_eth_dev_l2_tunnel_offload_set
12804 ETH_L2_TUNNEL_FORWARDING_MASK,
12808 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12809 .f = cmd_config_e_tag_forwarding_parsed,
12811 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12813 (void *)&cmd_config_e_tag_e_tag,
12814 (void *)&cmd_config_e_tag_set,
12815 (void *)&cmd_config_e_tag_forwarding,
12816 (void *)&cmd_config_e_tag_on_off,
12817 (void *)&cmd_config_e_tag_port,
12818 (void *)&cmd_config_e_tag_port_id,
12823 /* E-tag filter configuration */
12825 cmd_config_e_tag_filter_add_parsed(
12826 void *parsed_result,
12827 __attribute__((unused)) struct cmdline *cl,
12828 __attribute__((unused)) void *data)
12830 struct cmd_config_e_tag_result *res = parsed_result;
12831 struct rte_eth_l2_tunnel_conf entry;
12834 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12837 if (res->e_tag_id_val > 0x3fff) {
12838 printf("e-tag-id must be equal or less than 0x3fff.\n");
12842 ret = rte_eth_dev_filter_supported(res->port_id,
12843 RTE_ETH_FILTER_L2_TUNNEL);
12845 printf("E-tag filter is not supported on port %u.\n",
12850 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12851 entry.tunnel_id = res->e_tag_id_val;
12852 entry.pool = res->dst_pool_val;
12854 ret = rte_eth_dev_filter_ctrl(res->port_id,
12855 RTE_ETH_FILTER_L2_TUNNEL,
12856 RTE_ETH_FILTER_ADD,
12859 printf("E-tag filter programming error: (%s)\n",
12863 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12864 .f = cmd_config_e_tag_filter_add_parsed,
12866 .help_str = "E-tag ... : E-tag filter add",
12868 (void *)&cmd_config_e_tag_e_tag,
12869 (void *)&cmd_config_e_tag_set,
12870 (void *)&cmd_config_e_tag_filter,
12871 (void *)&cmd_config_e_tag_add,
12872 (void *)&cmd_config_e_tag_e_tag_id,
12873 (void *)&cmd_config_e_tag_e_tag_id_val,
12874 (void *)&cmd_config_e_tag_dst_pool,
12875 (void *)&cmd_config_e_tag_dst_pool_val,
12876 (void *)&cmd_config_e_tag_port,
12877 (void *)&cmd_config_e_tag_port_id,
12883 cmd_config_e_tag_filter_del_parsed(
12884 void *parsed_result,
12885 __attribute__((unused)) struct cmdline *cl,
12886 __attribute__((unused)) void *data)
12888 struct cmd_config_e_tag_result *res = parsed_result;
12889 struct rte_eth_l2_tunnel_conf entry;
12892 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12895 if (res->e_tag_id_val > 0x3fff) {
12896 printf("e-tag-id must be less than 0x3fff.\n");
12900 ret = rte_eth_dev_filter_supported(res->port_id,
12901 RTE_ETH_FILTER_L2_TUNNEL);
12903 printf("E-tag filter is not supported on port %u.\n",
12908 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12909 entry.tunnel_id = res->e_tag_id_val;
12911 ret = rte_eth_dev_filter_ctrl(res->port_id,
12912 RTE_ETH_FILTER_L2_TUNNEL,
12913 RTE_ETH_FILTER_DELETE,
12916 printf("E-tag filter programming error: (%s)\n",
12920 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12921 .f = cmd_config_e_tag_filter_del_parsed,
12923 .help_str = "E-tag ... : E-tag filter delete",
12925 (void *)&cmd_config_e_tag_e_tag,
12926 (void *)&cmd_config_e_tag_set,
12927 (void *)&cmd_config_e_tag_filter,
12928 (void *)&cmd_config_e_tag_del,
12929 (void *)&cmd_config_e_tag_e_tag_id,
12930 (void *)&cmd_config_e_tag_e_tag_id_val,
12931 (void *)&cmd_config_e_tag_port,
12932 (void *)&cmd_config_e_tag_port_id,
12937 /* vf vlan anti spoof configuration */
12939 /* Common result structure for vf vlan anti spoof */
12940 struct cmd_vf_vlan_anti_spoof_result {
12941 cmdline_fixed_string_t set;
12942 cmdline_fixed_string_t vf;
12943 cmdline_fixed_string_t vlan;
12944 cmdline_fixed_string_t antispoof;
12947 cmdline_fixed_string_t on_off;
12950 /* Common CLI fields for vf vlan anti spoof enable disable */
12951 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12952 TOKEN_STRING_INITIALIZER
12953 (struct cmd_vf_vlan_anti_spoof_result,
12955 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12956 TOKEN_STRING_INITIALIZER
12957 (struct cmd_vf_vlan_anti_spoof_result,
12959 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12960 TOKEN_STRING_INITIALIZER
12961 (struct cmd_vf_vlan_anti_spoof_result,
12963 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12964 TOKEN_STRING_INITIALIZER
12965 (struct cmd_vf_vlan_anti_spoof_result,
12966 antispoof, "antispoof");
12967 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12968 TOKEN_NUM_INITIALIZER
12969 (struct cmd_vf_vlan_anti_spoof_result,
12971 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12972 TOKEN_NUM_INITIALIZER
12973 (struct cmd_vf_vlan_anti_spoof_result,
12975 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12976 TOKEN_STRING_INITIALIZER
12977 (struct cmd_vf_vlan_anti_spoof_result,
12981 cmd_set_vf_vlan_anti_spoof_parsed(
12982 void *parsed_result,
12983 __attribute__((unused)) struct cmdline *cl,
12984 __attribute__((unused)) void *data)
12986 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12987 int ret = -ENOTSUP;
12989 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12991 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12994 #ifdef RTE_LIBRTE_IXGBE_PMD
12995 if (ret == -ENOTSUP)
12996 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12997 res->vf_id, is_on);
12999 #ifdef RTE_LIBRTE_I40E_PMD
13000 if (ret == -ENOTSUP)
13001 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13002 res->vf_id, is_on);
13004 #ifdef RTE_LIBRTE_BNXT_PMD
13005 if (ret == -ENOTSUP)
13006 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13007 res->vf_id, is_on);
13014 printf("invalid vf_id %d\n", res->vf_id);
13017 printf("invalid port_id %d\n", res->port_id);
13020 printf("function not implemented\n");
13023 printf("programming error: (%s)\n", strerror(-ret));
13027 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13028 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13030 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13032 (void *)&cmd_vf_vlan_anti_spoof_set,
13033 (void *)&cmd_vf_vlan_anti_spoof_vf,
13034 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13035 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13036 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13037 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13038 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13043 /* vf mac anti spoof configuration */
13045 /* Common result structure for vf mac anti spoof */
13046 struct cmd_vf_mac_anti_spoof_result {
13047 cmdline_fixed_string_t set;
13048 cmdline_fixed_string_t vf;
13049 cmdline_fixed_string_t mac;
13050 cmdline_fixed_string_t antispoof;
13053 cmdline_fixed_string_t on_off;
13056 /* Common CLI fields for vf mac anti spoof enable disable */
13057 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13058 TOKEN_STRING_INITIALIZER
13059 (struct cmd_vf_mac_anti_spoof_result,
13061 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13062 TOKEN_STRING_INITIALIZER
13063 (struct cmd_vf_mac_anti_spoof_result,
13065 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13066 TOKEN_STRING_INITIALIZER
13067 (struct cmd_vf_mac_anti_spoof_result,
13069 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13070 TOKEN_STRING_INITIALIZER
13071 (struct cmd_vf_mac_anti_spoof_result,
13072 antispoof, "antispoof");
13073 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13074 TOKEN_NUM_INITIALIZER
13075 (struct cmd_vf_mac_anti_spoof_result,
13077 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13078 TOKEN_NUM_INITIALIZER
13079 (struct cmd_vf_mac_anti_spoof_result,
13081 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13082 TOKEN_STRING_INITIALIZER
13083 (struct cmd_vf_mac_anti_spoof_result,
13087 cmd_set_vf_mac_anti_spoof_parsed(
13088 void *parsed_result,
13089 __attribute__((unused)) struct cmdline *cl,
13090 __attribute__((unused)) void *data)
13092 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13093 int ret = -ENOTSUP;
13095 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13097 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13100 #ifdef RTE_LIBRTE_IXGBE_PMD
13101 if (ret == -ENOTSUP)
13102 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13103 res->vf_id, is_on);
13105 #ifdef RTE_LIBRTE_I40E_PMD
13106 if (ret == -ENOTSUP)
13107 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13108 res->vf_id, is_on);
13110 #ifdef RTE_LIBRTE_BNXT_PMD
13111 if (ret == -ENOTSUP)
13112 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13113 res->vf_id, is_on);
13120 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13123 printf("invalid port_id %d\n", res->port_id);
13126 printf("function not implemented\n");
13129 printf("programming error: (%s)\n", strerror(-ret));
13133 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13134 .f = cmd_set_vf_mac_anti_spoof_parsed,
13136 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13138 (void *)&cmd_vf_mac_anti_spoof_set,
13139 (void *)&cmd_vf_mac_anti_spoof_vf,
13140 (void *)&cmd_vf_mac_anti_spoof_mac,
13141 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13142 (void *)&cmd_vf_mac_anti_spoof_port_id,
13143 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13144 (void *)&cmd_vf_mac_anti_spoof_on_off,
13149 /* vf vlan strip queue configuration */
13151 /* Common result structure for vf mac anti spoof */
13152 struct cmd_vf_vlan_stripq_result {
13153 cmdline_fixed_string_t set;
13154 cmdline_fixed_string_t vf;
13155 cmdline_fixed_string_t vlan;
13156 cmdline_fixed_string_t stripq;
13159 cmdline_fixed_string_t on_off;
13162 /* Common CLI fields for vf vlan strip enable disable */
13163 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13164 TOKEN_STRING_INITIALIZER
13165 (struct cmd_vf_vlan_stripq_result,
13167 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13168 TOKEN_STRING_INITIALIZER
13169 (struct cmd_vf_vlan_stripq_result,
13171 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13172 TOKEN_STRING_INITIALIZER
13173 (struct cmd_vf_vlan_stripq_result,
13175 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13176 TOKEN_STRING_INITIALIZER
13177 (struct cmd_vf_vlan_stripq_result,
13179 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13180 TOKEN_NUM_INITIALIZER
13181 (struct cmd_vf_vlan_stripq_result,
13183 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13184 TOKEN_NUM_INITIALIZER
13185 (struct cmd_vf_vlan_stripq_result,
13187 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13188 TOKEN_STRING_INITIALIZER
13189 (struct cmd_vf_vlan_stripq_result,
13193 cmd_set_vf_vlan_stripq_parsed(
13194 void *parsed_result,
13195 __attribute__((unused)) struct cmdline *cl,
13196 __attribute__((unused)) void *data)
13198 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13199 int ret = -ENOTSUP;
13201 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13203 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13206 #ifdef RTE_LIBRTE_IXGBE_PMD
13207 if (ret == -ENOTSUP)
13208 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13209 res->vf_id, is_on);
13211 #ifdef RTE_LIBRTE_I40E_PMD
13212 if (ret == -ENOTSUP)
13213 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13214 res->vf_id, is_on);
13216 #ifdef RTE_LIBRTE_BNXT_PMD
13217 if (ret == -ENOTSUP)
13218 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13219 res->vf_id, is_on);
13226 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13229 printf("invalid port_id %d\n", res->port_id);
13232 printf("function not implemented\n");
13235 printf("programming error: (%s)\n", strerror(-ret));
13239 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13240 .f = cmd_set_vf_vlan_stripq_parsed,
13242 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13244 (void *)&cmd_vf_vlan_stripq_set,
13245 (void *)&cmd_vf_vlan_stripq_vf,
13246 (void *)&cmd_vf_vlan_stripq_vlan,
13247 (void *)&cmd_vf_vlan_stripq_stripq,
13248 (void *)&cmd_vf_vlan_stripq_port_id,
13249 (void *)&cmd_vf_vlan_stripq_vf_id,
13250 (void *)&cmd_vf_vlan_stripq_on_off,
13255 /* vf vlan insert configuration */
13257 /* Common result structure for vf vlan insert */
13258 struct cmd_vf_vlan_insert_result {
13259 cmdline_fixed_string_t set;
13260 cmdline_fixed_string_t vf;
13261 cmdline_fixed_string_t vlan;
13262 cmdline_fixed_string_t insert;
13268 /* Common CLI fields for vf vlan insert enable disable */
13269 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13270 TOKEN_STRING_INITIALIZER
13271 (struct cmd_vf_vlan_insert_result,
13273 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13274 TOKEN_STRING_INITIALIZER
13275 (struct cmd_vf_vlan_insert_result,
13277 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13278 TOKEN_STRING_INITIALIZER
13279 (struct cmd_vf_vlan_insert_result,
13281 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13282 TOKEN_STRING_INITIALIZER
13283 (struct cmd_vf_vlan_insert_result,
13285 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13286 TOKEN_NUM_INITIALIZER
13287 (struct cmd_vf_vlan_insert_result,
13289 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13290 TOKEN_NUM_INITIALIZER
13291 (struct cmd_vf_vlan_insert_result,
13293 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13294 TOKEN_NUM_INITIALIZER
13295 (struct cmd_vf_vlan_insert_result,
13299 cmd_set_vf_vlan_insert_parsed(
13300 void *parsed_result,
13301 __attribute__((unused)) struct cmdline *cl,
13302 __attribute__((unused)) void *data)
13304 struct cmd_vf_vlan_insert_result *res = parsed_result;
13305 int ret = -ENOTSUP;
13307 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13310 #ifdef RTE_LIBRTE_IXGBE_PMD
13311 if (ret == -ENOTSUP)
13312 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13315 #ifdef RTE_LIBRTE_I40E_PMD
13316 if (ret == -ENOTSUP)
13317 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13320 #ifdef RTE_LIBRTE_BNXT_PMD
13321 if (ret == -ENOTSUP)
13322 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13330 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13333 printf("invalid port_id %d\n", res->port_id);
13336 printf("function not implemented\n");
13339 printf("programming error: (%s)\n", strerror(-ret));
13343 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13344 .f = cmd_set_vf_vlan_insert_parsed,
13346 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13348 (void *)&cmd_vf_vlan_insert_set,
13349 (void *)&cmd_vf_vlan_insert_vf,
13350 (void *)&cmd_vf_vlan_insert_vlan,
13351 (void *)&cmd_vf_vlan_insert_insert,
13352 (void *)&cmd_vf_vlan_insert_port_id,
13353 (void *)&cmd_vf_vlan_insert_vf_id,
13354 (void *)&cmd_vf_vlan_insert_vlan_id,
13359 /* tx loopback configuration */
13361 /* Common result structure for tx loopback */
13362 struct cmd_tx_loopback_result {
13363 cmdline_fixed_string_t set;
13364 cmdline_fixed_string_t tx;
13365 cmdline_fixed_string_t loopback;
13367 cmdline_fixed_string_t on_off;
13370 /* Common CLI fields for tx loopback enable disable */
13371 cmdline_parse_token_string_t cmd_tx_loopback_set =
13372 TOKEN_STRING_INITIALIZER
13373 (struct cmd_tx_loopback_result,
13375 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13376 TOKEN_STRING_INITIALIZER
13377 (struct cmd_tx_loopback_result,
13379 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13380 TOKEN_STRING_INITIALIZER
13381 (struct cmd_tx_loopback_result,
13382 loopback, "loopback");
13383 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13384 TOKEN_NUM_INITIALIZER
13385 (struct cmd_tx_loopback_result,
13387 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13388 TOKEN_STRING_INITIALIZER
13389 (struct cmd_tx_loopback_result,
13393 cmd_set_tx_loopback_parsed(
13394 void *parsed_result,
13395 __attribute__((unused)) struct cmdline *cl,
13396 __attribute__((unused)) void *data)
13398 struct cmd_tx_loopback_result *res = parsed_result;
13399 int ret = -ENOTSUP;
13401 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13403 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13406 #ifdef RTE_LIBRTE_IXGBE_PMD
13407 if (ret == -ENOTSUP)
13408 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13410 #ifdef RTE_LIBRTE_I40E_PMD
13411 if (ret == -ENOTSUP)
13412 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13414 #ifdef RTE_LIBRTE_BNXT_PMD
13415 if (ret == -ENOTSUP)
13416 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13418 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13419 if (ret == -ENOTSUP)
13420 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13427 printf("invalid is_on %d\n", is_on);
13430 printf("invalid port_id %d\n", res->port_id);
13433 printf("function not implemented\n");
13436 printf("programming error: (%s)\n", strerror(-ret));
13440 cmdline_parse_inst_t cmd_set_tx_loopback = {
13441 .f = cmd_set_tx_loopback_parsed,
13443 .help_str = "set tx loopback <port_id> on|off",
13445 (void *)&cmd_tx_loopback_set,
13446 (void *)&cmd_tx_loopback_tx,
13447 (void *)&cmd_tx_loopback_loopback,
13448 (void *)&cmd_tx_loopback_port_id,
13449 (void *)&cmd_tx_loopback_on_off,
13454 /* all queues drop enable configuration */
13456 /* Common result structure for all queues drop enable */
13457 struct cmd_all_queues_drop_en_result {
13458 cmdline_fixed_string_t set;
13459 cmdline_fixed_string_t all;
13460 cmdline_fixed_string_t queues;
13461 cmdline_fixed_string_t drop;
13463 cmdline_fixed_string_t on_off;
13466 /* Common CLI fields for tx loopback enable disable */
13467 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13468 TOKEN_STRING_INITIALIZER
13469 (struct cmd_all_queues_drop_en_result,
13471 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13472 TOKEN_STRING_INITIALIZER
13473 (struct cmd_all_queues_drop_en_result,
13475 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13476 TOKEN_STRING_INITIALIZER
13477 (struct cmd_all_queues_drop_en_result,
13479 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13480 TOKEN_STRING_INITIALIZER
13481 (struct cmd_all_queues_drop_en_result,
13483 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13484 TOKEN_NUM_INITIALIZER
13485 (struct cmd_all_queues_drop_en_result,
13487 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13488 TOKEN_STRING_INITIALIZER
13489 (struct cmd_all_queues_drop_en_result,
13493 cmd_set_all_queues_drop_en_parsed(
13494 void *parsed_result,
13495 __attribute__((unused)) struct cmdline *cl,
13496 __attribute__((unused)) void *data)
13498 struct cmd_all_queues_drop_en_result *res = parsed_result;
13499 int ret = -ENOTSUP;
13500 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13502 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13505 #ifdef RTE_LIBRTE_IXGBE_PMD
13506 if (ret == -ENOTSUP)
13507 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13509 #ifdef RTE_LIBRTE_BNXT_PMD
13510 if (ret == -ENOTSUP)
13511 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13517 printf("invalid is_on %d\n", is_on);
13520 printf("invalid port_id %d\n", res->port_id);
13523 printf("function not implemented\n");
13526 printf("programming error: (%s)\n", strerror(-ret));
13530 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13531 .f = cmd_set_all_queues_drop_en_parsed,
13533 .help_str = "set all queues drop <port_id> on|off",
13535 (void *)&cmd_all_queues_drop_en_set,
13536 (void *)&cmd_all_queues_drop_en_all,
13537 (void *)&cmd_all_queues_drop_en_queues,
13538 (void *)&cmd_all_queues_drop_en_drop,
13539 (void *)&cmd_all_queues_drop_en_port_id,
13540 (void *)&cmd_all_queues_drop_en_on_off,
13545 /* vf split drop enable configuration */
13547 /* Common result structure for vf split drop enable */
13548 struct cmd_vf_split_drop_en_result {
13549 cmdline_fixed_string_t set;
13550 cmdline_fixed_string_t vf;
13551 cmdline_fixed_string_t split;
13552 cmdline_fixed_string_t drop;
13555 cmdline_fixed_string_t on_off;
13558 /* Common CLI fields for vf split drop enable disable */
13559 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13560 TOKEN_STRING_INITIALIZER
13561 (struct cmd_vf_split_drop_en_result,
13563 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13564 TOKEN_STRING_INITIALIZER
13565 (struct cmd_vf_split_drop_en_result,
13567 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13568 TOKEN_STRING_INITIALIZER
13569 (struct cmd_vf_split_drop_en_result,
13571 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13572 TOKEN_STRING_INITIALIZER
13573 (struct cmd_vf_split_drop_en_result,
13575 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13576 TOKEN_NUM_INITIALIZER
13577 (struct cmd_vf_split_drop_en_result,
13579 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13580 TOKEN_NUM_INITIALIZER
13581 (struct cmd_vf_split_drop_en_result,
13583 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13584 TOKEN_STRING_INITIALIZER
13585 (struct cmd_vf_split_drop_en_result,
13589 cmd_set_vf_split_drop_en_parsed(
13590 void *parsed_result,
13591 __attribute__((unused)) struct cmdline *cl,
13592 __attribute__((unused)) void *data)
13594 struct cmd_vf_split_drop_en_result *res = parsed_result;
13595 int ret = -ENOTSUP;
13596 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13598 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13601 #ifdef RTE_LIBRTE_IXGBE_PMD
13602 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13609 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13612 printf("invalid port_id %d\n", res->port_id);
13615 printf("not supported on port %d\n", res->port_id);
13618 printf("programming error: (%s)\n", strerror(-ret));
13622 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13623 .f = cmd_set_vf_split_drop_en_parsed,
13625 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13627 (void *)&cmd_vf_split_drop_en_set,
13628 (void *)&cmd_vf_split_drop_en_vf,
13629 (void *)&cmd_vf_split_drop_en_split,
13630 (void *)&cmd_vf_split_drop_en_drop,
13631 (void *)&cmd_vf_split_drop_en_port_id,
13632 (void *)&cmd_vf_split_drop_en_vf_id,
13633 (void *)&cmd_vf_split_drop_en_on_off,
13638 /* vf mac address configuration */
13640 /* Common result structure for vf mac address */
13641 struct cmd_set_vf_mac_addr_result {
13642 cmdline_fixed_string_t set;
13643 cmdline_fixed_string_t vf;
13644 cmdline_fixed_string_t mac;
13645 cmdline_fixed_string_t addr;
13648 struct ether_addr mac_addr;
13652 /* Common CLI fields for vf split drop enable disable */
13653 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13654 TOKEN_STRING_INITIALIZER
13655 (struct cmd_set_vf_mac_addr_result,
13657 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13658 TOKEN_STRING_INITIALIZER
13659 (struct cmd_set_vf_mac_addr_result,
13661 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13662 TOKEN_STRING_INITIALIZER
13663 (struct cmd_set_vf_mac_addr_result,
13665 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13666 TOKEN_STRING_INITIALIZER
13667 (struct cmd_set_vf_mac_addr_result,
13669 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13670 TOKEN_NUM_INITIALIZER
13671 (struct cmd_set_vf_mac_addr_result,
13673 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13674 TOKEN_NUM_INITIALIZER
13675 (struct cmd_set_vf_mac_addr_result,
13677 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13678 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13682 cmd_set_vf_mac_addr_parsed(
13683 void *parsed_result,
13684 __attribute__((unused)) struct cmdline *cl,
13685 __attribute__((unused)) void *data)
13687 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13688 int ret = -ENOTSUP;
13690 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13693 #ifdef RTE_LIBRTE_IXGBE_PMD
13694 if (ret == -ENOTSUP)
13695 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13698 #ifdef RTE_LIBRTE_I40E_PMD
13699 if (ret == -ENOTSUP)
13700 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13703 #ifdef RTE_LIBRTE_BNXT_PMD
13704 if (ret == -ENOTSUP)
13705 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13713 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13716 printf("invalid port_id %d\n", res->port_id);
13719 printf("function not implemented\n");
13722 printf("programming error: (%s)\n", strerror(-ret));
13726 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13727 .f = cmd_set_vf_mac_addr_parsed,
13729 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13731 (void *)&cmd_set_vf_mac_addr_set,
13732 (void *)&cmd_set_vf_mac_addr_vf,
13733 (void *)&cmd_set_vf_mac_addr_mac,
13734 (void *)&cmd_set_vf_mac_addr_addr,
13735 (void *)&cmd_set_vf_mac_addr_port_id,
13736 (void *)&cmd_set_vf_mac_addr_vf_id,
13737 (void *)&cmd_set_vf_mac_addr_mac_addr,
13742 /* MACsec configuration */
13744 /* Common result structure for MACsec offload enable */
13745 struct cmd_macsec_offload_on_result {
13746 cmdline_fixed_string_t set;
13747 cmdline_fixed_string_t macsec;
13748 cmdline_fixed_string_t offload;
13750 cmdline_fixed_string_t on;
13751 cmdline_fixed_string_t encrypt;
13752 cmdline_fixed_string_t en_on_off;
13753 cmdline_fixed_string_t replay_protect;
13754 cmdline_fixed_string_t rp_on_off;
13757 /* Common CLI fields for MACsec offload disable */
13758 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13759 TOKEN_STRING_INITIALIZER
13760 (struct cmd_macsec_offload_on_result,
13762 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13763 TOKEN_STRING_INITIALIZER
13764 (struct cmd_macsec_offload_on_result,
13766 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13767 TOKEN_STRING_INITIALIZER
13768 (struct cmd_macsec_offload_on_result,
13769 offload, "offload");
13770 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13771 TOKEN_NUM_INITIALIZER
13772 (struct cmd_macsec_offload_on_result,
13774 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13775 TOKEN_STRING_INITIALIZER
13776 (struct cmd_macsec_offload_on_result,
13778 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13779 TOKEN_STRING_INITIALIZER
13780 (struct cmd_macsec_offload_on_result,
13781 encrypt, "encrypt");
13782 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13783 TOKEN_STRING_INITIALIZER
13784 (struct cmd_macsec_offload_on_result,
13785 en_on_off, "on#off");
13786 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13787 TOKEN_STRING_INITIALIZER
13788 (struct cmd_macsec_offload_on_result,
13789 replay_protect, "replay-protect");
13790 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13791 TOKEN_STRING_INITIALIZER
13792 (struct cmd_macsec_offload_on_result,
13793 rp_on_off, "on#off");
13796 cmd_set_macsec_offload_on_parsed(
13797 void *parsed_result,
13798 __attribute__((unused)) struct cmdline *cl,
13799 __attribute__((unused)) void *data)
13801 struct cmd_macsec_offload_on_result *res = parsed_result;
13802 int ret = -ENOTSUP;
13803 portid_t port_id = res->port_id;
13804 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13805 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13806 struct rte_eth_dev_info dev_info;
13808 if (port_id_is_invalid(port_id, ENABLED_WARN))
13810 if (!port_is_stopped(port_id)) {
13811 printf("Please stop port %d first\n", port_id);
13815 rte_eth_dev_info_get(port_id, &dev_info);
13816 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13817 #ifdef RTE_LIBRTE_IXGBE_PMD
13818 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13826 ports[port_id].dev_conf.txmode.offloads |=
13827 DEV_TX_OFFLOAD_MACSEC_INSERT;
13828 cmd_reconfig_device_queue(port_id, 1, 1);
13831 printf("invalid port_id %d\n", port_id);
13834 printf("not supported on port %d\n", port_id);
13837 printf("programming error: (%s)\n", strerror(-ret));
13841 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13842 .f = cmd_set_macsec_offload_on_parsed,
13844 .help_str = "set macsec offload <port_id> on "
13845 "encrypt on|off replay-protect on|off",
13847 (void *)&cmd_macsec_offload_on_set,
13848 (void *)&cmd_macsec_offload_on_macsec,
13849 (void *)&cmd_macsec_offload_on_offload,
13850 (void *)&cmd_macsec_offload_on_port_id,
13851 (void *)&cmd_macsec_offload_on_on,
13852 (void *)&cmd_macsec_offload_on_encrypt,
13853 (void *)&cmd_macsec_offload_on_en_on_off,
13854 (void *)&cmd_macsec_offload_on_replay_protect,
13855 (void *)&cmd_macsec_offload_on_rp_on_off,
13860 /* Common result structure for MACsec offload disable */
13861 struct cmd_macsec_offload_off_result {
13862 cmdline_fixed_string_t set;
13863 cmdline_fixed_string_t macsec;
13864 cmdline_fixed_string_t offload;
13866 cmdline_fixed_string_t off;
13869 /* Common CLI fields for MACsec offload disable */
13870 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13871 TOKEN_STRING_INITIALIZER
13872 (struct cmd_macsec_offload_off_result,
13874 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13875 TOKEN_STRING_INITIALIZER
13876 (struct cmd_macsec_offload_off_result,
13878 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13879 TOKEN_STRING_INITIALIZER
13880 (struct cmd_macsec_offload_off_result,
13881 offload, "offload");
13882 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13883 TOKEN_NUM_INITIALIZER
13884 (struct cmd_macsec_offload_off_result,
13886 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13887 TOKEN_STRING_INITIALIZER
13888 (struct cmd_macsec_offload_off_result,
13892 cmd_set_macsec_offload_off_parsed(
13893 void *parsed_result,
13894 __attribute__((unused)) struct cmdline *cl,
13895 __attribute__((unused)) void *data)
13897 struct cmd_macsec_offload_off_result *res = parsed_result;
13898 int ret = -ENOTSUP;
13899 struct rte_eth_dev_info dev_info;
13900 portid_t port_id = res->port_id;
13902 if (port_id_is_invalid(port_id, ENABLED_WARN))
13904 if (!port_is_stopped(port_id)) {
13905 printf("Please stop port %d first\n", port_id);
13909 rte_eth_dev_info_get(port_id, &dev_info);
13910 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13911 #ifdef RTE_LIBRTE_IXGBE_PMD
13912 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13917 ports[port_id].dev_conf.txmode.offloads &=
13918 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13919 cmd_reconfig_device_queue(port_id, 1, 1);
13922 printf("invalid port_id %d\n", port_id);
13925 printf("not supported on port %d\n", port_id);
13928 printf("programming error: (%s)\n", strerror(-ret));
13932 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13933 .f = cmd_set_macsec_offload_off_parsed,
13935 .help_str = "set macsec offload <port_id> off",
13937 (void *)&cmd_macsec_offload_off_set,
13938 (void *)&cmd_macsec_offload_off_macsec,
13939 (void *)&cmd_macsec_offload_off_offload,
13940 (void *)&cmd_macsec_offload_off_port_id,
13941 (void *)&cmd_macsec_offload_off_off,
13946 /* Common result structure for MACsec secure connection configure */
13947 struct cmd_macsec_sc_result {
13948 cmdline_fixed_string_t set;
13949 cmdline_fixed_string_t macsec;
13950 cmdline_fixed_string_t sc;
13951 cmdline_fixed_string_t tx_rx;
13953 struct ether_addr mac;
13957 /* Common CLI fields for MACsec secure connection configure */
13958 cmdline_parse_token_string_t cmd_macsec_sc_set =
13959 TOKEN_STRING_INITIALIZER
13960 (struct cmd_macsec_sc_result,
13962 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13963 TOKEN_STRING_INITIALIZER
13964 (struct cmd_macsec_sc_result,
13966 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13967 TOKEN_STRING_INITIALIZER
13968 (struct cmd_macsec_sc_result,
13970 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13971 TOKEN_STRING_INITIALIZER
13972 (struct cmd_macsec_sc_result,
13974 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13975 TOKEN_NUM_INITIALIZER
13976 (struct cmd_macsec_sc_result,
13978 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13979 TOKEN_ETHERADDR_INITIALIZER
13980 (struct cmd_macsec_sc_result,
13982 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13983 TOKEN_NUM_INITIALIZER
13984 (struct cmd_macsec_sc_result,
13988 cmd_set_macsec_sc_parsed(
13989 void *parsed_result,
13990 __attribute__((unused)) struct cmdline *cl,
13991 __attribute__((unused)) void *data)
13993 struct cmd_macsec_sc_result *res = parsed_result;
13994 int ret = -ENOTSUP;
13995 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13997 #ifdef RTE_LIBRTE_IXGBE_PMD
13999 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14000 res->mac.addr_bytes) :
14001 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14002 res->mac.addr_bytes, res->pi);
14004 RTE_SET_USED(is_tx);
14010 printf("invalid port_id %d\n", res->port_id);
14013 printf("not supported on port %d\n", res->port_id);
14016 printf("programming error: (%s)\n", strerror(-ret));
14020 cmdline_parse_inst_t cmd_set_macsec_sc = {
14021 .f = cmd_set_macsec_sc_parsed,
14023 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14025 (void *)&cmd_macsec_sc_set,
14026 (void *)&cmd_macsec_sc_macsec,
14027 (void *)&cmd_macsec_sc_sc,
14028 (void *)&cmd_macsec_sc_tx_rx,
14029 (void *)&cmd_macsec_sc_port_id,
14030 (void *)&cmd_macsec_sc_mac,
14031 (void *)&cmd_macsec_sc_pi,
14036 /* Common result structure for MACsec secure connection configure */
14037 struct cmd_macsec_sa_result {
14038 cmdline_fixed_string_t set;
14039 cmdline_fixed_string_t macsec;
14040 cmdline_fixed_string_t sa;
14041 cmdline_fixed_string_t tx_rx;
14046 cmdline_fixed_string_t key;
14049 /* Common CLI fields for MACsec secure connection configure */
14050 cmdline_parse_token_string_t cmd_macsec_sa_set =
14051 TOKEN_STRING_INITIALIZER
14052 (struct cmd_macsec_sa_result,
14054 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14055 TOKEN_STRING_INITIALIZER
14056 (struct cmd_macsec_sa_result,
14058 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14059 TOKEN_STRING_INITIALIZER
14060 (struct cmd_macsec_sa_result,
14062 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14063 TOKEN_STRING_INITIALIZER
14064 (struct cmd_macsec_sa_result,
14066 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14067 TOKEN_NUM_INITIALIZER
14068 (struct cmd_macsec_sa_result,
14070 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14071 TOKEN_NUM_INITIALIZER
14072 (struct cmd_macsec_sa_result,
14074 cmdline_parse_token_num_t cmd_macsec_sa_an =
14075 TOKEN_NUM_INITIALIZER
14076 (struct cmd_macsec_sa_result,
14078 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14079 TOKEN_NUM_INITIALIZER
14080 (struct cmd_macsec_sa_result,
14082 cmdline_parse_token_string_t cmd_macsec_sa_key =
14083 TOKEN_STRING_INITIALIZER
14084 (struct cmd_macsec_sa_result,
14088 cmd_set_macsec_sa_parsed(
14089 void *parsed_result,
14090 __attribute__((unused)) struct cmdline *cl,
14091 __attribute__((unused)) void *data)
14093 struct cmd_macsec_sa_result *res = parsed_result;
14094 int ret = -ENOTSUP;
14095 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14096 uint8_t key[16] = { 0 };
14102 key_len = strlen(res->key) / 2;
14106 for (i = 0; i < key_len; i++) {
14107 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14110 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14113 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14116 #ifdef RTE_LIBRTE_IXGBE_PMD
14118 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14119 res->idx, res->an, res->pn, key) :
14120 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14121 res->idx, res->an, res->pn, key);
14123 RTE_SET_USED(is_tx);
14130 printf("invalid idx %d or an %d\n", res->idx, res->an);
14133 printf("invalid port_id %d\n", res->port_id);
14136 printf("not supported on port %d\n", res->port_id);
14139 printf("programming error: (%s)\n", strerror(-ret));
14143 cmdline_parse_inst_t cmd_set_macsec_sa = {
14144 .f = cmd_set_macsec_sa_parsed,
14146 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14148 (void *)&cmd_macsec_sa_set,
14149 (void *)&cmd_macsec_sa_macsec,
14150 (void *)&cmd_macsec_sa_sa,
14151 (void *)&cmd_macsec_sa_tx_rx,
14152 (void *)&cmd_macsec_sa_port_id,
14153 (void *)&cmd_macsec_sa_idx,
14154 (void *)&cmd_macsec_sa_an,
14155 (void *)&cmd_macsec_sa_pn,
14156 (void *)&cmd_macsec_sa_key,
14161 /* VF unicast promiscuous mode configuration */
14163 /* Common result structure for VF unicast promiscuous mode */
14164 struct cmd_vf_promisc_result {
14165 cmdline_fixed_string_t set;
14166 cmdline_fixed_string_t vf;
14167 cmdline_fixed_string_t promisc;
14170 cmdline_fixed_string_t on_off;
14173 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14174 cmdline_parse_token_string_t cmd_vf_promisc_set =
14175 TOKEN_STRING_INITIALIZER
14176 (struct cmd_vf_promisc_result,
14178 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14179 TOKEN_STRING_INITIALIZER
14180 (struct cmd_vf_promisc_result,
14182 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14183 TOKEN_STRING_INITIALIZER
14184 (struct cmd_vf_promisc_result,
14185 promisc, "promisc");
14186 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14187 TOKEN_NUM_INITIALIZER
14188 (struct cmd_vf_promisc_result,
14190 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14191 TOKEN_NUM_INITIALIZER
14192 (struct cmd_vf_promisc_result,
14194 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14195 TOKEN_STRING_INITIALIZER
14196 (struct cmd_vf_promisc_result,
14200 cmd_set_vf_promisc_parsed(
14201 void *parsed_result,
14202 __attribute__((unused)) struct cmdline *cl,
14203 __attribute__((unused)) void *data)
14205 struct cmd_vf_promisc_result *res = parsed_result;
14206 int ret = -ENOTSUP;
14208 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14210 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14213 #ifdef RTE_LIBRTE_I40E_PMD
14214 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14215 res->vf_id, is_on);
14222 printf("invalid vf_id %d\n", res->vf_id);
14225 printf("invalid port_id %d\n", res->port_id);
14228 printf("function not implemented\n");
14231 printf("programming error: (%s)\n", strerror(-ret));
14235 cmdline_parse_inst_t cmd_set_vf_promisc = {
14236 .f = cmd_set_vf_promisc_parsed,
14238 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14239 "Set unicast promiscuous mode for a VF from the PF",
14241 (void *)&cmd_vf_promisc_set,
14242 (void *)&cmd_vf_promisc_vf,
14243 (void *)&cmd_vf_promisc_promisc,
14244 (void *)&cmd_vf_promisc_port_id,
14245 (void *)&cmd_vf_promisc_vf_id,
14246 (void *)&cmd_vf_promisc_on_off,
14251 /* VF multicast promiscuous mode configuration */
14253 /* Common result structure for VF multicast promiscuous mode */
14254 struct cmd_vf_allmulti_result {
14255 cmdline_fixed_string_t set;
14256 cmdline_fixed_string_t vf;
14257 cmdline_fixed_string_t allmulti;
14260 cmdline_fixed_string_t on_off;
14263 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14264 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14265 TOKEN_STRING_INITIALIZER
14266 (struct cmd_vf_allmulti_result,
14268 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14269 TOKEN_STRING_INITIALIZER
14270 (struct cmd_vf_allmulti_result,
14272 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14273 TOKEN_STRING_INITIALIZER
14274 (struct cmd_vf_allmulti_result,
14275 allmulti, "allmulti");
14276 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14277 TOKEN_NUM_INITIALIZER
14278 (struct cmd_vf_allmulti_result,
14280 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14281 TOKEN_NUM_INITIALIZER
14282 (struct cmd_vf_allmulti_result,
14284 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14285 TOKEN_STRING_INITIALIZER
14286 (struct cmd_vf_allmulti_result,
14290 cmd_set_vf_allmulti_parsed(
14291 void *parsed_result,
14292 __attribute__((unused)) struct cmdline *cl,
14293 __attribute__((unused)) void *data)
14295 struct cmd_vf_allmulti_result *res = parsed_result;
14296 int ret = -ENOTSUP;
14298 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14300 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14303 #ifdef RTE_LIBRTE_I40E_PMD
14304 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14305 res->vf_id, is_on);
14312 printf("invalid vf_id %d\n", res->vf_id);
14315 printf("invalid port_id %d\n", res->port_id);
14318 printf("function not implemented\n");
14321 printf("programming error: (%s)\n", strerror(-ret));
14325 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14326 .f = cmd_set_vf_allmulti_parsed,
14328 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14329 "Set multicast promiscuous mode for a VF from the PF",
14331 (void *)&cmd_vf_allmulti_set,
14332 (void *)&cmd_vf_allmulti_vf,
14333 (void *)&cmd_vf_allmulti_allmulti,
14334 (void *)&cmd_vf_allmulti_port_id,
14335 (void *)&cmd_vf_allmulti_vf_id,
14336 (void *)&cmd_vf_allmulti_on_off,
14341 /* vf broadcast mode configuration */
14343 /* Common result structure for vf broadcast */
14344 struct cmd_set_vf_broadcast_result {
14345 cmdline_fixed_string_t set;
14346 cmdline_fixed_string_t vf;
14347 cmdline_fixed_string_t broadcast;
14350 cmdline_fixed_string_t on_off;
14353 /* Common CLI fields for vf broadcast enable disable */
14354 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14355 TOKEN_STRING_INITIALIZER
14356 (struct cmd_set_vf_broadcast_result,
14358 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14359 TOKEN_STRING_INITIALIZER
14360 (struct cmd_set_vf_broadcast_result,
14362 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14363 TOKEN_STRING_INITIALIZER
14364 (struct cmd_set_vf_broadcast_result,
14365 broadcast, "broadcast");
14366 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14367 TOKEN_NUM_INITIALIZER
14368 (struct cmd_set_vf_broadcast_result,
14370 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14371 TOKEN_NUM_INITIALIZER
14372 (struct cmd_set_vf_broadcast_result,
14374 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14375 TOKEN_STRING_INITIALIZER
14376 (struct cmd_set_vf_broadcast_result,
14380 cmd_set_vf_broadcast_parsed(
14381 void *parsed_result,
14382 __attribute__((unused)) struct cmdline *cl,
14383 __attribute__((unused)) void *data)
14385 struct cmd_set_vf_broadcast_result *res = parsed_result;
14386 int ret = -ENOTSUP;
14388 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14390 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14393 #ifdef RTE_LIBRTE_I40E_PMD
14394 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14395 res->vf_id, is_on);
14402 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14405 printf("invalid port_id %d\n", res->port_id);
14408 printf("function not implemented\n");
14411 printf("programming error: (%s)\n", strerror(-ret));
14415 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14416 .f = cmd_set_vf_broadcast_parsed,
14418 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14420 (void *)&cmd_set_vf_broadcast_set,
14421 (void *)&cmd_set_vf_broadcast_vf,
14422 (void *)&cmd_set_vf_broadcast_broadcast,
14423 (void *)&cmd_set_vf_broadcast_port_id,
14424 (void *)&cmd_set_vf_broadcast_vf_id,
14425 (void *)&cmd_set_vf_broadcast_on_off,
14430 /* vf vlan tag configuration */
14432 /* Common result structure for vf vlan tag */
14433 struct cmd_set_vf_vlan_tag_result {
14434 cmdline_fixed_string_t set;
14435 cmdline_fixed_string_t vf;
14436 cmdline_fixed_string_t vlan;
14437 cmdline_fixed_string_t tag;
14440 cmdline_fixed_string_t on_off;
14443 /* Common CLI fields for vf vlan tag enable disable */
14444 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14445 TOKEN_STRING_INITIALIZER
14446 (struct cmd_set_vf_vlan_tag_result,
14448 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14449 TOKEN_STRING_INITIALIZER
14450 (struct cmd_set_vf_vlan_tag_result,
14452 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14453 TOKEN_STRING_INITIALIZER
14454 (struct cmd_set_vf_vlan_tag_result,
14456 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14457 TOKEN_STRING_INITIALIZER
14458 (struct cmd_set_vf_vlan_tag_result,
14460 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14461 TOKEN_NUM_INITIALIZER
14462 (struct cmd_set_vf_vlan_tag_result,
14464 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14465 TOKEN_NUM_INITIALIZER
14466 (struct cmd_set_vf_vlan_tag_result,
14468 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14469 TOKEN_STRING_INITIALIZER
14470 (struct cmd_set_vf_vlan_tag_result,
14474 cmd_set_vf_vlan_tag_parsed(
14475 void *parsed_result,
14476 __attribute__((unused)) struct cmdline *cl,
14477 __attribute__((unused)) void *data)
14479 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14480 int ret = -ENOTSUP;
14482 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14484 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14487 #ifdef RTE_LIBRTE_I40E_PMD
14488 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14489 res->vf_id, is_on);
14496 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14499 printf("invalid port_id %d\n", res->port_id);
14502 printf("function not implemented\n");
14505 printf("programming error: (%s)\n", strerror(-ret));
14509 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14510 .f = cmd_set_vf_vlan_tag_parsed,
14512 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14514 (void *)&cmd_set_vf_vlan_tag_set,
14515 (void *)&cmd_set_vf_vlan_tag_vf,
14516 (void *)&cmd_set_vf_vlan_tag_vlan,
14517 (void *)&cmd_set_vf_vlan_tag_tag,
14518 (void *)&cmd_set_vf_vlan_tag_port_id,
14519 (void *)&cmd_set_vf_vlan_tag_vf_id,
14520 (void *)&cmd_set_vf_vlan_tag_on_off,
14525 /* Common definition of VF and TC TX bandwidth configuration */
14526 struct cmd_vf_tc_bw_result {
14527 cmdline_fixed_string_t set;
14528 cmdline_fixed_string_t vf;
14529 cmdline_fixed_string_t tc;
14530 cmdline_fixed_string_t tx;
14531 cmdline_fixed_string_t min_bw;
14532 cmdline_fixed_string_t max_bw;
14533 cmdline_fixed_string_t strict_link_prio;
14538 cmdline_fixed_string_t bw_list;
14542 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14543 TOKEN_STRING_INITIALIZER
14544 (struct cmd_vf_tc_bw_result,
14546 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14547 TOKEN_STRING_INITIALIZER
14548 (struct cmd_vf_tc_bw_result,
14550 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14551 TOKEN_STRING_INITIALIZER
14552 (struct cmd_vf_tc_bw_result,
14554 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14555 TOKEN_STRING_INITIALIZER
14556 (struct cmd_vf_tc_bw_result,
14558 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14559 TOKEN_STRING_INITIALIZER
14560 (struct cmd_vf_tc_bw_result,
14561 strict_link_prio, "strict-link-priority");
14562 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14563 TOKEN_STRING_INITIALIZER
14564 (struct cmd_vf_tc_bw_result,
14565 min_bw, "min-bandwidth");
14566 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14567 TOKEN_STRING_INITIALIZER
14568 (struct cmd_vf_tc_bw_result,
14569 max_bw, "max-bandwidth");
14570 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14571 TOKEN_NUM_INITIALIZER
14572 (struct cmd_vf_tc_bw_result,
14574 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14575 TOKEN_NUM_INITIALIZER
14576 (struct cmd_vf_tc_bw_result,
14578 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14579 TOKEN_NUM_INITIALIZER
14580 (struct cmd_vf_tc_bw_result,
14582 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14583 TOKEN_NUM_INITIALIZER
14584 (struct cmd_vf_tc_bw_result,
14586 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14587 TOKEN_STRING_INITIALIZER
14588 (struct cmd_vf_tc_bw_result,
14590 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14591 TOKEN_NUM_INITIALIZER
14592 (struct cmd_vf_tc_bw_result,
14595 /* VF max bandwidth setting */
14597 cmd_vf_max_bw_parsed(
14598 void *parsed_result,
14599 __attribute__((unused)) struct cmdline *cl,
14600 __attribute__((unused)) void *data)
14602 struct cmd_vf_tc_bw_result *res = parsed_result;
14603 int ret = -ENOTSUP;
14605 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14608 #ifdef RTE_LIBRTE_I40E_PMD
14609 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14610 res->vf_id, res->bw);
14617 printf("invalid vf_id %d or bandwidth %d\n",
14618 res->vf_id, res->bw);
14621 printf("invalid port_id %d\n", res->port_id);
14624 printf("function not implemented\n");
14627 printf("programming error: (%s)\n", strerror(-ret));
14631 cmdline_parse_inst_t cmd_vf_max_bw = {
14632 .f = cmd_vf_max_bw_parsed,
14634 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14636 (void *)&cmd_vf_tc_bw_set,
14637 (void *)&cmd_vf_tc_bw_vf,
14638 (void *)&cmd_vf_tc_bw_tx,
14639 (void *)&cmd_vf_tc_bw_max_bw,
14640 (void *)&cmd_vf_tc_bw_port_id,
14641 (void *)&cmd_vf_tc_bw_vf_id,
14642 (void *)&cmd_vf_tc_bw_bw,
14648 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14653 const char *p, *p0 = str;
14660 p = strchr(p0, '(');
14662 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14666 p0 = strchr(p, ')');
14668 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14672 if (size >= sizeof(s)) {
14673 printf("The string size exceeds the internal buffer size\n");
14676 snprintf(s, sizeof(s), "%.*s", size, p);
14677 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14679 printf("Failed to get the bandwidth list. ");
14683 for (i = 0; i < ret; i++)
14684 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14689 /* TC min bandwidth setting */
14691 cmd_vf_tc_min_bw_parsed(
14692 void *parsed_result,
14693 __attribute__((unused)) struct cmdline *cl,
14694 __attribute__((unused)) void *data)
14696 struct cmd_vf_tc_bw_result *res = parsed_result;
14699 int ret = -ENOTSUP;
14701 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14704 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14708 #ifdef RTE_LIBRTE_I40E_PMD
14709 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14717 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14720 printf("invalid port_id %d\n", res->port_id);
14723 printf("function not implemented\n");
14726 printf("programming error: (%s)\n", strerror(-ret));
14730 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14731 .f = cmd_vf_tc_min_bw_parsed,
14733 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14734 " <bw1, bw2, ...>",
14736 (void *)&cmd_vf_tc_bw_set,
14737 (void *)&cmd_vf_tc_bw_vf,
14738 (void *)&cmd_vf_tc_bw_tc,
14739 (void *)&cmd_vf_tc_bw_tx,
14740 (void *)&cmd_vf_tc_bw_min_bw,
14741 (void *)&cmd_vf_tc_bw_port_id,
14742 (void *)&cmd_vf_tc_bw_vf_id,
14743 (void *)&cmd_vf_tc_bw_bw_list,
14749 cmd_tc_min_bw_parsed(
14750 void *parsed_result,
14751 __attribute__((unused)) struct cmdline *cl,
14752 __attribute__((unused)) void *data)
14754 struct cmd_vf_tc_bw_result *res = parsed_result;
14755 struct rte_port *port;
14758 int ret = -ENOTSUP;
14760 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14763 port = &ports[res->port_id];
14764 /** Check if the port is not started **/
14765 if (port->port_status != RTE_PORT_STOPPED) {
14766 printf("Please stop port %d first\n", res->port_id);
14770 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14774 #ifdef RTE_LIBRTE_IXGBE_PMD
14775 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14782 printf("invalid bandwidth\n");
14785 printf("invalid port_id %d\n", res->port_id);
14788 printf("function not implemented\n");
14791 printf("programming error: (%s)\n", strerror(-ret));
14795 cmdline_parse_inst_t cmd_tc_min_bw = {
14796 .f = cmd_tc_min_bw_parsed,
14798 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14800 (void *)&cmd_vf_tc_bw_set,
14801 (void *)&cmd_vf_tc_bw_tc,
14802 (void *)&cmd_vf_tc_bw_tx,
14803 (void *)&cmd_vf_tc_bw_min_bw,
14804 (void *)&cmd_vf_tc_bw_port_id,
14805 (void *)&cmd_vf_tc_bw_bw_list,
14810 /* TC max bandwidth setting */
14812 cmd_vf_tc_max_bw_parsed(
14813 void *parsed_result,
14814 __attribute__((unused)) struct cmdline *cl,
14815 __attribute__((unused)) void *data)
14817 struct cmd_vf_tc_bw_result *res = parsed_result;
14818 int ret = -ENOTSUP;
14820 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14823 #ifdef RTE_LIBRTE_I40E_PMD
14824 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14825 res->tc_no, res->bw);
14832 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14833 res->vf_id, res->tc_no, res->bw);
14836 printf("invalid port_id %d\n", res->port_id);
14839 printf("function not implemented\n");
14842 printf("programming error: (%s)\n", strerror(-ret));
14846 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14847 .f = cmd_vf_tc_max_bw_parsed,
14849 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14852 (void *)&cmd_vf_tc_bw_set,
14853 (void *)&cmd_vf_tc_bw_vf,
14854 (void *)&cmd_vf_tc_bw_tc,
14855 (void *)&cmd_vf_tc_bw_tx,
14856 (void *)&cmd_vf_tc_bw_max_bw,
14857 (void *)&cmd_vf_tc_bw_port_id,
14858 (void *)&cmd_vf_tc_bw_vf_id,
14859 (void *)&cmd_vf_tc_bw_tc_no,
14860 (void *)&cmd_vf_tc_bw_bw,
14866 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14868 /* *** Set Port default Traffic Management Hierarchy *** */
14869 struct cmd_set_port_tm_hierarchy_default_result {
14870 cmdline_fixed_string_t set;
14871 cmdline_fixed_string_t port;
14872 cmdline_fixed_string_t tm;
14873 cmdline_fixed_string_t hierarchy;
14874 cmdline_fixed_string_t def;
14878 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14879 TOKEN_STRING_INITIALIZER(
14880 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14881 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14882 TOKEN_STRING_INITIALIZER(
14883 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14884 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14885 TOKEN_STRING_INITIALIZER(
14886 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14887 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14888 TOKEN_STRING_INITIALIZER(
14889 struct cmd_set_port_tm_hierarchy_default_result,
14890 hierarchy, "hierarchy");
14891 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14892 TOKEN_STRING_INITIALIZER(
14893 struct cmd_set_port_tm_hierarchy_default_result,
14895 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14896 TOKEN_NUM_INITIALIZER(
14897 struct cmd_set_port_tm_hierarchy_default_result,
14900 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14901 __attribute__((unused)) struct cmdline *cl,
14902 __attribute__((unused)) void *data)
14904 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14905 struct rte_port *p;
14906 portid_t port_id = res->port_id;
14908 if (port_id_is_invalid(port_id, ENABLED_WARN))
14911 p = &ports[port_id];
14913 /* Forward mode: tm */
14914 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
14915 printf(" softnicfwd mode not enabled(error)\n");
14919 /* Set the default tm hierarchy */
14920 p->softport.default_tm_hierarchy_enable = 1;
14923 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14924 .f = cmd_set_port_tm_hierarchy_default_parsed,
14926 .help_str = "set port tm hierarchy default <port_id>",
14928 (void *)&cmd_set_port_tm_hierarchy_default_set,
14929 (void *)&cmd_set_port_tm_hierarchy_default_port,
14930 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14931 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14932 (void *)&cmd_set_port_tm_hierarchy_default_default,
14933 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14939 /** Set VXLAN encapsulation details */
14940 struct cmd_set_vxlan_result {
14941 cmdline_fixed_string_t set;
14942 cmdline_fixed_string_t vxlan;
14943 cmdline_fixed_string_t pos_token;
14944 cmdline_fixed_string_t ip_version;
14945 uint32_t vlan_present:1;
14949 cmdline_ipaddr_t ip_src;
14950 cmdline_ipaddr_t ip_dst;
14952 struct ether_addr eth_src;
14953 struct ether_addr eth_dst;
14956 cmdline_parse_token_string_t cmd_set_vxlan_set =
14957 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
14958 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
14959 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
14960 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
14961 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
14962 "vxlan-with-vlan");
14963 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
14964 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14966 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
14967 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
14969 cmdline_parse_token_string_t cmd_set_vxlan_vni =
14970 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14972 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
14973 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
14974 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
14975 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14977 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
14978 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
14979 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
14980 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14982 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
14983 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
14984 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
14985 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14987 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
14988 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
14989 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
14990 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14992 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
14993 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
14994 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
14995 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14997 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
14998 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
14999 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15000 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15002 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15003 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15004 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15005 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15007 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15008 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15010 static void cmd_set_vxlan_parsed(void *parsed_result,
15011 __attribute__((unused)) struct cmdline *cl,
15012 __attribute__((unused)) void *data)
15014 struct cmd_set_vxlan_result *res = parsed_result;
15019 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15022 if (strcmp(res->vxlan, "vxlan") == 0)
15023 vxlan_encap_conf.select_vlan = 0;
15024 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15025 vxlan_encap_conf.select_vlan = 1;
15026 if (strcmp(res->ip_version, "ipv4") == 0)
15027 vxlan_encap_conf.select_ipv4 = 1;
15028 else if (strcmp(res->ip_version, "ipv6") == 0)
15029 vxlan_encap_conf.select_ipv4 = 0;
15032 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15033 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15034 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15035 if (vxlan_encap_conf.select_ipv4) {
15036 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15037 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15039 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15040 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15042 if (vxlan_encap_conf.select_vlan)
15043 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15044 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15046 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15050 cmdline_parse_inst_t cmd_set_vxlan = {
15051 .f = cmd_set_vxlan_parsed,
15053 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15054 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15055 " eth-src <eth-src> eth-dst <eth-dst>",
15057 (void *)&cmd_set_vxlan_set,
15058 (void *)&cmd_set_vxlan_vxlan,
15059 (void *)&cmd_set_vxlan_ip_version,
15060 (void *)&cmd_set_vxlan_ip_version_value,
15061 (void *)&cmd_set_vxlan_vni,
15062 (void *)&cmd_set_vxlan_vni_value,
15063 (void *)&cmd_set_vxlan_udp_src,
15064 (void *)&cmd_set_vxlan_udp_src_value,
15065 (void *)&cmd_set_vxlan_udp_dst,
15066 (void *)&cmd_set_vxlan_udp_dst_value,
15067 (void *)&cmd_set_vxlan_ip_src,
15068 (void *)&cmd_set_vxlan_ip_src_value,
15069 (void *)&cmd_set_vxlan_ip_dst,
15070 (void *)&cmd_set_vxlan_ip_dst_value,
15071 (void *)&cmd_set_vxlan_eth_src,
15072 (void *)&cmd_set_vxlan_eth_src_value,
15073 (void *)&cmd_set_vxlan_eth_dst,
15074 (void *)&cmd_set_vxlan_eth_dst_value,
15079 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15080 .f = cmd_set_vxlan_parsed,
15082 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15083 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15084 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15087 (void *)&cmd_set_vxlan_set,
15088 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15089 (void *)&cmd_set_vxlan_ip_version,
15090 (void *)&cmd_set_vxlan_ip_version_value,
15091 (void *)&cmd_set_vxlan_vni,
15092 (void *)&cmd_set_vxlan_vni_value,
15093 (void *)&cmd_set_vxlan_udp_src,
15094 (void *)&cmd_set_vxlan_udp_src_value,
15095 (void *)&cmd_set_vxlan_udp_dst,
15096 (void *)&cmd_set_vxlan_udp_dst_value,
15097 (void *)&cmd_set_vxlan_ip_src,
15098 (void *)&cmd_set_vxlan_ip_src_value,
15099 (void *)&cmd_set_vxlan_ip_dst,
15100 (void *)&cmd_set_vxlan_ip_dst_value,
15101 (void *)&cmd_set_vxlan_vlan,
15102 (void *)&cmd_set_vxlan_vlan_value,
15103 (void *)&cmd_set_vxlan_eth_src,
15104 (void *)&cmd_set_vxlan_eth_src_value,
15105 (void *)&cmd_set_vxlan_eth_dst,
15106 (void *)&cmd_set_vxlan_eth_dst_value,
15111 /** Set NVGRE encapsulation details */
15112 struct cmd_set_nvgre_result {
15113 cmdline_fixed_string_t set;
15114 cmdline_fixed_string_t nvgre;
15115 cmdline_fixed_string_t pos_token;
15116 cmdline_fixed_string_t ip_version;
15118 cmdline_ipaddr_t ip_src;
15119 cmdline_ipaddr_t ip_dst;
15121 struct ether_addr eth_src;
15122 struct ether_addr eth_dst;
15125 cmdline_parse_token_string_t cmd_set_nvgre_set =
15126 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15127 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15128 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15129 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15130 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15131 "nvgre-with-vlan");
15132 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15133 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15135 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15136 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15138 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15139 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15141 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15142 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15143 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15144 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15146 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15147 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15148 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15149 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15151 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15152 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15153 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15154 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15156 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15157 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15158 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15159 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15161 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15162 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15163 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15164 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15166 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15167 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15169 static void cmd_set_nvgre_parsed(void *parsed_result,
15170 __attribute__((unused)) struct cmdline *cl,
15171 __attribute__((unused)) void *data)
15173 struct cmd_set_nvgre_result *res = parsed_result;
15175 uint32_t nvgre_tni;
15178 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15181 if (strcmp(res->nvgre, "nvgre") == 0)
15182 nvgre_encap_conf.select_vlan = 0;
15183 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15184 nvgre_encap_conf.select_vlan = 1;
15185 if (strcmp(res->ip_version, "ipv4") == 0)
15186 nvgre_encap_conf.select_ipv4 = 1;
15187 else if (strcmp(res->ip_version, "ipv6") == 0)
15188 nvgre_encap_conf.select_ipv4 = 0;
15191 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15192 if (nvgre_encap_conf.select_ipv4) {
15193 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15194 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15196 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15197 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15199 if (nvgre_encap_conf.select_vlan)
15200 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15201 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15203 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15207 cmdline_parse_inst_t cmd_set_nvgre = {
15208 .f = cmd_set_nvgre_parsed,
15210 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15211 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15212 " eth-dst <eth-dst>",
15214 (void *)&cmd_set_nvgre_set,
15215 (void *)&cmd_set_nvgre_nvgre,
15216 (void *)&cmd_set_nvgre_ip_version,
15217 (void *)&cmd_set_nvgre_ip_version_value,
15218 (void *)&cmd_set_nvgre_tni,
15219 (void *)&cmd_set_nvgre_tni_value,
15220 (void *)&cmd_set_nvgre_ip_src,
15221 (void *)&cmd_set_nvgre_ip_src_value,
15222 (void *)&cmd_set_nvgre_ip_dst,
15223 (void *)&cmd_set_nvgre_ip_dst_value,
15224 (void *)&cmd_set_nvgre_eth_src,
15225 (void *)&cmd_set_nvgre_eth_src_value,
15226 (void *)&cmd_set_nvgre_eth_dst,
15227 (void *)&cmd_set_nvgre_eth_dst_value,
15232 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15233 .f = cmd_set_nvgre_parsed,
15235 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15236 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15237 " eth-src <eth-src> eth-dst <eth-dst>",
15239 (void *)&cmd_set_nvgre_set,
15240 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15241 (void *)&cmd_set_nvgre_ip_version,
15242 (void *)&cmd_set_nvgre_ip_version_value,
15243 (void *)&cmd_set_nvgre_tni,
15244 (void *)&cmd_set_nvgre_tni_value,
15245 (void *)&cmd_set_nvgre_ip_src,
15246 (void *)&cmd_set_nvgre_ip_src_value,
15247 (void *)&cmd_set_nvgre_ip_dst,
15248 (void *)&cmd_set_nvgre_ip_dst_value,
15249 (void *)&cmd_set_nvgre_vlan,
15250 (void *)&cmd_set_nvgre_vlan_value,
15251 (void *)&cmd_set_nvgre_eth_src,
15252 (void *)&cmd_set_nvgre_eth_src_value,
15253 (void *)&cmd_set_nvgre_eth_dst,
15254 (void *)&cmd_set_nvgre_eth_dst_value,
15259 /* Strict link priority scheduling mode setting */
15261 cmd_strict_link_prio_parsed(
15262 void *parsed_result,
15263 __attribute__((unused)) struct cmdline *cl,
15264 __attribute__((unused)) void *data)
15266 struct cmd_vf_tc_bw_result *res = parsed_result;
15267 int ret = -ENOTSUP;
15269 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15272 #ifdef RTE_LIBRTE_I40E_PMD
15273 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
15280 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
15283 printf("invalid port_id %d\n", res->port_id);
15286 printf("function not implemented\n");
15289 printf("programming error: (%s)\n", strerror(-ret));
15293 cmdline_parse_inst_t cmd_strict_link_prio = {
15294 .f = cmd_strict_link_prio_parsed,
15296 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
15298 (void *)&cmd_vf_tc_bw_set,
15299 (void *)&cmd_vf_tc_bw_tx,
15300 (void *)&cmd_vf_tc_bw_strict_link_prio,
15301 (void *)&cmd_vf_tc_bw_port_id,
15302 (void *)&cmd_vf_tc_bw_tc_map,
15307 /* Load dynamic device personalization*/
15308 struct cmd_ddp_add_result {
15309 cmdline_fixed_string_t ddp;
15310 cmdline_fixed_string_t add;
15315 cmdline_parse_token_string_t cmd_ddp_add_ddp =
15316 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
15317 cmdline_parse_token_string_t cmd_ddp_add_add =
15318 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
15319 cmdline_parse_token_num_t cmd_ddp_add_port_id =
15320 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
15321 cmdline_parse_token_string_t cmd_ddp_add_filepath =
15322 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
15325 cmd_ddp_add_parsed(
15326 void *parsed_result,
15327 __attribute__((unused)) struct cmdline *cl,
15328 __attribute__((unused)) void *data)
15330 struct cmd_ddp_add_result *res = parsed_result;
15336 int ret = -ENOTSUP;
15338 if (!all_ports_stopped()) {
15339 printf("Please stop all ports first\n");
15343 filepath = strdup(res->filepath);
15344 if (filepath == NULL) {
15345 printf("Failed to allocate memory\n");
15348 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
15350 buff = open_file(file_fld[0], &size);
15352 free((void *)filepath);
15356 #ifdef RTE_LIBRTE_I40E_PMD
15357 if (ret == -ENOTSUP)
15358 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
15360 RTE_PMD_I40E_PKG_OP_WR_ADD);
15363 if (ret == -EEXIST)
15364 printf("Profile has already existed.\n");
15366 printf("Failed to load profile.\n");
15367 else if (file_num == 2)
15368 save_file(file_fld[1], buff, size);
15371 free((void *)filepath);
15374 cmdline_parse_inst_t cmd_ddp_add = {
15375 .f = cmd_ddp_add_parsed,
15377 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
15379 (void *)&cmd_ddp_add_ddp,
15380 (void *)&cmd_ddp_add_add,
15381 (void *)&cmd_ddp_add_port_id,
15382 (void *)&cmd_ddp_add_filepath,
15387 /* Delete dynamic device personalization*/
15388 struct cmd_ddp_del_result {
15389 cmdline_fixed_string_t ddp;
15390 cmdline_fixed_string_t del;
15395 cmdline_parse_token_string_t cmd_ddp_del_ddp =
15396 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
15397 cmdline_parse_token_string_t cmd_ddp_del_del =
15398 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
15399 cmdline_parse_token_num_t cmd_ddp_del_port_id =
15400 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
15401 cmdline_parse_token_string_t cmd_ddp_del_filepath =
15402 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
15405 cmd_ddp_del_parsed(
15406 void *parsed_result,
15407 __attribute__((unused)) struct cmdline *cl,
15408 __attribute__((unused)) void *data)
15410 struct cmd_ddp_del_result *res = parsed_result;
15413 int ret = -ENOTSUP;
15415 if (!all_ports_stopped()) {
15416 printf("Please stop all ports first\n");
15420 buff = open_file(res->filepath, &size);
15424 #ifdef RTE_LIBRTE_I40E_PMD
15425 if (ret == -ENOTSUP)
15426 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
15428 RTE_PMD_I40E_PKG_OP_WR_DEL);
15431 if (ret == -EACCES)
15432 printf("Profile does not exist.\n");
15434 printf("Failed to delete profile.\n");
15439 cmdline_parse_inst_t cmd_ddp_del = {
15440 .f = cmd_ddp_del_parsed,
15442 .help_str = "ddp del <port_id> <backup_profile_path>",
15444 (void *)&cmd_ddp_del_ddp,
15445 (void *)&cmd_ddp_del_del,
15446 (void *)&cmd_ddp_del_port_id,
15447 (void *)&cmd_ddp_del_filepath,
15452 /* Get dynamic device personalization profile info */
15453 struct cmd_ddp_info_result {
15454 cmdline_fixed_string_t ddp;
15455 cmdline_fixed_string_t get;
15456 cmdline_fixed_string_t info;
15460 cmdline_parse_token_string_t cmd_ddp_info_ddp =
15461 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
15462 cmdline_parse_token_string_t cmd_ddp_info_get =
15463 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
15464 cmdline_parse_token_string_t cmd_ddp_info_info =
15465 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
15466 cmdline_parse_token_string_t cmd_ddp_info_filepath =
15467 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
15470 cmd_ddp_info_parsed(
15471 void *parsed_result,
15472 __attribute__((unused)) struct cmdline *cl,
15473 __attribute__((unused)) void *data)
15475 struct cmd_ddp_info_result *res = parsed_result;
15478 int ret = -ENOTSUP;
15479 #ifdef RTE_LIBRTE_I40E_PMD
15482 uint32_t buff_size = 0;
15483 struct rte_pmd_i40e_profile_info info;
15484 uint32_t dev_num = 0;
15485 struct rte_pmd_i40e_ddp_device_id *devs;
15486 uint32_t proto_num = 0;
15487 struct rte_pmd_i40e_proto_info *proto = NULL;
15488 uint32_t pctype_num = 0;
15489 struct rte_pmd_i40e_ptype_info *pctype;
15490 uint32_t ptype_num = 0;
15491 struct rte_pmd_i40e_ptype_info *ptype;
15496 pkg = open_file(res->filepath, &pkg_size);
15500 #ifdef RTE_LIBRTE_I40E_PMD
15501 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15502 (uint8_t *)&info, sizeof(info),
15503 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
15505 printf("Global Track id: 0x%x\n", info.track_id);
15506 printf("Global Version: %d.%d.%d.%d\n",
15507 info.version.major,
15508 info.version.minor,
15509 info.version.update,
15510 info.version.draft);
15511 printf("Global Package name: %s\n\n", info.name);
15514 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15515 (uint8_t *)&info, sizeof(info),
15516 RTE_PMD_I40E_PKG_INFO_HEADER);
15518 printf("i40e Profile Track id: 0x%x\n", info.track_id);
15519 printf("i40e Profile Version: %d.%d.%d.%d\n",
15520 info.version.major,
15521 info.version.minor,
15522 info.version.update,
15523 info.version.draft);
15524 printf("i40e Profile name: %s\n\n", info.name);
15527 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15528 (uint8_t *)&buff_size, sizeof(buff_size),
15529 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
15530 if (!ret && buff_size) {
15531 buff = (uint8_t *)malloc(buff_size);
15533 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15535 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
15537 printf("Package Notes:\n%s\n\n", buff);
15542 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15543 (uint8_t *)&dev_num, sizeof(dev_num),
15544 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
15545 if (!ret && dev_num) {
15546 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
15547 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
15549 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15550 (uint8_t *)devs, buff_size,
15551 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
15553 printf("List of supported devices:\n");
15554 for (i = 0; i < dev_num; i++) {
15555 printf(" %04X:%04X %04X:%04X\n",
15556 devs[i].vendor_dev_id >> 16,
15557 devs[i].vendor_dev_id & 0xFFFF,
15558 devs[i].sub_vendor_dev_id >> 16,
15559 devs[i].sub_vendor_dev_id & 0xFFFF);
15567 /* get information about protocols and packet types */
15568 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15569 (uint8_t *)&proto_num, sizeof(proto_num),
15570 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
15571 if (ret || !proto_num)
15572 goto no_print_return;
15574 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
15575 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
15577 goto no_print_return;
15579 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
15581 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
15583 printf("List of used protocols:\n");
15584 for (i = 0; i < proto_num; i++)
15585 printf(" %2u: %s\n", proto[i].proto_id,
15589 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15590 (uint8_t *)&pctype_num, sizeof(pctype_num),
15591 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
15592 if (ret || !pctype_num)
15593 goto no_print_pctypes;
15595 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15596 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15598 goto no_print_pctypes;
15600 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
15602 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
15605 goto no_print_pctypes;
15608 printf("List of defined packet classification types:\n");
15609 for (i = 0; i < pctype_num; i++) {
15610 printf(" %2u:", pctype[i].ptype_id);
15611 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15612 proto_id = pctype[i].protocols[j];
15613 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15614 for (n = 0; n < proto_num; n++) {
15615 if (proto[n].proto_id == proto_id) {
15616 printf(" %s", proto[n].name);
15629 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
15631 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
15632 if (ret || !ptype_num)
15633 goto no_print_return;
15635 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15636 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15638 goto no_print_return;
15640 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
15642 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
15645 goto no_print_return;
15647 printf("List of defined packet types:\n");
15648 for (i = 0; i < ptype_num; i++) {
15649 printf(" %2u:", ptype[i].ptype_id);
15650 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15651 proto_id = ptype[i].protocols[j];
15652 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15653 for (n = 0; n < proto_num; n++) {
15654 if (proto[n].proto_id == proto_id) {
15655 printf(" %s", proto[n].name);
15671 if (ret == -ENOTSUP)
15672 printf("Function not supported in PMD driver\n");
15676 cmdline_parse_inst_t cmd_ddp_get_info = {
15677 .f = cmd_ddp_info_parsed,
15679 .help_str = "ddp get info <profile_path>",
15681 (void *)&cmd_ddp_info_ddp,
15682 (void *)&cmd_ddp_info_get,
15683 (void *)&cmd_ddp_info_info,
15684 (void *)&cmd_ddp_info_filepath,
15689 /* Get dynamic device personalization profile info list*/
15690 #define PROFILE_INFO_SIZE 48
15691 #define MAX_PROFILE_NUM 16
15693 struct cmd_ddp_get_list_result {
15694 cmdline_fixed_string_t ddp;
15695 cmdline_fixed_string_t get;
15696 cmdline_fixed_string_t list;
15700 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
15701 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
15702 cmdline_parse_token_string_t cmd_ddp_get_list_get =
15703 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
15704 cmdline_parse_token_string_t cmd_ddp_get_list_list =
15705 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
15706 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
15707 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
15710 cmd_ddp_get_list_parsed(
15711 __attribute__((unused)) void *parsed_result,
15712 __attribute__((unused)) struct cmdline *cl,
15713 __attribute__((unused)) void *data)
15715 #ifdef RTE_LIBRTE_I40E_PMD
15716 struct cmd_ddp_get_list_result *res = parsed_result;
15717 struct rte_pmd_i40e_profile_list *p_list;
15718 struct rte_pmd_i40e_profile_info *p_info;
15723 int ret = -ENOTSUP;
15725 #ifdef RTE_LIBRTE_I40E_PMD
15726 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
15727 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
15729 printf("%s: Failed to malloc buffer\n", __func__);
15731 if (ret == -ENOTSUP)
15732 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
15733 (uint8_t *)p_list, size);
15736 p_num = p_list->p_count;
15737 printf("Profile number is: %d\n\n", p_num);
15739 for (i = 0; i < p_num; i++) {
15740 p_info = &p_list->p_info[i];
15741 printf("Profile %d:\n", i);
15742 printf("Track id: 0x%x\n", p_info->track_id);
15743 printf("Version: %d.%d.%d.%d\n",
15744 p_info->version.major,
15745 p_info->version.minor,
15746 p_info->version.update,
15747 p_info->version.draft);
15748 printf("Profile name: %s\n\n", p_info->name);
15756 printf("Failed to get ddp list\n");
15759 cmdline_parse_inst_t cmd_ddp_get_list = {
15760 .f = cmd_ddp_get_list_parsed,
15762 .help_str = "ddp get list <port_id>",
15764 (void *)&cmd_ddp_get_list_ddp,
15765 (void *)&cmd_ddp_get_list_get,
15766 (void *)&cmd_ddp_get_list_list,
15767 (void *)&cmd_ddp_get_list_port_id,
15772 /* Configure input set */
15773 struct cmd_cfg_input_set_result {
15774 cmdline_fixed_string_t port;
15775 cmdline_fixed_string_t cfg;
15777 cmdline_fixed_string_t pctype;
15779 cmdline_fixed_string_t inset_type;
15780 cmdline_fixed_string_t opt;
15781 cmdline_fixed_string_t field;
15786 cmd_cfg_input_set_parsed(
15787 __attribute__((unused)) void *parsed_result,
15788 __attribute__((unused)) struct cmdline *cl,
15789 __attribute__((unused)) void *data)
15791 #ifdef RTE_LIBRTE_I40E_PMD
15792 struct cmd_cfg_input_set_result *res = parsed_result;
15793 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15794 struct rte_pmd_i40e_inset inset;
15796 int ret = -ENOTSUP;
15798 if (!all_ports_stopped()) {
15799 printf("Please stop all ports first\n");
15803 #ifdef RTE_LIBRTE_I40E_PMD
15804 if (!strcmp(res->inset_type, "hash_inset"))
15805 inset_type = INSET_HASH;
15806 else if (!strcmp(res->inset_type, "fdir_inset"))
15807 inset_type = INSET_FDIR;
15808 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15809 inset_type = INSET_FDIR_FLX;
15810 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
15811 &inset, inset_type);
15813 printf("Failed to get input set.\n");
15817 if (!strcmp(res->opt, "get")) {
15818 ret = rte_pmd_i40e_inset_field_get(inset.inset,
15821 printf("Field index %d is enabled.\n", res->field_idx);
15823 printf("Field index %d is disabled.\n", res->field_idx);
15825 } else if (!strcmp(res->opt, "set"))
15826 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15828 else if (!strcmp(res->opt, "clear"))
15829 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15832 printf("Failed to configure input set field.\n");
15836 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15837 &inset, inset_type);
15839 printf("Failed to set input set.\n");
15844 if (ret == -ENOTSUP)
15845 printf("Function not supported\n");
15848 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15849 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15851 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15852 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15854 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15855 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15857 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15858 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15860 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15861 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15863 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15864 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15866 "hash_inset#fdir_inset#fdir_flx_inset");
15867 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15868 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15869 opt, "get#set#clear");
15870 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15871 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15873 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15874 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15877 cmdline_parse_inst_t cmd_cfg_input_set = {
15878 .f = cmd_cfg_input_set_parsed,
15880 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15881 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15883 (void *)&cmd_cfg_input_set_port,
15884 (void *)&cmd_cfg_input_set_cfg,
15885 (void *)&cmd_cfg_input_set_port_id,
15886 (void *)&cmd_cfg_input_set_pctype,
15887 (void *)&cmd_cfg_input_set_pctype_id,
15888 (void *)&cmd_cfg_input_set_inset_type,
15889 (void *)&cmd_cfg_input_set_opt,
15890 (void *)&cmd_cfg_input_set_field,
15891 (void *)&cmd_cfg_input_set_field_idx,
15896 /* Clear input set */
15897 struct cmd_clear_input_set_result {
15898 cmdline_fixed_string_t port;
15899 cmdline_fixed_string_t cfg;
15901 cmdline_fixed_string_t pctype;
15903 cmdline_fixed_string_t inset_type;
15904 cmdline_fixed_string_t clear;
15905 cmdline_fixed_string_t all;
15909 cmd_clear_input_set_parsed(
15910 __attribute__((unused)) void *parsed_result,
15911 __attribute__((unused)) struct cmdline *cl,
15912 __attribute__((unused)) void *data)
15914 #ifdef RTE_LIBRTE_I40E_PMD
15915 struct cmd_clear_input_set_result *res = parsed_result;
15916 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15917 struct rte_pmd_i40e_inset inset;
15919 int ret = -ENOTSUP;
15921 if (!all_ports_stopped()) {
15922 printf("Please stop all ports first\n");
15926 #ifdef RTE_LIBRTE_I40E_PMD
15927 if (!strcmp(res->inset_type, "hash_inset"))
15928 inset_type = INSET_HASH;
15929 else if (!strcmp(res->inset_type, "fdir_inset"))
15930 inset_type = INSET_FDIR;
15931 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15932 inset_type = INSET_FDIR_FLX;
15934 memset(&inset, 0, sizeof(inset));
15936 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15937 &inset, inset_type);
15939 printf("Failed to clear input set.\n");
15945 if (ret == -ENOTSUP)
15946 printf("Function not supported\n");
15949 cmdline_parse_token_string_t cmd_clear_input_set_port =
15950 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15952 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15953 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15955 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15956 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15958 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15959 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15961 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15962 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15964 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15965 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15967 "hash_inset#fdir_inset#fdir_flx_inset");
15968 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15969 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15971 cmdline_parse_token_string_t cmd_clear_input_set_all =
15972 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15975 cmdline_parse_inst_t cmd_clear_input_set = {
15976 .f = cmd_clear_input_set_parsed,
15978 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15979 "fdir_inset|fdir_flx_inset clear all",
15981 (void *)&cmd_clear_input_set_port,
15982 (void *)&cmd_clear_input_set_cfg,
15983 (void *)&cmd_clear_input_set_port_id,
15984 (void *)&cmd_clear_input_set_pctype,
15985 (void *)&cmd_clear_input_set_pctype_id,
15986 (void *)&cmd_clear_input_set_inset_type,
15987 (void *)&cmd_clear_input_set_clear,
15988 (void *)&cmd_clear_input_set_all,
15993 /* show vf stats */
15995 /* Common result structure for show vf stats */
15996 struct cmd_show_vf_stats_result {
15997 cmdline_fixed_string_t show;
15998 cmdline_fixed_string_t vf;
15999 cmdline_fixed_string_t stats;
16004 /* Common CLI fields show vf stats*/
16005 cmdline_parse_token_string_t cmd_show_vf_stats_show =
16006 TOKEN_STRING_INITIALIZER
16007 (struct cmd_show_vf_stats_result,
16009 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
16010 TOKEN_STRING_INITIALIZER
16011 (struct cmd_show_vf_stats_result,
16013 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
16014 TOKEN_STRING_INITIALIZER
16015 (struct cmd_show_vf_stats_result,
16017 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
16018 TOKEN_NUM_INITIALIZER
16019 (struct cmd_show_vf_stats_result,
16021 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
16022 TOKEN_NUM_INITIALIZER
16023 (struct cmd_show_vf_stats_result,
16027 cmd_show_vf_stats_parsed(
16028 void *parsed_result,
16029 __attribute__((unused)) struct cmdline *cl,
16030 __attribute__((unused)) void *data)
16032 struct cmd_show_vf_stats_result *res = parsed_result;
16033 struct rte_eth_stats stats;
16034 int ret = -ENOTSUP;
16035 static const char *nic_stats_border = "########################";
16037 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16040 memset(&stats, 0, sizeof(stats));
16042 #ifdef RTE_LIBRTE_I40E_PMD
16043 if (ret == -ENOTSUP)
16044 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
16048 #ifdef RTE_LIBRTE_BNXT_PMD
16049 if (ret == -ENOTSUP)
16050 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
16059 printf("invalid vf_id %d\n", res->vf_id);
16062 printf("invalid port_id %d\n", res->port_id);
16065 printf("function not implemented\n");
16068 printf("programming error: (%s)\n", strerror(-ret));
16071 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
16072 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
16074 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
16076 stats.ipackets, stats.imissed, stats.ibytes);
16077 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
16078 printf(" RX-nombuf: %-10"PRIu64"\n",
16080 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
16082 stats.opackets, stats.oerrors, stats.obytes);
16084 printf(" %s############################%s\n",
16085 nic_stats_border, nic_stats_border);
16088 cmdline_parse_inst_t cmd_show_vf_stats = {
16089 .f = cmd_show_vf_stats_parsed,
16091 .help_str = "show vf stats <port_id> <vf_id>",
16093 (void *)&cmd_show_vf_stats_show,
16094 (void *)&cmd_show_vf_stats_vf,
16095 (void *)&cmd_show_vf_stats_stats,
16096 (void *)&cmd_show_vf_stats_port_id,
16097 (void *)&cmd_show_vf_stats_vf_id,
16102 /* clear vf stats */
16104 /* Common result structure for clear vf stats */
16105 struct cmd_clear_vf_stats_result {
16106 cmdline_fixed_string_t clear;
16107 cmdline_fixed_string_t vf;
16108 cmdline_fixed_string_t stats;
16113 /* Common CLI fields clear vf stats*/
16114 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
16115 TOKEN_STRING_INITIALIZER
16116 (struct cmd_clear_vf_stats_result,
16118 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
16119 TOKEN_STRING_INITIALIZER
16120 (struct cmd_clear_vf_stats_result,
16122 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
16123 TOKEN_STRING_INITIALIZER
16124 (struct cmd_clear_vf_stats_result,
16126 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
16127 TOKEN_NUM_INITIALIZER
16128 (struct cmd_clear_vf_stats_result,
16130 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
16131 TOKEN_NUM_INITIALIZER
16132 (struct cmd_clear_vf_stats_result,
16136 cmd_clear_vf_stats_parsed(
16137 void *parsed_result,
16138 __attribute__((unused)) struct cmdline *cl,
16139 __attribute__((unused)) void *data)
16141 struct cmd_clear_vf_stats_result *res = parsed_result;
16142 int ret = -ENOTSUP;
16144 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16147 #ifdef RTE_LIBRTE_I40E_PMD
16148 if (ret == -ENOTSUP)
16149 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
16152 #ifdef RTE_LIBRTE_BNXT_PMD
16153 if (ret == -ENOTSUP)
16154 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
16162 printf("invalid vf_id %d\n", res->vf_id);
16165 printf("invalid port_id %d\n", res->port_id);
16168 printf("function not implemented\n");
16171 printf("programming error: (%s)\n", strerror(-ret));
16175 cmdline_parse_inst_t cmd_clear_vf_stats = {
16176 .f = cmd_clear_vf_stats_parsed,
16178 .help_str = "clear vf stats <port_id> <vf_id>",
16180 (void *)&cmd_clear_vf_stats_clear,
16181 (void *)&cmd_clear_vf_stats_vf,
16182 (void *)&cmd_clear_vf_stats_stats,
16183 (void *)&cmd_clear_vf_stats_port_id,
16184 (void *)&cmd_clear_vf_stats_vf_id,
16189 /* port config pctype mapping reset */
16191 /* Common result structure for port config pctype mapping reset */
16192 struct cmd_pctype_mapping_reset_result {
16193 cmdline_fixed_string_t port;
16194 cmdline_fixed_string_t config;
16196 cmdline_fixed_string_t pctype;
16197 cmdline_fixed_string_t mapping;
16198 cmdline_fixed_string_t reset;
16201 /* Common CLI fields for port config pctype mapping reset*/
16202 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
16203 TOKEN_STRING_INITIALIZER
16204 (struct cmd_pctype_mapping_reset_result,
16206 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
16207 TOKEN_STRING_INITIALIZER
16208 (struct cmd_pctype_mapping_reset_result,
16210 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
16211 TOKEN_NUM_INITIALIZER
16212 (struct cmd_pctype_mapping_reset_result,
16214 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
16215 TOKEN_STRING_INITIALIZER
16216 (struct cmd_pctype_mapping_reset_result,
16218 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
16219 TOKEN_STRING_INITIALIZER
16220 (struct cmd_pctype_mapping_reset_result,
16221 mapping, "mapping");
16222 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
16223 TOKEN_STRING_INITIALIZER
16224 (struct cmd_pctype_mapping_reset_result,
16228 cmd_pctype_mapping_reset_parsed(
16229 void *parsed_result,
16230 __attribute__((unused)) struct cmdline *cl,
16231 __attribute__((unused)) void *data)
16233 struct cmd_pctype_mapping_reset_result *res = parsed_result;
16234 int ret = -ENOTSUP;
16236 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16239 #ifdef RTE_LIBRTE_I40E_PMD
16240 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
16247 printf("invalid port_id %d\n", res->port_id);
16250 printf("function not implemented\n");
16253 printf("programming error: (%s)\n", strerror(-ret));
16257 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
16258 .f = cmd_pctype_mapping_reset_parsed,
16260 .help_str = "port config <port_id> pctype mapping reset",
16262 (void *)&cmd_pctype_mapping_reset_port,
16263 (void *)&cmd_pctype_mapping_reset_config,
16264 (void *)&cmd_pctype_mapping_reset_port_id,
16265 (void *)&cmd_pctype_mapping_reset_pctype,
16266 (void *)&cmd_pctype_mapping_reset_mapping,
16267 (void *)&cmd_pctype_mapping_reset_reset,
16272 /* show port pctype mapping */
16274 /* Common result structure for show port pctype mapping */
16275 struct cmd_pctype_mapping_get_result {
16276 cmdline_fixed_string_t show;
16277 cmdline_fixed_string_t port;
16279 cmdline_fixed_string_t pctype;
16280 cmdline_fixed_string_t mapping;
16283 /* Common CLI fields for pctype mapping get */
16284 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
16285 TOKEN_STRING_INITIALIZER
16286 (struct cmd_pctype_mapping_get_result,
16288 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
16289 TOKEN_STRING_INITIALIZER
16290 (struct cmd_pctype_mapping_get_result,
16292 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
16293 TOKEN_NUM_INITIALIZER
16294 (struct cmd_pctype_mapping_get_result,
16296 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
16297 TOKEN_STRING_INITIALIZER
16298 (struct cmd_pctype_mapping_get_result,
16300 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
16301 TOKEN_STRING_INITIALIZER
16302 (struct cmd_pctype_mapping_get_result,
16303 mapping, "mapping");
16306 cmd_pctype_mapping_get_parsed(
16307 void *parsed_result,
16308 __attribute__((unused)) struct cmdline *cl,
16309 __attribute__((unused)) void *data)
16311 struct cmd_pctype_mapping_get_result *res = parsed_result;
16312 int ret = -ENOTSUP;
16313 #ifdef RTE_LIBRTE_I40E_PMD
16314 struct rte_pmd_i40e_flow_type_mapping
16315 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
16316 int i, j, first_pctype;
16319 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16322 #ifdef RTE_LIBRTE_I40E_PMD
16323 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
16330 printf("invalid port_id %d\n", res->port_id);
16333 printf("function not implemented\n");
16336 printf("programming error: (%s)\n", strerror(-ret));
16340 #ifdef RTE_LIBRTE_I40E_PMD
16341 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
16342 if (mapping[i].pctype != 0ULL) {
16345 printf("pctype: ");
16346 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
16347 if (mapping[i].pctype & (1ULL << j)) {
16348 printf(first_pctype ?
16349 "%02d" : ",%02d", j);
16353 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
16359 cmdline_parse_inst_t cmd_pctype_mapping_get = {
16360 .f = cmd_pctype_mapping_get_parsed,
16362 .help_str = "show port <port_id> pctype mapping",
16364 (void *)&cmd_pctype_mapping_get_show,
16365 (void *)&cmd_pctype_mapping_get_port,
16366 (void *)&cmd_pctype_mapping_get_port_id,
16367 (void *)&cmd_pctype_mapping_get_pctype,
16368 (void *)&cmd_pctype_mapping_get_mapping,
16373 /* port config pctype mapping update */
16375 /* Common result structure for port config pctype mapping update */
16376 struct cmd_pctype_mapping_update_result {
16377 cmdline_fixed_string_t port;
16378 cmdline_fixed_string_t config;
16380 cmdline_fixed_string_t pctype;
16381 cmdline_fixed_string_t mapping;
16382 cmdline_fixed_string_t update;
16383 cmdline_fixed_string_t pctype_list;
16384 uint16_t flow_type;
16387 /* Common CLI fields for pctype mapping update*/
16388 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
16389 TOKEN_STRING_INITIALIZER
16390 (struct cmd_pctype_mapping_update_result,
16392 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
16393 TOKEN_STRING_INITIALIZER
16394 (struct cmd_pctype_mapping_update_result,
16396 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
16397 TOKEN_NUM_INITIALIZER
16398 (struct cmd_pctype_mapping_update_result,
16400 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
16401 TOKEN_STRING_INITIALIZER
16402 (struct cmd_pctype_mapping_update_result,
16404 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
16405 TOKEN_STRING_INITIALIZER
16406 (struct cmd_pctype_mapping_update_result,
16407 mapping, "mapping");
16408 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
16409 TOKEN_STRING_INITIALIZER
16410 (struct cmd_pctype_mapping_update_result,
16412 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
16413 TOKEN_STRING_INITIALIZER
16414 (struct cmd_pctype_mapping_update_result,
16415 pctype_list, NULL);
16416 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
16417 TOKEN_NUM_INITIALIZER
16418 (struct cmd_pctype_mapping_update_result,
16419 flow_type, UINT16);
16422 cmd_pctype_mapping_update_parsed(
16423 void *parsed_result,
16424 __attribute__((unused)) struct cmdline *cl,
16425 __attribute__((unused)) void *data)
16427 struct cmd_pctype_mapping_update_result *res = parsed_result;
16428 int ret = -ENOTSUP;
16429 #ifdef RTE_LIBRTE_I40E_PMD
16430 struct rte_pmd_i40e_flow_type_mapping mapping;
16432 unsigned int nb_item;
16433 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
16436 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16439 #ifdef RTE_LIBRTE_I40E_PMD
16440 nb_item = parse_item_list(res->pctype_list, "pctypes",
16441 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
16442 mapping.flow_type = res->flow_type;
16443 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
16444 mapping.pctype |= (1ULL << pctype_list[i]);
16445 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
16455 printf("invalid pctype or flow type\n");
16458 printf("invalid port_id %d\n", res->port_id);
16461 printf("function not implemented\n");
16464 printf("programming error: (%s)\n", strerror(-ret));
16468 cmdline_parse_inst_t cmd_pctype_mapping_update = {
16469 .f = cmd_pctype_mapping_update_parsed,
16471 .help_str = "port config <port_id> pctype mapping update"
16472 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
16474 (void *)&cmd_pctype_mapping_update_port,
16475 (void *)&cmd_pctype_mapping_update_config,
16476 (void *)&cmd_pctype_mapping_update_port_id,
16477 (void *)&cmd_pctype_mapping_update_pctype,
16478 (void *)&cmd_pctype_mapping_update_mapping,
16479 (void *)&cmd_pctype_mapping_update_update,
16480 (void *)&cmd_pctype_mapping_update_pc_type,
16481 (void *)&cmd_pctype_mapping_update_flow_type,
16486 /* ptype mapping get */
16488 /* Common result structure for ptype mapping get */
16489 struct cmd_ptype_mapping_get_result {
16490 cmdline_fixed_string_t ptype;
16491 cmdline_fixed_string_t mapping;
16492 cmdline_fixed_string_t get;
16494 uint8_t valid_only;
16497 /* Common CLI fields for ptype mapping get */
16498 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
16499 TOKEN_STRING_INITIALIZER
16500 (struct cmd_ptype_mapping_get_result,
16502 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
16503 TOKEN_STRING_INITIALIZER
16504 (struct cmd_ptype_mapping_get_result,
16505 mapping, "mapping");
16506 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
16507 TOKEN_STRING_INITIALIZER
16508 (struct cmd_ptype_mapping_get_result,
16510 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
16511 TOKEN_NUM_INITIALIZER
16512 (struct cmd_ptype_mapping_get_result,
16514 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
16515 TOKEN_NUM_INITIALIZER
16516 (struct cmd_ptype_mapping_get_result,
16517 valid_only, UINT8);
16520 cmd_ptype_mapping_get_parsed(
16521 void *parsed_result,
16522 __attribute__((unused)) struct cmdline *cl,
16523 __attribute__((unused)) void *data)
16525 struct cmd_ptype_mapping_get_result *res = parsed_result;
16526 int ret = -ENOTSUP;
16527 #ifdef RTE_LIBRTE_I40E_PMD
16528 int max_ptype_num = 256;
16529 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
16534 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16537 #ifdef RTE_LIBRTE_I40E_PMD
16538 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
16549 printf("invalid port_id %d\n", res->port_id);
16552 printf("function not implemented\n");
16555 printf("programming error: (%s)\n", strerror(-ret));
16558 #ifdef RTE_LIBRTE_I40E_PMD
16560 for (i = 0; i < count; i++)
16561 printf("%3d\t0x%08x\n",
16562 mapping[i].hw_ptype, mapping[i].sw_ptype);
16567 cmdline_parse_inst_t cmd_ptype_mapping_get = {
16568 .f = cmd_ptype_mapping_get_parsed,
16570 .help_str = "ptype mapping get <port_id> <valid_only>",
16572 (void *)&cmd_ptype_mapping_get_ptype,
16573 (void *)&cmd_ptype_mapping_get_mapping,
16574 (void *)&cmd_ptype_mapping_get_get,
16575 (void *)&cmd_ptype_mapping_get_port_id,
16576 (void *)&cmd_ptype_mapping_get_valid_only,
16581 /* ptype mapping replace */
16583 /* Common result structure for ptype mapping replace */
16584 struct cmd_ptype_mapping_replace_result {
16585 cmdline_fixed_string_t ptype;
16586 cmdline_fixed_string_t mapping;
16587 cmdline_fixed_string_t replace;
16594 /* Common CLI fields for ptype mapping replace */
16595 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
16596 TOKEN_STRING_INITIALIZER
16597 (struct cmd_ptype_mapping_replace_result,
16599 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
16600 TOKEN_STRING_INITIALIZER
16601 (struct cmd_ptype_mapping_replace_result,
16602 mapping, "mapping");
16603 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
16604 TOKEN_STRING_INITIALIZER
16605 (struct cmd_ptype_mapping_replace_result,
16606 replace, "replace");
16607 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
16608 TOKEN_NUM_INITIALIZER
16609 (struct cmd_ptype_mapping_replace_result,
16611 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
16612 TOKEN_NUM_INITIALIZER
16613 (struct cmd_ptype_mapping_replace_result,
16615 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
16616 TOKEN_NUM_INITIALIZER
16617 (struct cmd_ptype_mapping_replace_result,
16619 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
16620 TOKEN_NUM_INITIALIZER
16621 (struct cmd_ptype_mapping_replace_result,
16625 cmd_ptype_mapping_replace_parsed(
16626 void *parsed_result,
16627 __attribute__((unused)) struct cmdline *cl,
16628 __attribute__((unused)) void *data)
16630 struct cmd_ptype_mapping_replace_result *res = parsed_result;
16631 int ret = -ENOTSUP;
16633 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16636 #ifdef RTE_LIBRTE_I40E_PMD
16637 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
16647 printf("invalid ptype 0x%8x or 0x%8x\n",
16648 res->target, res->pkt_type);
16651 printf("invalid port_id %d\n", res->port_id);
16654 printf("function not implemented\n");
16657 printf("programming error: (%s)\n", strerror(-ret));
16661 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
16662 .f = cmd_ptype_mapping_replace_parsed,
16665 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
16667 (void *)&cmd_ptype_mapping_replace_ptype,
16668 (void *)&cmd_ptype_mapping_replace_mapping,
16669 (void *)&cmd_ptype_mapping_replace_replace,
16670 (void *)&cmd_ptype_mapping_replace_port_id,
16671 (void *)&cmd_ptype_mapping_replace_target,
16672 (void *)&cmd_ptype_mapping_replace_mask,
16673 (void *)&cmd_ptype_mapping_replace_pkt_type,
16678 /* ptype mapping reset */
16680 /* Common result structure for ptype mapping reset */
16681 struct cmd_ptype_mapping_reset_result {
16682 cmdline_fixed_string_t ptype;
16683 cmdline_fixed_string_t mapping;
16684 cmdline_fixed_string_t reset;
16688 /* Common CLI fields for ptype mapping reset*/
16689 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
16690 TOKEN_STRING_INITIALIZER
16691 (struct cmd_ptype_mapping_reset_result,
16693 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
16694 TOKEN_STRING_INITIALIZER
16695 (struct cmd_ptype_mapping_reset_result,
16696 mapping, "mapping");
16697 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
16698 TOKEN_STRING_INITIALIZER
16699 (struct cmd_ptype_mapping_reset_result,
16701 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
16702 TOKEN_NUM_INITIALIZER
16703 (struct cmd_ptype_mapping_reset_result,
16707 cmd_ptype_mapping_reset_parsed(
16708 void *parsed_result,
16709 __attribute__((unused)) struct cmdline *cl,
16710 __attribute__((unused)) void *data)
16712 struct cmd_ptype_mapping_reset_result *res = parsed_result;
16713 int ret = -ENOTSUP;
16715 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16718 #ifdef RTE_LIBRTE_I40E_PMD
16719 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
16726 printf("invalid port_id %d\n", res->port_id);
16729 printf("function not implemented\n");
16732 printf("programming error: (%s)\n", strerror(-ret));
16736 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
16737 .f = cmd_ptype_mapping_reset_parsed,
16739 .help_str = "ptype mapping reset <port_id>",
16741 (void *)&cmd_ptype_mapping_reset_ptype,
16742 (void *)&cmd_ptype_mapping_reset_mapping,
16743 (void *)&cmd_ptype_mapping_reset_reset,
16744 (void *)&cmd_ptype_mapping_reset_port_id,
16749 /* ptype mapping update */
16751 /* Common result structure for ptype mapping update */
16752 struct cmd_ptype_mapping_update_result {
16753 cmdline_fixed_string_t ptype;
16754 cmdline_fixed_string_t mapping;
16755 cmdline_fixed_string_t reset;
16761 /* Common CLI fields for ptype mapping update*/
16762 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
16763 TOKEN_STRING_INITIALIZER
16764 (struct cmd_ptype_mapping_update_result,
16766 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
16767 TOKEN_STRING_INITIALIZER
16768 (struct cmd_ptype_mapping_update_result,
16769 mapping, "mapping");
16770 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
16771 TOKEN_STRING_INITIALIZER
16772 (struct cmd_ptype_mapping_update_result,
16774 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
16775 TOKEN_NUM_INITIALIZER
16776 (struct cmd_ptype_mapping_update_result,
16778 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
16779 TOKEN_NUM_INITIALIZER
16780 (struct cmd_ptype_mapping_update_result,
16782 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
16783 TOKEN_NUM_INITIALIZER
16784 (struct cmd_ptype_mapping_update_result,
16788 cmd_ptype_mapping_update_parsed(
16789 void *parsed_result,
16790 __attribute__((unused)) struct cmdline *cl,
16791 __attribute__((unused)) void *data)
16793 struct cmd_ptype_mapping_update_result *res = parsed_result;
16794 int ret = -ENOTSUP;
16795 #ifdef RTE_LIBRTE_I40E_PMD
16796 struct rte_pmd_i40e_ptype_mapping mapping;
16798 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16801 #ifdef RTE_LIBRTE_I40E_PMD
16802 mapping.hw_ptype = res->hw_ptype;
16803 mapping.sw_ptype = res->sw_ptype;
16804 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
16814 printf("invalid ptype 0x%8x\n", res->sw_ptype);
16817 printf("invalid port_id %d\n", res->port_id);
16820 printf("function not implemented\n");
16823 printf("programming error: (%s)\n", strerror(-ret));
16827 cmdline_parse_inst_t cmd_ptype_mapping_update = {
16828 .f = cmd_ptype_mapping_update_parsed,
16830 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16832 (void *)&cmd_ptype_mapping_update_ptype,
16833 (void *)&cmd_ptype_mapping_update_mapping,
16834 (void *)&cmd_ptype_mapping_update_update,
16835 (void *)&cmd_ptype_mapping_update_port_id,
16836 (void *)&cmd_ptype_mapping_update_hw_ptype,
16837 (void *)&cmd_ptype_mapping_update_sw_ptype,
16842 /* Common result structure for file commands */
16843 struct cmd_cmdfile_result {
16844 cmdline_fixed_string_t load;
16845 cmdline_fixed_string_t filename;
16848 /* Common CLI fields for file commands */
16849 cmdline_parse_token_string_t cmd_load_cmdfile =
16850 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16851 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16852 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16855 cmd_load_from_file_parsed(
16856 void *parsed_result,
16857 __attribute__((unused)) struct cmdline *cl,
16858 __attribute__((unused)) void *data)
16860 struct cmd_cmdfile_result *res = parsed_result;
16862 cmdline_read_from_file(res->filename);
16865 cmdline_parse_inst_t cmd_load_from_file = {
16866 .f = cmd_load_from_file_parsed,
16868 .help_str = "load <filename>",
16870 (void *)&cmd_load_cmdfile,
16871 (void *)&cmd_load_cmdfile_filename,
16876 /* Get Rx offloads capabilities */
16877 struct cmd_rx_offload_get_capa_result {
16878 cmdline_fixed_string_t show;
16879 cmdline_fixed_string_t port;
16881 cmdline_fixed_string_t rx_offload;
16882 cmdline_fixed_string_t capabilities;
16885 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
16886 TOKEN_STRING_INITIALIZER
16887 (struct cmd_rx_offload_get_capa_result,
16889 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
16890 TOKEN_STRING_INITIALIZER
16891 (struct cmd_rx_offload_get_capa_result,
16893 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
16894 TOKEN_NUM_INITIALIZER
16895 (struct cmd_rx_offload_get_capa_result,
16897 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
16898 TOKEN_STRING_INITIALIZER
16899 (struct cmd_rx_offload_get_capa_result,
16900 rx_offload, "rx_offload");
16901 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
16902 TOKEN_STRING_INITIALIZER
16903 (struct cmd_rx_offload_get_capa_result,
16904 capabilities, "capabilities");
16907 print_rx_offloads(uint64_t offloads)
16909 uint64_t single_offload;
16917 begin = __builtin_ctzll(offloads);
16918 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16920 single_offload = 1 << begin;
16921 for (bit = begin; bit < end; bit++) {
16922 if (offloads & single_offload)
16924 rte_eth_dev_rx_offload_name(single_offload));
16925 single_offload <<= 1;
16930 cmd_rx_offload_get_capa_parsed(
16931 void *parsed_result,
16932 __attribute__((unused)) struct cmdline *cl,
16933 __attribute__((unused)) void *data)
16935 struct cmd_rx_offload_get_capa_result *res = parsed_result;
16936 struct rte_eth_dev_info dev_info;
16937 portid_t port_id = res->port_id;
16938 uint64_t queue_offloads;
16939 uint64_t port_offloads;
16941 rte_eth_dev_info_get(port_id, &dev_info);
16942 queue_offloads = dev_info.rx_queue_offload_capa;
16943 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
16945 printf("Rx Offloading Capabilities of port %d :\n", port_id);
16946 printf(" Per Queue :");
16947 print_rx_offloads(queue_offloads);
16950 printf(" Per Port :");
16951 print_rx_offloads(port_offloads);
16955 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
16956 .f = cmd_rx_offload_get_capa_parsed,
16958 .help_str = "show port <port_id> rx_offload capabilities",
16960 (void *)&cmd_rx_offload_get_capa_show,
16961 (void *)&cmd_rx_offload_get_capa_port,
16962 (void *)&cmd_rx_offload_get_capa_port_id,
16963 (void *)&cmd_rx_offload_get_capa_rx_offload,
16964 (void *)&cmd_rx_offload_get_capa_capabilities,
16969 /* Get Rx offloads configuration */
16970 struct cmd_rx_offload_get_configuration_result {
16971 cmdline_fixed_string_t show;
16972 cmdline_fixed_string_t port;
16974 cmdline_fixed_string_t rx_offload;
16975 cmdline_fixed_string_t configuration;
16978 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16979 TOKEN_STRING_INITIALIZER
16980 (struct cmd_rx_offload_get_configuration_result,
16982 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16983 TOKEN_STRING_INITIALIZER
16984 (struct cmd_rx_offload_get_configuration_result,
16986 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
16987 TOKEN_NUM_INITIALIZER
16988 (struct cmd_rx_offload_get_configuration_result,
16990 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
16991 TOKEN_STRING_INITIALIZER
16992 (struct cmd_rx_offload_get_configuration_result,
16993 rx_offload, "rx_offload");
16994 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
16995 TOKEN_STRING_INITIALIZER
16996 (struct cmd_rx_offload_get_configuration_result,
16997 configuration, "configuration");
17000 cmd_rx_offload_get_configuration_parsed(
17001 void *parsed_result,
17002 __attribute__((unused)) struct cmdline *cl,
17003 __attribute__((unused)) void *data)
17005 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
17006 struct rte_eth_dev_info dev_info;
17007 portid_t port_id = res->port_id;
17008 struct rte_port *port = &ports[port_id];
17009 uint64_t port_offloads;
17010 uint64_t queue_offloads;
17011 uint16_t nb_rx_queues;
17014 printf("Rx Offloading Configuration of port %d :\n", port_id);
17016 port_offloads = port->dev_conf.rxmode.offloads;
17018 print_rx_offloads(port_offloads);
17021 rte_eth_dev_info_get(port_id, &dev_info);
17022 nb_rx_queues = dev_info.nb_rx_queues;
17023 for (q = 0; q < nb_rx_queues; q++) {
17024 queue_offloads = port->rx_conf[q].offloads;
17025 printf(" Queue[%2d] :", q);
17026 print_rx_offloads(queue_offloads);
17032 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
17033 .f = cmd_rx_offload_get_configuration_parsed,
17035 .help_str = "show port <port_id> rx_offload configuration",
17037 (void *)&cmd_rx_offload_get_configuration_show,
17038 (void *)&cmd_rx_offload_get_configuration_port,
17039 (void *)&cmd_rx_offload_get_configuration_port_id,
17040 (void *)&cmd_rx_offload_get_configuration_rx_offload,
17041 (void *)&cmd_rx_offload_get_configuration_configuration,
17046 /* Enable/Disable a per port offloading */
17047 struct cmd_config_per_port_rx_offload_result {
17048 cmdline_fixed_string_t port;
17049 cmdline_fixed_string_t config;
17051 cmdline_fixed_string_t rx_offload;
17052 cmdline_fixed_string_t offload;
17053 cmdline_fixed_string_t on_off;
17056 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
17057 TOKEN_STRING_INITIALIZER
17058 (struct cmd_config_per_port_rx_offload_result,
17060 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
17061 TOKEN_STRING_INITIALIZER
17062 (struct cmd_config_per_port_rx_offload_result,
17064 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
17065 TOKEN_NUM_INITIALIZER
17066 (struct cmd_config_per_port_rx_offload_result,
17068 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
17069 TOKEN_STRING_INITIALIZER
17070 (struct cmd_config_per_port_rx_offload_result,
17071 rx_offload, "rx_offload");
17072 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
17073 TOKEN_STRING_INITIALIZER
17074 (struct cmd_config_per_port_rx_offload_result,
17075 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
17076 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
17077 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
17078 "crc_strip#scatter#timestamp#security#keep_crc");
17079 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
17080 TOKEN_STRING_INITIALIZER
17081 (struct cmd_config_per_port_rx_offload_result,
17085 search_rx_offload(const char *name)
17087 uint64_t single_offload;
17088 const char *single_name;
17092 single_offload = 1;
17093 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
17094 single_name = rte_eth_dev_rx_offload_name(single_offload);
17095 if (!strcasecmp(single_name, name)) {
17098 } else if (!strcasecmp(single_name, "UNKNOWN"))
17100 else if (single_name == NULL)
17102 single_offload <<= 1;
17106 return single_offload;
17112 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
17113 __attribute__((unused)) struct cmdline *cl,
17114 __attribute__((unused)) void *data)
17116 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
17117 portid_t port_id = res->port_id;
17118 struct rte_eth_dev_info dev_info;
17119 struct rte_port *port = &ports[port_id];
17120 uint64_t single_offload;
17121 uint16_t nb_rx_queues;
17124 if (port->port_status != RTE_PORT_STOPPED) {
17125 printf("Error: Can't config offload when Port %d "
17126 "is not stopped\n", port_id);
17130 single_offload = search_rx_offload(res->offload);
17131 if (single_offload == 0) {
17132 printf("Unknown offload name: %s\n", res->offload);
17136 rte_eth_dev_info_get(port_id, &dev_info);
17137 nb_rx_queues = dev_info.nb_rx_queues;
17138 if (!strcmp(res->on_off, "on")) {
17139 port->dev_conf.rxmode.offloads |= single_offload;
17140 for (q = 0; q < nb_rx_queues; q++)
17141 port->rx_conf[q].offloads |= single_offload;
17143 port->dev_conf.rxmode.offloads &= ~single_offload;
17144 for (q = 0; q < nb_rx_queues; q++)
17145 port->rx_conf[q].offloads &= ~single_offload;
17148 cmd_reconfig_device_queue(port_id, 1, 1);
17151 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
17152 .f = cmd_config_per_port_rx_offload_parsed,
17154 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
17155 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
17156 "macsec_strip|header_split|vlan_filter|vlan_extend|"
17157 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
17160 (void *)&cmd_config_per_port_rx_offload_result_port,
17161 (void *)&cmd_config_per_port_rx_offload_result_config,
17162 (void *)&cmd_config_per_port_rx_offload_result_port_id,
17163 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
17164 (void *)&cmd_config_per_port_rx_offload_result_offload,
17165 (void *)&cmd_config_per_port_rx_offload_result_on_off,
17170 /* Enable/Disable a per queue offloading */
17171 struct cmd_config_per_queue_rx_offload_result {
17172 cmdline_fixed_string_t port;
17174 cmdline_fixed_string_t rxq;
17176 cmdline_fixed_string_t rx_offload;
17177 cmdline_fixed_string_t offload;
17178 cmdline_fixed_string_t on_off;
17181 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
17182 TOKEN_STRING_INITIALIZER
17183 (struct cmd_config_per_queue_rx_offload_result,
17185 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
17186 TOKEN_NUM_INITIALIZER
17187 (struct cmd_config_per_queue_rx_offload_result,
17189 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
17190 TOKEN_STRING_INITIALIZER
17191 (struct cmd_config_per_queue_rx_offload_result,
17193 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
17194 TOKEN_NUM_INITIALIZER
17195 (struct cmd_config_per_queue_rx_offload_result,
17197 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
17198 TOKEN_STRING_INITIALIZER
17199 (struct cmd_config_per_queue_rx_offload_result,
17200 rx_offload, "rx_offload");
17201 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
17202 TOKEN_STRING_INITIALIZER
17203 (struct cmd_config_per_queue_rx_offload_result,
17204 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
17205 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
17206 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
17207 "crc_strip#scatter#timestamp#security#keep_crc");
17208 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
17209 TOKEN_STRING_INITIALIZER
17210 (struct cmd_config_per_queue_rx_offload_result,
17214 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
17215 __attribute__((unused)) struct cmdline *cl,
17216 __attribute__((unused)) void *data)
17218 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
17219 struct rte_eth_dev_info dev_info;
17220 portid_t port_id = res->port_id;
17221 uint16_t queue_id = res->queue_id;
17222 struct rte_port *port = &ports[port_id];
17223 uint64_t single_offload;
17225 if (port->port_status != RTE_PORT_STOPPED) {
17226 printf("Error: Can't config offload when Port %d "
17227 "is not stopped\n", port_id);
17231 rte_eth_dev_info_get(port_id, &dev_info);
17232 if (queue_id >= dev_info.nb_rx_queues) {
17233 printf("Error: input queue_id should be 0 ... "
17234 "%d\n", dev_info.nb_rx_queues - 1);
17238 single_offload = search_rx_offload(res->offload);
17239 if (single_offload == 0) {
17240 printf("Unknown offload name: %s\n", res->offload);
17244 if (!strcmp(res->on_off, "on"))
17245 port->rx_conf[queue_id].offloads |= single_offload;
17247 port->rx_conf[queue_id].offloads &= ~single_offload;
17249 cmd_reconfig_device_queue(port_id, 1, 1);
17252 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
17253 .f = cmd_config_per_queue_rx_offload_parsed,
17255 .help_str = "port <port_id> rxq <queue_id> rx_offload "
17256 "vlan_strip|ipv4_cksum|"
17257 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
17258 "macsec_strip|header_split|vlan_filter|vlan_extend|"
17259 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
17262 (void *)&cmd_config_per_queue_rx_offload_result_port,
17263 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
17264 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
17265 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
17266 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
17267 (void *)&cmd_config_per_queue_rx_offload_result_offload,
17268 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
17273 /* Get Tx offloads capabilities */
17274 struct cmd_tx_offload_get_capa_result {
17275 cmdline_fixed_string_t show;
17276 cmdline_fixed_string_t port;
17278 cmdline_fixed_string_t tx_offload;
17279 cmdline_fixed_string_t capabilities;
17282 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
17283 TOKEN_STRING_INITIALIZER
17284 (struct cmd_tx_offload_get_capa_result,
17286 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
17287 TOKEN_STRING_INITIALIZER
17288 (struct cmd_tx_offload_get_capa_result,
17290 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
17291 TOKEN_NUM_INITIALIZER
17292 (struct cmd_tx_offload_get_capa_result,
17294 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
17295 TOKEN_STRING_INITIALIZER
17296 (struct cmd_tx_offload_get_capa_result,
17297 tx_offload, "tx_offload");
17298 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
17299 TOKEN_STRING_INITIALIZER
17300 (struct cmd_tx_offload_get_capa_result,
17301 capabilities, "capabilities");
17304 print_tx_offloads(uint64_t offloads)
17306 uint64_t single_offload;
17314 begin = __builtin_ctzll(offloads);
17315 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17317 single_offload = 1 << begin;
17318 for (bit = begin; bit < end; bit++) {
17319 if (offloads & single_offload)
17321 rte_eth_dev_tx_offload_name(single_offload));
17322 single_offload <<= 1;
17327 cmd_tx_offload_get_capa_parsed(
17328 void *parsed_result,
17329 __attribute__((unused)) struct cmdline *cl,
17330 __attribute__((unused)) void *data)
17332 struct cmd_tx_offload_get_capa_result *res = parsed_result;
17333 struct rte_eth_dev_info dev_info;
17334 portid_t port_id = res->port_id;
17335 uint64_t queue_offloads;
17336 uint64_t port_offloads;
17338 rte_eth_dev_info_get(port_id, &dev_info);
17339 queue_offloads = dev_info.tx_queue_offload_capa;
17340 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
17342 printf("Tx Offloading Capabilities of port %d :\n", port_id);
17343 printf(" Per Queue :");
17344 print_tx_offloads(queue_offloads);
17347 printf(" Per Port :");
17348 print_tx_offloads(port_offloads);
17352 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
17353 .f = cmd_tx_offload_get_capa_parsed,
17355 .help_str = "show port <port_id> tx_offload capabilities",
17357 (void *)&cmd_tx_offload_get_capa_show,
17358 (void *)&cmd_tx_offload_get_capa_port,
17359 (void *)&cmd_tx_offload_get_capa_port_id,
17360 (void *)&cmd_tx_offload_get_capa_tx_offload,
17361 (void *)&cmd_tx_offload_get_capa_capabilities,
17366 /* Get Tx offloads configuration */
17367 struct cmd_tx_offload_get_configuration_result {
17368 cmdline_fixed_string_t show;
17369 cmdline_fixed_string_t port;
17371 cmdline_fixed_string_t tx_offload;
17372 cmdline_fixed_string_t configuration;
17375 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
17376 TOKEN_STRING_INITIALIZER
17377 (struct cmd_tx_offload_get_configuration_result,
17379 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
17380 TOKEN_STRING_INITIALIZER
17381 (struct cmd_tx_offload_get_configuration_result,
17383 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
17384 TOKEN_NUM_INITIALIZER
17385 (struct cmd_tx_offload_get_configuration_result,
17387 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
17388 TOKEN_STRING_INITIALIZER
17389 (struct cmd_tx_offload_get_configuration_result,
17390 tx_offload, "tx_offload");
17391 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
17392 TOKEN_STRING_INITIALIZER
17393 (struct cmd_tx_offload_get_configuration_result,
17394 configuration, "configuration");
17397 cmd_tx_offload_get_configuration_parsed(
17398 void *parsed_result,
17399 __attribute__((unused)) struct cmdline *cl,
17400 __attribute__((unused)) void *data)
17402 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
17403 struct rte_eth_dev_info dev_info;
17404 portid_t port_id = res->port_id;
17405 struct rte_port *port = &ports[port_id];
17406 uint64_t port_offloads;
17407 uint64_t queue_offloads;
17408 uint16_t nb_tx_queues;
17411 printf("Tx Offloading Configuration of port %d :\n", port_id);
17413 port_offloads = port->dev_conf.txmode.offloads;
17415 print_tx_offloads(port_offloads);
17418 rte_eth_dev_info_get(port_id, &dev_info);
17419 nb_tx_queues = dev_info.nb_tx_queues;
17420 for (q = 0; q < nb_tx_queues; q++) {
17421 queue_offloads = port->tx_conf[q].offloads;
17422 printf(" Queue[%2d] :", q);
17423 print_tx_offloads(queue_offloads);
17429 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
17430 .f = cmd_tx_offload_get_configuration_parsed,
17432 .help_str = "show port <port_id> tx_offload configuration",
17434 (void *)&cmd_tx_offload_get_configuration_show,
17435 (void *)&cmd_tx_offload_get_configuration_port,
17436 (void *)&cmd_tx_offload_get_configuration_port_id,
17437 (void *)&cmd_tx_offload_get_configuration_tx_offload,
17438 (void *)&cmd_tx_offload_get_configuration_configuration,
17443 /* Enable/Disable a per port offloading */
17444 struct cmd_config_per_port_tx_offload_result {
17445 cmdline_fixed_string_t port;
17446 cmdline_fixed_string_t config;
17448 cmdline_fixed_string_t tx_offload;
17449 cmdline_fixed_string_t offload;
17450 cmdline_fixed_string_t on_off;
17453 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
17454 TOKEN_STRING_INITIALIZER
17455 (struct cmd_config_per_port_tx_offload_result,
17457 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
17458 TOKEN_STRING_INITIALIZER
17459 (struct cmd_config_per_port_tx_offload_result,
17461 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
17462 TOKEN_NUM_INITIALIZER
17463 (struct cmd_config_per_port_tx_offload_result,
17465 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
17466 TOKEN_STRING_INITIALIZER
17467 (struct cmd_config_per_port_tx_offload_result,
17468 tx_offload, "tx_offload");
17469 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
17470 TOKEN_STRING_INITIALIZER
17471 (struct cmd_config_per_port_tx_offload_result,
17472 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
17473 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
17474 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
17475 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
17476 "mt_lockfree#multi_segs#mbuf_fast_free#security");
17477 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
17478 TOKEN_STRING_INITIALIZER
17479 (struct cmd_config_per_port_tx_offload_result,
17483 search_tx_offload(const char *name)
17485 uint64_t single_offload;
17486 const char *single_name;
17490 single_offload = 1;
17491 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
17492 single_name = rte_eth_dev_tx_offload_name(single_offload);
17493 if (!strcasecmp(single_name, name)) {
17496 } else if (!strcasecmp(single_name, "UNKNOWN"))
17498 else if (single_name == NULL)
17500 single_offload <<= 1;
17504 return single_offload;
17510 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
17511 __attribute__((unused)) struct cmdline *cl,
17512 __attribute__((unused)) void *data)
17514 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
17515 portid_t port_id = res->port_id;
17516 struct rte_eth_dev_info dev_info;
17517 struct rte_port *port = &ports[port_id];
17518 uint64_t single_offload;
17519 uint16_t nb_tx_queues;
17522 if (port->port_status != RTE_PORT_STOPPED) {
17523 printf("Error: Can't config offload when Port %d "
17524 "is not stopped\n", port_id);
17528 single_offload = search_tx_offload(res->offload);
17529 if (single_offload == 0) {
17530 printf("Unknown offload name: %s\n", res->offload);
17534 rte_eth_dev_info_get(port_id, &dev_info);
17535 nb_tx_queues = dev_info.nb_tx_queues;
17536 if (!strcmp(res->on_off, "on")) {
17537 port->dev_conf.txmode.offloads |= single_offload;
17538 for (q = 0; q < nb_tx_queues; q++)
17539 port->tx_conf[q].offloads |= single_offload;
17541 port->dev_conf.txmode.offloads &= ~single_offload;
17542 for (q = 0; q < nb_tx_queues; q++)
17543 port->tx_conf[q].offloads &= ~single_offload;
17546 cmd_reconfig_device_queue(port_id, 1, 1);
17549 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
17550 .f = cmd_config_per_port_tx_offload_parsed,
17552 .help_str = "port config <port_id> tx_offload "
17553 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
17554 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
17555 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
17556 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
17557 "mt_lockfree|multi_segs|mbuf_fast_free|security "
17560 (void *)&cmd_config_per_port_tx_offload_result_port,
17561 (void *)&cmd_config_per_port_tx_offload_result_config,
17562 (void *)&cmd_config_per_port_tx_offload_result_port_id,
17563 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
17564 (void *)&cmd_config_per_port_tx_offload_result_offload,
17565 (void *)&cmd_config_per_port_tx_offload_result_on_off,
17570 /* Enable/Disable a per queue offloading */
17571 struct cmd_config_per_queue_tx_offload_result {
17572 cmdline_fixed_string_t port;
17574 cmdline_fixed_string_t txq;
17576 cmdline_fixed_string_t tx_offload;
17577 cmdline_fixed_string_t offload;
17578 cmdline_fixed_string_t on_off;
17581 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
17582 TOKEN_STRING_INITIALIZER
17583 (struct cmd_config_per_queue_tx_offload_result,
17585 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
17586 TOKEN_NUM_INITIALIZER
17587 (struct cmd_config_per_queue_tx_offload_result,
17589 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
17590 TOKEN_STRING_INITIALIZER
17591 (struct cmd_config_per_queue_tx_offload_result,
17593 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
17594 TOKEN_NUM_INITIALIZER
17595 (struct cmd_config_per_queue_tx_offload_result,
17597 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
17598 TOKEN_STRING_INITIALIZER
17599 (struct cmd_config_per_queue_tx_offload_result,
17600 tx_offload, "tx_offload");
17601 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
17602 TOKEN_STRING_INITIALIZER
17603 (struct cmd_config_per_queue_tx_offload_result,
17604 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
17605 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
17606 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
17607 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
17608 "mt_lockfree#multi_segs#mbuf_fast_free#security");
17609 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
17610 TOKEN_STRING_INITIALIZER
17611 (struct cmd_config_per_queue_tx_offload_result,
17615 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
17616 __attribute__((unused)) struct cmdline *cl,
17617 __attribute__((unused)) void *data)
17619 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
17620 struct rte_eth_dev_info dev_info;
17621 portid_t port_id = res->port_id;
17622 uint16_t queue_id = res->queue_id;
17623 struct rte_port *port = &ports[port_id];
17624 uint64_t single_offload;
17626 if (port->port_status != RTE_PORT_STOPPED) {
17627 printf("Error: Can't config offload when Port %d "
17628 "is not stopped\n", port_id);
17632 rte_eth_dev_info_get(port_id, &dev_info);
17633 if (queue_id >= dev_info.nb_tx_queues) {
17634 printf("Error: input queue_id should be 0 ... "
17635 "%d\n", dev_info.nb_tx_queues - 1);
17639 single_offload = search_tx_offload(res->offload);
17640 if (single_offload == 0) {
17641 printf("Unknown offload name: %s\n", res->offload);
17645 if (!strcmp(res->on_off, "on"))
17646 port->tx_conf[queue_id].offloads |= single_offload;
17648 port->tx_conf[queue_id].offloads &= ~single_offload;
17650 cmd_reconfig_device_queue(port_id, 1, 1);
17653 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
17654 .f = cmd_config_per_queue_tx_offload_parsed,
17656 .help_str = "port <port_id> txq <queue_id> tx_offload "
17657 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
17658 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
17659 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
17660 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
17661 "mt_lockfree|multi_segs|mbuf_fast_free|security "
17664 (void *)&cmd_config_per_queue_tx_offload_result_port,
17665 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
17666 (void *)&cmd_config_per_queue_tx_offload_result_txq,
17667 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
17668 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
17669 (void *)&cmd_config_per_queue_tx_offload_result_offload,
17670 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
17675 /* ******************************************************************************** */
17677 /* list of instructions */
17678 cmdline_parse_ctx_t main_ctx[] = {
17679 (cmdline_parse_inst_t *)&cmd_help_brief,
17680 (cmdline_parse_inst_t *)&cmd_help_long,
17681 (cmdline_parse_inst_t *)&cmd_quit,
17682 (cmdline_parse_inst_t *)&cmd_load_from_file,
17683 (cmdline_parse_inst_t *)&cmd_showport,
17684 (cmdline_parse_inst_t *)&cmd_showqueue,
17685 (cmdline_parse_inst_t *)&cmd_showportall,
17686 (cmdline_parse_inst_t *)&cmd_showcfg,
17687 (cmdline_parse_inst_t *)&cmd_start,
17688 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17689 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17690 (cmdline_parse_inst_t *)&cmd_set_link_up,
17691 (cmdline_parse_inst_t *)&cmd_set_link_down,
17692 (cmdline_parse_inst_t *)&cmd_reset,
17693 (cmdline_parse_inst_t *)&cmd_set_numbers,
17694 (cmdline_parse_inst_t *)&cmd_set_log,
17695 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17696 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17697 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17698 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17699 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17700 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17701 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17702 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17703 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17704 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17705 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17706 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17707 (cmdline_parse_inst_t *)&cmd_set_link_check,
17708 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17709 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17710 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17711 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17712 #ifdef RTE_LIBRTE_PMD_BOND
17713 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17714 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17715 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17716 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17717 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17718 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17719 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17720 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17721 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17722 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17723 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17725 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17726 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17727 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17728 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17729 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17730 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17731 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17732 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17733 (cmdline_parse_inst_t *)&cmd_csum_set,
17734 (cmdline_parse_inst_t *)&cmd_csum_show,
17735 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17736 (cmdline_parse_inst_t *)&cmd_tso_set,
17737 (cmdline_parse_inst_t *)&cmd_tso_show,
17738 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17739 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17740 (cmdline_parse_inst_t *)&cmd_gro_enable,
17741 (cmdline_parse_inst_t *)&cmd_gro_flush,
17742 (cmdline_parse_inst_t *)&cmd_gro_show,
17743 (cmdline_parse_inst_t *)&cmd_gso_enable,
17744 (cmdline_parse_inst_t *)&cmd_gso_size,
17745 (cmdline_parse_inst_t *)&cmd_gso_show,
17746 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17747 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17748 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17749 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17750 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17751 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17752 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17753 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17754 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17755 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17756 (cmdline_parse_inst_t *)&cmd_config_dcb,
17757 (cmdline_parse_inst_t *)&cmd_read_reg,
17758 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17759 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17760 (cmdline_parse_inst_t *)&cmd_write_reg,
17761 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17762 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17763 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17764 (cmdline_parse_inst_t *)&cmd_stop,
17765 (cmdline_parse_inst_t *)&cmd_mac_addr,
17766 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17767 (cmdline_parse_inst_t *)&cmd_set_qmap,
17768 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17769 (cmdline_parse_inst_t *)&cmd_operate_port,
17770 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17771 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17772 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17773 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17774 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17775 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17776 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17777 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17778 (cmdline_parse_inst_t *)&cmd_config_mtu,
17779 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17780 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17781 (cmdline_parse_inst_t *)&cmd_config_rss,
17782 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17783 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17784 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17785 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17786 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17787 (cmdline_parse_inst_t *)&cmd_showport_reta,
17788 (cmdline_parse_inst_t *)&cmd_config_burst,
17789 (cmdline_parse_inst_t *)&cmd_config_thresh,
17790 (cmdline_parse_inst_t *)&cmd_config_threshold,
17791 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17792 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17793 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17794 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
17795 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17796 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
17797 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17798 (cmdline_parse_inst_t *)&cmd_global_config,
17799 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
17800 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
17801 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
17802 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17803 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17804 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17805 (cmdline_parse_inst_t *)&cmd_dump,
17806 (cmdline_parse_inst_t *)&cmd_dump_one,
17807 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
17808 (cmdline_parse_inst_t *)&cmd_syn_filter,
17809 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
17810 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
17811 (cmdline_parse_inst_t *)&cmd_flex_filter,
17812 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
17813 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
17814 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
17815 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
17816 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
17817 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
17818 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17819 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
17820 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17821 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17822 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17823 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
17824 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17825 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
17826 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
17827 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
17828 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
17829 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
17830 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
17831 (cmdline_parse_inst_t *)&cmd_flow,
17832 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17833 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17834 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17835 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17836 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17837 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17838 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17839 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17840 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17841 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17842 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
17843 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17844 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17845 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17846 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
17847 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
17848 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
17849 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
17850 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
17851 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
17852 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
17853 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
17854 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
17855 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
17856 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17857 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17858 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17859 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17860 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17861 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17862 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17863 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17864 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17865 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17866 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17867 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17868 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17869 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17870 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17871 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17872 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17873 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17874 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17875 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17876 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17877 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17878 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17879 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17880 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17881 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
17882 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
17884 (cmdline_parse_inst_t *)&cmd_set_vxlan,
17885 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17886 (cmdline_parse_inst_t *)&cmd_set_nvgre,
17887 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17888 (cmdline_parse_inst_t *)&cmd_ddp_add,
17889 (cmdline_parse_inst_t *)&cmd_ddp_del,
17890 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17891 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17892 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17893 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17894 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17895 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17896 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17897 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17898 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17899 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17901 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17902 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17903 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17904 (cmdline_parse_inst_t *)&cmd_queue_region,
17905 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17906 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17907 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17908 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17909 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17910 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17911 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17912 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17913 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17914 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17915 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17916 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17917 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17918 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17919 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17920 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17921 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17922 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17923 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17924 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17925 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17926 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17927 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17928 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17929 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17930 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17931 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17932 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17933 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17934 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17935 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17936 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17937 #ifdef RTE_LIBRTE_BPF
17938 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17939 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17944 /* read cmdline commands from file */
17946 cmdline_read_from_file(const char *filename)
17948 struct cmdline *cl;
17950 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17952 printf("Failed to create file based cmdline context: %s\n",
17957 cmdline_interact(cl);
17962 printf("Read CLI commands from %s\n", filename);
17965 /* prompt function, called from main on MASTER lcore */
17969 /* initialize non-constant commands */
17970 cmd_set_fwd_mode_init();
17971 cmd_set_fwd_retry_mode_init();
17973 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17974 if (testpmd_cl == NULL)
17976 cmdline_interact(testpmd_cl);
17977 cmdline_stdin_exit(testpmd_cl);
17983 if (testpmd_cl != NULL)
17984 cmdline_quit(testpmd_cl);
17988 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17990 if (id == (portid_t)RTE_PORT_ALL) {
17993 RTE_ETH_FOREACH_DEV(pid) {
17994 /* check if need_reconfig has been set to 1 */
17995 if (ports[pid].need_reconfig == 0)
17996 ports[pid].need_reconfig = dev;
17997 /* check if need_reconfig_queues has been set to 1 */
17998 if (ports[pid].need_reconfig_queues == 0)
17999 ports[pid].need_reconfig_queues = queue;
18001 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
18002 /* check if need_reconfig has been set to 1 */
18003 if (ports[id].need_reconfig == 0)
18004 ports[id].need_reconfig = dev;
18005 /* check if need_reconfig_queues has been set to 1 */
18006 if (ports[id].need_reconfig_queues == 0)
18007 ports[id].need_reconfig_queues = queue;