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 traffic_management : Traffic Management commmands.\n"
105 " help all : All of the above sections.\n\n"
110 cmdline_parse_token_string_t cmd_help_brief_help =
111 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
113 cmdline_parse_inst_t cmd_help_brief = {
114 .f = cmd_help_brief_parsed,
116 .help_str = "help: Show help",
118 (void *)&cmd_help_brief_help,
123 /* *** Help command with help sections. *** */
124 struct cmd_help_long_result {
125 cmdline_fixed_string_t help;
126 cmdline_fixed_string_t section;
129 static void cmd_help_long_parsed(void *parsed_result,
131 __attribute__((unused)) void *data)
134 struct cmd_help_long_result *res = parsed_result;
136 if (!strcmp(res->section, "all"))
139 if (show_all || !strcmp(res->section, "control")) {
144 "Control forwarding:\n"
145 "-------------------\n\n"
148 " Start packet forwarding with current configuration.\n\n"
151 " Start packet forwarding with current config"
152 " after sending one burst of packets.\n\n"
155 " Stop packet forwarding, and display accumulated"
159 " Quit to prompt.\n\n"
163 if (show_all || !strcmp(res->section, "display")) {
171 "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
172 " Display information for port_id, or all.\n\n"
174 "show port X rss reta (size) (mask0,mask1,...)\n"
175 " Display the rss redirection table entry indicated"
176 " by masks on port X. size is used to indicate the"
177 " hardware supported reta size\n\n"
179 "show port (port_id) rss-hash [key]\n"
180 " Display the RSS hash functions and RSS hash key of port\n\n"
182 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
183 " Clear information for port_id, or all.\n\n"
185 "show (rxq|txq) info (port_id) (queue_id)\n"
186 " Display information for configured RX/TX queue.\n\n"
188 "show config (rxtx|cores|fwd|txpkts)\n"
189 " Display the given configuration.\n\n"
191 "read rxd (port_id) (queue_id) (rxd_id)\n"
192 " Display an RX descriptor of a port RX queue.\n\n"
194 "read txd (port_id) (queue_id) (txd_id)\n"
195 " Display a TX descriptor of a port TX queue.\n\n"
197 "ddp get list (port_id)\n"
198 " Get ddp profile info list\n\n"
200 "ddp get info (profile_path)\n"
201 " Get ddp profile information.\n\n"
203 "show vf stats (port_id) (vf_id)\n"
204 " Display a VF's statistics.\n\n"
206 "clear vf stats (port_id) (vf_id)\n"
207 " Reset a VF's statistics.\n\n"
209 "show port (port_id) pctype mapping\n"
210 " Get flow ptype to pctype mapping on a port\n\n"
212 "show port meter stats (port_id) (meter_id) (clear)\n"
213 " Get meter stats on a port\n\n"
215 "show fwd stats all\n"
216 " Display statistics for all fwd engines.\n\n"
218 "clear fwd stats all\n"
219 " Clear statistics for all fwd engines.\n\n"
221 "show port (port_id) rx_offload capabilities\n"
222 " List all per queue and per port Rx offloading"
223 " capabilities of a port\n\n"
225 "show port (port_id) rx_offload configuration\n"
226 " List port level and all queue level"
227 " Rx offloading configuration\n\n"
229 "show port (port_id) tx_offload capabilities\n"
230 " List all per queue and per port"
231 " Tx offloading capabilities of a port\n\n"
233 "show port (port_id) tx_offload configuration\n"
234 " List port level and all queue level"
235 " Tx offloading configuration\n\n"
237 "show port (port_id) tx_metadata\n"
238 " Show Tx metadata value set"
239 " for a specific port\n\n"
243 if (show_all || !strcmp(res->section, "config")) {
249 "Configuration changes only become active when"
250 " forwarding is started/restarted.\n\n"
253 " Reset forwarding to the default configuration.\n\n"
255 "set verbose (level)\n"
256 " Set the debug verbosity level X.\n\n"
258 "set log global|(type) (level)\n"
259 " Set the log level.\n\n"
262 " Set number of ports.\n\n"
265 " Set number of cores.\n\n"
267 "set coremask (mask)\n"
268 " Set the forwarding cores hexadecimal mask.\n\n"
270 "set portmask (mask)\n"
271 " Set the forwarding ports hexadecimal mask.\n\n"
274 " Set number of packets per burst.\n\n"
276 "set burst tx delay (microseconds) retry (num)\n"
277 " Set the transmit delay time and number of retries,"
278 " effective when retry is enabled.\n\n"
280 "set txpkts (x[,y]*)\n"
281 " Set the length of each segment of TXONLY"
282 " and optionally CSUM packets.\n\n"
284 "set txsplit (off|on|rand)\n"
285 " Set the split policy for the TX packets."
286 " Right now only applicable for CSUM and TXONLY"
289 "set corelist (x[,y]*)\n"
290 " Set the list of forwarding cores.\n\n"
292 "set portlist (x[,y]*)\n"
293 " Set the list of forwarding ports.\n\n"
295 "set port setup on (iterator|event)\n"
296 " Select how attached port is retrieved for setup.\n\n"
298 "set tx loopback (port_id) (on|off)\n"
299 " Enable or disable tx loopback.\n\n"
301 "set all queues drop (port_id) (on|off)\n"
302 " Set drop enable bit for all queues.\n\n"
304 "set vf split drop (port_id) (vf_id) (on|off)\n"
305 " Set split drop enable bit for a VF from the PF.\n\n"
307 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
308 " Set MAC antispoof for a VF from the PF.\n\n"
310 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
311 " Enable MACsec offload.\n\n"
313 "set macsec offload (port_id) off\n"
314 " Disable MACsec offload.\n\n"
316 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
317 " Configure MACsec secure connection (SC).\n\n"
319 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
320 " Configure MACsec secure association (SA).\n\n"
322 "set vf broadcast (port_id) (vf_id) (on|off)\n"
323 " Set VF broadcast for a VF from the PF.\n\n"
325 "vlan set strip (on|off) (port_id)\n"
326 " Set the VLAN strip on a port.\n\n"
328 "vlan set stripq (on|off) (port_id,queue_id)\n"
329 " Set the VLAN strip for a queue on a port.\n\n"
331 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
332 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
334 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
335 " Set VLAN insert for a VF from the PF.\n\n"
337 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
338 " Set VLAN antispoof for a VF from the PF.\n\n"
340 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
341 " Set VLAN tag for a VF from the PF.\n\n"
343 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
344 " Set a VF's max bandwidth(Mbps).\n\n"
346 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
347 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
349 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
350 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
352 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
353 " Set some TCs' strict link priority mode on a physical port.\n\n"
355 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
356 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
358 "vlan set filter (on|off) (port_id)\n"
359 " Set the VLAN filter on a port.\n\n"
361 "vlan set qinq (on|off) (port_id)\n"
362 " Set the VLAN QinQ (extended queue in queue)"
365 "vlan set (inner|outer) tpid (value) (port_id)\n"
366 " Set the VLAN TPID for Packet Filtering on"
369 "rx_vlan add (vlan_id|all) (port_id)\n"
370 " Add a vlan_id, or all identifiers, to the set"
371 " of VLAN identifiers filtered by port_id.\n\n"
373 "rx_vlan rm (vlan_id|all) (port_id)\n"
374 " Remove a vlan_id, or all identifiers, from the set"
375 " of VLAN identifiers filtered by port_id.\n\n"
377 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
378 " Add a vlan_id, to the set of VLAN identifiers"
379 "filtered for VF(s) from port_id.\n\n"
381 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
382 " Remove a vlan_id, to the set of VLAN identifiers"
383 "filtered for VF(s) from port_id.\n\n"
385 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
386 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
387 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
388 " add a tunnel filter of a port.\n\n"
390 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
391 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
392 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
393 " remove a tunnel filter of a port.\n\n"
395 "rx_vxlan_port add (udp_port) (port_id)\n"
396 " Add an UDP port for VXLAN packet filter on a port\n\n"
398 "rx_vxlan_port rm (udp_port) (port_id)\n"
399 " Remove an UDP port for VXLAN packet filter on a port\n\n"
401 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
402 " Set hardware insertion of VLAN IDs (single or double VLAN "
403 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
405 "tx_vlan set pvid port_id vlan_id (on|off)\n"
406 " Set port based TX VLAN insertion.\n\n"
408 "tx_vlan reset (port_id)\n"
409 " Disable hardware insertion of a VLAN header in"
410 " packets sent on a port.\n\n"
412 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
413 " Select hardware or software calculation of the"
414 " checksum when transmitting a packet using the"
415 " csum forward engine.\n"
416 " ip|udp|tcp|sctp always concern the inner layer.\n"
417 " outer-ip concerns the outer IP layer in"
418 " outer-udp concerns the outer UDP layer in"
419 " case the packet is recognized as a tunnel packet by"
420 " the forward engine (vxlan, gre and ipip are supported)\n"
421 " Please check the NIC datasheet for HW limits.\n\n"
423 "csum parse-tunnel (on|off) (tx_port_id)\n"
424 " If disabled, treat tunnel packets as non-tunneled"
425 " packets (treat inner headers as payload). The port\n"
426 " argument is the port used for TX in csum forward"
429 "csum show (port_id)\n"
430 " Display tx checksum offload configuration\n\n"
432 "tso set (segsize) (portid)\n"
433 " Enable TCP Segmentation Offload in csum forward"
435 " Please check the NIC datasheet for HW limits.\n\n"
438 " Display the status of TCP Segmentation Offload.\n\n"
440 "set port (port_id) gro on|off\n"
441 " Enable or disable Generic Receive Offload in"
442 " csum forwarding engine.\n\n"
444 "show port (port_id) gro\n"
445 " Display GRO configuration.\n\n"
447 "set gro flush (cycles)\n"
448 " Set the cycle to flush GROed packets from"
449 " reassembly tables.\n\n"
451 "set port (port_id) gso (on|off)"
452 " Enable or disable Generic Segmentation Offload in"
453 " csum forwarding engine.\n\n"
455 "set gso segsz (length)\n"
456 " Set max packet length for output GSO segments,"
457 " including packet header and payload.\n\n"
459 "show port (port_id) gso\n"
460 " Show GSO configuration.\n\n"
463 " Set packet forwarding mode.\n\n"
465 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
466 " Add a MAC address on port_id.\n\n"
468 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
469 " Remove a MAC address from port_id.\n\n"
471 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
472 " Set the default MAC address for port_id.\n\n"
474 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
475 " Add a MAC address for a VF on the port.\n\n"
477 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
478 " Set the MAC address for a VF from the PF.\n\n"
480 "set eth-peer (port_id) (peer_addr)\n"
481 " set the peer address for certain port.\n\n"
483 "set port (port_id) uta (mac_address|all) (on|off)\n"
484 " Add/Remove a or all unicast hash filter(s)"
487 "set promisc (port_id|all) (on|off)\n"
488 " Set the promiscuous mode on port_id, or all.\n\n"
490 "set allmulti (port_id|all) (on|off)\n"
491 " Set the allmulti mode on port_id, or all.\n\n"
493 "set vf promisc (port_id) (vf_id) (on|off)\n"
494 " Set unicast promiscuous mode for a VF from the PF.\n\n"
496 "set vf allmulti (port_id) (vf_id) (on|off)\n"
497 " Set multicast promiscuous mode for a VF from the PF.\n\n"
499 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
500 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
501 " (on|off) autoneg (on|off) (port_id)\n"
502 "set flow_ctrl rx (on|off) (portid)\n"
503 "set flow_ctrl tx (on|off) (portid)\n"
504 "set flow_ctrl high_water (high_water) (portid)\n"
505 "set flow_ctrl low_water (low_water) (portid)\n"
506 "set flow_ctrl pause_time (pause_time) (portid)\n"
507 "set flow_ctrl send_xon (send_xon) (portid)\n"
508 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
509 "set flow_ctrl autoneg (on|off) (port_id)\n"
510 " Set the link flow control parameter on a port.\n\n"
512 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
513 " (low_water) (pause_time) (priority) (port_id)\n"
514 " Set the priority flow control parameter on a"
517 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
518 " Set statistics mapping (qmapping 0..15) for RX/TX"
520 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
521 " on port 0 to mapping 5.\n\n"
523 "set xstats-hide-zero on|off\n"
524 " Set the option to hide the zero values"
525 " for xstats display.\n"
527 "set port (port_id) vf (vf_id) rx|tx on|off\n"
528 " Enable/Disable a VF receive/tranmit from a port\n\n"
530 "set port (port_id) vf (vf_id) (mac_addr)"
531 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
532 " Add/Remove unicast or multicast MAC addr filter"
535 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
537 " AUPE:accepts untagged VLAN;"
538 "ROPE:accept unicast hash\n\n"
539 " BAM:accepts broadcast packets;"
540 "MPE:accepts all multicast packets\n\n"
541 " Enable/Disable a VF receive mode of a port\n\n"
543 "set port (port_id) queue (queue_id) rate (rate_num)\n"
544 " Set rate limit for a queue of a port\n\n"
546 "set port (port_id) vf (vf_id) rate (rate_num) "
547 "queue_mask (queue_mask_value)\n"
548 " Set rate limit for queues in VF of a port\n\n"
550 "set port (port_id) mirror-rule (rule_id)"
551 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
552 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
553 " Set pool or vlan type mirror rule on a port.\n"
554 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
555 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
558 "set port (port_id) mirror-rule (rule_id)"
559 " (uplink-mirror|downlink-mirror) dst-pool"
560 " (pool_id) (on|off)\n"
561 " Set uplink or downlink type mirror rule on a port.\n"
562 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
563 " 0 on' enable mirror income traffic to pool 0.\n\n"
565 "reset port (port_id) mirror-rule (rule_id)\n"
566 " Reset a mirror rule.\n\n"
568 "set flush_rx (on|off)\n"
569 " Flush (default) or don't flush RX streams before"
570 " forwarding. Mainly used with PCAP drivers.\n\n"
572 "set bypass mode (normal|bypass|isolate) (port_id)\n"
573 " Set the bypass mode for the lowest port on bypass enabled"
576 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
577 "mode (normal|bypass|isolate) (port_id)\n"
578 " Set the event required to initiate specified bypass mode for"
579 " the lowest port on a bypass enabled NIC where:\n"
580 " timeout = enable bypass after watchdog timeout.\n"
581 " os_on = enable bypass when OS/board is powered on.\n"
582 " os_off = enable bypass when OS/board is powered off.\n"
583 " power_on = enable bypass when power supply is turned on.\n"
584 " power_off = enable bypass when power supply is turned off."
587 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
588 " Set the bypass watchdog timeout to 'n' seconds"
589 " where 0 = instant.\n\n"
591 "show bypass config (port_id)\n"
592 " Show the bypass configuration for a bypass enabled NIC"
593 " using the lowest port on the NIC.\n\n"
595 #ifdef RTE_LIBRTE_PMD_BOND
596 "create bonded device (mode) (socket)\n"
597 " Create a new bonded device with specific bonding mode and socket.\n\n"
599 "add bonding slave (slave_id) (port_id)\n"
600 " Add a slave device to a bonded device.\n\n"
602 "remove bonding slave (slave_id) (port_id)\n"
603 " Remove a slave device from a bonded device.\n\n"
605 "set bonding mode (value) (port_id)\n"
606 " Set the bonding mode on a bonded device.\n\n"
608 "set bonding primary (slave_id) (port_id)\n"
609 " Set the primary slave for a bonded device.\n\n"
611 "show bonding config (port_id)\n"
612 " Show the bonding config for port_id.\n\n"
614 "set bonding mac_addr (port_id) (address)\n"
615 " Set the MAC address of a bonded device.\n\n"
617 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
618 " Set Aggregation mode for IEEE802.3AD (mode 4)"
620 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
621 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
623 "set bonding mon_period (port_id) (value)\n"
624 " Set the bonding link status monitoring polling period in ms.\n\n"
626 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
627 " Enable/disable dedicated queues for LACP control traffic.\n\n"
630 "set link-up port (port_id)\n"
631 " Set link up for a port.\n\n"
633 "set link-down port (port_id)\n"
634 " Set link down for a port.\n\n"
636 "E-tag set insertion on port-tag-id (value)"
637 " port (port_id) vf (vf_id)\n"
638 " Enable E-tag insertion for a VF on a port\n\n"
640 "E-tag set insertion off port (port_id) vf (vf_id)\n"
641 " Disable E-tag insertion for a VF on a port\n\n"
643 "E-tag set stripping (on|off) port (port_id)\n"
644 " Enable/disable E-tag stripping on a port\n\n"
646 "E-tag set forwarding (on|off) port (port_id)\n"
647 " Enable/disable E-tag based forwarding"
650 "E-tag set filter add e-tag-id (value) dst-pool"
651 " (pool_id) port (port_id)\n"
652 " Add an E-tag forwarding filter on a port\n\n"
654 "E-tag set filter del e-tag-id (value) port (port_id)\n"
655 " Delete an E-tag forwarding filter on a port\n\n"
657 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
658 " Load a profile package on a port\n\n"
660 "ddp del (port_id) (backup_profile_path)\n"
661 " Delete a profile package from a port\n\n"
663 "ptype mapping get (port_id) (valid_only)\n"
664 " Get ptype mapping on a port\n\n"
666 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
667 " Replace target with the pkt_type in ptype mapping\n\n"
669 "ptype mapping reset (port_id)\n"
670 " Reset ptype mapping on a port\n\n"
672 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
673 " Update a ptype mapping item on a port\n\n"
675 "set port (port_id) queue-region region_id (value) "
676 "queue_start_index (value) queue_num (value)\n"
677 " Set a queue region on a port\n\n"
679 "set port (port_id) queue-region region_id (value) "
681 " Set a flowtype region index on a port\n\n"
683 "set port (port_id) queue-region UP (value) region_id (value)\n"
684 " Set the mapping of User Priority to "
685 "queue region on a port\n\n"
687 "set port (port_id) queue-region flush (on|off)\n"
688 " flush all queue region related configuration\n\n"
690 "show port meter cap (port_id)\n"
691 " Show port meter capability information\n\n"
693 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
694 " meter profile add - srtcm rfc 2697\n\n"
696 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
697 " meter profile add - trtcm rfc 2698\n\n"
699 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
700 " meter profile add - trtcm rfc 4115\n\n"
702 "del port meter profile (port_id) (profile_id)\n"
703 " meter profile delete\n\n"
705 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
706 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
707 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
708 "(dscp_tbl_entry63)]\n"
711 "enable port meter (port_id) (mtr_id)\n"
714 "disable port meter (port_id) (mtr_id)\n"
717 "del port meter (port_id) (mtr_id)\n"
720 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
721 " meter update meter profile\n\n"
723 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
724 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
725 " update meter dscp table entries\n\n"
727 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
728 "(action0) [(action1) (action2)]\n"
729 " meter update policer action\n\n"
731 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
732 " meter update stats\n\n"
734 "show port (port_id) queue-region\n"
735 " show all queue region related configuration info\n\n"
737 "vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
738 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
739 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
740 " Configure the VXLAN encapsulation for flows.\n\n"
742 "vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
743 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
744 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
745 " eth-dst (eth-dst)\n"
746 " Configure the VXLAN encapsulation for flows.\n\n"
748 "nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
749 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
751 " Configure the NVGRE encapsulation for flows.\n\n"
753 "nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
754 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
755 " eth-src (eth-src) eth-dst (eth-dst)\n"
756 " Configure the NVGRE encapsulation for flows.\n\n"
758 , list_pkt_forwarding_modes()
762 if (show_all || !strcmp(res->section, "ports")) {
768 "----------------\n\n"
770 "port start (port_id|all)\n"
771 " Start all ports or port_id.\n\n"
773 "port stop (port_id|all)\n"
774 " Stop all ports or port_id.\n\n"
776 "port close (port_id|all)\n"
777 " Close all ports or port_id.\n\n"
779 "port attach (ident)\n"
780 " Attach physical or virtual dev by pci address or virtual device name\n\n"
782 "port detach (port_id)\n"
783 " Detach physical or virtual dev by port_id\n\n"
785 "port config (port_id|all)"
786 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
787 " duplex (half|full|auto)\n"
788 " Set speed and duplex for all ports or port_id\n\n"
790 "port config (port_id|all) loopback (mode)\n"
791 " Set loopback mode for all ports or port_id\n\n"
793 "port config all (rxq|txq|rxd|txd) (value)\n"
794 " Set number for rxq/txq/rxd/txd.\n\n"
796 "port config all max-pkt-len (value)\n"
797 " Set the max packet length.\n\n"
799 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
800 "hw-vlan-strip|hw-vlan-extend|drop-en)"
802 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
805 "port config all rss (all|default|ip|tcp|udp|sctp|"
806 "ether|port|vxlan|geneve|nvgre|none|<flowtype_id>)\n"
807 " Set the RSS mode.\n\n"
809 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
810 " Set the RSS redirection table.\n\n"
812 "port config (port_id) dcb vt (on|off) (traffic_class)"
814 " Set the DCB mode.\n\n"
816 "port config all burst (value)\n"
817 " Set the number of packets per burst.\n\n"
819 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
821 " Set the ring prefetch/host/writeback threshold"
822 " for tx/rx queue.\n\n"
824 "port config all (txfreet|txrst|rxfreet) (value)\n"
825 " Set free threshold for rx/tx, or set"
826 " tx rs bit threshold.\n\n"
827 "port config mtu X value\n"
828 " Set the MTU of port X to a given value\n\n"
830 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
831 " Set a rx/tx queue's ring size configuration, the new"
832 " value will take effect after command that (re-)start the port"
833 " or command that setup the specific queue\n\n"
835 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
836 " Start/stop a rx/tx queue of port X. Only take effect"
837 " when port X is started\n\n"
839 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
840 " Switch on/off a deferred start of port X rx/tx queue. Only"
841 " take effect when port X is stopped.\n\n"
843 "port (port_id) (rxq|txq) (queue_id) setup\n"
844 " Setup a rx/tx queue of port X.\n\n"
846 "port config (port_id|all) l2-tunnel E-tag ether-type"
848 " Set the value of E-tag ether-type.\n\n"
850 "port config (port_id|all) l2-tunnel E-tag"
851 " (enable|disable)\n"
852 " Enable/disable the E-tag support.\n\n"
854 "port config (port_id) pctype mapping reset\n"
855 " Reset flow type to pctype mapping on a port\n\n"
857 "port config (port_id) pctype mapping update"
858 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
859 " Update a flow type to pctype mapping item on a port\n\n"
861 "port config (port_id) pctype (pctype_id) hash_inset|"
862 "fdir_inset|fdir_flx_inset get|set|clear field\n"
864 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
866 "port config (port_id) pctype (pctype_id) hash_inset|"
867 "fdir_inset|fdir_flx_inset clear all"
868 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
870 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
871 " Add/remove UDP tunnel port for tunneling offload\n\n"
873 "port config <port_id> rx_offload vlan_strip|"
874 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
875 "outer_ipv4_cksum|macsec_strip|header_split|"
876 "vlan_filter|vlan_extend|jumbo_frame|crc_strip|"
877 "scatter|timestamp|security|keep_crc on|off\n"
878 " Enable or disable a per port Rx offloading"
879 " on all Rx queues of a port\n\n"
881 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
882 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
883 "outer_ipv4_cksum|macsec_strip|header_split|"
884 "vlan_filter|vlan_extend|jumbo_frame|crc_strip|"
885 "scatter|timestamp|security|keep_crc on|off\n"
886 " Enable or disable a per queue Rx offloading"
887 " only on a specific Rx queue\n\n"
889 "port config (port_id) tx_offload vlan_insert|"
890 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
891 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
892 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
893 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
894 "security|match_metadata on|off\n"
895 " Enable or disable a per port Tx offloading"
896 " on all Tx queues of a port\n\n"
898 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
899 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
900 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
901 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
902 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
904 " Enable or disable a per queue Tx offloading"
905 " only on a specific Tx queue\n\n"
907 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
908 " Load an eBPF program as a callback"
909 " for particular RX/TX queue\n\n"
911 "bpf-unload rx|tx (port) (queue)\n"
912 " Unload previously loaded eBPF program"
913 " for particular RX/TX queue\n\n"
915 "port config (port_id) tx_metadata (value)\n"
916 " Set Tx metadata value per port. Testpmd will add this value"
917 " to any Tx packet sent from this port\n\n"
921 if (show_all || !strcmp(res->section, "registers")) {
929 "read reg (port_id) (address)\n"
930 " Display value of a port register.\n\n"
932 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
933 " Display a port register bit field.\n\n"
935 "read regbit (port_id) (address) (bit_x)\n"
936 " Display a single port register bit.\n\n"
938 "write reg (port_id) (address) (value)\n"
939 " Set value of a port register.\n\n"
941 "write regfield (port_id) (address) (bit_x) (bit_y)"
943 " Set bit field of a port register.\n\n"
945 "write regbit (port_id) (address) (bit_x) (value)\n"
946 " Set single bit value of a port register.\n\n"
949 if (show_all || !strcmp(res->section, "filters")) {
957 "ethertype_filter (port_id) (add|del)"
958 " (mac_addr|mac_ignr) (mac_address) ethertype"
959 " (ether_type) (drop|fwd) queue (queue_id)\n"
960 " Add/Del an ethertype filter.\n\n"
962 "2tuple_filter (port_id) (add|del)"
963 " dst_port (dst_port_value) protocol (protocol_value)"
964 " mask (mask_value) tcp_flags (tcp_flags_value)"
965 " priority (prio_value) queue (queue_id)\n"
966 " Add/Del a 2tuple filter.\n\n"
968 "5tuple_filter (port_id) (add|del)"
969 " dst_ip (dst_address) src_ip (src_address)"
970 " dst_port (dst_port_value) src_port (src_port_value)"
971 " protocol (protocol_value)"
972 " mask (mask_value) tcp_flags (tcp_flags_value)"
973 " priority (prio_value) queue (queue_id)\n"
974 " Add/Del a 5tuple filter.\n\n"
976 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
977 " Add/Del syn filter.\n\n"
979 "flex_filter (port_id) (add|del) len (len_value)"
980 " bytes (bytes_value) mask (mask_value)"
981 " priority (prio_value) queue (queue_id)\n"
982 " Add/Del a flex filter.\n\n"
984 "flow_director_filter (port_id) mode IP (add|del|update)"
985 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
986 " src (src_ip_address) dst (dst_ip_address)"
987 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
988 " vlan (vlan_value) flexbytes (flexbytes_value)"
989 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
990 " fd_id (fd_id_value)\n"
991 " Add/Del an IP type flow director filter.\n\n"
993 "flow_director_filter (port_id) mode IP (add|del|update)"
994 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
995 " src (src_ip_address) (src_port)"
996 " dst (dst_ip_address) (dst_port)"
997 " tos (tos_value) ttl (ttl_value)"
998 " vlan (vlan_value) flexbytes (flexbytes_value)"
999 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
1000 " fd_id (fd_id_value)\n"
1001 " Add/Del an UDP/TCP type flow director filter.\n\n"
1003 "flow_director_filter (port_id) mode IP (add|del|update)"
1004 " flow (ipv4-sctp|ipv6-sctp)"
1005 " src (src_ip_address) (src_port)"
1006 " dst (dst_ip_address) (dst_port)"
1007 " tag (verification_tag) "
1008 " tos (tos_value) ttl (ttl_value)"
1009 " vlan (vlan_value)"
1010 " flexbytes (flexbytes_value) (drop|fwd)"
1011 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1012 " Add/Del a SCTP type flow director filter.\n\n"
1014 "flow_director_filter (port_id) mode IP (add|del|update)"
1015 " flow l2_payload ether (ethertype)"
1016 " flexbytes (flexbytes_value) (drop|fwd)"
1017 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1018 " Add/Del a l2 payload type flow director filter.\n\n"
1020 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1021 " mac (mac_address) vlan (vlan_value)"
1022 " flexbytes (flexbytes_value) (drop|fwd)"
1023 " queue (queue_id) fd_id (fd_id_value)\n"
1024 " Add/Del a MAC-VLAN flow director filter.\n\n"
1026 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1027 " mac (mac_address) vlan (vlan_value)"
1028 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1029 " flexbytes (flexbytes_value) (drop|fwd)"
1030 " queue (queue_id) fd_id (fd_id_value)\n"
1031 " Add/Del a Tunnel flow director filter.\n\n"
1033 "flow_director_filter (port_id) mode raw (add|del|update)"
1034 " flow (flow_id) (drop|fwd) queue (queue_id)"
1035 " fd_id (fd_id_value) packet (packet file name)\n"
1036 " Add/Del a raw type flow director filter.\n\n"
1038 "flush_flow_director (port_id)\n"
1039 " Flush all flow director entries of a device.\n\n"
1041 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1042 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1043 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1044 " Set flow director IP mask.\n\n"
1046 "flow_director_mask (port_id) mode MAC-VLAN"
1047 " vlan (vlan_value)\n"
1048 " Set flow director MAC-VLAN mask.\n\n"
1050 "flow_director_mask (port_id) mode Tunnel"
1051 " vlan (vlan_value) mac (mac_value)"
1052 " tunnel-type (tunnel_type_value)"
1053 " tunnel-id (tunnel_id_value)\n"
1054 " Set flow director Tunnel mask.\n\n"
1056 "flow_director_flex_mask (port_id)"
1057 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1058 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1060 " Configure mask of flex payload.\n\n"
1062 "flow_director_flex_payload (port_id)"
1063 " (raw|l2|l3|l4) (config)\n"
1064 " Configure flex payload selection.\n\n"
1066 "get_sym_hash_ena_per_port (port_id)\n"
1067 " get symmetric hash enable configuration per port.\n\n"
1069 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1070 " set symmetric hash enable configuration per port"
1071 " to enable or disable.\n\n"
1073 "get_hash_global_config (port_id)\n"
1074 " Get the global configurations of hash filters.\n\n"
1076 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1077 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1078 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1079 " (enable|disable)\n"
1080 " Set the global configurations of hash filters.\n\n"
1082 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1083 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1084 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1085 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1086 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1087 "ipv6-next-header|udp-src-port|udp-dst-port|"
1088 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1089 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1090 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1091 "fld-8th|none) (select|add)\n"
1092 " Set the input set for hash.\n\n"
1094 "set_fdir_input_set (port_id) "
1095 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1096 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1097 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1098 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1099 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1100 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1101 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1103 " Set the input set for FDir.\n\n"
1105 "flow validate {port_id}"
1106 " [group {group_id}] [priority {level}]"
1107 " [ingress] [egress]"
1108 " pattern {item} [/ {item} [...]] / end"
1109 " actions {action} [/ {action} [...]] / end\n"
1110 " Check whether a flow rule can be created.\n\n"
1112 "flow create {port_id}"
1113 " [group {group_id}] [priority {level}]"
1114 " [ingress] [egress]"
1115 " pattern {item} [/ {item} [...]] / end"
1116 " actions {action} [/ {action} [...]] / end\n"
1117 " Create a flow rule.\n\n"
1119 "flow destroy {port_id} rule {rule_id} [...]\n"
1120 " Destroy specific flow rules.\n\n"
1122 "flow flush {port_id}\n"
1123 " Destroy all flow rules.\n\n"
1125 "flow query {port_id} {rule_id} {action}\n"
1126 " Query an existing flow rule.\n\n"
1128 "flow list {port_id} [group {group_id}] [...]\n"
1129 " List existing flow rules sorted by priority,"
1130 " filtered by group identifiers.\n\n"
1132 "flow isolate {port_id} {boolean}\n"
1133 " Restrict ingress traffic to the defined"
1138 if (show_all || !strcmp(res->section, "traffic_management")) {
1142 "Traffic Management:\n"
1144 "show port tm cap (port_id)\n"
1145 " Display the port TM capability.\n\n"
1147 "show port tm level cap (port_id) (level_id)\n"
1148 " Display the port TM hierarchical level capability.\n\n"
1150 "show port tm node cap (port_id) (node_id)\n"
1151 " Display the port TM node capability.\n\n"
1153 "show port tm node type (port_id) (node_id)\n"
1154 " Display the port TM node type.\n\n"
1156 "show port tm node stats (port_id) (node_id) (clear)\n"
1157 " Display the port TM node stats.\n\n"
1159 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
1160 "set port tm hierarchy default (port_id)\n"
1161 " Set default traffic Management hierarchy on a port\n\n"
1164 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1165 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1166 " (packet_length_adjust)\n"
1167 " Add port tm node private shaper profile.\n\n"
1169 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1170 " Delete port tm node private shaper profile.\n\n"
1172 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1173 " (shaper_profile_id)\n"
1174 " Add/update port tm node shared shaper.\n\n"
1176 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1177 " Delete port tm node shared shaper.\n\n"
1179 "set port tm node shaper profile (port_id) (node_id)"
1180 " (shaper_profile_id)\n"
1181 " Set port tm node shaper profile.\n\n"
1183 "add port tm node wred profile (port_id) (wred_profile_id)"
1184 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1185 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1186 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1187 " Add port tm node wred profile.\n\n"
1189 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1190 " Delete port tm node wred profile.\n\n"
1192 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1193 " (priority) (weight) (level_id) (shaper_profile_id)"
1194 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1195 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1196 " Add port tm nonleaf node.\n\n"
1198 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1199 " (priority) (weight) (level_id) (shaper_profile_id)"
1200 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1201 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1202 " Add port tm leaf node.\n\n"
1204 "del port tm node (port_id) (node_id)\n"
1205 " Delete port tm node.\n\n"
1207 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1208 " (priority) (weight)\n"
1209 " Set port tm node parent.\n\n"
1211 "suspend port tm node (port_id) (node_id)"
1212 " Suspend tm node.\n\n"
1214 "resume port tm node (port_id) (node_id)"
1215 " Resume tm node.\n\n"
1217 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1218 " Commit tm hierarchy.\n\n"
1220 "set port tm mark ip_ecn (port) (green) (yellow)"
1222 " Enables/Disables the traffic management marking"
1223 " for IP ECN (Explicit Congestion Notification)"
1224 " packets on a given port\n\n"
1226 "set port tm mark ip_dscp (port) (green) (yellow)"
1228 " Enables/Disables the traffic management marking"
1229 " on the port for IP dscp packets\n\n"
1231 "set port tm mark vlan_dei (port) (green) (yellow)"
1233 " Enables/Disables the traffic management marking"
1234 " on the port for VLAN packets with DEI enabled\n\n"
1240 cmdline_parse_token_string_t cmd_help_long_help =
1241 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1243 cmdline_parse_token_string_t cmd_help_long_section =
1244 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1245 "all#control#display#config#"
1246 "ports#registers#filters#traffic_management");
1248 cmdline_parse_inst_t cmd_help_long = {
1249 .f = cmd_help_long_parsed,
1251 .help_str = "help all|control|display|config|ports|register|"
1252 "filters|traffic_management: "
1255 (void *)&cmd_help_long_help,
1256 (void *)&cmd_help_long_section,
1262 /* *** start/stop/close all ports *** */
1263 struct cmd_operate_port_result {
1264 cmdline_fixed_string_t keyword;
1265 cmdline_fixed_string_t name;
1266 cmdline_fixed_string_t value;
1269 static void cmd_operate_port_parsed(void *parsed_result,
1270 __attribute__((unused)) struct cmdline *cl,
1271 __attribute__((unused)) void *data)
1273 struct cmd_operate_port_result *res = parsed_result;
1275 if (!strcmp(res->name, "start"))
1276 start_port(RTE_PORT_ALL);
1277 else if (!strcmp(res->name, "stop"))
1278 stop_port(RTE_PORT_ALL);
1279 else if (!strcmp(res->name, "close"))
1280 close_port(RTE_PORT_ALL);
1281 else if (!strcmp(res->name, "reset"))
1282 reset_port(RTE_PORT_ALL);
1284 printf("Unknown parameter\n");
1287 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1288 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1290 cmdline_parse_token_string_t cmd_operate_port_all_port =
1291 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1292 "start#stop#close#reset");
1293 cmdline_parse_token_string_t cmd_operate_port_all_all =
1294 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1296 cmdline_parse_inst_t cmd_operate_port = {
1297 .f = cmd_operate_port_parsed,
1299 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1301 (void *)&cmd_operate_port_all_cmd,
1302 (void *)&cmd_operate_port_all_port,
1303 (void *)&cmd_operate_port_all_all,
1308 /* *** start/stop/close specific port *** */
1309 struct cmd_operate_specific_port_result {
1310 cmdline_fixed_string_t keyword;
1311 cmdline_fixed_string_t name;
1315 static void cmd_operate_specific_port_parsed(void *parsed_result,
1316 __attribute__((unused)) struct cmdline *cl,
1317 __attribute__((unused)) void *data)
1319 struct cmd_operate_specific_port_result *res = parsed_result;
1321 if (!strcmp(res->name, "start"))
1322 start_port(res->value);
1323 else if (!strcmp(res->name, "stop"))
1324 stop_port(res->value);
1325 else if (!strcmp(res->name, "close"))
1326 close_port(res->value);
1327 else if (!strcmp(res->name, "reset"))
1328 reset_port(res->value);
1330 printf("Unknown parameter\n");
1333 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1334 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1336 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1337 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1338 name, "start#stop#close#reset");
1339 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1340 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1343 cmdline_parse_inst_t cmd_operate_specific_port = {
1344 .f = cmd_operate_specific_port_parsed,
1346 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1348 (void *)&cmd_operate_specific_port_cmd,
1349 (void *)&cmd_operate_specific_port_port,
1350 (void *)&cmd_operate_specific_port_id,
1355 /* *** enable port setup (after attach) via iterator or event *** */
1356 struct cmd_set_port_setup_on_result {
1357 cmdline_fixed_string_t set;
1358 cmdline_fixed_string_t port;
1359 cmdline_fixed_string_t setup;
1360 cmdline_fixed_string_t on;
1361 cmdline_fixed_string_t mode;
1364 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1365 __attribute__((unused)) struct cmdline *cl,
1366 __attribute__((unused)) void *data)
1368 struct cmd_set_port_setup_on_result *res = parsed_result;
1370 if (strcmp(res->mode, "event") == 0)
1371 setup_on_probe_event = true;
1372 else if (strcmp(res->mode, "iterator") == 0)
1373 setup_on_probe_event = false;
1375 printf("Unknown mode\n");
1378 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1379 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1381 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1382 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1384 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1385 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1387 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1388 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1390 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1391 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1392 mode, "iterator#event");
1394 cmdline_parse_inst_t cmd_set_port_setup_on = {
1395 .f = cmd_set_port_setup_on_parsed,
1397 .help_str = "set port setup on iterator|event",
1399 (void *)&cmd_set_port_setup_on_set,
1400 (void *)&cmd_set_port_setup_on_port,
1401 (void *)&cmd_set_port_setup_on_setup,
1402 (void *)&cmd_set_port_setup_on_on,
1403 (void *)&cmd_set_port_setup_on_mode,
1408 /* *** attach a specified port *** */
1409 struct cmd_operate_attach_port_result {
1410 cmdline_fixed_string_t port;
1411 cmdline_fixed_string_t keyword;
1412 cmdline_fixed_string_t identifier;
1415 static void cmd_operate_attach_port_parsed(void *parsed_result,
1416 __attribute__((unused)) struct cmdline *cl,
1417 __attribute__((unused)) void *data)
1419 struct cmd_operate_attach_port_result *res = parsed_result;
1421 if (!strcmp(res->keyword, "attach"))
1422 attach_port(res->identifier);
1424 printf("Unknown parameter\n");
1427 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1428 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1430 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1431 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1433 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1434 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1437 cmdline_parse_inst_t cmd_operate_attach_port = {
1438 .f = cmd_operate_attach_port_parsed,
1440 .help_str = "port attach <identifier>: "
1441 "(identifier: pci address or virtual dev name)",
1443 (void *)&cmd_operate_attach_port_port,
1444 (void *)&cmd_operate_attach_port_keyword,
1445 (void *)&cmd_operate_attach_port_identifier,
1450 /* *** detach a specified port *** */
1451 struct cmd_operate_detach_port_result {
1452 cmdline_fixed_string_t port;
1453 cmdline_fixed_string_t keyword;
1457 static void cmd_operate_detach_port_parsed(void *parsed_result,
1458 __attribute__((unused)) struct cmdline *cl,
1459 __attribute__((unused)) void *data)
1461 struct cmd_operate_detach_port_result *res = parsed_result;
1463 if (!strcmp(res->keyword, "detach"))
1464 detach_port_device(res->port_id);
1466 printf("Unknown parameter\n");
1469 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1470 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1472 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1473 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1475 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1476 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1479 cmdline_parse_inst_t cmd_operate_detach_port = {
1480 .f = cmd_operate_detach_port_parsed,
1482 .help_str = "port detach <port_id>",
1484 (void *)&cmd_operate_detach_port_port,
1485 (void *)&cmd_operate_detach_port_keyword,
1486 (void *)&cmd_operate_detach_port_port_id,
1491 /* *** configure speed for all ports *** */
1492 struct cmd_config_speed_all {
1493 cmdline_fixed_string_t port;
1494 cmdline_fixed_string_t keyword;
1495 cmdline_fixed_string_t all;
1496 cmdline_fixed_string_t item1;
1497 cmdline_fixed_string_t item2;
1498 cmdline_fixed_string_t value1;
1499 cmdline_fixed_string_t value2;
1503 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1508 if (!strcmp(duplexstr, "half")) {
1509 duplex = ETH_LINK_HALF_DUPLEX;
1510 } else if (!strcmp(duplexstr, "full")) {
1511 duplex = ETH_LINK_FULL_DUPLEX;
1512 } else if (!strcmp(duplexstr, "auto")) {
1513 duplex = ETH_LINK_FULL_DUPLEX;
1515 printf("Unknown duplex parameter\n");
1519 if (!strcmp(speedstr, "10")) {
1520 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1521 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1522 } else if (!strcmp(speedstr, "100")) {
1523 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1524 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1526 if (duplex != ETH_LINK_FULL_DUPLEX) {
1527 printf("Invalid speed/duplex parameters\n");
1530 if (!strcmp(speedstr, "1000")) {
1531 *speed = ETH_LINK_SPEED_1G;
1532 } else if (!strcmp(speedstr, "10000")) {
1533 *speed = ETH_LINK_SPEED_10G;
1534 } else if (!strcmp(speedstr, "25000")) {
1535 *speed = ETH_LINK_SPEED_25G;
1536 } else if (!strcmp(speedstr, "40000")) {
1537 *speed = ETH_LINK_SPEED_40G;
1538 } else if (!strcmp(speedstr, "50000")) {
1539 *speed = ETH_LINK_SPEED_50G;
1540 } else if (!strcmp(speedstr, "100000")) {
1541 *speed = ETH_LINK_SPEED_100G;
1542 } else if (!strcmp(speedstr, "auto")) {
1543 *speed = ETH_LINK_SPEED_AUTONEG;
1545 printf("Unknown speed parameter\n");
1554 cmd_config_speed_all_parsed(void *parsed_result,
1555 __attribute__((unused)) struct cmdline *cl,
1556 __attribute__((unused)) void *data)
1558 struct cmd_config_speed_all *res = parsed_result;
1559 uint32_t link_speed;
1562 if (!all_ports_stopped()) {
1563 printf("Please stop all ports first\n");
1567 if (parse_and_check_speed_duplex(res->value1, res->value2,
1571 RTE_ETH_FOREACH_DEV(pid) {
1572 ports[pid].dev_conf.link_speeds = link_speed;
1575 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1578 cmdline_parse_token_string_t cmd_config_speed_all_port =
1579 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1580 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1581 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1583 cmdline_parse_token_string_t cmd_config_speed_all_all =
1584 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1585 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1586 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1587 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1588 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1589 "10#100#1000#10000#25000#40000#50000#100000#auto");
1590 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1591 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1592 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1593 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1596 cmdline_parse_inst_t cmd_config_speed_all = {
1597 .f = cmd_config_speed_all_parsed,
1599 .help_str = "port config all speed "
1600 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1603 (void *)&cmd_config_speed_all_port,
1604 (void *)&cmd_config_speed_all_keyword,
1605 (void *)&cmd_config_speed_all_all,
1606 (void *)&cmd_config_speed_all_item1,
1607 (void *)&cmd_config_speed_all_value1,
1608 (void *)&cmd_config_speed_all_item2,
1609 (void *)&cmd_config_speed_all_value2,
1614 /* *** configure speed for specific port *** */
1615 struct cmd_config_speed_specific {
1616 cmdline_fixed_string_t port;
1617 cmdline_fixed_string_t keyword;
1619 cmdline_fixed_string_t item1;
1620 cmdline_fixed_string_t item2;
1621 cmdline_fixed_string_t value1;
1622 cmdline_fixed_string_t value2;
1626 cmd_config_speed_specific_parsed(void *parsed_result,
1627 __attribute__((unused)) struct cmdline *cl,
1628 __attribute__((unused)) void *data)
1630 struct cmd_config_speed_specific *res = parsed_result;
1631 uint32_t link_speed;
1633 if (!all_ports_stopped()) {
1634 printf("Please stop all ports first\n");
1638 if (port_id_is_invalid(res->id, ENABLED_WARN))
1641 if (parse_and_check_speed_duplex(res->value1, res->value2,
1645 ports[res->id].dev_conf.link_speeds = link_speed;
1647 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1651 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1652 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1654 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1655 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1657 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1658 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1659 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1660 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1662 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1663 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1664 "10#100#1000#10000#25000#40000#50000#100000#auto");
1665 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1666 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1668 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1669 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1672 cmdline_parse_inst_t cmd_config_speed_specific = {
1673 .f = cmd_config_speed_specific_parsed,
1675 .help_str = "port config <port_id> speed "
1676 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1679 (void *)&cmd_config_speed_specific_port,
1680 (void *)&cmd_config_speed_specific_keyword,
1681 (void *)&cmd_config_speed_specific_id,
1682 (void *)&cmd_config_speed_specific_item1,
1683 (void *)&cmd_config_speed_specific_value1,
1684 (void *)&cmd_config_speed_specific_item2,
1685 (void *)&cmd_config_speed_specific_value2,
1690 /* *** configure loopback for all ports *** */
1691 struct cmd_config_loopback_all {
1692 cmdline_fixed_string_t port;
1693 cmdline_fixed_string_t keyword;
1694 cmdline_fixed_string_t all;
1695 cmdline_fixed_string_t item;
1700 cmd_config_loopback_all_parsed(void *parsed_result,
1701 __attribute__((unused)) struct cmdline *cl,
1702 __attribute__((unused)) void *data)
1704 struct cmd_config_loopback_all *res = parsed_result;
1707 if (!all_ports_stopped()) {
1708 printf("Please stop all ports first\n");
1712 RTE_ETH_FOREACH_DEV(pid) {
1713 ports[pid].dev_conf.lpbk_mode = res->mode;
1716 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1719 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1720 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1721 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1722 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1724 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1725 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1726 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1727 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1729 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1730 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1732 cmdline_parse_inst_t cmd_config_loopback_all = {
1733 .f = cmd_config_loopback_all_parsed,
1735 .help_str = "port config all loopback <mode>",
1737 (void *)&cmd_config_loopback_all_port,
1738 (void *)&cmd_config_loopback_all_keyword,
1739 (void *)&cmd_config_loopback_all_all,
1740 (void *)&cmd_config_loopback_all_item,
1741 (void *)&cmd_config_loopback_all_mode,
1746 /* *** configure loopback for specific port *** */
1747 struct cmd_config_loopback_specific {
1748 cmdline_fixed_string_t port;
1749 cmdline_fixed_string_t keyword;
1751 cmdline_fixed_string_t item;
1756 cmd_config_loopback_specific_parsed(void *parsed_result,
1757 __attribute__((unused)) struct cmdline *cl,
1758 __attribute__((unused)) void *data)
1760 struct cmd_config_loopback_specific *res = parsed_result;
1762 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1765 if (!port_is_stopped(res->port_id)) {
1766 printf("Please stop port %u first\n", res->port_id);
1770 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1772 cmd_reconfig_device_queue(res->port_id, 1, 1);
1776 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1777 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1779 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1780 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1782 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1783 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1785 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1786 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1788 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1789 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1792 cmdline_parse_inst_t cmd_config_loopback_specific = {
1793 .f = cmd_config_loopback_specific_parsed,
1795 .help_str = "port config <port_id> loopback <mode>",
1797 (void *)&cmd_config_loopback_specific_port,
1798 (void *)&cmd_config_loopback_specific_keyword,
1799 (void *)&cmd_config_loopback_specific_id,
1800 (void *)&cmd_config_loopback_specific_item,
1801 (void *)&cmd_config_loopback_specific_mode,
1806 /* *** configure txq/rxq, txd/rxd *** */
1807 struct cmd_config_rx_tx {
1808 cmdline_fixed_string_t port;
1809 cmdline_fixed_string_t keyword;
1810 cmdline_fixed_string_t all;
1811 cmdline_fixed_string_t name;
1816 cmd_config_rx_tx_parsed(void *parsed_result,
1817 __attribute__((unused)) struct cmdline *cl,
1818 __attribute__((unused)) void *data)
1820 struct cmd_config_rx_tx *res = parsed_result;
1822 if (!all_ports_stopped()) {
1823 printf("Please stop all ports first\n");
1826 if (!strcmp(res->name, "rxq")) {
1827 if (!res->value && !nb_txq) {
1828 printf("Warning: Either rx or tx queues should be non zero\n");
1831 if (check_nb_rxq(res->value) != 0)
1833 nb_rxq = res->value;
1835 else if (!strcmp(res->name, "txq")) {
1836 if (!res->value && !nb_rxq) {
1837 printf("Warning: Either rx or tx queues should be non zero\n");
1840 if (check_nb_txq(res->value) != 0)
1842 nb_txq = res->value;
1844 else if (!strcmp(res->name, "rxd")) {
1845 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1846 printf("rxd %d invalid - must be > 0 && <= %d\n",
1847 res->value, RTE_TEST_RX_DESC_MAX);
1850 nb_rxd = res->value;
1851 } else if (!strcmp(res->name, "txd")) {
1852 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1853 printf("txd %d invalid - must be > 0 && <= %d\n",
1854 res->value, RTE_TEST_TX_DESC_MAX);
1857 nb_txd = res->value;
1859 printf("Unknown parameter\n");
1867 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1870 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1871 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1872 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1873 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1874 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1875 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1876 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1877 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1879 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1880 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1882 cmdline_parse_inst_t cmd_config_rx_tx = {
1883 .f = cmd_config_rx_tx_parsed,
1885 .help_str = "port config all rxq|txq|rxd|txd <value>",
1887 (void *)&cmd_config_rx_tx_port,
1888 (void *)&cmd_config_rx_tx_keyword,
1889 (void *)&cmd_config_rx_tx_all,
1890 (void *)&cmd_config_rx_tx_name,
1891 (void *)&cmd_config_rx_tx_value,
1896 /* *** config max packet length *** */
1897 struct cmd_config_max_pkt_len_result {
1898 cmdline_fixed_string_t port;
1899 cmdline_fixed_string_t keyword;
1900 cmdline_fixed_string_t all;
1901 cmdline_fixed_string_t name;
1906 cmd_config_max_pkt_len_parsed(void *parsed_result,
1907 __attribute__((unused)) struct cmdline *cl,
1908 __attribute__((unused)) void *data)
1910 struct cmd_config_max_pkt_len_result *res = parsed_result;
1913 if (!all_ports_stopped()) {
1914 printf("Please stop all ports first\n");
1918 RTE_ETH_FOREACH_DEV(pid) {
1919 struct rte_port *port = &ports[pid];
1920 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1922 if (!strcmp(res->name, "max-pkt-len")) {
1923 if (res->value < ETHER_MIN_LEN) {
1924 printf("max-pkt-len can not be less than %d\n",
1928 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1931 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1932 if (res->value > ETHER_MAX_LEN)
1933 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1935 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1936 port->dev_conf.rxmode.offloads = rx_offloads;
1938 printf("Unknown parameter\n");
1945 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1948 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1949 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1951 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1952 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1954 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1955 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1957 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1958 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1960 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1961 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1964 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1965 .f = cmd_config_max_pkt_len_parsed,
1967 .help_str = "port config all max-pkt-len <value>",
1969 (void *)&cmd_config_max_pkt_len_port,
1970 (void *)&cmd_config_max_pkt_len_keyword,
1971 (void *)&cmd_config_max_pkt_len_all,
1972 (void *)&cmd_config_max_pkt_len_name,
1973 (void *)&cmd_config_max_pkt_len_value,
1978 /* *** configure port MTU *** */
1979 struct cmd_config_mtu_result {
1980 cmdline_fixed_string_t port;
1981 cmdline_fixed_string_t keyword;
1982 cmdline_fixed_string_t mtu;
1988 cmd_config_mtu_parsed(void *parsed_result,
1989 __attribute__((unused)) struct cmdline *cl,
1990 __attribute__((unused)) void *data)
1992 struct cmd_config_mtu_result *res = parsed_result;
1994 if (res->value < ETHER_MIN_LEN) {
1995 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1998 port_mtu_set(res->port_id, res->value);
2001 cmdline_parse_token_string_t cmd_config_mtu_port =
2002 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2004 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2005 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2007 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2008 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2010 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2011 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2012 cmdline_parse_token_num_t cmd_config_mtu_value =
2013 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2015 cmdline_parse_inst_t cmd_config_mtu = {
2016 .f = cmd_config_mtu_parsed,
2018 .help_str = "port config mtu <port_id> <value>",
2020 (void *)&cmd_config_mtu_port,
2021 (void *)&cmd_config_mtu_keyword,
2022 (void *)&cmd_config_mtu_mtu,
2023 (void *)&cmd_config_mtu_port_id,
2024 (void *)&cmd_config_mtu_value,
2029 /* *** configure rx mode *** */
2030 struct cmd_config_rx_mode_flag {
2031 cmdline_fixed_string_t port;
2032 cmdline_fixed_string_t keyword;
2033 cmdline_fixed_string_t all;
2034 cmdline_fixed_string_t name;
2035 cmdline_fixed_string_t value;
2039 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2040 __attribute__((unused)) struct cmdline *cl,
2041 __attribute__((unused)) void *data)
2043 struct cmd_config_rx_mode_flag *res = parsed_result;
2046 if (!all_ports_stopped()) {
2047 printf("Please stop all ports first\n");
2051 RTE_ETH_FOREACH_DEV(pid) {
2052 struct rte_port *port;
2053 uint64_t rx_offloads;
2056 rx_offloads = port->dev_conf.rxmode.offloads;
2057 if (!strcmp(res->name, "crc-strip")) {
2058 if (!strcmp(res->value, "on")) {
2059 rx_offloads &= ~DEV_RX_OFFLOAD_KEEP_CRC;
2060 } else if (!strcmp(res->value, "off")) {
2061 rx_offloads |= DEV_RX_OFFLOAD_KEEP_CRC;
2063 printf("Unknown parameter\n");
2066 } else if (!strcmp(res->name, "scatter")) {
2067 if (!strcmp(res->value, "on")) {
2068 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
2069 } else if (!strcmp(res->value, "off")) {
2070 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
2072 printf("Unknown parameter\n");
2075 } else if (!strcmp(res->name, "rx-cksum")) {
2076 if (!strcmp(res->value, "on"))
2077 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
2078 else if (!strcmp(res->value, "off"))
2079 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
2081 printf("Unknown parameter\n");
2084 } else if (!strcmp(res->name, "rx-timestamp")) {
2085 if (!strcmp(res->value, "on"))
2086 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
2087 else if (!strcmp(res->value, "off"))
2088 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
2090 printf("Unknown parameter\n");
2093 } else if (!strcmp(res->name, "hw-vlan")) {
2094 if (!strcmp(res->value, "on")) {
2095 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
2096 DEV_RX_OFFLOAD_VLAN_STRIP);
2097 } else if (!strcmp(res->value, "off")) {
2098 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
2099 DEV_RX_OFFLOAD_VLAN_STRIP);
2101 printf("Unknown parameter\n");
2104 } else if (!strcmp(res->name, "hw-vlan-filter")) {
2105 if (!strcmp(res->value, "on"))
2106 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
2107 else if (!strcmp(res->value, "off"))
2108 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
2110 printf("Unknown parameter\n");
2113 } else if (!strcmp(res->name, "hw-vlan-strip")) {
2114 if (!strcmp(res->value, "on"))
2115 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
2116 else if (!strcmp(res->value, "off"))
2117 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
2119 printf("Unknown parameter\n");
2122 } else if (!strcmp(res->name, "hw-vlan-extend")) {
2123 if (!strcmp(res->value, "on"))
2124 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
2125 else if (!strcmp(res->value, "off"))
2126 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
2128 printf("Unknown parameter\n");
2131 } else if (!strcmp(res->name, "drop-en")) {
2132 if (!strcmp(res->value, "on"))
2134 else if (!strcmp(res->value, "off"))
2137 printf("Unknown parameter\n");
2141 printf("Unknown parameter\n");
2144 port->dev_conf.rxmode.offloads = rx_offloads;
2149 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2152 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2153 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2154 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2155 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2157 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2158 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2159 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2160 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2161 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
2162 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
2163 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2164 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2167 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2168 .f = cmd_config_rx_mode_flag_parsed,
2170 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
2171 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
2173 (void *)&cmd_config_rx_mode_flag_port,
2174 (void *)&cmd_config_rx_mode_flag_keyword,
2175 (void *)&cmd_config_rx_mode_flag_all,
2176 (void *)&cmd_config_rx_mode_flag_name,
2177 (void *)&cmd_config_rx_mode_flag_value,
2182 /* *** configure rss *** */
2183 struct cmd_config_rss {
2184 cmdline_fixed_string_t port;
2185 cmdline_fixed_string_t keyword;
2186 cmdline_fixed_string_t all;
2187 cmdline_fixed_string_t name;
2188 cmdline_fixed_string_t value;
2192 cmd_config_rss_parsed(void *parsed_result,
2193 __attribute__((unused)) struct cmdline *cl,
2194 __attribute__((unused)) void *data)
2196 struct cmd_config_rss *res = parsed_result;
2197 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2198 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2199 int use_default = 0;
2200 int all_updated = 1;
2204 if (!strcmp(res->value, "all"))
2205 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2206 ETH_RSS_UDP | ETH_RSS_SCTP |
2208 else if (!strcmp(res->value, "ip"))
2209 rss_conf.rss_hf = ETH_RSS_IP;
2210 else if (!strcmp(res->value, "udp"))
2211 rss_conf.rss_hf = ETH_RSS_UDP;
2212 else if (!strcmp(res->value, "tcp"))
2213 rss_conf.rss_hf = ETH_RSS_TCP;
2214 else if (!strcmp(res->value, "sctp"))
2215 rss_conf.rss_hf = ETH_RSS_SCTP;
2216 else if (!strcmp(res->value, "ether"))
2217 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2218 else if (!strcmp(res->value, "port"))
2219 rss_conf.rss_hf = ETH_RSS_PORT;
2220 else if (!strcmp(res->value, "vxlan"))
2221 rss_conf.rss_hf = ETH_RSS_VXLAN;
2222 else if (!strcmp(res->value, "geneve"))
2223 rss_conf.rss_hf = ETH_RSS_GENEVE;
2224 else if (!strcmp(res->value, "nvgre"))
2225 rss_conf.rss_hf = ETH_RSS_NVGRE;
2226 else if (!strcmp(res->value, "none"))
2227 rss_conf.rss_hf = 0;
2228 else if (!strcmp(res->value, "default"))
2230 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2231 atoi(res->value) < 64)
2232 rss_conf.rss_hf = 1ULL << atoi(res->value);
2234 printf("Unknown parameter\n");
2237 rss_conf.rss_key = NULL;
2238 /* Update global configuration for RSS types. */
2239 RTE_ETH_FOREACH_DEV(i) {
2240 struct rte_eth_rss_conf local_rss_conf;
2242 rte_eth_dev_info_get(i, &dev_info);
2244 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2246 local_rss_conf = rss_conf;
2247 local_rss_conf.rss_hf = rss_conf.rss_hf &
2248 dev_info.flow_type_rss_offloads;
2249 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2250 printf("Port %u modified RSS hash function based on hardware support,"
2251 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2252 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2254 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2257 printf("Configuration of RSS hash at ethernet port %d "
2258 "failed with error (%d): %s.\n",
2259 i, -diag, strerror(-diag));
2262 if (all_updated && !use_default)
2263 rss_hf = rss_conf.rss_hf;
2266 cmdline_parse_token_string_t cmd_config_rss_port =
2267 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2268 cmdline_parse_token_string_t cmd_config_rss_keyword =
2269 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2270 cmdline_parse_token_string_t cmd_config_rss_all =
2271 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2272 cmdline_parse_token_string_t cmd_config_rss_name =
2273 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2274 cmdline_parse_token_string_t cmd_config_rss_value =
2275 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2277 cmdline_parse_inst_t cmd_config_rss = {
2278 .f = cmd_config_rss_parsed,
2280 .help_str = "port config all rss "
2281 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
2283 (void *)&cmd_config_rss_port,
2284 (void *)&cmd_config_rss_keyword,
2285 (void *)&cmd_config_rss_all,
2286 (void *)&cmd_config_rss_name,
2287 (void *)&cmd_config_rss_value,
2292 /* *** configure rss hash key *** */
2293 struct cmd_config_rss_hash_key {
2294 cmdline_fixed_string_t port;
2295 cmdline_fixed_string_t config;
2297 cmdline_fixed_string_t rss_hash_key;
2298 cmdline_fixed_string_t rss_type;
2299 cmdline_fixed_string_t key;
2303 hexa_digit_to_value(char hexa_digit)
2305 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2306 return (uint8_t) (hexa_digit - '0');
2307 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2308 return (uint8_t) ((hexa_digit - 'a') + 10);
2309 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2310 return (uint8_t) ((hexa_digit - 'A') + 10);
2311 /* Invalid hexa digit */
2316 parse_and_check_key_hexa_digit(char *key, int idx)
2320 hexa_v = hexa_digit_to_value(key[idx]);
2322 printf("invalid key: character %c at position %d is not a "
2323 "valid hexa digit\n", key[idx], idx);
2328 cmd_config_rss_hash_key_parsed(void *parsed_result,
2329 __attribute__((unused)) struct cmdline *cl,
2330 __attribute__((unused)) void *data)
2332 struct cmd_config_rss_hash_key *res = parsed_result;
2333 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2337 struct rte_eth_dev_info dev_info;
2338 uint8_t hash_key_size;
2341 memset(&dev_info, 0, sizeof(dev_info));
2342 rte_eth_dev_info_get(res->port_id, &dev_info);
2343 if (dev_info.hash_key_size > 0 &&
2344 dev_info.hash_key_size <= sizeof(hash_key))
2345 hash_key_size = dev_info.hash_key_size;
2347 printf("dev_info did not provide a valid hash key size\n");
2350 /* Check the length of the RSS hash key */
2351 key_len = strlen(res->key);
2352 if (key_len != (hash_key_size * 2)) {
2353 printf("key length: %d invalid - key must be a string of %d"
2354 " hexa-decimal numbers\n",
2355 (int) key_len, hash_key_size * 2);
2358 /* Translate RSS hash key into binary representation */
2359 for (i = 0; i < hash_key_size; i++) {
2360 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2363 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2366 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2368 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2372 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2373 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2374 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2375 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2377 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2378 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2379 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2380 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2381 rss_hash_key, "rss-hash-key");
2382 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2383 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2384 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2385 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2386 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2387 "ipv6-tcp-ex#ipv6-udp-ex");
2388 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2389 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2391 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2392 .f = cmd_config_rss_hash_key_parsed,
2394 .help_str = "port config <port_id> rss-hash-key "
2395 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2396 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2397 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2398 "<string of hex digits (variable length, NIC dependent)>",
2400 (void *)&cmd_config_rss_hash_key_port,
2401 (void *)&cmd_config_rss_hash_key_config,
2402 (void *)&cmd_config_rss_hash_key_port_id,
2403 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2404 (void *)&cmd_config_rss_hash_key_rss_type,
2405 (void *)&cmd_config_rss_hash_key_value,
2410 /* *** configure port rxq/txq ring size *** */
2411 struct cmd_config_rxtx_ring_size {
2412 cmdline_fixed_string_t port;
2413 cmdline_fixed_string_t config;
2415 cmdline_fixed_string_t rxtxq;
2417 cmdline_fixed_string_t rsize;
2422 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2423 __attribute__((unused)) struct cmdline *cl,
2424 __attribute__((unused)) void *data)
2426 struct cmd_config_rxtx_ring_size *res = parsed_result;
2427 struct rte_port *port;
2430 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2433 if (res->portid == (portid_t)RTE_PORT_ALL) {
2434 printf("Invalid port id\n");
2438 port = &ports[res->portid];
2440 if (!strcmp(res->rxtxq, "rxq"))
2442 else if (!strcmp(res->rxtxq, "txq"))
2445 printf("Unknown parameter\n");
2449 if (isrx && rx_queue_id_is_invalid(res->qid))
2451 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2454 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2455 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2461 port->nb_rx_desc[res->qid] = res->size;
2463 port->nb_tx_desc[res->qid] = res->size;
2465 cmd_reconfig_device_queue(res->portid, 0, 1);
2468 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2469 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2471 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2472 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2474 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2475 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2477 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2478 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2480 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2481 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2483 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2484 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2485 rsize, "ring_size");
2486 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2487 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2490 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2491 .f = cmd_config_rxtx_ring_size_parsed,
2493 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2495 (void *)&cmd_config_rxtx_ring_size_port,
2496 (void *)&cmd_config_rxtx_ring_size_config,
2497 (void *)&cmd_config_rxtx_ring_size_portid,
2498 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2499 (void *)&cmd_config_rxtx_ring_size_qid,
2500 (void *)&cmd_config_rxtx_ring_size_rsize,
2501 (void *)&cmd_config_rxtx_ring_size_size,
2506 /* *** configure port rxq/txq start/stop *** */
2507 struct cmd_config_rxtx_queue {
2508 cmdline_fixed_string_t port;
2510 cmdline_fixed_string_t rxtxq;
2512 cmdline_fixed_string_t opname;
2516 cmd_config_rxtx_queue_parsed(void *parsed_result,
2517 __attribute__((unused)) struct cmdline *cl,
2518 __attribute__((unused)) void *data)
2520 struct cmd_config_rxtx_queue *res = parsed_result;
2525 if (test_done == 0) {
2526 printf("Please stop forwarding first\n");
2530 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2533 if (port_is_started(res->portid) != 1) {
2534 printf("Please start port %u first\n", res->portid);
2538 if (!strcmp(res->rxtxq, "rxq"))
2540 else if (!strcmp(res->rxtxq, "txq"))
2543 printf("Unknown parameter\n");
2547 if (isrx && rx_queue_id_is_invalid(res->qid))
2549 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2552 if (!strcmp(res->opname, "start"))
2554 else if (!strcmp(res->opname, "stop"))
2557 printf("Unknown parameter\n");
2561 if (isstart && isrx)
2562 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2563 else if (!isstart && isrx)
2564 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2565 else if (isstart && !isrx)
2566 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2568 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2570 if (ret == -ENOTSUP)
2571 printf("Function not supported in PMD driver\n");
2574 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2575 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2576 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2577 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2578 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2579 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2580 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2581 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2582 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2583 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2586 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2587 .f = cmd_config_rxtx_queue_parsed,
2589 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2591 (void *)&cmd_config_rxtx_queue_port,
2592 (void *)&cmd_config_rxtx_queue_portid,
2593 (void *)&cmd_config_rxtx_queue_rxtxq,
2594 (void *)&cmd_config_rxtx_queue_qid,
2595 (void *)&cmd_config_rxtx_queue_opname,
2600 /* *** configure port rxq/txq deferred start on/off *** */
2601 struct cmd_config_deferred_start_rxtx_queue {
2602 cmdline_fixed_string_t port;
2604 cmdline_fixed_string_t rxtxq;
2606 cmdline_fixed_string_t opname;
2607 cmdline_fixed_string_t state;
2611 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2612 __attribute__((unused)) struct cmdline *cl,
2613 __attribute__((unused)) void *data)
2615 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2616 struct rte_port *port;
2619 uint8_t needreconfig = 0;
2621 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2624 if (port_is_started(res->port_id) != 0) {
2625 printf("Please stop port %u first\n", res->port_id);
2629 port = &ports[res->port_id];
2631 isrx = !strcmp(res->rxtxq, "rxq");
2633 if (isrx && rx_queue_id_is_invalid(res->qid))
2635 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2638 ison = !strcmp(res->state, "on");
2640 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2641 port->rx_conf[res->qid].rx_deferred_start = ison;
2643 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2644 port->tx_conf[res->qid].tx_deferred_start = ison;
2649 cmd_reconfig_device_queue(res->port_id, 0, 1);
2652 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2653 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2655 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2656 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2658 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2659 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2661 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2662 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2664 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2665 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2666 opname, "deferred_start");
2667 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2668 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2671 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2672 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2674 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2676 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2677 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2678 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2679 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2680 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2681 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2686 /* *** configure port rxq/txq setup *** */
2687 struct cmd_setup_rxtx_queue {
2688 cmdline_fixed_string_t port;
2690 cmdline_fixed_string_t rxtxq;
2692 cmdline_fixed_string_t setup;
2695 /* Common CLI fields for queue setup */
2696 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2697 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2698 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2699 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2700 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2701 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2702 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2703 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2704 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2705 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2708 cmd_setup_rxtx_queue_parsed(
2709 void *parsed_result,
2710 __attribute__((unused)) struct cmdline *cl,
2711 __attribute__((unused)) void *data)
2713 struct cmd_setup_rxtx_queue *res = parsed_result;
2714 struct rte_port *port;
2715 struct rte_mempool *mp;
2716 unsigned int socket_id;
2720 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2723 if (res->portid == (portid_t)RTE_PORT_ALL) {
2724 printf("Invalid port id\n");
2728 if (!strcmp(res->rxtxq, "rxq"))
2730 else if (!strcmp(res->rxtxq, "txq"))
2733 printf("Unknown parameter\n");
2737 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2738 printf("Invalid rx queue\n");
2740 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2741 printf("Invalid tx queue\n");
2745 port = &ports[res->portid];
2747 socket_id = rxring_numa[res->portid];
2748 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2749 socket_id = port->socket_id;
2751 mp = mbuf_pool_find(socket_id);
2753 printf("Failed to setup RX queue: "
2754 "No mempool allocation"
2755 " on the socket %d\n",
2756 rxring_numa[res->portid]);
2759 ret = rte_eth_rx_queue_setup(res->portid,
2761 port->nb_rx_desc[res->qid],
2763 &port->rx_conf[res->qid],
2766 printf("Failed to setup RX queue\n");
2768 socket_id = txring_numa[res->portid];
2769 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2770 socket_id = port->socket_id;
2772 ret = rte_eth_tx_queue_setup(res->portid,
2774 port->nb_tx_desc[res->qid],
2776 &port->tx_conf[res->qid]);
2778 printf("Failed to setup TX queue\n");
2782 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2783 .f = cmd_setup_rxtx_queue_parsed,
2785 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2787 (void *)&cmd_setup_rxtx_queue_port,
2788 (void *)&cmd_setup_rxtx_queue_portid,
2789 (void *)&cmd_setup_rxtx_queue_rxtxq,
2790 (void *)&cmd_setup_rxtx_queue_qid,
2791 (void *)&cmd_setup_rxtx_queue_setup,
2797 /* *** Configure RSS RETA *** */
2798 struct cmd_config_rss_reta {
2799 cmdline_fixed_string_t port;
2800 cmdline_fixed_string_t keyword;
2802 cmdline_fixed_string_t name;
2803 cmdline_fixed_string_t list_name;
2804 cmdline_fixed_string_t list_of_items;
2808 parse_reta_config(const char *str,
2809 struct rte_eth_rss_reta_entry64 *reta_conf,
2810 uint16_t nb_entries)
2814 uint16_t hash_index, idx, shift;
2817 const char *p, *p0 = str;
2824 unsigned long int_fld[_NUM_FLD];
2825 char *str_fld[_NUM_FLD];
2827 while ((p = strchr(p0,'(')) != NULL) {
2829 if((p0 = strchr(p,')')) == NULL)
2833 if(size >= sizeof(s))
2836 snprintf(s, sizeof(s), "%.*s", size, p);
2837 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2839 for (i = 0; i < _NUM_FLD; i++) {
2841 int_fld[i] = strtoul(str_fld[i], &end, 0);
2842 if (errno != 0 || end == str_fld[i] ||
2847 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2848 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2850 if (hash_index >= nb_entries) {
2851 printf("Invalid RETA hash index=%d\n", hash_index);
2855 idx = hash_index / RTE_RETA_GROUP_SIZE;
2856 shift = hash_index % RTE_RETA_GROUP_SIZE;
2857 reta_conf[idx].mask |= (1ULL << shift);
2858 reta_conf[idx].reta[shift] = nb_queue;
2865 cmd_set_rss_reta_parsed(void *parsed_result,
2866 __attribute__((unused)) struct cmdline *cl,
2867 __attribute__((unused)) void *data)
2870 struct rte_eth_dev_info dev_info;
2871 struct rte_eth_rss_reta_entry64 reta_conf[8];
2872 struct cmd_config_rss_reta *res = parsed_result;
2874 memset(&dev_info, 0, sizeof(dev_info));
2875 rte_eth_dev_info_get(res->port_id, &dev_info);
2876 if (dev_info.reta_size == 0) {
2877 printf("Redirection table size is 0 which is "
2878 "invalid for RSS\n");
2881 printf("The reta size of port %d is %u\n",
2882 res->port_id, dev_info.reta_size);
2883 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2884 printf("Currently do not support more than %u entries of "
2885 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2889 memset(reta_conf, 0, sizeof(reta_conf));
2890 if (!strcmp(res->list_name, "reta")) {
2891 if (parse_reta_config(res->list_of_items, reta_conf,
2892 dev_info.reta_size)) {
2893 printf("Invalid RSS Redirection Table "
2894 "config entered\n");
2897 ret = rte_eth_dev_rss_reta_update(res->port_id,
2898 reta_conf, dev_info.reta_size);
2900 printf("Bad redirection table parameter, "
2901 "return code = %d \n", ret);
2905 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2906 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2907 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2908 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2909 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2910 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2911 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2912 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2913 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2914 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2915 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2916 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2918 cmdline_parse_inst_t cmd_config_rss_reta = {
2919 .f = cmd_set_rss_reta_parsed,
2921 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2923 (void *)&cmd_config_rss_reta_port,
2924 (void *)&cmd_config_rss_reta_keyword,
2925 (void *)&cmd_config_rss_reta_port_id,
2926 (void *)&cmd_config_rss_reta_name,
2927 (void *)&cmd_config_rss_reta_list_name,
2928 (void *)&cmd_config_rss_reta_list_of_items,
2933 /* *** SHOW PORT RETA INFO *** */
2934 struct cmd_showport_reta {
2935 cmdline_fixed_string_t show;
2936 cmdline_fixed_string_t port;
2938 cmdline_fixed_string_t rss;
2939 cmdline_fixed_string_t reta;
2941 cmdline_fixed_string_t list_of_items;
2945 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2946 uint16_t nb_entries,
2950 const char *p, *p0 = str;
2955 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2956 RTE_RETA_GROUP_SIZE;
2959 p = strchr(p0, '(');
2963 p0 = strchr(p, ')');
2967 if (size >= sizeof(s)) {
2968 printf("The string size exceeds the internal buffer size\n");
2971 snprintf(s, sizeof(s), "%.*s", size, p);
2972 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2973 if (ret <= 0 || ret != num) {
2974 printf("The bits of masks do not match the number of "
2975 "reta entries: %u\n", num);
2978 for (i = 0; i < ret; i++)
2979 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2985 cmd_showport_reta_parsed(void *parsed_result,
2986 __attribute__((unused)) struct cmdline *cl,
2987 __attribute__((unused)) void *data)
2989 struct cmd_showport_reta *res = parsed_result;
2990 struct rte_eth_rss_reta_entry64 reta_conf[8];
2991 struct rte_eth_dev_info dev_info;
2992 uint16_t max_reta_size;
2994 memset(&dev_info, 0, sizeof(dev_info));
2995 rte_eth_dev_info_get(res->port_id, &dev_info);
2996 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2997 if (res->size == 0 || res->size > max_reta_size) {
2998 printf("Invalid redirection table size: %u (1-%u)\n",
2999 res->size, max_reta_size);
3003 memset(reta_conf, 0, sizeof(reta_conf));
3004 if (showport_parse_reta_config(reta_conf, res->size,
3005 res->list_of_items) < 0) {
3006 printf("Invalid string: %s for reta masks\n",
3007 res->list_of_items);
3010 port_rss_reta_info(res->port_id, reta_conf, res->size);
3013 cmdline_parse_token_string_t cmd_showport_reta_show =
3014 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3015 cmdline_parse_token_string_t cmd_showport_reta_port =
3016 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3017 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3018 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3019 cmdline_parse_token_string_t cmd_showport_reta_rss =
3020 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3021 cmdline_parse_token_string_t cmd_showport_reta_reta =
3022 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3023 cmdline_parse_token_num_t cmd_showport_reta_size =
3024 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3025 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3026 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3027 list_of_items, NULL);
3029 cmdline_parse_inst_t cmd_showport_reta = {
3030 .f = cmd_showport_reta_parsed,
3032 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3034 (void *)&cmd_showport_reta_show,
3035 (void *)&cmd_showport_reta_port,
3036 (void *)&cmd_showport_reta_port_id,
3037 (void *)&cmd_showport_reta_rss,
3038 (void *)&cmd_showport_reta_reta,
3039 (void *)&cmd_showport_reta_size,
3040 (void *)&cmd_showport_reta_list_of_items,
3045 /* *** Show RSS hash configuration *** */
3046 struct cmd_showport_rss_hash {
3047 cmdline_fixed_string_t show;
3048 cmdline_fixed_string_t port;
3050 cmdline_fixed_string_t rss_hash;
3051 cmdline_fixed_string_t rss_type;
3052 cmdline_fixed_string_t key; /* optional argument */
3055 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3056 __attribute__((unused)) struct cmdline *cl,
3059 struct cmd_showport_rss_hash *res = parsed_result;
3061 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3064 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3065 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3066 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3067 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3068 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3069 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3070 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3071 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3073 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3074 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3076 cmdline_parse_inst_t cmd_showport_rss_hash = {
3077 .f = cmd_showport_rss_hash_parsed,
3079 .help_str = "show port <port_id> rss-hash",
3081 (void *)&cmd_showport_rss_hash_show,
3082 (void *)&cmd_showport_rss_hash_port,
3083 (void *)&cmd_showport_rss_hash_port_id,
3084 (void *)&cmd_showport_rss_hash_rss_hash,
3089 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3090 .f = cmd_showport_rss_hash_parsed,
3092 .help_str = "show port <port_id> rss-hash key",
3094 (void *)&cmd_showport_rss_hash_show,
3095 (void *)&cmd_showport_rss_hash_port,
3096 (void *)&cmd_showport_rss_hash_port_id,
3097 (void *)&cmd_showport_rss_hash_rss_hash,
3098 (void *)&cmd_showport_rss_hash_rss_key,
3103 /* *** Configure DCB *** */
3104 struct cmd_config_dcb {
3105 cmdline_fixed_string_t port;
3106 cmdline_fixed_string_t config;
3108 cmdline_fixed_string_t dcb;
3109 cmdline_fixed_string_t vt;
3110 cmdline_fixed_string_t vt_en;
3112 cmdline_fixed_string_t pfc;
3113 cmdline_fixed_string_t pfc_en;
3117 cmd_config_dcb_parsed(void *parsed_result,
3118 __attribute__((unused)) struct cmdline *cl,
3119 __attribute__((unused)) void *data)
3121 struct cmd_config_dcb *res = parsed_result;
3122 portid_t port_id = res->port_id;
3123 struct rte_port *port;
3127 port = &ports[port_id];
3128 /** Check if the port is not started **/
3129 if (port->port_status != RTE_PORT_STOPPED) {
3130 printf("Please stop port %d first\n", port_id);
3134 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3135 printf("The invalid number of traffic class,"
3136 " only 4 or 8 allowed.\n");
3140 if (nb_fwd_lcores < res->num_tcs) {
3141 printf("nb_cores shouldn't be less than number of TCs.\n");
3144 if (!strncmp(res->pfc_en, "on", 2))
3149 /* DCB in VT mode */
3150 if (!strncmp(res->vt_en, "on", 2))
3151 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3152 (enum rte_eth_nb_tcs)res->num_tcs,
3155 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3156 (enum rte_eth_nb_tcs)res->num_tcs,
3161 printf("Cannot initialize network ports.\n");
3165 cmd_reconfig_device_queue(port_id, 1, 1);
3168 cmdline_parse_token_string_t cmd_config_dcb_port =
3169 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3170 cmdline_parse_token_string_t cmd_config_dcb_config =
3171 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3172 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3173 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3174 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3175 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3176 cmdline_parse_token_string_t cmd_config_dcb_vt =
3177 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3178 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3179 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3180 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3181 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3182 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3183 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3184 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3185 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3187 cmdline_parse_inst_t cmd_config_dcb = {
3188 .f = cmd_config_dcb_parsed,
3190 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3192 (void *)&cmd_config_dcb_port,
3193 (void *)&cmd_config_dcb_config,
3194 (void *)&cmd_config_dcb_port_id,
3195 (void *)&cmd_config_dcb_dcb,
3196 (void *)&cmd_config_dcb_vt,
3197 (void *)&cmd_config_dcb_vt_en,
3198 (void *)&cmd_config_dcb_num_tcs,
3199 (void *)&cmd_config_dcb_pfc,
3200 (void *)&cmd_config_dcb_pfc_en,
3205 /* *** configure number of packets per burst *** */
3206 struct cmd_config_burst {
3207 cmdline_fixed_string_t port;
3208 cmdline_fixed_string_t keyword;
3209 cmdline_fixed_string_t all;
3210 cmdline_fixed_string_t name;
3215 cmd_config_burst_parsed(void *parsed_result,
3216 __attribute__((unused)) struct cmdline *cl,
3217 __attribute__((unused)) void *data)
3219 struct cmd_config_burst *res = parsed_result;
3220 struct rte_eth_dev_info dev_info;
3221 uint16_t rec_nb_pkts;
3223 if (!all_ports_stopped()) {
3224 printf("Please stop all ports first\n");
3228 if (!strcmp(res->name, "burst")) {
3229 if (res->value == 0) {
3230 /* If user gives a value of zero, query the PMD for
3231 * its recommended Rx burst size. Testpmd uses a single
3232 * size for all ports, so assume all ports are the same
3233 * NIC model and use the values from Port 0.
3235 rte_eth_dev_info_get(0, &dev_info);
3236 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3238 if (rec_nb_pkts == 0) {
3239 printf("PMD does not recommend a burst size.\n"
3240 "User provided value must be between"
3241 " 1 and %d\n", MAX_PKT_BURST);
3243 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3244 printf("PMD recommended burst size of %d"
3245 " exceeds maximum value of %d\n",
3246 rec_nb_pkts, MAX_PKT_BURST);
3249 printf("Using PMD-provided burst value of %d\n",
3251 nb_pkt_per_burst = rec_nb_pkts;
3252 } else if (res->value > MAX_PKT_BURST) {
3253 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3256 nb_pkt_per_burst = res->value;
3258 printf("Unknown parameter\n");
3264 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3267 cmdline_parse_token_string_t cmd_config_burst_port =
3268 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3269 cmdline_parse_token_string_t cmd_config_burst_keyword =
3270 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3271 cmdline_parse_token_string_t cmd_config_burst_all =
3272 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3273 cmdline_parse_token_string_t cmd_config_burst_name =
3274 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3275 cmdline_parse_token_num_t cmd_config_burst_value =
3276 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3278 cmdline_parse_inst_t cmd_config_burst = {
3279 .f = cmd_config_burst_parsed,
3281 .help_str = "port config all burst <value>",
3283 (void *)&cmd_config_burst_port,
3284 (void *)&cmd_config_burst_keyword,
3285 (void *)&cmd_config_burst_all,
3286 (void *)&cmd_config_burst_name,
3287 (void *)&cmd_config_burst_value,
3292 /* *** configure rx/tx queues *** */
3293 struct cmd_config_thresh {
3294 cmdline_fixed_string_t port;
3295 cmdline_fixed_string_t keyword;
3296 cmdline_fixed_string_t all;
3297 cmdline_fixed_string_t name;
3302 cmd_config_thresh_parsed(void *parsed_result,
3303 __attribute__((unused)) struct cmdline *cl,
3304 __attribute__((unused)) void *data)
3306 struct cmd_config_thresh *res = parsed_result;
3308 if (!all_ports_stopped()) {
3309 printf("Please stop all ports first\n");
3313 if (!strcmp(res->name, "txpt"))
3314 tx_pthresh = res->value;
3315 else if(!strcmp(res->name, "txht"))
3316 tx_hthresh = res->value;
3317 else if(!strcmp(res->name, "txwt"))
3318 tx_wthresh = res->value;
3319 else if(!strcmp(res->name, "rxpt"))
3320 rx_pthresh = res->value;
3321 else if(!strcmp(res->name, "rxht"))
3322 rx_hthresh = res->value;
3323 else if(!strcmp(res->name, "rxwt"))
3324 rx_wthresh = res->value;
3326 printf("Unknown parameter\n");
3332 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3335 cmdline_parse_token_string_t cmd_config_thresh_port =
3336 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3337 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3338 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3339 cmdline_parse_token_string_t cmd_config_thresh_all =
3340 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3341 cmdline_parse_token_string_t cmd_config_thresh_name =
3342 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3343 "txpt#txht#txwt#rxpt#rxht#rxwt");
3344 cmdline_parse_token_num_t cmd_config_thresh_value =
3345 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3347 cmdline_parse_inst_t cmd_config_thresh = {
3348 .f = cmd_config_thresh_parsed,
3350 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3352 (void *)&cmd_config_thresh_port,
3353 (void *)&cmd_config_thresh_keyword,
3354 (void *)&cmd_config_thresh_all,
3355 (void *)&cmd_config_thresh_name,
3356 (void *)&cmd_config_thresh_value,
3361 /* *** configure free/rs threshold *** */
3362 struct cmd_config_threshold {
3363 cmdline_fixed_string_t port;
3364 cmdline_fixed_string_t keyword;
3365 cmdline_fixed_string_t all;
3366 cmdline_fixed_string_t name;
3371 cmd_config_threshold_parsed(void *parsed_result,
3372 __attribute__((unused)) struct cmdline *cl,
3373 __attribute__((unused)) void *data)
3375 struct cmd_config_threshold *res = parsed_result;
3377 if (!all_ports_stopped()) {
3378 printf("Please stop all ports first\n");
3382 if (!strcmp(res->name, "txfreet"))
3383 tx_free_thresh = res->value;
3384 else if (!strcmp(res->name, "txrst"))
3385 tx_rs_thresh = res->value;
3386 else if (!strcmp(res->name, "rxfreet"))
3387 rx_free_thresh = res->value;
3389 printf("Unknown parameter\n");
3395 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3398 cmdline_parse_token_string_t cmd_config_threshold_port =
3399 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3400 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3401 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3403 cmdline_parse_token_string_t cmd_config_threshold_all =
3404 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3405 cmdline_parse_token_string_t cmd_config_threshold_name =
3406 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3407 "txfreet#txrst#rxfreet");
3408 cmdline_parse_token_num_t cmd_config_threshold_value =
3409 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3411 cmdline_parse_inst_t cmd_config_threshold = {
3412 .f = cmd_config_threshold_parsed,
3414 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3416 (void *)&cmd_config_threshold_port,
3417 (void *)&cmd_config_threshold_keyword,
3418 (void *)&cmd_config_threshold_all,
3419 (void *)&cmd_config_threshold_name,
3420 (void *)&cmd_config_threshold_value,
3426 struct cmd_stop_result {
3427 cmdline_fixed_string_t stop;
3430 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3431 __attribute__((unused)) struct cmdline *cl,
3432 __attribute__((unused)) void *data)
3434 stop_packet_forwarding();
3437 cmdline_parse_token_string_t cmd_stop_stop =
3438 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3440 cmdline_parse_inst_t cmd_stop = {
3441 .f = cmd_stop_parsed,
3443 .help_str = "stop: Stop packet forwarding",
3445 (void *)&cmd_stop_stop,
3450 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3453 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3454 unsigned int *parsed_items, int check_unique_values)
3456 unsigned int nb_item;
3464 * First parse all items in the list and store their value.
3469 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3471 if ((c >= '0') && (c <= '9')) {
3472 value = (unsigned int) (value * 10 + (c - '0'));
3477 printf("character %c is not a decimal digit\n", c);
3481 printf("No valid value before comma\n");
3484 if (nb_item < max_items) {
3485 parsed_items[nb_item] = value;
3491 if (nb_item >= max_items) {
3492 printf("Number of %s = %u > %u (maximum items)\n",
3493 item_name, nb_item + 1, max_items);
3496 parsed_items[nb_item++] = value;
3497 if (! check_unique_values)
3501 * Then, check that all values in the list are differents.
3502 * No optimization here...
3504 for (i = 0; i < nb_item; i++) {
3505 for (j = i + 1; j < nb_item; j++) {
3506 if (parsed_items[j] == parsed_items[i]) {
3507 printf("duplicated %s %u at index %u and %u\n",
3508 item_name, parsed_items[i], i, j);
3516 struct cmd_set_list_result {
3517 cmdline_fixed_string_t cmd_keyword;
3518 cmdline_fixed_string_t list_name;
3519 cmdline_fixed_string_t list_of_items;
3522 static void cmd_set_list_parsed(void *parsed_result,
3523 __attribute__((unused)) struct cmdline *cl,
3524 __attribute__((unused)) void *data)
3526 struct cmd_set_list_result *res;
3528 unsigned int lcorelist[RTE_MAX_LCORE];
3529 unsigned int portlist[RTE_MAX_ETHPORTS];
3531 unsigned int nb_item;
3533 if (test_done == 0) {
3534 printf("Please stop forwarding first\n");
3538 res = parsed_result;
3539 if (!strcmp(res->list_name, "corelist")) {
3540 nb_item = parse_item_list(res->list_of_items, "core",
3542 parsed_items.lcorelist, 1);
3544 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3549 if (!strcmp(res->list_name, "portlist")) {
3550 nb_item = parse_item_list(res->list_of_items, "port",
3552 parsed_items.portlist, 1);
3554 set_fwd_ports_list(parsed_items.portlist, nb_item);
3560 cmdline_parse_token_string_t cmd_set_list_keyword =
3561 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3563 cmdline_parse_token_string_t cmd_set_list_name =
3564 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3565 "corelist#portlist");
3566 cmdline_parse_token_string_t cmd_set_list_of_items =
3567 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3570 cmdline_parse_inst_t cmd_set_fwd_list = {
3571 .f = cmd_set_list_parsed,
3573 .help_str = "set corelist|portlist <list0[,list1]*>",
3575 (void *)&cmd_set_list_keyword,
3576 (void *)&cmd_set_list_name,
3577 (void *)&cmd_set_list_of_items,
3582 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3584 struct cmd_setmask_result {
3585 cmdline_fixed_string_t set;
3586 cmdline_fixed_string_t mask;
3590 static void cmd_set_mask_parsed(void *parsed_result,
3591 __attribute__((unused)) struct cmdline *cl,
3592 __attribute__((unused)) void *data)
3594 struct cmd_setmask_result *res = parsed_result;
3596 if (test_done == 0) {
3597 printf("Please stop forwarding first\n");
3600 if (!strcmp(res->mask, "coremask")) {
3601 set_fwd_lcores_mask(res->hexavalue);
3603 } else if (!strcmp(res->mask, "portmask")) {
3604 set_fwd_ports_mask(res->hexavalue);
3609 cmdline_parse_token_string_t cmd_setmask_set =
3610 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3611 cmdline_parse_token_string_t cmd_setmask_mask =
3612 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3613 "coremask#portmask");
3614 cmdline_parse_token_num_t cmd_setmask_value =
3615 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3617 cmdline_parse_inst_t cmd_set_fwd_mask = {
3618 .f = cmd_set_mask_parsed,
3620 .help_str = "set coremask|portmask <hexadecimal value>",
3622 (void *)&cmd_setmask_set,
3623 (void *)&cmd_setmask_mask,
3624 (void *)&cmd_setmask_value,
3630 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3632 struct cmd_set_result {
3633 cmdline_fixed_string_t set;
3634 cmdline_fixed_string_t what;
3638 static void cmd_set_parsed(void *parsed_result,
3639 __attribute__((unused)) struct cmdline *cl,
3640 __attribute__((unused)) void *data)
3642 struct cmd_set_result *res = parsed_result;
3643 if (!strcmp(res->what, "nbport")) {
3644 set_fwd_ports_number(res->value);
3646 } else if (!strcmp(res->what, "nbcore")) {
3647 set_fwd_lcores_number(res->value);
3649 } else if (!strcmp(res->what, "burst"))
3650 set_nb_pkt_per_burst(res->value);
3651 else if (!strcmp(res->what, "verbose"))
3652 set_verbose_level(res->value);
3655 cmdline_parse_token_string_t cmd_set_set =
3656 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3657 cmdline_parse_token_string_t cmd_set_what =
3658 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3659 "nbport#nbcore#burst#verbose");
3660 cmdline_parse_token_num_t cmd_set_value =
3661 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3663 cmdline_parse_inst_t cmd_set_numbers = {
3664 .f = cmd_set_parsed,
3666 .help_str = "set nbport|nbcore|burst|verbose <value>",
3668 (void *)&cmd_set_set,
3669 (void *)&cmd_set_what,
3670 (void *)&cmd_set_value,
3675 /* *** SET LOG LEVEL CONFIGURATION *** */
3677 struct cmd_set_log_result {
3678 cmdline_fixed_string_t set;
3679 cmdline_fixed_string_t log;
3680 cmdline_fixed_string_t type;
3685 cmd_set_log_parsed(void *parsed_result,
3686 __attribute__((unused)) struct cmdline *cl,
3687 __attribute__((unused)) void *data)
3689 struct cmd_set_log_result *res;
3692 res = parsed_result;
3693 if (!strcmp(res->type, "global"))
3694 rte_log_set_global_level(res->level);
3696 ret = rte_log_set_level_regexp(res->type, res->level);
3698 printf("Unable to set log level\n");
3702 cmdline_parse_token_string_t cmd_set_log_set =
3703 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3704 cmdline_parse_token_string_t cmd_set_log_log =
3705 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3706 cmdline_parse_token_string_t cmd_set_log_type =
3707 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3708 cmdline_parse_token_num_t cmd_set_log_level =
3709 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3711 cmdline_parse_inst_t cmd_set_log = {
3712 .f = cmd_set_log_parsed,
3714 .help_str = "set log global|<type> <level>",
3716 (void *)&cmd_set_log_set,
3717 (void *)&cmd_set_log_log,
3718 (void *)&cmd_set_log_type,
3719 (void *)&cmd_set_log_level,
3724 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3726 struct cmd_set_txpkts_result {
3727 cmdline_fixed_string_t cmd_keyword;
3728 cmdline_fixed_string_t txpkts;
3729 cmdline_fixed_string_t seg_lengths;
3733 cmd_set_txpkts_parsed(void *parsed_result,
3734 __attribute__((unused)) struct cmdline *cl,
3735 __attribute__((unused)) void *data)
3737 struct cmd_set_txpkts_result *res;
3738 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3739 unsigned int nb_segs;
3741 res = parsed_result;
3742 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3743 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3745 set_tx_pkt_segments(seg_lengths, nb_segs);
3748 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3749 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3750 cmd_keyword, "set");
3751 cmdline_parse_token_string_t cmd_set_txpkts_name =
3752 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3754 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3755 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3758 cmdline_parse_inst_t cmd_set_txpkts = {
3759 .f = cmd_set_txpkts_parsed,
3761 .help_str = "set txpkts <len0[,len1]*>",
3763 (void *)&cmd_set_txpkts_keyword,
3764 (void *)&cmd_set_txpkts_name,
3765 (void *)&cmd_set_txpkts_lengths,
3770 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3772 struct cmd_set_txsplit_result {
3773 cmdline_fixed_string_t cmd_keyword;
3774 cmdline_fixed_string_t txsplit;
3775 cmdline_fixed_string_t mode;
3779 cmd_set_txsplit_parsed(void *parsed_result,
3780 __attribute__((unused)) struct cmdline *cl,
3781 __attribute__((unused)) void *data)
3783 struct cmd_set_txsplit_result *res;
3785 res = parsed_result;
3786 set_tx_pkt_split(res->mode);
3789 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3790 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3791 cmd_keyword, "set");
3792 cmdline_parse_token_string_t cmd_set_txsplit_name =
3793 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3794 txsplit, "txsplit");
3795 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3796 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3799 cmdline_parse_inst_t cmd_set_txsplit = {
3800 .f = cmd_set_txsplit_parsed,
3802 .help_str = "set txsplit on|off|rand",
3804 (void *)&cmd_set_txsplit_keyword,
3805 (void *)&cmd_set_txsplit_name,
3806 (void *)&cmd_set_txsplit_mode,
3811 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3812 struct cmd_rx_vlan_filter_all_result {
3813 cmdline_fixed_string_t rx_vlan;
3814 cmdline_fixed_string_t what;
3815 cmdline_fixed_string_t all;
3820 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3821 __attribute__((unused)) struct cmdline *cl,
3822 __attribute__((unused)) void *data)
3824 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3826 if (!strcmp(res->what, "add"))
3827 rx_vlan_all_filter_set(res->port_id, 1);
3829 rx_vlan_all_filter_set(res->port_id, 0);
3832 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3833 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3834 rx_vlan, "rx_vlan");
3835 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3836 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3838 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3839 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3841 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3842 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3845 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3846 .f = cmd_rx_vlan_filter_all_parsed,
3848 .help_str = "rx_vlan add|rm all <port_id>: "
3849 "Add/Remove all identifiers to/from the set of VLAN "
3850 "identifiers filtered by a port",
3852 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3853 (void *)&cmd_rx_vlan_filter_all_what,
3854 (void *)&cmd_rx_vlan_filter_all_all,
3855 (void *)&cmd_rx_vlan_filter_all_portid,
3860 /* *** VLAN OFFLOAD SET ON A PORT *** */
3861 struct cmd_vlan_offload_result {
3862 cmdline_fixed_string_t vlan;
3863 cmdline_fixed_string_t set;
3864 cmdline_fixed_string_t vlan_type;
3865 cmdline_fixed_string_t what;
3866 cmdline_fixed_string_t on;
3867 cmdline_fixed_string_t port_id;
3871 cmd_vlan_offload_parsed(void *parsed_result,
3872 __attribute__((unused)) struct cmdline *cl,
3873 __attribute__((unused)) void *data)
3876 struct cmd_vlan_offload_result *res = parsed_result;
3879 portid_t port_id = 0;
3883 len = strnlen(str, STR_TOKEN_SIZE);
3885 /* Get port_id first */
3893 tmp = strtoul(str, NULL, 0);
3894 /* If port_id greater that what portid_t can represent, return */
3895 if(tmp >= RTE_MAX_ETHPORTS)
3897 port_id = (portid_t)tmp;
3899 if (!strcmp(res->on, "on"))
3904 if (!strcmp(res->what, "strip"))
3905 rx_vlan_strip_set(port_id, on);
3906 else if(!strcmp(res->what, "stripq")){
3907 uint16_t queue_id = 0;
3909 /* No queue_id, return */
3911 printf("must specify (port,queue_id)\n");
3914 tmp = strtoul(str + i + 1, NULL, 0);
3915 /* If queue_id greater that what 16-bits can represent, return */
3919 queue_id = (uint16_t)tmp;
3920 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3922 else if (!strcmp(res->what, "filter"))
3923 rx_vlan_filter_set(port_id, on);
3925 vlan_extend_set(port_id, on);
3930 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3931 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3933 cmdline_parse_token_string_t cmd_vlan_offload_set =
3934 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3936 cmdline_parse_token_string_t cmd_vlan_offload_what =
3937 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3938 what, "strip#filter#qinq#stripq");
3939 cmdline_parse_token_string_t cmd_vlan_offload_on =
3940 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3942 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3943 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3946 cmdline_parse_inst_t cmd_vlan_offload = {
3947 .f = cmd_vlan_offload_parsed,
3949 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3950 "<port_id[,queue_id]>: "
3951 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3953 (void *)&cmd_vlan_offload_vlan,
3954 (void *)&cmd_vlan_offload_set,
3955 (void *)&cmd_vlan_offload_what,
3956 (void *)&cmd_vlan_offload_on,
3957 (void *)&cmd_vlan_offload_portid,
3962 /* *** VLAN TPID SET ON A PORT *** */
3963 struct cmd_vlan_tpid_result {
3964 cmdline_fixed_string_t vlan;
3965 cmdline_fixed_string_t set;
3966 cmdline_fixed_string_t vlan_type;
3967 cmdline_fixed_string_t what;
3973 cmd_vlan_tpid_parsed(void *parsed_result,
3974 __attribute__((unused)) struct cmdline *cl,
3975 __attribute__((unused)) void *data)
3977 struct cmd_vlan_tpid_result *res = parsed_result;
3978 enum rte_vlan_type vlan_type;
3980 if (!strcmp(res->vlan_type, "inner"))
3981 vlan_type = ETH_VLAN_TYPE_INNER;
3982 else if (!strcmp(res->vlan_type, "outer"))
3983 vlan_type = ETH_VLAN_TYPE_OUTER;
3985 printf("Unknown vlan type\n");
3988 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3991 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3992 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3994 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3995 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3997 cmdline_parse_token_string_t cmd_vlan_type =
3998 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3999 vlan_type, "inner#outer");
4000 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4001 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4003 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4004 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4006 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4007 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4010 cmdline_parse_inst_t cmd_vlan_tpid = {
4011 .f = cmd_vlan_tpid_parsed,
4013 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4014 "Set the VLAN Ether type",
4016 (void *)&cmd_vlan_tpid_vlan,
4017 (void *)&cmd_vlan_tpid_set,
4018 (void *)&cmd_vlan_type,
4019 (void *)&cmd_vlan_tpid_what,
4020 (void *)&cmd_vlan_tpid_tpid,
4021 (void *)&cmd_vlan_tpid_portid,
4026 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4027 struct cmd_rx_vlan_filter_result {
4028 cmdline_fixed_string_t rx_vlan;
4029 cmdline_fixed_string_t what;
4035 cmd_rx_vlan_filter_parsed(void *parsed_result,
4036 __attribute__((unused)) struct cmdline *cl,
4037 __attribute__((unused)) void *data)
4039 struct cmd_rx_vlan_filter_result *res = parsed_result;
4041 if (!strcmp(res->what, "add"))
4042 rx_vft_set(res->port_id, res->vlan_id, 1);
4044 rx_vft_set(res->port_id, res->vlan_id, 0);
4047 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4048 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4049 rx_vlan, "rx_vlan");
4050 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4051 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4053 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4054 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4056 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4057 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4060 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4061 .f = cmd_rx_vlan_filter_parsed,
4063 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4064 "Add/Remove a VLAN identifier to/from the set of VLAN "
4065 "identifiers filtered by a port",
4067 (void *)&cmd_rx_vlan_filter_rx_vlan,
4068 (void *)&cmd_rx_vlan_filter_what,
4069 (void *)&cmd_rx_vlan_filter_vlanid,
4070 (void *)&cmd_rx_vlan_filter_portid,
4075 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4076 struct cmd_tx_vlan_set_result {
4077 cmdline_fixed_string_t tx_vlan;
4078 cmdline_fixed_string_t set;
4084 cmd_tx_vlan_set_parsed(void *parsed_result,
4085 __attribute__((unused)) struct cmdline *cl,
4086 __attribute__((unused)) void *data)
4088 struct cmd_tx_vlan_set_result *res = parsed_result;
4090 if (!port_is_stopped(res->port_id)) {
4091 printf("Please stop port %d first\n", res->port_id);
4095 tx_vlan_set(res->port_id, res->vlan_id);
4097 cmd_reconfig_device_queue(res->port_id, 1, 1);
4100 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4101 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4102 tx_vlan, "tx_vlan");
4103 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4104 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4106 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4107 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4109 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4110 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4113 cmdline_parse_inst_t cmd_tx_vlan_set = {
4114 .f = cmd_tx_vlan_set_parsed,
4116 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4117 "Enable hardware insertion of a single VLAN header "
4118 "with a given TAG Identifier in packets sent on a port",
4120 (void *)&cmd_tx_vlan_set_tx_vlan,
4121 (void *)&cmd_tx_vlan_set_set,
4122 (void *)&cmd_tx_vlan_set_portid,
4123 (void *)&cmd_tx_vlan_set_vlanid,
4128 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4129 struct cmd_tx_vlan_set_qinq_result {
4130 cmdline_fixed_string_t tx_vlan;
4131 cmdline_fixed_string_t set;
4134 uint16_t vlan_id_outer;
4138 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4139 __attribute__((unused)) struct cmdline *cl,
4140 __attribute__((unused)) void *data)
4142 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4144 if (!port_is_stopped(res->port_id)) {
4145 printf("Please stop port %d first\n", res->port_id);
4149 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4151 cmd_reconfig_device_queue(res->port_id, 1, 1);
4154 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4155 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4156 tx_vlan, "tx_vlan");
4157 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4158 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4160 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4161 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4163 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4164 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4166 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4167 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4168 vlan_id_outer, UINT16);
4170 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4171 .f = cmd_tx_vlan_set_qinq_parsed,
4173 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4174 "Enable hardware insertion of double VLAN header "
4175 "with given TAG Identifiers in packets sent on a port",
4177 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4178 (void *)&cmd_tx_vlan_set_qinq_set,
4179 (void *)&cmd_tx_vlan_set_qinq_portid,
4180 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4181 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4186 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4187 struct cmd_tx_vlan_set_pvid_result {
4188 cmdline_fixed_string_t tx_vlan;
4189 cmdline_fixed_string_t set;
4190 cmdline_fixed_string_t pvid;
4193 cmdline_fixed_string_t mode;
4197 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4198 __attribute__((unused)) struct cmdline *cl,
4199 __attribute__((unused)) void *data)
4201 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4203 if (strcmp(res->mode, "on") == 0)
4204 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4206 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4209 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4210 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4211 tx_vlan, "tx_vlan");
4212 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4213 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4215 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4216 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4218 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4219 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4221 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4222 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4224 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4225 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4228 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4229 .f = cmd_tx_vlan_set_pvid_parsed,
4231 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4233 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4234 (void *)&cmd_tx_vlan_set_pvid_set,
4235 (void *)&cmd_tx_vlan_set_pvid_pvid,
4236 (void *)&cmd_tx_vlan_set_pvid_port_id,
4237 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4238 (void *)&cmd_tx_vlan_set_pvid_mode,
4243 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4244 struct cmd_tx_vlan_reset_result {
4245 cmdline_fixed_string_t tx_vlan;
4246 cmdline_fixed_string_t reset;
4251 cmd_tx_vlan_reset_parsed(void *parsed_result,
4252 __attribute__((unused)) struct cmdline *cl,
4253 __attribute__((unused)) void *data)
4255 struct cmd_tx_vlan_reset_result *res = parsed_result;
4257 if (!port_is_stopped(res->port_id)) {
4258 printf("Please stop port %d first\n", res->port_id);
4262 tx_vlan_reset(res->port_id);
4264 cmd_reconfig_device_queue(res->port_id, 1, 1);
4267 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4268 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4269 tx_vlan, "tx_vlan");
4270 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4271 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4273 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4274 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4277 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4278 .f = cmd_tx_vlan_reset_parsed,
4280 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4281 "VLAN header in packets sent on a port",
4283 (void *)&cmd_tx_vlan_reset_tx_vlan,
4284 (void *)&cmd_tx_vlan_reset_reset,
4285 (void *)&cmd_tx_vlan_reset_portid,
4291 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4292 struct cmd_csum_result {
4293 cmdline_fixed_string_t csum;
4294 cmdline_fixed_string_t mode;
4295 cmdline_fixed_string_t proto;
4296 cmdline_fixed_string_t hwsw;
4301 csum_show(int port_id)
4303 struct rte_eth_dev_info dev_info;
4304 uint64_t tx_offloads;
4306 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4307 printf("Parse tunnel is %s\n",
4308 (ports[port_id].parse_tunnel) ? "on" : "off");
4309 printf("IP checksum offload is %s\n",
4310 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4311 printf("UDP checksum offload is %s\n",
4312 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4313 printf("TCP checksum offload is %s\n",
4314 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4315 printf("SCTP checksum offload is %s\n",
4316 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4317 printf("Outer-Ip checksum offload is %s\n",
4318 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4319 printf("Outer-Udp checksum offload is %s\n",
4320 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4322 /* display warnings if configuration is not supported by the NIC */
4323 rte_eth_dev_info_get(port_id, &dev_info);
4324 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4325 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4326 printf("Warning: hardware IP checksum enabled but not "
4327 "supported by port %d\n", port_id);
4329 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4330 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4331 printf("Warning: hardware UDP checksum enabled but not "
4332 "supported by port %d\n", port_id);
4334 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4335 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4336 printf("Warning: hardware TCP checksum enabled but not "
4337 "supported by port %d\n", port_id);
4339 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4340 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4341 printf("Warning: hardware SCTP checksum enabled but not "
4342 "supported by port %d\n", port_id);
4344 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4345 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4346 printf("Warning: hardware outer IP checksum enabled but not "
4347 "supported by port %d\n", port_id);
4349 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4350 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4352 printf("Warning: hardware outer UDP checksum enabled but not "
4353 "supported by port %d\n", port_id);
4358 cmd_csum_parsed(void *parsed_result,
4359 __attribute__((unused)) struct cmdline *cl,
4360 __attribute__((unused)) void *data)
4362 struct cmd_csum_result *res = parsed_result;
4364 uint64_t csum_offloads = 0;
4365 struct rte_eth_dev_info dev_info;
4367 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4368 printf("invalid port %d\n", res->port_id);
4371 if (!port_is_stopped(res->port_id)) {
4372 printf("Please stop port %d first\n", res->port_id);
4376 rte_eth_dev_info_get(res->port_id, &dev_info);
4377 if (!strcmp(res->mode, "set")) {
4379 if (!strcmp(res->hwsw, "hw"))
4382 if (!strcmp(res->proto, "ip")) {
4383 if (hw == 0 || (dev_info.tx_offload_capa &
4384 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4385 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4387 printf("IP checksum offload is not supported "
4388 "by port %u\n", res->port_id);
4390 } else if (!strcmp(res->proto, "udp")) {
4391 if (hw == 0 || (dev_info.tx_offload_capa &
4392 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4393 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4395 printf("UDP checksum offload is not supported "
4396 "by port %u\n", res->port_id);
4398 } else if (!strcmp(res->proto, "tcp")) {
4399 if (hw == 0 || (dev_info.tx_offload_capa &
4400 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4401 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4403 printf("TCP checksum offload is not supported "
4404 "by port %u\n", res->port_id);
4406 } else if (!strcmp(res->proto, "sctp")) {
4407 if (hw == 0 || (dev_info.tx_offload_capa &
4408 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4409 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4411 printf("SCTP checksum offload is not supported "
4412 "by port %u\n", res->port_id);
4414 } else if (!strcmp(res->proto, "outer-ip")) {
4415 if (hw == 0 || (dev_info.tx_offload_capa &
4416 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4418 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4420 printf("Outer IP checksum offload is not "
4421 "supported by port %u\n", res->port_id);
4423 } else if (!strcmp(res->proto, "outer-udp")) {
4424 if (hw == 0 || (dev_info.tx_offload_capa &
4425 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4427 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4429 printf("Outer UDP checksum offload is not "
4430 "supported by port %u\n", res->port_id);
4435 ports[res->port_id].dev_conf.txmode.offloads |=
4438 ports[res->port_id].dev_conf.txmode.offloads &=
4442 csum_show(res->port_id);
4444 cmd_reconfig_device_queue(res->port_id, 1, 1);
4447 cmdline_parse_token_string_t cmd_csum_csum =
4448 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4450 cmdline_parse_token_string_t cmd_csum_mode =
4451 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4453 cmdline_parse_token_string_t cmd_csum_proto =
4454 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4455 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4456 cmdline_parse_token_string_t cmd_csum_hwsw =
4457 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4459 cmdline_parse_token_num_t cmd_csum_portid =
4460 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4463 cmdline_parse_inst_t cmd_csum_set = {
4464 .f = cmd_csum_parsed,
4466 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4467 "Enable/Disable hardware calculation of L3/L4 checksum when "
4468 "using csum forward engine",
4470 (void *)&cmd_csum_csum,
4471 (void *)&cmd_csum_mode,
4472 (void *)&cmd_csum_proto,
4473 (void *)&cmd_csum_hwsw,
4474 (void *)&cmd_csum_portid,
4479 cmdline_parse_token_string_t cmd_csum_mode_show =
4480 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4483 cmdline_parse_inst_t cmd_csum_show = {
4484 .f = cmd_csum_parsed,
4486 .help_str = "csum show <port_id>: Show checksum offload configuration",
4488 (void *)&cmd_csum_csum,
4489 (void *)&cmd_csum_mode_show,
4490 (void *)&cmd_csum_portid,
4495 /* Enable/disable tunnel parsing */
4496 struct cmd_csum_tunnel_result {
4497 cmdline_fixed_string_t csum;
4498 cmdline_fixed_string_t parse;
4499 cmdline_fixed_string_t onoff;
4504 cmd_csum_tunnel_parsed(void *parsed_result,
4505 __attribute__((unused)) struct cmdline *cl,
4506 __attribute__((unused)) void *data)
4508 struct cmd_csum_tunnel_result *res = parsed_result;
4510 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4513 if (!strcmp(res->onoff, "on"))
4514 ports[res->port_id].parse_tunnel = 1;
4516 ports[res->port_id].parse_tunnel = 0;
4518 csum_show(res->port_id);
4521 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4522 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4524 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4525 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4526 parse, "parse-tunnel");
4527 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4528 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4530 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4531 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4534 cmdline_parse_inst_t cmd_csum_tunnel = {
4535 .f = cmd_csum_tunnel_parsed,
4537 .help_str = "csum parse-tunnel on|off <port_id>: "
4538 "Enable/Disable parsing of tunnels for csum engine",
4540 (void *)&cmd_csum_tunnel_csum,
4541 (void *)&cmd_csum_tunnel_parse,
4542 (void *)&cmd_csum_tunnel_onoff,
4543 (void *)&cmd_csum_tunnel_portid,
4548 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4549 struct cmd_tso_set_result {
4550 cmdline_fixed_string_t tso;
4551 cmdline_fixed_string_t mode;
4557 cmd_tso_set_parsed(void *parsed_result,
4558 __attribute__((unused)) struct cmdline *cl,
4559 __attribute__((unused)) void *data)
4561 struct cmd_tso_set_result *res = parsed_result;
4562 struct rte_eth_dev_info dev_info;
4564 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4566 if (!port_is_stopped(res->port_id)) {
4567 printf("Please stop port %d first\n", res->port_id);
4571 if (!strcmp(res->mode, "set"))
4572 ports[res->port_id].tso_segsz = res->tso_segsz;
4574 rte_eth_dev_info_get(res->port_id, &dev_info);
4575 if ((ports[res->port_id].tso_segsz != 0) &&
4576 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4577 printf("Error: TSO is not supported by port %d\n",
4582 if (ports[res->port_id].tso_segsz == 0) {
4583 ports[res->port_id].dev_conf.txmode.offloads &=
4584 ~DEV_TX_OFFLOAD_TCP_TSO;
4585 printf("TSO for non-tunneled packets is disabled\n");
4587 ports[res->port_id].dev_conf.txmode.offloads |=
4588 DEV_TX_OFFLOAD_TCP_TSO;
4589 printf("TSO segment size for non-tunneled packets is %d\n",
4590 ports[res->port_id].tso_segsz);
4593 /* display warnings if configuration is not supported by the NIC */
4594 rte_eth_dev_info_get(res->port_id, &dev_info);
4595 if ((ports[res->port_id].tso_segsz != 0) &&
4596 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4597 printf("Warning: TSO enabled but not "
4598 "supported by port %d\n", res->port_id);
4601 cmd_reconfig_device_queue(res->port_id, 1, 1);
4604 cmdline_parse_token_string_t cmd_tso_set_tso =
4605 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4607 cmdline_parse_token_string_t cmd_tso_set_mode =
4608 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4610 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4611 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4613 cmdline_parse_token_num_t cmd_tso_set_portid =
4614 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4617 cmdline_parse_inst_t cmd_tso_set = {
4618 .f = cmd_tso_set_parsed,
4620 .help_str = "tso set <tso_segsz> <port_id>: "
4621 "Set TSO segment size of non-tunneled packets for csum engine "
4624 (void *)&cmd_tso_set_tso,
4625 (void *)&cmd_tso_set_mode,
4626 (void *)&cmd_tso_set_tso_segsz,
4627 (void *)&cmd_tso_set_portid,
4632 cmdline_parse_token_string_t cmd_tso_show_mode =
4633 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4637 cmdline_parse_inst_t cmd_tso_show = {
4638 .f = cmd_tso_set_parsed,
4640 .help_str = "tso show <port_id>: "
4641 "Show TSO segment size of non-tunneled packets for csum engine",
4643 (void *)&cmd_tso_set_tso,
4644 (void *)&cmd_tso_show_mode,
4645 (void *)&cmd_tso_set_portid,
4650 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4651 struct cmd_tunnel_tso_set_result {
4652 cmdline_fixed_string_t tso;
4653 cmdline_fixed_string_t mode;
4658 static struct rte_eth_dev_info
4659 check_tunnel_tso_nic_support(portid_t port_id)
4661 struct rte_eth_dev_info dev_info;
4663 rte_eth_dev_info_get(port_id, &dev_info);
4664 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4665 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4666 "not enabled for port %d\n", port_id);
4667 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4668 printf("Warning: GRE TUNNEL TSO not supported therefore "
4669 "not enabled for port %d\n", port_id);
4670 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4671 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4672 "not enabled for port %d\n", port_id);
4673 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4674 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4675 "not enabled for port %d\n", port_id);
4676 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4677 printf("Warning: IP TUNNEL TSO not supported therefore "
4678 "not enabled for port %d\n", port_id);
4679 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4680 printf("Warning: UDP TUNNEL TSO not supported therefore "
4681 "not enabled for port %d\n", port_id);
4686 cmd_tunnel_tso_set_parsed(void *parsed_result,
4687 __attribute__((unused)) struct cmdline *cl,
4688 __attribute__((unused)) void *data)
4690 struct cmd_tunnel_tso_set_result *res = parsed_result;
4691 struct rte_eth_dev_info dev_info;
4693 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4695 if (!port_is_stopped(res->port_id)) {
4696 printf("Please stop port %d first\n", res->port_id);
4700 if (!strcmp(res->mode, "set"))
4701 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4703 dev_info = check_tunnel_tso_nic_support(res->port_id);
4704 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4705 ports[res->port_id].dev_conf.txmode.offloads &=
4706 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4707 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4708 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4709 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4710 DEV_TX_OFFLOAD_IP_TNL_TSO |
4711 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4712 printf("TSO for tunneled packets is disabled\n");
4714 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4715 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4716 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4717 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4718 DEV_TX_OFFLOAD_IP_TNL_TSO |
4719 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4721 ports[res->port_id].dev_conf.txmode.offloads |=
4722 (tso_offloads & dev_info.tx_offload_capa);
4723 printf("TSO segment size for tunneled packets is %d\n",
4724 ports[res->port_id].tunnel_tso_segsz);
4726 /* Below conditions are needed to make it work:
4727 * (1) tunnel TSO is supported by the NIC;
4728 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4730 * (3) for tunneled pkts with outer L3 of IPv4,
4731 * "csum set outer-ip" must be set to hw, because after tso,
4732 * total_len of outer IP header is changed, and the checksum
4733 * of outer IP header calculated by sw should be wrong; that
4734 * is not necessary for IPv6 tunneled pkts because there's no
4735 * checksum in IP header anymore.
4738 if (!ports[res->port_id].parse_tunnel)
4739 printf("Warning: csum parse_tunnel must be set "
4740 "so that tunneled packets are recognized\n");
4741 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4742 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4743 printf("Warning: csum set outer-ip must be set to hw "
4744 "if outer L3 is IPv4; not necessary for IPv6\n");
4747 cmd_reconfig_device_queue(res->port_id, 1, 1);
4750 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4751 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4753 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4754 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4756 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4757 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4759 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4760 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4763 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4764 .f = cmd_tunnel_tso_set_parsed,
4766 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4767 "Set TSO segment size of tunneled packets for csum engine "
4770 (void *)&cmd_tunnel_tso_set_tso,
4771 (void *)&cmd_tunnel_tso_set_mode,
4772 (void *)&cmd_tunnel_tso_set_tso_segsz,
4773 (void *)&cmd_tunnel_tso_set_portid,
4778 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4779 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4783 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4784 .f = cmd_tunnel_tso_set_parsed,
4786 .help_str = "tunnel_tso show <port_id> "
4787 "Show TSO segment size of tunneled packets for csum engine",
4789 (void *)&cmd_tunnel_tso_set_tso,
4790 (void *)&cmd_tunnel_tso_show_mode,
4791 (void *)&cmd_tunnel_tso_set_portid,
4796 /* *** SET GRO FOR A PORT *** */
4797 struct cmd_gro_enable_result {
4798 cmdline_fixed_string_t cmd_set;
4799 cmdline_fixed_string_t cmd_port;
4800 cmdline_fixed_string_t cmd_keyword;
4801 cmdline_fixed_string_t cmd_onoff;
4806 cmd_gro_enable_parsed(void *parsed_result,
4807 __attribute__((unused)) struct cmdline *cl,
4808 __attribute__((unused)) void *data)
4810 struct cmd_gro_enable_result *res;
4812 res = parsed_result;
4813 if (!strcmp(res->cmd_keyword, "gro"))
4814 setup_gro(res->cmd_onoff, res->cmd_pid);
4817 cmdline_parse_token_string_t cmd_gro_enable_set =
4818 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4820 cmdline_parse_token_string_t cmd_gro_enable_port =
4821 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4822 cmd_keyword, "port");
4823 cmdline_parse_token_num_t cmd_gro_enable_pid =
4824 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4826 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4827 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4828 cmd_keyword, "gro");
4829 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4830 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4831 cmd_onoff, "on#off");
4833 cmdline_parse_inst_t cmd_gro_enable = {
4834 .f = cmd_gro_enable_parsed,
4836 .help_str = "set port <port_id> gro on|off",
4838 (void *)&cmd_gro_enable_set,
4839 (void *)&cmd_gro_enable_port,
4840 (void *)&cmd_gro_enable_pid,
4841 (void *)&cmd_gro_enable_keyword,
4842 (void *)&cmd_gro_enable_onoff,
4847 /* *** DISPLAY GRO CONFIGURATION *** */
4848 struct cmd_gro_show_result {
4849 cmdline_fixed_string_t cmd_show;
4850 cmdline_fixed_string_t cmd_port;
4851 cmdline_fixed_string_t cmd_keyword;
4856 cmd_gro_show_parsed(void *parsed_result,
4857 __attribute__((unused)) struct cmdline *cl,
4858 __attribute__((unused)) void *data)
4860 struct cmd_gro_show_result *res;
4862 res = parsed_result;
4863 if (!strcmp(res->cmd_keyword, "gro"))
4864 show_gro(res->cmd_pid);
4867 cmdline_parse_token_string_t cmd_gro_show_show =
4868 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4870 cmdline_parse_token_string_t cmd_gro_show_port =
4871 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4873 cmdline_parse_token_num_t cmd_gro_show_pid =
4874 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4876 cmdline_parse_token_string_t cmd_gro_show_keyword =
4877 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4878 cmd_keyword, "gro");
4880 cmdline_parse_inst_t cmd_gro_show = {
4881 .f = cmd_gro_show_parsed,
4883 .help_str = "show port <port_id> gro",
4885 (void *)&cmd_gro_show_show,
4886 (void *)&cmd_gro_show_port,
4887 (void *)&cmd_gro_show_pid,
4888 (void *)&cmd_gro_show_keyword,
4893 /* *** SET FLUSH CYCLES FOR GRO *** */
4894 struct cmd_gro_flush_result {
4895 cmdline_fixed_string_t cmd_set;
4896 cmdline_fixed_string_t cmd_keyword;
4897 cmdline_fixed_string_t cmd_flush;
4902 cmd_gro_flush_parsed(void *parsed_result,
4903 __attribute__((unused)) struct cmdline *cl,
4904 __attribute__((unused)) void *data)
4906 struct cmd_gro_flush_result *res;
4908 res = parsed_result;
4909 if ((!strcmp(res->cmd_keyword, "gro")) &&
4910 (!strcmp(res->cmd_flush, "flush")))
4911 setup_gro_flush_cycles(res->cmd_cycles);
4914 cmdline_parse_token_string_t cmd_gro_flush_set =
4915 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4917 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4918 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4919 cmd_keyword, "gro");
4920 cmdline_parse_token_string_t cmd_gro_flush_flush =
4921 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4922 cmd_flush, "flush");
4923 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4924 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4927 cmdline_parse_inst_t cmd_gro_flush = {
4928 .f = cmd_gro_flush_parsed,
4930 .help_str = "set gro flush <cycles>",
4932 (void *)&cmd_gro_flush_set,
4933 (void *)&cmd_gro_flush_keyword,
4934 (void *)&cmd_gro_flush_flush,
4935 (void *)&cmd_gro_flush_cycles,
4940 /* *** ENABLE/DISABLE GSO *** */
4941 struct cmd_gso_enable_result {
4942 cmdline_fixed_string_t cmd_set;
4943 cmdline_fixed_string_t cmd_port;
4944 cmdline_fixed_string_t cmd_keyword;
4945 cmdline_fixed_string_t cmd_mode;
4950 cmd_gso_enable_parsed(void *parsed_result,
4951 __attribute__((unused)) struct cmdline *cl,
4952 __attribute__((unused)) void *data)
4954 struct cmd_gso_enable_result *res;
4956 res = parsed_result;
4957 if (!strcmp(res->cmd_keyword, "gso"))
4958 setup_gso(res->cmd_mode, res->cmd_pid);
4961 cmdline_parse_token_string_t cmd_gso_enable_set =
4962 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4964 cmdline_parse_token_string_t cmd_gso_enable_port =
4965 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4967 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4968 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4969 cmd_keyword, "gso");
4970 cmdline_parse_token_string_t cmd_gso_enable_mode =
4971 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4972 cmd_mode, "on#off");
4973 cmdline_parse_token_num_t cmd_gso_enable_pid =
4974 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4977 cmdline_parse_inst_t cmd_gso_enable = {
4978 .f = cmd_gso_enable_parsed,
4980 .help_str = "set port <port_id> gso on|off",
4982 (void *)&cmd_gso_enable_set,
4983 (void *)&cmd_gso_enable_port,
4984 (void *)&cmd_gso_enable_pid,
4985 (void *)&cmd_gso_enable_keyword,
4986 (void *)&cmd_gso_enable_mode,
4991 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4992 struct cmd_gso_size_result {
4993 cmdline_fixed_string_t cmd_set;
4994 cmdline_fixed_string_t cmd_keyword;
4995 cmdline_fixed_string_t cmd_segsz;
5000 cmd_gso_size_parsed(void *parsed_result,
5001 __attribute__((unused)) struct cmdline *cl,
5002 __attribute__((unused)) void *data)
5004 struct cmd_gso_size_result *res = parsed_result;
5006 if (test_done == 0) {
5007 printf("Before setting GSO segsz, please first"
5008 " stop fowarding\n");
5012 if (!strcmp(res->cmd_keyword, "gso") &&
5013 !strcmp(res->cmd_segsz, "segsz")) {
5014 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5015 printf("gso_size should be larger than %zu."
5016 " Please input a legal value\n",
5017 RTE_GSO_SEG_SIZE_MIN);
5019 gso_max_segment_size = res->cmd_size;
5023 cmdline_parse_token_string_t cmd_gso_size_set =
5024 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5026 cmdline_parse_token_string_t cmd_gso_size_keyword =
5027 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5028 cmd_keyword, "gso");
5029 cmdline_parse_token_string_t cmd_gso_size_segsz =
5030 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5031 cmd_segsz, "segsz");
5032 cmdline_parse_token_num_t cmd_gso_size_size =
5033 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5036 cmdline_parse_inst_t cmd_gso_size = {
5037 .f = cmd_gso_size_parsed,
5039 .help_str = "set gso segsz <length>",
5041 (void *)&cmd_gso_size_set,
5042 (void *)&cmd_gso_size_keyword,
5043 (void *)&cmd_gso_size_segsz,
5044 (void *)&cmd_gso_size_size,
5049 /* *** SHOW GSO CONFIGURATION *** */
5050 struct cmd_gso_show_result {
5051 cmdline_fixed_string_t cmd_show;
5052 cmdline_fixed_string_t cmd_port;
5053 cmdline_fixed_string_t cmd_keyword;
5058 cmd_gso_show_parsed(void *parsed_result,
5059 __attribute__((unused)) struct cmdline *cl,
5060 __attribute__((unused)) void *data)
5062 struct cmd_gso_show_result *res = parsed_result;
5064 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5065 printf("invalid port id %u\n", res->cmd_pid);
5068 if (!strcmp(res->cmd_keyword, "gso")) {
5069 if (gso_ports[res->cmd_pid].enable) {
5070 printf("Max GSO'd packet size: %uB\n"
5071 "Supported GSO types: TCP/IPv4, "
5072 "UDP/IPv4, VxLAN with inner "
5073 "TCP/IPv4 packet, GRE with inner "
5074 "TCP/IPv4 packet\n",
5075 gso_max_segment_size);
5077 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5081 cmdline_parse_token_string_t cmd_gso_show_show =
5082 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5084 cmdline_parse_token_string_t cmd_gso_show_port =
5085 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5087 cmdline_parse_token_string_t cmd_gso_show_keyword =
5088 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5089 cmd_keyword, "gso");
5090 cmdline_parse_token_num_t cmd_gso_show_pid =
5091 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5094 cmdline_parse_inst_t cmd_gso_show = {
5095 .f = cmd_gso_show_parsed,
5097 .help_str = "show port <port_id> gso",
5099 (void *)&cmd_gso_show_show,
5100 (void *)&cmd_gso_show_port,
5101 (void *)&cmd_gso_show_pid,
5102 (void *)&cmd_gso_show_keyword,
5107 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5108 struct cmd_set_flush_rx {
5109 cmdline_fixed_string_t set;
5110 cmdline_fixed_string_t flush_rx;
5111 cmdline_fixed_string_t mode;
5115 cmd_set_flush_rx_parsed(void *parsed_result,
5116 __attribute__((unused)) struct cmdline *cl,
5117 __attribute__((unused)) void *data)
5119 struct cmd_set_flush_rx *res = parsed_result;
5120 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5123 cmdline_parse_token_string_t cmd_setflushrx_set =
5124 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5126 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5127 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5128 flush_rx, "flush_rx");
5129 cmdline_parse_token_string_t cmd_setflushrx_mode =
5130 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5134 cmdline_parse_inst_t cmd_set_flush_rx = {
5135 .f = cmd_set_flush_rx_parsed,
5136 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5139 (void *)&cmd_setflushrx_set,
5140 (void *)&cmd_setflushrx_flush_rx,
5141 (void *)&cmd_setflushrx_mode,
5146 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5147 struct cmd_set_link_check {
5148 cmdline_fixed_string_t set;
5149 cmdline_fixed_string_t link_check;
5150 cmdline_fixed_string_t mode;
5154 cmd_set_link_check_parsed(void *parsed_result,
5155 __attribute__((unused)) struct cmdline *cl,
5156 __attribute__((unused)) void *data)
5158 struct cmd_set_link_check *res = parsed_result;
5159 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5162 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5163 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5165 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5166 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5167 link_check, "link_check");
5168 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5169 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5173 cmdline_parse_inst_t cmd_set_link_check = {
5174 .f = cmd_set_link_check_parsed,
5175 .help_str = "set link_check on|off: Enable/Disable link status check "
5176 "when starting/stopping a port",
5179 (void *)&cmd_setlinkcheck_set,
5180 (void *)&cmd_setlinkcheck_link_check,
5181 (void *)&cmd_setlinkcheck_mode,
5186 /* *** SET NIC BYPASS MODE *** */
5187 struct cmd_set_bypass_mode_result {
5188 cmdline_fixed_string_t set;
5189 cmdline_fixed_string_t bypass;
5190 cmdline_fixed_string_t mode;
5191 cmdline_fixed_string_t value;
5196 cmd_set_bypass_mode_parsed(void *parsed_result,
5197 __attribute__((unused)) struct cmdline *cl,
5198 __attribute__((unused)) void *data)
5200 struct cmd_set_bypass_mode_result *res = parsed_result;
5201 portid_t port_id = res->port_id;
5202 int32_t rc = -EINVAL;
5204 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5205 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5207 if (!strcmp(res->value, "bypass"))
5208 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5209 else if (!strcmp(res->value, "isolate"))
5210 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5212 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5214 /* Set the bypass mode for the relevant port. */
5215 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5218 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5221 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5222 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5224 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5225 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5227 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5228 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5230 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5231 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5232 value, "normal#bypass#isolate");
5233 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5234 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5237 cmdline_parse_inst_t cmd_set_bypass_mode = {
5238 .f = cmd_set_bypass_mode_parsed,
5239 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5240 "Set the NIC bypass mode for port_id",
5243 (void *)&cmd_setbypass_mode_set,
5244 (void *)&cmd_setbypass_mode_bypass,
5245 (void *)&cmd_setbypass_mode_mode,
5246 (void *)&cmd_setbypass_mode_value,
5247 (void *)&cmd_setbypass_mode_port,
5252 /* *** SET NIC BYPASS EVENT *** */
5253 struct cmd_set_bypass_event_result {
5254 cmdline_fixed_string_t set;
5255 cmdline_fixed_string_t bypass;
5256 cmdline_fixed_string_t event;
5257 cmdline_fixed_string_t event_value;
5258 cmdline_fixed_string_t mode;
5259 cmdline_fixed_string_t mode_value;
5264 cmd_set_bypass_event_parsed(void *parsed_result,
5265 __attribute__((unused)) struct cmdline *cl,
5266 __attribute__((unused)) void *data)
5268 int32_t rc = -EINVAL;
5269 struct cmd_set_bypass_event_result *res = parsed_result;
5270 portid_t port_id = res->port_id;
5272 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5273 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5274 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5276 if (!strcmp(res->event_value, "timeout"))
5277 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5278 else if (!strcmp(res->event_value, "os_on"))
5279 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5280 else if (!strcmp(res->event_value, "os_off"))
5281 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5282 else if (!strcmp(res->event_value, "power_on"))
5283 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5284 else if (!strcmp(res->event_value, "power_off"))
5285 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5287 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5289 if (!strcmp(res->mode_value, "bypass"))
5290 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5291 else if (!strcmp(res->mode_value, "isolate"))
5292 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5294 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5296 /* Set the watchdog timeout. */
5297 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5300 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5301 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5305 printf("Failed to set timeout value %u "
5306 "for port %d, errto code: %d.\n",
5307 bypass_timeout, port_id, rc);
5311 /* Set the bypass event to transition to bypass mode. */
5312 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5317 printf("\t Failed to set bypass event for port = %d.\n",
5321 cmdline_parse_token_string_t cmd_setbypass_event_set =
5322 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5324 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5325 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5327 cmdline_parse_token_string_t cmd_setbypass_event_event =
5328 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5330 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5331 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5332 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5333 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5334 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5336 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5337 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5338 mode_value, "normal#bypass#isolate");
5339 cmdline_parse_token_num_t cmd_setbypass_event_port =
5340 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5343 cmdline_parse_inst_t cmd_set_bypass_event = {
5344 .f = cmd_set_bypass_event_parsed,
5345 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5346 "power_off mode normal|bypass|isolate <port_id>: "
5347 "Set the NIC bypass event mode for port_id",
5350 (void *)&cmd_setbypass_event_set,
5351 (void *)&cmd_setbypass_event_bypass,
5352 (void *)&cmd_setbypass_event_event,
5353 (void *)&cmd_setbypass_event_event_value,
5354 (void *)&cmd_setbypass_event_mode,
5355 (void *)&cmd_setbypass_event_mode_value,
5356 (void *)&cmd_setbypass_event_port,
5362 /* *** SET NIC BYPASS TIMEOUT *** */
5363 struct cmd_set_bypass_timeout_result {
5364 cmdline_fixed_string_t set;
5365 cmdline_fixed_string_t bypass;
5366 cmdline_fixed_string_t timeout;
5367 cmdline_fixed_string_t value;
5371 cmd_set_bypass_timeout_parsed(void *parsed_result,
5372 __attribute__((unused)) struct cmdline *cl,
5373 __attribute__((unused)) void *data)
5375 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5377 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5378 if (!strcmp(res->value, "1.5"))
5379 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5380 else if (!strcmp(res->value, "2"))
5381 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5382 else if (!strcmp(res->value, "3"))
5383 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5384 else if (!strcmp(res->value, "4"))
5385 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5386 else if (!strcmp(res->value, "8"))
5387 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5388 else if (!strcmp(res->value, "16"))
5389 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5390 else if (!strcmp(res->value, "32"))
5391 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5393 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5397 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5398 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5400 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5401 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5403 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5404 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5405 timeout, "timeout");
5406 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5407 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5408 value, "0#1.5#2#3#4#8#16#32");
5410 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5411 .f = cmd_set_bypass_timeout_parsed,
5412 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5413 "Set the NIC bypass watchdog timeout in seconds",
5416 (void *)&cmd_setbypass_timeout_set,
5417 (void *)&cmd_setbypass_timeout_bypass,
5418 (void *)&cmd_setbypass_timeout_timeout,
5419 (void *)&cmd_setbypass_timeout_value,
5424 /* *** SHOW NIC BYPASS MODE *** */
5425 struct cmd_show_bypass_config_result {
5426 cmdline_fixed_string_t show;
5427 cmdline_fixed_string_t bypass;
5428 cmdline_fixed_string_t config;
5433 cmd_show_bypass_config_parsed(void *parsed_result,
5434 __attribute__((unused)) struct cmdline *cl,
5435 __attribute__((unused)) void *data)
5437 struct cmd_show_bypass_config_result *res = parsed_result;
5438 portid_t port_id = res->port_id;
5440 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5441 uint32_t event_mode;
5442 uint32_t bypass_mode;
5443 uint32_t timeout = bypass_timeout;
5446 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5447 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5448 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5449 {"UNKNOWN", "normal", "bypass", "isolate"};
5450 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5457 int num_events = (sizeof events) / (sizeof events[0]);
5459 /* Display the bypass mode.*/
5460 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5461 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5465 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5466 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5468 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5471 /* Display the bypass timeout.*/
5472 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5473 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5475 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5477 /* Display the bypass events and associated modes. */
5478 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5480 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5481 printf("\tFailed to get bypass mode for event = %s\n",
5484 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5485 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5487 printf("\tbypass event: %-16s = %s\n", events[i],
5493 printf("\tFailed to get bypass configuration for port = %d\n",
5497 cmdline_parse_token_string_t cmd_showbypass_config_show =
5498 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5500 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5501 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5503 cmdline_parse_token_string_t cmd_showbypass_config_config =
5504 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5506 cmdline_parse_token_num_t cmd_showbypass_config_port =
5507 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5510 cmdline_parse_inst_t cmd_show_bypass_config = {
5511 .f = cmd_show_bypass_config_parsed,
5512 .help_str = "show bypass config <port_id>: "
5513 "Show the NIC bypass config for port_id",
5516 (void *)&cmd_showbypass_config_show,
5517 (void *)&cmd_showbypass_config_bypass,
5518 (void *)&cmd_showbypass_config_config,
5519 (void *)&cmd_showbypass_config_port,
5524 #ifdef RTE_LIBRTE_PMD_BOND
5525 /* *** SET BONDING MODE *** */
5526 struct cmd_set_bonding_mode_result {
5527 cmdline_fixed_string_t set;
5528 cmdline_fixed_string_t bonding;
5529 cmdline_fixed_string_t mode;
5534 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5535 __attribute__((unused)) struct cmdline *cl,
5536 __attribute__((unused)) void *data)
5538 struct cmd_set_bonding_mode_result *res = parsed_result;
5539 portid_t port_id = res->port_id;
5541 /* Set the bonding mode for the relevant port. */
5542 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5543 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5546 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5547 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5549 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5550 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5551 bonding, "bonding");
5552 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5553 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5555 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5556 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5558 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5559 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5562 cmdline_parse_inst_t cmd_set_bonding_mode = {
5563 .f = cmd_set_bonding_mode_parsed,
5564 .help_str = "set bonding mode <mode_value> <port_id>: "
5565 "Set the bonding mode for port_id",
5568 (void *) &cmd_setbonding_mode_set,
5569 (void *) &cmd_setbonding_mode_bonding,
5570 (void *) &cmd_setbonding_mode_mode,
5571 (void *) &cmd_setbonding_mode_value,
5572 (void *) &cmd_setbonding_mode_port,
5577 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5578 struct cmd_set_bonding_lacp_dedicated_queues_result {
5579 cmdline_fixed_string_t set;
5580 cmdline_fixed_string_t bonding;
5581 cmdline_fixed_string_t lacp;
5582 cmdline_fixed_string_t dedicated_queues;
5584 cmdline_fixed_string_t mode;
5587 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5588 __attribute__((unused)) struct cmdline *cl,
5589 __attribute__((unused)) void *data)
5591 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5592 portid_t port_id = res->port_id;
5593 struct rte_port *port;
5595 port = &ports[port_id];
5597 /** Check if the port is not started **/
5598 if (port->port_status != RTE_PORT_STOPPED) {
5599 printf("Please stop port %d first\n", port_id);
5603 if (!strcmp(res->mode, "enable")) {
5604 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5605 printf("Dedicate queues for LACP control packets"
5608 printf("Enabling dedicate queues for LACP control "
5609 "packets on port %d failed\n", port_id);
5610 } else if (!strcmp(res->mode, "disable")) {
5611 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5612 printf("Dedicated queues for LACP control packets "
5615 printf("Disabling dedicated queues for LACP control "
5616 "traffic on port %d failed\n", port_id);
5620 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5621 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5623 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5624 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5625 bonding, "bonding");
5626 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5627 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5629 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5630 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5631 dedicated_queues, "dedicated_queues");
5632 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5633 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5635 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5636 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5637 mode, "enable#disable");
5639 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5640 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5641 .help_str = "set bonding lacp dedicated_queues <port_id> "
5643 "Enable/disable dedicated queues for LACP control traffic for port_id",
5646 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5647 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5648 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5649 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5650 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5651 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5656 /* *** SET BALANCE XMIT POLICY *** */
5657 struct cmd_set_bonding_balance_xmit_policy_result {
5658 cmdline_fixed_string_t set;
5659 cmdline_fixed_string_t bonding;
5660 cmdline_fixed_string_t balance_xmit_policy;
5662 cmdline_fixed_string_t policy;
5665 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5666 __attribute__((unused)) struct cmdline *cl,
5667 __attribute__((unused)) void *data)
5669 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5670 portid_t port_id = res->port_id;
5673 if (!strcmp(res->policy, "l2")) {
5674 policy = BALANCE_XMIT_POLICY_LAYER2;
5675 } else if (!strcmp(res->policy, "l23")) {
5676 policy = BALANCE_XMIT_POLICY_LAYER23;
5677 } else if (!strcmp(res->policy, "l34")) {
5678 policy = BALANCE_XMIT_POLICY_LAYER34;
5680 printf("\t Invalid xmit policy selection");
5684 /* Set the bonding mode for the relevant port. */
5685 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5686 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5691 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5692 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5694 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5695 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5696 bonding, "bonding");
5697 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5698 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5699 balance_xmit_policy, "balance_xmit_policy");
5700 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5701 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5703 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5704 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5705 policy, "l2#l23#l34");
5707 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5708 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5709 .help_str = "set bonding balance_xmit_policy <port_id> "
5711 "Set the bonding balance_xmit_policy for port_id",
5714 (void *)&cmd_setbonding_balance_xmit_policy_set,
5715 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5716 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5717 (void *)&cmd_setbonding_balance_xmit_policy_port,
5718 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5723 /* *** SHOW NIC BONDING CONFIGURATION *** */
5724 struct cmd_show_bonding_config_result {
5725 cmdline_fixed_string_t show;
5726 cmdline_fixed_string_t bonding;
5727 cmdline_fixed_string_t config;
5731 static void cmd_show_bonding_config_parsed(void *parsed_result,
5732 __attribute__((unused)) struct cmdline *cl,
5733 __attribute__((unused)) void *data)
5735 struct cmd_show_bonding_config_result *res = parsed_result;
5736 int bonding_mode, agg_mode;
5737 portid_t slaves[RTE_MAX_ETHPORTS];
5738 int num_slaves, num_active_slaves;
5741 portid_t port_id = res->port_id;
5743 /* Display the bonding mode.*/
5744 bonding_mode = rte_eth_bond_mode_get(port_id);
5745 if (bonding_mode < 0) {
5746 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5749 printf("\tBonding mode: %d\n", bonding_mode);
5751 if (bonding_mode == BONDING_MODE_BALANCE) {
5752 int balance_xmit_policy;
5754 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5755 if (balance_xmit_policy < 0) {
5756 printf("\tFailed to get balance xmit policy for port = %d\n",
5760 printf("\tBalance Xmit Policy: ");
5762 switch (balance_xmit_policy) {
5763 case BALANCE_XMIT_POLICY_LAYER2:
5764 printf("BALANCE_XMIT_POLICY_LAYER2");
5766 case BALANCE_XMIT_POLICY_LAYER23:
5767 printf("BALANCE_XMIT_POLICY_LAYER23");
5769 case BALANCE_XMIT_POLICY_LAYER34:
5770 printf("BALANCE_XMIT_POLICY_LAYER34");
5777 if (bonding_mode == BONDING_MODE_8023AD) {
5778 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5779 printf("\tIEEE802.3AD Aggregator Mode: ");
5782 printf("bandwidth");
5794 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5796 if (num_slaves < 0) {
5797 printf("\tFailed to get slave list for port = %d\n", port_id);
5800 if (num_slaves > 0) {
5801 printf("\tSlaves (%d): [", num_slaves);
5802 for (i = 0; i < num_slaves - 1; i++)
5803 printf("%d ", slaves[i]);
5805 printf("%d]\n", slaves[num_slaves - 1]);
5807 printf("\tSlaves: []\n");
5811 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5814 if (num_active_slaves < 0) {
5815 printf("\tFailed to get active slave list for port = %d\n", port_id);
5818 if (num_active_slaves > 0) {
5819 printf("\tActive Slaves (%d): [", num_active_slaves);
5820 for (i = 0; i < num_active_slaves - 1; i++)
5821 printf("%d ", slaves[i]);
5823 printf("%d]\n", slaves[num_active_slaves - 1]);
5826 printf("\tActive Slaves: []\n");
5830 primary_id = rte_eth_bond_primary_get(port_id);
5831 if (primary_id < 0) {
5832 printf("\tFailed to get primary slave for port = %d\n", port_id);
5835 printf("\tPrimary: [%d]\n", primary_id);
5839 cmdline_parse_token_string_t cmd_showbonding_config_show =
5840 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5842 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5843 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5844 bonding, "bonding");
5845 cmdline_parse_token_string_t cmd_showbonding_config_config =
5846 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5848 cmdline_parse_token_num_t cmd_showbonding_config_port =
5849 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5852 cmdline_parse_inst_t cmd_show_bonding_config = {
5853 .f = cmd_show_bonding_config_parsed,
5854 .help_str = "show bonding config <port_id>: "
5855 "Show the bonding config for port_id",
5858 (void *)&cmd_showbonding_config_show,
5859 (void *)&cmd_showbonding_config_bonding,
5860 (void *)&cmd_showbonding_config_config,
5861 (void *)&cmd_showbonding_config_port,
5866 /* *** SET BONDING PRIMARY *** */
5867 struct cmd_set_bonding_primary_result {
5868 cmdline_fixed_string_t set;
5869 cmdline_fixed_string_t bonding;
5870 cmdline_fixed_string_t primary;
5875 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5876 __attribute__((unused)) struct cmdline *cl,
5877 __attribute__((unused)) void *data)
5879 struct cmd_set_bonding_primary_result *res = parsed_result;
5880 portid_t master_port_id = res->port_id;
5881 portid_t slave_port_id = res->slave_id;
5883 /* Set the primary slave for a bonded device. */
5884 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5885 printf("\t Failed to set primary slave for port = %d.\n",
5892 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5893 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5895 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5896 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5897 bonding, "bonding");
5898 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5899 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5900 primary, "primary");
5901 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5902 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5904 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5905 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5908 cmdline_parse_inst_t cmd_set_bonding_primary = {
5909 .f = cmd_set_bonding_primary_parsed,
5910 .help_str = "set bonding primary <slave_id> <port_id>: "
5911 "Set the primary slave for port_id",
5914 (void *)&cmd_setbonding_primary_set,
5915 (void *)&cmd_setbonding_primary_bonding,
5916 (void *)&cmd_setbonding_primary_primary,
5917 (void *)&cmd_setbonding_primary_slave,
5918 (void *)&cmd_setbonding_primary_port,
5923 /* *** ADD SLAVE *** */
5924 struct cmd_add_bonding_slave_result {
5925 cmdline_fixed_string_t add;
5926 cmdline_fixed_string_t bonding;
5927 cmdline_fixed_string_t slave;
5932 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5933 __attribute__((unused)) struct cmdline *cl,
5934 __attribute__((unused)) void *data)
5936 struct cmd_add_bonding_slave_result *res = parsed_result;
5937 portid_t master_port_id = res->port_id;
5938 portid_t slave_port_id = res->slave_id;
5940 /* add the slave for a bonded device. */
5941 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5942 printf("\t Failed to add slave %d to master port = %d.\n",
5943 slave_port_id, master_port_id);
5947 set_port_slave_flag(slave_port_id);
5950 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5951 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5953 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5954 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5955 bonding, "bonding");
5956 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5957 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5959 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5960 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5962 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5963 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5966 cmdline_parse_inst_t cmd_add_bonding_slave = {
5967 .f = cmd_add_bonding_slave_parsed,
5968 .help_str = "add bonding slave <slave_id> <port_id>: "
5969 "Add a slave device to a bonded device",
5972 (void *)&cmd_addbonding_slave_add,
5973 (void *)&cmd_addbonding_slave_bonding,
5974 (void *)&cmd_addbonding_slave_slave,
5975 (void *)&cmd_addbonding_slave_slaveid,
5976 (void *)&cmd_addbonding_slave_port,
5981 /* *** REMOVE SLAVE *** */
5982 struct cmd_remove_bonding_slave_result {
5983 cmdline_fixed_string_t remove;
5984 cmdline_fixed_string_t bonding;
5985 cmdline_fixed_string_t slave;
5990 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5991 __attribute__((unused)) struct cmdline *cl,
5992 __attribute__((unused)) void *data)
5994 struct cmd_remove_bonding_slave_result *res = parsed_result;
5995 portid_t master_port_id = res->port_id;
5996 portid_t slave_port_id = res->slave_id;
5998 /* remove the slave from a bonded device. */
5999 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6000 printf("\t Failed to remove slave %d from master port = %d.\n",
6001 slave_port_id, master_port_id);
6005 clear_port_slave_flag(slave_port_id);
6008 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6009 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6011 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6012 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6013 bonding, "bonding");
6014 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6015 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6017 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6018 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6020 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6021 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6024 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6025 .f = cmd_remove_bonding_slave_parsed,
6026 .help_str = "remove bonding slave <slave_id> <port_id>: "
6027 "Remove a slave device from a bonded device",
6030 (void *)&cmd_removebonding_slave_remove,
6031 (void *)&cmd_removebonding_slave_bonding,
6032 (void *)&cmd_removebonding_slave_slave,
6033 (void *)&cmd_removebonding_slave_slaveid,
6034 (void *)&cmd_removebonding_slave_port,
6039 /* *** CREATE BONDED DEVICE *** */
6040 struct cmd_create_bonded_device_result {
6041 cmdline_fixed_string_t create;
6042 cmdline_fixed_string_t bonded;
6043 cmdline_fixed_string_t device;
6048 static int bond_dev_num = 0;
6050 static void cmd_create_bonded_device_parsed(void *parsed_result,
6051 __attribute__((unused)) struct cmdline *cl,
6052 __attribute__((unused)) void *data)
6054 struct cmd_create_bonded_device_result *res = parsed_result;
6055 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6058 if (test_done == 0) {
6059 printf("Please stop forwarding first\n");
6063 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6066 /* Create a new bonded device. */
6067 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6069 printf("\t Failed to create bonded device.\n");
6072 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6075 /* Update number of ports */
6076 nb_ports = rte_eth_dev_count_avail();
6077 reconfig(port_id, res->socket);
6078 rte_eth_promiscuous_enable(port_id);
6079 ports[port_id].need_setup = 0;
6080 ports[port_id].port_status = RTE_PORT_STOPPED;
6085 cmdline_parse_token_string_t cmd_createbonded_device_create =
6086 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6088 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6089 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6091 cmdline_parse_token_string_t cmd_createbonded_device_device =
6092 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6094 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6095 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6097 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6098 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6101 cmdline_parse_inst_t cmd_create_bonded_device = {
6102 .f = cmd_create_bonded_device_parsed,
6103 .help_str = "create bonded device <mode> <socket>: "
6104 "Create a new bonded device with specific bonding mode and socket",
6107 (void *)&cmd_createbonded_device_create,
6108 (void *)&cmd_createbonded_device_bonded,
6109 (void *)&cmd_createbonded_device_device,
6110 (void *)&cmd_createbonded_device_mode,
6111 (void *)&cmd_createbonded_device_socket,
6116 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6117 struct cmd_set_bond_mac_addr_result {
6118 cmdline_fixed_string_t set;
6119 cmdline_fixed_string_t bonding;
6120 cmdline_fixed_string_t mac_addr;
6122 struct ether_addr address;
6125 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6126 __attribute__((unused)) struct cmdline *cl,
6127 __attribute__((unused)) void *data)
6129 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6132 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6135 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6137 /* check the return value and print it if is < 0 */
6139 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6142 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6143 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6144 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6145 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6147 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6148 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6150 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6151 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6153 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6154 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6156 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6157 .f = cmd_set_bond_mac_addr_parsed,
6159 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6161 (void *)&cmd_set_bond_mac_addr_set,
6162 (void *)&cmd_set_bond_mac_addr_bonding,
6163 (void *)&cmd_set_bond_mac_addr_mac,
6164 (void *)&cmd_set_bond_mac_addr_portnum,
6165 (void *)&cmd_set_bond_mac_addr_addr,
6171 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6172 struct cmd_set_bond_mon_period_result {
6173 cmdline_fixed_string_t set;
6174 cmdline_fixed_string_t bonding;
6175 cmdline_fixed_string_t mon_period;
6180 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6181 __attribute__((unused)) struct cmdline *cl,
6182 __attribute__((unused)) void *data)
6184 struct cmd_set_bond_mon_period_result *res = parsed_result;
6187 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6189 /* check the return value and print it if is < 0 */
6191 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6194 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6195 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6197 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6198 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6199 bonding, "bonding");
6200 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6201 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6202 mon_period, "mon_period");
6203 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6204 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6206 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6207 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6210 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6211 .f = cmd_set_bond_mon_period_parsed,
6213 .help_str = "set bonding mon_period <port_id> <period_ms>",
6215 (void *)&cmd_set_bond_mon_period_set,
6216 (void *)&cmd_set_bond_mon_period_bonding,
6217 (void *)&cmd_set_bond_mon_period_mon_period,
6218 (void *)&cmd_set_bond_mon_period_portnum,
6219 (void *)&cmd_set_bond_mon_period_period_ms,
6226 struct cmd_set_bonding_agg_mode_policy_result {
6227 cmdline_fixed_string_t set;
6228 cmdline_fixed_string_t bonding;
6229 cmdline_fixed_string_t agg_mode;
6231 cmdline_fixed_string_t policy;
6236 cmd_set_bonding_agg_mode(void *parsed_result,
6237 __attribute__((unused)) struct cmdline *cl,
6238 __attribute__((unused)) void *data)
6240 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6241 uint8_t policy = AGG_BANDWIDTH;
6243 if (!strcmp(res->policy, "bandwidth"))
6244 policy = AGG_BANDWIDTH;
6245 else if (!strcmp(res->policy, "stable"))
6246 policy = AGG_STABLE;
6247 else if (!strcmp(res->policy, "count"))
6250 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6254 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6255 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6257 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6258 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6259 bonding, "bonding");
6261 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6262 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6263 agg_mode, "agg_mode");
6265 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6266 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6269 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6270 TOKEN_STRING_INITIALIZER(
6271 struct cmd_set_bonding_balance_xmit_policy_result,
6272 policy, "stable#bandwidth#count");
6274 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6275 .f = cmd_set_bonding_agg_mode,
6277 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6279 (void *)&cmd_set_bonding_agg_mode_set,
6280 (void *)&cmd_set_bonding_agg_mode_bonding,
6281 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6282 (void *)&cmd_set_bonding_agg_mode_portnum,
6283 (void *)&cmd_set_bonding_agg_mode_policy_string,
6289 #endif /* RTE_LIBRTE_PMD_BOND */
6291 /* *** SET FORWARDING MODE *** */
6292 struct cmd_set_fwd_mode_result {
6293 cmdline_fixed_string_t set;
6294 cmdline_fixed_string_t fwd;
6295 cmdline_fixed_string_t mode;
6298 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6299 __attribute__((unused)) struct cmdline *cl,
6300 __attribute__((unused)) void *data)
6302 struct cmd_set_fwd_mode_result *res = parsed_result;
6305 set_pkt_forwarding_mode(res->mode);
6308 cmdline_parse_token_string_t cmd_setfwd_set =
6309 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6310 cmdline_parse_token_string_t cmd_setfwd_fwd =
6311 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6312 cmdline_parse_token_string_t cmd_setfwd_mode =
6313 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6314 "" /* defined at init */);
6316 cmdline_parse_inst_t cmd_set_fwd_mode = {
6317 .f = cmd_set_fwd_mode_parsed,
6319 .help_str = NULL, /* defined at init */
6321 (void *)&cmd_setfwd_set,
6322 (void *)&cmd_setfwd_fwd,
6323 (void *)&cmd_setfwd_mode,
6328 static void cmd_set_fwd_mode_init(void)
6331 static char token[128];
6332 static char help[256];
6333 cmdline_parse_token_string_t *token_struct;
6335 modes = list_pkt_forwarding_modes();
6336 snprintf(help, sizeof(help), "set fwd %s: "
6337 "Set packet forwarding mode", modes);
6338 cmd_set_fwd_mode.help_str = help;
6340 /* string token separator is # */
6341 for (c = token; *modes != '\0'; modes++)
6346 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6347 token_struct->string_data.str = token;
6350 /* *** SET RETRY FORWARDING MODE *** */
6351 struct cmd_set_fwd_retry_mode_result {
6352 cmdline_fixed_string_t set;
6353 cmdline_fixed_string_t fwd;
6354 cmdline_fixed_string_t mode;
6355 cmdline_fixed_string_t retry;
6358 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6359 __attribute__((unused)) struct cmdline *cl,
6360 __attribute__((unused)) void *data)
6362 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6365 set_pkt_forwarding_mode(res->mode);
6368 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6369 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6371 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6372 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6374 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6375 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6377 "" /* defined at init */);
6378 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6379 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6382 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6383 .f = cmd_set_fwd_retry_mode_parsed,
6385 .help_str = NULL, /* defined at init */
6387 (void *)&cmd_setfwd_retry_set,
6388 (void *)&cmd_setfwd_retry_fwd,
6389 (void *)&cmd_setfwd_retry_mode,
6390 (void *)&cmd_setfwd_retry_retry,
6395 static void cmd_set_fwd_retry_mode_init(void)
6398 static char token[128];
6399 static char help[256];
6400 cmdline_parse_token_string_t *token_struct;
6402 modes = list_pkt_forwarding_retry_modes();
6403 snprintf(help, sizeof(help), "set fwd %s retry: "
6404 "Set packet forwarding mode with retry", modes);
6405 cmd_set_fwd_retry_mode.help_str = help;
6407 /* string token separator is # */
6408 for (c = token; *modes != '\0'; modes++)
6413 token_struct = (cmdline_parse_token_string_t *)
6414 cmd_set_fwd_retry_mode.tokens[2];
6415 token_struct->string_data.str = token;
6418 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6419 struct cmd_set_burst_tx_retry_result {
6420 cmdline_fixed_string_t set;
6421 cmdline_fixed_string_t burst;
6422 cmdline_fixed_string_t tx;
6423 cmdline_fixed_string_t delay;
6425 cmdline_fixed_string_t retry;
6429 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6430 __attribute__((unused)) struct cmdline *cl,
6431 __attribute__((unused)) void *data)
6433 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6435 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6436 && !strcmp(res->tx, "tx")) {
6437 if (!strcmp(res->delay, "delay"))
6438 burst_tx_delay_time = res->time;
6439 if (!strcmp(res->retry, "retry"))
6440 burst_tx_retry_num = res->retry_num;
6445 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6446 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6447 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6448 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6450 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6451 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6452 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6453 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6454 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6455 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6456 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6457 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6458 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6459 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6461 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6462 .f = cmd_set_burst_tx_retry_parsed,
6463 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6465 (void *)&cmd_set_burst_tx_retry_set,
6466 (void *)&cmd_set_burst_tx_retry_burst,
6467 (void *)&cmd_set_burst_tx_retry_tx,
6468 (void *)&cmd_set_burst_tx_retry_delay,
6469 (void *)&cmd_set_burst_tx_retry_time,
6470 (void *)&cmd_set_burst_tx_retry_retry,
6471 (void *)&cmd_set_burst_tx_retry_retry_num,
6476 /* *** SET PROMISC MODE *** */
6477 struct cmd_set_promisc_mode_result {
6478 cmdline_fixed_string_t set;
6479 cmdline_fixed_string_t promisc;
6480 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6481 uint16_t port_num; /* valid if "allports" argument == 0 */
6482 cmdline_fixed_string_t mode;
6485 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6486 __attribute__((unused)) struct cmdline *cl,
6489 struct cmd_set_promisc_mode_result *res = parsed_result;
6493 if (!strcmp(res->mode, "on"))
6500 RTE_ETH_FOREACH_DEV(i) {
6502 rte_eth_promiscuous_enable(i);
6504 rte_eth_promiscuous_disable(i);
6509 rte_eth_promiscuous_enable(res->port_num);
6511 rte_eth_promiscuous_disable(res->port_num);
6515 cmdline_parse_token_string_t cmd_setpromisc_set =
6516 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6517 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6518 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6520 cmdline_parse_token_string_t cmd_setpromisc_portall =
6521 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6523 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6524 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6526 cmdline_parse_token_string_t cmd_setpromisc_mode =
6527 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6530 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6531 .f = cmd_set_promisc_mode_parsed,
6533 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6535 (void *)&cmd_setpromisc_set,
6536 (void *)&cmd_setpromisc_promisc,
6537 (void *)&cmd_setpromisc_portall,
6538 (void *)&cmd_setpromisc_mode,
6543 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6544 .f = cmd_set_promisc_mode_parsed,
6546 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6548 (void *)&cmd_setpromisc_set,
6549 (void *)&cmd_setpromisc_promisc,
6550 (void *)&cmd_setpromisc_portnum,
6551 (void *)&cmd_setpromisc_mode,
6556 /* *** SET ALLMULTI MODE *** */
6557 struct cmd_set_allmulti_mode_result {
6558 cmdline_fixed_string_t set;
6559 cmdline_fixed_string_t allmulti;
6560 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6561 uint16_t port_num; /* valid if "allports" argument == 0 */
6562 cmdline_fixed_string_t mode;
6565 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6566 __attribute__((unused)) struct cmdline *cl,
6569 struct cmd_set_allmulti_mode_result *res = parsed_result;
6573 if (!strcmp(res->mode, "on"))
6580 RTE_ETH_FOREACH_DEV(i) {
6582 rte_eth_allmulticast_enable(i);
6584 rte_eth_allmulticast_disable(i);
6589 rte_eth_allmulticast_enable(res->port_num);
6591 rte_eth_allmulticast_disable(res->port_num);
6595 cmdline_parse_token_string_t cmd_setallmulti_set =
6596 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6597 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6598 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6600 cmdline_parse_token_string_t cmd_setallmulti_portall =
6601 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6603 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6604 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6606 cmdline_parse_token_string_t cmd_setallmulti_mode =
6607 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6610 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6611 .f = cmd_set_allmulti_mode_parsed,
6613 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6615 (void *)&cmd_setallmulti_set,
6616 (void *)&cmd_setallmulti_allmulti,
6617 (void *)&cmd_setallmulti_portall,
6618 (void *)&cmd_setallmulti_mode,
6623 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6624 .f = cmd_set_allmulti_mode_parsed,
6626 .help_str = "set allmulti <port_id> on|off: "
6627 "Set allmulti mode on port_id",
6629 (void *)&cmd_setallmulti_set,
6630 (void *)&cmd_setallmulti_allmulti,
6631 (void *)&cmd_setallmulti_portnum,
6632 (void *)&cmd_setallmulti_mode,
6637 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6638 struct cmd_link_flow_ctrl_set_result {
6639 cmdline_fixed_string_t set;
6640 cmdline_fixed_string_t flow_ctrl;
6641 cmdline_fixed_string_t rx;
6642 cmdline_fixed_string_t rx_lfc_mode;
6643 cmdline_fixed_string_t tx;
6644 cmdline_fixed_string_t tx_lfc_mode;
6645 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6646 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6647 cmdline_fixed_string_t autoneg_str;
6648 cmdline_fixed_string_t autoneg;
6649 cmdline_fixed_string_t hw_str;
6650 uint32_t high_water;
6651 cmdline_fixed_string_t lw_str;
6653 cmdline_fixed_string_t pt_str;
6654 uint16_t pause_time;
6655 cmdline_fixed_string_t xon_str;
6660 cmdline_parse_token_string_t cmd_lfc_set_set =
6661 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6663 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6664 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6665 flow_ctrl, "flow_ctrl");
6666 cmdline_parse_token_string_t cmd_lfc_set_rx =
6667 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6669 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6670 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6671 rx_lfc_mode, "on#off");
6672 cmdline_parse_token_string_t cmd_lfc_set_tx =
6673 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6675 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6676 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6677 tx_lfc_mode, "on#off");
6678 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6679 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6680 hw_str, "high_water");
6681 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6682 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6683 high_water, UINT32);
6684 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6685 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6686 lw_str, "low_water");
6687 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6688 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6690 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6691 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6692 pt_str, "pause_time");
6693 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6694 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6695 pause_time, UINT16);
6696 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6697 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6698 xon_str, "send_xon");
6699 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6700 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6702 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6703 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6704 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6705 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6706 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6707 mac_ctrl_frame_fwd_mode, "on#off");
6708 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6709 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6710 autoneg_str, "autoneg");
6711 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6712 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6714 cmdline_parse_token_num_t cmd_lfc_set_portid =
6715 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6718 /* forward declaration */
6720 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6723 cmdline_parse_inst_t cmd_link_flow_control_set = {
6724 .f = cmd_link_flow_ctrl_set_parsed,
6726 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6727 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6728 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6730 (void *)&cmd_lfc_set_set,
6731 (void *)&cmd_lfc_set_flow_ctrl,
6732 (void *)&cmd_lfc_set_rx,
6733 (void *)&cmd_lfc_set_rx_mode,
6734 (void *)&cmd_lfc_set_tx,
6735 (void *)&cmd_lfc_set_tx_mode,
6736 (void *)&cmd_lfc_set_high_water,
6737 (void *)&cmd_lfc_set_low_water,
6738 (void *)&cmd_lfc_set_pause_time,
6739 (void *)&cmd_lfc_set_send_xon,
6740 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6741 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6742 (void *)&cmd_lfc_set_autoneg_str,
6743 (void *)&cmd_lfc_set_autoneg,
6744 (void *)&cmd_lfc_set_portid,
6749 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6750 .f = cmd_link_flow_ctrl_set_parsed,
6751 .data = (void *)&cmd_link_flow_control_set_rx,
6752 .help_str = "set flow_ctrl rx on|off <port_id>: "
6753 "Change rx flow control parameter",
6755 (void *)&cmd_lfc_set_set,
6756 (void *)&cmd_lfc_set_flow_ctrl,
6757 (void *)&cmd_lfc_set_rx,
6758 (void *)&cmd_lfc_set_rx_mode,
6759 (void *)&cmd_lfc_set_portid,
6764 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6765 .f = cmd_link_flow_ctrl_set_parsed,
6766 .data = (void *)&cmd_link_flow_control_set_tx,
6767 .help_str = "set flow_ctrl tx on|off <port_id>: "
6768 "Change tx flow control parameter",
6770 (void *)&cmd_lfc_set_set,
6771 (void *)&cmd_lfc_set_flow_ctrl,
6772 (void *)&cmd_lfc_set_tx,
6773 (void *)&cmd_lfc_set_tx_mode,
6774 (void *)&cmd_lfc_set_portid,
6779 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6780 .f = cmd_link_flow_ctrl_set_parsed,
6781 .data = (void *)&cmd_link_flow_control_set_hw,
6782 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6783 "Change high water flow control parameter",
6785 (void *)&cmd_lfc_set_set,
6786 (void *)&cmd_lfc_set_flow_ctrl,
6787 (void *)&cmd_lfc_set_high_water_str,
6788 (void *)&cmd_lfc_set_high_water,
6789 (void *)&cmd_lfc_set_portid,
6794 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6795 .f = cmd_link_flow_ctrl_set_parsed,
6796 .data = (void *)&cmd_link_flow_control_set_lw,
6797 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6798 "Change low water flow control parameter",
6800 (void *)&cmd_lfc_set_set,
6801 (void *)&cmd_lfc_set_flow_ctrl,
6802 (void *)&cmd_lfc_set_low_water_str,
6803 (void *)&cmd_lfc_set_low_water,
6804 (void *)&cmd_lfc_set_portid,
6809 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6810 .f = cmd_link_flow_ctrl_set_parsed,
6811 .data = (void *)&cmd_link_flow_control_set_pt,
6812 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6813 "Change pause time flow control parameter",
6815 (void *)&cmd_lfc_set_set,
6816 (void *)&cmd_lfc_set_flow_ctrl,
6817 (void *)&cmd_lfc_set_pause_time_str,
6818 (void *)&cmd_lfc_set_pause_time,
6819 (void *)&cmd_lfc_set_portid,
6824 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6825 .f = cmd_link_flow_ctrl_set_parsed,
6826 .data = (void *)&cmd_link_flow_control_set_xon,
6827 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6828 "Change send_xon flow control parameter",
6830 (void *)&cmd_lfc_set_set,
6831 (void *)&cmd_lfc_set_flow_ctrl,
6832 (void *)&cmd_lfc_set_send_xon_str,
6833 (void *)&cmd_lfc_set_send_xon,
6834 (void *)&cmd_lfc_set_portid,
6839 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6840 .f = cmd_link_flow_ctrl_set_parsed,
6841 .data = (void *)&cmd_link_flow_control_set_macfwd,
6842 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6843 "Change mac ctrl fwd flow control parameter",
6845 (void *)&cmd_lfc_set_set,
6846 (void *)&cmd_lfc_set_flow_ctrl,
6847 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6848 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6849 (void *)&cmd_lfc_set_portid,
6854 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6855 .f = cmd_link_flow_ctrl_set_parsed,
6856 .data = (void *)&cmd_link_flow_control_set_autoneg,
6857 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6858 "Change autoneg flow control parameter",
6860 (void *)&cmd_lfc_set_set,
6861 (void *)&cmd_lfc_set_flow_ctrl,
6862 (void *)&cmd_lfc_set_autoneg_str,
6863 (void *)&cmd_lfc_set_autoneg,
6864 (void *)&cmd_lfc_set_portid,
6870 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6871 __attribute__((unused)) struct cmdline *cl,
6874 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6875 cmdline_parse_inst_t *cmd = data;
6876 struct rte_eth_fc_conf fc_conf;
6882 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6883 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6884 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6885 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6887 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6888 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6891 /* Partial command line, retrieve current configuration */
6893 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6895 printf("cannot get current flow ctrl parameters, return"
6896 "code = %d\n", ret);
6900 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6901 (fc_conf.mode == RTE_FC_FULL))
6903 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6904 (fc_conf.mode == RTE_FC_FULL))
6908 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6909 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6911 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6912 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6914 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6916 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6917 fc_conf.high_water = res->high_water;
6919 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6920 fc_conf.low_water = res->low_water;
6922 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6923 fc_conf.pause_time = res->pause_time;
6925 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6926 fc_conf.send_xon = res->send_xon;
6928 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6929 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6930 fc_conf.mac_ctrl_frame_fwd = 1;
6932 fc_conf.mac_ctrl_frame_fwd = 0;
6935 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6936 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6938 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6940 printf("bad flow contrl parameter, return code = %d \n", ret);
6943 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6944 struct cmd_priority_flow_ctrl_set_result {
6945 cmdline_fixed_string_t set;
6946 cmdline_fixed_string_t pfc_ctrl;
6947 cmdline_fixed_string_t rx;
6948 cmdline_fixed_string_t rx_pfc_mode;
6949 cmdline_fixed_string_t tx;
6950 cmdline_fixed_string_t tx_pfc_mode;
6951 uint32_t high_water;
6953 uint16_t pause_time;
6959 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6960 __attribute__((unused)) struct cmdline *cl,
6961 __attribute__((unused)) void *data)
6963 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6964 struct rte_eth_pfc_conf pfc_conf;
6965 int rx_fc_enable, tx_fc_enable;
6969 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6970 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6971 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6972 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6974 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6975 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6978 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6979 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6980 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6981 pfc_conf.fc.high_water = res->high_water;
6982 pfc_conf.fc.low_water = res->low_water;
6983 pfc_conf.fc.pause_time = res->pause_time;
6984 pfc_conf.priority = res->priority;
6986 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6988 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6991 cmdline_parse_token_string_t cmd_pfc_set_set =
6992 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6994 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6995 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6996 pfc_ctrl, "pfc_ctrl");
6997 cmdline_parse_token_string_t cmd_pfc_set_rx =
6998 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7000 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7001 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7002 rx_pfc_mode, "on#off");
7003 cmdline_parse_token_string_t cmd_pfc_set_tx =
7004 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7006 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7007 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7008 tx_pfc_mode, "on#off");
7009 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7010 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7011 high_water, UINT32);
7012 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7013 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7015 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7016 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7017 pause_time, UINT16);
7018 cmdline_parse_token_num_t cmd_pfc_set_priority =
7019 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7021 cmdline_parse_token_num_t cmd_pfc_set_portid =
7022 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7025 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7026 .f = cmd_priority_flow_ctrl_set_parsed,
7028 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7029 "<pause_time> <priority> <port_id>: "
7030 "Configure the Ethernet priority flow control",
7032 (void *)&cmd_pfc_set_set,
7033 (void *)&cmd_pfc_set_flow_ctrl,
7034 (void *)&cmd_pfc_set_rx,
7035 (void *)&cmd_pfc_set_rx_mode,
7036 (void *)&cmd_pfc_set_tx,
7037 (void *)&cmd_pfc_set_tx_mode,
7038 (void *)&cmd_pfc_set_high_water,
7039 (void *)&cmd_pfc_set_low_water,
7040 (void *)&cmd_pfc_set_pause_time,
7041 (void *)&cmd_pfc_set_priority,
7042 (void *)&cmd_pfc_set_portid,
7047 /* *** RESET CONFIGURATION *** */
7048 struct cmd_reset_result {
7049 cmdline_fixed_string_t reset;
7050 cmdline_fixed_string_t def;
7053 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
7055 __attribute__((unused)) void *data)
7057 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7058 set_def_fwd_config();
7061 cmdline_parse_token_string_t cmd_reset_set =
7062 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7063 cmdline_parse_token_string_t cmd_reset_def =
7064 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7067 cmdline_parse_inst_t cmd_reset = {
7068 .f = cmd_reset_parsed,
7070 .help_str = "set default: Reset default forwarding configuration",
7072 (void *)&cmd_reset_set,
7073 (void *)&cmd_reset_def,
7078 /* *** START FORWARDING *** */
7079 struct cmd_start_result {
7080 cmdline_fixed_string_t start;
7083 cmdline_parse_token_string_t cmd_start_start =
7084 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7086 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
7087 __attribute__((unused)) struct cmdline *cl,
7088 __attribute__((unused)) void *data)
7090 start_packet_forwarding(0);
7093 cmdline_parse_inst_t cmd_start = {
7094 .f = cmd_start_parsed,
7096 .help_str = "start: Start packet forwarding",
7098 (void *)&cmd_start_start,
7103 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7104 struct cmd_start_tx_first_result {
7105 cmdline_fixed_string_t start;
7106 cmdline_fixed_string_t tx_first;
7110 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
7111 __attribute__((unused)) struct cmdline *cl,
7112 __attribute__((unused)) void *data)
7114 start_packet_forwarding(1);
7117 cmdline_parse_token_string_t cmd_start_tx_first_start =
7118 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7120 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7121 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7122 tx_first, "tx_first");
7124 cmdline_parse_inst_t cmd_start_tx_first = {
7125 .f = cmd_start_tx_first_parsed,
7127 .help_str = "start tx_first: Start packet forwarding, "
7128 "after sending 1 burst of packets",
7130 (void *)&cmd_start_tx_first_start,
7131 (void *)&cmd_start_tx_first_tx_first,
7136 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7137 struct cmd_start_tx_first_n_result {
7138 cmdline_fixed_string_t start;
7139 cmdline_fixed_string_t tx_first;
7144 cmd_start_tx_first_n_parsed(void *parsed_result,
7145 __attribute__((unused)) struct cmdline *cl,
7146 __attribute__((unused)) void *data)
7148 struct cmd_start_tx_first_n_result *res = parsed_result;
7150 start_packet_forwarding(res->tx_num);
7153 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7154 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7156 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7157 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7158 tx_first, "tx_first");
7159 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7160 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7163 cmdline_parse_inst_t cmd_start_tx_first_n = {
7164 .f = cmd_start_tx_first_n_parsed,
7166 .help_str = "start tx_first <num>: "
7167 "packet forwarding, after sending <num> bursts of packets",
7169 (void *)&cmd_start_tx_first_n_start,
7170 (void *)&cmd_start_tx_first_n_tx_first,
7171 (void *)&cmd_start_tx_first_n_tx_num,
7176 /* *** SET LINK UP *** */
7177 struct cmd_set_link_up_result {
7178 cmdline_fixed_string_t set;
7179 cmdline_fixed_string_t link_up;
7180 cmdline_fixed_string_t port;
7184 cmdline_parse_token_string_t cmd_set_link_up_set =
7185 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7186 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7187 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7189 cmdline_parse_token_string_t cmd_set_link_up_port =
7190 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7191 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7192 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7194 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
7195 __attribute__((unused)) struct cmdline *cl,
7196 __attribute__((unused)) void *data)
7198 struct cmd_set_link_up_result *res = parsed_result;
7199 dev_set_link_up(res->port_id);
7202 cmdline_parse_inst_t cmd_set_link_up = {
7203 .f = cmd_set_link_up_parsed,
7205 .help_str = "set link-up port <port id>",
7207 (void *)&cmd_set_link_up_set,
7208 (void *)&cmd_set_link_up_link_up,
7209 (void *)&cmd_set_link_up_port,
7210 (void *)&cmd_set_link_up_port_id,
7215 /* *** SET LINK DOWN *** */
7216 struct cmd_set_link_down_result {
7217 cmdline_fixed_string_t set;
7218 cmdline_fixed_string_t link_down;
7219 cmdline_fixed_string_t port;
7223 cmdline_parse_token_string_t cmd_set_link_down_set =
7224 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7225 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7226 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7228 cmdline_parse_token_string_t cmd_set_link_down_port =
7229 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7230 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7231 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7233 static void cmd_set_link_down_parsed(
7234 __attribute__((unused)) void *parsed_result,
7235 __attribute__((unused)) struct cmdline *cl,
7236 __attribute__((unused)) void *data)
7238 struct cmd_set_link_down_result *res = parsed_result;
7239 dev_set_link_down(res->port_id);
7242 cmdline_parse_inst_t cmd_set_link_down = {
7243 .f = cmd_set_link_down_parsed,
7245 .help_str = "set link-down port <port id>",
7247 (void *)&cmd_set_link_down_set,
7248 (void *)&cmd_set_link_down_link_down,
7249 (void *)&cmd_set_link_down_port,
7250 (void *)&cmd_set_link_down_port_id,
7255 /* *** SHOW CFG *** */
7256 struct cmd_showcfg_result {
7257 cmdline_fixed_string_t show;
7258 cmdline_fixed_string_t cfg;
7259 cmdline_fixed_string_t what;
7262 static void cmd_showcfg_parsed(void *parsed_result,
7263 __attribute__((unused)) struct cmdline *cl,
7264 __attribute__((unused)) void *data)
7266 struct cmd_showcfg_result *res = parsed_result;
7267 if (!strcmp(res->what, "rxtx"))
7268 rxtx_config_display();
7269 else if (!strcmp(res->what, "cores"))
7270 fwd_lcores_config_display();
7271 else if (!strcmp(res->what, "fwd"))
7272 pkt_fwd_config_display(&cur_fwd_config);
7273 else if (!strcmp(res->what, "txpkts"))
7274 show_tx_pkt_segments();
7277 cmdline_parse_token_string_t cmd_showcfg_show =
7278 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7279 cmdline_parse_token_string_t cmd_showcfg_port =
7280 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7281 cmdline_parse_token_string_t cmd_showcfg_what =
7282 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7283 "rxtx#cores#fwd#txpkts");
7285 cmdline_parse_inst_t cmd_showcfg = {
7286 .f = cmd_showcfg_parsed,
7288 .help_str = "show config rxtx|cores|fwd|txpkts",
7290 (void *)&cmd_showcfg_show,
7291 (void *)&cmd_showcfg_port,
7292 (void *)&cmd_showcfg_what,
7297 /* *** SHOW ALL PORT INFO *** */
7298 struct cmd_showportall_result {
7299 cmdline_fixed_string_t show;
7300 cmdline_fixed_string_t port;
7301 cmdline_fixed_string_t what;
7302 cmdline_fixed_string_t all;
7305 static void cmd_showportall_parsed(void *parsed_result,
7306 __attribute__((unused)) struct cmdline *cl,
7307 __attribute__((unused)) void *data)
7311 struct cmd_showportall_result *res = parsed_result;
7312 if (!strcmp(res->show, "clear")) {
7313 if (!strcmp(res->what, "stats"))
7314 RTE_ETH_FOREACH_DEV(i)
7316 else if (!strcmp(res->what, "xstats"))
7317 RTE_ETH_FOREACH_DEV(i)
7318 nic_xstats_clear(i);
7319 } else if (!strcmp(res->what, "info"))
7320 RTE_ETH_FOREACH_DEV(i)
7321 port_infos_display(i);
7322 else if (!strcmp(res->what, "summary")) {
7323 port_summary_header_display();
7324 RTE_ETH_FOREACH_DEV(i)
7325 port_summary_display(i);
7327 else if (!strcmp(res->what, "stats"))
7328 RTE_ETH_FOREACH_DEV(i)
7329 nic_stats_display(i);
7330 else if (!strcmp(res->what, "xstats"))
7331 RTE_ETH_FOREACH_DEV(i)
7332 nic_xstats_display(i);
7333 else if (!strcmp(res->what, "fdir"))
7334 RTE_ETH_FOREACH_DEV(i)
7336 else if (!strcmp(res->what, "stat_qmap"))
7337 RTE_ETH_FOREACH_DEV(i)
7338 nic_stats_mapping_display(i);
7339 else if (!strcmp(res->what, "dcb_tc"))
7340 RTE_ETH_FOREACH_DEV(i)
7341 port_dcb_info_display(i);
7342 else if (!strcmp(res->what, "cap"))
7343 RTE_ETH_FOREACH_DEV(i)
7344 port_offload_cap_display(i);
7347 cmdline_parse_token_string_t cmd_showportall_show =
7348 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7350 cmdline_parse_token_string_t cmd_showportall_port =
7351 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7352 cmdline_parse_token_string_t cmd_showportall_what =
7353 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7354 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7355 cmdline_parse_token_string_t cmd_showportall_all =
7356 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7357 cmdline_parse_inst_t cmd_showportall = {
7358 .f = cmd_showportall_parsed,
7360 .help_str = "show|clear port "
7361 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7363 (void *)&cmd_showportall_show,
7364 (void *)&cmd_showportall_port,
7365 (void *)&cmd_showportall_what,
7366 (void *)&cmd_showportall_all,
7371 /* *** SHOW PORT INFO *** */
7372 struct cmd_showport_result {
7373 cmdline_fixed_string_t show;
7374 cmdline_fixed_string_t port;
7375 cmdline_fixed_string_t what;
7379 static void cmd_showport_parsed(void *parsed_result,
7380 __attribute__((unused)) struct cmdline *cl,
7381 __attribute__((unused)) void *data)
7383 struct cmd_showport_result *res = parsed_result;
7384 if (!strcmp(res->show, "clear")) {
7385 if (!strcmp(res->what, "stats"))
7386 nic_stats_clear(res->portnum);
7387 else if (!strcmp(res->what, "xstats"))
7388 nic_xstats_clear(res->portnum);
7389 } else if (!strcmp(res->what, "info"))
7390 port_infos_display(res->portnum);
7391 else if (!strcmp(res->what, "summary")) {
7392 port_summary_header_display();
7393 port_summary_display(res->portnum);
7395 else if (!strcmp(res->what, "stats"))
7396 nic_stats_display(res->portnum);
7397 else if (!strcmp(res->what, "xstats"))
7398 nic_xstats_display(res->portnum);
7399 else if (!strcmp(res->what, "fdir"))
7400 fdir_get_infos(res->portnum);
7401 else if (!strcmp(res->what, "stat_qmap"))
7402 nic_stats_mapping_display(res->portnum);
7403 else if (!strcmp(res->what, "dcb_tc"))
7404 port_dcb_info_display(res->portnum);
7405 else if (!strcmp(res->what, "cap"))
7406 port_offload_cap_display(res->portnum);
7409 cmdline_parse_token_string_t cmd_showport_show =
7410 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7412 cmdline_parse_token_string_t cmd_showport_port =
7413 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7414 cmdline_parse_token_string_t cmd_showport_what =
7415 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7416 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7417 cmdline_parse_token_num_t cmd_showport_portnum =
7418 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7420 cmdline_parse_inst_t cmd_showport = {
7421 .f = cmd_showport_parsed,
7423 .help_str = "show|clear port "
7424 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7427 (void *)&cmd_showport_show,
7428 (void *)&cmd_showport_port,
7429 (void *)&cmd_showport_what,
7430 (void *)&cmd_showport_portnum,
7435 /* *** SHOW QUEUE INFO *** */
7436 struct cmd_showqueue_result {
7437 cmdline_fixed_string_t show;
7438 cmdline_fixed_string_t type;
7439 cmdline_fixed_string_t what;
7445 cmd_showqueue_parsed(void *parsed_result,
7446 __attribute__((unused)) struct cmdline *cl,
7447 __attribute__((unused)) void *data)
7449 struct cmd_showqueue_result *res = parsed_result;
7451 if (!strcmp(res->type, "rxq"))
7452 rx_queue_infos_display(res->portnum, res->queuenum);
7453 else if (!strcmp(res->type, "txq"))
7454 tx_queue_infos_display(res->portnum, res->queuenum);
7457 cmdline_parse_token_string_t cmd_showqueue_show =
7458 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7459 cmdline_parse_token_string_t cmd_showqueue_type =
7460 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7461 cmdline_parse_token_string_t cmd_showqueue_what =
7462 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7463 cmdline_parse_token_num_t cmd_showqueue_portnum =
7464 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7465 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7466 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7468 cmdline_parse_inst_t cmd_showqueue = {
7469 .f = cmd_showqueue_parsed,
7471 .help_str = "show rxq|txq info <port_id> <queue_id>",
7473 (void *)&cmd_showqueue_show,
7474 (void *)&cmd_showqueue_type,
7475 (void *)&cmd_showqueue_what,
7476 (void *)&cmd_showqueue_portnum,
7477 (void *)&cmd_showqueue_queuenum,
7482 /* *** READ PORT REGISTER *** */
7483 struct cmd_read_reg_result {
7484 cmdline_fixed_string_t read;
7485 cmdline_fixed_string_t reg;
7491 cmd_read_reg_parsed(void *parsed_result,
7492 __attribute__((unused)) struct cmdline *cl,
7493 __attribute__((unused)) void *data)
7495 struct cmd_read_reg_result *res = parsed_result;
7496 port_reg_display(res->port_id, res->reg_off);
7499 cmdline_parse_token_string_t cmd_read_reg_read =
7500 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7501 cmdline_parse_token_string_t cmd_read_reg_reg =
7502 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7503 cmdline_parse_token_num_t cmd_read_reg_port_id =
7504 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7505 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7506 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7508 cmdline_parse_inst_t cmd_read_reg = {
7509 .f = cmd_read_reg_parsed,
7511 .help_str = "read reg <port_id> <reg_off>",
7513 (void *)&cmd_read_reg_read,
7514 (void *)&cmd_read_reg_reg,
7515 (void *)&cmd_read_reg_port_id,
7516 (void *)&cmd_read_reg_reg_off,
7521 /* *** READ PORT REGISTER BIT FIELD *** */
7522 struct cmd_read_reg_bit_field_result {
7523 cmdline_fixed_string_t read;
7524 cmdline_fixed_string_t regfield;
7532 cmd_read_reg_bit_field_parsed(void *parsed_result,
7533 __attribute__((unused)) struct cmdline *cl,
7534 __attribute__((unused)) void *data)
7536 struct cmd_read_reg_bit_field_result *res = parsed_result;
7537 port_reg_bit_field_display(res->port_id, res->reg_off,
7538 res->bit1_pos, res->bit2_pos);
7541 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7542 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7544 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7545 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7546 regfield, "regfield");
7547 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7548 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7550 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7551 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7553 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7554 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7556 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7557 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7560 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7561 .f = cmd_read_reg_bit_field_parsed,
7563 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7564 "Read register bit field between bit_x and bit_y included",
7566 (void *)&cmd_read_reg_bit_field_read,
7567 (void *)&cmd_read_reg_bit_field_regfield,
7568 (void *)&cmd_read_reg_bit_field_port_id,
7569 (void *)&cmd_read_reg_bit_field_reg_off,
7570 (void *)&cmd_read_reg_bit_field_bit1_pos,
7571 (void *)&cmd_read_reg_bit_field_bit2_pos,
7576 /* *** READ PORT REGISTER BIT *** */
7577 struct cmd_read_reg_bit_result {
7578 cmdline_fixed_string_t read;
7579 cmdline_fixed_string_t regbit;
7586 cmd_read_reg_bit_parsed(void *parsed_result,
7587 __attribute__((unused)) struct cmdline *cl,
7588 __attribute__((unused)) void *data)
7590 struct cmd_read_reg_bit_result *res = parsed_result;
7591 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7594 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7595 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7596 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7597 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7599 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7600 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7601 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7602 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7603 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7604 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7606 cmdline_parse_inst_t cmd_read_reg_bit = {
7607 .f = cmd_read_reg_bit_parsed,
7609 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7611 (void *)&cmd_read_reg_bit_read,
7612 (void *)&cmd_read_reg_bit_regbit,
7613 (void *)&cmd_read_reg_bit_port_id,
7614 (void *)&cmd_read_reg_bit_reg_off,
7615 (void *)&cmd_read_reg_bit_bit_pos,
7620 /* *** WRITE PORT REGISTER *** */
7621 struct cmd_write_reg_result {
7622 cmdline_fixed_string_t write;
7623 cmdline_fixed_string_t reg;
7630 cmd_write_reg_parsed(void *parsed_result,
7631 __attribute__((unused)) struct cmdline *cl,
7632 __attribute__((unused)) void *data)
7634 struct cmd_write_reg_result *res = parsed_result;
7635 port_reg_set(res->port_id, res->reg_off, res->value);
7638 cmdline_parse_token_string_t cmd_write_reg_write =
7639 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7640 cmdline_parse_token_string_t cmd_write_reg_reg =
7641 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7642 cmdline_parse_token_num_t cmd_write_reg_port_id =
7643 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7644 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7645 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7646 cmdline_parse_token_num_t cmd_write_reg_value =
7647 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7649 cmdline_parse_inst_t cmd_write_reg = {
7650 .f = cmd_write_reg_parsed,
7652 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7654 (void *)&cmd_write_reg_write,
7655 (void *)&cmd_write_reg_reg,
7656 (void *)&cmd_write_reg_port_id,
7657 (void *)&cmd_write_reg_reg_off,
7658 (void *)&cmd_write_reg_value,
7663 /* *** WRITE PORT REGISTER BIT FIELD *** */
7664 struct cmd_write_reg_bit_field_result {
7665 cmdline_fixed_string_t write;
7666 cmdline_fixed_string_t regfield;
7675 cmd_write_reg_bit_field_parsed(void *parsed_result,
7676 __attribute__((unused)) struct cmdline *cl,
7677 __attribute__((unused)) void *data)
7679 struct cmd_write_reg_bit_field_result *res = parsed_result;
7680 port_reg_bit_field_set(res->port_id, res->reg_off,
7681 res->bit1_pos, res->bit2_pos, res->value);
7684 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7685 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7687 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7688 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7689 regfield, "regfield");
7690 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7691 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7693 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7694 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7696 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7697 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7699 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7700 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7702 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7703 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7706 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7707 .f = cmd_write_reg_bit_field_parsed,
7709 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7711 "Set register bit field between bit_x and bit_y included",
7713 (void *)&cmd_write_reg_bit_field_write,
7714 (void *)&cmd_write_reg_bit_field_regfield,
7715 (void *)&cmd_write_reg_bit_field_port_id,
7716 (void *)&cmd_write_reg_bit_field_reg_off,
7717 (void *)&cmd_write_reg_bit_field_bit1_pos,
7718 (void *)&cmd_write_reg_bit_field_bit2_pos,
7719 (void *)&cmd_write_reg_bit_field_value,
7724 /* *** WRITE PORT REGISTER BIT *** */
7725 struct cmd_write_reg_bit_result {
7726 cmdline_fixed_string_t write;
7727 cmdline_fixed_string_t regbit;
7735 cmd_write_reg_bit_parsed(void *parsed_result,
7736 __attribute__((unused)) struct cmdline *cl,
7737 __attribute__((unused)) void *data)
7739 struct cmd_write_reg_bit_result *res = parsed_result;
7740 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7743 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7744 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7746 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7747 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7749 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7750 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7751 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7752 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7753 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7754 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7755 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7756 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7758 cmdline_parse_inst_t cmd_write_reg_bit = {
7759 .f = cmd_write_reg_bit_parsed,
7761 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7764 (void *)&cmd_write_reg_bit_write,
7765 (void *)&cmd_write_reg_bit_regbit,
7766 (void *)&cmd_write_reg_bit_port_id,
7767 (void *)&cmd_write_reg_bit_reg_off,
7768 (void *)&cmd_write_reg_bit_bit_pos,
7769 (void *)&cmd_write_reg_bit_value,
7774 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7775 struct cmd_read_rxd_txd_result {
7776 cmdline_fixed_string_t read;
7777 cmdline_fixed_string_t rxd_txd;
7784 cmd_read_rxd_txd_parsed(void *parsed_result,
7785 __attribute__((unused)) struct cmdline *cl,
7786 __attribute__((unused)) void *data)
7788 struct cmd_read_rxd_txd_result *res = parsed_result;
7790 if (!strcmp(res->rxd_txd, "rxd"))
7791 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7792 else if (!strcmp(res->rxd_txd, "txd"))
7793 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7796 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7797 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7798 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7799 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7801 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7802 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7803 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7804 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7805 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7806 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7808 cmdline_parse_inst_t cmd_read_rxd_txd = {
7809 .f = cmd_read_rxd_txd_parsed,
7811 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7813 (void *)&cmd_read_rxd_txd_read,
7814 (void *)&cmd_read_rxd_txd_rxd_txd,
7815 (void *)&cmd_read_rxd_txd_port_id,
7816 (void *)&cmd_read_rxd_txd_queue_id,
7817 (void *)&cmd_read_rxd_txd_desc_id,
7823 struct cmd_quit_result {
7824 cmdline_fixed_string_t quit;
7827 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7829 __attribute__((unused)) void *data)
7834 cmdline_parse_token_string_t cmd_quit_quit =
7835 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7837 cmdline_parse_inst_t cmd_quit = {
7838 .f = cmd_quit_parsed,
7840 .help_str = "quit: Exit application",
7842 (void *)&cmd_quit_quit,
7847 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7848 struct cmd_mac_addr_result {
7849 cmdline_fixed_string_t mac_addr_cmd;
7850 cmdline_fixed_string_t what;
7852 struct ether_addr address;
7855 static void cmd_mac_addr_parsed(void *parsed_result,
7856 __attribute__((unused)) struct cmdline *cl,
7857 __attribute__((unused)) void *data)
7859 struct cmd_mac_addr_result *res = parsed_result;
7862 if (strcmp(res->what, "add") == 0)
7863 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7864 else if (strcmp(res->what, "set") == 0)
7865 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7868 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7870 /* check the return value and print it if is < 0 */
7872 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7876 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7877 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7879 cmdline_parse_token_string_t cmd_mac_addr_what =
7880 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7882 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7883 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7885 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7886 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7888 cmdline_parse_inst_t cmd_mac_addr = {
7889 .f = cmd_mac_addr_parsed,
7891 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7892 "Add/Remove/Set MAC address on port_id",
7894 (void *)&cmd_mac_addr_cmd,
7895 (void *)&cmd_mac_addr_what,
7896 (void *)&cmd_mac_addr_portnum,
7897 (void *)&cmd_mac_addr_addr,
7902 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7903 struct cmd_eth_peer_result {
7904 cmdline_fixed_string_t set;
7905 cmdline_fixed_string_t eth_peer;
7907 cmdline_fixed_string_t peer_addr;
7910 static void cmd_set_eth_peer_parsed(void *parsed_result,
7911 __attribute__((unused)) struct cmdline *cl,
7912 __attribute__((unused)) void *data)
7914 struct cmd_eth_peer_result *res = parsed_result;
7916 if (test_done == 0) {
7917 printf("Please stop forwarding first\n");
7920 if (!strcmp(res->eth_peer, "eth-peer")) {
7921 set_fwd_eth_peer(res->port_id, res->peer_addr);
7925 cmdline_parse_token_string_t cmd_eth_peer_set =
7926 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7927 cmdline_parse_token_string_t cmd_eth_peer =
7928 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7929 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7930 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7931 cmdline_parse_token_string_t cmd_eth_peer_addr =
7932 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7934 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7935 .f = cmd_set_eth_peer_parsed,
7937 .help_str = "set eth-peer <port_id> <peer_mac>",
7939 (void *)&cmd_eth_peer_set,
7940 (void *)&cmd_eth_peer,
7941 (void *)&cmd_eth_peer_port_id,
7942 (void *)&cmd_eth_peer_addr,
7947 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7948 struct cmd_set_qmap_result {
7949 cmdline_fixed_string_t set;
7950 cmdline_fixed_string_t qmap;
7951 cmdline_fixed_string_t what;
7958 cmd_set_qmap_parsed(void *parsed_result,
7959 __attribute__((unused)) struct cmdline *cl,
7960 __attribute__((unused)) void *data)
7962 struct cmd_set_qmap_result *res = parsed_result;
7963 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7965 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7968 cmdline_parse_token_string_t cmd_setqmap_set =
7969 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7971 cmdline_parse_token_string_t cmd_setqmap_qmap =
7972 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7974 cmdline_parse_token_string_t cmd_setqmap_what =
7975 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7977 cmdline_parse_token_num_t cmd_setqmap_portid =
7978 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7980 cmdline_parse_token_num_t cmd_setqmap_queueid =
7981 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7983 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7984 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7987 cmdline_parse_inst_t cmd_set_qmap = {
7988 .f = cmd_set_qmap_parsed,
7990 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7991 "Set statistics mapping value on tx|rx queue_id of port_id",
7993 (void *)&cmd_setqmap_set,
7994 (void *)&cmd_setqmap_qmap,
7995 (void *)&cmd_setqmap_what,
7996 (void *)&cmd_setqmap_portid,
7997 (void *)&cmd_setqmap_queueid,
7998 (void *)&cmd_setqmap_mapvalue,
8003 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8004 struct cmd_set_xstats_hide_zero_result {
8005 cmdline_fixed_string_t keyword;
8006 cmdline_fixed_string_t name;
8007 cmdline_fixed_string_t on_off;
8011 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8012 __attribute__((unused)) struct cmdline *cl,
8013 __attribute__((unused)) void *data)
8015 struct cmd_set_xstats_hide_zero_result *res;
8016 uint16_t on_off = 0;
8018 res = parsed_result;
8019 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8020 set_xstats_hide_zero(on_off);
8023 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8024 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8026 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8027 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8028 name, "xstats-hide-zero");
8029 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8030 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8033 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8034 .f = cmd_set_xstats_hide_zero_parsed,
8036 .help_str = "set xstats-hide-zero on|off",
8038 (void *)&cmd_set_xstats_hide_zero_keyword,
8039 (void *)&cmd_set_xstats_hide_zero_name,
8040 (void *)&cmd_set_xstats_hide_zero_on_off,
8045 /* *** CONFIGURE UNICAST HASH TABLE *** */
8046 struct cmd_set_uc_hash_table {
8047 cmdline_fixed_string_t set;
8048 cmdline_fixed_string_t port;
8050 cmdline_fixed_string_t what;
8051 struct ether_addr address;
8052 cmdline_fixed_string_t mode;
8056 cmd_set_uc_hash_parsed(void *parsed_result,
8057 __attribute__((unused)) struct cmdline *cl,
8058 __attribute__((unused)) void *data)
8061 struct cmd_set_uc_hash_table *res = parsed_result;
8063 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8065 if (strcmp(res->what, "uta") == 0)
8066 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8067 &res->address,(uint8_t)is_on);
8069 printf("bad unicast hash table parameter, return code = %d \n", ret);
8073 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8074 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8076 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8077 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8079 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8080 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8082 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8083 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8085 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8086 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8088 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8089 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8092 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8093 .f = cmd_set_uc_hash_parsed,
8095 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8097 (void *)&cmd_set_uc_hash_set,
8098 (void *)&cmd_set_uc_hash_port,
8099 (void *)&cmd_set_uc_hash_portid,
8100 (void *)&cmd_set_uc_hash_what,
8101 (void *)&cmd_set_uc_hash_mac,
8102 (void *)&cmd_set_uc_hash_mode,
8107 struct cmd_set_uc_all_hash_table {
8108 cmdline_fixed_string_t set;
8109 cmdline_fixed_string_t port;
8111 cmdline_fixed_string_t what;
8112 cmdline_fixed_string_t value;
8113 cmdline_fixed_string_t mode;
8117 cmd_set_uc_all_hash_parsed(void *parsed_result,
8118 __attribute__((unused)) struct cmdline *cl,
8119 __attribute__((unused)) void *data)
8122 struct cmd_set_uc_all_hash_table *res = parsed_result;
8124 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8126 if ((strcmp(res->what, "uta") == 0) &&
8127 (strcmp(res->value, "all") == 0))
8128 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8130 printf("bad unicast hash table parameter,"
8131 "return code = %d \n", ret);
8134 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8135 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8137 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8138 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8140 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8141 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8143 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8144 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8146 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8147 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8149 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8150 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8153 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8154 .f = cmd_set_uc_all_hash_parsed,
8156 .help_str = "set port <port_id> uta all on|off",
8158 (void *)&cmd_set_uc_all_hash_set,
8159 (void *)&cmd_set_uc_all_hash_port,
8160 (void *)&cmd_set_uc_all_hash_portid,
8161 (void *)&cmd_set_uc_all_hash_what,
8162 (void *)&cmd_set_uc_all_hash_value,
8163 (void *)&cmd_set_uc_all_hash_mode,
8168 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8169 struct cmd_set_vf_macvlan_filter {
8170 cmdline_fixed_string_t set;
8171 cmdline_fixed_string_t port;
8173 cmdline_fixed_string_t vf;
8175 struct ether_addr address;
8176 cmdline_fixed_string_t filter_type;
8177 cmdline_fixed_string_t mode;
8181 cmd_set_vf_macvlan_parsed(void *parsed_result,
8182 __attribute__((unused)) struct cmdline *cl,
8183 __attribute__((unused)) void *data)
8186 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8187 struct rte_eth_mac_filter filter;
8189 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8191 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
8193 /* set VF MAC filter */
8197 filter.dst_id = res->vf_id;
8199 if (!strcmp(res->filter_type, "exact-mac"))
8200 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8201 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8202 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8203 else if (!strcmp(res->filter_type, "hashmac"))
8204 filter.filter_type = RTE_MAC_HASH_MATCH;
8205 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8206 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8208 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8211 ret = rte_eth_dev_filter_ctrl(res->port_id,
8212 RTE_ETH_FILTER_MACVLAN,
8216 ret = rte_eth_dev_filter_ctrl(res->port_id,
8217 RTE_ETH_FILTER_MACVLAN,
8218 RTE_ETH_FILTER_DELETE,
8222 printf("bad set MAC hash parameter, return code = %d\n", ret);
8226 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8227 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8229 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8230 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8232 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8233 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8235 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8236 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8238 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8239 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8241 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8242 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8244 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8245 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8246 filter_type, "exact-mac#exact-mac-vlan"
8247 "#hashmac#hashmac-vlan");
8248 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8249 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8252 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8253 .f = cmd_set_vf_macvlan_parsed,
8255 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8256 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8257 "Exact match rule: exact match of MAC or MAC and VLAN; "
8258 "hash match rule: hash match of MAC and exact match of VLAN",
8260 (void *)&cmd_set_vf_macvlan_set,
8261 (void *)&cmd_set_vf_macvlan_port,
8262 (void *)&cmd_set_vf_macvlan_portid,
8263 (void *)&cmd_set_vf_macvlan_vf,
8264 (void *)&cmd_set_vf_macvlan_vf_id,
8265 (void *)&cmd_set_vf_macvlan_mac,
8266 (void *)&cmd_set_vf_macvlan_filter_type,
8267 (void *)&cmd_set_vf_macvlan_mode,
8272 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8273 struct cmd_set_vf_traffic {
8274 cmdline_fixed_string_t set;
8275 cmdline_fixed_string_t port;
8277 cmdline_fixed_string_t vf;
8279 cmdline_fixed_string_t what;
8280 cmdline_fixed_string_t mode;
8284 cmd_set_vf_traffic_parsed(void *parsed_result,
8285 __attribute__((unused)) struct cmdline *cl,
8286 __attribute__((unused)) void *data)
8288 struct cmd_set_vf_traffic *res = parsed_result;
8289 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8290 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8292 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8295 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8296 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8298 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8299 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8301 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8302 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8304 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8305 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8307 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8308 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8310 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8311 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8313 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8314 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8317 cmdline_parse_inst_t cmd_set_vf_traffic = {
8318 .f = cmd_set_vf_traffic_parsed,
8320 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8322 (void *)&cmd_setvf_traffic_set,
8323 (void *)&cmd_setvf_traffic_port,
8324 (void *)&cmd_setvf_traffic_portid,
8325 (void *)&cmd_setvf_traffic_vf,
8326 (void *)&cmd_setvf_traffic_vfid,
8327 (void *)&cmd_setvf_traffic_what,
8328 (void *)&cmd_setvf_traffic_mode,
8333 /* *** CONFIGURE VF RECEIVE MODE *** */
8334 struct cmd_set_vf_rxmode {
8335 cmdline_fixed_string_t set;
8336 cmdline_fixed_string_t port;
8338 cmdline_fixed_string_t vf;
8340 cmdline_fixed_string_t what;
8341 cmdline_fixed_string_t mode;
8342 cmdline_fixed_string_t on;
8346 cmd_set_vf_rxmode_parsed(void *parsed_result,
8347 __attribute__((unused)) struct cmdline *cl,
8348 __attribute__((unused)) void *data)
8351 uint16_t rx_mode = 0;
8352 struct cmd_set_vf_rxmode *res = parsed_result;
8354 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8355 if (!strcmp(res->what,"rxmode")) {
8356 if (!strcmp(res->mode, "AUPE"))
8357 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
8358 else if (!strcmp(res->mode, "ROPE"))
8359 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
8360 else if (!strcmp(res->mode, "BAM"))
8361 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
8362 else if (!strncmp(res->mode, "MPE",3))
8363 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
8366 RTE_SET_USED(is_on);
8368 #ifdef RTE_LIBRTE_IXGBE_PMD
8369 if (ret == -ENOTSUP)
8370 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8371 rx_mode, (uint8_t)is_on);
8373 #ifdef RTE_LIBRTE_BNXT_PMD
8374 if (ret == -ENOTSUP)
8375 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8376 rx_mode, (uint8_t)is_on);
8379 printf("bad VF receive mode parameter, return code = %d \n",
8383 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8384 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8386 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8387 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8389 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8390 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8392 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8393 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8395 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8396 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8398 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8399 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8401 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8402 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8403 mode, "AUPE#ROPE#BAM#MPE");
8404 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8405 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8408 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8409 .f = cmd_set_vf_rxmode_parsed,
8411 .help_str = "set port <port_id> vf <vf_id> rxmode "
8412 "AUPE|ROPE|BAM|MPE on|off",
8414 (void *)&cmd_set_vf_rxmode_set,
8415 (void *)&cmd_set_vf_rxmode_port,
8416 (void *)&cmd_set_vf_rxmode_portid,
8417 (void *)&cmd_set_vf_rxmode_vf,
8418 (void *)&cmd_set_vf_rxmode_vfid,
8419 (void *)&cmd_set_vf_rxmode_what,
8420 (void *)&cmd_set_vf_rxmode_mode,
8421 (void *)&cmd_set_vf_rxmode_on,
8426 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8427 struct cmd_vf_mac_addr_result {
8428 cmdline_fixed_string_t mac_addr_cmd;
8429 cmdline_fixed_string_t what;
8430 cmdline_fixed_string_t port;
8432 cmdline_fixed_string_t vf;
8434 struct ether_addr address;
8437 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8438 __attribute__((unused)) struct cmdline *cl,
8439 __attribute__((unused)) void *data)
8441 struct cmd_vf_mac_addr_result *res = parsed_result;
8444 if (strcmp(res->what, "add") != 0)
8447 #ifdef RTE_LIBRTE_I40E_PMD
8448 if (ret == -ENOTSUP)
8449 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8452 #ifdef RTE_LIBRTE_BNXT_PMD
8453 if (ret == -ENOTSUP)
8454 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8459 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8463 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8464 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8465 mac_addr_cmd,"mac_addr");
8466 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8467 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8469 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8470 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8472 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8473 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8475 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8476 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8478 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8479 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8481 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8482 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8485 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8486 .f = cmd_vf_mac_addr_parsed,
8488 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8489 "Add MAC address filtering for a VF on port_id",
8491 (void *)&cmd_vf_mac_addr_cmd,
8492 (void *)&cmd_vf_mac_addr_what,
8493 (void *)&cmd_vf_mac_addr_port,
8494 (void *)&cmd_vf_mac_addr_portnum,
8495 (void *)&cmd_vf_mac_addr_vf,
8496 (void *)&cmd_vf_mac_addr_vfnum,
8497 (void *)&cmd_vf_mac_addr_addr,
8502 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8503 struct cmd_vf_rx_vlan_filter {
8504 cmdline_fixed_string_t rx_vlan;
8505 cmdline_fixed_string_t what;
8507 cmdline_fixed_string_t port;
8509 cmdline_fixed_string_t vf;
8514 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8515 __attribute__((unused)) struct cmdline *cl,
8516 __attribute__((unused)) void *data)
8518 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8521 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8523 #ifdef RTE_LIBRTE_IXGBE_PMD
8524 if (ret == -ENOTSUP)
8525 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8526 res->vlan_id, res->vf_mask, is_add);
8528 #ifdef RTE_LIBRTE_I40E_PMD
8529 if (ret == -ENOTSUP)
8530 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8531 res->vlan_id, res->vf_mask, is_add);
8533 #ifdef RTE_LIBRTE_BNXT_PMD
8534 if (ret == -ENOTSUP)
8535 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8536 res->vlan_id, res->vf_mask, is_add);
8543 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8544 res->vlan_id, res->vf_mask);
8547 printf("invalid port_id %d\n", res->port_id);
8550 printf("function not implemented or supported\n");
8553 printf("programming error: (%s)\n", strerror(-ret));
8557 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8558 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8559 rx_vlan, "rx_vlan");
8560 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8561 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8563 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8564 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8566 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8567 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8569 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8570 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8572 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8573 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8575 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8576 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8579 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8580 .f = cmd_vf_rx_vlan_filter_parsed,
8582 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8583 "(vf_mask = hexadecimal VF mask)",
8585 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8586 (void *)&cmd_vf_rx_vlan_filter_what,
8587 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8588 (void *)&cmd_vf_rx_vlan_filter_port,
8589 (void *)&cmd_vf_rx_vlan_filter_portid,
8590 (void *)&cmd_vf_rx_vlan_filter_vf,
8591 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8596 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8597 struct cmd_queue_rate_limit_result {
8598 cmdline_fixed_string_t set;
8599 cmdline_fixed_string_t port;
8601 cmdline_fixed_string_t queue;
8603 cmdline_fixed_string_t rate;
8607 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8608 __attribute__((unused)) struct cmdline *cl,
8609 __attribute__((unused)) void *data)
8611 struct cmd_queue_rate_limit_result *res = parsed_result;
8614 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8615 && (strcmp(res->queue, "queue") == 0)
8616 && (strcmp(res->rate, "rate") == 0))
8617 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8620 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8624 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8625 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8627 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8628 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8630 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8631 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8633 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8634 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8636 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8637 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8639 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8640 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8642 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8643 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8646 cmdline_parse_inst_t cmd_queue_rate_limit = {
8647 .f = cmd_queue_rate_limit_parsed,
8649 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8650 "Set rate limit for a queue on port_id",
8652 (void *)&cmd_queue_rate_limit_set,
8653 (void *)&cmd_queue_rate_limit_port,
8654 (void *)&cmd_queue_rate_limit_portnum,
8655 (void *)&cmd_queue_rate_limit_queue,
8656 (void *)&cmd_queue_rate_limit_queuenum,
8657 (void *)&cmd_queue_rate_limit_rate,
8658 (void *)&cmd_queue_rate_limit_ratenum,
8663 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8664 struct cmd_vf_rate_limit_result {
8665 cmdline_fixed_string_t set;
8666 cmdline_fixed_string_t port;
8668 cmdline_fixed_string_t vf;
8670 cmdline_fixed_string_t rate;
8672 cmdline_fixed_string_t q_msk;
8676 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8677 __attribute__((unused)) struct cmdline *cl,
8678 __attribute__((unused)) void *data)
8680 struct cmd_vf_rate_limit_result *res = parsed_result;
8683 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8684 && (strcmp(res->vf, "vf") == 0)
8685 && (strcmp(res->rate, "rate") == 0)
8686 && (strcmp(res->q_msk, "queue_mask") == 0))
8687 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8688 res->rate_num, res->q_msk_val);
8690 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8694 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8695 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8697 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8698 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8700 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8701 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8703 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8704 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8706 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8707 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8709 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8710 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8712 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8713 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8715 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8716 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8717 q_msk, "queue_mask");
8718 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8719 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8722 cmdline_parse_inst_t cmd_vf_rate_limit = {
8723 .f = cmd_vf_rate_limit_parsed,
8725 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8726 "queue_mask <queue_mask_value>: "
8727 "Set rate limit for queues of VF on port_id",
8729 (void *)&cmd_vf_rate_limit_set,
8730 (void *)&cmd_vf_rate_limit_port,
8731 (void *)&cmd_vf_rate_limit_portnum,
8732 (void *)&cmd_vf_rate_limit_vf,
8733 (void *)&cmd_vf_rate_limit_vfnum,
8734 (void *)&cmd_vf_rate_limit_rate,
8735 (void *)&cmd_vf_rate_limit_ratenum,
8736 (void *)&cmd_vf_rate_limit_q_msk,
8737 (void *)&cmd_vf_rate_limit_q_msk_val,
8742 /* *** ADD TUNNEL FILTER OF A PORT *** */
8743 struct cmd_tunnel_filter_result {
8744 cmdline_fixed_string_t cmd;
8745 cmdline_fixed_string_t what;
8747 struct ether_addr outer_mac;
8748 struct ether_addr inner_mac;
8749 cmdline_ipaddr_t ip_value;
8750 uint16_t inner_vlan;
8751 cmdline_fixed_string_t tunnel_type;
8752 cmdline_fixed_string_t filter_type;
8758 cmd_tunnel_filter_parsed(void *parsed_result,
8759 __attribute__((unused)) struct cmdline *cl,
8760 __attribute__((unused)) void *data)
8762 struct cmd_tunnel_filter_result *res = parsed_result;
8763 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8766 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8768 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8769 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8770 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8772 if (res->ip_value.family == AF_INET) {
8773 tunnel_filter_conf.ip_addr.ipv4_addr =
8774 res->ip_value.addr.ipv4.s_addr;
8775 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8777 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8778 &(res->ip_value.addr.ipv6),
8779 sizeof(struct in6_addr));
8780 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8783 if (!strcmp(res->filter_type, "imac-ivlan"))
8784 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8785 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8786 tunnel_filter_conf.filter_type =
8787 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8788 else if (!strcmp(res->filter_type, "imac-tenid"))
8789 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8790 else if (!strcmp(res->filter_type, "imac"))
8791 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8792 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8793 tunnel_filter_conf.filter_type =
8794 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8795 else if (!strcmp(res->filter_type, "oip"))
8796 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8797 else if (!strcmp(res->filter_type, "iip"))
8798 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8800 printf("The filter type is not supported");
8804 if (!strcmp(res->tunnel_type, "vxlan"))
8805 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8806 else if (!strcmp(res->tunnel_type, "nvgre"))
8807 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8808 else if (!strcmp(res->tunnel_type, "ipingre"))
8809 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8811 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8815 tunnel_filter_conf.tenant_id = res->tenant_id;
8816 tunnel_filter_conf.queue_id = res->queue_num;
8817 if (!strcmp(res->what, "add"))
8818 ret = rte_eth_dev_filter_ctrl(res->port_id,
8819 RTE_ETH_FILTER_TUNNEL,
8821 &tunnel_filter_conf);
8823 ret = rte_eth_dev_filter_ctrl(res->port_id,
8824 RTE_ETH_FILTER_TUNNEL,
8825 RTE_ETH_FILTER_DELETE,
8826 &tunnel_filter_conf);
8828 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8832 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8833 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8834 cmd, "tunnel_filter");
8835 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8836 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8838 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8839 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8841 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8842 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8844 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8845 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8847 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8848 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8849 inner_vlan, UINT16);
8850 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8851 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8853 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8854 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8855 tunnel_type, "vxlan#nvgre#ipingre");
8857 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8858 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8859 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8860 "imac#omac-imac-tenid");
8861 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8862 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8864 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8865 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8868 cmdline_parse_inst_t cmd_tunnel_filter = {
8869 .f = cmd_tunnel_filter_parsed,
8871 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8872 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8873 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8874 "<queue_id>: Add/Rm tunnel filter of a port",
8876 (void *)&cmd_tunnel_filter_cmd,
8877 (void *)&cmd_tunnel_filter_what,
8878 (void *)&cmd_tunnel_filter_port_id,
8879 (void *)&cmd_tunnel_filter_outer_mac,
8880 (void *)&cmd_tunnel_filter_inner_mac,
8881 (void *)&cmd_tunnel_filter_ip_value,
8882 (void *)&cmd_tunnel_filter_innner_vlan,
8883 (void *)&cmd_tunnel_filter_tunnel_type,
8884 (void *)&cmd_tunnel_filter_filter_type,
8885 (void *)&cmd_tunnel_filter_tenant_id,
8886 (void *)&cmd_tunnel_filter_queue_num,
8891 /* *** CONFIGURE TUNNEL UDP PORT *** */
8892 struct cmd_tunnel_udp_config {
8893 cmdline_fixed_string_t cmd;
8894 cmdline_fixed_string_t what;
8900 cmd_tunnel_udp_config_parsed(void *parsed_result,
8901 __attribute__((unused)) struct cmdline *cl,
8902 __attribute__((unused)) void *data)
8904 struct cmd_tunnel_udp_config *res = parsed_result;
8905 struct rte_eth_udp_tunnel tunnel_udp;
8908 tunnel_udp.udp_port = res->udp_port;
8910 if (!strcmp(res->cmd, "rx_vxlan_port"))
8911 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8913 if (!strcmp(res->what, "add"))
8914 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8917 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8921 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8924 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8925 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8926 cmd, "rx_vxlan_port");
8927 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8928 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8930 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8931 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8933 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8934 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8937 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8938 .f = cmd_tunnel_udp_config_parsed,
8940 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8941 "Add/Remove a tunneling UDP port filter",
8943 (void *)&cmd_tunnel_udp_config_cmd,
8944 (void *)&cmd_tunnel_udp_config_what,
8945 (void *)&cmd_tunnel_udp_config_udp_port,
8946 (void *)&cmd_tunnel_udp_config_port_id,
8951 struct cmd_config_tunnel_udp_port {
8952 cmdline_fixed_string_t port;
8953 cmdline_fixed_string_t config;
8955 cmdline_fixed_string_t udp_tunnel_port;
8956 cmdline_fixed_string_t action;
8957 cmdline_fixed_string_t tunnel_type;
8962 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8963 __attribute__((unused)) struct cmdline *cl,
8964 __attribute__((unused)) void *data)
8966 struct cmd_config_tunnel_udp_port *res = parsed_result;
8967 struct rte_eth_udp_tunnel tunnel_udp;
8970 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8973 tunnel_udp.udp_port = res->udp_port;
8975 if (!strcmp(res->tunnel_type, "vxlan")) {
8976 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8977 } else if (!strcmp(res->tunnel_type, "geneve")) {
8978 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
8980 printf("Invalid tunnel type\n");
8984 if (!strcmp(res->action, "add"))
8985 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8988 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8992 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
8995 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
8996 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
8998 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
8999 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9001 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9002 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9004 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9005 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9008 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9009 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9011 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9012 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9014 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9015 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9018 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9019 .f = cmd_cfg_tunnel_udp_port_parsed,
9021 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve <udp_port>",
9023 (void *)&cmd_config_tunnel_udp_port_port,
9024 (void *)&cmd_config_tunnel_udp_port_config,
9025 (void *)&cmd_config_tunnel_udp_port_port_id,
9026 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9027 (void *)&cmd_config_tunnel_udp_port_action,
9028 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9029 (void *)&cmd_config_tunnel_udp_port_value,
9034 /* *** GLOBAL CONFIG *** */
9035 struct cmd_global_config_result {
9036 cmdline_fixed_string_t cmd;
9038 cmdline_fixed_string_t cfg_type;
9043 cmd_global_config_parsed(void *parsed_result,
9044 __attribute__((unused)) struct cmdline *cl,
9045 __attribute__((unused)) void *data)
9047 struct cmd_global_config_result *res = parsed_result;
9048 struct rte_eth_global_cfg conf;
9051 memset(&conf, 0, sizeof(conf));
9052 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9053 conf.cfg.gre_key_len = res->len;
9054 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9055 RTE_ETH_FILTER_SET, &conf);
9057 printf("Global config error\n");
9060 cmdline_parse_token_string_t cmd_global_config_cmd =
9061 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9063 cmdline_parse_token_num_t cmd_global_config_port_id =
9064 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9066 cmdline_parse_token_string_t cmd_global_config_type =
9067 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9068 cfg_type, "gre-key-len");
9069 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9070 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9073 cmdline_parse_inst_t cmd_global_config = {
9074 .f = cmd_global_config_parsed,
9075 .data = (void *)NULL,
9076 .help_str = "global_config <port_id> gre-key-len <key_len>",
9078 (void *)&cmd_global_config_cmd,
9079 (void *)&cmd_global_config_port_id,
9080 (void *)&cmd_global_config_type,
9081 (void *)&cmd_global_config_gre_key_len,
9086 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9087 struct cmd_set_mirror_mask_result {
9088 cmdline_fixed_string_t set;
9089 cmdline_fixed_string_t port;
9091 cmdline_fixed_string_t mirror;
9093 cmdline_fixed_string_t what;
9094 cmdline_fixed_string_t value;
9095 cmdline_fixed_string_t dstpool;
9097 cmdline_fixed_string_t on;
9100 cmdline_parse_token_string_t cmd_mirror_mask_set =
9101 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9103 cmdline_parse_token_string_t cmd_mirror_mask_port =
9104 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9106 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9107 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9109 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9110 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9111 mirror, "mirror-rule");
9112 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9113 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9115 cmdline_parse_token_string_t cmd_mirror_mask_what =
9116 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9117 what, "pool-mirror-up#pool-mirror-down"
9119 cmdline_parse_token_string_t cmd_mirror_mask_value =
9120 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9122 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9123 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9124 dstpool, "dst-pool");
9125 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9126 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9128 cmdline_parse_token_string_t cmd_mirror_mask_on =
9129 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9133 cmd_set_mirror_mask_parsed(void *parsed_result,
9134 __attribute__((unused)) struct cmdline *cl,
9135 __attribute__((unused)) void *data)
9138 struct cmd_set_mirror_mask_result *res = parsed_result;
9139 struct rte_eth_mirror_conf mr_conf;
9141 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9143 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9145 mr_conf.dst_pool = res->dstpool_id;
9147 if (!strcmp(res->what, "pool-mirror-up")) {
9148 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9149 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9150 } else if (!strcmp(res->what, "pool-mirror-down")) {
9151 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9152 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9153 } else if (!strcmp(res->what, "vlan-mirror")) {
9154 mr_conf.rule_type = ETH_MIRROR_VLAN;
9155 nb_item = parse_item_list(res->value, "vlan",
9156 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9160 for (i = 0; i < nb_item; i++) {
9161 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
9162 printf("Invalid vlan_id: must be < 4096\n");
9166 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9167 mr_conf.vlan.vlan_mask |= 1ULL << i;
9171 if (!strcmp(res->on, "on"))
9172 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9175 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9178 printf("mirror rule add error: (%s)\n", strerror(-ret));
9181 cmdline_parse_inst_t cmd_set_mirror_mask = {
9182 .f = cmd_set_mirror_mask_parsed,
9184 .help_str = "set port <port_id> mirror-rule <rule_id> "
9185 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9186 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9188 (void *)&cmd_mirror_mask_set,
9189 (void *)&cmd_mirror_mask_port,
9190 (void *)&cmd_mirror_mask_portid,
9191 (void *)&cmd_mirror_mask_mirror,
9192 (void *)&cmd_mirror_mask_ruleid,
9193 (void *)&cmd_mirror_mask_what,
9194 (void *)&cmd_mirror_mask_value,
9195 (void *)&cmd_mirror_mask_dstpool,
9196 (void *)&cmd_mirror_mask_poolid,
9197 (void *)&cmd_mirror_mask_on,
9202 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9203 struct cmd_set_mirror_link_result {
9204 cmdline_fixed_string_t set;
9205 cmdline_fixed_string_t port;
9207 cmdline_fixed_string_t mirror;
9209 cmdline_fixed_string_t what;
9210 cmdline_fixed_string_t dstpool;
9212 cmdline_fixed_string_t on;
9215 cmdline_parse_token_string_t cmd_mirror_link_set =
9216 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9218 cmdline_parse_token_string_t cmd_mirror_link_port =
9219 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9221 cmdline_parse_token_num_t cmd_mirror_link_portid =
9222 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9224 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9225 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9226 mirror, "mirror-rule");
9227 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9228 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9230 cmdline_parse_token_string_t cmd_mirror_link_what =
9231 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9232 what, "uplink-mirror#downlink-mirror");
9233 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9234 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9235 dstpool, "dst-pool");
9236 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9237 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9239 cmdline_parse_token_string_t cmd_mirror_link_on =
9240 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9244 cmd_set_mirror_link_parsed(void *parsed_result,
9245 __attribute__((unused)) struct cmdline *cl,
9246 __attribute__((unused)) void *data)
9249 struct cmd_set_mirror_link_result *res = parsed_result;
9250 struct rte_eth_mirror_conf mr_conf;
9252 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9253 if (!strcmp(res->what, "uplink-mirror"))
9254 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9256 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9258 mr_conf.dst_pool = res->dstpool_id;
9260 if (!strcmp(res->on, "on"))
9261 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9264 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9267 /* check the return value and print it if is < 0 */
9269 printf("mirror rule add error: (%s)\n", strerror(-ret));
9273 cmdline_parse_inst_t cmd_set_mirror_link = {
9274 .f = cmd_set_mirror_link_parsed,
9276 .help_str = "set port <port_id> mirror-rule <rule_id> "
9277 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9279 (void *)&cmd_mirror_link_set,
9280 (void *)&cmd_mirror_link_port,
9281 (void *)&cmd_mirror_link_portid,
9282 (void *)&cmd_mirror_link_mirror,
9283 (void *)&cmd_mirror_link_ruleid,
9284 (void *)&cmd_mirror_link_what,
9285 (void *)&cmd_mirror_link_dstpool,
9286 (void *)&cmd_mirror_link_poolid,
9287 (void *)&cmd_mirror_link_on,
9292 /* *** RESET VM MIRROR RULE *** */
9293 struct cmd_rm_mirror_rule_result {
9294 cmdline_fixed_string_t reset;
9295 cmdline_fixed_string_t port;
9297 cmdline_fixed_string_t mirror;
9301 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9302 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9304 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9305 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9307 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9308 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9310 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9311 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9312 mirror, "mirror-rule");
9313 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9314 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9318 cmd_reset_mirror_rule_parsed(void *parsed_result,
9319 __attribute__((unused)) struct cmdline *cl,
9320 __attribute__((unused)) void *data)
9323 struct cmd_set_mirror_link_result *res = parsed_result;
9325 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9327 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9330 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9331 .f = cmd_reset_mirror_rule_parsed,
9333 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9335 (void *)&cmd_rm_mirror_rule_reset,
9336 (void *)&cmd_rm_mirror_rule_port,
9337 (void *)&cmd_rm_mirror_rule_portid,
9338 (void *)&cmd_rm_mirror_rule_mirror,
9339 (void *)&cmd_rm_mirror_rule_ruleid,
9344 /* ******************************************************************************** */
9346 struct cmd_dump_result {
9347 cmdline_fixed_string_t dump;
9351 dump_struct_sizes(void)
9353 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9354 DUMP_SIZE(struct rte_mbuf);
9355 DUMP_SIZE(struct rte_mempool);
9356 DUMP_SIZE(struct rte_ring);
9360 static void cmd_dump_parsed(void *parsed_result,
9361 __attribute__((unused)) struct cmdline *cl,
9362 __attribute__((unused)) void *data)
9364 struct cmd_dump_result *res = parsed_result;
9366 if (!strcmp(res->dump, "dump_physmem"))
9367 rte_dump_physmem_layout(stdout);
9368 else if (!strcmp(res->dump, "dump_memzone"))
9369 rte_memzone_dump(stdout);
9370 else if (!strcmp(res->dump, "dump_struct_sizes"))
9371 dump_struct_sizes();
9372 else if (!strcmp(res->dump, "dump_ring"))
9373 rte_ring_list_dump(stdout);
9374 else if (!strcmp(res->dump, "dump_mempool"))
9375 rte_mempool_list_dump(stdout);
9376 else if (!strcmp(res->dump, "dump_devargs"))
9377 rte_devargs_dump(stdout);
9378 else if (!strcmp(res->dump, "dump_log_types"))
9379 rte_log_dump(stdout);
9382 cmdline_parse_token_string_t cmd_dump_dump =
9383 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9386 "dump_struct_sizes#"
9392 cmdline_parse_inst_t cmd_dump = {
9393 .f = cmd_dump_parsed, /* function to call */
9394 .data = NULL, /* 2nd arg of func */
9395 .help_str = "Dump status",
9396 .tokens = { /* token list, NULL terminated */
9397 (void *)&cmd_dump_dump,
9402 /* ******************************************************************************** */
9404 struct cmd_dump_one_result {
9405 cmdline_fixed_string_t dump;
9406 cmdline_fixed_string_t name;
9409 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9410 __attribute__((unused)) void *data)
9412 struct cmd_dump_one_result *res = parsed_result;
9414 if (!strcmp(res->dump, "dump_ring")) {
9416 r = rte_ring_lookup(res->name);
9418 cmdline_printf(cl, "Cannot find ring\n");
9421 rte_ring_dump(stdout, r);
9422 } else if (!strcmp(res->dump, "dump_mempool")) {
9423 struct rte_mempool *mp;
9424 mp = rte_mempool_lookup(res->name);
9426 cmdline_printf(cl, "Cannot find mempool\n");
9429 rte_mempool_dump(stdout, mp);
9433 cmdline_parse_token_string_t cmd_dump_one_dump =
9434 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9435 "dump_ring#dump_mempool");
9437 cmdline_parse_token_string_t cmd_dump_one_name =
9438 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9440 cmdline_parse_inst_t cmd_dump_one = {
9441 .f = cmd_dump_one_parsed, /* function to call */
9442 .data = NULL, /* 2nd arg of func */
9443 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9444 .tokens = { /* token list, NULL terminated */
9445 (void *)&cmd_dump_one_dump,
9446 (void *)&cmd_dump_one_name,
9451 /* *** Add/Del syn filter *** */
9452 struct cmd_syn_filter_result {
9453 cmdline_fixed_string_t filter;
9455 cmdline_fixed_string_t ops;
9456 cmdline_fixed_string_t priority;
9457 cmdline_fixed_string_t high;
9458 cmdline_fixed_string_t queue;
9463 cmd_syn_filter_parsed(void *parsed_result,
9464 __attribute__((unused)) struct cmdline *cl,
9465 __attribute__((unused)) void *data)
9467 struct cmd_syn_filter_result *res = parsed_result;
9468 struct rte_eth_syn_filter syn_filter;
9471 ret = rte_eth_dev_filter_supported(res->port_id,
9472 RTE_ETH_FILTER_SYN);
9474 printf("syn filter is not supported on port %u.\n",
9479 memset(&syn_filter, 0, sizeof(syn_filter));
9481 if (!strcmp(res->ops, "add")) {
9482 if (!strcmp(res->high, "high"))
9483 syn_filter.hig_pri = 1;
9485 syn_filter.hig_pri = 0;
9487 syn_filter.queue = res->queue_id;
9488 ret = rte_eth_dev_filter_ctrl(res->port_id,
9493 ret = rte_eth_dev_filter_ctrl(res->port_id,
9495 RTE_ETH_FILTER_DELETE,
9499 printf("syn filter programming error: (%s)\n",
9503 cmdline_parse_token_string_t cmd_syn_filter_filter =
9504 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9505 filter, "syn_filter");
9506 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9507 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9509 cmdline_parse_token_string_t cmd_syn_filter_ops =
9510 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9512 cmdline_parse_token_string_t cmd_syn_filter_priority =
9513 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9514 priority, "priority");
9515 cmdline_parse_token_string_t cmd_syn_filter_high =
9516 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9518 cmdline_parse_token_string_t cmd_syn_filter_queue =
9519 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9521 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9522 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9525 cmdline_parse_inst_t cmd_syn_filter = {
9526 .f = cmd_syn_filter_parsed,
9528 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9529 "<queue_id>: Add/Delete syn filter",
9531 (void *)&cmd_syn_filter_filter,
9532 (void *)&cmd_syn_filter_port_id,
9533 (void *)&cmd_syn_filter_ops,
9534 (void *)&cmd_syn_filter_priority,
9535 (void *)&cmd_syn_filter_high,
9536 (void *)&cmd_syn_filter_queue,
9537 (void *)&cmd_syn_filter_queue_id,
9542 /* *** queue region set *** */
9543 struct cmd_queue_region_result {
9544 cmdline_fixed_string_t set;
9545 cmdline_fixed_string_t port;
9547 cmdline_fixed_string_t cmd;
9548 cmdline_fixed_string_t region;
9550 cmdline_fixed_string_t queue_start_index;
9552 cmdline_fixed_string_t queue_num;
9553 uint8_t queue_num_value;
9557 cmd_queue_region_parsed(void *parsed_result,
9558 __attribute__((unused)) struct cmdline *cl,
9559 __attribute__((unused)) void *data)
9561 struct cmd_queue_region_result *res = parsed_result;
9563 #ifdef RTE_LIBRTE_I40E_PMD
9564 struct rte_pmd_i40e_queue_region_conf region_conf;
9565 enum rte_pmd_i40e_queue_region_op op_type;
9568 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9571 #ifdef RTE_LIBRTE_I40E_PMD
9572 memset(®ion_conf, 0, sizeof(region_conf));
9573 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9574 region_conf.region_id = res->region_id;
9575 region_conf.queue_num = res->queue_num_value;
9576 region_conf.queue_start_index = res->queue_id;
9578 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9579 op_type, ®ion_conf);
9586 printf("function not implemented or supported\n");
9589 printf("queue region config error: (%s)\n", strerror(-ret));
9593 cmdline_parse_token_string_t cmd_queue_region_set =
9594 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9596 cmdline_parse_token_string_t cmd_queue_region_port =
9597 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9598 cmdline_parse_token_num_t cmd_queue_region_port_id =
9599 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9601 cmdline_parse_token_string_t cmd_queue_region_cmd =
9602 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9603 cmd, "queue-region");
9604 cmdline_parse_token_string_t cmd_queue_region_id =
9605 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9606 region, "region_id");
9607 cmdline_parse_token_num_t cmd_queue_region_index =
9608 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9610 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9611 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9612 queue_start_index, "queue_start_index");
9613 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9614 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9616 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9617 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9618 queue_num, "queue_num");
9619 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9620 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9621 queue_num_value, UINT8);
9623 cmdline_parse_inst_t cmd_queue_region = {
9624 .f = cmd_queue_region_parsed,
9626 .help_str = "set port <port_id> queue-region region_id <value> "
9627 "queue_start_index <value> queue_num <value>: Set a queue region",
9629 (void *)&cmd_queue_region_set,
9630 (void *)&cmd_queue_region_port,
9631 (void *)&cmd_queue_region_port_id,
9632 (void *)&cmd_queue_region_cmd,
9633 (void *)&cmd_queue_region_id,
9634 (void *)&cmd_queue_region_index,
9635 (void *)&cmd_queue_region_queue_start_index,
9636 (void *)&cmd_queue_region_queue_id,
9637 (void *)&cmd_queue_region_queue_num,
9638 (void *)&cmd_queue_region_queue_num_value,
9643 /* *** queue region and flowtype set *** */
9644 struct cmd_region_flowtype_result {
9645 cmdline_fixed_string_t set;
9646 cmdline_fixed_string_t port;
9648 cmdline_fixed_string_t cmd;
9649 cmdline_fixed_string_t region;
9651 cmdline_fixed_string_t flowtype;
9652 uint8_t flowtype_id;
9656 cmd_region_flowtype_parsed(void *parsed_result,
9657 __attribute__((unused)) struct cmdline *cl,
9658 __attribute__((unused)) void *data)
9660 struct cmd_region_flowtype_result *res = parsed_result;
9662 #ifdef RTE_LIBRTE_I40E_PMD
9663 struct rte_pmd_i40e_queue_region_conf region_conf;
9664 enum rte_pmd_i40e_queue_region_op op_type;
9667 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9670 #ifdef RTE_LIBRTE_I40E_PMD
9671 memset(®ion_conf, 0, sizeof(region_conf));
9673 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9674 region_conf.region_id = res->region_id;
9675 region_conf.hw_flowtype = res->flowtype_id;
9677 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9678 op_type, ®ion_conf);
9685 printf("function not implemented or supported\n");
9688 printf("region flowtype config error: (%s)\n", strerror(-ret));
9692 cmdline_parse_token_string_t cmd_region_flowtype_set =
9693 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9695 cmdline_parse_token_string_t cmd_region_flowtype_port =
9696 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9698 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9699 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9701 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9702 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9703 cmd, "queue-region");
9704 cmdline_parse_token_string_t cmd_region_flowtype_index =
9705 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9706 region, "region_id");
9707 cmdline_parse_token_num_t cmd_region_flowtype_id =
9708 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9710 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9711 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9712 flowtype, "flowtype");
9713 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9714 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9715 flowtype_id, UINT8);
9716 cmdline_parse_inst_t cmd_region_flowtype = {
9717 .f = cmd_region_flowtype_parsed,
9719 .help_str = "set port <port_id> queue-region region_id <value> "
9720 "flowtype <value>: Set a flowtype region index",
9722 (void *)&cmd_region_flowtype_set,
9723 (void *)&cmd_region_flowtype_port,
9724 (void *)&cmd_region_flowtype_port_index,
9725 (void *)&cmd_region_flowtype_cmd,
9726 (void *)&cmd_region_flowtype_index,
9727 (void *)&cmd_region_flowtype_id,
9728 (void *)&cmd_region_flowtype_flow_index,
9729 (void *)&cmd_region_flowtype_flow_id,
9734 /* *** User Priority (UP) to queue region (region_id) set *** */
9735 struct cmd_user_priority_region_result {
9736 cmdline_fixed_string_t set;
9737 cmdline_fixed_string_t port;
9739 cmdline_fixed_string_t cmd;
9740 cmdline_fixed_string_t user_priority;
9741 uint8_t user_priority_id;
9742 cmdline_fixed_string_t region;
9747 cmd_user_priority_region_parsed(void *parsed_result,
9748 __attribute__((unused)) struct cmdline *cl,
9749 __attribute__((unused)) void *data)
9751 struct cmd_user_priority_region_result *res = parsed_result;
9753 #ifdef RTE_LIBRTE_I40E_PMD
9754 struct rte_pmd_i40e_queue_region_conf region_conf;
9755 enum rte_pmd_i40e_queue_region_op op_type;
9758 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9761 #ifdef RTE_LIBRTE_I40E_PMD
9762 memset(®ion_conf, 0, sizeof(region_conf));
9763 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9764 region_conf.user_priority = res->user_priority_id;
9765 region_conf.region_id = res->region_id;
9767 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9768 op_type, ®ion_conf);
9775 printf("function not implemented or supported\n");
9778 printf("user_priority region config error: (%s)\n",
9783 cmdline_parse_token_string_t cmd_user_priority_region_set =
9784 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9786 cmdline_parse_token_string_t cmd_user_priority_region_port =
9787 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9789 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9790 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9792 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9793 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9794 cmd, "queue-region");
9795 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9796 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9797 user_priority, "UP");
9798 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9799 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9800 user_priority_id, UINT8);
9801 cmdline_parse_token_string_t cmd_user_priority_region_region =
9802 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9803 region, "region_id");
9804 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9805 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9808 cmdline_parse_inst_t cmd_user_priority_region = {
9809 .f = cmd_user_priority_region_parsed,
9811 .help_str = "set port <port_id> queue-region UP <value> "
9812 "region_id <value>: Set the mapping of User Priority (UP) "
9813 "to queue region (region_id) ",
9815 (void *)&cmd_user_priority_region_set,
9816 (void *)&cmd_user_priority_region_port,
9817 (void *)&cmd_user_priority_region_port_index,
9818 (void *)&cmd_user_priority_region_cmd,
9819 (void *)&cmd_user_priority_region_UP,
9820 (void *)&cmd_user_priority_region_UP_id,
9821 (void *)&cmd_user_priority_region_region,
9822 (void *)&cmd_user_priority_region_region_id,
9827 /* *** flush all queue region related configuration *** */
9828 struct cmd_flush_queue_region_result {
9829 cmdline_fixed_string_t set;
9830 cmdline_fixed_string_t port;
9832 cmdline_fixed_string_t cmd;
9833 cmdline_fixed_string_t flush;
9834 cmdline_fixed_string_t what;
9838 cmd_flush_queue_region_parsed(void *parsed_result,
9839 __attribute__((unused)) struct cmdline *cl,
9840 __attribute__((unused)) void *data)
9842 struct cmd_flush_queue_region_result *res = parsed_result;
9844 #ifdef RTE_LIBRTE_I40E_PMD
9845 struct rte_pmd_i40e_queue_region_conf region_conf;
9846 enum rte_pmd_i40e_queue_region_op op_type;
9849 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9852 #ifdef RTE_LIBRTE_I40E_PMD
9853 memset(®ion_conf, 0, sizeof(region_conf));
9855 if (strcmp(res->what, "on") == 0)
9856 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9858 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9860 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9861 op_type, ®ion_conf);
9868 printf("function not implemented or supported\n");
9871 printf("queue region config flush error: (%s)\n",
9876 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9877 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9879 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9880 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9882 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9883 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9885 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9886 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9887 cmd, "queue-region");
9888 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9889 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9891 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9892 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9895 cmdline_parse_inst_t cmd_flush_queue_region = {
9896 .f = cmd_flush_queue_region_parsed,
9898 .help_str = "set port <port_id> queue-region flush on|off"
9899 ": flush all queue region related configuration",
9901 (void *)&cmd_flush_queue_region_set,
9902 (void *)&cmd_flush_queue_region_port,
9903 (void *)&cmd_flush_queue_region_port_index,
9904 (void *)&cmd_flush_queue_region_cmd,
9905 (void *)&cmd_flush_queue_region_flush,
9906 (void *)&cmd_flush_queue_region_what,
9911 /* *** get all queue region related configuration info *** */
9912 struct cmd_show_queue_region_info {
9913 cmdline_fixed_string_t show;
9914 cmdline_fixed_string_t port;
9916 cmdline_fixed_string_t cmd;
9920 cmd_show_queue_region_info_parsed(void *parsed_result,
9921 __attribute__((unused)) struct cmdline *cl,
9922 __attribute__((unused)) void *data)
9924 struct cmd_show_queue_region_info *res = parsed_result;
9926 #ifdef RTE_LIBRTE_I40E_PMD
9927 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9928 enum rte_pmd_i40e_queue_region_op op_type;
9931 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9934 #ifdef RTE_LIBRTE_I40E_PMD
9935 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9937 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9939 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9940 op_type, &rte_pmd_regions);
9942 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9949 printf("function not implemented or supported\n");
9952 printf("queue region config info show error: (%s)\n",
9957 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9958 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9960 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9961 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9963 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9964 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9966 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9967 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9968 cmd, "queue-region");
9970 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9971 .f = cmd_show_queue_region_info_parsed,
9973 .help_str = "show port <port_id> queue-region"
9974 ": show all queue region related configuration info",
9976 (void *)&cmd_show_queue_region_info_get,
9977 (void *)&cmd_show_queue_region_info_port,
9978 (void *)&cmd_show_queue_region_info_port_index,
9979 (void *)&cmd_show_queue_region_info_cmd,
9984 /* *** ADD/REMOVE A 2tuple FILTER *** */
9985 struct cmd_2tuple_filter_result {
9986 cmdline_fixed_string_t filter;
9988 cmdline_fixed_string_t ops;
9989 cmdline_fixed_string_t dst_port;
9990 uint16_t dst_port_value;
9991 cmdline_fixed_string_t protocol;
9992 uint8_t protocol_value;
9993 cmdline_fixed_string_t mask;
9995 cmdline_fixed_string_t tcp_flags;
9996 uint8_t tcp_flags_value;
9997 cmdline_fixed_string_t priority;
9998 uint8_t priority_value;
9999 cmdline_fixed_string_t queue;
10004 cmd_2tuple_filter_parsed(void *parsed_result,
10005 __attribute__((unused)) struct cmdline *cl,
10006 __attribute__((unused)) void *data)
10008 struct rte_eth_ntuple_filter filter;
10009 struct cmd_2tuple_filter_result *res = parsed_result;
10012 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10014 printf("ntuple filter is not supported on port %u.\n",
10019 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10021 filter.flags = RTE_2TUPLE_FLAGS;
10022 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10023 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10024 filter.proto = res->protocol_value;
10025 filter.priority = res->priority_value;
10026 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10027 printf("nonzero tcp_flags is only meaningful"
10028 " when protocol is TCP.\n");
10031 if (res->tcp_flags_value > TCP_FLAG_ALL) {
10032 printf("invalid TCP flags.\n");
10036 if (res->tcp_flags_value != 0) {
10037 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10038 filter.tcp_flags = res->tcp_flags_value;
10041 /* need convert to big endian. */
10042 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10043 filter.queue = res->queue_id;
10045 if (!strcmp(res->ops, "add"))
10046 ret = rte_eth_dev_filter_ctrl(res->port_id,
10047 RTE_ETH_FILTER_NTUPLE,
10048 RTE_ETH_FILTER_ADD,
10051 ret = rte_eth_dev_filter_ctrl(res->port_id,
10052 RTE_ETH_FILTER_NTUPLE,
10053 RTE_ETH_FILTER_DELETE,
10056 printf("2tuple filter programming error: (%s)\n",
10061 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10062 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10063 filter, "2tuple_filter");
10064 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10065 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10067 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10068 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10070 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10071 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10072 dst_port, "dst_port");
10073 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10074 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10075 dst_port_value, UINT16);
10076 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10077 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10078 protocol, "protocol");
10079 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10080 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10081 protocol_value, UINT8);
10082 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10083 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10085 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10086 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10088 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10089 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10090 tcp_flags, "tcp_flags");
10091 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10092 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10093 tcp_flags_value, UINT8);
10094 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10095 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10096 priority, "priority");
10097 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10098 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10099 priority_value, UINT8);
10100 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10101 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10103 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10104 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10107 cmdline_parse_inst_t cmd_2tuple_filter = {
10108 .f = cmd_2tuple_filter_parsed,
10110 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10111 "<value> mask <value> tcp_flags <value> priority <value> queue "
10112 "<queue_id>: Add a 2tuple filter",
10114 (void *)&cmd_2tuple_filter_filter,
10115 (void *)&cmd_2tuple_filter_port_id,
10116 (void *)&cmd_2tuple_filter_ops,
10117 (void *)&cmd_2tuple_filter_dst_port,
10118 (void *)&cmd_2tuple_filter_dst_port_value,
10119 (void *)&cmd_2tuple_filter_protocol,
10120 (void *)&cmd_2tuple_filter_protocol_value,
10121 (void *)&cmd_2tuple_filter_mask,
10122 (void *)&cmd_2tuple_filter_mask_value,
10123 (void *)&cmd_2tuple_filter_tcp_flags,
10124 (void *)&cmd_2tuple_filter_tcp_flags_value,
10125 (void *)&cmd_2tuple_filter_priority,
10126 (void *)&cmd_2tuple_filter_priority_value,
10127 (void *)&cmd_2tuple_filter_queue,
10128 (void *)&cmd_2tuple_filter_queue_id,
10133 /* *** ADD/REMOVE A 5tuple FILTER *** */
10134 struct cmd_5tuple_filter_result {
10135 cmdline_fixed_string_t filter;
10137 cmdline_fixed_string_t ops;
10138 cmdline_fixed_string_t dst_ip;
10139 cmdline_ipaddr_t dst_ip_value;
10140 cmdline_fixed_string_t src_ip;
10141 cmdline_ipaddr_t src_ip_value;
10142 cmdline_fixed_string_t dst_port;
10143 uint16_t dst_port_value;
10144 cmdline_fixed_string_t src_port;
10145 uint16_t src_port_value;
10146 cmdline_fixed_string_t protocol;
10147 uint8_t protocol_value;
10148 cmdline_fixed_string_t mask;
10149 uint8_t mask_value;
10150 cmdline_fixed_string_t tcp_flags;
10151 uint8_t tcp_flags_value;
10152 cmdline_fixed_string_t priority;
10153 uint8_t priority_value;
10154 cmdline_fixed_string_t queue;
10159 cmd_5tuple_filter_parsed(void *parsed_result,
10160 __attribute__((unused)) struct cmdline *cl,
10161 __attribute__((unused)) void *data)
10163 struct rte_eth_ntuple_filter filter;
10164 struct cmd_5tuple_filter_result *res = parsed_result;
10167 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10169 printf("ntuple filter is not supported on port %u.\n",
10174 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10176 filter.flags = RTE_5TUPLE_FLAGS;
10177 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10178 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10179 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10180 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10181 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10182 filter.proto = res->protocol_value;
10183 filter.priority = res->priority_value;
10184 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10185 printf("nonzero tcp_flags is only meaningful"
10186 " when protocol is TCP.\n");
10189 if (res->tcp_flags_value > TCP_FLAG_ALL) {
10190 printf("invalid TCP flags.\n");
10194 if (res->tcp_flags_value != 0) {
10195 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10196 filter.tcp_flags = res->tcp_flags_value;
10199 if (res->dst_ip_value.family == AF_INET)
10200 /* no need to convert, already big endian. */
10201 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10203 if (filter.dst_ip_mask == 0) {
10204 printf("can not support ipv6 involved compare.\n");
10210 if (res->src_ip_value.family == AF_INET)
10211 /* no need to convert, already big endian. */
10212 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10214 if (filter.src_ip_mask == 0) {
10215 printf("can not support ipv6 involved compare.\n");
10220 /* need convert to big endian. */
10221 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10222 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10223 filter.queue = res->queue_id;
10225 if (!strcmp(res->ops, "add"))
10226 ret = rte_eth_dev_filter_ctrl(res->port_id,
10227 RTE_ETH_FILTER_NTUPLE,
10228 RTE_ETH_FILTER_ADD,
10231 ret = rte_eth_dev_filter_ctrl(res->port_id,
10232 RTE_ETH_FILTER_NTUPLE,
10233 RTE_ETH_FILTER_DELETE,
10236 printf("5tuple filter programming error: (%s)\n",
10240 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10241 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10242 filter, "5tuple_filter");
10243 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10244 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10246 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10247 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10249 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10250 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10252 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10253 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10255 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10256 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10258 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10259 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10261 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10262 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10263 dst_port, "dst_port");
10264 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10265 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10266 dst_port_value, UINT16);
10267 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10268 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10269 src_port, "src_port");
10270 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10271 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10272 src_port_value, UINT16);
10273 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10274 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10275 protocol, "protocol");
10276 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10277 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10278 protocol_value, UINT8);
10279 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10280 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10282 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10283 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10285 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10286 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10287 tcp_flags, "tcp_flags");
10288 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10289 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10290 tcp_flags_value, UINT8);
10291 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10292 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10293 priority, "priority");
10294 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10295 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10296 priority_value, UINT8);
10297 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10298 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10300 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10301 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10304 cmdline_parse_inst_t cmd_5tuple_filter = {
10305 .f = cmd_5tuple_filter_parsed,
10307 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10308 "src_ip <value> dst_port <value> src_port <value> "
10309 "protocol <value> mask <value> tcp_flags <value> "
10310 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10312 (void *)&cmd_5tuple_filter_filter,
10313 (void *)&cmd_5tuple_filter_port_id,
10314 (void *)&cmd_5tuple_filter_ops,
10315 (void *)&cmd_5tuple_filter_dst_ip,
10316 (void *)&cmd_5tuple_filter_dst_ip_value,
10317 (void *)&cmd_5tuple_filter_src_ip,
10318 (void *)&cmd_5tuple_filter_src_ip_value,
10319 (void *)&cmd_5tuple_filter_dst_port,
10320 (void *)&cmd_5tuple_filter_dst_port_value,
10321 (void *)&cmd_5tuple_filter_src_port,
10322 (void *)&cmd_5tuple_filter_src_port_value,
10323 (void *)&cmd_5tuple_filter_protocol,
10324 (void *)&cmd_5tuple_filter_protocol_value,
10325 (void *)&cmd_5tuple_filter_mask,
10326 (void *)&cmd_5tuple_filter_mask_value,
10327 (void *)&cmd_5tuple_filter_tcp_flags,
10328 (void *)&cmd_5tuple_filter_tcp_flags_value,
10329 (void *)&cmd_5tuple_filter_priority,
10330 (void *)&cmd_5tuple_filter_priority_value,
10331 (void *)&cmd_5tuple_filter_queue,
10332 (void *)&cmd_5tuple_filter_queue_id,
10337 /* *** ADD/REMOVE A flex FILTER *** */
10338 struct cmd_flex_filter_result {
10339 cmdline_fixed_string_t filter;
10340 cmdline_fixed_string_t ops;
10342 cmdline_fixed_string_t len;
10344 cmdline_fixed_string_t bytes;
10345 cmdline_fixed_string_t bytes_value;
10346 cmdline_fixed_string_t mask;
10347 cmdline_fixed_string_t mask_value;
10348 cmdline_fixed_string_t priority;
10349 uint8_t priority_value;
10350 cmdline_fixed_string_t queue;
10354 static int xdigit2val(unsigned char c)
10359 else if (isupper(c))
10360 val = c - 'A' + 10;
10362 val = c - 'a' + 10;
10367 cmd_flex_filter_parsed(void *parsed_result,
10368 __attribute__((unused)) struct cmdline *cl,
10369 __attribute__((unused)) void *data)
10372 struct rte_eth_flex_filter filter;
10373 struct cmd_flex_filter_result *res = parsed_result;
10374 char *bytes_ptr, *mask_ptr;
10375 uint16_t len, i, j = 0;
10380 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10381 printf("the len exceed the max length 128\n");
10384 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10385 filter.len = res->len_value;
10386 filter.priority = res->priority_value;
10387 filter.queue = res->queue_id;
10388 bytes_ptr = res->bytes_value;
10389 mask_ptr = res->mask_value;
10391 /* translate bytes string to array. */
10392 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10393 (bytes_ptr[1] == 'X')))
10395 len = strnlen(bytes_ptr, res->len_value * 2);
10396 if (len == 0 || (len % 8 != 0)) {
10397 printf("please check len and bytes input\n");
10400 for (i = 0; i < len; i++) {
10402 if (isxdigit(c) == 0) {
10403 /* invalid characters. */
10404 printf("invalid input\n");
10407 val = xdigit2val(c);
10410 filter.bytes[j] = byte;
10411 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10418 /* translate mask string to uint8_t array. */
10419 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10420 (mask_ptr[1] == 'X')))
10422 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10424 printf("invalid input\n");
10429 for (i = 0; i < len; i++) {
10431 if (isxdigit(c) == 0) {
10432 /* invalid characters. */
10433 printf("invalid input\n");
10436 val = xdigit2val(c);
10439 filter.mask[j] = byte;
10440 printf("mask[%d]:%02x ", j, filter.mask[j]);
10448 if (!strcmp(res->ops, "add"))
10449 ret = rte_eth_dev_filter_ctrl(res->port_id,
10450 RTE_ETH_FILTER_FLEXIBLE,
10451 RTE_ETH_FILTER_ADD,
10454 ret = rte_eth_dev_filter_ctrl(res->port_id,
10455 RTE_ETH_FILTER_FLEXIBLE,
10456 RTE_ETH_FILTER_DELETE,
10460 printf("flex filter setting error: (%s)\n", strerror(-ret));
10463 cmdline_parse_token_string_t cmd_flex_filter_filter =
10464 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10465 filter, "flex_filter");
10466 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10467 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10469 cmdline_parse_token_string_t cmd_flex_filter_ops =
10470 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10472 cmdline_parse_token_string_t cmd_flex_filter_len =
10473 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10475 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10476 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10478 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10479 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10481 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10482 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10483 bytes_value, NULL);
10484 cmdline_parse_token_string_t cmd_flex_filter_mask =
10485 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10487 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10488 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10490 cmdline_parse_token_string_t cmd_flex_filter_priority =
10491 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10492 priority, "priority");
10493 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10494 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10495 priority_value, UINT8);
10496 cmdline_parse_token_string_t cmd_flex_filter_queue =
10497 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10499 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10500 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10502 cmdline_parse_inst_t cmd_flex_filter = {
10503 .f = cmd_flex_filter_parsed,
10505 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10506 "<value> mask <value> priority <value> queue <queue_id>: "
10507 "Add/Del a flex filter",
10509 (void *)&cmd_flex_filter_filter,
10510 (void *)&cmd_flex_filter_port_id,
10511 (void *)&cmd_flex_filter_ops,
10512 (void *)&cmd_flex_filter_len,
10513 (void *)&cmd_flex_filter_len_value,
10514 (void *)&cmd_flex_filter_bytes,
10515 (void *)&cmd_flex_filter_bytes_value,
10516 (void *)&cmd_flex_filter_mask,
10517 (void *)&cmd_flex_filter_mask_value,
10518 (void *)&cmd_flex_filter_priority,
10519 (void *)&cmd_flex_filter_priority_value,
10520 (void *)&cmd_flex_filter_queue,
10521 (void *)&cmd_flex_filter_queue_id,
10526 /* *** Filters Control *** */
10528 /* *** deal with ethertype filter *** */
10529 struct cmd_ethertype_filter_result {
10530 cmdline_fixed_string_t filter;
10532 cmdline_fixed_string_t ops;
10533 cmdline_fixed_string_t mac;
10534 struct ether_addr mac_addr;
10535 cmdline_fixed_string_t ethertype;
10536 uint16_t ethertype_value;
10537 cmdline_fixed_string_t drop;
10538 cmdline_fixed_string_t queue;
10542 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10543 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10544 filter, "ethertype_filter");
10545 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10546 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10548 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10549 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10551 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10552 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10553 mac, "mac_addr#mac_ignr");
10554 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10555 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10557 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10558 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10559 ethertype, "ethertype");
10560 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10561 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10562 ethertype_value, UINT16);
10563 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10564 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10566 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10567 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10569 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10570 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10574 cmd_ethertype_filter_parsed(void *parsed_result,
10575 __attribute__((unused)) struct cmdline *cl,
10576 __attribute__((unused)) void *data)
10578 struct cmd_ethertype_filter_result *res = parsed_result;
10579 struct rte_eth_ethertype_filter filter;
10582 ret = rte_eth_dev_filter_supported(res->port_id,
10583 RTE_ETH_FILTER_ETHERTYPE);
10585 printf("ethertype filter is not supported on port %u.\n",
10590 memset(&filter, 0, sizeof(filter));
10591 if (!strcmp(res->mac, "mac_addr")) {
10592 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10593 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10594 sizeof(struct ether_addr));
10596 if (!strcmp(res->drop, "drop"))
10597 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10598 filter.ether_type = res->ethertype_value;
10599 filter.queue = res->queue_id;
10601 if (!strcmp(res->ops, "add"))
10602 ret = rte_eth_dev_filter_ctrl(res->port_id,
10603 RTE_ETH_FILTER_ETHERTYPE,
10604 RTE_ETH_FILTER_ADD,
10607 ret = rte_eth_dev_filter_ctrl(res->port_id,
10608 RTE_ETH_FILTER_ETHERTYPE,
10609 RTE_ETH_FILTER_DELETE,
10612 printf("ethertype filter programming error: (%s)\n",
10616 cmdline_parse_inst_t cmd_ethertype_filter = {
10617 .f = cmd_ethertype_filter_parsed,
10619 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10620 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10621 "Add or delete an ethertype filter entry",
10623 (void *)&cmd_ethertype_filter_filter,
10624 (void *)&cmd_ethertype_filter_port_id,
10625 (void *)&cmd_ethertype_filter_ops,
10626 (void *)&cmd_ethertype_filter_mac,
10627 (void *)&cmd_ethertype_filter_mac_addr,
10628 (void *)&cmd_ethertype_filter_ethertype,
10629 (void *)&cmd_ethertype_filter_ethertype_value,
10630 (void *)&cmd_ethertype_filter_drop,
10631 (void *)&cmd_ethertype_filter_queue,
10632 (void *)&cmd_ethertype_filter_queue_id,
10637 /* *** deal with flow director filter *** */
10638 struct cmd_flow_director_result {
10639 cmdline_fixed_string_t flow_director_filter;
10641 cmdline_fixed_string_t mode;
10642 cmdline_fixed_string_t mode_value;
10643 cmdline_fixed_string_t ops;
10644 cmdline_fixed_string_t flow;
10645 cmdline_fixed_string_t flow_type;
10646 cmdline_fixed_string_t ether;
10647 uint16_t ether_type;
10648 cmdline_fixed_string_t src;
10649 cmdline_ipaddr_t ip_src;
10651 cmdline_fixed_string_t dst;
10652 cmdline_ipaddr_t ip_dst;
10654 cmdline_fixed_string_t verify_tag;
10655 uint32_t verify_tag_value;
10656 cmdline_fixed_string_t tos;
10658 cmdline_fixed_string_t proto;
10659 uint8_t proto_value;
10660 cmdline_fixed_string_t ttl;
10662 cmdline_fixed_string_t vlan;
10663 uint16_t vlan_value;
10664 cmdline_fixed_string_t flexbytes;
10665 cmdline_fixed_string_t flexbytes_value;
10666 cmdline_fixed_string_t pf_vf;
10667 cmdline_fixed_string_t drop;
10668 cmdline_fixed_string_t queue;
10670 cmdline_fixed_string_t fd_id;
10671 uint32_t fd_id_value;
10672 cmdline_fixed_string_t mac;
10673 struct ether_addr mac_addr;
10674 cmdline_fixed_string_t tunnel;
10675 cmdline_fixed_string_t tunnel_type;
10676 cmdline_fixed_string_t tunnel_id;
10677 uint32_t tunnel_id_value;
10678 cmdline_fixed_string_t packet;
10683 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10686 const char *p, *p0 = q_arg;
10688 unsigned long int_fld;
10689 char *str_fld[max_num];
10694 p = strchr(p0, '(');
10698 p0 = strchr(p, ')');
10703 if (size >= sizeof(s))
10706 snprintf(s, sizeof(s), "%.*s", size, p);
10707 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10708 if (ret < 0 || ret > max_num)
10710 for (i = 0; i < ret; i++) {
10712 int_fld = strtoul(str_fld[i], &end, 0);
10713 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10715 flexbytes[i] = (uint8_t)int_fld;
10721 str2flowtype(char *string)
10724 static const struct {
10727 } flowtype_str[] = {
10728 {"raw", RTE_ETH_FLOW_RAW},
10729 {"ipv4", RTE_ETH_FLOW_IPV4},
10730 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10731 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10732 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10733 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10734 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10735 {"ipv6", RTE_ETH_FLOW_IPV6},
10736 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10737 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10738 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10739 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10740 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10741 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10744 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10745 if (!strcmp(flowtype_str[i].str, string))
10746 return flowtype_str[i].type;
10749 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10750 return (uint16_t)atoi(string);
10752 return RTE_ETH_FLOW_UNKNOWN;
10755 static enum rte_eth_fdir_tunnel_type
10756 str2fdir_tunneltype(char *string)
10760 static const struct {
10762 enum rte_eth_fdir_tunnel_type type;
10763 } tunneltype_str[] = {
10764 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10765 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10768 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10769 if (!strcmp(tunneltype_str[i].str, string))
10770 return tunneltype_str[i].type;
10772 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10775 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10777 if ((ip_addr).family == AF_INET) \
10778 (ip) = (ip_addr).addr.ipv4.s_addr; \
10780 printf("invalid parameter.\n"); \
10785 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10787 if ((ip_addr).family == AF_INET6) \
10788 rte_memcpy(&(ip), \
10789 &((ip_addr).addr.ipv6), \
10790 sizeof(struct in6_addr)); \
10792 printf("invalid parameter.\n"); \
10798 cmd_flow_director_filter_parsed(void *parsed_result,
10799 __attribute__((unused)) struct cmdline *cl,
10800 __attribute__((unused)) void *data)
10802 struct cmd_flow_director_result *res = parsed_result;
10803 struct rte_eth_fdir_filter entry;
10804 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10806 unsigned long vf_id;
10809 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10811 printf("flow director is not supported on port %u.\n",
10815 memset(flexbytes, 0, sizeof(flexbytes));
10816 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10818 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10819 if (strcmp(res->mode_value, "MAC-VLAN")) {
10820 printf("Please set mode to MAC-VLAN.\n");
10823 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10824 if (strcmp(res->mode_value, "Tunnel")) {
10825 printf("Please set mode to Tunnel.\n");
10829 if (!strcmp(res->mode_value, "raw")) {
10830 #ifdef RTE_LIBRTE_I40E_PMD
10831 struct rte_pmd_i40e_flow_type_mapping
10832 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10833 struct rte_pmd_i40e_pkt_template_conf conf;
10834 uint16_t flow_type = str2flowtype(res->flow_type);
10835 uint16_t i, port = res->port_id;
10838 memset(&conf, 0, sizeof(conf));
10840 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10841 printf("Invalid flow type specified.\n");
10844 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10848 if (mapping[flow_type].pctype == 0ULL) {
10849 printf("Invalid flow type specified.\n");
10852 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10853 if (mapping[flow_type].pctype & (1ULL << i)) {
10854 conf.input.pctype = i;
10859 conf.input.packet = open_file(res->filepath,
10860 &conf.input.length);
10861 if (!conf.input.packet)
10863 if (!strcmp(res->drop, "drop"))
10864 conf.action.behavior =
10865 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10867 conf.action.behavior =
10868 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10869 conf.action.report_status =
10870 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10871 conf.action.rx_queue = res->queue_id;
10872 conf.soft_id = res->fd_id_value;
10873 add = strcmp(res->ops, "del") ? 1 : 0;
10874 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10878 printf("flow director config error: (%s)\n",
10880 close_file(conf.input.packet);
10883 } else if (strcmp(res->mode_value, "IP")) {
10884 printf("Please set mode to IP or raw.\n");
10887 entry.input.flow_type = str2flowtype(res->flow_type);
10890 ret = parse_flexbytes(res->flexbytes_value,
10892 RTE_ETH_FDIR_MAX_FLEXLEN);
10894 printf("error: Cannot parse flexbytes input.\n");
10898 switch (entry.input.flow_type) {
10899 case RTE_ETH_FLOW_FRAG_IPV4:
10900 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10901 entry.input.flow.ip4_flow.proto = res->proto_value;
10903 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10904 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10905 IPV4_ADDR_TO_UINT(res->ip_dst,
10906 entry.input.flow.ip4_flow.dst_ip);
10907 IPV4_ADDR_TO_UINT(res->ip_src,
10908 entry.input.flow.ip4_flow.src_ip);
10909 entry.input.flow.ip4_flow.tos = res->tos_value;
10910 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10911 /* need convert to big endian. */
10912 entry.input.flow.udp4_flow.dst_port =
10913 rte_cpu_to_be_16(res->port_dst);
10914 entry.input.flow.udp4_flow.src_port =
10915 rte_cpu_to_be_16(res->port_src);
10917 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10918 IPV4_ADDR_TO_UINT(res->ip_dst,
10919 entry.input.flow.sctp4_flow.ip.dst_ip);
10920 IPV4_ADDR_TO_UINT(res->ip_src,
10921 entry.input.flow.sctp4_flow.ip.src_ip);
10922 entry.input.flow.ip4_flow.tos = res->tos_value;
10923 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10924 /* need convert to big endian. */
10925 entry.input.flow.sctp4_flow.dst_port =
10926 rte_cpu_to_be_16(res->port_dst);
10927 entry.input.flow.sctp4_flow.src_port =
10928 rte_cpu_to_be_16(res->port_src);
10929 entry.input.flow.sctp4_flow.verify_tag =
10930 rte_cpu_to_be_32(res->verify_tag_value);
10932 case RTE_ETH_FLOW_FRAG_IPV6:
10933 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10934 entry.input.flow.ipv6_flow.proto = res->proto_value;
10936 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10937 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10938 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10939 entry.input.flow.ipv6_flow.dst_ip);
10940 IPV6_ADDR_TO_ARRAY(res->ip_src,
10941 entry.input.flow.ipv6_flow.src_ip);
10942 entry.input.flow.ipv6_flow.tc = res->tos_value;
10943 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10944 /* need convert to big endian. */
10945 entry.input.flow.udp6_flow.dst_port =
10946 rte_cpu_to_be_16(res->port_dst);
10947 entry.input.flow.udp6_flow.src_port =
10948 rte_cpu_to_be_16(res->port_src);
10950 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10951 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10952 entry.input.flow.sctp6_flow.ip.dst_ip);
10953 IPV6_ADDR_TO_ARRAY(res->ip_src,
10954 entry.input.flow.sctp6_flow.ip.src_ip);
10955 entry.input.flow.ipv6_flow.tc = res->tos_value;
10956 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10957 /* need convert to big endian. */
10958 entry.input.flow.sctp6_flow.dst_port =
10959 rte_cpu_to_be_16(res->port_dst);
10960 entry.input.flow.sctp6_flow.src_port =
10961 rte_cpu_to_be_16(res->port_src);
10962 entry.input.flow.sctp6_flow.verify_tag =
10963 rte_cpu_to_be_32(res->verify_tag_value);
10965 case RTE_ETH_FLOW_L2_PAYLOAD:
10966 entry.input.flow.l2_flow.ether_type =
10967 rte_cpu_to_be_16(res->ether_type);
10973 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10974 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10976 sizeof(struct ether_addr));
10978 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10979 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10981 sizeof(struct ether_addr));
10982 entry.input.flow.tunnel_flow.tunnel_type =
10983 str2fdir_tunneltype(res->tunnel_type);
10984 entry.input.flow.tunnel_flow.tunnel_id =
10985 rte_cpu_to_be_32(res->tunnel_id_value);
10988 rte_memcpy(entry.input.flow_ext.flexbytes,
10990 RTE_ETH_FDIR_MAX_FLEXLEN);
10992 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10994 entry.action.flex_off = 0; /*use 0 by default */
10995 if (!strcmp(res->drop, "drop"))
10996 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10998 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11000 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11001 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11002 if (!strcmp(res->pf_vf, "pf"))
11003 entry.input.flow_ext.is_vf = 0;
11004 else if (!strncmp(res->pf_vf, "vf", 2)) {
11005 struct rte_eth_dev_info dev_info;
11007 memset(&dev_info, 0, sizeof(dev_info));
11008 rte_eth_dev_info_get(res->port_id, &dev_info);
11010 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11011 if (errno != 0 || *end != '\0' ||
11012 vf_id >= dev_info.max_vfs) {
11013 printf("invalid parameter %s.\n", res->pf_vf);
11016 entry.input.flow_ext.is_vf = 1;
11017 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11019 printf("invalid parameter %s.\n", res->pf_vf);
11024 /* set to report FD ID by default */
11025 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11026 entry.action.rx_queue = res->queue_id;
11027 entry.soft_id = res->fd_id_value;
11028 if (!strcmp(res->ops, "add"))
11029 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11030 RTE_ETH_FILTER_ADD, &entry);
11031 else if (!strcmp(res->ops, "del"))
11032 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11033 RTE_ETH_FILTER_DELETE, &entry);
11035 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11036 RTE_ETH_FILTER_UPDATE, &entry);
11038 printf("flow director programming error: (%s)\n",
11042 cmdline_parse_token_string_t cmd_flow_director_filter =
11043 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11044 flow_director_filter, "flow_director_filter");
11045 cmdline_parse_token_num_t cmd_flow_director_port_id =
11046 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11048 cmdline_parse_token_string_t cmd_flow_director_ops =
11049 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11050 ops, "add#del#update");
11051 cmdline_parse_token_string_t cmd_flow_director_flow =
11052 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11054 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11055 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11057 cmdline_parse_token_string_t cmd_flow_director_ether =
11058 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11060 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11061 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11062 ether_type, UINT16);
11063 cmdline_parse_token_string_t cmd_flow_director_src =
11064 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11066 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11067 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11069 cmdline_parse_token_num_t cmd_flow_director_port_src =
11070 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11072 cmdline_parse_token_string_t cmd_flow_director_dst =
11073 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11075 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11076 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11078 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11079 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11081 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11082 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11083 verify_tag, "verify_tag");
11084 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11085 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11086 verify_tag_value, UINT32);
11087 cmdline_parse_token_string_t cmd_flow_director_tos =
11088 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11090 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11091 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11093 cmdline_parse_token_string_t cmd_flow_director_proto =
11094 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11096 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11097 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11098 proto_value, UINT8);
11099 cmdline_parse_token_string_t cmd_flow_director_ttl =
11100 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11102 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11103 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11105 cmdline_parse_token_string_t cmd_flow_director_vlan =
11106 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11108 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11109 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11110 vlan_value, UINT16);
11111 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11112 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11113 flexbytes, "flexbytes");
11114 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11115 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11116 flexbytes_value, NULL);
11117 cmdline_parse_token_string_t cmd_flow_director_drop =
11118 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11120 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11121 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11123 cmdline_parse_token_string_t cmd_flow_director_queue =
11124 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11126 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11127 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11129 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11130 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11132 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11133 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11134 fd_id_value, UINT32);
11136 cmdline_parse_token_string_t cmd_flow_director_mode =
11137 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11139 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11140 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11142 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11143 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11144 mode_value, "MAC-VLAN");
11145 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11146 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11147 mode_value, "Tunnel");
11148 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11149 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11150 mode_value, "raw");
11151 cmdline_parse_token_string_t cmd_flow_director_mac =
11152 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11154 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11155 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11157 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11158 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11160 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11161 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11162 tunnel_type, "NVGRE#VxLAN");
11163 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11164 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11165 tunnel_id, "tunnel-id");
11166 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11167 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11168 tunnel_id_value, UINT32);
11169 cmdline_parse_token_string_t cmd_flow_director_packet =
11170 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11172 cmdline_parse_token_string_t cmd_flow_director_filepath =
11173 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11176 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11177 .f = cmd_flow_director_filter_parsed,
11179 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11180 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11181 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11182 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11183 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11184 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11185 "fd_id <fd_id_value>: "
11186 "Add or delete an ip flow director entry on NIC",
11188 (void *)&cmd_flow_director_filter,
11189 (void *)&cmd_flow_director_port_id,
11190 (void *)&cmd_flow_director_mode,
11191 (void *)&cmd_flow_director_mode_ip,
11192 (void *)&cmd_flow_director_ops,
11193 (void *)&cmd_flow_director_flow,
11194 (void *)&cmd_flow_director_flow_type,
11195 (void *)&cmd_flow_director_src,
11196 (void *)&cmd_flow_director_ip_src,
11197 (void *)&cmd_flow_director_dst,
11198 (void *)&cmd_flow_director_ip_dst,
11199 (void *)&cmd_flow_director_tos,
11200 (void *)&cmd_flow_director_tos_value,
11201 (void *)&cmd_flow_director_proto,
11202 (void *)&cmd_flow_director_proto_value,
11203 (void *)&cmd_flow_director_ttl,
11204 (void *)&cmd_flow_director_ttl_value,
11205 (void *)&cmd_flow_director_vlan,
11206 (void *)&cmd_flow_director_vlan_value,
11207 (void *)&cmd_flow_director_flexbytes,
11208 (void *)&cmd_flow_director_flexbytes_value,
11209 (void *)&cmd_flow_director_drop,
11210 (void *)&cmd_flow_director_pf_vf,
11211 (void *)&cmd_flow_director_queue,
11212 (void *)&cmd_flow_director_queue_id,
11213 (void *)&cmd_flow_director_fd_id,
11214 (void *)&cmd_flow_director_fd_id_value,
11219 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11220 .f = cmd_flow_director_filter_parsed,
11222 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11223 "director entry on NIC",
11225 (void *)&cmd_flow_director_filter,
11226 (void *)&cmd_flow_director_port_id,
11227 (void *)&cmd_flow_director_mode,
11228 (void *)&cmd_flow_director_mode_ip,
11229 (void *)&cmd_flow_director_ops,
11230 (void *)&cmd_flow_director_flow,
11231 (void *)&cmd_flow_director_flow_type,
11232 (void *)&cmd_flow_director_src,
11233 (void *)&cmd_flow_director_ip_src,
11234 (void *)&cmd_flow_director_port_src,
11235 (void *)&cmd_flow_director_dst,
11236 (void *)&cmd_flow_director_ip_dst,
11237 (void *)&cmd_flow_director_port_dst,
11238 (void *)&cmd_flow_director_tos,
11239 (void *)&cmd_flow_director_tos_value,
11240 (void *)&cmd_flow_director_ttl,
11241 (void *)&cmd_flow_director_ttl_value,
11242 (void *)&cmd_flow_director_vlan,
11243 (void *)&cmd_flow_director_vlan_value,
11244 (void *)&cmd_flow_director_flexbytes,
11245 (void *)&cmd_flow_director_flexbytes_value,
11246 (void *)&cmd_flow_director_drop,
11247 (void *)&cmd_flow_director_pf_vf,
11248 (void *)&cmd_flow_director_queue,
11249 (void *)&cmd_flow_director_queue_id,
11250 (void *)&cmd_flow_director_fd_id,
11251 (void *)&cmd_flow_director_fd_id_value,
11256 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11257 .f = cmd_flow_director_filter_parsed,
11259 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11260 "director entry on NIC",
11262 (void *)&cmd_flow_director_filter,
11263 (void *)&cmd_flow_director_port_id,
11264 (void *)&cmd_flow_director_mode,
11265 (void *)&cmd_flow_director_mode_ip,
11266 (void *)&cmd_flow_director_ops,
11267 (void *)&cmd_flow_director_flow,
11268 (void *)&cmd_flow_director_flow_type,
11269 (void *)&cmd_flow_director_src,
11270 (void *)&cmd_flow_director_ip_src,
11271 (void *)&cmd_flow_director_port_src,
11272 (void *)&cmd_flow_director_dst,
11273 (void *)&cmd_flow_director_ip_dst,
11274 (void *)&cmd_flow_director_port_dst,
11275 (void *)&cmd_flow_director_verify_tag,
11276 (void *)&cmd_flow_director_verify_tag_value,
11277 (void *)&cmd_flow_director_tos,
11278 (void *)&cmd_flow_director_tos_value,
11279 (void *)&cmd_flow_director_ttl,
11280 (void *)&cmd_flow_director_ttl_value,
11281 (void *)&cmd_flow_director_vlan,
11282 (void *)&cmd_flow_director_vlan_value,
11283 (void *)&cmd_flow_director_flexbytes,
11284 (void *)&cmd_flow_director_flexbytes_value,
11285 (void *)&cmd_flow_director_drop,
11286 (void *)&cmd_flow_director_pf_vf,
11287 (void *)&cmd_flow_director_queue,
11288 (void *)&cmd_flow_director_queue_id,
11289 (void *)&cmd_flow_director_fd_id,
11290 (void *)&cmd_flow_director_fd_id_value,
11295 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11296 .f = cmd_flow_director_filter_parsed,
11298 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11299 "director entry on NIC",
11301 (void *)&cmd_flow_director_filter,
11302 (void *)&cmd_flow_director_port_id,
11303 (void *)&cmd_flow_director_mode,
11304 (void *)&cmd_flow_director_mode_ip,
11305 (void *)&cmd_flow_director_ops,
11306 (void *)&cmd_flow_director_flow,
11307 (void *)&cmd_flow_director_flow_type,
11308 (void *)&cmd_flow_director_ether,
11309 (void *)&cmd_flow_director_ether_type,
11310 (void *)&cmd_flow_director_flexbytes,
11311 (void *)&cmd_flow_director_flexbytes_value,
11312 (void *)&cmd_flow_director_drop,
11313 (void *)&cmd_flow_director_pf_vf,
11314 (void *)&cmd_flow_director_queue,
11315 (void *)&cmd_flow_director_queue_id,
11316 (void *)&cmd_flow_director_fd_id,
11317 (void *)&cmd_flow_director_fd_id_value,
11322 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11323 .f = cmd_flow_director_filter_parsed,
11325 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11326 "director entry on NIC",
11328 (void *)&cmd_flow_director_filter,
11329 (void *)&cmd_flow_director_port_id,
11330 (void *)&cmd_flow_director_mode,
11331 (void *)&cmd_flow_director_mode_mac_vlan,
11332 (void *)&cmd_flow_director_ops,
11333 (void *)&cmd_flow_director_mac,
11334 (void *)&cmd_flow_director_mac_addr,
11335 (void *)&cmd_flow_director_vlan,
11336 (void *)&cmd_flow_director_vlan_value,
11337 (void *)&cmd_flow_director_flexbytes,
11338 (void *)&cmd_flow_director_flexbytes_value,
11339 (void *)&cmd_flow_director_drop,
11340 (void *)&cmd_flow_director_queue,
11341 (void *)&cmd_flow_director_queue_id,
11342 (void *)&cmd_flow_director_fd_id,
11343 (void *)&cmd_flow_director_fd_id_value,
11348 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11349 .f = cmd_flow_director_filter_parsed,
11351 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11352 "director entry on NIC",
11354 (void *)&cmd_flow_director_filter,
11355 (void *)&cmd_flow_director_port_id,
11356 (void *)&cmd_flow_director_mode,
11357 (void *)&cmd_flow_director_mode_tunnel,
11358 (void *)&cmd_flow_director_ops,
11359 (void *)&cmd_flow_director_mac,
11360 (void *)&cmd_flow_director_mac_addr,
11361 (void *)&cmd_flow_director_vlan,
11362 (void *)&cmd_flow_director_vlan_value,
11363 (void *)&cmd_flow_director_tunnel,
11364 (void *)&cmd_flow_director_tunnel_type,
11365 (void *)&cmd_flow_director_tunnel_id,
11366 (void *)&cmd_flow_director_tunnel_id_value,
11367 (void *)&cmd_flow_director_flexbytes,
11368 (void *)&cmd_flow_director_flexbytes_value,
11369 (void *)&cmd_flow_director_drop,
11370 (void *)&cmd_flow_director_queue,
11371 (void *)&cmd_flow_director_queue_id,
11372 (void *)&cmd_flow_director_fd_id,
11373 (void *)&cmd_flow_director_fd_id_value,
11378 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11379 .f = cmd_flow_director_filter_parsed,
11381 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11382 "director entry on NIC",
11384 (void *)&cmd_flow_director_filter,
11385 (void *)&cmd_flow_director_port_id,
11386 (void *)&cmd_flow_director_mode,
11387 (void *)&cmd_flow_director_mode_raw,
11388 (void *)&cmd_flow_director_ops,
11389 (void *)&cmd_flow_director_flow,
11390 (void *)&cmd_flow_director_flow_type,
11391 (void *)&cmd_flow_director_drop,
11392 (void *)&cmd_flow_director_queue,
11393 (void *)&cmd_flow_director_queue_id,
11394 (void *)&cmd_flow_director_fd_id,
11395 (void *)&cmd_flow_director_fd_id_value,
11396 (void *)&cmd_flow_director_packet,
11397 (void *)&cmd_flow_director_filepath,
11402 struct cmd_flush_flow_director_result {
11403 cmdline_fixed_string_t flush_flow_director;
11407 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11408 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11409 flush_flow_director, "flush_flow_director");
11410 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11411 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11415 cmd_flush_flow_director_parsed(void *parsed_result,
11416 __attribute__((unused)) struct cmdline *cl,
11417 __attribute__((unused)) void *data)
11419 struct cmd_flow_director_result *res = parsed_result;
11422 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11424 printf("flow director is not supported on port %u.\n",
11429 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11430 RTE_ETH_FILTER_FLUSH, NULL);
11432 printf("flow director table flushing error: (%s)\n",
11436 cmdline_parse_inst_t cmd_flush_flow_director = {
11437 .f = cmd_flush_flow_director_parsed,
11439 .help_str = "flush_flow_director <port_id>: "
11440 "Flush all flow director entries of a device on NIC",
11442 (void *)&cmd_flush_flow_director_flush,
11443 (void *)&cmd_flush_flow_director_port_id,
11448 /* *** deal with flow director mask *** */
11449 struct cmd_flow_director_mask_result {
11450 cmdline_fixed_string_t flow_director_mask;
11452 cmdline_fixed_string_t mode;
11453 cmdline_fixed_string_t mode_value;
11454 cmdline_fixed_string_t vlan;
11455 uint16_t vlan_mask;
11456 cmdline_fixed_string_t src_mask;
11457 cmdline_ipaddr_t ipv4_src;
11458 cmdline_ipaddr_t ipv6_src;
11460 cmdline_fixed_string_t dst_mask;
11461 cmdline_ipaddr_t ipv4_dst;
11462 cmdline_ipaddr_t ipv6_dst;
11464 cmdline_fixed_string_t mac;
11465 uint8_t mac_addr_byte_mask;
11466 cmdline_fixed_string_t tunnel_id;
11467 uint32_t tunnel_id_mask;
11468 cmdline_fixed_string_t tunnel_type;
11469 uint8_t tunnel_type_mask;
11473 cmd_flow_director_mask_parsed(void *parsed_result,
11474 __attribute__((unused)) struct cmdline *cl,
11475 __attribute__((unused)) void *data)
11477 struct cmd_flow_director_mask_result *res = parsed_result;
11478 struct rte_eth_fdir_masks *mask;
11479 struct rte_port *port;
11481 port = &ports[res->port_id];
11482 /** Check if the port is not started **/
11483 if (port->port_status != RTE_PORT_STOPPED) {
11484 printf("Please stop port %d first\n", res->port_id);
11488 mask = &port->dev_conf.fdir_conf.mask;
11490 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11491 if (strcmp(res->mode_value, "MAC-VLAN")) {
11492 printf("Please set mode to MAC-VLAN.\n");
11496 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11497 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11498 if (strcmp(res->mode_value, "Tunnel")) {
11499 printf("Please set mode to Tunnel.\n");
11503 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11504 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11505 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11506 mask->tunnel_type_mask = res->tunnel_type_mask;
11508 if (strcmp(res->mode_value, "IP")) {
11509 printf("Please set mode to IP.\n");
11513 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11514 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11515 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11516 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11517 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11518 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11519 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11522 cmd_reconfig_device_queue(res->port_id, 1, 1);
11525 cmdline_parse_token_string_t cmd_flow_director_mask =
11526 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11527 flow_director_mask, "flow_director_mask");
11528 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11529 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11531 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11532 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11534 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11535 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11536 vlan_mask, UINT16);
11537 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11538 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11539 src_mask, "src_mask");
11540 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11541 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11543 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11544 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11546 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11547 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11549 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11550 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11551 dst_mask, "dst_mask");
11552 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11553 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11555 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11556 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11558 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11559 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11562 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11563 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11565 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11566 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11568 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11569 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11570 mode_value, "MAC-VLAN");
11571 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11572 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11573 mode_value, "Tunnel");
11574 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11575 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11577 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11578 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11579 mac_addr_byte_mask, UINT8);
11580 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11581 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11582 tunnel_type, "tunnel-type");
11583 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11584 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11585 tunnel_type_mask, UINT8);
11586 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11587 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11588 tunnel_id, "tunnel-id");
11589 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11590 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11591 tunnel_id_mask, UINT32);
11593 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11594 .f = cmd_flow_director_mask_parsed,
11596 .help_str = "flow_director_mask ... : "
11597 "Set IP mode flow director's mask on NIC",
11599 (void *)&cmd_flow_director_mask,
11600 (void *)&cmd_flow_director_mask_port_id,
11601 (void *)&cmd_flow_director_mask_mode,
11602 (void *)&cmd_flow_director_mask_mode_ip,
11603 (void *)&cmd_flow_director_mask_vlan,
11604 (void *)&cmd_flow_director_mask_vlan_value,
11605 (void *)&cmd_flow_director_mask_src,
11606 (void *)&cmd_flow_director_mask_ipv4_src,
11607 (void *)&cmd_flow_director_mask_ipv6_src,
11608 (void *)&cmd_flow_director_mask_port_src,
11609 (void *)&cmd_flow_director_mask_dst,
11610 (void *)&cmd_flow_director_mask_ipv4_dst,
11611 (void *)&cmd_flow_director_mask_ipv6_dst,
11612 (void *)&cmd_flow_director_mask_port_dst,
11617 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11618 .f = cmd_flow_director_mask_parsed,
11620 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11621 "flow director's mask on NIC",
11623 (void *)&cmd_flow_director_mask,
11624 (void *)&cmd_flow_director_mask_port_id,
11625 (void *)&cmd_flow_director_mask_mode,
11626 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11627 (void *)&cmd_flow_director_mask_vlan,
11628 (void *)&cmd_flow_director_mask_vlan_value,
11633 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11634 .f = cmd_flow_director_mask_parsed,
11636 .help_str = "flow_director_mask ... : Set tunnel mode "
11637 "flow director's mask on NIC",
11639 (void *)&cmd_flow_director_mask,
11640 (void *)&cmd_flow_director_mask_port_id,
11641 (void *)&cmd_flow_director_mask_mode,
11642 (void *)&cmd_flow_director_mask_mode_tunnel,
11643 (void *)&cmd_flow_director_mask_vlan,
11644 (void *)&cmd_flow_director_mask_vlan_value,
11645 (void *)&cmd_flow_director_mask_mac,
11646 (void *)&cmd_flow_director_mask_mac_value,
11647 (void *)&cmd_flow_director_mask_tunnel_type,
11648 (void *)&cmd_flow_director_mask_tunnel_type_value,
11649 (void *)&cmd_flow_director_mask_tunnel_id,
11650 (void *)&cmd_flow_director_mask_tunnel_id_value,
11655 /* *** deal with flow director mask on flexible payload *** */
11656 struct cmd_flow_director_flex_mask_result {
11657 cmdline_fixed_string_t flow_director_flexmask;
11659 cmdline_fixed_string_t flow;
11660 cmdline_fixed_string_t flow_type;
11661 cmdline_fixed_string_t mask;
11665 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11666 __attribute__((unused)) struct cmdline *cl,
11667 __attribute__((unused)) void *data)
11669 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11670 struct rte_eth_fdir_info fdir_info;
11671 struct rte_eth_fdir_flex_mask flex_mask;
11672 struct rte_port *port;
11673 uint64_t flow_type_mask;
11677 port = &ports[res->port_id];
11678 /** Check if the port is not started **/
11679 if (port->port_status != RTE_PORT_STOPPED) {
11680 printf("Please stop port %d first\n", res->port_id);
11684 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11685 ret = parse_flexbytes(res->mask,
11687 RTE_ETH_FDIR_MAX_FLEXLEN);
11689 printf("error: Cannot parse mask input.\n");
11693 memset(&fdir_info, 0, sizeof(fdir_info));
11694 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11695 RTE_ETH_FILTER_INFO, &fdir_info);
11697 printf("Cannot get FDir filter info\n");
11701 if (!strcmp(res->flow_type, "none")) {
11702 /* means don't specify the flow type */
11703 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11704 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11705 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11706 0, sizeof(struct rte_eth_fdir_flex_mask));
11707 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11708 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11710 sizeof(struct rte_eth_fdir_flex_mask));
11711 cmd_reconfig_device_queue(res->port_id, 1, 1);
11714 flow_type_mask = fdir_info.flow_types_mask[0];
11715 if (!strcmp(res->flow_type, "all")) {
11716 if (!flow_type_mask) {
11717 printf("No flow type supported\n");
11720 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11721 if (flow_type_mask & (1ULL << i)) {
11722 flex_mask.flow_type = i;
11723 fdir_set_flex_mask(res->port_id, &flex_mask);
11726 cmd_reconfig_device_queue(res->port_id, 1, 1);
11729 flex_mask.flow_type = str2flowtype(res->flow_type);
11730 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11731 printf("Flow type %s not supported on port %d\n",
11732 res->flow_type, res->port_id);
11735 fdir_set_flex_mask(res->port_id, &flex_mask);
11736 cmd_reconfig_device_queue(res->port_id, 1, 1);
11739 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11740 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11741 flow_director_flexmask,
11742 "flow_director_flex_mask");
11743 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11744 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11746 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11747 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11749 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11750 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11751 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11752 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11753 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11754 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11757 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11758 .f = cmd_flow_director_flex_mask_parsed,
11760 .help_str = "flow_director_flex_mask ... : "
11761 "Set flow director's flex mask on NIC",
11763 (void *)&cmd_flow_director_flexmask,
11764 (void *)&cmd_flow_director_flexmask_port_id,
11765 (void *)&cmd_flow_director_flexmask_flow,
11766 (void *)&cmd_flow_director_flexmask_flow_type,
11767 (void *)&cmd_flow_director_flexmask_mask,
11772 /* *** deal with flow director flexible payload configuration *** */
11773 struct cmd_flow_director_flexpayload_result {
11774 cmdline_fixed_string_t flow_director_flexpayload;
11776 cmdline_fixed_string_t payload_layer;
11777 cmdline_fixed_string_t payload_cfg;
11781 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11784 const char *p, *p0 = q_arg;
11786 unsigned long int_fld;
11787 char *str_fld[max_num];
11792 p = strchr(p0, '(');
11796 p0 = strchr(p, ')');
11801 if (size >= sizeof(s))
11804 snprintf(s, sizeof(s), "%.*s", size, p);
11805 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11806 if (ret < 0 || ret > max_num)
11808 for (i = 0; i < ret; i++) {
11810 int_fld = strtoul(str_fld[i], &end, 0);
11811 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11813 offsets[i] = (uint16_t)int_fld;
11819 cmd_flow_director_flxpld_parsed(void *parsed_result,
11820 __attribute__((unused)) struct cmdline *cl,
11821 __attribute__((unused)) void *data)
11823 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11824 struct rte_eth_flex_payload_cfg flex_cfg;
11825 struct rte_port *port;
11828 port = &ports[res->port_id];
11829 /** Check if the port is not started **/
11830 if (port->port_status != RTE_PORT_STOPPED) {
11831 printf("Please stop port %d first\n", res->port_id);
11835 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11837 if (!strcmp(res->payload_layer, "raw"))
11838 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11839 else if (!strcmp(res->payload_layer, "l2"))
11840 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11841 else if (!strcmp(res->payload_layer, "l3"))
11842 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11843 else if (!strcmp(res->payload_layer, "l4"))
11844 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11846 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11847 RTE_ETH_FDIR_MAX_FLEXLEN);
11849 printf("error: Cannot parse flex payload input.\n");
11853 fdir_set_flex_payload(res->port_id, &flex_cfg);
11854 cmd_reconfig_device_queue(res->port_id, 1, 1);
11857 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11858 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11859 flow_director_flexpayload,
11860 "flow_director_flex_payload");
11861 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11862 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11864 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11865 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11866 payload_layer, "raw#l2#l3#l4");
11867 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11868 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11869 payload_cfg, NULL);
11871 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11872 .f = cmd_flow_director_flxpld_parsed,
11874 .help_str = "flow_director_flexpayload ... : "
11875 "Set flow director's flex payload on NIC",
11877 (void *)&cmd_flow_director_flexpayload,
11878 (void *)&cmd_flow_director_flexpayload_port_id,
11879 (void *)&cmd_flow_director_flexpayload_payload_layer,
11880 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11885 /* Generic flow interface command. */
11886 extern cmdline_parse_inst_t cmd_flow;
11888 /* *** Classification Filters Control *** */
11889 /* *** Get symmetric hash enable per port *** */
11890 struct cmd_get_sym_hash_ena_per_port_result {
11891 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11896 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11897 __rte_unused struct cmdline *cl,
11898 __rte_unused void *data)
11900 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11901 struct rte_eth_hash_filter_info info;
11904 if (rte_eth_dev_filter_supported(res->port_id,
11905 RTE_ETH_FILTER_HASH) < 0) {
11906 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11911 memset(&info, 0, sizeof(info));
11912 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11913 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11914 RTE_ETH_FILTER_GET, &info);
11917 printf("Cannot get symmetric hash enable per port "
11918 "on port %u\n", res->port_id);
11922 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11923 "enabled" : "disabled", res->port_id);
11926 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11927 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11928 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11929 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11930 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11933 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11934 .f = cmd_get_sym_hash_per_port_parsed,
11936 .help_str = "get_sym_hash_ena_per_port <port_id>",
11938 (void *)&cmd_get_sym_hash_ena_per_port_all,
11939 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11944 /* *** Set symmetric hash enable per port *** */
11945 struct cmd_set_sym_hash_ena_per_port_result {
11946 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11947 cmdline_fixed_string_t enable;
11952 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11953 __rte_unused struct cmdline *cl,
11954 __rte_unused void *data)
11956 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11957 struct rte_eth_hash_filter_info info;
11960 if (rte_eth_dev_filter_supported(res->port_id,
11961 RTE_ETH_FILTER_HASH) < 0) {
11962 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11967 memset(&info, 0, sizeof(info));
11968 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11969 if (!strcmp(res->enable, "enable"))
11970 info.info.enable = 1;
11971 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11972 RTE_ETH_FILTER_SET, &info);
11974 printf("Cannot set symmetric hash enable per port on "
11975 "port %u\n", res->port_id);
11978 printf("Symmetric hash has been set to %s on port %u\n",
11979 res->enable, res->port_id);
11982 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11983 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11984 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11985 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11986 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11988 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11989 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11990 enable, "enable#disable");
11992 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11993 .f = cmd_set_sym_hash_per_port_parsed,
11995 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11997 (void *)&cmd_set_sym_hash_ena_per_port_all,
11998 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11999 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12004 /* Get global config of hash function */
12005 struct cmd_get_hash_global_config_result {
12006 cmdline_fixed_string_t get_hash_global_config;
12011 flowtype_to_str(uint16_t ftype)
12017 } ftype_table[] = {
12018 {"ipv4", RTE_ETH_FLOW_IPV4},
12019 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12020 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12021 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12022 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12023 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12024 {"ipv6", RTE_ETH_FLOW_IPV6},
12025 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12026 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12027 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12028 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12029 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12030 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12031 {"port", RTE_ETH_FLOW_PORT},
12032 {"vxlan", RTE_ETH_FLOW_VXLAN},
12033 {"geneve", RTE_ETH_FLOW_GENEVE},
12034 {"nvgre", RTE_ETH_FLOW_NVGRE},
12037 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12038 if (ftype_table[i].ftype == ftype)
12039 return ftype_table[i].str;
12046 cmd_get_hash_global_config_parsed(void *parsed_result,
12047 __rte_unused struct cmdline *cl,
12048 __rte_unused void *data)
12050 struct cmd_get_hash_global_config_result *res = parsed_result;
12051 struct rte_eth_hash_filter_info info;
12052 uint32_t idx, offset;
12057 if (rte_eth_dev_filter_supported(res->port_id,
12058 RTE_ETH_FILTER_HASH) < 0) {
12059 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12064 memset(&info, 0, sizeof(info));
12065 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12066 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12067 RTE_ETH_FILTER_GET, &info);
12069 printf("Cannot get hash global configurations by port %d\n",
12074 switch (info.info.global_conf.hash_func) {
12075 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12076 printf("Hash function is Toeplitz\n");
12078 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12079 printf("Hash function is Simple XOR\n");
12082 printf("Unknown hash function\n");
12086 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12087 idx = i / UINT64_BIT;
12088 offset = i % UINT64_BIT;
12089 if (!(info.info.global_conf.valid_bit_mask[idx] &
12092 str = flowtype_to_str(i);
12095 printf("Symmetric hash is %s globally for flow type %s "
12097 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12098 (1ULL << offset)) ? "enabled" : "disabled"), str,
12103 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12104 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12105 get_hash_global_config, "get_hash_global_config");
12106 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12107 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12110 cmdline_parse_inst_t cmd_get_hash_global_config = {
12111 .f = cmd_get_hash_global_config_parsed,
12113 .help_str = "get_hash_global_config <port_id>",
12115 (void *)&cmd_get_hash_global_config_all,
12116 (void *)&cmd_get_hash_global_config_port_id,
12121 /* Set global config of hash function */
12122 struct cmd_set_hash_global_config_result {
12123 cmdline_fixed_string_t set_hash_global_config;
12125 cmdline_fixed_string_t hash_func;
12126 cmdline_fixed_string_t flow_type;
12127 cmdline_fixed_string_t enable;
12131 cmd_set_hash_global_config_parsed(void *parsed_result,
12132 __rte_unused struct cmdline *cl,
12133 __rte_unused void *data)
12135 struct cmd_set_hash_global_config_result *res = parsed_result;
12136 struct rte_eth_hash_filter_info info;
12137 uint32_t ftype, idx, offset;
12140 if (rte_eth_dev_filter_supported(res->port_id,
12141 RTE_ETH_FILTER_HASH) < 0) {
12142 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12146 memset(&info, 0, sizeof(info));
12147 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12148 if (!strcmp(res->hash_func, "toeplitz"))
12149 info.info.global_conf.hash_func =
12150 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12151 else if (!strcmp(res->hash_func, "simple_xor"))
12152 info.info.global_conf.hash_func =
12153 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12154 else if (!strcmp(res->hash_func, "default"))
12155 info.info.global_conf.hash_func =
12156 RTE_ETH_HASH_FUNCTION_DEFAULT;
12158 ftype = str2flowtype(res->flow_type);
12159 idx = ftype / UINT64_BIT;
12160 offset = ftype % UINT64_BIT;
12161 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12162 if (!strcmp(res->enable, "enable"))
12163 info.info.global_conf.sym_hash_enable_mask[idx] |=
12165 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12166 RTE_ETH_FILTER_SET, &info);
12168 printf("Cannot set global hash configurations by port %d\n",
12171 printf("Global hash configurations have been set "
12172 "successfully by port %d\n", res->port_id);
12175 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12176 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12177 set_hash_global_config, "set_hash_global_config");
12178 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12179 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12181 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12182 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12183 hash_func, "toeplitz#simple_xor#default");
12184 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12185 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12187 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12188 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12189 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12190 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12191 enable, "enable#disable");
12193 cmdline_parse_inst_t cmd_set_hash_global_config = {
12194 .f = cmd_set_hash_global_config_parsed,
12196 .help_str = "set_hash_global_config <port_id> "
12197 "toeplitz|simple_xor|default "
12198 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12199 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12200 "l2_payload enable|disable",
12202 (void *)&cmd_set_hash_global_config_all,
12203 (void *)&cmd_set_hash_global_config_port_id,
12204 (void *)&cmd_set_hash_global_config_hash_func,
12205 (void *)&cmd_set_hash_global_config_flow_type,
12206 (void *)&cmd_set_hash_global_config_enable,
12211 /* Set hash input set */
12212 struct cmd_set_hash_input_set_result {
12213 cmdline_fixed_string_t set_hash_input_set;
12215 cmdline_fixed_string_t flow_type;
12216 cmdline_fixed_string_t inset_field;
12217 cmdline_fixed_string_t select;
12220 static enum rte_eth_input_set_field
12221 str2inset(char *string)
12225 static const struct {
12227 enum rte_eth_input_set_field inset;
12228 } inset_table[] = {
12229 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12230 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12231 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12232 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12233 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12234 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12235 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12236 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12237 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12238 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12239 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12240 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12241 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12242 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12243 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12244 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12245 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12246 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12247 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12248 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12249 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12250 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12251 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12252 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12253 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12254 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12255 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12256 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12257 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12258 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12259 {"none", RTE_ETH_INPUT_SET_NONE},
12262 for (i = 0; i < RTE_DIM(inset_table); i++) {
12263 if (!strcmp(string, inset_table[i].str))
12264 return inset_table[i].inset;
12267 return RTE_ETH_INPUT_SET_UNKNOWN;
12271 cmd_set_hash_input_set_parsed(void *parsed_result,
12272 __rte_unused struct cmdline *cl,
12273 __rte_unused void *data)
12275 struct cmd_set_hash_input_set_result *res = parsed_result;
12276 struct rte_eth_hash_filter_info info;
12278 memset(&info, 0, sizeof(info));
12279 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12280 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12281 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12282 info.info.input_set_conf.inset_size = 1;
12283 if (!strcmp(res->select, "select"))
12284 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12285 else if (!strcmp(res->select, "add"))
12286 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12287 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12288 RTE_ETH_FILTER_SET, &info);
12291 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12292 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12293 set_hash_input_set, "set_hash_input_set");
12294 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12295 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12297 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12298 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12300 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12301 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12303 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12304 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12305 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12306 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12307 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12309 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12310 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12311 select, "select#add");
12313 cmdline_parse_inst_t cmd_set_hash_input_set = {
12314 .f = cmd_set_hash_input_set_parsed,
12316 .help_str = "set_hash_input_set <port_id> "
12317 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12318 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12319 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12320 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12321 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12322 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12323 "fld-7th|fld-8th|none select|add",
12325 (void *)&cmd_set_hash_input_set_cmd,
12326 (void *)&cmd_set_hash_input_set_port_id,
12327 (void *)&cmd_set_hash_input_set_flow_type,
12328 (void *)&cmd_set_hash_input_set_field,
12329 (void *)&cmd_set_hash_input_set_select,
12334 /* Set flow director input set */
12335 struct cmd_set_fdir_input_set_result {
12336 cmdline_fixed_string_t set_fdir_input_set;
12338 cmdline_fixed_string_t flow_type;
12339 cmdline_fixed_string_t inset_field;
12340 cmdline_fixed_string_t select;
12344 cmd_set_fdir_input_set_parsed(void *parsed_result,
12345 __rte_unused struct cmdline *cl,
12346 __rte_unused void *data)
12348 struct cmd_set_fdir_input_set_result *res = parsed_result;
12349 struct rte_eth_fdir_filter_info info;
12351 memset(&info, 0, sizeof(info));
12352 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12353 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12354 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12355 info.info.input_set_conf.inset_size = 1;
12356 if (!strcmp(res->select, "select"))
12357 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12358 else if (!strcmp(res->select, "add"))
12359 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12360 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12361 RTE_ETH_FILTER_SET, &info);
12364 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12365 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12366 set_fdir_input_set, "set_fdir_input_set");
12367 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12368 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12370 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12371 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12373 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12374 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12375 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12376 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12378 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12379 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12380 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12381 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12382 "sctp-veri-tag#none");
12383 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12384 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12385 select, "select#add");
12387 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12388 .f = cmd_set_fdir_input_set_parsed,
12390 .help_str = "set_fdir_input_set <port_id> "
12391 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12392 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12393 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12394 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12395 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12396 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12397 "sctp-veri-tag|none select|add",
12399 (void *)&cmd_set_fdir_input_set_cmd,
12400 (void *)&cmd_set_fdir_input_set_port_id,
12401 (void *)&cmd_set_fdir_input_set_flow_type,
12402 (void *)&cmd_set_fdir_input_set_field,
12403 (void *)&cmd_set_fdir_input_set_select,
12408 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12409 struct cmd_mcast_addr_result {
12410 cmdline_fixed_string_t mcast_addr_cmd;
12411 cmdline_fixed_string_t what;
12413 struct ether_addr mc_addr;
12416 static void cmd_mcast_addr_parsed(void *parsed_result,
12417 __attribute__((unused)) struct cmdline *cl,
12418 __attribute__((unused)) void *data)
12420 struct cmd_mcast_addr_result *res = parsed_result;
12422 if (!is_multicast_ether_addr(&res->mc_addr)) {
12423 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12424 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12425 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12426 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12429 if (strcmp(res->what, "add") == 0)
12430 mcast_addr_add(res->port_num, &res->mc_addr);
12432 mcast_addr_remove(res->port_num, &res->mc_addr);
12435 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12436 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12437 mcast_addr_cmd, "mcast_addr");
12438 cmdline_parse_token_string_t cmd_mcast_addr_what =
12439 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12441 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12442 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12443 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12444 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12446 cmdline_parse_inst_t cmd_mcast_addr = {
12447 .f = cmd_mcast_addr_parsed,
12449 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12450 "Add/Remove multicast MAC address on port_id",
12452 (void *)&cmd_mcast_addr_cmd,
12453 (void *)&cmd_mcast_addr_what,
12454 (void *)&cmd_mcast_addr_portnum,
12455 (void *)&cmd_mcast_addr_addr,
12460 /* l2 tunnel config
12461 * only support E-tag now.
12464 /* Ether type config */
12465 struct cmd_config_l2_tunnel_eth_type_result {
12466 cmdline_fixed_string_t port;
12467 cmdline_fixed_string_t config;
12468 cmdline_fixed_string_t all;
12470 cmdline_fixed_string_t l2_tunnel;
12471 cmdline_fixed_string_t l2_tunnel_type;
12472 cmdline_fixed_string_t eth_type;
12473 uint16_t eth_type_val;
12476 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12477 TOKEN_STRING_INITIALIZER
12478 (struct cmd_config_l2_tunnel_eth_type_result,
12480 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12481 TOKEN_STRING_INITIALIZER
12482 (struct cmd_config_l2_tunnel_eth_type_result,
12484 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12485 TOKEN_STRING_INITIALIZER
12486 (struct cmd_config_l2_tunnel_eth_type_result,
12488 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12489 TOKEN_NUM_INITIALIZER
12490 (struct cmd_config_l2_tunnel_eth_type_result,
12492 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12493 TOKEN_STRING_INITIALIZER
12494 (struct cmd_config_l2_tunnel_eth_type_result,
12495 l2_tunnel, "l2-tunnel");
12496 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12497 TOKEN_STRING_INITIALIZER
12498 (struct cmd_config_l2_tunnel_eth_type_result,
12499 l2_tunnel_type, "E-tag");
12500 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12501 TOKEN_STRING_INITIALIZER
12502 (struct cmd_config_l2_tunnel_eth_type_result,
12503 eth_type, "ether-type");
12504 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12505 TOKEN_NUM_INITIALIZER
12506 (struct cmd_config_l2_tunnel_eth_type_result,
12507 eth_type_val, UINT16);
12509 static enum rte_eth_tunnel_type
12510 str2fdir_l2_tunnel_type(char *string)
12514 static const struct {
12516 enum rte_eth_tunnel_type type;
12517 } l2_tunnel_type_str[] = {
12518 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12521 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12522 if (!strcmp(l2_tunnel_type_str[i].str, string))
12523 return l2_tunnel_type_str[i].type;
12525 return RTE_TUNNEL_TYPE_NONE;
12528 /* ether type config for all ports */
12530 cmd_config_l2_tunnel_eth_type_all_parsed
12531 (void *parsed_result,
12532 __attribute__((unused)) struct cmdline *cl,
12533 __attribute__((unused)) void *data)
12535 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12536 struct rte_eth_l2_tunnel_conf entry;
12539 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12540 entry.ether_type = res->eth_type_val;
12542 RTE_ETH_FOREACH_DEV(pid) {
12543 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12547 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12548 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12550 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12552 (void *)&cmd_config_l2_tunnel_eth_type_port,
12553 (void *)&cmd_config_l2_tunnel_eth_type_config,
12554 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12555 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12556 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12557 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12558 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12563 /* ether type config for a specific port */
12565 cmd_config_l2_tunnel_eth_type_specific_parsed(
12566 void *parsed_result,
12567 __attribute__((unused)) struct cmdline *cl,
12568 __attribute__((unused)) void *data)
12570 struct cmd_config_l2_tunnel_eth_type_result *res =
12572 struct rte_eth_l2_tunnel_conf entry;
12574 if (port_id_is_invalid(res->id, ENABLED_WARN))
12577 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12578 entry.ether_type = res->eth_type_val;
12580 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12583 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12584 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12586 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12588 (void *)&cmd_config_l2_tunnel_eth_type_port,
12589 (void *)&cmd_config_l2_tunnel_eth_type_config,
12590 (void *)&cmd_config_l2_tunnel_eth_type_id,
12591 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12592 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12593 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12594 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12599 /* Enable/disable l2 tunnel */
12600 struct cmd_config_l2_tunnel_en_dis_result {
12601 cmdline_fixed_string_t port;
12602 cmdline_fixed_string_t config;
12603 cmdline_fixed_string_t all;
12605 cmdline_fixed_string_t l2_tunnel;
12606 cmdline_fixed_string_t l2_tunnel_type;
12607 cmdline_fixed_string_t en_dis;
12610 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12611 TOKEN_STRING_INITIALIZER
12612 (struct cmd_config_l2_tunnel_en_dis_result,
12614 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12615 TOKEN_STRING_INITIALIZER
12616 (struct cmd_config_l2_tunnel_en_dis_result,
12618 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12619 TOKEN_STRING_INITIALIZER
12620 (struct cmd_config_l2_tunnel_en_dis_result,
12622 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12623 TOKEN_NUM_INITIALIZER
12624 (struct cmd_config_l2_tunnel_en_dis_result,
12626 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12627 TOKEN_STRING_INITIALIZER
12628 (struct cmd_config_l2_tunnel_en_dis_result,
12629 l2_tunnel, "l2-tunnel");
12630 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12631 TOKEN_STRING_INITIALIZER
12632 (struct cmd_config_l2_tunnel_en_dis_result,
12633 l2_tunnel_type, "E-tag");
12634 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12635 TOKEN_STRING_INITIALIZER
12636 (struct cmd_config_l2_tunnel_en_dis_result,
12637 en_dis, "enable#disable");
12639 /* enable/disable l2 tunnel for all ports */
12641 cmd_config_l2_tunnel_en_dis_all_parsed(
12642 void *parsed_result,
12643 __attribute__((unused)) struct cmdline *cl,
12644 __attribute__((unused)) void *data)
12646 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12647 struct rte_eth_l2_tunnel_conf entry;
12651 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12653 if (!strcmp("enable", res->en_dis))
12658 RTE_ETH_FOREACH_DEV(pid) {
12659 rte_eth_dev_l2_tunnel_offload_set(pid,
12661 ETH_L2_TUNNEL_ENABLE_MASK,
12666 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12667 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12669 .help_str = "port config all l2-tunnel E-tag enable|disable",
12671 (void *)&cmd_config_l2_tunnel_en_dis_port,
12672 (void *)&cmd_config_l2_tunnel_en_dis_config,
12673 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12674 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12675 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12676 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12681 /* enable/disable l2 tunnel for a port */
12683 cmd_config_l2_tunnel_en_dis_specific_parsed(
12684 void *parsed_result,
12685 __attribute__((unused)) struct cmdline *cl,
12686 __attribute__((unused)) void *data)
12688 struct cmd_config_l2_tunnel_en_dis_result *res =
12690 struct rte_eth_l2_tunnel_conf entry;
12692 if (port_id_is_invalid(res->id, ENABLED_WARN))
12695 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12697 if (!strcmp("enable", res->en_dis))
12698 rte_eth_dev_l2_tunnel_offload_set(res->id,
12700 ETH_L2_TUNNEL_ENABLE_MASK,
12703 rte_eth_dev_l2_tunnel_offload_set(res->id,
12705 ETH_L2_TUNNEL_ENABLE_MASK,
12709 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12710 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12712 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12714 (void *)&cmd_config_l2_tunnel_en_dis_port,
12715 (void *)&cmd_config_l2_tunnel_en_dis_config,
12716 (void *)&cmd_config_l2_tunnel_en_dis_id,
12717 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12718 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12719 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12724 /* E-tag configuration */
12726 /* Common result structure for all E-tag configuration */
12727 struct cmd_config_e_tag_result {
12728 cmdline_fixed_string_t e_tag;
12729 cmdline_fixed_string_t set;
12730 cmdline_fixed_string_t insertion;
12731 cmdline_fixed_string_t stripping;
12732 cmdline_fixed_string_t forwarding;
12733 cmdline_fixed_string_t filter;
12734 cmdline_fixed_string_t add;
12735 cmdline_fixed_string_t del;
12736 cmdline_fixed_string_t on;
12737 cmdline_fixed_string_t off;
12738 cmdline_fixed_string_t on_off;
12739 cmdline_fixed_string_t port_tag_id;
12740 uint32_t port_tag_id_val;
12741 cmdline_fixed_string_t e_tag_id;
12742 uint16_t e_tag_id_val;
12743 cmdline_fixed_string_t dst_pool;
12744 uint8_t dst_pool_val;
12745 cmdline_fixed_string_t port;
12747 cmdline_fixed_string_t vf;
12751 /* Common CLI fields for all E-tag configuration */
12752 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12753 TOKEN_STRING_INITIALIZER
12754 (struct cmd_config_e_tag_result,
12756 cmdline_parse_token_string_t cmd_config_e_tag_set =
12757 TOKEN_STRING_INITIALIZER
12758 (struct cmd_config_e_tag_result,
12760 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12761 TOKEN_STRING_INITIALIZER
12762 (struct cmd_config_e_tag_result,
12763 insertion, "insertion");
12764 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12765 TOKEN_STRING_INITIALIZER
12766 (struct cmd_config_e_tag_result,
12767 stripping, "stripping");
12768 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12769 TOKEN_STRING_INITIALIZER
12770 (struct cmd_config_e_tag_result,
12771 forwarding, "forwarding");
12772 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12773 TOKEN_STRING_INITIALIZER
12774 (struct cmd_config_e_tag_result,
12776 cmdline_parse_token_string_t cmd_config_e_tag_add =
12777 TOKEN_STRING_INITIALIZER
12778 (struct cmd_config_e_tag_result,
12780 cmdline_parse_token_string_t cmd_config_e_tag_del =
12781 TOKEN_STRING_INITIALIZER
12782 (struct cmd_config_e_tag_result,
12784 cmdline_parse_token_string_t cmd_config_e_tag_on =
12785 TOKEN_STRING_INITIALIZER
12786 (struct cmd_config_e_tag_result,
12788 cmdline_parse_token_string_t cmd_config_e_tag_off =
12789 TOKEN_STRING_INITIALIZER
12790 (struct cmd_config_e_tag_result,
12792 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12793 TOKEN_STRING_INITIALIZER
12794 (struct cmd_config_e_tag_result,
12796 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12797 TOKEN_STRING_INITIALIZER
12798 (struct cmd_config_e_tag_result,
12799 port_tag_id, "port-tag-id");
12800 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12801 TOKEN_NUM_INITIALIZER
12802 (struct cmd_config_e_tag_result,
12803 port_tag_id_val, UINT32);
12804 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12805 TOKEN_STRING_INITIALIZER
12806 (struct cmd_config_e_tag_result,
12807 e_tag_id, "e-tag-id");
12808 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12809 TOKEN_NUM_INITIALIZER
12810 (struct cmd_config_e_tag_result,
12811 e_tag_id_val, UINT16);
12812 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12813 TOKEN_STRING_INITIALIZER
12814 (struct cmd_config_e_tag_result,
12815 dst_pool, "dst-pool");
12816 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12817 TOKEN_NUM_INITIALIZER
12818 (struct cmd_config_e_tag_result,
12819 dst_pool_val, UINT8);
12820 cmdline_parse_token_string_t cmd_config_e_tag_port =
12821 TOKEN_STRING_INITIALIZER
12822 (struct cmd_config_e_tag_result,
12824 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12825 TOKEN_NUM_INITIALIZER
12826 (struct cmd_config_e_tag_result,
12828 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12829 TOKEN_STRING_INITIALIZER
12830 (struct cmd_config_e_tag_result,
12832 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12833 TOKEN_NUM_INITIALIZER
12834 (struct cmd_config_e_tag_result,
12837 /* E-tag insertion configuration */
12839 cmd_config_e_tag_insertion_en_parsed(
12840 void *parsed_result,
12841 __attribute__((unused)) struct cmdline *cl,
12842 __attribute__((unused)) void *data)
12844 struct cmd_config_e_tag_result *res =
12846 struct rte_eth_l2_tunnel_conf entry;
12848 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12851 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12852 entry.tunnel_id = res->port_tag_id_val;
12853 entry.vf_id = res->vf_id;
12854 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12856 ETH_L2_TUNNEL_INSERTION_MASK,
12861 cmd_config_e_tag_insertion_dis_parsed(
12862 void *parsed_result,
12863 __attribute__((unused)) struct cmdline *cl,
12864 __attribute__((unused)) void *data)
12866 struct cmd_config_e_tag_result *res =
12868 struct rte_eth_l2_tunnel_conf entry;
12870 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12873 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12874 entry.vf_id = res->vf_id;
12876 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12878 ETH_L2_TUNNEL_INSERTION_MASK,
12882 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12883 .f = cmd_config_e_tag_insertion_en_parsed,
12885 .help_str = "E-tag ... : E-tag insertion enable",
12887 (void *)&cmd_config_e_tag_e_tag,
12888 (void *)&cmd_config_e_tag_set,
12889 (void *)&cmd_config_e_tag_insertion,
12890 (void *)&cmd_config_e_tag_on,
12891 (void *)&cmd_config_e_tag_port_tag_id,
12892 (void *)&cmd_config_e_tag_port_tag_id_val,
12893 (void *)&cmd_config_e_tag_port,
12894 (void *)&cmd_config_e_tag_port_id,
12895 (void *)&cmd_config_e_tag_vf,
12896 (void *)&cmd_config_e_tag_vf_id,
12901 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12902 .f = cmd_config_e_tag_insertion_dis_parsed,
12904 .help_str = "E-tag ... : E-tag insertion disable",
12906 (void *)&cmd_config_e_tag_e_tag,
12907 (void *)&cmd_config_e_tag_set,
12908 (void *)&cmd_config_e_tag_insertion,
12909 (void *)&cmd_config_e_tag_off,
12910 (void *)&cmd_config_e_tag_port,
12911 (void *)&cmd_config_e_tag_port_id,
12912 (void *)&cmd_config_e_tag_vf,
12913 (void *)&cmd_config_e_tag_vf_id,
12918 /* E-tag stripping configuration */
12920 cmd_config_e_tag_stripping_parsed(
12921 void *parsed_result,
12922 __attribute__((unused)) struct cmdline *cl,
12923 __attribute__((unused)) void *data)
12925 struct cmd_config_e_tag_result *res =
12927 struct rte_eth_l2_tunnel_conf entry;
12929 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12932 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12934 if (!strcmp(res->on_off, "on"))
12935 rte_eth_dev_l2_tunnel_offload_set
12938 ETH_L2_TUNNEL_STRIPPING_MASK,
12941 rte_eth_dev_l2_tunnel_offload_set
12944 ETH_L2_TUNNEL_STRIPPING_MASK,
12948 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12949 .f = cmd_config_e_tag_stripping_parsed,
12951 .help_str = "E-tag ... : E-tag stripping enable/disable",
12953 (void *)&cmd_config_e_tag_e_tag,
12954 (void *)&cmd_config_e_tag_set,
12955 (void *)&cmd_config_e_tag_stripping,
12956 (void *)&cmd_config_e_tag_on_off,
12957 (void *)&cmd_config_e_tag_port,
12958 (void *)&cmd_config_e_tag_port_id,
12963 /* E-tag forwarding configuration */
12965 cmd_config_e_tag_forwarding_parsed(
12966 void *parsed_result,
12967 __attribute__((unused)) struct cmdline *cl,
12968 __attribute__((unused)) void *data)
12970 struct cmd_config_e_tag_result *res = parsed_result;
12971 struct rte_eth_l2_tunnel_conf entry;
12973 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12976 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12978 if (!strcmp(res->on_off, "on"))
12979 rte_eth_dev_l2_tunnel_offload_set
12982 ETH_L2_TUNNEL_FORWARDING_MASK,
12985 rte_eth_dev_l2_tunnel_offload_set
12988 ETH_L2_TUNNEL_FORWARDING_MASK,
12992 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12993 .f = cmd_config_e_tag_forwarding_parsed,
12995 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12997 (void *)&cmd_config_e_tag_e_tag,
12998 (void *)&cmd_config_e_tag_set,
12999 (void *)&cmd_config_e_tag_forwarding,
13000 (void *)&cmd_config_e_tag_on_off,
13001 (void *)&cmd_config_e_tag_port,
13002 (void *)&cmd_config_e_tag_port_id,
13007 /* E-tag filter configuration */
13009 cmd_config_e_tag_filter_add_parsed(
13010 void *parsed_result,
13011 __attribute__((unused)) struct cmdline *cl,
13012 __attribute__((unused)) void *data)
13014 struct cmd_config_e_tag_result *res = parsed_result;
13015 struct rte_eth_l2_tunnel_conf entry;
13018 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13021 if (res->e_tag_id_val > 0x3fff) {
13022 printf("e-tag-id must be equal or less than 0x3fff.\n");
13026 ret = rte_eth_dev_filter_supported(res->port_id,
13027 RTE_ETH_FILTER_L2_TUNNEL);
13029 printf("E-tag filter is not supported on port %u.\n",
13034 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13035 entry.tunnel_id = res->e_tag_id_val;
13036 entry.pool = res->dst_pool_val;
13038 ret = rte_eth_dev_filter_ctrl(res->port_id,
13039 RTE_ETH_FILTER_L2_TUNNEL,
13040 RTE_ETH_FILTER_ADD,
13043 printf("E-tag filter programming error: (%s)\n",
13047 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13048 .f = cmd_config_e_tag_filter_add_parsed,
13050 .help_str = "E-tag ... : E-tag filter add",
13052 (void *)&cmd_config_e_tag_e_tag,
13053 (void *)&cmd_config_e_tag_set,
13054 (void *)&cmd_config_e_tag_filter,
13055 (void *)&cmd_config_e_tag_add,
13056 (void *)&cmd_config_e_tag_e_tag_id,
13057 (void *)&cmd_config_e_tag_e_tag_id_val,
13058 (void *)&cmd_config_e_tag_dst_pool,
13059 (void *)&cmd_config_e_tag_dst_pool_val,
13060 (void *)&cmd_config_e_tag_port,
13061 (void *)&cmd_config_e_tag_port_id,
13067 cmd_config_e_tag_filter_del_parsed(
13068 void *parsed_result,
13069 __attribute__((unused)) struct cmdline *cl,
13070 __attribute__((unused)) void *data)
13072 struct cmd_config_e_tag_result *res = parsed_result;
13073 struct rte_eth_l2_tunnel_conf entry;
13076 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13079 if (res->e_tag_id_val > 0x3fff) {
13080 printf("e-tag-id must be less than 0x3fff.\n");
13084 ret = rte_eth_dev_filter_supported(res->port_id,
13085 RTE_ETH_FILTER_L2_TUNNEL);
13087 printf("E-tag filter is not supported on port %u.\n",
13092 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13093 entry.tunnel_id = res->e_tag_id_val;
13095 ret = rte_eth_dev_filter_ctrl(res->port_id,
13096 RTE_ETH_FILTER_L2_TUNNEL,
13097 RTE_ETH_FILTER_DELETE,
13100 printf("E-tag filter programming error: (%s)\n",
13104 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13105 .f = cmd_config_e_tag_filter_del_parsed,
13107 .help_str = "E-tag ... : E-tag filter delete",
13109 (void *)&cmd_config_e_tag_e_tag,
13110 (void *)&cmd_config_e_tag_set,
13111 (void *)&cmd_config_e_tag_filter,
13112 (void *)&cmd_config_e_tag_del,
13113 (void *)&cmd_config_e_tag_e_tag_id,
13114 (void *)&cmd_config_e_tag_e_tag_id_val,
13115 (void *)&cmd_config_e_tag_port,
13116 (void *)&cmd_config_e_tag_port_id,
13121 /* vf vlan anti spoof configuration */
13123 /* Common result structure for vf vlan anti spoof */
13124 struct cmd_vf_vlan_anti_spoof_result {
13125 cmdline_fixed_string_t set;
13126 cmdline_fixed_string_t vf;
13127 cmdline_fixed_string_t vlan;
13128 cmdline_fixed_string_t antispoof;
13131 cmdline_fixed_string_t on_off;
13134 /* Common CLI fields for vf vlan anti spoof enable disable */
13135 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13136 TOKEN_STRING_INITIALIZER
13137 (struct cmd_vf_vlan_anti_spoof_result,
13139 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13140 TOKEN_STRING_INITIALIZER
13141 (struct cmd_vf_vlan_anti_spoof_result,
13143 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13144 TOKEN_STRING_INITIALIZER
13145 (struct cmd_vf_vlan_anti_spoof_result,
13147 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13148 TOKEN_STRING_INITIALIZER
13149 (struct cmd_vf_vlan_anti_spoof_result,
13150 antispoof, "antispoof");
13151 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13152 TOKEN_NUM_INITIALIZER
13153 (struct cmd_vf_vlan_anti_spoof_result,
13155 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13156 TOKEN_NUM_INITIALIZER
13157 (struct cmd_vf_vlan_anti_spoof_result,
13159 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13160 TOKEN_STRING_INITIALIZER
13161 (struct cmd_vf_vlan_anti_spoof_result,
13165 cmd_set_vf_vlan_anti_spoof_parsed(
13166 void *parsed_result,
13167 __attribute__((unused)) struct cmdline *cl,
13168 __attribute__((unused)) void *data)
13170 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13171 int ret = -ENOTSUP;
13173 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13175 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13178 #ifdef RTE_LIBRTE_IXGBE_PMD
13179 if (ret == -ENOTSUP)
13180 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13181 res->vf_id, is_on);
13183 #ifdef RTE_LIBRTE_I40E_PMD
13184 if (ret == -ENOTSUP)
13185 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13186 res->vf_id, is_on);
13188 #ifdef RTE_LIBRTE_BNXT_PMD
13189 if (ret == -ENOTSUP)
13190 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13191 res->vf_id, is_on);
13198 printf("invalid vf_id %d\n", res->vf_id);
13201 printf("invalid port_id %d\n", res->port_id);
13204 printf("function not implemented\n");
13207 printf("programming error: (%s)\n", strerror(-ret));
13211 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13212 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13214 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13216 (void *)&cmd_vf_vlan_anti_spoof_set,
13217 (void *)&cmd_vf_vlan_anti_spoof_vf,
13218 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13219 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13220 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13221 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13222 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13227 /* vf mac anti spoof configuration */
13229 /* Common result structure for vf mac anti spoof */
13230 struct cmd_vf_mac_anti_spoof_result {
13231 cmdline_fixed_string_t set;
13232 cmdline_fixed_string_t vf;
13233 cmdline_fixed_string_t mac;
13234 cmdline_fixed_string_t antispoof;
13237 cmdline_fixed_string_t on_off;
13240 /* Common CLI fields for vf mac anti spoof enable disable */
13241 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13242 TOKEN_STRING_INITIALIZER
13243 (struct cmd_vf_mac_anti_spoof_result,
13245 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13246 TOKEN_STRING_INITIALIZER
13247 (struct cmd_vf_mac_anti_spoof_result,
13249 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13250 TOKEN_STRING_INITIALIZER
13251 (struct cmd_vf_mac_anti_spoof_result,
13253 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13254 TOKEN_STRING_INITIALIZER
13255 (struct cmd_vf_mac_anti_spoof_result,
13256 antispoof, "antispoof");
13257 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13258 TOKEN_NUM_INITIALIZER
13259 (struct cmd_vf_mac_anti_spoof_result,
13261 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13262 TOKEN_NUM_INITIALIZER
13263 (struct cmd_vf_mac_anti_spoof_result,
13265 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13266 TOKEN_STRING_INITIALIZER
13267 (struct cmd_vf_mac_anti_spoof_result,
13271 cmd_set_vf_mac_anti_spoof_parsed(
13272 void *parsed_result,
13273 __attribute__((unused)) struct cmdline *cl,
13274 __attribute__((unused)) void *data)
13276 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13277 int ret = -ENOTSUP;
13279 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13281 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13284 #ifdef RTE_LIBRTE_IXGBE_PMD
13285 if (ret == -ENOTSUP)
13286 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13287 res->vf_id, is_on);
13289 #ifdef RTE_LIBRTE_I40E_PMD
13290 if (ret == -ENOTSUP)
13291 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13292 res->vf_id, is_on);
13294 #ifdef RTE_LIBRTE_BNXT_PMD
13295 if (ret == -ENOTSUP)
13296 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13297 res->vf_id, is_on);
13304 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13307 printf("invalid port_id %d\n", res->port_id);
13310 printf("function not implemented\n");
13313 printf("programming error: (%s)\n", strerror(-ret));
13317 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13318 .f = cmd_set_vf_mac_anti_spoof_parsed,
13320 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13322 (void *)&cmd_vf_mac_anti_spoof_set,
13323 (void *)&cmd_vf_mac_anti_spoof_vf,
13324 (void *)&cmd_vf_mac_anti_spoof_mac,
13325 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13326 (void *)&cmd_vf_mac_anti_spoof_port_id,
13327 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13328 (void *)&cmd_vf_mac_anti_spoof_on_off,
13333 /* vf vlan strip queue configuration */
13335 /* Common result structure for vf mac anti spoof */
13336 struct cmd_vf_vlan_stripq_result {
13337 cmdline_fixed_string_t set;
13338 cmdline_fixed_string_t vf;
13339 cmdline_fixed_string_t vlan;
13340 cmdline_fixed_string_t stripq;
13343 cmdline_fixed_string_t on_off;
13346 /* Common CLI fields for vf vlan strip enable disable */
13347 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13348 TOKEN_STRING_INITIALIZER
13349 (struct cmd_vf_vlan_stripq_result,
13351 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13352 TOKEN_STRING_INITIALIZER
13353 (struct cmd_vf_vlan_stripq_result,
13355 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13356 TOKEN_STRING_INITIALIZER
13357 (struct cmd_vf_vlan_stripq_result,
13359 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13360 TOKEN_STRING_INITIALIZER
13361 (struct cmd_vf_vlan_stripq_result,
13363 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13364 TOKEN_NUM_INITIALIZER
13365 (struct cmd_vf_vlan_stripq_result,
13367 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13368 TOKEN_NUM_INITIALIZER
13369 (struct cmd_vf_vlan_stripq_result,
13371 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13372 TOKEN_STRING_INITIALIZER
13373 (struct cmd_vf_vlan_stripq_result,
13377 cmd_set_vf_vlan_stripq_parsed(
13378 void *parsed_result,
13379 __attribute__((unused)) struct cmdline *cl,
13380 __attribute__((unused)) void *data)
13382 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13383 int ret = -ENOTSUP;
13385 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13387 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13390 #ifdef RTE_LIBRTE_IXGBE_PMD
13391 if (ret == -ENOTSUP)
13392 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13393 res->vf_id, is_on);
13395 #ifdef RTE_LIBRTE_I40E_PMD
13396 if (ret == -ENOTSUP)
13397 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13398 res->vf_id, is_on);
13400 #ifdef RTE_LIBRTE_BNXT_PMD
13401 if (ret == -ENOTSUP)
13402 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13403 res->vf_id, is_on);
13410 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13413 printf("invalid port_id %d\n", res->port_id);
13416 printf("function not implemented\n");
13419 printf("programming error: (%s)\n", strerror(-ret));
13423 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13424 .f = cmd_set_vf_vlan_stripq_parsed,
13426 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13428 (void *)&cmd_vf_vlan_stripq_set,
13429 (void *)&cmd_vf_vlan_stripq_vf,
13430 (void *)&cmd_vf_vlan_stripq_vlan,
13431 (void *)&cmd_vf_vlan_stripq_stripq,
13432 (void *)&cmd_vf_vlan_stripq_port_id,
13433 (void *)&cmd_vf_vlan_stripq_vf_id,
13434 (void *)&cmd_vf_vlan_stripq_on_off,
13439 /* vf vlan insert configuration */
13441 /* Common result structure for vf vlan insert */
13442 struct cmd_vf_vlan_insert_result {
13443 cmdline_fixed_string_t set;
13444 cmdline_fixed_string_t vf;
13445 cmdline_fixed_string_t vlan;
13446 cmdline_fixed_string_t insert;
13452 /* Common CLI fields for vf vlan insert enable disable */
13453 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13454 TOKEN_STRING_INITIALIZER
13455 (struct cmd_vf_vlan_insert_result,
13457 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13458 TOKEN_STRING_INITIALIZER
13459 (struct cmd_vf_vlan_insert_result,
13461 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13462 TOKEN_STRING_INITIALIZER
13463 (struct cmd_vf_vlan_insert_result,
13465 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13466 TOKEN_STRING_INITIALIZER
13467 (struct cmd_vf_vlan_insert_result,
13469 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13470 TOKEN_NUM_INITIALIZER
13471 (struct cmd_vf_vlan_insert_result,
13473 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13474 TOKEN_NUM_INITIALIZER
13475 (struct cmd_vf_vlan_insert_result,
13477 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13478 TOKEN_NUM_INITIALIZER
13479 (struct cmd_vf_vlan_insert_result,
13483 cmd_set_vf_vlan_insert_parsed(
13484 void *parsed_result,
13485 __attribute__((unused)) struct cmdline *cl,
13486 __attribute__((unused)) void *data)
13488 struct cmd_vf_vlan_insert_result *res = parsed_result;
13489 int ret = -ENOTSUP;
13491 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13494 #ifdef RTE_LIBRTE_IXGBE_PMD
13495 if (ret == -ENOTSUP)
13496 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13499 #ifdef RTE_LIBRTE_I40E_PMD
13500 if (ret == -ENOTSUP)
13501 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13504 #ifdef RTE_LIBRTE_BNXT_PMD
13505 if (ret == -ENOTSUP)
13506 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13514 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13517 printf("invalid port_id %d\n", res->port_id);
13520 printf("function not implemented\n");
13523 printf("programming error: (%s)\n", strerror(-ret));
13527 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13528 .f = cmd_set_vf_vlan_insert_parsed,
13530 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13532 (void *)&cmd_vf_vlan_insert_set,
13533 (void *)&cmd_vf_vlan_insert_vf,
13534 (void *)&cmd_vf_vlan_insert_vlan,
13535 (void *)&cmd_vf_vlan_insert_insert,
13536 (void *)&cmd_vf_vlan_insert_port_id,
13537 (void *)&cmd_vf_vlan_insert_vf_id,
13538 (void *)&cmd_vf_vlan_insert_vlan_id,
13543 /* tx loopback configuration */
13545 /* Common result structure for tx loopback */
13546 struct cmd_tx_loopback_result {
13547 cmdline_fixed_string_t set;
13548 cmdline_fixed_string_t tx;
13549 cmdline_fixed_string_t loopback;
13551 cmdline_fixed_string_t on_off;
13554 /* Common CLI fields for tx loopback enable disable */
13555 cmdline_parse_token_string_t cmd_tx_loopback_set =
13556 TOKEN_STRING_INITIALIZER
13557 (struct cmd_tx_loopback_result,
13559 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13560 TOKEN_STRING_INITIALIZER
13561 (struct cmd_tx_loopback_result,
13563 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13564 TOKEN_STRING_INITIALIZER
13565 (struct cmd_tx_loopback_result,
13566 loopback, "loopback");
13567 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13568 TOKEN_NUM_INITIALIZER
13569 (struct cmd_tx_loopback_result,
13571 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13572 TOKEN_STRING_INITIALIZER
13573 (struct cmd_tx_loopback_result,
13577 cmd_set_tx_loopback_parsed(
13578 void *parsed_result,
13579 __attribute__((unused)) struct cmdline *cl,
13580 __attribute__((unused)) void *data)
13582 struct cmd_tx_loopback_result *res = parsed_result;
13583 int ret = -ENOTSUP;
13585 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13587 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13590 #ifdef RTE_LIBRTE_IXGBE_PMD
13591 if (ret == -ENOTSUP)
13592 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13594 #ifdef RTE_LIBRTE_I40E_PMD
13595 if (ret == -ENOTSUP)
13596 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13598 #ifdef RTE_LIBRTE_BNXT_PMD
13599 if (ret == -ENOTSUP)
13600 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13602 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13603 if (ret == -ENOTSUP)
13604 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13611 printf("invalid is_on %d\n", is_on);
13614 printf("invalid port_id %d\n", res->port_id);
13617 printf("function not implemented\n");
13620 printf("programming error: (%s)\n", strerror(-ret));
13624 cmdline_parse_inst_t cmd_set_tx_loopback = {
13625 .f = cmd_set_tx_loopback_parsed,
13627 .help_str = "set tx loopback <port_id> on|off",
13629 (void *)&cmd_tx_loopback_set,
13630 (void *)&cmd_tx_loopback_tx,
13631 (void *)&cmd_tx_loopback_loopback,
13632 (void *)&cmd_tx_loopback_port_id,
13633 (void *)&cmd_tx_loopback_on_off,
13638 /* all queues drop enable configuration */
13640 /* Common result structure for all queues drop enable */
13641 struct cmd_all_queues_drop_en_result {
13642 cmdline_fixed_string_t set;
13643 cmdline_fixed_string_t all;
13644 cmdline_fixed_string_t queues;
13645 cmdline_fixed_string_t drop;
13647 cmdline_fixed_string_t on_off;
13650 /* Common CLI fields for tx loopback enable disable */
13651 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13652 TOKEN_STRING_INITIALIZER
13653 (struct cmd_all_queues_drop_en_result,
13655 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13656 TOKEN_STRING_INITIALIZER
13657 (struct cmd_all_queues_drop_en_result,
13659 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13660 TOKEN_STRING_INITIALIZER
13661 (struct cmd_all_queues_drop_en_result,
13663 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13664 TOKEN_STRING_INITIALIZER
13665 (struct cmd_all_queues_drop_en_result,
13667 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13668 TOKEN_NUM_INITIALIZER
13669 (struct cmd_all_queues_drop_en_result,
13671 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13672 TOKEN_STRING_INITIALIZER
13673 (struct cmd_all_queues_drop_en_result,
13677 cmd_set_all_queues_drop_en_parsed(
13678 void *parsed_result,
13679 __attribute__((unused)) struct cmdline *cl,
13680 __attribute__((unused)) void *data)
13682 struct cmd_all_queues_drop_en_result *res = parsed_result;
13683 int ret = -ENOTSUP;
13684 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13686 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13689 #ifdef RTE_LIBRTE_IXGBE_PMD
13690 if (ret == -ENOTSUP)
13691 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13693 #ifdef RTE_LIBRTE_BNXT_PMD
13694 if (ret == -ENOTSUP)
13695 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13701 printf("invalid is_on %d\n", is_on);
13704 printf("invalid port_id %d\n", res->port_id);
13707 printf("function not implemented\n");
13710 printf("programming error: (%s)\n", strerror(-ret));
13714 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13715 .f = cmd_set_all_queues_drop_en_parsed,
13717 .help_str = "set all queues drop <port_id> on|off",
13719 (void *)&cmd_all_queues_drop_en_set,
13720 (void *)&cmd_all_queues_drop_en_all,
13721 (void *)&cmd_all_queues_drop_en_queues,
13722 (void *)&cmd_all_queues_drop_en_drop,
13723 (void *)&cmd_all_queues_drop_en_port_id,
13724 (void *)&cmd_all_queues_drop_en_on_off,
13729 /* vf split drop enable configuration */
13731 /* Common result structure for vf split drop enable */
13732 struct cmd_vf_split_drop_en_result {
13733 cmdline_fixed_string_t set;
13734 cmdline_fixed_string_t vf;
13735 cmdline_fixed_string_t split;
13736 cmdline_fixed_string_t drop;
13739 cmdline_fixed_string_t on_off;
13742 /* Common CLI fields for vf split drop enable disable */
13743 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13744 TOKEN_STRING_INITIALIZER
13745 (struct cmd_vf_split_drop_en_result,
13747 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13748 TOKEN_STRING_INITIALIZER
13749 (struct cmd_vf_split_drop_en_result,
13751 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13752 TOKEN_STRING_INITIALIZER
13753 (struct cmd_vf_split_drop_en_result,
13755 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13756 TOKEN_STRING_INITIALIZER
13757 (struct cmd_vf_split_drop_en_result,
13759 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13760 TOKEN_NUM_INITIALIZER
13761 (struct cmd_vf_split_drop_en_result,
13763 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13764 TOKEN_NUM_INITIALIZER
13765 (struct cmd_vf_split_drop_en_result,
13767 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13768 TOKEN_STRING_INITIALIZER
13769 (struct cmd_vf_split_drop_en_result,
13773 cmd_set_vf_split_drop_en_parsed(
13774 void *parsed_result,
13775 __attribute__((unused)) struct cmdline *cl,
13776 __attribute__((unused)) void *data)
13778 struct cmd_vf_split_drop_en_result *res = parsed_result;
13779 int ret = -ENOTSUP;
13780 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13782 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13785 #ifdef RTE_LIBRTE_IXGBE_PMD
13786 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13793 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13796 printf("invalid port_id %d\n", res->port_id);
13799 printf("not supported on port %d\n", res->port_id);
13802 printf("programming error: (%s)\n", strerror(-ret));
13806 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13807 .f = cmd_set_vf_split_drop_en_parsed,
13809 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13811 (void *)&cmd_vf_split_drop_en_set,
13812 (void *)&cmd_vf_split_drop_en_vf,
13813 (void *)&cmd_vf_split_drop_en_split,
13814 (void *)&cmd_vf_split_drop_en_drop,
13815 (void *)&cmd_vf_split_drop_en_port_id,
13816 (void *)&cmd_vf_split_drop_en_vf_id,
13817 (void *)&cmd_vf_split_drop_en_on_off,
13822 /* vf mac address configuration */
13824 /* Common result structure for vf mac address */
13825 struct cmd_set_vf_mac_addr_result {
13826 cmdline_fixed_string_t set;
13827 cmdline_fixed_string_t vf;
13828 cmdline_fixed_string_t mac;
13829 cmdline_fixed_string_t addr;
13832 struct ether_addr mac_addr;
13836 /* Common CLI fields for vf split drop enable disable */
13837 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13838 TOKEN_STRING_INITIALIZER
13839 (struct cmd_set_vf_mac_addr_result,
13841 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13842 TOKEN_STRING_INITIALIZER
13843 (struct cmd_set_vf_mac_addr_result,
13845 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13846 TOKEN_STRING_INITIALIZER
13847 (struct cmd_set_vf_mac_addr_result,
13849 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13850 TOKEN_STRING_INITIALIZER
13851 (struct cmd_set_vf_mac_addr_result,
13853 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13854 TOKEN_NUM_INITIALIZER
13855 (struct cmd_set_vf_mac_addr_result,
13857 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13858 TOKEN_NUM_INITIALIZER
13859 (struct cmd_set_vf_mac_addr_result,
13861 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13862 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13866 cmd_set_vf_mac_addr_parsed(
13867 void *parsed_result,
13868 __attribute__((unused)) struct cmdline *cl,
13869 __attribute__((unused)) void *data)
13871 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13872 int ret = -ENOTSUP;
13874 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13877 #ifdef RTE_LIBRTE_IXGBE_PMD
13878 if (ret == -ENOTSUP)
13879 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13882 #ifdef RTE_LIBRTE_I40E_PMD
13883 if (ret == -ENOTSUP)
13884 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13887 #ifdef RTE_LIBRTE_BNXT_PMD
13888 if (ret == -ENOTSUP)
13889 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13897 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13900 printf("invalid port_id %d\n", res->port_id);
13903 printf("function not implemented\n");
13906 printf("programming error: (%s)\n", strerror(-ret));
13910 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13911 .f = cmd_set_vf_mac_addr_parsed,
13913 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13915 (void *)&cmd_set_vf_mac_addr_set,
13916 (void *)&cmd_set_vf_mac_addr_vf,
13917 (void *)&cmd_set_vf_mac_addr_mac,
13918 (void *)&cmd_set_vf_mac_addr_addr,
13919 (void *)&cmd_set_vf_mac_addr_port_id,
13920 (void *)&cmd_set_vf_mac_addr_vf_id,
13921 (void *)&cmd_set_vf_mac_addr_mac_addr,
13926 /* MACsec configuration */
13928 /* Common result structure for MACsec offload enable */
13929 struct cmd_macsec_offload_on_result {
13930 cmdline_fixed_string_t set;
13931 cmdline_fixed_string_t macsec;
13932 cmdline_fixed_string_t offload;
13934 cmdline_fixed_string_t on;
13935 cmdline_fixed_string_t encrypt;
13936 cmdline_fixed_string_t en_on_off;
13937 cmdline_fixed_string_t replay_protect;
13938 cmdline_fixed_string_t rp_on_off;
13941 /* Common CLI fields for MACsec offload disable */
13942 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13943 TOKEN_STRING_INITIALIZER
13944 (struct cmd_macsec_offload_on_result,
13946 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13947 TOKEN_STRING_INITIALIZER
13948 (struct cmd_macsec_offload_on_result,
13950 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13951 TOKEN_STRING_INITIALIZER
13952 (struct cmd_macsec_offload_on_result,
13953 offload, "offload");
13954 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13955 TOKEN_NUM_INITIALIZER
13956 (struct cmd_macsec_offload_on_result,
13958 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13959 TOKEN_STRING_INITIALIZER
13960 (struct cmd_macsec_offload_on_result,
13962 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13963 TOKEN_STRING_INITIALIZER
13964 (struct cmd_macsec_offload_on_result,
13965 encrypt, "encrypt");
13966 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13967 TOKEN_STRING_INITIALIZER
13968 (struct cmd_macsec_offload_on_result,
13969 en_on_off, "on#off");
13970 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13971 TOKEN_STRING_INITIALIZER
13972 (struct cmd_macsec_offload_on_result,
13973 replay_protect, "replay-protect");
13974 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13975 TOKEN_STRING_INITIALIZER
13976 (struct cmd_macsec_offload_on_result,
13977 rp_on_off, "on#off");
13980 cmd_set_macsec_offload_on_parsed(
13981 void *parsed_result,
13982 __attribute__((unused)) struct cmdline *cl,
13983 __attribute__((unused)) void *data)
13985 struct cmd_macsec_offload_on_result *res = parsed_result;
13986 int ret = -ENOTSUP;
13987 portid_t port_id = res->port_id;
13988 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13989 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13990 struct rte_eth_dev_info dev_info;
13992 if (port_id_is_invalid(port_id, ENABLED_WARN))
13994 if (!port_is_stopped(port_id)) {
13995 printf("Please stop port %d first\n", port_id);
13999 rte_eth_dev_info_get(port_id, &dev_info);
14000 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14001 #ifdef RTE_LIBRTE_IXGBE_PMD
14002 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14010 ports[port_id].dev_conf.txmode.offloads |=
14011 DEV_TX_OFFLOAD_MACSEC_INSERT;
14012 cmd_reconfig_device_queue(port_id, 1, 1);
14015 printf("invalid port_id %d\n", port_id);
14018 printf("not supported on port %d\n", port_id);
14021 printf("programming error: (%s)\n", strerror(-ret));
14025 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14026 .f = cmd_set_macsec_offload_on_parsed,
14028 .help_str = "set macsec offload <port_id> on "
14029 "encrypt on|off replay-protect on|off",
14031 (void *)&cmd_macsec_offload_on_set,
14032 (void *)&cmd_macsec_offload_on_macsec,
14033 (void *)&cmd_macsec_offload_on_offload,
14034 (void *)&cmd_macsec_offload_on_port_id,
14035 (void *)&cmd_macsec_offload_on_on,
14036 (void *)&cmd_macsec_offload_on_encrypt,
14037 (void *)&cmd_macsec_offload_on_en_on_off,
14038 (void *)&cmd_macsec_offload_on_replay_protect,
14039 (void *)&cmd_macsec_offload_on_rp_on_off,
14044 /* Common result structure for MACsec offload disable */
14045 struct cmd_macsec_offload_off_result {
14046 cmdline_fixed_string_t set;
14047 cmdline_fixed_string_t macsec;
14048 cmdline_fixed_string_t offload;
14050 cmdline_fixed_string_t off;
14053 /* Common CLI fields for MACsec offload disable */
14054 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14055 TOKEN_STRING_INITIALIZER
14056 (struct cmd_macsec_offload_off_result,
14058 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14059 TOKEN_STRING_INITIALIZER
14060 (struct cmd_macsec_offload_off_result,
14062 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14063 TOKEN_STRING_INITIALIZER
14064 (struct cmd_macsec_offload_off_result,
14065 offload, "offload");
14066 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14067 TOKEN_NUM_INITIALIZER
14068 (struct cmd_macsec_offload_off_result,
14070 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14071 TOKEN_STRING_INITIALIZER
14072 (struct cmd_macsec_offload_off_result,
14076 cmd_set_macsec_offload_off_parsed(
14077 void *parsed_result,
14078 __attribute__((unused)) struct cmdline *cl,
14079 __attribute__((unused)) void *data)
14081 struct cmd_macsec_offload_off_result *res = parsed_result;
14082 int ret = -ENOTSUP;
14083 struct rte_eth_dev_info dev_info;
14084 portid_t port_id = res->port_id;
14086 if (port_id_is_invalid(port_id, ENABLED_WARN))
14088 if (!port_is_stopped(port_id)) {
14089 printf("Please stop port %d first\n", port_id);
14093 rte_eth_dev_info_get(port_id, &dev_info);
14094 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14095 #ifdef RTE_LIBRTE_IXGBE_PMD
14096 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14101 ports[port_id].dev_conf.txmode.offloads &=
14102 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14103 cmd_reconfig_device_queue(port_id, 1, 1);
14106 printf("invalid port_id %d\n", port_id);
14109 printf("not supported on port %d\n", port_id);
14112 printf("programming error: (%s)\n", strerror(-ret));
14116 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14117 .f = cmd_set_macsec_offload_off_parsed,
14119 .help_str = "set macsec offload <port_id> off",
14121 (void *)&cmd_macsec_offload_off_set,
14122 (void *)&cmd_macsec_offload_off_macsec,
14123 (void *)&cmd_macsec_offload_off_offload,
14124 (void *)&cmd_macsec_offload_off_port_id,
14125 (void *)&cmd_macsec_offload_off_off,
14130 /* Common result structure for MACsec secure connection configure */
14131 struct cmd_macsec_sc_result {
14132 cmdline_fixed_string_t set;
14133 cmdline_fixed_string_t macsec;
14134 cmdline_fixed_string_t sc;
14135 cmdline_fixed_string_t tx_rx;
14137 struct ether_addr mac;
14141 /* Common CLI fields for MACsec secure connection configure */
14142 cmdline_parse_token_string_t cmd_macsec_sc_set =
14143 TOKEN_STRING_INITIALIZER
14144 (struct cmd_macsec_sc_result,
14146 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14147 TOKEN_STRING_INITIALIZER
14148 (struct cmd_macsec_sc_result,
14150 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14151 TOKEN_STRING_INITIALIZER
14152 (struct cmd_macsec_sc_result,
14154 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14155 TOKEN_STRING_INITIALIZER
14156 (struct cmd_macsec_sc_result,
14158 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14159 TOKEN_NUM_INITIALIZER
14160 (struct cmd_macsec_sc_result,
14162 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14163 TOKEN_ETHERADDR_INITIALIZER
14164 (struct cmd_macsec_sc_result,
14166 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14167 TOKEN_NUM_INITIALIZER
14168 (struct cmd_macsec_sc_result,
14172 cmd_set_macsec_sc_parsed(
14173 void *parsed_result,
14174 __attribute__((unused)) struct cmdline *cl,
14175 __attribute__((unused)) void *data)
14177 struct cmd_macsec_sc_result *res = parsed_result;
14178 int ret = -ENOTSUP;
14179 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14181 #ifdef RTE_LIBRTE_IXGBE_PMD
14183 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14184 res->mac.addr_bytes) :
14185 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14186 res->mac.addr_bytes, res->pi);
14188 RTE_SET_USED(is_tx);
14194 printf("invalid port_id %d\n", res->port_id);
14197 printf("not supported on port %d\n", res->port_id);
14200 printf("programming error: (%s)\n", strerror(-ret));
14204 cmdline_parse_inst_t cmd_set_macsec_sc = {
14205 .f = cmd_set_macsec_sc_parsed,
14207 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14209 (void *)&cmd_macsec_sc_set,
14210 (void *)&cmd_macsec_sc_macsec,
14211 (void *)&cmd_macsec_sc_sc,
14212 (void *)&cmd_macsec_sc_tx_rx,
14213 (void *)&cmd_macsec_sc_port_id,
14214 (void *)&cmd_macsec_sc_mac,
14215 (void *)&cmd_macsec_sc_pi,
14220 /* Common result structure for MACsec secure connection configure */
14221 struct cmd_macsec_sa_result {
14222 cmdline_fixed_string_t set;
14223 cmdline_fixed_string_t macsec;
14224 cmdline_fixed_string_t sa;
14225 cmdline_fixed_string_t tx_rx;
14230 cmdline_fixed_string_t key;
14233 /* Common CLI fields for MACsec secure connection configure */
14234 cmdline_parse_token_string_t cmd_macsec_sa_set =
14235 TOKEN_STRING_INITIALIZER
14236 (struct cmd_macsec_sa_result,
14238 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14239 TOKEN_STRING_INITIALIZER
14240 (struct cmd_macsec_sa_result,
14242 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14243 TOKEN_STRING_INITIALIZER
14244 (struct cmd_macsec_sa_result,
14246 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14247 TOKEN_STRING_INITIALIZER
14248 (struct cmd_macsec_sa_result,
14250 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14251 TOKEN_NUM_INITIALIZER
14252 (struct cmd_macsec_sa_result,
14254 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14255 TOKEN_NUM_INITIALIZER
14256 (struct cmd_macsec_sa_result,
14258 cmdline_parse_token_num_t cmd_macsec_sa_an =
14259 TOKEN_NUM_INITIALIZER
14260 (struct cmd_macsec_sa_result,
14262 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14263 TOKEN_NUM_INITIALIZER
14264 (struct cmd_macsec_sa_result,
14266 cmdline_parse_token_string_t cmd_macsec_sa_key =
14267 TOKEN_STRING_INITIALIZER
14268 (struct cmd_macsec_sa_result,
14272 cmd_set_macsec_sa_parsed(
14273 void *parsed_result,
14274 __attribute__((unused)) struct cmdline *cl,
14275 __attribute__((unused)) void *data)
14277 struct cmd_macsec_sa_result *res = parsed_result;
14278 int ret = -ENOTSUP;
14279 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14280 uint8_t key[16] = { 0 };
14286 key_len = strlen(res->key) / 2;
14290 for (i = 0; i < key_len; i++) {
14291 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14294 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14297 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14300 #ifdef RTE_LIBRTE_IXGBE_PMD
14302 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14303 res->idx, res->an, res->pn, key) :
14304 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14305 res->idx, res->an, res->pn, key);
14307 RTE_SET_USED(is_tx);
14314 printf("invalid idx %d or an %d\n", res->idx, res->an);
14317 printf("invalid port_id %d\n", res->port_id);
14320 printf("not supported on port %d\n", res->port_id);
14323 printf("programming error: (%s)\n", strerror(-ret));
14327 cmdline_parse_inst_t cmd_set_macsec_sa = {
14328 .f = cmd_set_macsec_sa_parsed,
14330 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14332 (void *)&cmd_macsec_sa_set,
14333 (void *)&cmd_macsec_sa_macsec,
14334 (void *)&cmd_macsec_sa_sa,
14335 (void *)&cmd_macsec_sa_tx_rx,
14336 (void *)&cmd_macsec_sa_port_id,
14337 (void *)&cmd_macsec_sa_idx,
14338 (void *)&cmd_macsec_sa_an,
14339 (void *)&cmd_macsec_sa_pn,
14340 (void *)&cmd_macsec_sa_key,
14345 /* VF unicast promiscuous mode configuration */
14347 /* Common result structure for VF unicast promiscuous mode */
14348 struct cmd_vf_promisc_result {
14349 cmdline_fixed_string_t set;
14350 cmdline_fixed_string_t vf;
14351 cmdline_fixed_string_t promisc;
14354 cmdline_fixed_string_t on_off;
14357 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14358 cmdline_parse_token_string_t cmd_vf_promisc_set =
14359 TOKEN_STRING_INITIALIZER
14360 (struct cmd_vf_promisc_result,
14362 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14363 TOKEN_STRING_INITIALIZER
14364 (struct cmd_vf_promisc_result,
14366 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14367 TOKEN_STRING_INITIALIZER
14368 (struct cmd_vf_promisc_result,
14369 promisc, "promisc");
14370 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14371 TOKEN_NUM_INITIALIZER
14372 (struct cmd_vf_promisc_result,
14374 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14375 TOKEN_NUM_INITIALIZER
14376 (struct cmd_vf_promisc_result,
14378 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14379 TOKEN_STRING_INITIALIZER
14380 (struct cmd_vf_promisc_result,
14384 cmd_set_vf_promisc_parsed(
14385 void *parsed_result,
14386 __attribute__((unused)) struct cmdline *cl,
14387 __attribute__((unused)) void *data)
14389 struct cmd_vf_promisc_result *res = parsed_result;
14390 int ret = -ENOTSUP;
14392 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14394 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14397 #ifdef RTE_LIBRTE_I40E_PMD
14398 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14399 res->vf_id, is_on);
14406 printf("invalid vf_id %d\n", res->vf_id);
14409 printf("invalid port_id %d\n", res->port_id);
14412 printf("function not implemented\n");
14415 printf("programming error: (%s)\n", strerror(-ret));
14419 cmdline_parse_inst_t cmd_set_vf_promisc = {
14420 .f = cmd_set_vf_promisc_parsed,
14422 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14423 "Set unicast promiscuous mode for a VF from the PF",
14425 (void *)&cmd_vf_promisc_set,
14426 (void *)&cmd_vf_promisc_vf,
14427 (void *)&cmd_vf_promisc_promisc,
14428 (void *)&cmd_vf_promisc_port_id,
14429 (void *)&cmd_vf_promisc_vf_id,
14430 (void *)&cmd_vf_promisc_on_off,
14435 /* VF multicast promiscuous mode configuration */
14437 /* Common result structure for VF multicast promiscuous mode */
14438 struct cmd_vf_allmulti_result {
14439 cmdline_fixed_string_t set;
14440 cmdline_fixed_string_t vf;
14441 cmdline_fixed_string_t allmulti;
14444 cmdline_fixed_string_t on_off;
14447 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14448 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14449 TOKEN_STRING_INITIALIZER
14450 (struct cmd_vf_allmulti_result,
14452 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14453 TOKEN_STRING_INITIALIZER
14454 (struct cmd_vf_allmulti_result,
14456 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14457 TOKEN_STRING_INITIALIZER
14458 (struct cmd_vf_allmulti_result,
14459 allmulti, "allmulti");
14460 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14461 TOKEN_NUM_INITIALIZER
14462 (struct cmd_vf_allmulti_result,
14464 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14465 TOKEN_NUM_INITIALIZER
14466 (struct cmd_vf_allmulti_result,
14468 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14469 TOKEN_STRING_INITIALIZER
14470 (struct cmd_vf_allmulti_result,
14474 cmd_set_vf_allmulti_parsed(
14475 void *parsed_result,
14476 __attribute__((unused)) struct cmdline *cl,
14477 __attribute__((unused)) void *data)
14479 struct cmd_vf_allmulti_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_multicast_promisc(res->port_id,
14489 res->vf_id, is_on);
14496 printf("invalid vf_id %d\n", res->vf_id);
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_allmulti = {
14510 .f = cmd_set_vf_allmulti_parsed,
14512 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14513 "Set multicast promiscuous mode for a VF from the PF",
14515 (void *)&cmd_vf_allmulti_set,
14516 (void *)&cmd_vf_allmulti_vf,
14517 (void *)&cmd_vf_allmulti_allmulti,
14518 (void *)&cmd_vf_allmulti_port_id,
14519 (void *)&cmd_vf_allmulti_vf_id,
14520 (void *)&cmd_vf_allmulti_on_off,
14525 /* vf broadcast mode configuration */
14527 /* Common result structure for vf broadcast */
14528 struct cmd_set_vf_broadcast_result {
14529 cmdline_fixed_string_t set;
14530 cmdline_fixed_string_t vf;
14531 cmdline_fixed_string_t broadcast;
14534 cmdline_fixed_string_t on_off;
14537 /* Common CLI fields for vf broadcast enable disable */
14538 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14539 TOKEN_STRING_INITIALIZER
14540 (struct cmd_set_vf_broadcast_result,
14542 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14543 TOKEN_STRING_INITIALIZER
14544 (struct cmd_set_vf_broadcast_result,
14546 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14547 TOKEN_STRING_INITIALIZER
14548 (struct cmd_set_vf_broadcast_result,
14549 broadcast, "broadcast");
14550 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14551 TOKEN_NUM_INITIALIZER
14552 (struct cmd_set_vf_broadcast_result,
14554 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14555 TOKEN_NUM_INITIALIZER
14556 (struct cmd_set_vf_broadcast_result,
14558 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14559 TOKEN_STRING_INITIALIZER
14560 (struct cmd_set_vf_broadcast_result,
14564 cmd_set_vf_broadcast_parsed(
14565 void *parsed_result,
14566 __attribute__((unused)) struct cmdline *cl,
14567 __attribute__((unused)) void *data)
14569 struct cmd_set_vf_broadcast_result *res = parsed_result;
14570 int ret = -ENOTSUP;
14572 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14574 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14577 #ifdef RTE_LIBRTE_I40E_PMD
14578 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14579 res->vf_id, is_on);
14586 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14589 printf("invalid port_id %d\n", res->port_id);
14592 printf("function not implemented\n");
14595 printf("programming error: (%s)\n", strerror(-ret));
14599 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14600 .f = cmd_set_vf_broadcast_parsed,
14602 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14604 (void *)&cmd_set_vf_broadcast_set,
14605 (void *)&cmd_set_vf_broadcast_vf,
14606 (void *)&cmd_set_vf_broadcast_broadcast,
14607 (void *)&cmd_set_vf_broadcast_port_id,
14608 (void *)&cmd_set_vf_broadcast_vf_id,
14609 (void *)&cmd_set_vf_broadcast_on_off,
14614 /* vf vlan tag configuration */
14616 /* Common result structure for vf vlan tag */
14617 struct cmd_set_vf_vlan_tag_result {
14618 cmdline_fixed_string_t set;
14619 cmdline_fixed_string_t vf;
14620 cmdline_fixed_string_t vlan;
14621 cmdline_fixed_string_t tag;
14624 cmdline_fixed_string_t on_off;
14627 /* Common CLI fields for vf vlan tag enable disable */
14628 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14629 TOKEN_STRING_INITIALIZER
14630 (struct cmd_set_vf_vlan_tag_result,
14632 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14633 TOKEN_STRING_INITIALIZER
14634 (struct cmd_set_vf_vlan_tag_result,
14636 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14637 TOKEN_STRING_INITIALIZER
14638 (struct cmd_set_vf_vlan_tag_result,
14640 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14641 TOKEN_STRING_INITIALIZER
14642 (struct cmd_set_vf_vlan_tag_result,
14644 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14645 TOKEN_NUM_INITIALIZER
14646 (struct cmd_set_vf_vlan_tag_result,
14648 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14649 TOKEN_NUM_INITIALIZER
14650 (struct cmd_set_vf_vlan_tag_result,
14652 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14653 TOKEN_STRING_INITIALIZER
14654 (struct cmd_set_vf_vlan_tag_result,
14658 cmd_set_vf_vlan_tag_parsed(
14659 void *parsed_result,
14660 __attribute__((unused)) struct cmdline *cl,
14661 __attribute__((unused)) void *data)
14663 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14664 int ret = -ENOTSUP;
14666 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14668 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14671 #ifdef RTE_LIBRTE_I40E_PMD
14672 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14673 res->vf_id, is_on);
14680 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14683 printf("invalid port_id %d\n", res->port_id);
14686 printf("function not implemented\n");
14689 printf("programming error: (%s)\n", strerror(-ret));
14693 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14694 .f = cmd_set_vf_vlan_tag_parsed,
14696 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14698 (void *)&cmd_set_vf_vlan_tag_set,
14699 (void *)&cmd_set_vf_vlan_tag_vf,
14700 (void *)&cmd_set_vf_vlan_tag_vlan,
14701 (void *)&cmd_set_vf_vlan_tag_tag,
14702 (void *)&cmd_set_vf_vlan_tag_port_id,
14703 (void *)&cmd_set_vf_vlan_tag_vf_id,
14704 (void *)&cmd_set_vf_vlan_tag_on_off,
14709 /* Common definition of VF and TC TX bandwidth configuration */
14710 struct cmd_vf_tc_bw_result {
14711 cmdline_fixed_string_t set;
14712 cmdline_fixed_string_t vf;
14713 cmdline_fixed_string_t tc;
14714 cmdline_fixed_string_t tx;
14715 cmdline_fixed_string_t min_bw;
14716 cmdline_fixed_string_t max_bw;
14717 cmdline_fixed_string_t strict_link_prio;
14722 cmdline_fixed_string_t bw_list;
14726 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14727 TOKEN_STRING_INITIALIZER
14728 (struct cmd_vf_tc_bw_result,
14730 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14731 TOKEN_STRING_INITIALIZER
14732 (struct cmd_vf_tc_bw_result,
14734 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14735 TOKEN_STRING_INITIALIZER
14736 (struct cmd_vf_tc_bw_result,
14738 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14739 TOKEN_STRING_INITIALIZER
14740 (struct cmd_vf_tc_bw_result,
14742 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14743 TOKEN_STRING_INITIALIZER
14744 (struct cmd_vf_tc_bw_result,
14745 strict_link_prio, "strict-link-priority");
14746 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14747 TOKEN_STRING_INITIALIZER
14748 (struct cmd_vf_tc_bw_result,
14749 min_bw, "min-bandwidth");
14750 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14751 TOKEN_STRING_INITIALIZER
14752 (struct cmd_vf_tc_bw_result,
14753 max_bw, "max-bandwidth");
14754 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14755 TOKEN_NUM_INITIALIZER
14756 (struct cmd_vf_tc_bw_result,
14758 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14759 TOKEN_NUM_INITIALIZER
14760 (struct cmd_vf_tc_bw_result,
14762 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14763 TOKEN_NUM_INITIALIZER
14764 (struct cmd_vf_tc_bw_result,
14766 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14767 TOKEN_NUM_INITIALIZER
14768 (struct cmd_vf_tc_bw_result,
14770 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14771 TOKEN_STRING_INITIALIZER
14772 (struct cmd_vf_tc_bw_result,
14774 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14775 TOKEN_NUM_INITIALIZER
14776 (struct cmd_vf_tc_bw_result,
14779 /* VF max bandwidth setting */
14781 cmd_vf_max_bw_parsed(
14782 void *parsed_result,
14783 __attribute__((unused)) struct cmdline *cl,
14784 __attribute__((unused)) void *data)
14786 struct cmd_vf_tc_bw_result *res = parsed_result;
14787 int ret = -ENOTSUP;
14789 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14792 #ifdef RTE_LIBRTE_I40E_PMD
14793 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14794 res->vf_id, res->bw);
14801 printf("invalid vf_id %d or bandwidth %d\n",
14802 res->vf_id, res->bw);
14805 printf("invalid port_id %d\n", res->port_id);
14808 printf("function not implemented\n");
14811 printf("programming error: (%s)\n", strerror(-ret));
14815 cmdline_parse_inst_t cmd_vf_max_bw = {
14816 .f = cmd_vf_max_bw_parsed,
14818 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14820 (void *)&cmd_vf_tc_bw_set,
14821 (void *)&cmd_vf_tc_bw_vf,
14822 (void *)&cmd_vf_tc_bw_tx,
14823 (void *)&cmd_vf_tc_bw_max_bw,
14824 (void *)&cmd_vf_tc_bw_port_id,
14825 (void *)&cmd_vf_tc_bw_vf_id,
14826 (void *)&cmd_vf_tc_bw_bw,
14832 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14837 const char *p, *p0 = str;
14844 p = strchr(p0, '(');
14846 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14850 p0 = strchr(p, ')');
14852 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14856 if (size >= sizeof(s)) {
14857 printf("The string size exceeds the internal buffer size\n");
14860 snprintf(s, sizeof(s), "%.*s", size, p);
14861 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14863 printf("Failed to get the bandwidth list. ");
14867 for (i = 0; i < ret; i++)
14868 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14873 /* TC min bandwidth setting */
14875 cmd_vf_tc_min_bw_parsed(
14876 void *parsed_result,
14877 __attribute__((unused)) struct cmdline *cl,
14878 __attribute__((unused)) void *data)
14880 struct cmd_vf_tc_bw_result *res = parsed_result;
14883 int ret = -ENOTSUP;
14885 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14888 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14892 #ifdef RTE_LIBRTE_I40E_PMD
14893 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14901 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14904 printf("invalid port_id %d\n", res->port_id);
14907 printf("function not implemented\n");
14910 printf("programming error: (%s)\n", strerror(-ret));
14914 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14915 .f = cmd_vf_tc_min_bw_parsed,
14917 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14918 " <bw1, bw2, ...>",
14920 (void *)&cmd_vf_tc_bw_set,
14921 (void *)&cmd_vf_tc_bw_vf,
14922 (void *)&cmd_vf_tc_bw_tc,
14923 (void *)&cmd_vf_tc_bw_tx,
14924 (void *)&cmd_vf_tc_bw_min_bw,
14925 (void *)&cmd_vf_tc_bw_port_id,
14926 (void *)&cmd_vf_tc_bw_vf_id,
14927 (void *)&cmd_vf_tc_bw_bw_list,
14933 cmd_tc_min_bw_parsed(
14934 void *parsed_result,
14935 __attribute__((unused)) struct cmdline *cl,
14936 __attribute__((unused)) void *data)
14938 struct cmd_vf_tc_bw_result *res = parsed_result;
14939 struct rte_port *port;
14942 int ret = -ENOTSUP;
14944 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14947 port = &ports[res->port_id];
14948 /** Check if the port is not started **/
14949 if (port->port_status != RTE_PORT_STOPPED) {
14950 printf("Please stop port %d first\n", res->port_id);
14954 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14958 #ifdef RTE_LIBRTE_IXGBE_PMD
14959 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14966 printf("invalid bandwidth\n");
14969 printf("invalid port_id %d\n", res->port_id);
14972 printf("function not implemented\n");
14975 printf("programming error: (%s)\n", strerror(-ret));
14979 cmdline_parse_inst_t cmd_tc_min_bw = {
14980 .f = cmd_tc_min_bw_parsed,
14982 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14984 (void *)&cmd_vf_tc_bw_set,
14985 (void *)&cmd_vf_tc_bw_tc,
14986 (void *)&cmd_vf_tc_bw_tx,
14987 (void *)&cmd_vf_tc_bw_min_bw,
14988 (void *)&cmd_vf_tc_bw_port_id,
14989 (void *)&cmd_vf_tc_bw_bw_list,
14994 /* TC max bandwidth setting */
14996 cmd_vf_tc_max_bw_parsed(
14997 void *parsed_result,
14998 __attribute__((unused)) struct cmdline *cl,
14999 __attribute__((unused)) void *data)
15001 struct cmd_vf_tc_bw_result *res = parsed_result;
15002 int ret = -ENOTSUP;
15004 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15007 #ifdef RTE_LIBRTE_I40E_PMD
15008 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15009 res->tc_no, res->bw);
15016 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15017 res->vf_id, res->tc_no, res->bw);
15020 printf("invalid port_id %d\n", res->port_id);
15023 printf("function not implemented\n");
15026 printf("programming error: (%s)\n", strerror(-ret));
15030 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15031 .f = cmd_vf_tc_max_bw_parsed,
15033 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15036 (void *)&cmd_vf_tc_bw_set,
15037 (void *)&cmd_vf_tc_bw_vf,
15038 (void *)&cmd_vf_tc_bw_tc,
15039 (void *)&cmd_vf_tc_bw_tx,
15040 (void *)&cmd_vf_tc_bw_max_bw,
15041 (void *)&cmd_vf_tc_bw_port_id,
15042 (void *)&cmd_vf_tc_bw_vf_id,
15043 (void *)&cmd_vf_tc_bw_tc_no,
15044 (void *)&cmd_vf_tc_bw_bw,
15050 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15052 /* *** Set Port default Traffic Management Hierarchy *** */
15053 struct cmd_set_port_tm_hierarchy_default_result {
15054 cmdline_fixed_string_t set;
15055 cmdline_fixed_string_t port;
15056 cmdline_fixed_string_t tm;
15057 cmdline_fixed_string_t hierarchy;
15058 cmdline_fixed_string_t def;
15062 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15063 TOKEN_STRING_INITIALIZER(
15064 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15065 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15066 TOKEN_STRING_INITIALIZER(
15067 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15068 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15069 TOKEN_STRING_INITIALIZER(
15070 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15071 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15072 TOKEN_STRING_INITIALIZER(
15073 struct cmd_set_port_tm_hierarchy_default_result,
15074 hierarchy, "hierarchy");
15075 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15076 TOKEN_STRING_INITIALIZER(
15077 struct cmd_set_port_tm_hierarchy_default_result,
15079 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15080 TOKEN_NUM_INITIALIZER(
15081 struct cmd_set_port_tm_hierarchy_default_result,
15084 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15085 __attribute__((unused)) struct cmdline *cl,
15086 __attribute__((unused)) void *data)
15088 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15089 struct rte_port *p;
15090 portid_t port_id = res->port_id;
15092 if (port_id_is_invalid(port_id, ENABLED_WARN))
15095 p = &ports[port_id];
15097 /* Forward mode: tm */
15098 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15099 printf(" softnicfwd mode not enabled(error)\n");
15103 /* Set the default tm hierarchy */
15104 p->softport.default_tm_hierarchy_enable = 1;
15107 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15108 .f = cmd_set_port_tm_hierarchy_default_parsed,
15110 .help_str = "set port tm hierarchy default <port_id>",
15112 (void *)&cmd_set_port_tm_hierarchy_default_set,
15113 (void *)&cmd_set_port_tm_hierarchy_default_port,
15114 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15115 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15116 (void *)&cmd_set_port_tm_hierarchy_default_default,
15117 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15123 /** Set VXLAN encapsulation details */
15124 struct cmd_set_vxlan_result {
15125 cmdline_fixed_string_t set;
15126 cmdline_fixed_string_t vxlan;
15127 cmdline_fixed_string_t pos_token;
15128 cmdline_fixed_string_t ip_version;
15129 uint32_t vlan_present:1;
15133 cmdline_ipaddr_t ip_src;
15134 cmdline_ipaddr_t ip_dst;
15136 struct ether_addr eth_src;
15137 struct ether_addr eth_dst;
15140 cmdline_parse_token_string_t cmd_set_vxlan_set =
15141 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15142 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15143 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15144 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15145 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15146 "vxlan-with-vlan");
15147 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15148 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15150 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15151 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15153 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15154 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15156 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15157 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15158 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15159 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15161 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15162 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15163 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15164 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15166 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15167 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15168 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15169 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15171 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15172 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15173 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15174 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15176 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15177 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15178 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15179 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15181 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15182 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15183 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15184 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15186 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15187 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15188 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15189 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15191 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15192 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15194 static void cmd_set_vxlan_parsed(void *parsed_result,
15195 __attribute__((unused)) struct cmdline *cl,
15196 __attribute__((unused)) void *data)
15198 struct cmd_set_vxlan_result *res = parsed_result;
15203 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15206 if (strcmp(res->vxlan, "vxlan") == 0)
15207 vxlan_encap_conf.select_vlan = 0;
15208 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15209 vxlan_encap_conf.select_vlan = 1;
15210 if (strcmp(res->ip_version, "ipv4") == 0)
15211 vxlan_encap_conf.select_ipv4 = 1;
15212 else if (strcmp(res->ip_version, "ipv6") == 0)
15213 vxlan_encap_conf.select_ipv4 = 0;
15216 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15217 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15218 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15219 if (vxlan_encap_conf.select_ipv4) {
15220 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15221 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15223 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15224 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15226 if (vxlan_encap_conf.select_vlan)
15227 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15228 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15230 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15234 cmdline_parse_inst_t cmd_set_vxlan = {
15235 .f = cmd_set_vxlan_parsed,
15237 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15238 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15239 " eth-src <eth-src> eth-dst <eth-dst>",
15241 (void *)&cmd_set_vxlan_set,
15242 (void *)&cmd_set_vxlan_vxlan,
15243 (void *)&cmd_set_vxlan_ip_version,
15244 (void *)&cmd_set_vxlan_ip_version_value,
15245 (void *)&cmd_set_vxlan_vni,
15246 (void *)&cmd_set_vxlan_vni_value,
15247 (void *)&cmd_set_vxlan_udp_src,
15248 (void *)&cmd_set_vxlan_udp_src_value,
15249 (void *)&cmd_set_vxlan_udp_dst,
15250 (void *)&cmd_set_vxlan_udp_dst_value,
15251 (void *)&cmd_set_vxlan_ip_src,
15252 (void *)&cmd_set_vxlan_ip_src_value,
15253 (void *)&cmd_set_vxlan_ip_dst,
15254 (void *)&cmd_set_vxlan_ip_dst_value,
15255 (void *)&cmd_set_vxlan_eth_src,
15256 (void *)&cmd_set_vxlan_eth_src_value,
15257 (void *)&cmd_set_vxlan_eth_dst,
15258 (void *)&cmd_set_vxlan_eth_dst_value,
15263 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15264 .f = cmd_set_vxlan_parsed,
15266 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15267 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15268 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15271 (void *)&cmd_set_vxlan_set,
15272 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15273 (void *)&cmd_set_vxlan_ip_version,
15274 (void *)&cmd_set_vxlan_ip_version_value,
15275 (void *)&cmd_set_vxlan_vni,
15276 (void *)&cmd_set_vxlan_vni_value,
15277 (void *)&cmd_set_vxlan_udp_src,
15278 (void *)&cmd_set_vxlan_udp_src_value,
15279 (void *)&cmd_set_vxlan_udp_dst,
15280 (void *)&cmd_set_vxlan_udp_dst_value,
15281 (void *)&cmd_set_vxlan_ip_src,
15282 (void *)&cmd_set_vxlan_ip_src_value,
15283 (void *)&cmd_set_vxlan_ip_dst,
15284 (void *)&cmd_set_vxlan_ip_dst_value,
15285 (void *)&cmd_set_vxlan_vlan,
15286 (void *)&cmd_set_vxlan_vlan_value,
15287 (void *)&cmd_set_vxlan_eth_src,
15288 (void *)&cmd_set_vxlan_eth_src_value,
15289 (void *)&cmd_set_vxlan_eth_dst,
15290 (void *)&cmd_set_vxlan_eth_dst_value,
15295 /** Set NVGRE encapsulation details */
15296 struct cmd_set_nvgre_result {
15297 cmdline_fixed_string_t set;
15298 cmdline_fixed_string_t nvgre;
15299 cmdline_fixed_string_t pos_token;
15300 cmdline_fixed_string_t ip_version;
15302 cmdline_ipaddr_t ip_src;
15303 cmdline_ipaddr_t ip_dst;
15305 struct ether_addr eth_src;
15306 struct ether_addr eth_dst;
15309 cmdline_parse_token_string_t cmd_set_nvgre_set =
15310 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15311 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15312 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15313 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15314 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15315 "nvgre-with-vlan");
15316 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15317 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15319 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15320 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15322 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15323 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15325 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15326 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15327 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15328 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15330 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15331 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15332 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15333 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15335 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15336 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15337 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15338 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15340 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15341 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15342 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15343 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15345 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15346 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15347 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15348 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15350 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15351 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15353 static void cmd_set_nvgre_parsed(void *parsed_result,
15354 __attribute__((unused)) struct cmdline *cl,
15355 __attribute__((unused)) void *data)
15357 struct cmd_set_nvgre_result *res = parsed_result;
15359 uint32_t nvgre_tni;
15362 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15365 if (strcmp(res->nvgre, "nvgre") == 0)
15366 nvgre_encap_conf.select_vlan = 0;
15367 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15368 nvgre_encap_conf.select_vlan = 1;
15369 if (strcmp(res->ip_version, "ipv4") == 0)
15370 nvgre_encap_conf.select_ipv4 = 1;
15371 else if (strcmp(res->ip_version, "ipv6") == 0)
15372 nvgre_encap_conf.select_ipv4 = 0;
15375 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15376 if (nvgre_encap_conf.select_ipv4) {
15377 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15378 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15380 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15381 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15383 if (nvgre_encap_conf.select_vlan)
15384 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15385 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15387 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15391 cmdline_parse_inst_t cmd_set_nvgre = {
15392 .f = cmd_set_nvgre_parsed,
15394 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15395 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15396 " eth-dst <eth-dst>",
15398 (void *)&cmd_set_nvgre_set,
15399 (void *)&cmd_set_nvgre_nvgre,
15400 (void *)&cmd_set_nvgre_ip_version,
15401 (void *)&cmd_set_nvgre_ip_version_value,
15402 (void *)&cmd_set_nvgre_tni,
15403 (void *)&cmd_set_nvgre_tni_value,
15404 (void *)&cmd_set_nvgre_ip_src,
15405 (void *)&cmd_set_nvgre_ip_src_value,
15406 (void *)&cmd_set_nvgre_ip_dst,
15407 (void *)&cmd_set_nvgre_ip_dst_value,
15408 (void *)&cmd_set_nvgre_eth_src,
15409 (void *)&cmd_set_nvgre_eth_src_value,
15410 (void *)&cmd_set_nvgre_eth_dst,
15411 (void *)&cmd_set_nvgre_eth_dst_value,
15416 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15417 .f = cmd_set_nvgre_parsed,
15419 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15420 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15421 " eth-src <eth-src> eth-dst <eth-dst>",
15423 (void *)&cmd_set_nvgre_set,
15424 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15425 (void *)&cmd_set_nvgre_ip_version,
15426 (void *)&cmd_set_nvgre_ip_version_value,
15427 (void *)&cmd_set_nvgre_tni,
15428 (void *)&cmd_set_nvgre_tni_value,
15429 (void *)&cmd_set_nvgre_ip_src,
15430 (void *)&cmd_set_nvgre_ip_src_value,
15431 (void *)&cmd_set_nvgre_ip_dst,
15432 (void *)&cmd_set_nvgre_ip_dst_value,
15433 (void *)&cmd_set_nvgre_vlan,
15434 (void *)&cmd_set_nvgre_vlan_value,
15435 (void *)&cmd_set_nvgre_eth_src,
15436 (void *)&cmd_set_nvgre_eth_src_value,
15437 (void *)&cmd_set_nvgre_eth_dst,
15438 (void *)&cmd_set_nvgre_eth_dst_value,
15443 /** Set L2 encapsulation details */
15444 struct cmd_set_l2_encap_result {
15445 cmdline_fixed_string_t set;
15446 cmdline_fixed_string_t l2_encap;
15447 cmdline_fixed_string_t pos_token;
15448 cmdline_fixed_string_t ip_version;
15449 uint32_t vlan_present:1;
15451 struct ether_addr eth_src;
15452 struct ether_addr eth_dst;
15455 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15456 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15457 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15458 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15459 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15460 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15461 "l2_encap-with-vlan");
15462 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15463 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15465 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15466 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15468 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15469 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15471 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15472 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15473 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15474 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15476 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15477 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15478 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15479 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15481 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15482 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15484 static void cmd_set_l2_encap_parsed(void *parsed_result,
15485 __attribute__((unused)) struct cmdline *cl,
15486 __attribute__((unused)) void *data)
15488 struct cmd_set_l2_encap_result *res = parsed_result;
15490 if (strcmp(res->l2_encap, "l2_encap") == 0)
15491 l2_encap_conf.select_vlan = 0;
15492 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15493 l2_encap_conf.select_vlan = 1;
15494 if (strcmp(res->ip_version, "ipv4") == 0)
15495 l2_encap_conf.select_ipv4 = 1;
15496 else if (strcmp(res->ip_version, "ipv6") == 0)
15497 l2_encap_conf.select_ipv4 = 0;
15500 if (l2_encap_conf.select_vlan)
15501 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15502 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15504 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15508 cmdline_parse_inst_t cmd_set_l2_encap = {
15509 .f = cmd_set_l2_encap_parsed,
15511 .help_str = "set l2_encap ip-version ipv4|ipv6"
15512 " eth-src <eth-src> eth-dst <eth-dst>",
15514 (void *)&cmd_set_l2_encap_set,
15515 (void *)&cmd_set_l2_encap_l2_encap,
15516 (void *)&cmd_set_l2_encap_ip_version,
15517 (void *)&cmd_set_l2_encap_ip_version_value,
15518 (void *)&cmd_set_l2_encap_eth_src,
15519 (void *)&cmd_set_l2_encap_eth_src_value,
15520 (void *)&cmd_set_l2_encap_eth_dst,
15521 (void *)&cmd_set_l2_encap_eth_dst_value,
15526 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15527 .f = cmd_set_l2_encap_parsed,
15529 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15530 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15532 (void *)&cmd_set_l2_encap_set,
15533 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15534 (void *)&cmd_set_l2_encap_ip_version,
15535 (void *)&cmd_set_l2_encap_ip_version_value,
15536 (void *)&cmd_set_l2_encap_vlan,
15537 (void *)&cmd_set_l2_encap_vlan_value,
15538 (void *)&cmd_set_l2_encap_eth_src,
15539 (void *)&cmd_set_l2_encap_eth_src_value,
15540 (void *)&cmd_set_l2_encap_eth_dst,
15541 (void *)&cmd_set_l2_encap_eth_dst_value,
15546 /** Set L2 decapsulation details */
15547 struct cmd_set_l2_decap_result {
15548 cmdline_fixed_string_t set;
15549 cmdline_fixed_string_t l2_decap;
15550 cmdline_fixed_string_t pos_token;
15551 uint32_t vlan_present:1;
15554 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15555 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15556 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15557 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15559 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15560 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15561 "l2_decap-with-vlan");
15563 static void cmd_set_l2_decap_parsed(void *parsed_result,
15564 __attribute__((unused)) struct cmdline *cl,
15565 __attribute__((unused)) void *data)
15567 struct cmd_set_l2_decap_result *res = parsed_result;
15569 if (strcmp(res->l2_decap, "l2_decap") == 0)
15570 l2_decap_conf.select_vlan = 0;
15571 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15572 l2_decap_conf.select_vlan = 1;
15575 cmdline_parse_inst_t cmd_set_l2_decap = {
15576 .f = cmd_set_l2_decap_parsed,
15578 .help_str = "set l2_decap",
15580 (void *)&cmd_set_l2_decap_set,
15581 (void *)&cmd_set_l2_decap_l2_decap,
15586 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15587 .f = cmd_set_l2_decap_parsed,
15589 .help_str = "set l2_decap-with-vlan",
15591 (void *)&cmd_set_l2_decap_set,
15592 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15597 /** Set MPLSoGRE encapsulation details */
15598 struct cmd_set_mplsogre_encap_result {
15599 cmdline_fixed_string_t set;
15600 cmdline_fixed_string_t mplsogre;
15601 cmdline_fixed_string_t pos_token;
15602 cmdline_fixed_string_t ip_version;
15603 uint32_t vlan_present:1;
15605 cmdline_ipaddr_t ip_src;
15606 cmdline_ipaddr_t ip_dst;
15608 struct ether_addr eth_src;
15609 struct ether_addr eth_dst;
15612 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15613 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15615 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15616 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15618 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15619 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15620 mplsogre, "mplsogre_encap-with-vlan");
15621 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15622 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15623 pos_token, "ip-version");
15624 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15625 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15626 ip_version, "ipv4#ipv6");
15627 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15628 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15629 pos_token, "label");
15630 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15631 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15633 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15634 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15635 pos_token, "ip-src");
15636 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15637 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15638 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15639 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15640 pos_token, "ip-dst");
15641 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15642 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15643 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15644 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15645 pos_token, "vlan-tci");
15646 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15647 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15649 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15650 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15651 pos_token, "eth-src");
15652 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15653 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15655 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15656 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15657 pos_token, "eth-dst");
15658 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15659 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15662 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15663 __attribute__((unused)) struct cmdline *cl,
15664 __attribute__((unused)) void *data)
15666 struct cmd_set_mplsogre_encap_result *res = parsed_result;
15668 uint32_t mplsogre_label;
15671 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15674 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15675 mplsogre_encap_conf.select_vlan = 0;
15676 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15677 mplsogre_encap_conf.select_vlan = 1;
15678 if (strcmp(res->ip_version, "ipv4") == 0)
15679 mplsogre_encap_conf.select_ipv4 = 1;
15680 else if (strcmp(res->ip_version, "ipv6") == 0)
15681 mplsogre_encap_conf.select_ipv4 = 0;
15684 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15685 if (mplsogre_encap_conf.select_ipv4) {
15686 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15687 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15689 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15690 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15692 if (mplsogre_encap_conf.select_vlan)
15693 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15694 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15696 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15700 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15701 .f = cmd_set_mplsogre_encap_parsed,
15703 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15704 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15705 " eth-dst <eth-dst>",
15707 (void *)&cmd_set_mplsogre_encap_set,
15708 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15709 (void *)&cmd_set_mplsogre_encap_ip_version,
15710 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15711 (void *)&cmd_set_mplsogre_encap_label,
15712 (void *)&cmd_set_mplsogre_encap_label_value,
15713 (void *)&cmd_set_mplsogre_encap_ip_src,
15714 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15715 (void *)&cmd_set_mplsogre_encap_ip_dst,
15716 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15717 (void *)&cmd_set_mplsogre_encap_eth_src,
15718 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15719 (void *)&cmd_set_mplsogre_encap_eth_dst,
15720 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15725 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
15726 .f = cmd_set_mplsogre_encap_parsed,
15728 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
15729 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
15730 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15732 (void *)&cmd_set_mplsogre_encap_set,
15733 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
15734 (void *)&cmd_set_mplsogre_encap_ip_version,
15735 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15736 (void *)&cmd_set_mplsogre_encap_label,
15737 (void *)&cmd_set_mplsogre_encap_label_value,
15738 (void *)&cmd_set_mplsogre_encap_ip_src,
15739 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15740 (void *)&cmd_set_mplsogre_encap_ip_dst,
15741 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15742 (void *)&cmd_set_mplsogre_encap_vlan,
15743 (void *)&cmd_set_mplsogre_encap_vlan_value,
15744 (void *)&cmd_set_mplsogre_encap_eth_src,
15745 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15746 (void *)&cmd_set_mplsogre_encap_eth_dst,
15747 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15752 /** Set MPLSoGRE decapsulation details */
15753 struct cmd_set_mplsogre_decap_result {
15754 cmdline_fixed_string_t set;
15755 cmdline_fixed_string_t mplsogre;
15756 cmdline_fixed_string_t pos_token;
15757 cmdline_fixed_string_t ip_version;
15758 uint32_t vlan_present:1;
15761 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
15762 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
15764 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
15765 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
15767 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
15768 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15769 mplsogre, "mplsogre_decap-with-vlan");
15770 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
15771 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15772 pos_token, "ip-version");
15773 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
15774 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15775 ip_version, "ipv4#ipv6");
15777 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
15778 __attribute__((unused)) struct cmdline *cl,
15779 __attribute__((unused)) void *data)
15781 struct cmd_set_mplsogre_decap_result *res = parsed_result;
15783 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
15784 mplsogre_decap_conf.select_vlan = 0;
15785 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
15786 mplsogre_decap_conf.select_vlan = 1;
15787 if (strcmp(res->ip_version, "ipv4") == 0)
15788 mplsogre_decap_conf.select_ipv4 = 1;
15789 else if (strcmp(res->ip_version, "ipv6") == 0)
15790 mplsogre_decap_conf.select_ipv4 = 0;
15793 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
15794 .f = cmd_set_mplsogre_decap_parsed,
15796 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
15798 (void *)&cmd_set_mplsogre_decap_set,
15799 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
15800 (void *)&cmd_set_mplsogre_decap_ip_version,
15801 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15806 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
15807 .f = cmd_set_mplsogre_decap_parsed,
15809 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
15811 (void *)&cmd_set_mplsogre_decap_set,
15812 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
15813 (void *)&cmd_set_mplsogre_decap_ip_version,
15814 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15819 /** Set MPLSoUDP encapsulation details */
15820 struct cmd_set_mplsoudp_encap_result {
15821 cmdline_fixed_string_t set;
15822 cmdline_fixed_string_t mplsoudp;
15823 cmdline_fixed_string_t pos_token;
15824 cmdline_fixed_string_t ip_version;
15825 uint32_t vlan_present:1;
15829 cmdline_ipaddr_t ip_src;
15830 cmdline_ipaddr_t ip_dst;
15832 struct ether_addr eth_src;
15833 struct ether_addr eth_dst;
15836 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
15837 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
15839 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
15840 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
15842 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
15843 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15844 mplsoudp, "mplsoudp_encap-with-vlan");
15845 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
15846 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15847 pos_token, "ip-version");
15848 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
15849 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15850 ip_version, "ipv4#ipv6");
15851 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
15852 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15853 pos_token, "label");
15854 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
15855 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
15857 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
15858 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15859 pos_token, "udp-src");
15860 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
15861 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
15863 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
15864 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15865 pos_token, "udp-dst");
15866 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
15867 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
15869 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
15870 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15871 pos_token, "ip-src");
15872 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
15873 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
15874 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
15875 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15876 pos_token, "ip-dst");
15877 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
15878 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
15879 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
15880 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15881 pos_token, "vlan-tci");
15882 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
15883 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
15885 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
15886 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15887 pos_token, "eth-src");
15888 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
15889 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15891 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
15892 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15893 pos_token, "eth-dst");
15894 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
15895 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15898 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
15899 __attribute__((unused)) struct cmdline *cl,
15900 __attribute__((unused)) void *data)
15902 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
15904 uint32_t mplsoudp_label;
15907 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
15910 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
15911 mplsoudp_encap_conf.select_vlan = 0;
15912 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
15913 mplsoudp_encap_conf.select_vlan = 1;
15914 if (strcmp(res->ip_version, "ipv4") == 0)
15915 mplsoudp_encap_conf.select_ipv4 = 1;
15916 else if (strcmp(res->ip_version, "ipv6") == 0)
15917 mplsoudp_encap_conf.select_ipv4 = 0;
15920 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
15921 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15922 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15923 if (mplsoudp_encap_conf.select_ipv4) {
15924 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
15925 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
15927 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
15928 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
15930 if (mplsoudp_encap_conf.select_vlan)
15931 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15932 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
15934 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15938 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
15939 .f = cmd_set_mplsoudp_encap_parsed,
15941 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
15942 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
15943 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
15945 (void *)&cmd_set_mplsoudp_encap_set,
15946 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
15947 (void *)&cmd_set_mplsoudp_encap_ip_version,
15948 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
15949 (void *)&cmd_set_mplsoudp_encap_label,
15950 (void *)&cmd_set_mplsoudp_encap_label_value,
15951 (void *)&cmd_set_mplsoudp_encap_udp_src,
15952 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
15953 (void *)&cmd_set_mplsoudp_encap_udp_dst,
15954 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
15955 (void *)&cmd_set_mplsoudp_encap_ip_src,
15956 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
15957 (void *)&cmd_set_mplsoudp_encap_ip_dst,
15958 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
15959 (void *)&cmd_set_mplsoudp_encap_eth_src,
15960 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
15961 (void *)&cmd_set_mplsoudp_encap_eth_dst,
15962 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
15967 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
15968 .f = cmd_set_mplsoudp_encap_parsed,
15970 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
15971 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
15972 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15973 " eth-src <eth-src> eth-dst <eth-dst>",
15975 (void *)&cmd_set_mplsoudp_encap_set,
15976 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
15977 (void *)&cmd_set_mplsoudp_encap_ip_version,
15978 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
15979 (void *)&cmd_set_mplsoudp_encap_label,
15980 (void *)&cmd_set_mplsoudp_encap_label_value,
15981 (void *)&cmd_set_mplsoudp_encap_udp_src,
15982 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
15983 (void *)&cmd_set_mplsoudp_encap_udp_dst,
15984 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
15985 (void *)&cmd_set_mplsoudp_encap_ip_src,
15986 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
15987 (void *)&cmd_set_mplsoudp_encap_ip_dst,
15988 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
15989 (void *)&cmd_set_mplsoudp_encap_vlan,
15990 (void *)&cmd_set_mplsoudp_encap_vlan_value,
15991 (void *)&cmd_set_mplsoudp_encap_eth_src,
15992 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
15993 (void *)&cmd_set_mplsoudp_encap_eth_dst,
15994 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
15999 /** Set MPLSoUDP decapsulation details */
16000 struct cmd_set_mplsoudp_decap_result {
16001 cmdline_fixed_string_t set;
16002 cmdline_fixed_string_t mplsoudp;
16003 cmdline_fixed_string_t pos_token;
16004 cmdline_fixed_string_t ip_version;
16005 uint32_t vlan_present:1;
16008 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16009 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16011 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16012 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16014 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16015 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16016 mplsoudp, "mplsoudp_decap-with-vlan");
16017 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16018 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16019 pos_token, "ip-version");
16020 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16021 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16022 ip_version, "ipv4#ipv6");
16024 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16025 __attribute__((unused)) struct cmdline *cl,
16026 __attribute__((unused)) void *data)
16028 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16030 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16031 mplsoudp_decap_conf.select_vlan = 0;
16032 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16033 mplsoudp_decap_conf.select_vlan = 1;
16034 if (strcmp(res->ip_version, "ipv4") == 0)
16035 mplsoudp_decap_conf.select_ipv4 = 1;
16036 else if (strcmp(res->ip_version, "ipv6") == 0)
16037 mplsoudp_decap_conf.select_ipv4 = 0;
16040 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16041 .f = cmd_set_mplsoudp_decap_parsed,
16043 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16045 (void *)&cmd_set_mplsoudp_decap_set,
16046 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16047 (void *)&cmd_set_mplsoudp_decap_ip_version,
16048 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16053 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16054 .f = cmd_set_mplsoudp_decap_parsed,
16056 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16058 (void *)&cmd_set_mplsoudp_decap_set,
16059 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16060 (void *)&cmd_set_mplsoudp_decap_ip_version,
16061 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16066 /* Strict link priority scheduling mode setting */
16068 cmd_strict_link_prio_parsed(
16069 void *parsed_result,
16070 __attribute__((unused)) struct cmdline *cl,
16071 __attribute__((unused)) void *data)
16073 struct cmd_vf_tc_bw_result *res = parsed_result;
16074 int ret = -ENOTSUP;
16076 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16079 #ifdef RTE_LIBRTE_I40E_PMD
16080 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16087 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16090 printf("invalid port_id %d\n", res->port_id);
16093 printf("function not implemented\n");
16096 printf("programming error: (%s)\n", strerror(-ret));
16100 cmdline_parse_inst_t cmd_strict_link_prio = {
16101 .f = cmd_strict_link_prio_parsed,
16103 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16105 (void *)&cmd_vf_tc_bw_set,
16106 (void *)&cmd_vf_tc_bw_tx,
16107 (void *)&cmd_vf_tc_bw_strict_link_prio,
16108 (void *)&cmd_vf_tc_bw_port_id,
16109 (void *)&cmd_vf_tc_bw_tc_map,
16114 /* Load dynamic device personalization*/
16115 struct cmd_ddp_add_result {
16116 cmdline_fixed_string_t ddp;
16117 cmdline_fixed_string_t add;
16122 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16123 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16124 cmdline_parse_token_string_t cmd_ddp_add_add =
16125 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16126 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16127 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16128 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16129 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16132 cmd_ddp_add_parsed(
16133 void *parsed_result,
16134 __attribute__((unused)) struct cmdline *cl,
16135 __attribute__((unused)) void *data)
16137 struct cmd_ddp_add_result *res = parsed_result;
16143 int ret = -ENOTSUP;
16145 if (!all_ports_stopped()) {
16146 printf("Please stop all ports first\n");
16150 filepath = strdup(res->filepath);
16151 if (filepath == NULL) {
16152 printf("Failed to allocate memory\n");
16155 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16157 buff = open_file(file_fld[0], &size);
16159 free((void *)filepath);
16163 #ifdef RTE_LIBRTE_I40E_PMD
16164 if (ret == -ENOTSUP)
16165 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16167 RTE_PMD_I40E_PKG_OP_WR_ADD);
16170 if (ret == -EEXIST)
16171 printf("Profile has already existed.\n");
16173 printf("Failed to load profile.\n");
16174 else if (file_num == 2)
16175 save_file(file_fld[1], buff, size);
16178 free((void *)filepath);
16181 cmdline_parse_inst_t cmd_ddp_add = {
16182 .f = cmd_ddp_add_parsed,
16184 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16186 (void *)&cmd_ddp_add_ddp,
16187 (void *)&cmd_ddp_add_add,
16188 (void *)&cmd_ddp_add_port_id,
16189 (void *)&cmd_ddp_add_filepath,
16194 /* Delete dynamic device personalization*/
16195 struct cmd_ddp_del_result {
16196 cmdline_fixed_string_t ddp;
16197 cmdline_fixed_string_t del;
16202 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16203 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16204 cmdline_parse_token_string_t cmd_ddp_del_del =
16205 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16206 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16207 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16208 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16209 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16212 cmd_ddp_del_parsed(
16213 void *parsed_result,
16214 __attribute__((unused)) struct cmdline *cl,
16215 __attribute__((unused)) void *data)
16217 struct cmd_ddp_del_result *res = parsed_result;
16220 int ret = -ENOTSUP;
16222 if (!all_ports_stopped()) {
16223 printf("Please stop all ports first\n");
16227 buff = open_file(res->filepath, &size);
16231 #ifdef RTE_LIBRTE_I40E_PMD
16232 if (ret == -ENOTSUP)
16233 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16235 RTE_PMD_I40E_PKG_OP_WR_DEL);
16238 if (ret == -EACCES)
16239 printf("Profile does not exist.\n");
16241 printf("Failed to delete profile.\n");
16246 cmdline_parse_inst_t cmd_ddp_del = {
16247 .f = cmd_ddp_del_parsed,
16249 .help_str = "ddp del <port_id> <backup_profile_path>",
16251 (void *)&cmd_ddp_del_ddp,
16252 (void *)&cmd_ddp_del_del,
16253 (void *)&cmd_ddp_del_port_id,
16254 (void *)&cmd_ddp_del_filepath,
16259 /* Get dynamic device personalization profile info */
16260 struct cmd_ddp_info_result {
16261 cmdline_fixed_string_t ddp;
16262 cmdline_fixed_string_t get;
16263 cmdline_fixed_string_t info;
16267 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16268 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16269 cmdline_parse_token_string_t cmd_ddp_info_get =
16270 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16271 cmdline_parse_token_string_t cmd_ddp_info_info =
16272 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16273 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16274 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16277 cmd_ddp_info_parsed(
16278 void *parsed_result,
16279 __attribute__((unused)) struct cmdline *cl,
16280 __attribute__((unused)) void *data)
16282 struct cmd_ddp_info_result *res = parsed_result;
16285 int ret = -ENOTSUP;
16286 #ifdef RTE_LIBRTE_I40E_PMD
16289 uint32_t buff_size = 0;
16290 struct rte_pmd_i40e_profile_info info;
16291 uint32_t dev_num = 0;
16292 struct rte_pmd_i40e_ddp_device_id *devs;
16293 uint32_t proto_num = 0;
16294 struct rte_pmd_i40e_proto_info *proto = NULL;
16295 uint32_t pctype_num = 0;
16296 struct rte_pmd_i40e_ptype_info *pctype;
16297 uint32_t ptype_num = 0;
16298 struct rte_pmd_i40e_ptype_info *ptype;
16303 pkg = open_file(res->filepath, &pkg_size);
16307 #ifdef RTE_LIBRTE_I40E_PMD
16308 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16309 (uint8_t *)&info, sizeof(info),
16310 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16312 printf("Global Track id: 0x%x\n", info.track_id);
16313 printf("Global Version: %d.%d.%d.%d\n",
16314 info.version.major,
16315 info.version.minor,
16316 info.version.update,
16317 info.version.draft);
16318 printf("Global Package name: %s\n\n", info.name);
16321 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16322 (uint8_t *)&info, sizeof(info),
16323 RTE_PMD_I40E_PKG_INFO_HEADER);
16325 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16326 printf("i40e Profile Version: %d.%d.%d.%d\n",
16327 info.version.major,
16328 info.version.minor,
16329 info.version.update,
16330 info.version.draft);
16331 printf("i40e Profile name: %s\n\n", info.name);
16334 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16335 (uint8_t *)&buff_size, sizeof(buff_size),
16336 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16337 if (!ret && buff_size) {
16338 buff = (uint8_t *)malloc(buff_size);
16340 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16342 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16344 printf("Package Notes:\n%s\n\n", buff);
16349 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16350 (uint8_t *)&dev_num, sizeof(dev_num),
16351 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16352 if (!ret && dev_num) {
16353 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16354 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16356 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16357 (uint8_t *)devs, buff_size,
16358 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16360 printf("List of supported devices:\n");
16361 for (i = 0; i < dev_num; i++) {
16362 printf(" %04X:%04X %04X:%04X\n",
16363 devs[i].vendor_dev_id >> 16,
16364 devs[i].vendor_dev_id & 0xFFFF,
16365 devs[i].sub_vendor_dev_id >> 16,
16366 devs[i].sub_vendor_dev_id & 0xFFFF);
16374 /* get information about protocols and packet types */
16375 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16376 (uint8_t *)&proto_num, sizeof(proto_num),
16377 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16378 if (ret || !proto_num)
16379 goto no_print_return;
16381 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16382 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16384 goto no_print_return;
16386 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16388 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16390 printf("List of used protocols:\n");
16391 for (i = 0; i < proto_num; i++)
16392 printf(" %2u: %s\n", proto[i].proto_id,
16396 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16397 (uint8_t *)&pctype_num, sizeof(pctype_num),
16398 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16399 if (ret || !pctype_num)
16400 goto no_print_pctypes;
16402 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16403 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16405 goto no_print_pctypes;
16407 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16409 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16412 goto no_print_pctypes;
16415 printf("List of defined packet classification types:\n");
16416 for (i = 0; i < pctype_num; i++) {
16417 printf(" %2u:", pctype[i].ptype_id);
16418 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16419 proto_id = pctype[i].protocols[j];
16420 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16421 for (n = 0; n < proto_num; n++) {
16422 if (proto[n].proto_id == proto_id) {
16423 printf(" %s", proto[n].name);
16436 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16438 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16439 if (ret || !ptype_num)
16440 goto no_print_return;
16442 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16443 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16445 goto no_print_return;
16447 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16449 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16452 goto no_print_return;
16454 printf("List of defined packet types:\n");
16455 for (i = 0; i < ptype_num; i++) {
16456 printf(" %2u:", ptype[i].ptype_id);
16457 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16458 proto_id = ptype[i].protocols[j];
16459 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16460 for (n = 0; n < proto_num; n++) {
16461 if (proto[n].proto_id == proto_id) {
16462 printf(" %s", proto[n].name);
16478 if (ret == -ENOTSUP)
16479 printf("Function not supported in PMD driver\n");
16483 cmdline_parse_inst_t cmd_ddp_get_info = {
16484 .f = cmd_ddp_info_parsed,
16486 .help_str = "ddp get info <profile_path>",
16488 (void *)&cmd_ddp_info_ddp,
16489 (void *)&cmd_ddp_info_get,
16490 (void *)&cmd_ddp_info_info,
16491 (void *)&cmd_ddp_info_filepath,
16496 /* Get dynamic device personalization profile info list*/
16497 #define PROFILE_INFO_SIZE 48
16498 #define MAX_PROFILE_NUM 16
16500 struct cmd_ddp_get_list_result {
16501 cmdline_fixed_string_t ddp;
16502 cmdline_fixed_string_t get;
16503 cmdline_fixed_string_t list;
16507 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16508 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16509 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16510 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16511 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16512 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16513 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16514 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16517 cmd_ddp_get_list_parsed(
16518 __attribute__((unused)) void *parsed_result,
16519 __attribute__((unused)) struct cmdline *cl,
16520 __attribute__((unused)) void *data)
16522 #ifdef RTE_LIBRTE_I40E_PMD
16523 struct cmd_ddp_get_list_result *res = parsed_result;
16524 struct rte_pmd_i40e_profile_list *p_list;
16525 struct rte_pmd_i40e_profile_info *p_info;
16530 int ret = -ENOTSUP;
16532 #ifdef RTE_LIBRTE_I40E_PMD
16533 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16534 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16536 printf("%s: Failed to malloc buffer\n", __func__);
16538 if (ret == -ENOTSUP)
16539 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16540 (uint8_t *)p_list, size);
16543 p_num = p_list->p_count;
16544 printf("Profile number is: %d\n\n", p_num);
16546 for (i = 0; i < p_num; i++) {
16547 p_info = &p_list->p_info[i];
16548 printf("Profile %d:\n", i);
16549 printf("Track id: 0x%x\n", p_info->track_id);
16550 printf("Version: %d.%d.%d.%d\n",
16551 p_info->version.major,
16552 p_info->version.minor,
16553 p_info->version.update,
16554 p_info->version.draft);
16555 printf("Profile name: %s\n\n", p_info->name);
16563 printf("Failed to get ddp list\n");
16566 cmdline_parse_inst_t cmd_ddp_get_list = {
16567 .f = cmd_ddp_get_list_parsed,
16569 .help_str = "ddp get list <port_id>",
16571 (void *)&cmd_ddp_get_list_ddp,
16572 (void *)&cmd_ddp_get_list_get,
16573 (void *)&cmd_ddp_get_list_list,
16574 (void *)&cmd_ddp_get_list_port_id,
16579 /* Configure input set */
16580 struct cmd_cfg_input_set_result {
16581 cmdline_fixed_string_t port;
16582 cmdline_fixed_string_t cfg;
16584 cmdline_fixed_string_t pctype;
16586 cmdline_fixed_string_t inset_type;
16587 cmdline_fixed_string_t opt;
16588 cmdline_fixed_string_t field;
16593 cmd_cfg_input_set_parsed(
16594 __attribute__((unused)) void *parsed_result,
16595 __attribute__((unused)) struct cmdline *cl,
16596 __attribute__((unused)) void *data)
16598 #ifdef RTE_LIBRTE_I40E_PMD
16599 struct cmd_cfg_input_set_result *res = parsed_result;
16600 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16601 struct rte_pmd_i40e_inset inset;
16603 int ret = -ENOTSUP;
16605 if (!all_ports_stopped()) {
16606 printf("Please stop all ports first\n");
16610 #ifdef RTE_LIBRTE_I40E_PMD
16611 if (!strcmp(res->inset_type, "hash_inset"))
16612 inset_type = INSET_HASH;
16613 else if (!strcmp(res->inset_type, "fdir_inset"))
16614 inset_type = INSET_FDIR;
16615 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16616 inset_type = INSET_FDIR_FLX;
16617 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16618 &inset, inset_type);
16620 printf("Failed to get input set.\n");
16624 if (!strcmp(res->opt, "get")) {
16625 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16628 printf("Field index %d is enabled.\n", res->field_idx);
16630 printf("Field index %d is disabled.\n", res->field_idx);
16632 } else if (!strcmp(res->opt, "set"))
16633 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16635 else if (!strcmp(res->opt, "clear"))
16636 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16639 printf("Failed to configure input set field.\n");
16643 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16644 &inset, inset_type);
16646 printf("Failed to set input set.\n");
16651 if (ret == -ENOTSUP)
16652 printf("Function not supported\n");
16655 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16656 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16658 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16659 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16661 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16662 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16664 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16665 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16667 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16668 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16670 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16671 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16673 "hash_inset#fdir_inset#fdir_flx_inset");
16674 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16675 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16676 opt, "get#set#clear");
16677 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16678 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16680 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16681 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16684 cmdline_parse_inst_t cmd_cfg_input_set = {
16685 .f = cmd_cfg_input_set_parsed,
16687 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16688 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16690 (void *)&cmd_cfg_input_set_port,
16691 (void *)&cmd_cfg_input_set_cfg,
16692 (void *)&cmd_cfg_input_set_port_id,
16693 (void *)&cmd_cfg_input_set_pctype,
16694 (void *)&cmd_cfg_input_set_pctype_id,
16695 (void *)&cmd_cfg_input_set_inset_type,
16696 (void *)&cmd_cfg_input_set_opt,
16697 (void *)&cmd_cfg_input_set_field,
16698 (void *)&cmd_cfg_input_set_field_idx,
16703 /* Clear input set */
16704 struct cmd_clear_input_set_result {
16705 cmdline_fixed_string_t port;
16706 cmdline_fixed_string_t cfg;
16708 cmdline_fixed_string_t pctype;
16710 cmdline_fixed_string_t inset_type;
16711 cmdline_fixed_string_t clear;
16712 cmdline_fixed_string_t all;
16716 cmd_clear_input_set_parsed(
16717 __attribute__((unused)) void *parsed_result,
16718 __attribute__((unused)) struct cmdline *cl,
16719 __attribute__((unused)) void *data)
16721 #ifdef RTE_LIBRTE_I40E_PMD
16722 struct cmd_clear_input_set_result *res = parsed_result;
16723 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16724 struct rte_pmd_i40e_inset inset;
16726 int ret = -ENOTSUP;
16728 if (!all_ports_stopped()) {
16729 printf("Please stop all ports first\n");
16733 #ifdef RTE_LIBRTE_I40E_PMD
16734 if (!strcmp(res->inset_type, "hash_inset"))
16735 inset_type = INSET_HASH;
16736 else if (!strcmp(res->inset_type, "fdir_inset"))
16737 inset_type = INSET_FDIR;
16738 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16739 inset_type = INSET_FDIR_FLX;
16741 memset(&inset, 0, sizeof(inset));
16743 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16744 &inset, inset_type);
16746 printf("Failed to clear input set.\n");
16752 if (ret == -ENOTSUP)
16753 printf("Function not supported\n");
16756 cmdline_parse_token_string_t cmd_clear_input_set_port =
16757 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16759 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
16760 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16762 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
16763 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16765 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
16766 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16768 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
16769 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16771 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
16772 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16774 "hash_inset#fdir_inset#fdir_flx_inset");
16775 cmdline_parse_token_string_t cmd_clear_input_set_clear =
16776 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16778 cmdline_parse_token_string_t cmd_clear_input_set_all =
16779 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16782 cmdline_parse_inst_t cmd_clear_input_set = {
16783 .f = cmd_clear_input_set_parsed,
16785 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16786 "fdir_inset|fdir_flx_inset clear all",
16788 (void *)&cmd_clear_input_set_port,
16789 (void *)&cmd_clear_input_set_cfg,
16790 (void *)&cmd_clear_input_set_port_id,
16791 (void *)&cmd_clear_input_set_pctype,
16792 (void *)&cmd_clear_input_set_pctype_id,
16793 (void *)&cmd_clear_input_set_inset_type,
16794 (void *)&cmd_clear_input_set_clear,
16795 (void *)&cmd_clear_input_set_all,
16800 /* show vf stats */
16802 /* Common result structure for show vf stats */
16803 struct cmd_show_vf_stats_result {
16804 cmdline_fixed_string_t show;
16805 cmdline_fixed_string_t vf;
16806 cmdline_fixed_string_t stats;
16811 /* Common CLI fields show vf stats*/
16812 cmdline_parse_token_string_t cmd_show_vf_stats_show =
16813 TOKEN_STRING_INITIALIZER
16814 (struct cmd_show_vf_stats_result,
16816 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
16817 TOKEN_STRING_INITIALIZER
16818 (struct cmd_show_vf_stats_result,
16820 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
16821 TOKEN_STRING_INITIALIZER
16822 (struct cmd_show_vf_stats_result,
16824 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
16825 TOKEN_NUM_INITIALIZER
16826 (struct cmd_show_vf_stats_result,
16828 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
16829 TOKEN_NUM_INITIALIZER
16830 (struct cmd_show_vf_stats_result,
16834 cmd_show_vf_stats_parsed(
16835 void *parsed_result,
16836 __attribute__((unused)) struct cmdline *cl,
16837 __attribute__((unused)) void *data)
16839 struct cmd_show_vf_stats_result *res = parsed_result;
16840 struct rte_eth_stats stats;
16841 int ret = -ENOTSUP;
16842 static const char *nic_stats_border = "########################";
16844 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16847 memset(&stats, 0, sizeof(stats));
16849 #ifdef RTE_LIBRTE_I40E_PMD
16850 if (ret == -ENOTSUP)
16851 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
16855 #ifdef RTE_LIBRTE_BNXT_PMD
16856 if (ret == -ENOTSUP)
16857 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
16866 printf("invalid vf_id %d\n", res->vf_id);
16869 printf("invalid port_id %d\n", res->port_id);
16872 printf("function not implemented\n");
16875 printf("programming error: (%s)\n", strerror(-ret));
16878 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
16879 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
16881 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
16883 stats.ipackets, stats.imissed, stats.ibytes);
16884 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
16885 printf(" RX-nombuf: %-10"PRIu64"\n",
16887 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
16889 stats.opackets, stats.oerrors, stats.obytes);
16891 printf(" %s############################%s\n",
16892 nic_stats_border, nic_stats_border);
16895 cmdline_parse_inst_t cmd_show_vf_stats = {
16896 .f = cmd_show_vf_stats_parsed,
16898 .help_str = "show vf stats <port_id> <vf_id>",
16900 (void *)&cmd_show_vf_stats_show,
16901 (void *)&cmd_show_vf_stats_vf,
16902 (void *)&cmd_show_vf_stats_stats,
16903 (void *)&cmd_show_vf_stats_port_id,
16904 (void *)&cmd_show_vf_stats_vf_id,
16909 /* clear vf stats */
16911 /* Common result structure for clear vf stats */
16912 struct cmd_clear_vf_stats_result {
16913 cmdline_fixed_string_t clear;
16914 cmdline_fixed_string_t vf;
16915 cmdline_fixed_string_t stats;
16920 /* Common CLI fields clear vf stats*/
16921 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
16922 TOKEN_STRING_INITIALIZER
16923 (struct cmd_clear_vf_stats_result,
16925 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
16926 TOKEN_STRING_INITIALIZER
16927 (struct cmd_clear_vf_stats_result,
16929 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
16930 TOKEN_STRING_INITIALIZER
16931 (struct cmd_clear_vf_stats_result,
16933 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
16934 TOKEN_NUM_INITIALIZER
16935 (struct cmd_clear_vf_stats_result,
16937 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
16938 TOKEN_NUM_INITIALIZER
16939 (struct cmd_clear_vf_stats_result,
16943 cmd_clear_vf_stats_parsed(
16944 void *parsed_result,
16945 __attribute__((unused)) struct cmdline *cl,
16946 __attribute__((unused)) void *data)
16948 struct cmd_clear_vf_stats_result *res = parsed_result;
16949 int ret = -ENOTSUP;
16951 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16954 #ifdef RTE_LIBRTE_I40E_PMD
16955 if (ret == -ENOTSUP)
16956 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
16959 #ifdef RTE_LIBRTE_BNXT_PMD
16960 if (ret == -ENOTSUP)
16961 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
16969 printf("invalid vf_id %d\n", res->vf_id);
16972 printf("invalid port_id %d\n", res->port_id);
16975 printf("function not implemented\n");
16978 printf("programming error: (%s)\n", strerror(-ret));
16982 cmdline_parse_inst_t cmd_clear_vf_stats = {
16983 .f = cmd_clear_vf_stats_parsed,
16985 .help_str = "clear vf stats <port_id> <vf_id>",
16987 (void *)&cmd_clear_vf_stats_clear,
16988 (void *)&cmd_clear_vf_stats_vf,
16989 (void *)&cmd_clear_vf_stats_stats,
16990 (void *)&cmd_clear_vf_stats_port_id,
16991 (void *)&cmd_clear_vf_stats_vf_id,
16996 /* port config pctype mapping reset */
16998 /* Common result structure for port config pctype mapping reset */
16999 struct cmd_pctype_mapping_reset_result {
17000 cmdline_fixed_string_t port;
17001 cmdline_fixed_string_t config;
17003 cmdline_fixed_string_t pctype;
17004 cmdline_fixed_string_t mapping;
17005 cmdline_fixed_string_t reset;
17008 /* Common CLI fields for port config pctype mapping reset*/
17009 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17010 TOKEN_STRING_INITIALIZER
17011 (struct cmd_pctype_mapping_reset_result,
17013 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17014 TOKEN_STRING_INITIALIZER
17015 (struct cmd_pctype_mapping_reset_result,
17017 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17018 TOKEN_NUM_INITIALIZER
17019 (struct cmd_pctype_mapping_reset_result,
17021 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17022 TOKEN_STRING_INITIALIZER
17023 (struct cmd_pctype_mapping_reset_result,
17025 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17026 TOKEN_STRING_INITIALIZER
17027 (struct cmd_pctype_mapping_reset_result,
17028 mapping, "mapping");
17029 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17030 TOKEN_STRING_INITIALIZER
17031 (struct cmd_pctype_mapping_reset_result,
17035 cmd_pctype_mapping_reset_parsed(
17036 void *parsed_result,
17037 __attribute__((unused)) struct cmdline *cl,
17038 __attribute__((unused)) void *data)
17040 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17041 int ret = -ENOTSUP;
17043 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17046 #ifdef RTE_LIBRTE_I40E_PMD
17047 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17054 printf("invalid port_id %d\n", res->port_id);
17057 printf("function not implemented\n");
17060 printf("programming error: (%s)\n", strerror(-ret));
17064 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17065 .f = cmd_pctype_mapping_reset_parsed,
17067 .help_str = "port config <port_id> pctype mapping reset",
17069 (void *)&cmd_pctype_mapping_reset_port,
17070 (void *)&cmd_pctype_mapping_reset_config,
17071 (void *)&cmd_pctype_mapping_reset_port_id,
17072 (void *)&cmd_pctype_mapping_reset_pctype,
17073 (void *)&cmd_pctype_mapping_reset_mapping,
17074 (void *)&cmd_pctype_mapping_reset_reset,
17079 /* show port pctype mapping */
17081 /* Common result structure for show port pctype mapping */
17082 struct cmd_pctype_mapping_get_result {
17083 cmdline_fixed_string_t show;
17084 cmdline_fixed_string_t port;
17086 cmdline_fixed_string_t pctype;
17087 cmdline_fixed_string_t mapping;
17090 /* Common CLI fields for pctype mapping get */
17091 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17092 TOKEN_STRING_INITIALIZER
17093 (struct cmd_pctype_mapping_get_result,
17095 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17096 TOKEN_STRING_INITIALIZER
17097 (struct cmd_pctype_mapping_get_result,
17099 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17100 TOKEN_NUM_INITIALIZER
17101 (struct cmd_pctype_mapping_get_result,
17103 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17104 TOKEN_STRING_INITIALIZER
17105 (struct cmd_pctype_mapping_get_result,
17107 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17108 TOKEN_STRING_INITIALIZER
17109 (struct cmd_pctype_mapping_get_result,
17110 mapping, "mapping");
17113 cmd_pctype_mapping_get_parsed(
17114 void *parsed_result,
17115 __attribute__((unused)) struct cmdline *cl,
17116 __attribute__((unused)) void *data)
17118 struct cmd_pctype_mapping_get_result *res = parsed_result;
17119 int ret = -ENOTSUP;
17120 #ifdef RTE_LIBRTE_I40E_PMD
17121 struct rte_pmd_i40e_flow_type_mapping
17122 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17123 int i, j, first_pctype;
17126 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17129 #ifdef RTE_LIBRTE_I40E_PMD
17130 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17137 printf("invalid port_id %d\n", res->port_id);
17140 printf("function not implemented\n");
17143 printf("programming error: (%s)\n", strerror(-ret));
17147 #ifdef RTE_LIBRTE_I40E_PMD
17148 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17149 if (mapping[i].pctype != 0ULL) {
17152 printf("pctype: ");
17153 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17154 if (mapping[i].pctype & (1ULL << j)) {
17155 printf(first_pctype ?
17156 "%02d" : ",%02d", j);
17160 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17166 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17167 .f = cmd_pctype_mapping_get_parsed,
17169 .help_str = "show port <port_id> pctype mapping",
17171 (void *)&cmd_pctype_mapping_get_show,
17172 (void *)&cmd_pctype_mapping_get_port,
17173 (void *)&cmd_pctype_mapping_get_port_id,
17174 (void *)&cmd_pctype_mapping_get_pctype,
17175 (void *)&cmd_pctype_mapping_get_mapping,
17180 /* port config pctype mapping update */
17182 /* Common result structure for port config pctype mapping update */
17183 struct cmd_pctype_mapping_update_result {
17184 cmdline_fixed_string_t port;
17185 cmdline_fixed_string_t config;
17187 cmdline_fixed_string_t pctype;
17188 cmdline_fixed_string_t mapping;
17189 cmdline_fixed_string_t update;
17190 cmdline_fixed_string_t pctype_list;
17191 uint16_t flow_type;
17194 /* Common CLI fields for pctype mapping update*/
17195 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17196 TOKEN_STRING_INITIALIZER
17197 (struct cmd_pctype_mapping_update_result,
17199 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17200 TOKEN_STRING_INITIALIZER
17201 (struct cmd_pctype_mapping_update_result,
17203 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17204 TOKEN_NUM_INITIALIZER
17205 (struct cmd_pctype_mapping_update_result,
17207 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17208 TOKEN_STRING_INITIALIZER
17209 (struct cmd_pctype_mapping_update_result,
17211 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17212 TOKEN_STRING_INITIALIZER
17213 (struct cmd_pctype_mapping_update_result,
17214 mapping, "mapping");
17215 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17216 TOKEN_STRING_INITIALIZER
17217 (struct cmd_pctype_mapping_update_result,
17219 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17220 TOKEN_STRING_INITIALIZER
17221 (struct cmd_pctype_mapping_update_result,
17222 pctype_list, NULL);
17223 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17224 TOKEN_NUM_INITIALIZER
17225 (struct cmd_pctype_mapping_update_result,
17226 flow_type, UINT16);
17229 cmd_pctype_mapping_update_parsed(
17230 void *parsed_result,
17231 __attribute__((unused)) struct cmdline *cl,
17232 __attribute__((unused)) void *data)
17234 struct cmd_pctype_mapping_update_result *res = parsed_result;
17235 int ret = -ENOTSUP;
17236 #ifdef RTE_LIBRTE_I40E_PMD
17237 struct rte_pmd_i40e_flow_type_mapping mapping;
17239 unsigned int nb_item;
17240 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17243 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17246 #ifdef RTE_LIBRTE_I40E_PMD
17247 nb_item = parse_item_list(res->pctype_list, "pctypes",
17248 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17249 mapping.flow_type = res->flow_type;
17250 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17251 mapping.pctype |= (1ULL << pctype_list[i]);
17252 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17262 printf("invalid pctype or flow type\n");
17265 printf("invalid port_id %d\n", res->port_id);
17268 printf("function not implemented\n");
17271 printf("programming error: (%s)\n", strerror(-ret));
17275 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17276 .f = cmd_pctype_mapping_update_parsed,
17278 .help_str = "port config <port_id> pctype mapping update"
17279 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17281 (void *)&cmd_pctype_mapping_update_port,
17282 (void *)&cmd_pctype_mapping_update_config,
17283 (void *)&cmd_pctype_mapping_update_port_id,
17284 (void *)&cmd_pctype_mapping_update_pctype,
17285 (void *)&cmd_pctype_mapping_update_mapping,
17286 (void *)&cmd_pctype_mapping_update_update,
17287 (void *)&cmd_pctype_mapping_update_pc_type,
17288 (void *)&cmd_pctype_mapping_update_flow_type,
17293 /* ptype mapping get */
17295 /* Common result structure for ptype mapping get */
17296 struct cmd_ptype_mapping_get_result {
17297 cmdline_fixed_string_t ptype;
17298 cmdline_fixed_string_t mapping;
17299 cmdline_fixed_string_t get;
17301 uint8_t valid_only;
17304 /* Common CLI fields for ptype mapping get */
17305 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17306 TOKEN_STRING_INITIALIZER
17307 (struct cmd_ptype_mapping_get_result,
17309 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17310 TOKEN_STRING_INITIALIZER
17311 (struct cmd_ptype_mapping_get_result,
17312 mapping, "mapping");
17313 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17314 TOKEN_STRING_INITIALIZER
17315 (struct cmd_ptype_mapping_get_result,
17317 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17318 TOKEN_NUM_INITIALIZER
17319 (struct cmd_ptype_mapping_get_result,
17321 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17322 TOKEN_NUM_INITIALIZER
17323 (struct cmd_ptype_mapping_get_result,
17324 valid_only, UINT8);
17327 cmd_ptype_mapping_get_parsed(
17328 void *parsed_result,
17329 __attribute__((unused)) struct cmdline *cl,
17330 __attribute__((unused)) void *data)
17332 struct cmd_ptype_mapping_get_result *res = parsed_result;
17333 int ret = -ENOTSUP;
17334 #ifdef RTE_LIBRTE_I40E_PMD
17335 int max_ptype_num = 256;
17336 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17341 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17344 #ifdef RTE_LIBRTE_I40E_PMD
17345 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17356 printf("invalid port_id %d\n", res->port_id);
17359 printf("function not implemented\n");
17362 printf("programming error: (%s)\n", strerror(-ret));
17365 #ifdef RTE_LIBRTE_I40E_PMD
17367 for (i = 0; i < count; i++)
17368 printf("%3d\t0x%08x\n",
17369 mapping[i].hw_ptype, mapping[i].sw_ptype);
17374 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17375 .f = cmd_ptype_mapping_get_parsed,
17377 .help_str = "ptype mapping get <port_id> <valid_only>",
17379 (void *)&cmd_ptype_mapping_get_ptype,
17380 (void *)&cmd_ptype_mapping_get_mapping,
17381 (void *)&cmd_ptype_mapping_get_get,
17382 (void *)&cmd_ptype_mapping_get_port_id,
17383 (void *)&cmd_ptype_mapping_get_valid_only,
17388 /* ptype mapping replace */
17390 /* Common result structure for ptype mapping replace */
17391 struct cmd_ptype_mapping_replace_result {
17392 cmdline_fixed_string_t ptype;
17393 cmdline_fixed_string_t mapping;
17394 cmdline_fixed_string_t replace;
17401 /* Common CLI fields for ptype mapping replace */
17402 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17403 TOKEN_STRING_INITIALIZER
17404 (struct cmd_ptype_mapping_replace_result,
17406 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17407 TOKEN_STRING_INITIALIZER
17408 (struct cmd_ptype_mapping_replace_result,
17409 mapping, "mapping");
17410 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17411 TOKEN_STRING_INITIALIZER
17412 (struct cmd_ptype_mapping_replace_result,
17413 replace, "replace");
17414 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17415 TOKEN_NUM_INITIALIZER
17416 (struct cmd_ptype_mapping_replace_result,
17418 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17419 TOKEN_NUM_INITIALIZER
17420 (struct cmd_ptype_mapping_replace_result,
17422 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17423 TOKEN_NUM_INITIALIZER
17424 (struct cmd_ptype_mapping_replace_result,
17426 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17427 TOKEN_NUM_INITIALIZER
17428 (struct cmd_ptype_mapping_replace_result,
17432 cmd_ptype_mapping_replace_parsed(
17433 void *parsed_result,
17434 __attribute__((unused)) struct cmdline *cl,
17435 __attribute__((unused)) void *data)
17437 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17438 int ret = -ENOTSUP;
17440 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17443 #ifdef RTE_LIBRTE_I40E_PMD
17444 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17454 printf("invalid ptype 0x%8x or 0x%8x\n",
17455 res->target, res->pkt_type);
17458 printf("invalid port_id %d\n", res->port_id);
17461 printf("function not implemented\n");
17464 printf("programming error: (%s)\n", strerror(-ret));
17468 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17469 .f = cmd_ptype_mapping_replace_parsed,
17472 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17474 (void *)&cmd_ptype_mapping_replace_ptype,
17475 (void *)&cmd_ptype_mapping_replace_mapping,
17476 (void *)&cmd_ptype_mapping_replace_replace,
17477 (void *)&cmd_ptype_mapping_replace_port_id,
17478 (void *)&cmd_ptype_mapping_replace_target,
17479 (void *)&cmd_ptype_mapping_replace_mask,
17480 (void *)&cmd_ptype_mapping_replace_pkt_type,
17485 /* ptype mapping reset */
17487 /* Common result structure for ptype mapping reset */
17488 struct cmd_ptype_mapping_reset_result {
17489 cmdline_fixed_string_t ptype;
17490 cmdline_fixed_string_t mapping;
17491 cmdline_fixed_string_t reset;
17495 /* Common CLI fields for ptype mapping reset*/
17496 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17497 TOKEN_STRING_INITIALIZER
17498 (struct cmd_ptype_mapping_reset_result,
17500 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17501 TOKEN_STRING_INITIALIZER
17502 (struct cmd_ptype_mapping_reset_result,
17503 mapping, "mapping");
17504 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17505 TOKEN_STRING_INITIALIZER
17506 (struct cmd_ptype_mapping_reset_result,
17508 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17509 TOKEN_NUM_INITIALIZER
17510 (struct cmd_ptype_mapping_reset_result,
17514 cmd_ptype_mapping_reset_parsed(
17515 void *parsed_result,
17516 __attribute__((unused)) struct cmdline *cl,
17517 __attribute__((unused)) void *data)
17519 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17520 int ret = -ENOTSUP;
17522 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17525 #ifdef RTE_LIBRTE_I40E_PMD
17526 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17533 printf("invalid port_id %d\n", res->port_id);
17536 printf("function not implemented\n");
17539 printf("programming error: (%s)\n", strerror(-ret));
17543 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17544 .f = cmd_ptype_mapping_reset_parsed,
17546 .help_str = "ptype mapping reset <port_id>",
17548 (void *)&cmd_ptype_mapping_reset_ptype,
17549 (void *)&cmd_ptype_mapping_reset_mapping,
17550 (void *)&cmd_ptype_mapping_reset_reset,
17551 (void *)&cmd_ptype_mapping_reset_port_id,
17556 /* ptype mapping update */
17558 /* Common result structure for ptype mapping update */
17559 struct cmd_ptype_mapping_update_result {
17560 cmdline_fixed_string_t ptype;
17561 cmdline_fixed_string_t mapping;
17562 cmdline_fixed_string_t reset;
17568 /* Common CLI fields for ptype mapping update*/
17569 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17570 TOKEN_STRING_INITIALIZER
17571 (struct cmd_ptype_mapping_update_result,
17573 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17574 TOKEN_STRING_INITIALIZER
17575 (struct cmd_ptype_mapping_update_result,
17576 mapping, "mapping");
17577 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17578 TOKEN_STRING_INITIALIZER
17579 (struct cmd_ptype_mapping_update_result,
17581 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17582 TOKEN_NUM_INITIALIZER
17583 (struct cmd_ptype_mapping_update_result,
17585 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17586 TOKEN_NUM_INITIALIZER
17587 (struct cmd_ptype_mapping_update_result,
17589 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17590 TOKEN_NUM_INITIALIZER
17591 (struct cmd_ptype_mapping_update_result,
17595 cmd_ptype_mapping_update_parsed(
17596 void *parsed_result,
17597 __attribute__((unused)) struct cmdline *cl,
17598 __attribute__((unused)) void *data)
17600 struct cmd_ptype_mapping_update_result *res = parsed_result;
17601 int ret = -ENOTSUP;
17602 #ifdef RTE_LIBRTE_I40E_PMD
17603 struct rte_pmd_i40e_ptype_mapping mapping;
17605 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17608 #ifdef RTE_LIBRTE_I40E_PMD
17609 mapping.hw_ptype = res->hw_ptype;
17610 mapping.sw_ptype = res->sw_ptype;
17611 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17621 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17624 printf("invalid port_id %d\n", res->port_id);
17627 printf("function not implemented\n");
17630 printf("programming error: (%s)\n", strerror(-ret));
17634 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17635 .f = cmd_ptype_mapping_update_parsed,
17637 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17639 (void *)&cmd_ptype_mapping_update_ptype,
17640 (void *)&cmd_ptype_mapping_update_mapping,
17641 (void *)&cmd_ptype_mapping_update_update,
17642 (void *)&cmd_ptype_mapping_update_port_id,
17643 (void *)&cmd_ptype_mapping_update_hw_ptype,
17644 (void *)&cmd_ptype_mapping_update_sw_ptype,
17649 /* Common result structure for file commands */
17650 struct cmd_cmdfile_result {
17651 cmdline_fixed_string_t load;
17652 cmdline_fixed_string_t filename;
17655 /* Common CLI fields for file commands */
17656 cmdline_parse_token_string_t cmd_load_cmdfile =
17657 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17658 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17659 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17662 cmd_load_from_file_parsed(
17663 void *parsed_result,
17664 __attribute__((unused)) struct cmdline *cl,
17665 __attribute__((unused)) void *data)
17667 struct cmd_cmdfile_result *res = parsed_result;
17669 cmdline_read_from_file(res->filename);
17672 cmdline_parse_inst_t cmd_load_from_file = {
17673 .f = cmd_load_from_file_parsed,
17675 .help_str = "load <filename>",
17677 (void *)&cmd_load_cmdfile,
17678 (void *)&cmd_load_cmdfile_filename,
17683 /* Get Rx offloads capabilities */
17684 struct cmd_rx_offload_get_capa_result {
17685 cmdline_fixed_string_t show;
17686 cmdline_fixed_string_t port;
17688 cmdline_fixed_string_t rx_offload;
17689 cmdline_fixed_string_t capabilities;
17692 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17693 TOKEN_STRING_INITIALIZER
17694 (struct cmd_rx_offload_get_capa_result,
17696 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17697 TOKEN_STRING_INITIALIZER
17698 (struct cmd_rx_offload_get_capa_result,
17700 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17701 TOKEN_NUM_INITIALIZER
17702 (struct cmd_rx_offload_get_capa_result,
17704 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17705 TOKEN_STRING_INITIALIZER
17706 (struct cmd_rx_offload_get_capa_result,
17707 rx_offload, "rx_offload");
17708 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17709 TOKEN_STRING_INITIALIZER
17710 (struct cmd_rx_offload_get_capa_result,
17711 capabilities, "capabilities");
17714 print_rx_offloads(uint64_t offloads)
17716 uint64_t single_offload;
17724 begin = __builtin_ctzll(offloads);
17725 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17727 single_offload = 1ULL << begin;
17728 for (bit = begin; bit < end; bit++) {
17729 if (offloads & single_offload)
17731 rte_eth_dev_rx_offload_name(single_offload));
17732 single_offload <<= 1;
17737 cmd_rx_offload_get_capa_parsed(
17738 void *parsed_result,
17739 __attribute__((unused)) struct cmdline *cl,
17740 __attribute__((unused)) void *data)
17742 struct cmd_rx_offload_get_capa_result *res = parsed_result;
17743 struct rte_eth_dev_info dev_info;
17744 portid_t port_id = res->port_id;
17745 uint64_t queue_offloads;
17746 uint64_t port_offloads;
17748 rte_eth_dev_info_get(port_id, &dev_info);
17749 queue_offloads = dev_info.rx_queue_offload_capa;
17750 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
17752 printf("Rx Offloading Capabilities of port %d :\n", port_id);
17753 printf(" Per Queue :");
17754 print_rx_offloads(queue_offloads);
17757 printf(" Per Port :");
17758 print_rx_offloads(port_offloads);
17762 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
17763 .f = cmd_rx_offload_get_capa_parsed,
17765 .help_str = "show port <port_id> rx_offload capabilities",
17767 (void *)&cmd_rx_offload_get_capa_show,
17768 (void *)&cmd_rx_offload_get_capa_port,
17769 (void *)&cmd_rx_offload_get_capa_port_id,
17770 (void *)&cmd_rx_offload_get_capa_rx_offload,
17771 (void *)&cmd_rx_offload_get_capa_capabilities,
17776 /* Get Rx offloads configuration */
17777 struct cmd_rx_offload_get_configuration_result {
17778 cmdline_fixed_string_t show;
17779 cmdline_fixed_string_t port;
17781 cmdline_fixed_string_t rx_offload;
17782 cmdline_fixed_string_t configuration;
17785 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
17786 TOKEN_STRING_INITIALIZER
17787 (struct cmd_rx_offload_get_configuration_result,
17789 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
17790 TOKEN_STRING_INITIALIZER
17791 (struct cmd_rx_offload_get_configuration_result,
17793 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
17794 TOKEN_NUM_INITIALIZER
17795 (struct cmd_rx_offload_get_configuration_result,
17797 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
17798 TOKEN_STRING_INITIALIZER
17799 (struct cmd_rx_offload_get_configuration_result,
17800 rx_offload, "rx_offload");
17801 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
17802 TOKEN_STRING_INITIALIZER
17803 (struct cmd_rx_offload_get_configuration_result,
17804 configuration, "configuration");
17807 cmd_rx_offload_get_configuration_parsed(
17808 void *parsed_result,
17809 __attribute__((unused)) struct cmdline *cl,
17810 __attribute__((unused)) void *data)
17812 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
17813 struct rte_eth_dev_info dev_info;
17814 portid_t port_id = res->port_id;
17815 struct rte_port *port = &ports[port_id];
17816 uint64_t port_offloads;
17817 uint64_t queue_offloads;
17818 uint16_t nb_rx_queues;
17821 printf("Rx Offloading Configuration of port %d :\n", port_id);
17823 port_offloads = port->dev_conf.rxmode.offloads;
17825 print_rx_offloads(port_offloads);
17828 rte_eth_dev_info_get(port_id, &dev_info);
17829 nb_rx_queues = dev_info.nb_rx_queues;
17830 for (q = 0; q < nb_rx_queues; q++) {
17831 queue_offloads = port->rx_conf[q].offloads;
17832 printf(" Queue[%2d] :", q);
17833 print_rx_offloads(queue_offloads);
17839 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
17840 .f = cmd_rx_offload_get_configuration_parsed,
17842 .help_str = "show port <port_id> rx_offload configuration",
17844 (void *)&cmd_rx_offload_get_configuration_show,
17845 (void *)&cmd_rx_offload_get_configuration_port,
17846 (void *)&cmd_rx_offload_get_configuration_port_id,
17847 (void *)&cmd_rx_offload_get_configuration_rx_offload,
17848 (void *)&cmd_rx_offload_get_configuration_configuration,
17853 /* Enable/Disable a per port offloading */
17854 struct cmd_config_per_port_rx_offload_result {
17855 cmdline_fixed_string_t port;
17856 cmdline_fixed_string_t config;
17858 cmdline_fixed_string_t rx_offload;
17859 cmdline_fixed_string_t offload;
17860 cmdline_fixed_string_t on_off;
17863 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
17864 TOKEN_STRING_INITIALIZER
17865 (struct cmd_config_per_port_rx_offload_result,
17867 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
17868 TOKEN_STRING_INITIALIZER
17869 (struct cmd_config_per_port_rx_offload_result,
17871 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
17872 TOKEN_NUM_INITIALIZER
17873 (struct cmd_config_per_port_rx_offload_result,
17875 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
17876 TOKEN_STRING_INITIALIZER
17877 (struct cmd_config_per_port_rx_offload_result,
17878 rx_offload, "rx_offload");
17879 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
17880 TOKEN_STRING_INITIALIZER
17881 (struct cmd_config_per_port_rx_offload_result,
17882 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
17883 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
17884 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
17885 "crc_strip#scatter#timestamp#security#keep_crc");
17886 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
17887 TOKEN_STRING_INITIALIZER
17888 (struct cmd_config_per_port_rx_offload_result,
17892 search_rx_offload(const char *name)
17894 uint64_t single_offload;
17895 const char *single_name;
17899 single_offload = 1;
17900 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
17901 single_name = rte_eth_dev_rx_offload_name(single_offload);
17902 if (!strcasecmp(single_name, name)) {
17906 single_offload <<= 1;
17910 return single_offload;
17916 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
17917 __attribute__((unused)) struct cmdline *cl,
17918 __attribute__((unused)) void *data)
17920 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
17921 portid_t port_id = res->port_id;
17922 struct rte_eth_dev_info dev_info;
17923 struct rte_port *port = &ports[port_id];
17924 uint64_t single_offload;
17925 uint16_t nb_rx_queues;
17928 if (port->port_status != RTE_PORT_STOPPED) {
17929 printf("Error: Can't config offload when Port %d "
17930 "is not stopped\n", port_id);
17934 single_offload = search_rx_offload(res->offload);
17935 if (single_offload == 0) {
17936 printf("Unknown offload name: %s\n", res->offload);
17940 rte_eth_dev_info_get(port_id, &dev_info);
17941 nb_rx_queues = dev_info.nb_rx_queues;
17942 if (!strcmp(res->on_off, "on")) {
17943 port->dev_conf.rxmode.offloads |= single_offload;
17944 for (q = 0; q < nb_rx_queues; q++)
17945 port->rx_conf[q].offloads |= single_offload;
17947 port->dev_conf.rxmode.offloads &= ~single_offload;
17948 for (q = 0; q < nb_rx_queues; q++)
17949 port->rx_conf[q].offloads &= ~single_offload;
17952 cmd_reconfig_device_queue(port_id, 1, 1);
17955 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
17956 .f = cmd_config_per_port_rx_offload_parsed,
17958 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
17959 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
17960 "macsec_strip|header_split|vlan_filter|vlan_extend|"
17961 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
17964 (void *)&cmd_config_per_port_rx_offload_result_port,
17965 (void *)&cmd_config_per_port_rx_offload_result_config,
17966 (void *)&cmd_config_per_port_rx_offload_result_port_id,
17967 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
17968 (void *)&cmd_config_per_port_rx_offload_result_offload,
17969 (void *)&cmd_config_per_port_rx_offload_result_on_off,
17974 /* Enable/Disable a per queue offloading */
17975 struct cmd_config_per_queue_rx_offload_result {
17976 cmdline_fixed_string_t port;
17978 cmdline_fixed_string_t rxq;
17980 cmdline_fixed_string_t rx_offload;
17981 cmdline_fixed_string_t offload;
17982 cmdline_fixed_string_t on_off;
17985 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
17986 TOKEN_STRING_INITIALIZER
17987 (struct cmd_config_per_queue_rx_offload_result,
17989 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
17990 TOKEN_NUM_INITIALIZER
17991 (struct cmd_config_per_queue_rx_offload_result,
17993 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
17994 TOKEN_STRING_INITIALIZER
17995 (struct cmd_config_per_queue_rx_offload_result,
17997 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
17998 TOKEN_NUM_INITIALIZER
17999 (struct cmd_config_per_queue_rx_offload_result,
18001 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18002 TOKEN_STRING_INITIALIZER
18003 (struct cmd_config_per_queue_rx_offload_result,
18004 rx_offload, "rx_offload");
18005 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18006 TOKEN_STRING_INITIALIZER
18007 (struct cmd_config_per_queue_rx_offload_result,
18008 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18009 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18010 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18011 "crc_strip#scatter#timestamp#security#keep_crc");
18012 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18013 TOKEN_STRING_INITIALIZER
18014 (struct cmd_config_per_queue_rx_offload_result,
18018 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18019 __attribute__((unused)) struct cmdline *cl,
18020 __attribute__((unused)) void *data)
18022 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18023 struct rte_eth_dev_info dev_info;
18024 portid_t port_id = res->port_id;
18025 uint16_t queue_id = res->queue_id;
18026 struct rte_port *port = &ports[port_id];
18027 uint64_t single_offload;
18029 if (port->port_status != RTE_PORT_STOPPED) {
18030 printf("Error: Can't config offload when Port %d "
18031 "is not stopped\n", port_id);
18035 rte_eth_dev_info_get(port_id, &dev_info);
18036 if (queue_id >= dev_info.nb_rx_queues) {
18037 printf("Error: input queue_id should be 0 ... "
18038 "%d\n", dev_info.nb_rx_queues - 1);
18042 single_offload = search_rx_offload(res->offload);
18043 if (single_offload == 0) {
18044 printf("Unknown offload name: %s\n", res->offload);
18048 if (!strcmp(res->on_off, "on"))
18049 port->rx_conf[queue_id].offloads |= single_offload;
18051 port->rx_conf[queue_id].offloads &= ~single_offload;
18053 cmd_reconfig_device_queue(port_id, 1, 1);
18056 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18057 .f = cmd_config_per_queue_rx_offload_parsed,
18059 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18060 "vlan_strip|ipv4_cksum|"
18061 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18062 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18063 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
18066 (void *)&cmd_config_per_queue_rx_offload_result_port,
18067 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18068 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18069 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18070 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18071 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18072 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18077 /* Get Tx offloads capabilities */
18078 struct cmd_tx_offload_get_capa_result {
18079 cmdline_fixed_string_t show;
18080 cmdline_fixed_string_t port;
18082 cmdline_fixed_string_t tx_offload;
18083 cmdline_fixed_string_t capabilities;
18086 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18087 TOKEN_STRING_INITIALIZER
18088 (struct cmd_tx_offload_get_capa_result,
18090 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18091 TOKEN_STRING_INITIALIZER
18092 (struct cmd_tx_offload_get_capa_result,
18094 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18095 TOKEN_NUM_INITIALIZER
18096 (struct cmd_tx_offload_get_capa_result,
18098 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18099 TOKEN_STRING_INITIALIZER
18100 (struct cmd_tx_offload_get_capa_result,
18101 tx_offload, "tx_offload");
18102 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18103 TOKEN_STRING_INITIALIZER
18104 (struct cmd_tx_offload_get_capa_result,
18105 capabilities, "capabilities");
18108 print_tx_offloads(uint64_t offloads)
18110 uint64_t single_offload;
18118 begin = __builtin_ctzll(offloads);
18119 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18121 single_offload = 1ULL << begin;
18122 for (bit = begin; bit < end; bit++) {
18123 if (offloads & single_offload)
18125 rte_eth_dev_tx_offload_name(single_offload));
18126 single_offload <<= 1;
18131 cmd_tx_offload_get_capa_parsed(
18132 void *parsed_result,
18133 __attribute__((unused)) struct cmdline *cl,
18134 __attribute__((unused)) void *data)
18136 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18137 struct rte_eth_dev_info dev_info;
18138 portid_t port_id = res->port_id;
18139 uint64_t queue_offloads;
18140 uint64_t port_offloads;
18142 rte_eth_dev_info_get(port_id, &dev_info);
18143 queue_offloads = dev_info.tx_queue_offload_capa;
18144 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18146 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18147 printf(" Per Queue :");
18148 print_tx_offloads(queue_offloads);
18151 printf(" Per Port :");
18152 print_tx_offloads(port_offloads);
18156 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18157 .f = cmd_tx_offload_get_capa_parsed,
18159 .help_str = "show port <port_id> tx_offload capabilities",
18161 (void *)&cmd_tx_offload_get_capa_show,
18162 (void *)&cmd_tx_offload_get_capa_port,
18163 (void *)&cmd_tx_offload_get_capa_port_id,
18164 (void *)&cmd_tx_offload_get_capa_tx_offload,
18165 (void *)&cmd_tx_offload_get_capa_capabilities,
18170 /* Get Tx offloads configuration */
18171 struct cmd_tx_offload_get_configuration_result {
18172 cmdline_fixed_string_t show;
18173 cmdline_fixed_string_t port;
18175 cmdline_fixed_string_t tx_offload;
18176 cmdline_fixed_string_t configuration;
18179 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18180 TOKEN_STRING_INITIALIZER
18181 (struct cmd_tx_offload_get_configuration_result,
18183 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18184 TOKEN_STRING_INITIALIZER
18185 (struct cmd_tx_offload_get_configuration_result,
18187 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18188 TOKEN_NUM_INITIALIZER
18189 (struct cmd_tx_offload_get_configuration_result,
18191 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18192 TOKEN_STRING_INITIALIZER
18193 (struct cmd_tx_offload_get_configuration_result,
18194 tx_offload, "tx_offload");
18195 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18196 TOKEN_STRING_INITIALIZER
18197 (struct cmd_tx_offload_get_configuration_result,
18198 configuration, "configuration");
18201 cmd_tx_offload_get_configuration_parsed(
18202 void *parsed_result,
18203 __attribute__((unused)) struct cmdline *cl,
18204 __attribute__((unused)) void *data)
18206 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18207 struct rte_eth_dev_info dev_info;
18208 portid_t port_id = res->port_id;
18209 struct rte_port *port = &ports[port_id];
18210 uint64_t port_offloads;
18211 uint64_t queue_offloads;
18212 uint16_t nb_tx_queues;
18215 printf("Tx Offloading Configuration of port %d :\n", port_id);
18217 port_offloads = port->dev_conf.txmode.offloads;
18219 print_tx_offloads(port_offloads);
18222 rte_eth_dev_info_get(port_id, &dev_info);
18223 nb_tx_queues = dev_info.nb_tx_queues;
18224 for (q = 0; q < nb_tx_queues; q++) {
18225 queue_offloads = port->tx_conf[q].offloads;
18226 printf(" Queue[%2d] :", q);
18227 print_tx_offloads(queue_offloads);
18233 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18234 .f = cmd_tx_offload_get_configuration_parsed,
18236 .help_str = "show port <port_id> tx_offload configuration",
18238 (void *)&cmd_tx_offload_get_configuration_show,
18239 (void *)&cmd_tx_offload_get_configuration_port,
18240 (void *)&cmd_tx_offload_get_configuration_port_id,
18241 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18242 (void *)&cmd_tx_offload_get_configuration_configuration,
18247 /* Enable/Disable a per port offloading */
18248 struct cmd_config_per_port_tx_offload_result {
18249 cmdline_fixed_string_t port;
18250 cmdline_fixed_string_t config;
18252 cmdline_fixed_string_t tx_offload;
18253 cmdline_fixed_string_t offload;
18254 cmdline_fixed_string_t on_off;
18257 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18258 TOKEN_STRING_INITIALIZER
18259 (struct cmd_config_per_port_tx_offload_result,
18261 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18262 TOKEN_STRING_INITIALIZER
18263 (struct cmd_config_per_port_tx_offload_result,
18265 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18266 TOKEN_NUM_INITIALIZER
18267 (struct cmd_config_per_port_tx_offload_result,
18269 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18270 TOKEN_STRING_INITIALIZER
18271 (struct cmd_config_per_port_tx_offload_result,
18272 tx_offload, "tx_offload");
18273 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18274 TOKEN_STRING_INITIALIZER
18275 (struct cmd_config_per_port_tx_offload_result,
18276 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18277 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18278 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18279 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18280 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18282 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18283 TOKEN_STRING_INITIALIZER
18284 (struct cmd_config_per_port_tx_offload_result,
18288 search_tx_offload(const char *name)
18290 uint64_t single_offload;
18291 const char *single_name;
18295 single_offload = 1;
18296 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18297 single_name = rte_eth_dev_tx_offload_name(single_offload);
18298 if (single_name == NULL)
18300 if (!strcasecmp(single_name, name)) {
18303 } else if (!strcasecmp(single_name, "UNKNOWN"))
18305 single_offload <<= 1;
18309 return single_offload;
18315 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18316 __attribute__((unused)) struct cmdline *cl,
18317 __attribute__((unused)) void *data)
18319 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18320 portid_t port_id = res->port_id;
18321 struct rte_eth_dev_info dev_info;
18322 struct rte_port *port = &ports[port_id];
18323 uint64_t single_offload;
18324 uint16_t nb_tx_queues;
18327 if (port->port_status != RTE_PORT_STOPPED) {
18328 printf("Error: Can't config offload when Port %d "
18329 "is not stopped\n", port_id);
18333 single_offload = search_tx_offload(res->offload);
18334 if (single_offload == 0) {
18335 printf("Unknown offload name: %s\n", res->offload);
18339 rte_eth_dev_info_get(port_id, &dev_info);
18340 nb_tx_queues = dev_info.nb_tx_queues;
18341 if (!strcmp(res->on_off, "on")) {
18342 port->dev_conf.txmode.offloads |= single_offload;
18343 for (q = 0; q < nb_tx_queues; q++)
18344 port->tx_conf[q].offloads |= single_offload;
18346 port->dev_conf.txmode.offloads &= ~single_offload;
18347 for (q = 0; q < nb_tx_queues; q++)
18348 port->tx_conf[q].offloads &= ~single_offload;
18351 cmd_reconfig_device_queue(port_id, 1, 1);
18354 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18355 .f = cmd_config_per_port_tx_offload_parsed,
18357 .help_str = "port config <port_id> tx_offload "
18358 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18359 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18360 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18361 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18362 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18363 "match_metadata on|off",
18365 (void *)&cmd_config_per_port_tx_offload_result_port,
18366 (void *)&cmd_config_per_port_tx_offload_result_config,
18367 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18368 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18369 (void *)&cmd_config_per_port_tx_offload_result_offload,
18370 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18375 /* Enable/Disable a per queue offloading */
18376 struct cmd_config_per_queue_tx_offload_result {
18377 cmdline_fixed_string_t port;
18379 cmdline_fixed_string_t txq;
18381 cmdline_fixed_string_t tx_offload;
18382 cmdline_fixed_string_t offload;
18383 cmdline_fixed_string_t on_off;
18386 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18387 TOKEN_STRING_INITIALIZER
18388 (struct cmd_config_per_queue_tx_offload_result,
18390 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18391 TOKEN_NUM_INITIALIZER
18392 (struct cmd_config_per_queue_tx_offload_result,
18394 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18395 TOKEN_STRING_INITIALIZER
18396 (struct cmd_config_per_queue_tx_offload_result,
18398 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18399 TOKEN_NUM_INITIALIZER
18400 (struct cmd_config_per_queue_tx_offload_result,
18402 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18403 TOKEN_STRING_INITIALIZER
18404 (struct cmd_config_per_queue_tx_offload_result,
18405 tx_offload, "tx_offload");
18406 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18407 TOKEN_STRING_INITIALIZER
18408 (struct cmd_config_per_queue_tx_offload_result,
18409 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18410 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18411 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18412 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18413 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18414 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18415 TOKEN_STRING_INITIALIZER
18416 (struct cmd_config_per_queue_tx_offload_result,
18420 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18421 __attribute__((unused)) struct cmdline *cl,
18422 __attribute__((unused)) void *data)
18424 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18425 struct rte_eth_dev_info dev_info;
18426 portid_t port_id = res->port_id;
18427 uint16_t queue_id = res->queue_id;
18428 struct rte_port *port = &ports[port_id];
18429 uint64_t single_offload;
18431 if (port->port_status != RTE_PORT_STOPPED) {
18432 printf("Error: Can't config offload when Port %d "
18433 "is not stopped\n", port_id);
18437 rte_eth_dev_info_get(port_id, &dev_info);
18438 if (queue_id >= dev_info.nb_tx_queues) {
18439 printf("Error: input queue_id should be 0 ... "
18440 "%d\n", dev_info.nb_tx_queues - 1);
18444 single_offload = search_tx_offload(res->offload);
18445 if (single_offload == 0) {
18446 printf("Unknown offload name: %s\n", res->offload);
18450 if (!strcmp(res->on_off, "on"))
18451 port->tx_conf[queue_id].offloads |= single_offload;
18453 port->tx_conf[queue_id].offloads &= ~single_offload;
18455 cmd_reconfig_device_queue(port_id, 1, 1);
18458 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18459 .f = cmd_config_per_queue_tx_offload_parsed,
18461 .help_str = "port <port_id> txq <queue_id> tx_offload "
18462 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18463 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18464 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18465 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18466 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18469 (void *)&cmd_config_per_queue_tx_offload_result_port,
18470 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18471 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18472 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18473 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18474 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18475 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18480 /* *** configure tx_metadata for specific port *** */
18481 struct cmd_config_tx_metadata_specific_result {
18482 cmdline_fixed_string_t port;
18483 cmdline_fixed_string_t keyword;
18485 cmdline_fixed_string_t item;
18490 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18491 __attribute__((unused)) struct cmdline *cl,
18492 __attribute__((unused)) void *data)
18494 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18496 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18498 ports[res->port_id].tx_metadata = rte_cpu_to_be_32(res->value);
18499 /* Add/remove callback to insert valid metadata in every Tx packet. */
18500 if (ports[res->port_id].tx_metadata)
18501 add_tx_md_callback(res->port_id);
18503 remove_tx_md_callback(res->port_id);
18506 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18507 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18509 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18510 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18511 keyword, "config");
18512 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18513 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18515 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18516 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18517 item, "tx_metadata");
18518 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18519 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18522 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18523 .f = cmd_config_tx_metadata_specific_parsed,
18525 .help_str = "port config <port_id> tx_metadata <value>",
18527 (void *)&cmd_config_tx_metadata_specific_port,
18528 (void *)&cmd_config_tx_metadata_specific_keyword,
18529 (void *)&cmd_config_tx_metadata_specific_id,
18530 (void *)&cmd_config_tx_metadata_specific_item,
18531 (void *)&cmd_config_tx_metadata_specific_value,
18536 /* *** display tx_metadata per port configuration *** */
18537 struct cmd_show_tx_metadata_result {
18538 cmdline_fixed_string_t cmd_show;
18539 cmdline_fixed_string_t cmd_port;
18540 cmdline_fixed_string_t cmd_keyword;
18545 cmd_show_tx_metadata_parsed(void *parsed_result,
18546 __attribute__((unused)) struct cmdline *cl,
18547 __attribute__((unused)) void *data)
18549 struct cmd_show_tx_metadata_result *res = parsed_result;
18551 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18552 printf("invalid port id %u\n", res->cmd_pid);
18555 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18556 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18557 rte_be_to_cpu_32(ports[res->cmd_pid].tx_metadata));
18561 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18562 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18564 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18565 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18567 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18568 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18570 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18571 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18572 cmd_keyword, "tx_metadata");
18574 cmdline_parse_inst_t cmd_show_tx_metadata = {
18575 .f = cmd_show_tx_metadata_parsed,
18577 .help_str = "show port <port_id> tx_metadata",
18579 (void *)&cmd_show_tx_metadata_show,
18580 (void *)&cmd_show_tx_metadata_port,
18581 (void *)&cmd_show_tx_metadata_pid,
18582 (void *)&cmd_show_tx_metadata_keyword,
18587 /* ******************************************************************************** */
18589 /* list of instructions */
18590 cmdline_parse_ctx_t main_ctx[] = {
18591 (cmdline_parse_inst_t *)&cmd_help_brief,
18592 (cmdline_parse_inst_t *)&cmd_help_long,
18593 (cmdline_parse_inst_t *)&cmd_quit,
18594 (cmdline_parse_inst_t *)&cmd_load_from_file,
18595 (cmdline_parse_inst_t *)&cmd_showport,
18596 (cmdline_parse_inst_t *)&cmd_showqueue,
18597 (cmdline_parse_inst_t *)&cmd_showportall,
18598 (cmdline_parse_inst_t *)&cmd_showcfg,
18599 (cmdline_parse_inst_t *)&cmd_start,
18600 (cmdline_parse_inst_t *)&cmd_start_tx_first,
18601 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
18602 (cmdline_parse_inst_t *)&cmd_set_link_up,
18603 (cmdline_parse_inst_t *)&cmd_set_link_down,
18604 (cmdline_parse_inst_t *)&cmd_reset,
18605 (cmdline_parse_inst_t *)&cmd_set_numbers,
18606 (cmdline_parse_inst_t *)&cmd_set_log,
18607 (cmdline_parse_inst_t *)&cmd_set_txpkts,
18608 (cmdline_parse_inst_t *)&cmd_set_txsplit,
18609 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
18610 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
18611 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
18612 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
18613 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
18614 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
18615 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
18616 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
18617 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
18618 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
18619 (cmdline_parse_inst_t *)&cmd_set_link_check,
18620 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
18621 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
18622 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
18623 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
18624 #ifdef RTE_LIBRTE_PMD_BOND
18625 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
18626 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
18627 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
18628 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
18629 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
18630 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
18631 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
18632 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
18633 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
18634 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
18635 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
18637 (cmdline_parse_inst_t *)&cmd_vlan_offload,
18638 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
18639 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
18640 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
18641 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
18642 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
18643 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
18644 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
18645 (cmdline_parse_inst_t *)&cmd_csum_set,
18646 (cmdline_parse_inst_t *)&cmd_csum_show,
18647 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
18648 (cmdline_parse_inst_t *)&cmd_tso_set,
18649 (cmdline_parse_inst_t *)&cmd_tso_show,
18650 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
18651 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
18652 (cmdline_parse_inst_t *)&cmd_gro_enable,
18653 (cmdline_parse_inst_t *)&cmd_gro_flush,
18654 (cmdline_parse_inst_t *)&cmd_gro_show,
18655 (cmdline_parse_inst_t *)&cmd_gso_enable,
18656 (cmdline_parse_inst_t *)&cmd_gso_size,
18657 (cmdline_parse_inst_t *)&cmd_gso_show,
18658 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
18659 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
18660 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
18661 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
18662 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
18663 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
18664 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
18665 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
18666 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
18667 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
18668 (cmdline_parse_inst_t *)&cmd_config_dcb,
18669 (cmdline_parse_inst_t *)&cmd_read_reg,
18670 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
18671 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
18672 (cmdline_parse_inst_t *)&cmd_write_reg,
18673 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
18674 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
18675 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
18676 (cmdline_parse_inst_t *)&cmd_stop,
18677 (cmdline_parse_inst_t *)&cmd_mac_addr,
18678 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
18679 (cmdline_parse_inst_t *)&cmd_set_qmap,
18680 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
18681 (cmdline_parse_inst_t *)&cmd_operate_port,
18682 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
18683 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
18684 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
18685 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
18686 (cmdline_parse_inst_t *)&cmd_config_speed_all,
18687 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
18688 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
18689 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
18690 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
18691 (cmdline_parse_inst_t *)&cmd_config_mtu,
18692 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
18693 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
18694 (cmdline_parse_inst_t *)&cmd_config_rss,
18695 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
18696 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
18697 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
18698 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
18699 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
18700 (cmdline_parse_inst_t *)&cmd_showport_reta,
18701 (cmdline_parse_inst_t *)&cmd_config_burst,
18702 (cmdline_parse_inst_t *)&cmd_config_thresh,
18703 (cmdline_parse_inst_t *)&cmd_config_threshold,
18704 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
18705 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
18706 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
18707 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
18708 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
18709 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
18710 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
18711 (cmdline_parse_inst_t *)&cmd_global_config,
18712 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
18713 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
18714 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
18715 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
18716 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
18717 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
18718 (cmdline_parse_inst_t *)&cmd_dump,
18719 (cmdline_parse_inst_t *)&cmd_dump_one,
18720 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
18721 (cmdline_parse_inst_t *)&cmd_syn_filter,
18722 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
18723 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
18724 (cmdline_parse_inst_t *)&cmd_flex_filter,
18725 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
18726 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
18727 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
18728 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
18729 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
18730 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
18731 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
18732 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
18733 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
18734 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
18735 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
18736 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
18737 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
18738 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
18739 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
18740 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
18741 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
18742 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
18743 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
18744 (cmdline_parse_inst_t *)&cmd_flow,
18745 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
18746 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
18747 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
18748 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
18749 (cmdline_parse_inst_t *)&cmd_create_port_meter,
18750 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
18751 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
18752 (cmdline_parse_inst_t *)&cmd_del_port_meter,
18753 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
18754 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
18755 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
18756 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
18757 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
18758 (cmdline_parse_inst_t *)&cmd_mcast_addr,
18759 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
18760 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
18761 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
18762 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
18763 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
18764 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
18765 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
18766 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
18767 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
18768 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
18769 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
18770 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
18771 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
18772 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
18773 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
18774 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
18775 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
18776 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
18777 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
18778 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
18779 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
18780 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
18781 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
18782 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
18783 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
18784 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
18785 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
18786 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
18787 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
18788 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
18789 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
18790 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
18791 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
18792 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
18793 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
18794 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
18795 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
18797 (cmdline_parse_inst_t *)&cmd_set_vxlan,
18798 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
18799 (cmdline_parse_inst_t *)&cmd_set_nvgre,
18800 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
18801 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
18802 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
18803 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
18804 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
18805 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
18806 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
18807 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
18808 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
18809 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
18810 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
18811 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
18812 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
18813 (cmdline_parse_inst_t *)&cmd_ddp_add,
18814 (cmdline_parse_inst_t *)&cmd_ddp_del,
18815 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
18816 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
18817 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
18818 (cmdline_parse_inst_t *)&cmd_clear_input_set,
18819 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
18820 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
18821 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
18822 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
18823 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
18824 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
18826 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
18827 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
18828 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
18829 (cmdline_parse_inst_t *)&cmd_queue_region,
18830 (cmdline_parse_inst_t *)&cmd_region_flowtype,
18831 (cmdline_parse_inst_t *)&cmd_user_priority_region,
18832 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
18833 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
18834 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
18835 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
18836 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
18837 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
18838 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
18839 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
18840 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
18841 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
18842 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
18843 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
18844 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
18845 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
18846 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
18847 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
18848 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
18849 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
18850 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
18851 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
18852 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
18853 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
18854 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
18855 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
18856 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
18857 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
18858 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
18859 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
18860 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
18861 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
18862 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
18863 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
18864 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
18865 #ifdef RTE_LIBRTE_BPF
18866 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
18867 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
18869 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
18870 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
18874 /* read cmdline commands from file */
18876 cmdline_read_from_file(const char *filename)
18878 struct cmdline *cl;
18880 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
18882 printf("Failed to create file based cmdline context: %s\n",
18887 cmdline_interact(cl);
18892 printf("Read CLI commands from %s\n", filename);
18895 /* prompt function, called from main on MASTER lcore */
18899 /* initialize non-constant commands */
18900 cmd_set_fwd_mode_init();
18901 cmd_set_fwd_retry_mode_init();
18903 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
18904 if (testpmd_cl == NULL)
18906 cmdline_interact(testpmd_cl);
18907 cmdline_stdin_exit(testpmd_cl);
18913 if (testpmd_cl != NULL)
18914 cmdline_quit(testpmd_cl);
18918 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
18920 if (id == (portid_t)RTE_PORT_ALL) {
18923 RTE_ETH_FOREACH_DEV(pid) {
18924 /* check if need_reconfig has been set to 1 */
18925 if (ports[pid].need_reconfig == 0)
18926 ports[pid].need_reconfig = dev;
18927 /* check if need_reconfig_queues has been set to 1 */
18928 if (ports[pid].need_reconfig_queues == 0)
18929 ports[pid].need_reconfig_queues = queue;
18931 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
18932 /* check if need_reconfig has been set to 1 */
18933 if (ports[id].need_reconfig == 0)
18934 ports[id].need_reconfig = dev;
18935 /* check if need_reconfig_queues has been set to 1 */
18936 if (ports[id].need_reconfig_queues == 0)
18937 ports[id].need_reconfig_queues = queue;