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>
50 #include <cmdline_rdline.h>
51 #include <cmdline_parse.h>
52 #include <cmdline_parse_num.h>
53 #include <cmdline_parse_string.h>
54 #include <cmdline_parse_ipaddr.h>
55 #include <cmdline_parse_etheraddr.h>
56 #include <cmdline_socket.h>
58 #ifdef RTE_LIBRTE_PMD_BOND
59 #include <rte_eth_bond.h>
60 #include <rte_eth_bond_8023ad.h>
62 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
63 #include <rte_pmd_dpaa.h>
65 #ifdef RTE_LIBRTE_IXGBE_PMD
66 #include <rte_pmd_ixgbe.h>
68 #ifdef RTE_LIBRTE_I40E_PMD
69 #include <rte_pmd_i40e.h>
71 #ifdef RTE_LIBRTE_BNXT_PMD
72 #include <rte_pmd_bnxt.h>
75 #include "cmdline_mtr.h"
76 #include "cmdline_tm.h"
79 static struct cmdline *testpmd_cl;
81 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
83 /* *** Help command with introduction. *** */
84 struct cmd_help_brief_result {
85 cmdline_fixed_string_t help;
88 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
90 __attribute__((unused)) void *data)
95 "Help is available for the following sections:\n\n"
96 " help control : Start and stop forwarding.\n"
97 " help display : Displaying port, stats and config "
99 " help config : Configuration information.\n"
100 " help ports : Configuring ports.\n"
101 " help registers : Reading and setting port registers.\n"
102 " help filters : Filters configuration help.\n"
103 " help traffic_management : Traffic Management commmands.\n"
104 " help devices : Device related cmds.\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"
241 "show device info (<identifier>|all)"
242 " Show general information about devices probed.\n\n"
246 if (show_all || !strcmp(res->section, "config")) {
252 "Configuration changes only become active when"
253 " forwarding is started/restarted.\n\n"
256 " Reset forwarding to the default configuration.\n\n"
258 "set verbose (level)\n"
259 " Set the debug verbosity level X.\n\n"
261 "set log global|(type) (level)\n"
262 " Set the log level.\n\n"
265 " Set number of ports.\n\n"
268 " Set number of cores.\n\n"
270 "set coremask (mask)\n"
271 " Set the forwarding cores hexadecimal mask.\n\n"
273 "set portmask (mask)\n"
274 " Set the forwarding ports hexadecimal mask.\n\n"
277 " Set number of packets per burst.\n\n"
279 "set burst tx delay (microseconds) retry (num)\n"
280 " Set the transmit delay time and number of retries,"
281 " effective when retry is enabled.\n\n"
283 "set txpkts (x[,y]*)\n"
284 " Set the length of each segment of TXONLY"
285 " and optionally CSUM packets.\n\n"
287 "set txsplit (off|on|rand)\n"
288 " Set the split policy for the TX packets."
289 " Right now only applicable for CSUM and TXONLY"
292 "set corelist (x[,y]*)\n"
293 " Set the list of forwarding cores.\n\n"
295 "set portlist (x[,y]*)\n"
296 " Set the list of forwarding ports.\n\n"
298 "set port setup on (iterator|event)\n"
299 " Select how attached port is retrieved for setup.\n\n"
301 "set tx loopback (port_id) (on|off)\n"
302 " Enable or disable tx loopback.\n\n"
304 "set all queues drop (port_id) (on|off)\n"
305 " Set drop enable bit for all queues.\n\n"
307 "set vf split drop (port_id) (vf_id) (on|off)\n"
308 " Set split drop enable bit for a VF from the PF.\n\n"
310 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
311 " Set MAC antispoof for a VF from the PF.\n\n"
313 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
314 " Enable MACsec offload.\n\n"
316 "set macsec offload (port_id) off\n"
317 " Disable MACsec offload.\n\n"
319 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
320 " Configure MACsec secure connection (SC).\n\n"
322 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
323 " Configure MACsec secure association (SA).\n\n"
325 "set vf broadcast (port_id) (vf_id) (on|off)\n"
326 " Set VF broadcast for a VF from the PF.\n\n"
328 "vlan set strip (on|off) (port_id)\n"
329 " Set the VLAN strip on a port.\n\n"
331 "vlan set stripq (on|off) (port_id,queue_id)\n"
332 " Set the VLAN strip for a queue on a port.\n\n"
334 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
335 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
337 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
338 " Set VLAN insert for a VF from the PF.\n\n"
340 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
341 " Set VLAN antispoof for a VF from the PF.\n\n"
343 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
344 " Set VLAN tag for a VF from the PF.\n\n"
346 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
347 " Set a VF's max bandwidth(Mbps).\n\n"
349 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
350 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
352 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
353 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
355 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
356 " Set some TCs' strict link priority mode on a physical port.\n\n"
358 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
359 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
361 "vlan set filter (on|off) (port_id)\n"
362 " Set the VLAN filter on a port.\n\n"
364 "vlan set qinq (on|off) (port_id)\n"
365 " Set the VLAN QinQ (extended queue in queue)"
368 "vlan set (inner|outer) tpid (value) (port_id)\n"
369 " Set the VLAN TPID for Packet Filtering on"
372 "rx_vlan add (vlan_id|all) (port_id)\n"
373 " Add a vlan_id, or all identifiers, to the set"
374 " of VLAN identifiers filtered by port_id.\n\n"
376 "rx_vlan rm (vlan_id|all) (port_id)\n"
377 " Remove a vlan_id, or all identifiers, from the set"
378 " of VLAN identifiers filtered by port_id.\n\n"
380 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
381 " Add a vlan_id, to the set of VLAN identifiers"
382 "filtered for VF(s) from port_id.\n\n"
384 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
385 " Remove a vlan_id, to the set of VLAN identifiers"
386 "filtered for VF(s) from port_id.\n\n"
388 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
389 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
390 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
391 " add a tunnel filter of a port.\n\n"
393 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
394 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
395 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
396 " remove a tunnel filter of a port.\n\n"
398 "rx_vxlan_port add (udp_port) (port_id)\n"
399 " Add an UDP port for VXLAN packet filter on a port\n\n"
401 "rx_vxlan_port rm (udp_port) (port_id)\n"
402 " Remove an UDP port for VXLAN packet filter on a port\n\n"
404 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
405 " Set hardware insertion of VLAN IDs (single or double VLAN "
406 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
408 "tx_vlan set pvid port_id vlan_id (on|off)\n"
409 " Set port based TX VLAN insertion.\n\n"
411 "tx_vlan reset (port_id)\n"
412 " Disable hardware insertion of a VLAN header in"
413 " packets sent on a port.\n\n"
415 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
416 " Select hardware or software calculation of the"
417 " checksum when transmitting a packet using the"
418 " csum forward engine.\n"
419 " ip|udp|tcp|sctp always concern the inner layer.\n"
420 " outer-ip concerns the outer IP layer in"
421 " outer-udp concerns the outer UDP layer in"
422 " case the packet is recognized as a tunnel packet by"
423 " the forward engine (vxlan, gre and ipip are supported)\n"
424 " Please check the NIC datasheet for HW limits.\n\n"
426 "csum parse-tunnel (on|off) (tx_port_id)\n"
427 " If disabled, treat tunnel packets as non-tunneled"
428 " packets (treat inner headers as payload). The port\n"
429 " argument is the port used for TX in csum forward"
432 "csum show (port_id)\n"
433 " Display tx checksum offload configuration\n\n"
435 "tso set (segsize) (portid)\n"
436 " Enable TCP Segmentation Offload in csum forward"
438 " Please check the NIC datasheet for HW limits.\n\n"
441 " Display the status of TCP Segmentation Offload.\n\n"
443 "set port (port_id) gro on|off\n"
444 " Enable or disable Generic Receive Offload in"
445 " csum forwarding engine.\n\n"
447 "show port (port_id) gro\n"
448 " Display GRO configuration.\n\n"
450 "set gro flush (cycles)\n"
451 " Set the cycle to flush GROed packets from"
452 " reassembly tables.\n\n"
454 "set port (port_id) gso (on|off)"
455 " Enable or disable Generic Segmentation Offload in"
456 " csum forwarding engine.\n\n"
458 "set gso segsz (length)\n"
459 " Set max packet length for output GSO segments,"
460 " including packet header and payload.\n\n"
462 "show port (port_id) gso\n"
463 " Show GSO configuration.\n\n"
466 " Set packet forwarding mode.\n\n"
468 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
469 " Add a MAC address on port_id.\n\n"
471 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
472 " Remove a MAC address from port_id.\n\n"
474 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
475 " Set the default MAC address for port_id.\n\n"
477 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
478 " Add a MAC address for a VF on the port.\n\n"
480 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
481 " Set the MAC address for a VF from the PF.\n\n"
483 "set eth-peer (port_id) (peer_addr)\n"
484 " set the peer address for certain port.\n\n"
486 "set port (port_id) uta (mac_address|all) (on|off)\n"
487 " Add/Remove a or all unicast hash filter(s)"
490 "set promisc (port_id|all) (on|off)\n"
491 " Set the promiscuous mode on port_id, or all.\n\n"
493 "set allmulti (port_id|all) (on|off)\n"
494 " Set the allmulti mode on port_id, or all.\n\n"
496 "set vf promisc (port_id) (vf_id) (on|off)\n"
497 " Set unicast promiscuous mode for a VF from the PF.\n\n"
499 "set vf allmulti (port_id) (vf_id) (on|off)\n"
500 " Set multicast promiscuous mode for a VF from the PF.\n\n"
502 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
503 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
504 " (on|off) autoneg (on|off) (port_id)\n"
505 "set flow_ctrl rx (on|off) (portid)\n"
506 "set flow_ctrl tx (on|off) (portid)\n"
507 "set flow_ctrl high_water (high_water) (portid)\n"
508 "set flow_ctrl low_water (low_water) (portid)\n"
509 "set flow_ctrl pause_time (pause_time) (portid)\n"
510 "set flow_ctrl send_xon (send_xon) (portid)\n"
511 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
512 "set flow_ctrl autoneg (on|off) (port_id)\n"
513 " Set the link flow control parameter on a port.\n\n"
515 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
516 " (low_water) (pause_time) (priority) (port_id)\n"
517 " Set the priority flow control parameter on a"
520 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
521 " Set statistics mapping (qmapping 0..15) for RX/TX"
523 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
524 " on port 0 to mapping 5.\n\n"
526 "set xstats-hide-zero on|off\n"
527 " Set the option to hide the zero values"
528 " for xstats display.\n"
530 "set port (port_id) vf (vf_id) rx|tx on|off\n"
531 " Enable/Disable a VF receive/tranmit from a port\n\n"
533 "set port (port_id) vf (vf_id) (mac_addr)"
534 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
535 " Add/Remove unicast or multicast MAC addr filter"
538 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
540 " AUPE:accepts untagged VLAN;"
541 "ROPE:accept unicast hash\n\n"
542 " BAM:accepts broadcast packets;"
543 "MPE:accepts all multicast packets\n\n"
544 " Enable/Disable a VF receive mode of a port\n\n"
546 "set port (port_id) queue (queue_id) rate (rate_num)\n"
547 " Set rate limit for a queue of a port\n\n"
549 "set port (port_id) vf (vf_id) rate (rate_num) "
550 "queue_mask (queue_mask_value)\n"
551 " Set rate limit for queues in VF of a port\n\n"
553 "set port (port_id) mirror-rule (rule_id)"
554 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
555 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
556 " Set pool or vlan type mirror rule on a port.\n"
557 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
558 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
561 "set port (port_id) mirror-rule (rule_id)"
562 " (uplink-mirror|downlink-mirror) dst-pool"
563 " (pool_id) (on|off)\n"
564 " Set uplink or downlink type mirror rule on a port.\n"
565 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
566 " 0 on' enable mirror income traffic to pool 0.\n\n"
568 "reset port (port_id) mirror-rule (rule_id)\n"
569 " Reset a mirror rule.\n\n"
571 "set flush_rx (on|off)\n"
572 " Flush (default) or don't flush RX streams before"
573 " forwarding. Mainly used with PCAP drivers.\n\n"
575 "set bypass mode (normal|bypass|isolate) (port_id)\n"
576 " Set the bypass mode for the lowest port on bypass enabled"
579 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
580 "mode (normal|bypass|isolate) (port_id)\n"
581 " Set the event required to initiate specified bypass mode for"
582 " the lowest port on a bypass enabled NIC where:\n"
583 " timeout = enable bypass after watchdog timeout.\n"
584 " os_on = enable bypass when OS/board is powered on.\n"
585 " os_off = enable bypass when OS/board is powered off.\n"
586 " power_on = enable bypass when power supply is turned on.\n"
587 " power_off = enable bypass when power supply is turned off."
590 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
591 " Set the bypass watchdog timeout to 'n' seconds"
592 " where 0 = instant.\n\n"
594 "show bypass config (port_id)\n"
595 " Show the bypass configuration for a bypass enabled NIC"
596 " using the lowest port on the NIC.\n\n"
598 #ifdef RTE_LIBRTE_PMD_BOND
599 "create bonded device (mode) (socket)\n"
600 " Create a new bonded device with specific bonding mode and socket.\n\n"
602 "add bonding slave (slave_id) (port_id)\n"
603 " Add a slave device to a bonded device.\n\n"
605 "remove bonding slave (slave_id) (port_id)\n"
606 " Remove a slave device from a bonded device.\n\n"
608 "set bonding mode (value) (port_id)\n"
609 " Set the bonding mode on a bonded device.\n\n"
611 "set bonding primary (slave_id) (port_id)\n"
612 " Set the primary slave for a bonded device.\n\n"
614 "show bonding config (port_id)\n"
615 " Show the bonding config for port_id.\n\n"
617 "set bonding mac_addr (port_id) (address)\n"
618 " Set the MAC address of a bonded device.\n\n"
620 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
621 " Set Aggregation mode for IEEE802.3AD (mode 4)"
623 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
624 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
626 "set bonding mon_period (port_id) (value)\n"
627 " Set the bonding link status monitoring polling period in ms.\n\n"
629 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
630 " Enable/disable dedicated queues for LACP control traffic.\n\n"
633 "set link-up port (port_id)\n"
634 " Set link up for a port.\n\n"
636 "set link-down port (port_id)\n"
637 " Set link down for a port.\n\n"
639 "E-tag set insertion on port-tag-id (value)"
640 " port (port_id) vf (vf_id)\n"
641 " Enable E-tag insertion for a VF on a port\n\n"
643 "E-tag set insertion off port (port_id) vf (vf_id)\n"
644 " Disable E-tag insertion for a VF on a port\n\n"
646 "E-tag set stripping (on|off) port (port_id)\n"
647 " Enable/disable E-tag stripping on a port\n\n"
649 "E-tag set forwarding (on|off) port (port_id)\n"
650 " Enable/disable E-tag based forwarding"
653 "E-tag set filter add e-tag-id (value) dst-pool"
654 " (pool_id) port (port_id)\n"
655 " Add an E-tag forwarding filter on a port\n\n"
657 "E-tag set filter del e-tag-id (value) port (port_id)\n"
658 " Delete an E-tag forwarding filter on a port\n\n"
660 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
661 " Load a profile package on a port\n\n"
663 "ddp del (port_id) (backup_profile_path)\n"
664 " Delete a profile package from a port\n\n"
666 "ptype mapping get (port_id) (valid_only)\n"
667 " Get ptype mapping on a port\n\n"
669 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
670 " Replace target with the pkt_type in ptype mapping\n\n"
672 "ptype mapping reset (port_id)\n"
673 " Reset ptype mapping on a port\n\n"
675 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
676 " Update a ptype mapping item on a port\n\n"
678 "set port (port_id) queue-region region_id (value) "
679 "queue_start_index (value) queue_num (value)\n"
680 " Set a queue region on a port\n\n"
682 "set port (port_id) queue-region region_id (value) "
684 " Set a flowtype region index on a port\n\n"
686 "set port (port_id) queue-region UP (value) region_id (value)\n"
687 " Set the mapping of User Priority to "
688 "queue region on a port\n\n"
690 "set port (port_id) queue-region flush (on|off)\n"
691 " flush all queue region related configuration\n\n"
693 "show port meter cap (port_id)\n"
694 " Show port meter capability information\n\n"
696 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
697 " meter profile add - srtcm rfc 2697\n\n"
699 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
700 " meter profile add - trtcm rfc 2698\n\n"
702 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
703 " meter profile add - trtcm rfc 4115\n\n"
705 "del port meter profile (port_id) (profile_id)\n"
706 " meter profile delete\n\n"
708 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
709 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
710 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
711 "(dscp_tbl_entry63)]\n"
714 "enable port meter (port_id) (mtr_id)\n"
717 "disable port meter (port_id) (mtr_id)\n"
720 "del port meter (port_id) (mtr_id)\n"
723 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
724 " meter update meter profile\n\n"
726 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
727 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
728 " update meter dscp table entries\n\n"
730 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
731 "(action0) [(action1) (action2)]\n"
732 " meter update policer action\n\n"
734 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
735 " meter update stats\n\n"
737 "show port (port_id) queue-region\n"
738 " show all queue region related configuration info\n\n"
740 , list_pkt_forwarding_modes()
744 if (show_all || !strcmp(res->section, "ports")) {
750 "----------------\n\n"
752 "port start (port_id|all)\n"
753 " Start all ports or port_id.\n\n"
755 "port stop (port_id|all)\n"
756 " Stop all ports or port_id.\n\n"
758 "port close (port_id|all)\n"
759 " Close all ports or port_id.\n\n"
761 "port attach (ident)\n"
762 " Attach physical or virtual dev by pci address or virtual device name\n\n"
764 "port detach (port_id)\n"
765 " Detach physical or virtual dev by port_id\n\n"
767 "port config (port_id|all)"
768 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
769 " duplex (half|full|auto)\n"
770 " Set speed and duplex for all ports or port_id\n\n"
772 "port config (port_id|all) loopback (mode)\n"
773 " Set loopback mode for all ports or port_id\n\n"
775 "port config all (rxq|txq|rxd|txd) (value)\n"
776 " Set number for rxq/txq/rxd/txd.\n\n"
778 "port config all max-pkt-len (value)\n"
779 " Set the max packet length.\n\n"
781 "port config all drop-en (on|off)\n"
782 " Enable or disable packet drop on all RX queues of all ports when no "
783 "receive buffers available.\n\n"
785 "port config all rss (all|default|ip|tcp|udp|sctp|"
786 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n"
787 " Set the RSS mode.\n\n"
789 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
790 " Set the RSS redirection table.\n\n"
792 "port config (port_id) dcb vt (on|off) (traffic_class)"
794 " Set the DCB mode.\n\n"
796 "port config all burst (value)\n"
797 " Set the number of packets per burst.\n\n"
799 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
801 " Set the ring prefetch/host/writeback threshold"
802 " for tx/rx queue.\n\n"
804 "port config all (txfreet|txrst|rxfreet) (value)\n"
805 " Set free threshold for rx/tx, or set"
806 " tx rs bit threshold.\n\n"
807 "port config mtu X value\n"
808 " Set the MTU of port X to a given value\n\n"
810 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
811 " Set a rx/tx queue's ring size configuration, the new"
812 " value will take effect after command that (re-)start the port"
813 " or command that setup the specific queue\n\n"
815 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
816 " Start/stop a rx/tx queue of port X. Only take effect"
817 " when port X is started\n\n"
819 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
820 " Switch on/off a deferred start of port X rx/tx queue. Only"
821 " take effect when port X is stopped.\n\n"
823 "port (port_id) (rxq|txq) (queue_id) setup\n"
824 " Setup a rx/tx queue of port X.\n\n"
826 "port config (port_id|all) l2-tunnel E-tag ether-type"
828 " Set the value of E-tag ether-type.\n\n"
830 "port config (port_id|all) l2-tunnel E-tag"
831 " (enable|disable)\n"
832 " Enable/disable the E-tag support.\n\n"
834 "port config (port_id) pctype mapping reset\n"
835 " Reset flow type to pctype mapping on a port\n\n"
837 "port config (port_id) pctype mapping update"
838 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
839 " Update a flow type to pctype mapping item on a port\n\n"
841 "port config (port_id) pctype (pctype_id) hash_inset|"
842 "fdir_inset|fdir_flx_inset get|set|clear field\n"
844 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
846 "port config (port_id) pctype (pctype_id) hash_inset|"
847 "fdir_inset|fdir_flx_inset clear all"
848 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
850 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
851 " Add/remove UDP tunnel port for tunneling offload\n\n"
853 "port config <port_id> rx_offload vlan_strip|"
854 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
855 "outer_ipv4_cksum|macsec_strip|header_split|"
856 "vlan_filter|vlan_extend|jumbo_frame|crc_strip|"
857 "scatter|timestamp|security|keep_crc on|off\n"
858 " Enable or disable a per port Rx offloading"
859 " on all Rx queues of a port\n\n"
861 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
862 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
863 "outer_ipv4_cksum|macsec_strip|header_split|"
864 "vlan_filter|vlan_extend|jumbo_frame|crc_strip|"
865 "scatter|timestamp|security|keep_crc on|off\n"
866 " Enable or disable a per queue Rx offloading"
867 " only on a specific Rx queue\n\n"
869 "port config (port_id) tx_offload vlan_insert|"
870 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
871 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
872 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
873 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
874 "security|match_metadata on|off\n"
875 " Enable or disable a per port Tx offloading"
876 " on all Tx queues of a port\n\n"
878 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
879 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
880 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
881 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
882 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
884 " Enable or disable a per queue Tx offloading"
885 " only on a specific Tx queue\n\n"
887 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
888 " Load an eBPF program as a callback"
889 " for particular RX/TX queue\n\n"
891 "bpf-unload rx|tx (port) (queue)\n"
892 " Unload previously loaded eBPF program"
893 " for particular RX/TX queue\n\n"
895 "port config (port_id) tx_metadata (value)\n"
896 " Set Tx metadata value per port. Testpmd will add this value"
897 " to any Tx packet sent from this port\n\n"
901 if (show_all || !strcmp(res->section, "registers")) {
909 "read reg (port_id) (address)\n"
910 " Display value of a port register.\n\n"
912 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
913 " Display a port register bit field.\n\n"
915 "read regbit (port_id) (address) (bit_x)\n"
916 " Display a single port register bit.\n\n"
918 "write reg (port_id) (address) (value)\n"
919 " Set value of a port register.\n\n"
921 "write regfield (port_id) (address) (bit_x) (bit_y)"
923 " Set bit field of a port register.\n\n"
925 "write regbit (port_id) (address) (bit_x) (value)\n"
926 " Set single bit value of a port register.\n\n"
929 if (show_all || !strcmp(res->section, "filters")) {
937 "ethertype_filter (port_id) (add|del)"
938 " (mac_addr|mac_ignr) (mac_address) ethertype"
939 " (ether_type) (drop|fwd) queue (queue_id)\n"
940 " Add/Del an ethertype filter.\n\n"
942 "2tuple_filter (port_id) (add|del)"
943 " dst_port (dst_port_value) protocol (protocol_value)"
944 " mask (mask_value) tcp_flags (tcp_flags_value)"
945 " priority (prio_value) queue (queue_id)\n"
946 " Add/Del a 2tuple filter.\n\n"
948 "5tuple_filter (port_id) (add|del)"
949 " dst_ip (dst_address) src_ip (src_address)"
950 " dst_port (dst_port_value) src_port (src_port_value)"
951 " protocol (protocol_value)"
952 " mask (mask_value) tcp_flags (tcp_flags_value)"
953 " priority (prio_value) queue (queue_id)\n"
954 " Add/Del a 5tuple filter.\n\n"
956 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
957 " Add/Del syn filter.\n\n"
959 "flex_filter (port_id) (add|del) len (len_value)"
960 " bytes (bytes_value) mask (mask_value)"
961 " priority (prio_value) queue (queue_id)\n"
962 " Add/Del a flex filter.\n\n"
964 "flow_director_filter (port_id) mode IP (add|del|update)"
965 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
966 " src (src_ip_address) dst (dst_ip_address)"
967 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
968 " vlan (vlan_value) flexbytes (flexbytes_value)"
969 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
970 " fd_id (fd_id_value)\n"
971 " Add/Del an IP type flow director filter.\n\n"
973 "flow_director_filter (port_id) mode IP (add|del|update)"
974 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
975 " src (src_ip_address) (src_port)"
976 " dst (dst_ip_address) (dst_port)"
977 " tos (tos_value) ttl (ttl_value)"
978 " vlan (vlan_value) flexbytes (flexbytes_value)"
979 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
980 " fd_id (fd_id_value)\n"
981 " Add/Del an UDP/TCP type flow director filter.\n\n"
983 "flow_director_filter (port_id) mode IP (add|del|update)"
984 " flow (ipv4-sctp|ipv6-sctp)"
985 " src (src_ip_address) (src_port)"
986 " dst (dst_ip_address) (dst_port)"
987 " tag (verification_tag) "
988 " tos (tos_value) ttl (ttl_value)"
990 " flexbytes (flexbytes_value) (drop|fwd)"
991 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
992 " Add/Del a SCTP type flow director filter.\n\n"
994 "flow_director_filter (port_id) mode IP (add|del|update)"
995 " flow l2_payload ether (ethertype)"
996 " flexbytes (flexbytes_value) (drop|fwd)"
997 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
998 " Add/Del a l2 payload type flow director filter.\n\n"
1000 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1001 " mac (mac_address) vlan (vlan_value)"
1002 " flexbytes (flexbytes_value) (drop|fwd)"
1003 " queue (queue_id) fd_id (fd_id_value)\n"
1004 " Add/Del a MAC-VLAN flow director filter.\n\n"
1006 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1007 " mac (mac_address) vlan (vlan_value)"
1008 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1009 " flexbytes (flexbytes_value) (drop|fwd)"
1010 " queue (queue_id) fd_id (fd_id_value)\n"
1011 " Add/Del a Tunnel flow director filter.\n\n"
1013 "flow_director_filter (port_id) mode raw (add|del|update)"
1014 " flow (flow_id) (drop|fwd) queue (queue_id)"
1015 " fd_id (fd_id_value) packet (packet file name)\n"
1016 " Add/Del a raw type flow director filter.\n\n"
1018 "flush_flow_director (port_id)\n"
1019 " Flush all flow director entries of a device.\n\n"
1021 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1022 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1023 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1024 " Set flow director IP mask.\n\n"
1026 "flow_director_mask (port_id) mode MAC-VLAN"
1027 " vlan (vlan_value)\n"
1028 " Set flow director MAC-VLAN mask.\n\n"
1030 "flow_director_mask (port_id) mode Tunnel"
1031 " vlan (vlan_value) mac (mac_value)"
1032 " tunnel-type (tunnel_type_value)"
1033 " tunnel-id (tunnel_id_value)\n"
1034 " Set flow director Tunnel mask.\n\n"
1036 "flow_director_flex_mask (port_id)"
1037 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1038 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1040 " Configure mask of flex payload.\n\n"
1042 "flow_director_flex_payload (port_id)"
1043 " (raw|l2|l3|l4) (config)\n"
1044 " Configure flex payload selection.\n\n"
1046 "get_sym_hash_ena_per_port (port_id)\n"
1047 " get symmetric hash enable configuration per port.\n\n"
1049 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1050 " set symmetric hash enable configuration per port"
1051 " to enable or disable.\n\n"
1053 "get_hash_global_config (port_id)\n"
1054 " Get the global configurations of hash filters.\n\n"
1056 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1057 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1058 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1059 " (enable|disable)\n"
1060 " Set the global configurations of hash filters.\n\n"
1062 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1063 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1064 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1065 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1066 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1067 "ipv6-next-header|udp-src-port|udp-dst-port|"
1068 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1069 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1070 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1071 "fld-8th|none) (select|add)\n"
1072 " Set the input set for hash.\n\n"
1074 "set_fdir_input_set (port_id) "
1075 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1076 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1077 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1078 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1079 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1080 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1081 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1083 " Set the input set for FDir.\n\n"
1085 "flow validate {port_id}"
1086 " [group {group_id}] [priority {level}]"
1087 " [ingress] [egress]"
1088 " pattern {item} [/ {item} [...]] / end"
1089 " actions {action} [/ {action} [...]] / end\n"
1090 " Check whether a flow rule can be created.\n\n"
1092 "flow create {port_id}"
1093 " [group {group_id}] [priority {level}]"
1094 " [ingress] [egress]"
1095 " pattern {item} [/ {item} [...]] / end"
1096 " actions {action} [/ {action} [...]] / end\n"
1097 " Create a flow rule.\n\n"
1099 "flow destroy {port_id} rule {rule_id} [...]\n"
1100 " Destroy specific flow rules.\n\n"
1102 "flow flush {port_id}\n"
1103 " Destroy all flow rules.\n\n"
1105 "flow query {port_id} {rule_id} {action}\n"
1106 " Query an existing flow rule.\n\n"
1108 "flow list {port_id} [group {group_id}] [...]\n"
1109 " List existing flow rules sorted by priority,"
1110 " filtered by group identifiers.\n\n"
1112 "flow isolate {port_id} {boolean}\n"
1113 " Restrict ingress traffic to the defined"
1116 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1117 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1118 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1119 " Configure the VXLAN encapsulation for flows.\n\n"
1121 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1122 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1123 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1124 " eth-dst (eth-dst)\n"
1125 " Configure the VXLAN encapsulation for flows.\n\n"
1127 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1128 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1129 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1130 " eth-dst (eth-dst)\n"
1131 " Configure the VXLAN encapsulation for flows.\n\n"
1133 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1134 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1136 " Configure the NVGRE encapsulation for flows.\n\n"
1138 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1139 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1140 " eth-src (eth-src) eth-dst (eth-dst)\n"
1141 " Configure the NVGRE encapsulation for flows.\n\n"
1143 "set raw_encap {flow items}\n"
1144 " Configure the encapsulation with raw data.\n\n"
1146 "set raw_decap {flow items}\n"
1147 " Configure the decapsulation with raw data.\n\n"
1152 if (show_all || !strcmp(res->section, "traffic_management")) {
1156 "Traffic Management:\n"
1158 "show port tm cap (port_id)\n"
1159 " Display the port TM capability.\n\n"
1161 "show port tm level cap (port_id) (level_id)\n"
1162 " Display the port TM hierarchical level capability.\n\n"
1164 "show port tm node cap (port_id) (node_id)\n"
1165 " Display the port TM node capability.\n\n"
1167 "show port tm node type (port_id) (node_id)\n"
1168 " Display the port TM node type.\n\n"
1170 "show port tm node stats (port_id) (node_id) (clear)\n"
1171 " Display the port TM node stats.\n\n"
1173 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
1174 "set port tm hierarchy default (port_id)\n"
1175 " Set default traffic Management hierarchy on a port\n\n"
1178 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1179 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1180 " (packet_length_adjust)\n"
1181 " Add port tm node private shaper profile.\n\n"
1183 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1184 " Delete port tm node private shaper profile.\n\n"
1186 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1187 " (shaper_profile_id)\n"
1188 " Add/update port tm node shared shaper.\n\n"
1190 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1191 " Delete port tm node shared shaper.\n\n"
1193 "set port tm node shaper profile (port_id) (node_id)"
1194 " (shaper_profile_id)\n"
1195 " Set port tm node shaper profile.\n\n"
1197 "add port tm node wred profile (port_id) (wred_profile_id)"
1198 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1199 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1200 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1201 " Add port tm node wred profile.\n\n"
1203 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1204 " Delete port tm node wred profile.\n\n"
1206 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1207 " (priority) (weight) (level_id) (shaper_profile_id)"
1208 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1209 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1210 " Add port tm nonleaf node.\n\n"
1212 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1213 " (priority) (weight) (level_id) (shaper_profile_id)"
1214 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1215 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1216 " Add port tm leaf node.\n\n"
1218 "del port tm node (port_id) (node_id)\n"
1219 " Delete port tm node.\n\n"
1221 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1222 " (priority) (weight)\n"
1223 " Set port tm node parent.\n\n"
1225 "suspend port tm node (port_id) (node_id)"
1226 " Suspend tm node.\n\n"
1228 "resume port tm node (port_id) (node_id)"
1229 " Resume tm node.\n\n"
1231 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1232 " Commit tm hierarchy.\n\n"
1234 "set port tm mark ip_ecn (port) (green) (yellow)"
1236 " Enables/Disables the traffic management marking"
1237 " for IP ECN (Explicit Congestion Notification)"
1238 " packets on a given port\n\n"
1240 "set port tm mark ip_dscp (port) (green) (yellow)"
1242 " Enables/Disables the traffic management marking"
1243 " on the port for IP dscp packets\n\n"
1245 "set port tm mark vlan_dei (port) (green) (yellow)"
1247 " Enables/Disables the traffic management marking"
1248 " on the port for VLAN packets with DEI enabled\n\n"
1252 if (show_all || !strcmp(res->section, "devices")) {
1256 "Device Operations:\n"
1258 "device detach (identifier)\n"
1259 " Detach device by identifier.\n\n"
1265 cmdline_parse_token_string_t cmd_help_long_help =
1266 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1268 cmdline_parse_token_string_t cmd_help_long_section =
1269 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1270 "all#control#display#config#"
1271 "ports#registers#filters#traffic_management#devices");
1273 cmdline_parse_inst_t cmd_help_long = {
1274 .f = cmd_help_long_parsed,
1276 .help_str = "help all|control|display|config|ports|register|"
1277 "filters|traffic_management|devices: "
1280 (void *)&cmd_help_long_help,
1281 (void *)&cmd_help_long_section,
1287 /* *** start/stop/close all ports *** */
1288 struct cmd_operate_port_result {
1289 cmdline_fixed_string_t keyword;
1290 cmdline_fixed_string_t name;
1291 cmdline_fixed_string_t value;
1294 static void cmd_operate_port_parsed(void *parsed_result,
1295 __attribute__((unused)) struct cmdline *cl,
1296 __attribute__((unused)) void *data)
1298 struct cmd_operate_port_result *res = parsed_result;
1300 if (!strcmp(res->name, "start"))
1301 start_port(RTE_PORT_ALL);
1302 else if (!strcmp(res->name, "stop"))
1303 stop_port(RTE_PORT_ALL);
1304 else if (!strcmp(res->name, "close"))
1305 close_port(RTE_PORT_ALL);
1306 else if (!strcmp(res->name, "reset"))
1307 reset_port(RTE_PORT_ALL);
1309 printf("Unknown parameter\n");
1312 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1313 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1315 cmdline_parse_token_string_t cmd_operate_port_all_port =
1316 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1317 "start#stop#close#reset");
1318 cmdline_parse_token_string_t cmd_operate_port_all_all =
1319 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1321 cmdline_parse_inst_t cmd_operate_port = {
1322 .f = cmd_operate_port_parsed,
1324 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1326 (void *)&cmd_operate_port_all_cmd,
1327 (void *)&cmd_operate_port_all_port,
1328 (void *)&cmd_operate_port_all_all,
1333 /* *** start/stop/close specific port *** */
1334 struct cmd_operate_specific_port_result {
1335 cmdline_fixed_string_t keyword;
1336 cmdline_fixed_string_t name;
1340 static void cmd_operate_specific_port_parsed(void *parsed_result,
1341 __attribute__((unused)) struct cmdline *cl,
1342 __attribute__((unused)) void *data)
1344 struct cmd_operate_specific_port_result *res = parsed_result;
1346 if (!strcmp(res->name, "start"))
1347 start_port(res->value);
1348 else if (!strcmp(res->name, "stop"))
1349 stop_port(res->value);
1350 else if (!strcmp(res->name, "close"))
1351 close_port(res->value);
1352 else if (!strcmp(res->name, "reset"))
1353 reset_port(res->value);
1355 printf("Unknown parameter\n");
1358 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1359 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1361 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1362 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1363 name, "start#stop#close#reset");
1364 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1365 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1368 cmdline_parse_inst_t cmd_operate_specific_port = {
1369 .f = cmd_operate_specific_port_parsed,
1371 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1373 (void *)&cmd_operate_specific_port_cmd,
1374 (void *)&cmd_operate_specific_port_port,
1375 (void *)&cmd_operate_specific_port_id,
1380 /* *** enable port setup (after attach) via iterator or event *** */
1381 struct cmd_set_port_setup_on_result {
1382 cmdline_fixed_string_t set;
1383 cmdline_fixed_string_t port;
1384 cmdline_fixed_string_t setup;
1385 cmdline_fixed_string_t on;
1386 cmdline_fixed_string_t mode;
1389 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1390 __attribute__((unused)) struct cmdline *cl,
1391 __attribute__((unused)) void *data)
1393 struct cmd_set_port_setup_on_result *res = parsed_result;
1395 if (strcmp(res->mode, "event") == 0)
1396 setup_on_probe_event = true;
1397 else if (strcmp(res->mode, "iterator") == 0)
1398 setup_on_probe_event = false;
1400 printf("Unknown mode\n");
1403 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1404 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1406 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1407 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1409 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1410 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1412 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1413 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1415 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1416 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1417 mode, "iterator#event");
1419 cmdline_parse_inst_t cmd_set_port_setup_on = {
1420 .f = cmd_set_port_setup_on_parsed,
1422 .help_str = "set port setup on iterator|event",
1424 (void *)&cmd_set_port_setup_on_set,
1425 (void *)&cmd_set_port_setup_on_port,
1426 (void *)&cmd_set_port_setup_on_setup,
1427 (void *)&cmd_set_port_setup_on_on,
1428 (void *)&cmd_set_port_setup_on_mode,
1433 /* *** attach a specified port *** */
1434 struct cmd_operate_attach_port_result {
1435 cmdline_fixed_string_t port;
1436 cmdline_fixed_string_t keyword;
1437 cmdline_fixed_string_t identifier;
1440 static void cmd_operate_attach_port_parsed(void *parsed_result,
1441 __attribute__((unused)) struct cmdline *cl,
1442 __attribute__((unused)) void *data)
1444 struct cmd_operate_attach_port_result *res = parsed_result;
1446 if (!strcmp(res->keyword, "attach"))
1447 attach_port(res->identifier);
1449 printf("Unknown parameter\n");
1452 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1453 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1455 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1456 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1458 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1459 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1462 cmdline_parse_inst_t cmd_operate_attach_port = {
1463 .f = cmd_operate_attach_port_parsed,
1465 .help_str = "port attach <identifier>: "
1466 "(identifier: pci address or virtual dev name)",
1468 (void *)&cmd_operate_attach_port_port,
1469 (void *)&cmd_operate_attach_port_keyword,
1470 (void *)&cmd_operate_attach_port_identifier,
1475 /* *** detach a specified port *** */
1476 struct cmd_operate_detach_port_result {
1477 cmdline_fixed_string_t port;
1478 cmdline_fixed_string_t keyword;
1482 static void cmd_operate_detach_port_parsed(void *parsed_result,
1483 __attribute__((unused)) struct cmdline *cl,
1484 __attribute__((unused)) void *data)
1486 struct cmd_operate_detach_port_result *res = parsed_result;
1488 if (!strcmp(res->keyword, "detach"))
1489 detach_port_device(res->port_id);
1491 printf("Unknown parameter\n");
1494 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1495 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1497 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1498 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1500 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1501 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1504 cmdline_parse_inst_t cmd_operate_detach_port = {
1505 .f = cmd_operate_detach_port_parsed,
1507 .help_str = "port detach <port_id>",
1509 (void *)&cmd_operate_detach_port_port,
1510 (void *)&cmd_operate_detach_port_keyword,
1511 (void *)&cmd_operate_detach_port_port_id,
1516 /* *** detach device by identifier *** */
1517 struct cmd_operate_detach_device_result {
1518 cmdline_fixed_string_t device;
1519 cmdline_fixed_string_t keyword;
1520 cmdline_fixed_string_t identifier;
1523 static void cmd_operate_detach_device_parsed(void *parsed_result,
1524 __attribute__((unused)) struct cmdline *cl,
1525 __attribute__((unused)) void *data)
1527 struct cmd_operate_detach_device_result *res = parsed_result;
1529 if (!strcmp(res->keyword, "detach"))
1530 detach_device(res->identifier);
1532 printf("Unknown parameter\n");
1535 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1536 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1538 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1539 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1541 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1542 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1545 cmdline_parse_inst_t cmd_operate_detach_device = {
1546 .f = cmd_operate_detach_device_parsed,
1548 .help_str = "device detach <identifier>:"
1549 "(identifier: pci address or virtual dev name)",
1551 (void *)&cmd_operate_detach_device_device,
1552 (void *)&cmd_operate_detach_device_keyword,
1553 (void *)&cmd_operate_detach_device_identifier,
1557 /* *** configure speed for all ports *** */
1558 struct cmd_config_speed_all {
1559 cmdline_fixed_string_t port;
1560 cmdline_fixed_string_t keyword;
1561 cmdline_fixed_string_t all;
1562 cmdline_fixed_string_t item1;
1563 cmdline_fixed_string_t item2;
1564 cmdline_fixed_string_t value1;
1565 cmdline_fixed_string_t value2;
1569 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1574 if (!strcmp(duplexstr, "half")) {
1575 duplex = ETH_LINK_HALF_DUPLEX;
1576 } else if (!strcmp(duplexstr, "full")) {
1577 duplex = ETH_LINK_FULL_DUPLEX;
1578 } else if (!strcmp(duplexstr, "auto")) {
1579 duplex = ETH_LINK_FULL_DUPLEX;
1581 printf("Unknown duplex parameter\n");
1585 if (!strcmp(speedstr, "10")) {
1586 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1587 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1588 } else if (!strcmp(speedstr, "100")) {
1589 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1590 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1592 if (duplex != ETH_LINK_FULL_DUPLEX) {
1593 printf("Invalid speed/duplex parameters\n");
1596 if (!strcmp(speedstr, "1000")) {
1597 *speed = ETH_LINK_SPEED_1G;
1598 } else if (!strcmp(speedstr, "10000")) {
1599 *speed = ETH_LINK_SPEED_10G;
1600 } else if (!strcmp(speedstr, "25000")) {
1601 *speed = ETH_LINK_SPEED_25G;
1602 } else if (!strcmp(speedstr, "40000")) {
1603 *speed = ETH_LINK_SPEED_40G;
1604 } else if (!strcmp(speedstr, "50000")) {
1605 *speed = ETH_LINK_SPEED_50G;
1606 } else if (!strcmp(speedstr, "100000")) {
1607 *speed = ETH_LINK_SPEED_100G;
1608 } else if (!strcmp(speedstr, "auto")) {
1609 *speed = ETH_LINK_SPEED_AUTONEG;
1611 printf("Unknown speed parameter\n");
1620 cmd_config_speed_all_parsed(void *parsed_result,
1621 __attribute__((unused)) struct cmdline *cl,
1622 __attribute__((unused)) void *data)
1624 struct cmd_config_speed_all *res = parsed_result;
1625 uint32_t link_speed;
1628 if (!all_ports_stopped()) {
1629 printf("Please stop all ports first\n");
1633 if (parse_and_check_speed_duplex(res->value1, res->value2,
1637 RTE_ETH_FOREACH_DEV(pid) {
1638 ports[pid].dev_conf.link_speeds = link_speed;
1641 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1644 cmdline_parse_token_string_t cmd_config_speed_all_port =
1645 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1646 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1647 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1649 cmdline_parse_token_string_t cmd_config_speed_all_all =
1650 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1651 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1652 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1653 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1654 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1655 "10#100#1000#10000#25000#40000#50000#100000#auto");
1656 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1657 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1658 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1659 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1662 cmdline_parse_inst_t cmd_config_speed_all = {
1663 .f = cmd_config_speed_all_parsed,
1665 .help_str = "port config all speed "
1666 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1669 (void *)&cmd_config_speed_all_port,
1670 (void *)&cmd_config_speed_all_keyword,
1671 (void *)&cmd_config_speed_all_all,
1672 (void *)&cmd_config_speed_all_item1,
1673 (void *)&cmd_config_speed_all_value1,
1674 (void *)&cmd_config_speed_all_item2,
1675 (void *)&cmd_config_speed_all_value2,
1680 /* *** configure speed for specific port *** */
1681 struct cmd_config_speed_specific {
1682 cmdline_fixed_string_t port;
1683 cmdline_fixed_string_t keyword;
1685 cmdline_fixed_string_t item1;
1686 cmdline_fixed_string_t item2;
1687 cmdline_fixed_string_t value1;
1688 cmdline_fixed_string_t value2;
1692 cmd_config_speed_specific_parsed(void *parsed_result,
1693 __attribute__((unused)) struct cmdline *cl,
1694 __attribute__((unused)) void *data)
1696 struct cmd_config_speed_specific *res = parsed_result;
1697 uint32_t link_speed;
1699 if (!all_ports_stopped()) {
1700 printf("Please stop all ports first\n");
1704 if (port_id_is_invalid(res->id, ENABLED_WARN))
1707 if (parse_and_check_speed_duplex(res->value1, res->value2,
1711 ports[res->id].dev_conf.link_speeds = link_speed;
1713 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1717 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1718 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1720 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1721 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1723 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1724 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1725 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1726 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1728 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1729 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1730 "10#100#1000#10000#25000#40000#50000#100000#auto");
1731 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1732 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1734 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1735 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1738 cmdline_parse_inst_t cmd_config_speed_specific = {
1739 .f = cmd_config_speed_specific_parsed,
1741 .help_str = "port config <port_id> speed "
1742 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1745 (void *)&cmd_config_speed_specific_port,
1746 (void *)&cmd_config_speed_specific_keyword,
1747 (void *)&cmd_config_speed_specific_id,
1748 (void *)&cmd_config_speed_specific_item1,
1749 (void *)&cmd_config_speed_specific_value1,
1750 (void *)&cmd_config_speed_specific_item2,
1751 (void *)&cmd_config_speed_specific_value2,
1756 /* *** configure loopback for all ports *** */
1757 struct cmd_config_loopback_all {
1758 cmdline_fixed_string_t port;
1759 cmdline_fixed_string_t keyword;
1760 cmdline_fixed_string_t all;
1761 cmdline_fixed_string_t item;
1766 cmd_config_loopback_all_parsed(void *parsed_result,
1767 __attribute__((unused)) struct cmdline *cl,
1768 __attribute__((unused)) void *data)
1770 struct cmd_config_loopback_all *res = parsed_result;
1773 if (!all_ports_stopped()) {
1774 printf("Please stop all ports first\n");
1778 RTE_ETH_FOREACH_DEV(pid) {
1779 ports[pid].dev_conf.lpbk_mode = res->mode;
1782 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1785 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1786 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1787 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1788 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1790 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1791 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1792 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1793 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1795 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1796 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1798 cmdline_parse_inst_t cmd_config_loopback_all = {
1799 .f = cmd_config_loopback_all_parsed,
1801 .help_str = "port config all loopback <mode>",
1803 (void *)&cmd_config_loopback_all_port,
1804 (void *)&cmd_config_loopback_all_keyword,
1805 (void *)&cmd_config_loopback_all_all,
1806 (void *)&cmd_config_loopback_all_item,
1807 (void *)&cmd_config_loopback_all_mode,
1812 /* *** configure loopback for specific port *** */
1813 struct cmd_config_loopback_specific {
1814 cmdline_fixed_string_t port;
1815 cmdline_fixed_string_t keyword;
1817 cmdline_fixed_string_t item;
1822 cmd_config_loopback_specific_parsed(void *parsed_result,
1823 __attribute__((unused)) struct cmdline *cl,
1824 __attribute__((unused)) void *data)
1826 struct cmd_config_loopback_specific *res = parsed_result;
1828 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1831 if (!port_is_stopped(res->port_id)) {
1832 printf("Please stop port %u first\n", res->port_id);
1836 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1838 cmd_reconfig_device_queue(res->port_id, 1, 1);
1842 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1843 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1845 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1846 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1848 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1849 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1851 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1852 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1854 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1855 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1858 cmdline_parse_inst_t cmd_config_loopback_specific = {
1859 .f = cmd_config_loopback_specific_parsed,
1861 .help_str = "port config <port_id> loopback <mode>",
1863 (void *)&cmd_config_loopback_specific_port,
1864 (void *)&cmd_config_loopback_specific_keyword,
1865 (void *)&cmd_config_loopback_specific_id,
1866 (void *)&cmd_config_loopback_specific_item,
1867 (void *)&cmd_config_loopback_specific_mode,
1872 /* *** configure txq/rxq, txd/rxd *** */
1873 struct cmd_config_rx_tx {
1874 cmdline_fixed_string_t port;
1875 cmdline_fixed_string_t keyword;
1876 cmdline_fixed_string_t all;
1877 cmdline_fixed_string_t name;
1882 cmd_config_rx_tx_parsed(void *parsed_result,
1883 __attribute__((unused)) struct cmdline *cl,
1884 __attribute__((unused)) void *data)
1886 struct cmd_config_rx_tx *res = parsed_result;
1888 if (!all_ports_stopped()) {
1889 printf("Please stop all ports first\n");
1892 if (!strcmp(res->name, "rxq")) {
1893 if (!res->value && !nb_txq) {
1894 printf("Warning: Either rx or tx queues should be non zero\n");
1897 if (check_nb_rxq(res->value) != 0)
1899 nb_rxq = res->value;
1901 else if (!strcmp(res->name, "txq")) {
1902 if (!res->value && !nb_rxq) {
1903 printf("Warning: Either rx or tx queues should be non zero\n");
1906 if (check_nb_txq(res->value) != 0)
1908 nb_txq = res->value;
1910 else if (!strcmp(res->name, "rxd")) {
1911 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1912 printf("rxd %d invalid - must be > 0 && <= %d\n",
1913 res->value, RTE_TEST_RX_DESC_MAX);
1916 nb_rxd = res->value;
1917 } else if (!strcmp(res->name, "txd")) {
1918 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1919 printf("txd %d invalid - must be > 0 && <= %d\n",
1920 res->value, RTE_TEST_TX_DESC_MAX);
1923 nb_txd = res->value;
1925 printf("Unknown parameter\n");
1933 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1936 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1937 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1938 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1939 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1940 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1941 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1942 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1943 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1945 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1946 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1948 cmdline_parse_inst_t cmd_config_rx_tx = {
1949 .f = cmd_config_rx_tx_parsed,
1951 .help_str = "port config all rxq|txq|rxd|txd <value>",
1953 (void *)&cmd_config_rx_tx_port,
1954 (void *)&cmd_config_rx_tx_keyword,
1955 (void *)&cmd_config_rx_tx_all,
1956 (void *)&cmd_config_rx_tx_name,
1957 (void *)&cmd_config_rx_tx_value,
1962 /* *** config max packet length *** */
1963 struct cmd_config_max_pkt_len_result {
1964 cmdline_fixed_string_t port;
1965 cmdline_fixed_string_t keyword;
1966 cmdline_fixed_string_t all;
1967 cmdline_fixed_string_t name;
1972 cmd_config_max_pkt_len_parsed(void *parsed_result,
1973 __attribute__((unused)) struct cmdline *cl,
1974 __attribute__((unused)) void *data)
1976 struct cmd_config_max_pkt_len_result *res = parsed_result;
1979 if (!all_ports_stopped()) {
1980 printf("Please stop all ports first\n");
1984 RTE_ETH_FOREACH_DEV(pid) {
1985 struct rte_port *port = &ports[pid];
1986 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1988 if (!strcmp(res->name, "max-pkt-len")) {
1989 if (res->value < RTE_ETHER_MIN_LEN) {
1990 printf("max-pkt-len can not be less than %d\n",
1994 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1997 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1998 if (res->value > RTE_ETHER_MAX_LEN)
1999 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2001 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2002 port->dev_conf.rxmode.offloads = rx_offloads;
2004 printf("Unknown parameter\n");
2011 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2014 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2015 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2017 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2018 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2020 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2021 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2023 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2024 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2026 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2027 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2030 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2031 .f = cmd_config_max_pkt_len_parsed,
2033 .help_str = "port config all max-pkt-len <value>",
2035 (void *)&cmd_config_max_pkt_len_port,
2036 (void *)&cmd_config_max_pkt_len_keyword,
2037 (void *)&cmd_config_max_pkt_len_all,
2038 (void *)&cmd_config_max_pkt_len_name,
2039 (void *)&cmd_config_max_pkt_len_value,
2044 /* *** configure port MTU *** */
2045 struct cmd_config_mtu_result {
2046 cmdline_fixed_string_t port;
2047 cmdline_fixed_string_t keyword;
2048 cmdline_fixed_string_t mtu;
2054 cmd_config_mtu_parsed(void *parsed_result,
2055 __attribute__((unused)) struct cmdline *cl,
2056 __attribute__((unused)) void *data)
2058 struct cmd_config_mtu_result *res = parsed_result;
2060 if (res->value < RTE_ETHER_MIN_LEN) {
2061 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2064 port_mtu_set(res->port_id, res->value);
2067 cmdline_parse_token_string_t cmd_config_mtu_port =
2068 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2070 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2071 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2073 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2074 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2076 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2077 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2078 cmdline_parse_token_num_t cmd_config_mtu_value =
2079 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2081 cmdline_parse_inst_t cmd_config_mtu = {
2082 .f = cmd_config_mtu_parsed,
2084 .help_str = "port config mtu <port_id> <value>",
2086 (void *)&cmd_config_mtu_port,
2087 (void *)&cmd_config_mtu_keyword,
2088 (void *)&cmd_config_mtu_mtu,
2089 (void *)&cmd_config_mtu_port_id,
2090 (void *)&cmd_config_mtu_value,
2095 /* *** configure rx mode *** */
2096 struct cmd_config_rx_mode_flag {
2097 cmdline_fixed_string_t port;
2098 cmdline_fixed_string_t keyword;
2099 cmdline_fixed_string_t all;
2100 cmdline_fixed_string_t name;
2101 cmdline_fixed_string_t value;
2105 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2106 __attribute__((unused)) struct cmdline *cl,
2107 __attribute__((unused)) void *data)
2109 struct cmd_config_rx_mode_flag *res = parsed_result;
2111 if (!all_ports_stopped()) {
2112 printf("Please stop all ports first\n");
2116 if (!strcmp(res->name, "drop-en")) {
2117 if (!strcmp(res->value, "on"))
2119 else if (!strcmp(res->value, "off"))
2122 printf("Unknown parameter\n");
2126 printf("Unknown parameter\n");
2132 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2135 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2136 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2137 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2138 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2140 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2141 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2142 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2143 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2145 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2146 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2149 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2150 .f = cmd_config_rx_mode_flag_parsed,
2152 .help_str = "port config all drop-en on|off",
2154 (void *)&cmd_config_rx_mode_flag_port,
2155 (void *)&cmd_config_rx_mode_flag_keyword,
2156 (void *)&cmd_config_rx_mode_flag_all,
2157 (void *)&cmd_config_rx_mode_flag_name,
2158 (void *)&cmd_config_rx_mode_flag_value,
2163 /* *** configure rss *** */
2164 struct cmd_config_rss {
2165 cmdline_fixed_string_t port;
2166 cmdline_fixed_string_t keyword;
2167 cmdline_fixed_string_t all;
2168 cmdline_fixed_string_t name;
2169 cmdline_fixed_string_t value;
2173 cmd_config_rss_parsed(void *parsed_result,
2174 __attribute__((unused)) struct cmdline *cl,
2175 __attribute__((unused)) void *data)
2177 struct cmd_config_rss *res = parsed_result;
2178 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2179 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2180 int use_default = 0;
2181 int all_updated = 1;
2186 if (!strcmp(res->value, "all"))
2187 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2188 ETH_RSS_UDP | ETH_RSS_SCTP |
2190 else if (!strcmp(res->value, "ip"))
2191 rss_conf.rss_hf = ETH_RSS_IP;
2192 else if (!strcmp(res->value, "udp"))
2193 rss_conf.rss_hf = ETH_RSS_UDP;
2194 else if (!strcmp(res->value, "tcp"))
2195 rss_conf.rss_hf = ETH_RSS_TCP;
2196 else if (!strcmp(res->value, "sctp"))
2197 rss_conf.rss_hf = ETH_RSS_SCTP;
2198 else if (!strcmp(res->value, "ether"))
2199 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2200 else if (!strcmp(res->value, "port"))
2201 rss_conf.rss_hf = ETH_RSS_PORT;
2202 else if (!strcmp(res->value, "vxlan"))
2203 rss_conf.rss_hf = ETH_RSS_VXLAN;
2204 else if (!strcmp(res->value, "geneve"))
2205 rss_conf.rss_hf = ETH_RSS_GENEVE;
2206 else if (!strcmp(res->value, "nvgre"))
2207 rss_conf.rss_hf = ETH_RSS_NVGRE;
2208 else if (!strcmp(res->value, "none"))
2209 rss_conf.rss_hf = 0;
2210 else if (!strcmp(res->value, "default"))
2212 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2213 atoi(res->value) < 64)
2214 rss_conf.rss_hf = 1ULL << atoi(res->value);
2216 printf("Unknown parameter\n");
2219 rss_conf.rss_key = NULL;
2220 /* Update global configuration for RSS types. */
2221 RTE_ETH_FOREACH_DEV(i) {
2222 struct rte_eth_rss_conf local_rss_conf;
2224 ret = eth_dev_info_get_print_err(i, &dev_info);
2229 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2231 local_rss_conf = rss_conf;
2232 local_rss_conf.rss_hf = rss_conf.rss_hf &
2233 dev_info.flow_type_rss_offloads;
2234 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2235 printf("Port %u modified RSS hash function based on hardware support,"
2236 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2237 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2239 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2242 printf("Configuration of RSS hash at ethernet port %d "
2243 "failed with error (%d): %s.\n",
2244 i, -diag, strerror(-diag));
2247 if (all_updated && !use_default)
2248 rss_hf = rss_conf.rss_hf;
2251 cmdline_parse_token_string_t cmd_config_rss_port =
2252 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2253 cmdline_parse_token_string_t cmd_config_rss_keyword =
2254 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2255 cmdline_parse_token_string_t cmd_config_rss_all =
2256 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2257 cmdline_parse_token_string_t cmd_config_rss_name =
2258 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2259 cmdline_parse_token_string_t cmd_config_rss_value =
2260 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2262 cmdline_parse_inst_t cmd_config_rss = {
2263 .f = cmd_config_rss_parsed,
2265 .help_str = "port config all rss "
2266 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>",
2268 (void *)&cmd_config_rss_port,
2269 (void *)&cmd_config_rss_keyword,
2270 (void *)&cmd_config_rss_all,
2271 (void *)&cmd_config_rss_name,
2272 (void *)&cmd_config_rss_value,
2277 /* *** configure rss hash key *** */
2278 struct cmd_config_rss_hash_key {
2279 cmdline_fixed_string_t port;
2280 cmdline_fixed_string_t config;
2282 cmdline_fixed_string_t rss_hash_key;
2283 cmdline_fixed_string_t rss_type;
2284 cmdline_fixed_string_t key;
2288 hexa_digit_to_value(char hexa_digit)
2290 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2291 return (uint8_t) (hexa_digit - '0');
2292 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2293 return (uint8_t) ((hexa_digit - 'a') + 10);
2294 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2295 return (uint8_t) ((hexa_digit - 'A') + 10);
2296 /* Invalid hexa digit */
2301 parse_and_check_key_hexa_digit(char *key, int idx)
2305 hexa_v = hexa_digit_to_value(key[idx]);
2307 printf("invalid key: character %c at position %d is not a "
2308 "valid hexa digit\n", key[idx], idx);
2313 cmd_config_rss_hash_key_parsed(void *parsed_result,
2314 __attribute__((unused)) struct cmdline *cl,
2315 __attribute__((unused)) void *data)
2317 struct cmd_config_rss_hash_key *res = parsed_result;
2318 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2322 struct rte_eth_dev_info dev_info;
2323 uint8_t hash_key_size;
2327 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2331 if (dev_info.hash_key_size > 0 &&
2332 dev_info.hash_key_size <= sizeof(hash_key))
2333 hash_key_size = dev_info.hash_key_size;
2335 printf("dev_info did not provide a valid hash key size\n");
2338 /* Check the length of the RSS hash key */
2339 key_len = strlen(res->key);
2340 if (key_len != (hash_key_size * 2)) {
2341 printf("key length: %d invalid - key must be a string of %d"
2342 " hexa-decimal numbers\n",
2343 (int) key_len, hash_key_size * 2);
2346 /* Translate RSS hash key into binary representation */
2347 for (i = 0; i < hash_key_size; i++) {
2348 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2351 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2354 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2356 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2360 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2361 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2362 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2363 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2365 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2366 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2367 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2368 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2369 rss_hash_key, "rss-hash-key");
2370 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2371 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2372 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2373 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2374 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2375 "ipv6-tcp-ex#ipv6-udp-ex");
2376 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2377 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2379 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2380 .f = cmd_config_rss_hash_key_parsed,
2382 .help_str = "port config <port_id> rss-hash-key "
2383 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2384 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2385 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2386 "<string of hex digits (variable length, NIC dependent)>",
2388 (void *)&cmd_config_rss_hash_key_port,
2389 (void *)&cmd_config_rss_hash_key_config,
2390 (void *)&cmd_config_rss_hash_key_port_id,
2391 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2392 (void *)&cmd_config_rss_hash_key_rss_type,
2393 (void *)&cmd_config_rss_hash_key_value,
2398 /* *** configure port rxq/txq ring size *** */
2399 struct cmd_config_rxtx_ring_size {
2400 cmdline_fixed_string_t port;
2401 cmdline_fixed_string_t config;
2403 cmdline_fixed_string_t rxtxq;
2405 cmdline_fixed_string_t rsize;
2410 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2411 __attribute__((unused)) struct cmdline *cl,
2412 __attribute__((unused)) void *data)
2414 struct cmd_config_rxtx_ring_size *res = parsed_result;
2415 struct rte_port *port;
2418 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2421 if (res->portid == (portid_t)RTE_PORT_ALL) {
2422 printf("Invalid port id\n");
2426 port = &ports[res->portid];
2428 if (!strcmp(res->rxtxq, "rxq"))
2430 else if (!strcmp(res->rxtxq, "txq"))
2433 printf("Unknown parameter\n");
2437 if (isrx && rx_queue_id_is_invalid(res->qid))
2439 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2442 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2443 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2449 port->nb_rx_desc[res->qid] = res->size;
2451 port->nb_tx_desc[res->qid] = res->size;
2453 cmd_reconfig_device_queue(res->portid, 0, 1);
2456 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2457 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2459 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2460 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2462 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2463 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2465 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2466 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2468 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2469 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2471 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2472 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2473 rsize, "ring_size");
2474 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2475 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2478 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2479 .f = cmd_config_rxtx_ring_size_parsed,
2481 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2483 (void *)&cmd_config_rxtx_ring_size_port,
2484 (void *)&cmd_config_rxtx_ring_size_config,
2485 (void *)&cmd_config_rxtx_ring_size_portid,
2486 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2487 (void *)&cmd_config_rxtx_ring_size_qid,
2488 (void *)&cmd_config_rxtx_ring_size_rsize,
2489 (void *)&cmd_config_rxtx_ring_size_size,
2494 /* *** configure port rxq/txq start/stop *** */
2495 struct cmd_config_rxtx_queue {
2496 cmdline_fixed_string_t port;
2498 cmdline_fixed_string_t rxtxq;
2500 cmdline_fixed_string_t opname;
2504 cmd_config_rxtx_queue_parsed(void *parsed_result,
2505 __attribute__((unused)) struct cmdline *cl,
2506 __attribute__((unused)) void *data)
2508 struct cmd_config_rxtx_queue *res = parsed_result;
2513 if (test_done == 0) {
2514 printf("Please stop forwarding first\n");
2518 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2521 if (port_is_started(res->portid) != 1) {
2522 printf("Please start port %u first\n", res->portid);
2526 if (!strcmp(res->rxtxq, "rxq"))
2528 else if (!strcmp(res->rxtxq, "txq"))
2531 printf("Unknown parameter\n");
2535 if (isrx && rx_queue_id_is_invalid(res->qid))
2537 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2540 if (!strcmp(res->opname, "start"))
2542 else if (!strcmp(res->opname, "stop"))
2545 printf("Unknown parameter\n");
2549 if (isstart && isrx)
2550 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2551 else if (!isstart && isrx)
2552 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2553 else if (isstart && !isrx)
2554 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2556 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2558 if (ret == -ENOTSUP)
2559 printf("Function not supported in PMD driver\n");
2562 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2563 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2564 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2565 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2566 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2567 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2568 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2569 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2570 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2571 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2574 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2575 .f = cmd_config_rxtx_queue_parsed,
2577 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2579 (void *)&cmd_config_rxtx_queue_port,
2580 (void *)&cmd_config_rxtx_queue_portid,
2581 (void *)&cmd_config_rxtx_queue_rxtxq,
2582 (void *)&cmd_config_rxtx_queue_qid,
2583 (void *)&cmd_config_rxtx_queue_opname,
2588 /* *** configure port rxq/txq deferred start on/off *** */
2589 struct cmd_config_deferred_start_rxtx_queue {
2590 cmdline_fixed_string_t port;
2592 cmdline_fixed_string_t rxtxq;
2594 cmdline_fixed_string_t opname;
2595 cmdline_fixed_string_t state;
2599 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2600 __attribute__((unused)) struct cmdline *cl,
2601 __attribute__((unused)) void *data)
2603 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2604 struct rte_port *port;
2607 uint8_t needreconfig = 0;
2609 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2612 if (port_is_started(res->port_id) != 0) {
2613 printf("Please stop port %u first\n", res->port_id);
2617 port = &ports[res->port_id];
2619 isrx = !strcmp(res->rxtxq, "rxq");
2621 if (isrx && rx_queue_id_is_invalid(res->qid))
2623 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2626 ison = !strcmp(res->state, "on");
2628 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2629 port->rx_conf[res->qid].rx_deferred_start = ison;
2631 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2632 port->tx_conf[res->qid].tx_deferred_start = ison;
2637 cmd_reconfig_device_queue(res->port_id, 0, 1);
2640 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2641 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2643 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2644 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2646 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2647 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2649 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2650 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2652 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2653 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2654 opname, "deferred_start");
2655 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2656 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2659 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2660 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2662 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2664 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2665 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2666 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2667 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2668 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2669 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2674 /* *** configure port rxq/txq setup *** */
2675 struct cmd_setup_rxtx_queue {
2676 cmdline_fixed_string_t port;
2678 cmdline_fixed_string_t rxtxq;
2680 cmdline_fixed_string_t setup;
2683 /* Common CLI fields for queue setup */
2684 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2685 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2686 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2687 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2688 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2689 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2690 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2691 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2692 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2693 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2696 cmd_setup_rxtx_queue_parsed(
2697 void *parsed_result,
2698 __attribute__((unused)) struct cmdline *cl,
2699 __attribute__((unused)) void *data)
2701 struct cmd_setup_rxtx_queue *res = parsed_result;
2702 struct rte_port *port;
2703 struct rte_mempool *mp;
2704 unsigned int socket_id;
2708 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2711 if (res->portid == (portid_t)RTE_PORT_ALL) {
2712 printf("Invalid port id\n");
2716 if (!strcmp(res->rxtxq, "rxq"))
2718 else if (!strcmp(res->rxtxq, "txq"))
2721 printf("Unknown parameter\n");
2725 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2726 printf("Invalid rx queue\n");
2728 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2729 printf("Invalid tx queue\n");
2733 port = &ports[res->portid];
2735 socket_id = rxring_numa[res->portid];
2736 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2737 socket_id = port->socket_id;
2739 mp = mbuf_pool_find(socket_id);
2741 printf("Failed to setup RX queue: "
2742 "No mempool allocation"
2743 " on the socket %d\n",
2744 rxring_numa[res->portid]);
2747 ret = rte_eth_rx_queue_setup(res->portid,
2749 port->nb_rx_desc[res->qid],
2751 &port->rx_conf[res->qid],
2754 printf("Failed to setup RX queue\n");
2756 socket_id = txring_numa[res->portid];
2757 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2758 socket_id = port->socket_id;
2760 ret = rte_eth_tx_queue_setup(res->portid,
2762 port->nb_tx_desc[res->qid],
2764 &port->tx_conf[res->qid]);
2766 printf("Failed to setup TX queue\n");
2770 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2771 .f = cmd_setup_rxtx_queue_parsed,
2773 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2775 (void *)&cmd_setup_rxtx_queue_port,
2776 (void *)&cmd_setup_rxtx_queue_portid,
2777 (void *)&cmd_setup_rxtx_queue_rxtxq,
2778 (void *)&cmd_setup_rxtx_queue_qid,
2779 (void *)&cmd_setup_rxtx_queue_setup,
2785 /* *** Configure RSS RETA *** */
2786 struct cmd_config_rss_reta {
2787 cmdline_fixed_string_t port;
2788 cmdline_fixed_string_t keyword;
2790 cmdline_fixed_string_t name;
2791 cmdline_fixed_string_t list_name;
2792 cmdline_fixed_string_t list_of_items;
2796 parse_reta_config(const char *str,
2797 struct rte_eth_rss_reta_entry64 *reta_conf,
2798 uint16_t nb_entries)
2802 uint16_t hash_index, idx, shift;
2805 const char *p, *p0 = str;
2812 unsigned long int_fld[_NUM_FLD];
2813 char *str_fld[_NUM_FLD];
2815 while ((p = strchr(p0,'(')) != NULL) {
2817 if((p0 = strchr(p,')')) == NULL)
2821 if(size >= sizeof(s))
2824 snprintf(s, sizeof(s), "%.*s", size, p);
2825 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2827 for (i = 0; i < _NUM_FLD; i++) {
2829 int_fld[i] = strtoul(str_fld[i], &end, 0);
2830 if (errno != 0 || end == str_fld[i] ||
2835 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2836 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2838 if (hash_index >= nb_entries) {
2839 printf("Invalid RETA hash index=%d\n", hash_index);
2843 idx = hash_index / RTE_RETA_GROUP_SIZE;
2844 shift = hash_index % RTE_RETA_GROUP_SIZE;
2845 reta_conf[idx].mask |= (1ULL << shift);
2846 reta_conf[idx].reta[shift] = nb_queue;
2853 cmd_set_rss_reta_parsed(void *parsed_result,
2854 __attribute__((unused)) struct cmdline *cl,
2855 __attribute__((unused)) void *data)
2858 struct rte_eth_dev_info dev_info;
2859 struct rte_eth_rss_reta_entry64 reta_conf[8];
2860 struct cmd_config_rss_reta *res = parsed_result;
2862 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2866 if (dev_info.reta_size == 0) {
2867 printf("Redirection table size is 0 which is "
2868 "invalid for RSS\n");
2871 printf("The reta size of port %d is %u\n",
2872 res->port_id, dev_info.reta_size);
2873 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2874 printf("Currently do not support more than %u entries of "
2875 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2879 memset(reta_conf, 0, sizeof(reta_conf));
2880 if (!strcmp(res->list_name, "reta")) {
2881 if (parse_reta_config(res->list_of_items, reta_conf,
2882 dev_info.reta_size)) {
2883 printf("Invalid RSS Redirection Table "
2884 "config entered\n");
2887 ret = rte_eth_dev_rss_reta_update(res->port_id,
2888 reta_conf, dev_info.reta_size);
2890 printf("Bad redirection table parameter, "
2891 "return code = %d \n", ret);
2895 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2896 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2897 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2898 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2899 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2900 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2901 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2902 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2903 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2904 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2905 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2906 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2908 cmdline_parse_inst_t cmd_config_rss_reta = {
2909 .f = cmd_set_rss_reta_parsed,
2911 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2913 (void *)&cmd_config_rss_reta_port,
2914 (void *)&cmd_config_rss_reta_keyword,
2915 (void *)&cmd_config_rss_reta_port_id,
2916 (void *)&cmd_config_rss_reta_name,
2917 (void *)&cmd_config_rss_reta_list_name,
2918 (void *)&cmd_config_rss_reta_list_of_items,
2923 /* *** SHOW PORT RETA INFO *** */
2924 struct cmd_showport_reta {
2925 cmdline_fixed_string_t show;
2926 cmdline_fixed_string_t port;
2928 cmdline_fixed_string_t rss;
2929 cmdline_fixed_string_t reta;
2931 cmdline_fixed_string_t list_of_items;
2935 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2936 uint16_t nb_entries,
2940 const char *p, *p0 = str;
2945 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2946 RTE_RETA_GROUP_SIZE;
2949 p = strchr(p0, '(');
2953 p0 = strchr(p, ')');
2957 if (size >= sizeof(s)) {
2958 printf("The string size exceeds the internal buffer size\n");
2961 snprintf(s, sizeof(s), "%.*s", size, p);
2962 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2963 if (ret <= 0 || ret != num) {
2964 printf("The bits of masks do not match the number of "
2965 "reta entries: %u\n", num);
2968 for (i = 0; i < ret; i++)
2969 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2975 cmd_showport_reta_parsed(void *parsed_result,
2976 __attribute__((unused)) struct cmdline *cl,
2977 __attribute__((unused)) void *data)
2979 struct cmd_showport_reta *res = parsed_result;
2980 struct rte_eth_rss_reta_entry64 reta_conf[8];
2981 struct rte_eth_dev_info dev_info;
2982 uint16_t max_reta_size;
2985 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2989 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2990 if (res->size == 0 || res->size > max_reta_size) {
2991 printf("Invalid redirection table size: %u (1-%u)\n",
2992 res->size, max_reta_size);
2996 memset(reta_conf, 0, sizeof(reta_conf));
2997 if (showport_parse_reta_config(reta_conf, res->size,
2998 res->list_of_items) < 0) {
2999 printf("Invalid string: %s for reta masks\n",
3000 res->list_of_items);
3003 port_rss_reta_info(res->port_id, reta_conf, res->size);
3006 cmdline_parse_token_string_t cmd_showport_reta_show =
3007 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3008 cmdline_parse_token_string_t cmd_showport_reta_port =
3009 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3010 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3011 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3012 cmdline_parse_token_string_t cmd_showport_reta_rss =
3013 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3014 cmdline_parse_token_string_t cmd_showport_reta_reta =
3015 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3016 cmdline_parse_token_num_t cmd_showport_reta_size =
3017 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3018 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3019 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3020 list_of_items, NULL);
3022 cmdline_parse_inst_t cmd_showport_reta = {
3023 .f = cmd_showport_reta_parsed,
3025 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3027 (void *)&cmd_showport_reta_show,
3028 (void *)&cmd_showport_reta_port,
3029 (void *)&cmd_showport_reta_port_id,
3030 (void *)&cmd_showport_reta_rss,
3031 (void *)&cmd_showport_reta_reta,
3032 (void *)&cmd_showport_reta_size,
3033 (void *)&cmd_showport_reta_list_of_items,
3038 /* *** Show RSS hash configuration *** */
3039 struct cmd_showport_rss_hash {
3040 cmdline_fixed_string_t show;
3041 cmdline_fixed_string_t port;
3043 cmdline_fixed_string_t rss_hash;
3044 cmdline_fixed_string_t rss_type;
3045 cmdline_fixed_string_t key; /* optional argument */
3048 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3049 __attribute__((unused)) struct cmdline *cl,
3052 struct cmd_showport_rss_hash *res = parsed_result;
3054 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3057 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3058 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3059 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3060 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3061 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3062 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3063 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3064 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3066 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3067 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3069 cmdline_parse_inst_t cmd_showport_rss_hash = {
3070 .f = cmd_showport_rss_hash_parsed,
3072 .help_str = "show port <port_id> rss-hash",
3074 (void *)&cmd_showport_rss_hash_show,
3075 (void *)&cmd_showport_rss_hash_port,
3076 (void *)&cmd_showport_rss_hash_port_id,
3077 (void *)&cmd_showport_rss_hash_rss_hash,
3082 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3083 .f = cmd_showport_rss_hash_parsed,
3085 .help_str = "show port <port_id> rss-hash key",
3087 (void *)&cmd_showport_rss_hash_show,
3088 (void *)&cmd_showport_rss_hash_port,
3089 (void *)&cmd_showport_rss_hash_port_id,
3090 (void *)&cmd_showport_rss_hash_rss_hash,
3091 (void *)&cmd_showport_rss_hash_rss_key,
3096 /* *** Configure DCB *** */
3097 struct cmd_config_dcb {
3098 cmdline_fixed_string_t port;
3099 cmdline_fixed_string_t config;
3101 cmdline_fixed_string_t dcb;
3102 cmdline_fixed_string_t vt;
3103 cmdline_fixed_string_t vt_en;
3105 cmdline_fixed_string_t pfc;
3106 cmdline_fixed_string_t pfc_en;
3110 cmd_config_dcb_parsed(void *parsed_result,
3111 __attribute__((unused)) struct cmdline *cl,
3112 __attribute__((unused)) void *data)
3114 struct cmd_config_dcb *res = parsed_result;
3115 portid_t port_id = res->port_id;
3116 struct rte_port *port;
3120 port = &ports[port_id];
3121 /** Check if the port is not started **/
3122 if (port->port_status != RTE_PORT_STOPPED) {
3123 printf("Please stop port %d first\n", port_id);
3127 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3128 printf("The invalid number of traffic class,"
3129 " only 4 or 8 allowed.\n");
3133 if (nb_fwd_lcores < res->num_tcs) {
3134 printf("nb_cores shouldn't be less than number of TCs.\n");
3137 if (!strncmp(res->pfc_en, "on", 2))
3142 /* DCB in VT mode */
3143 if (!strncmp(res->vt_en, "on", 2))
3144 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3145 (enum rte_eth_nb_tcs)res->num_tcs,
3148 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3149 (enum rte_eth_nb_tcs)res->num_tcs,
3154 printf("Cannot initialize network ports.\n");
3158 cmd_reconfig_device_queue(port_id, 1, 1);
3161 cmdline_parse_token_string_t cmd_config_dcb_port =
3162 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3163 cmdline_parse_token_string_t cmd_config_dcb_config =
3164 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3165 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3166 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3167 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3168 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3169 cmdline_parse_token_string_t cmd_config_dcb_vt =
3170 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3171 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3172 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3173 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3174 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3175 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3176 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3177 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3178 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3180 cmdline_parse_inst_t cmd_config_dcb = {
3181 .f = cmd_config_dcb_parsed,
3183 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3185 (void *)&cmd_config_dcb_port,
3186 (void *)&cmd_config_dcb_config,
3187 (void *)&cmd_config_dcb_port_id,
3188 (void *)&cmd_config_dcb_dcb,
3189 (void *)&cmd_config_dcb_vt,
3190 (void *)&cmd_config_dcb_vt_en,
3191 (void *)&cmd_config_dcb_num_tcs,
3192 (void *)&cmd_config_dcb_pfc,
3193 (void *)&cmd_config_dcb_pfc_en,
3198 /* *** configure number of packets per burst *** */
3199 struct cmd_config_burst {
3200 cmdline_fixed_string_t port;
3201 cmdline_fixed_string_t keyword;
3202 cmdline_fixed_string_t all;
3203 cmdline_fixed_string_t name;
3208 cmd_config_burst_parsed(void *parsed_result,
3209 __attribute__((unused)) struct cmdline *cl,
3210 __attribute__((unused)) void *data)
3212 struct cmd_config_burst *res = parsed_result;
3213 struct rte_eth_dev_info dev_info;
3214 uint16_t rec_nb_pkts;
3217 if (!all_ports_stopped()) {
3218 printf("Please stop all ports first\n");
3222 if (!strcmp(res->name, "burst")) {
3223 if (res->value == 0) {
3224 /* If user gives a value of zero, query the PMD for
3225 * its recommended Rx burst size. Testpmd uses a single
3226 * size for all ports, so assume all ports are the same
3227 * NIC model and use the values from Port 0.
3229 ret = eth_dev_info_get_print_err(0, &dev_info);
3233 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3235 if (rec_nb_pkts == 0) {
3236 printf("PMD does not recommend a burst size.\n"
3237 "User provided value must be between"
3238 " 1 and %d\n", MAX_PKT_BURST);
3240 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3241 printf("PMD recommended burst size of %d"
3242 " exceeds maximum value of %d\n",
3243 rec_nb_pkts, MAX_PKT_BURST);
3246 printf("Using PMD-provided burst value of %d\n",
3248 nb_pkt_per_burst = rec_nb_pkts;
3249 } else if (res->value > MAX_PKT_BURST) {
3250 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3253 nb_pkt_per_burst = res->value;
3255 printf("Unknown parameter\n");
3261 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3264 cmdline_parse_token_string_t cmd_config_burst_port =
3265 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3266 cmdline_parse_token_string_t cmd_config_burst_keyword =
3267 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3268 cmdline_parse_token_string_t cmd_config_burst_all =
3269 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3270 cmdline_parse_token_string_t cmd_config_burst_name =
3271 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3272 cmdline_parse_token_num_t cmd_config_burst_value =
3273 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3275 cmdline_parse_inst_t cmd_config_burst = {
3276 .f = cmd_config_burst_parsed,
3278 .help_str = "port config all burst <value>",
3280 (void *)&cmd_config_burst_port,
3281 (void *)&cmd_config_burst_keyword,
3282 (void *)&cmd_config_burst_all,
3283 (void *)&cmd_config_burst_name,
3284 (void *)&cmd_config_burst_value,
3289 /* *** configure rx/tx queues *** */
3290 struct cmd_config_thresh {
3291 cmdline_fixed_string_t port;
3292 cmdline_fixed_string_t keyword;
3293 cmdline_fixed_string_t all;
3294 cmdline_fixed_string_t name;
3299 cmd_config_thresh_parsed(void *parsed_result,
3300 __attribute__((unused)) struct cmdline *cl,
3301 __attribute__((unused)) void *data)
3303 struct cmd_config_thresh *res = parsed_result;
3305 if (!all_ports_stopped()) {
3306 printf("Please stop all ports first\n");
3310 if (!strcmp(res->name, "txpt"))
3311 tx_pthresh = res->value;
3312 else if(!strcmp(res->name, "txht"))
3313 tx_hthresh = res->value;
3314 else if(!strcmp(res->name, "txwt"))
3315 tx_wthresh = res->value;
3316 else if(!strcmp(res->name, "rxpt"))
3317 rx_pthresh = res->value;
3318 else if(!strcmp(res->name, "rxht"))
3319 rx_hthresh = res->value;
3320 else if(!strcmp(res->name, "rxwt"))
3321 rx_wthresh = res->value;
3323 printf("Unknown parameter\n");
3329 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3332 cmdline_parse_token_string_t cmd_config_thresh_port =
3333 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3334 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3335 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3336 cmdline_parse_token_string_t cmd_config_thresh_all =
3337 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3338 cmdline_parse_token_string_t cmd_config_thresh_name =
3339 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3340 "txpt#txht#txwt#rxpt#rxht#rxwt");
3341 cmdline_parse_token_num_t cmd_config_thresh_value =
3342 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3344 cmdline_parse_inst_t cmd_config_thresh = {
3345 .f = cmd_config_thresh_parsed,
3347 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3349 (void *)&cmd_config_thresh_port,
3350 (void *)&cmd_config_thresh_keyword,
3351 (void *)&cmd_config_thresh_all,
3352 (void *)&cmd_config_thresh_name,
3353 (void *)&cmd_config_thresh_value,
3358 /* *** configure free/rs threshold *** */
3359 struct cmd_config_threshold {
3360 cmdline_fixed_string_t port;
3361 cmdline_fixed_string_t keyword;
3362 cmdline_fixed_string_t all;
3363 cmdline_fixed_string_t name;
3368 cmd_config_threshold_parsed(void *parsed_result,
3369 __attribute__((unused)) struct cmdline *cl,
3370 __attribute__((unused)) void *data)
3372 struct cmd_config_threshold *res = parsed_result;
3374 if (!all_ports_stopped()) {
3375 printf("Please stop all ports first\n");
3379 if (!strcmp(res->name, "txfreet"))
3380 tx_free_thresh = res->value;
3381 else if (!strcmp(res->name, "txrst"))
3382 tx_rs_thresh = res->value;
3383 else if (!strcmp(res->name, "rxfreet"))
3384 rx_free_thresh = res->value;
3386 printf("Unknown parameter\n");
3392 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3395 cmdline_parse_token_string_t cmd_config_threshold_port =
3396 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3397 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3398 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3400 cmdline_parse_token_string_t cmd_config_threshold_all =
3401 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3402 cmdline_parse_token_string_t cmd_config_threshold_name =
3403 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3404 "txfreet#txrst#rxfreet");
3405 cmdline_parse_token_num_t cmd_config_threshold_value =
3406 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3408 cmdline_parse_inst_t cmd_config_threshold = {
3409 .f = cmd_config_threshold_parsed,
3411 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3413 (void *)&cmd_config_threshold_port,
3414 (void *)&cmd_config_threshold_keyword,
3415 (void *)&cmd_config_threshold_all,
3416 (void *)&cmd_config_threshold_name,
3417 (void *)&cmd_config_threshold_value,
3423 struct cmd_stop_result {
3424 cmdline_fixed_string_t stop;
3427 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3428 __attribute__((unused)) struct cmdline *cl,
3429 __attribute__((unused)) void *data)
3431 stop_packet_forwarding();
3434 cmdline_parse_token_string_t cmd_stop_stop =
3435 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3437 cmdline_parse_inst_t cmd_stop = {
3438 .f = cmd_stop_parsed,
3440 .help_str = "stop: Stop packet forwarding",
3442 (void *)&cmd_stop_stop,
3447 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3450 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3451 unsigned int *parsed_items, int check_unique_values)
3453 unsigned int nb_item;
3461 * First parse all items in the list and store their value.
3466 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3468 if ((c >= '0') && (c <= '9')) {
3469 value = (unsigned int) (value * 10 + (c - '0'));
3474 printf("character %c is not a decimal digit\n", c);
3478 printf("No valid value before comma\n");
3481 if (nb_item < max_items) {
3482 parsed_items[nb_item] = value;
3488 if (nb_item >= max_items) {
3489 printf("Number of %s = %u > %u (maximum items)\n",
3490 item_name, nb_item + 1, max_items);
3493 parsed_items[nb_item++] = value;
3494 if (! check_unique_values)
3498 * Then, check that all values in the list are differents.
3499 * No optimization here...
3501 for (i = 0; i < nb_item; i++) {
3502 for (j = i + 1; j < nb_item; j++) {
3503 if (parsed_items[j] == parsed_items[i]) {
3504 printf("duplicated %s %u at index %u and %u\n",
3505 item_name, parsed_items[i], i, j);
3513 struct cmd_set_list_result {
3514 cmdline_fixed_string_t cmd_keyword;
3515 cmdline_fixed_string_t list_name;
3516 cmdline_fixed_string_t list_of_items;
3519 static void cmd_set_list_parsed(void *parsed_result,
3520 __attribute__((unused)) struct cmdline *cl,
3521 __attribute__((unused)) void *data)
3523 struct cmd_set_list_result *res;
3525 unsigned int lcorelist[RTE_MAX_LCORE];
3526 unsigned int portlist[RTE_MAX_ETHPORTS];
3528 unsigned int nb_item;
3530 if (test_done == 0) {
3531 printf("Please stop forwarding first\n");
3535 res = parsed_result;
3536 if (!strcmp(res->list_name, "corelist")) {
3537 nb_item = parse_item_list(res->list_of_items, "core",
3539 parsed_items.lcorelist, 1);
3541 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3546 if (!strcmp(res->list_name, "portlist")) {
3547 nb_item = parse_item_list(res->list_of_items, "port",
3549 parsed_items.portlist, 1);
3551 set_fwd_ports_list(parsed_items.portlist, nb_item);
3557 cmdline_parse_token_string_t cmd_set_list_keyword =
3558 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3560 cmdline_parse_token_string_t cmd_set_list_name =
3561 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3562 "corelist#portlist");
3563 cmdline_parse_token_string_t cmd_set_list_of_items =
3564 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3567 cmdline_parse_inst_t cmd_set_fwd_list = {
3568 .f = cmd_set_list_parsed,
3570 .help_str = "set corelist|portlist <list0[,list1]*>",
3572 (void *)&cmd_set_list_keyword,
3573 (void *)&cmd_set_list_name,
3574 (void *)&cmd_set_list_of_items,
3579 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3581 struct cmd_setmask_result {
3582 cmdline_fixed_string_t set;
3583 cmdline_fixed_string_t mask;
3587 static void cmd_set_mask_parsed(void *parsed_result,
3588 __attribute__((unused)) struct cmdline *cl,
3589 __attribute__((unused)) void *data)
3591 struct cmd_setmask_result *res = parsed_result;
3593 if (test_done == 0) {
3594 printf("Please stop forwarding first\n");
3597 if (!strcmp(res->mask, "coremask")) {
3598 set_fwd_lcores_mask(res->hexavalue);
3600 } else if (!strcmp(res->mask, "portmask")) {
3601 set_fwd_ports_mask(res->hexavalue);
3606 cmdline_parse_token_string_t cmd_setmask_set =
3607 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3608 cmdline_parse_token_string_t cmd_setmask_mask =
3609 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3610 "coremask#portmask");
3611 cmdline_parse_token_num_t cmd_setmask_value =
3612 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3614 cmdline_parse_inst_t cmd_set_fwd_mask = {
3615 .f = cmd_set_mask_parsed,
3617 .help_str = "set coremask|portmask <hexadecimal value>",
3619 (void *)&cmd_setmask_set,
3620 (void *)&cmd_setmask_mask,
3621 (void *)&cmd_setmask_value,
3627 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3629 struct cmd_set_result {
3630 cmdline_fixed_string_t set;
3631 cmdline_fixed_string_t what;
3635 static void cmd_set_parsed(void *parsed_result,
3636 __attribute__((unused)) struct cmdline *cl,
3637 __attribute__((unused)) void *data)
3639 struct cmd_set_result *res = parsed_result;
3640 if (!strcmp(res->what, "nbport")) {
3641 set_fwd_ports_number(res->value);
3643 } else if (!strcmp(res->what, "nbcore")) {
3644 set_fwd_lcores_number(res->value);
3646 } else if (!strcmp(res->what, "burst"))
3647 set_nb_pkt_per_burst(res->value);
3648 else if (!strcmp(res->what, "verbose"))
3649 set_verbose_level(res->value);
3652 cmdline_parse_token_string_t cmd_set_set =
3653 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3654 cmdline_parse_token_string_t cmd_set_what =
3655 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3656 "nbport#nbcore#burst#verbose");
3657 cmdline_parse_token_num_t cmd_set_value =
3658 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3660 cmdline_parse_inst_t cmd_set_numbers = {
3661 .f = cmd_set_parsed,
3663 .help_str = "set nbport|nbcore|burst|verbose <value>",
3665 (void *)&cmd_set_set,
3666 (void *)&cmd_set_what,
3667 (void *)&cmd_set_value,
3672 /* *** SET LOG LEVEL CONFIGURATION *** */
3674 struct cmd_set_log_result {
3675 cmdline_fixed_string_t set;
3676 cmdline_fixed_string_t log;
3677 cmdline_fixed_string_t type;
3682 cmd_set_log_parsed(void *parsed_result,
3683 __attribute__((unused)) struct cmdline *cl,
3684 __attribute__((unused)) void *data)
3686 struct cmd_set_log_result *res;
3689 res = parsed_result;
3690 if (!strcmp(res->type, "global"))
3691 rte_log_set_global_level(res->level);
3693 ret = rte_log_set_level_regexp(res->type, res->level);
3695 printf("Unable to set log level\n");
3699 cmdline_parse_token_string_t cmd_set_log_set =
3700 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3701 cmdline_parse_token_string_t cmd_set_log_log =
3702 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3703 cmdline_parse_token_string_t cmd_set_log_type =
3704 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3705 cmdline_parse_token_num_t cmd_set_log_level =
3706 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3708 cmdline_parse_inst_t cmd_set_log = {
3709 .f = cmd_set_log_parsed,
3711 .help_str = "set log global|<type> <level>",
3713 (void *)&cmd_set_log_set,
3714 (void *)&cmd_set_log_log,
3715 (void *)&cmd_set_log_type,
3716 (void *)&cmd_set_log_level,
3721 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3723 struct cmd_set_txpkts_result {
3724 cmdline_fixed_string_t cmd_keyword;
3725 cmdline_fixed_string_t txpkts;
3726 cmdline_fixed_string_t seg_lengths;
3730 cmd_set_txpkts_parsed(void *parsed_result,
3731 __attribute__((unused)) struct cmdline *cl,
3732 __attribute__((unused)) void *data)
3734 struct cmd_set_txpkts_result *res;
3735 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3736 unsigned int nb_segs;
3738 res = parsed_result;
3739 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3740 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3742 set_tx_pkt_segments(seg_lengths, nb_segs);
3745 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3746 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3747 cmd_keyword, "set");
3748 cmdline_parse_token_string_t cmd_set_txpkts_name =
3749 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3751 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3752 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3755 cmdline_parse_inst_t cmd_set_txpkts = {
3756 .f = cmd_set_txpkts_parsed,
3758 .help_str = "set txpkts <len0[,len1]*>",
3760 (void *)&cmd_set_txpkts_keyword,
3761 (void *)&cmd_set_txpkts_name,
3762 (void *)&cmd_set_txpkts_lengths,
3767 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3769 struct cmd_set_txsplit_result {
3770 cmdline_fixed_string_t cmd_keyword;
3771 cmdline_fixed_string_t txsplit;
3772 cmdline_fixed_string_t mode;
3776 cmd_set_txsplit_parsed(void *parsed_result,
3777 __attribute__((unused)) struct cmdline *cl,
3778 __attribute__((unused)) void *data)
3780 struct cmd_set_txsplit_result *res;
3782 res = parsed_result;
3783 set_tx_pkt_split(res->mode);
3786 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3787 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3788 cmd_keyword, "set");
3789 cmdline_parse_token_string_t cmd_set_txsplit_name =
3790 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3791 txsplit, "txsplit");
3792 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3793 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3796 cmdline_parse_inst_t cmd_set_txsplit = {
3797 .f = cmd_set_txsplit_parsed,
3799 .help_str = "set txsplit on|off|rand",
3801 (void *)&cmd_set_txsplit_keyword,
3802 (void *)&cmd_set_txsplit_name,
3803 (void *)&cmd_set_txsplit_mode,
3808 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3809 struct cmd_rx_vlan_filter_all_result {
3810 cmdline_fixed_string_t rx_vlan;
3811 cmdline_fixed_string_t what;
3812 cmdline_fixed_string_t all;
3817 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3818 __attribute__((unused)) struct cmdline *cl,
3819 __attribute__((unused)) void *data)
3821 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3823 if (!strcmp(res->what, "add"))
3824 rx_vlan_all_filter_set(res->port_id, 1);
3826 rx_vlan_all_filter_set(res->port_id, 0);
3829 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3830 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3831 rx_vlan, "rx_vlan");
3832 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3833 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3835 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3836 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3838 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3839 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3842 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3843 .f = cmd_rx_vlan_filter_all_parsed,
3845 .help_str = "rx_vlan add|rm all <port_id>: "
3846 "Add/Remove all identifiers to/from the set of VLAN "
3847 "identifiers filtered by a port",
3849 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3850 (void *)&cmd_rx_vlan_filter_all_what,
3851 (void *)&cmd_rx_vlan_filter_all_all,
3852 (void *)&cmd_rx_vlan_filter_all_portid,
3857 /* *** VLAN OFFLOAD SET ON A PORT *** */
3858 struct cmd_vlan_offload_result {
3859 cmdline_fixed_string_t vlan;
3860 cmdline_fixed_string_t set;
3861 cmdline_fixed_string_t vlan_type;
3862 cmdline_fixed_string_t what;
3863 cmdline_fixed_string_t on;
3864 cmdline_fixed_string_t port_id;
3868 cmd_vlan_offload_parsed(void *parsed_result,
3869 __attribute__((unused)) struct cmdline *cl,
3870 __attribute__((unused)) void *data)
3873 struct cmd_vlan_offload_result *res = parsed_result;
3876 portid_t port_id = 0;
3880 len = strnlen(str, STR_TOKEN_SIZE);
3882 /* Get port_id first */
3890 tmp = strtoul(str, NULL, 0);
3891 /* If port_id greater that what portid_t can represent, return */
3892 if(tmp >= RTE_MAX_ETHPORTS)
3894 port_id = (portid_t)tmp;
3896 if (!strcmp(res->on, "on"))
3901 if (!strcmp(res->what, "strip"))
3902 rx_vlan_strip_set(port_id, on);
3903 else if(!strcmp(res->what, "stripq")){
3904 uint16_t queue_id = 0;
3906 /* No queue_id, return */
3908 printf("must specify (port,queue_id)\n");
3911 tmp = strtoul(str + i + 1, NULL, 0);
3912 /* If queue_id greater that what 16-bits can represent, return */
3916 queue_id = (uint16_t)tmp;
3917 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3919 else if (!strcmp(res->what, "filter"))
3920 rx_vlan_filter_set(port_id, on);
3922 vlan_extend_set(port_id, on);
3927 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3928 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3930 cmdline_parse_token_string_t cmd_vlan_offload_set =
3931 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3933 cmdline_parse_token_string_t cmd_vlan_offload_what =
3934 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3935 what, "strip#filter#qinq#stripq");
3936 cmdline_parse_token_string_t cmd_vlan_offload_on =
3937 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3939 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3940 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3943 cmdline_parse_inst_t cmd_vlan_offload = {
3944 .f = cmd_vlan_offload_parsed,
3946 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3947 "<port_id[,queue_id]>: "
3948 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3950 (void *)&cmd_vlan_offload_vlan,
3951 (void *)&cmd_vlan_offload_set,
3952 (void *)&cmd_vlan_offload_what,
3953 (void *)&cmd_vlan_offload_on,
3954 (void *)&cmd_vlan_offload_portid,
3959 /* *** VLAN TPID SET ON A PORT *** */
3960 struct cmd_vlan_tpid_result {
3961 cmdline_fixed_string_t vlan;
3962 cmdline_fixed_string_t set;
3963 cmdline_fixed_string_t vlan_type;
3964 cmdline_fixed_string_t what;
3970 cmd_vlan_tpid_parsed(void *parsed_result,
3971 __attribute__((unused)) struct cmdline *cl,
3972 __attribute__((unused)) void *data)
3974 struct cmd_vlan_tpid_result *res = parsed_result;
3975 enum rte_vlan_type vlan_type;
3977 if (!strcmp(res->vlan_type, "inner"))
3978 vlan_type = ETH_VLAN_TYPE_INNER;
3979 else if (!strcmp(res->vlan_type, "outer"))
3980 vlan_type = ETH_VLAN_TYPE_OUTER;
3982 printf("Unknown vlan type\n");
3985 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3988 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3989 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3991 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3992 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3994 cmdline_parse_token_string_t cmd_vlan_type =
3995 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3996 vlan_type, "inner#outer");
3997 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3998 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4000 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4001 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4003 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4004 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4007 cmdline_parse_inst_t cmd_vlan_tpid = {
4008 .f = cmd_vlan_tpid_parsed,
4010 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4011 "Set the VLAN Ether type",
4013 (void *)&cmd_vlan_tpid_vlan,
4014 (void *)&cmd_vlan_tpid_set,
4015 (void *)&cmd_vlan_type,
4016 (void *)&cmd_vlan_tpid_what,
4017 (void *)&cmd_vlan_tpid_tpid,
4018 (void *)&cmd_vlan_tpid_portid,
4023 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4024 struct cmd_rx_vlan_filter_result {
4025 cmdline_fixed_string_t rx_vlan;
4026 cmdline_fixed_string_t what;
4032 cmd_rx_vlan_filter_parsed(void *parsed_result,
4033 __attribute__((unused)) struct cmdline *cl,
4034 __attribute__((unused)) void *data)
4036 struct cmd_rx_vlan_filter_result *res = parsed_result;
4038 if (!strcmp(res->what, "add"))
4039 rx_vft_set(res->port_id, res->vlan_id, 1);
4041 rx_vft_set(res->port_id, res->vlan_id, 0);
4044 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4045 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4046 rx_vlan, "rx_vlan");
4047 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4048 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4050 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4051 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4053 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4054 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4057 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4058 .f = cmd_rx_vlan_filter_parsed,
4060 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4061 "Add/Remove a VLAN identifier to/from the set of VLAN "
4062 "identifiers filtered by a port",
4064 (void *)&cmd_rx_vlan_filter_rx_vlan,
4065 (void *)&cmd_rx_vlan_filter_what,
4066 (void *)&cmd_rx_vlan_filter_vlanid,
4067 (void *)&cmd_rx_vlan_filter_portid,
4072 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4073 struct cmd_tx_vlan_set_result {
4074 cmdline_fixed_string_t tx_vlan;
4075 cmdline_fixed_string_t set;
4081 cmd_tx_vlan_set_parsed(void *parsed_result,
4082 __attribute__((unused)) struct cmdline *cl,
4083 __attribute__((unused)) void *data)
4085 struct cmd_tx_vlan_set_result *res = parsed_result;
4087 if (!port_is_stopped(res->port_id)) {
4088 printf("Please stop port %d first\n", res->port_id);
4092 tx_vlan_set(res->port_id, res->vlan_id);
4094 cmd_reconfig_device_queue(res->port_id, 1, 1);
4097 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4098 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4099 tx_vlan, "tx_vlan");
4100 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4101 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4103 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4104 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4106 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4107 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4110 cmdline_parse_inst_t cmd_tx_vlan_set = {
4111 .f = cmd_tx_vlan_set_parsed,
4113 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4114 "Enable hardware insertion of a single VLAN header "
4115 "with a given TAG Identifier in packets sent on a port",
4117 (void *)&cmd_tx_vlan_set_tx_vlan,
4118 (void *)&cmd_tx_vlan_set_set,
4119 (void *)&cmd_tx_vlan_set_portid,
4120 (void *)&cmd_tx_vlan_set_vlanid,
4125 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4126 struct cmd_tx_vlan_set_qinq_result {
4127 cmdline_fixed_string_t tx_vlan;
4128 cmdline_fixed_string_t set;
4131 uint16_t vlan_id_outer;
4135 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4136 __attribute__((unused)) struct cmdline *cl,
4137 __attribute__((unused)) void *data)
4139 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4141 if (!port_is_stopped(res->port_id)) {
4142 printf("Please stop port %d first\n", res->port_id);
4146 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4148 cmd_reconfig_device_queue(res->port_id, 1, 1);
4151 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4152 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4153 tx_vlan, "tx_vlan");
4154 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4155 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4157 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4158 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4160 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4161 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4163 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4164 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4165 vlan_id_outer, UINT16);
4167 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4168 .f = cmd_tx_vlan_set_qinq_parsed,
4170 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4171 "Enable hardware insertion of double VLAN header "
4172 "with given TAG Identifiers in packets sent on a port",
4174 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4175 (void *)&cmd_tx_vlan_set_qinq_set,
4176 (void *)&cmd_tx_vlan_set_qinq_portid,
4177 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4178 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4183 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4184 struct cmd_tx_vlan_set_pvid_result {
4185 cmdline_fixed_string_t tx_vlan;
4186 cmdline_fixed_string_t set;
4187 cmdline_fixed_string_t pvid;
4190 cmdline_fixed_string_t mode;
4194 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4195 __attribute__((unused)) struct cmdline *cl,
4196 __attribute__((unused)) void *data)
4198 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4200 if (strcmp(res->mode, "on") == 0)
4201 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4203 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4206 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4207 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4208 tx_vlan, "tx_vlan");
4209 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4210 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4212 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4213 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4215 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4216 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4218 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4219 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4221 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4222 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4225 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4226 .f = cmd_tx_vlan_set_pvid_parsed,
4228 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4230 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4231 (void *)&cmd_tx_vlan_set_pvid_set,
4232 (void *)&cmd_tx_vlan_set_pvid_pvid,
4233 (void *)&cmd_tx_vlan_set_pvid_port_id,
4234 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4235 (void *)&cmd_tx_vlan_set_pvid_mode,
4240 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4241 struct cmd_tx_vlan_reset_result {
4242 cmdline_fixed_string_t tx_vlan;
4243 cmdline_fixed_string_t reset;
4248 cmd_tx_vlan_reset_parsed(void *parsed_result,
4249 __attribute__((unused)) struct cmdline *cl,
4250 __attribute__((unused)) void *data)
4252 struct cmd_tx_vlan_reset_result *res = parsed_result;
4254 if (!port_is_stopped(res->port_id)) {
4255 printf("Please stop port %d first\n", res->port_id);
4259 tx_vlan_reset(res->port_id);
4261 cmd_reconfig_device_queue(res->port_id, 1, 1);
4264 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4265 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4266 tx_vlan, "tx_vlan");
4267 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4268 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4270 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4271 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4274 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4275 .f = cmd_tx_vlan_reset_parsed,
4277 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4278 "VLAN header in packets sent on a port",
4280 (void *)&cmd_tx_vlan_reset_tx_vlan,
4281 (void *)&cmd_tx_vlan_reset_reset,
4282 (void *)&cmd_tx_vlan_reset_portid,
4288 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4289 struct cmd_csum_result {
4290 cmdline_fixed_string_t csum;
4291 cmdline_fixed_string_t mode;
4292 cmdline_fixed_string_t proto;
4293 cmdline_fixed_string_t hwsw;
4298 csum_show(int port_id)
4300 struct rte_eth_dev_info dev_info;
4301 uint64_t tx_offloads;
4304 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4305 printf("Parse tunnel is %s\n",
4306 (ports[port_id].parse_tunnel) ? "on" : "off");
4307 printf("IP checksum offload is %s\n",
4308 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4309 printf("UDP checksum offload is %s\n",
4310 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4311 printf("TCP checksum offload is %s\n",
4312 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4313 printf("SCTP checksum offload is %s\n",
4314 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4315 printf("Outer-Ip checksum offload is %s\n",
4316 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4317 printf("Outer-Udp checksum offload is %s\n",
4318 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4320 /* display warnings if configuration is not supported by the NIC */
4321 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4325 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4326 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4327 printf("Warning: hardware IP checksum enabled but not "
4328 "supported by port %d\n", port_id);
4330 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4331 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4332 printf("Warning: hardware UDP checksum enabled but not "
4333 "supported by port %d\n", port_id);
4335 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4336 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4337 printf("Warning: hardware TCP checksum enabled but not "
4338 "supported by port %d\n", port_id);
4340 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4341 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4342 printf("Warning: hardware SCTP checksum enabled but not "
4343 "supported by port %d\n", port_id);
4345 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4346 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4347 printf("Warning: hardware outer IP checksum enabled but not "
4348 "supported by port %d\n", port_id);
4350 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4351 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4353 printf("Warning: hardware outer UDP checksum enabled but not "
4354 "supported by port %d\n", port_id);
4359 cmd_config_queue_tx_offloads(struct rte_port *port)
4363 /* Apply queue tx offloads configuration */
4364 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4365 port->tx_conf[k].offloads =
4366 port->dev_conf.txmode.offloads;
4370 cmd_csum_parsed(void *parsed_result,
4371 __attribute__((unused)) struct cmdline *cl,
4372 __attribute__((unused)) void *data)
4374 struct cmd_csum_result *res = parsed_result;
4376 uint64_t csum_offloads = 0;
4377 struct rte_eth_dev_info dev_info;
4380 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4381 printf("invalid port %d\n", res->port_id);
4384 if (!port_is_stopped(res->port_id)) {
4385 printf("Please stop port %d first\n", res->port_id);
4389 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4393 if (!strcmp(res->mode, "set")) {
4395 if (!strcmp(res->hwsw, "hw"))
4398 if (!strcmp(res->proto, "ip")) {
4399 if (hw == 0 || (dev_info.tx_offload_capa &
4400 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4401 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4403 printf("IP checksum offload is not supported "
4404 "by port %u\n", res->port_id);
4406 } else if (!strcmp(res->proto, "udp")) {
4407 if (hw == 0 || (dev_info.tx_offload_capa &
4408 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4409 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4411 printf("UDP checksum offload is not supported "
4412 "by port %u\n", res->port_id);
4414 } else if (!strcmp(res->proto, "tcp")) {
4415 if (hw == 0 || (dev_info.tx_offload_capa &
4416 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4417 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4419 printf("TCP checksum offload is not supported "
4420 "by port %u\n", res->port_id);
4422 } else if (!strcmp(res->proto, "sctp")) {
4423 if (hw == 0 || (dev_info.tx_offload_capa &
4424 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4425 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4427 printf("SCTP checksum offload is not supported "
4428 "by port %u\n", res->port_id);
4430 } else if (!strcmp(res->proto, "outer-ip")) {
4431 if (hw == 0 || (dev_info.tx_offload_capa &
4432 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4434 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4436 printf("Outer IP checksum offload is not "
4437 "supported by port %u\n", res->port_id);
4439 } else if (!strcmp(res->proto, "outer-udp")) {
4440 if (hw == 0 || (dev_info.tx_offload_capa &
4441 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4443 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4445 printf("Outer UDP checksum offload is not "
4446 "supported by port %u\n", res->port_id);
4451 ports[res->port_id].dev_conf.txmode.offloads |=
4454 ports[res->port_id].dev_conf.txmode.offloads &=
4457 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4459 csum_show(res->port_id);
4461 cmd_reconfig_device_queue(res->port_id, 1, 1);
4464 cmdline_parse_token_string_t cmd_csum_csum =
4465 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4467 cmdline_parse_token_string_t cmd_csum_mode =
4468 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4470 cmdline_parse_token_string_t cmd_csum_proto =
4471 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4472 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4473 cmdline_parse_token_string_t cmd_csum_hwsw =
4474 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4476 cmdline_parse_token_num_t cmd_csum_portid =
4477 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4480 cmdline_parse_inst_t cmd_csum_set = {
4481 .f = cmd_csum_parsed,
4483 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4484 "Enable/Disable hardware calculation of L3/L4 checksum when "
4485 "using csum forward engine",
4487 (void *)&cmd_csum_csum,
4488 (void *)&cmd_csum_mode,
4489 (void *)&cmd_csum_proto,
4490 (void *)&cmd_csum_hwsw,
4491 (void *)&cmd_csum_portid,
4496 cmdline_parse_token_string_t cmd_csum_mode_show =
4497 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4500 cmdline_parse_inst_t cmd_csum_show = {
4501 .f = cmd_csum_parsed,
4503 .help_str = "csum show <port_id>: Show checksum offload configuration",
4505 (void *)&cmd_csum_csum,
4506 (void *)&cmd_csum_mode_show,
4507 (void *)&cmd_csum_portid,
4512 /* Enable/disable tunnel parsing */
4513 struct cmd_csum_tunnel_result {
4514 cmdline_fixed_string_t csum;
4515 cmdline_fixed_string_t parse;
4516 cmdline_fixed_string_t onoff;
4521 cmd_csum_tunnel_parsed(void *parsed_result,
4522 __attribute__((unused)) struct cmdline *cl,
4523 __attribute__((unused)) void *data)
4525 struct cmd_csum_tunnel_result *res = parsed_result;
4527 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4530 if (!strcmp(res->onoff, "on"))
4531 ports[res->port_id].parse_tunnel = 1;
4533 ports[res->port_id].parse_tunnel = 0;
4535 csum_show(res->port_id);
4538 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4539 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4541 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4542 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4543 parse, "parse-tunnel");
4544 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4545 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4547 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4548 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4551 cmdline_parse_inst_t cmd_csum_tunnel = {
4552 .f = cmd_csum_tunnel_parsed,
4554 .help_str = "csum parse-tunnel on|off <port_id>: "
4555 "Enable/Disable parsing of tunnels for csum engine",
4557 (void *)&cmd_csum_tunnel_csum,
4558 (void *)&cmd_csum_tunnel_parse,
4559 (void *)&cmd_csum_tunnel_onoff,
4560 (void *)&cmd_csum_tunnel_portid,
4565 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4566 struct cmd_tso_set_result {
4567 cmdline_fixed_string_t tso;
4568 cmdline_fixed_string_t mode;
4574 cmd_tso_set_parsed(void *parsed_result,
4575 __attribute__((unused)) struct cmdline *cl,
4576 __attribute__((unused)) void *data)
4578 struct cmd_tso_set_result *res = parsed_result;
4579 struct rte_eth_dev_info dev_info;
4582 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4584 if (!port_is_stopped(res->port_id)) {
4585 printf("Please stop port %d first\n", res->port_id);
4589 if (!strcmp(res->mode, "set"))
4590 ports[res->port_id].tso_segsz = res->tso_segsz;
4592 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4596 if ((ports[res->port_id].tso_segsz != 0) &&
4597 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4598 printf("Error: TSO is not supported by port %d\n",
4603 if (ports[res->port_id].tso_segsz == 0) {
4604 ports[res->port_id].dev_conf.txmode.offloads &=
4605 ~DEV_TX_OFFLOAD_TCP_TSO;
4606 printf("TSO for non-tunneled packets is disabled\n");
4608 ports[res->port_id].dev_conf.txmode.offloads |=
4609 DEV_TX_OFFLOAD_TCP_TSO;
4610 printf("TSO segment size for non-tunneled packets is %d\n",
4611 ports[res->port_id].tso_segsz);
4613 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4615 /* display warnings if configuration is not supported by the NIC */
4616 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4620 if ((ports[res->port_id].tso_segsz != 0) &&
4621 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4622 printf("Warning: TSO enabled but not "
4623 "supported by port %d\n", res->port_id);
4626 cmd_reconfig_device_queue(res->port_id, 1, 1);
4629 cmdline_parse_token_string_t cmd_tso_set_tso =
4630 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4632 cmdline_parse_token_string_t cmd_tso_set_mode =
4633 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4635 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4636 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4638 cmdline_parse_token_num_t cmd_tso_set_portid =
4639 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4642 cmdline_parse_inst_t cmd_tso_set = {
4643 .f = cmd_tso_set_parsed,
4645 .help_str = "tso set <tso_segsz> <port_id>: "
4646 "Set TSO segment size of non-tunneled packets for csum engine "
4649 (void *)&cmd_tso_set_tso,
4650 (void *)&cmd_tso_set_mode,
4651 (void *)&cmd_tso_set_tso_segsz,
4652 (void *)&cmd_tso_set_portid,
4657 cmdline_parse_token_string_t cmd_tso_show_mode =
4658 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4662 cmdline_parse_inst_t cmd_tso_show = {
4663 .f = cmd_tso_set_parsed,
4665 .help_str = "tso show <port_id>: "
4666 "Show TSO segment size of non-tunneled packets for csum engine",
4668 (void *)&cmd_tso_set_tso,
4669 (void *)&cmd_tso_show_mode,
4670 (void *)&cmd_tso_set_portid,
4675 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4676 struct cmd_tunnel_tso_set_result {
4677 cmdline_fixed_string_t tso;
4678 cmdline_fixed_string_t mode;
4683 static struct rte_eth_dev_info
4684 check_tunnel_tso_nic_support(portid_t port_id)
4686 struct rte_eth_dev_info dev_info;
4688 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4691 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4692 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4693 "not enabled for port %d\n", port_id);
4694 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4695 printf("Warning: GRE TUNNEL TSO not supported therefore "
4696 "not enabled for port %d\n", port_id);
4697 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4698 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4699 "not enabled for port %d\n", port_id);
4700 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4701 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4702 "not enabled for port %d\n", port_id);
4703 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4704 printf("Warning: IP TUNNEL TSO not supported therefore "
4705 "not enabled for port %d\n", port_id);
4706 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4707 printf("Warning: UDP TUNNEL TSO not supported therefore "
4708 "not enabled for port %d\n", port_id);
4713 cmd_tunnel_tso_set_parsed(void *parsed_result,
4714 __attribute__((unused)) struct cmdline *cl,
4715 __attribute__((unused)) void *data)
4717 struct cmd_tunnel_tso_set_result *res = parsed_result;
4718 struct rte_eth_dev_info dev_info;
4720 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4722 if (!port_is_stopped(res->port_id)) {
4723 printf("Please stop port %d first\n", res->port_id);
4727 if (!strcmp(res->mode, "set"))
4728 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4730 dev_info = check_tunnel_tso_nic_support(res->port_id);
4731 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4732 ports[res->port_id].dev_conf.txmode.offloads &=
4733 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4734 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4735 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4736 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4737 DEV_TX_OFFLOAD_IP_TNL_TSO |
4738 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4739 printf("TSO for tunneled packets is disabled\n");
4741 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4742 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4743 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4744 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4745 DEV_TX_OFFLOAD_IP_TNL_TSO |
4746 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4748 ports[res->port_id].dev_conf.txmode.offloads |=
4749 (tso_offloads & dev_info.tx_offload_capa);
4750 printf("TSO segment size for tunneled packets is %d\n",
4751 ports[res->port_id].tunnel_tso_segsz);
4753 /* Below conditions are needed to make it work:
4754 * (1) tunnel TSO is supported by the NIC;
4755 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4757 * (3) for tunneled pkts with outer L3 of IPv4,
4758 * "csum set outer-ip" must be set to hw, because after tso,
4759 * total_len of outer IP header is changed, and the checksum
4760 * of outer IP header calculated by sw should be wrong; that
4761 * is not necessary for IPv6 tunneled pkts because there's no
4762 * checksum in IP header anymore.
4765 if (!ports[res->port_id].parse_tunnel)
4766 printf("Warning: csum parse_tunnel must be set "
4767 "so that tunneled packets are recognized\n");
4768 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4769 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4770 printf("Warning: csum set outer-ip must be set to hw "
4771 "if outer L3 is IPv4; not necessary for IPv6\n");
4774 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4775 cmd_reconfig_device_queue(res->port_id, 1, 1);
4778 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4779 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4781 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4782 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4784 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4785 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4787 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4788 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4791 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4792 .f = cmd_tunnel_tso_set_parsed,
4794 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4795 "Set TSO segment size of tunneled packets for csum engine "
4798 (void *)&cmd_tunnel_tso_set_tso,
4799 (void *)&cmd_tunnel_tso_set_mode,
4800 (void *)&cmd_tunnel_tso_set_tso_segsz,
4801 (void *)&cmd_tunnel_tso_set_portid,
4806 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4807 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4811 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4812 .f = cmd_tunnel_tso_set_parsed,
4814 .help_str = "tunnel_tso show <port_id> "
4815 "Show TSO segment size of tunneled packets for csum engine",
4817 (void *)&cmd_tunnel_tso_set_tso,
4818 (void *)&cmd_tunnel_tso_show_mode,
4819 (void *)&cmd_tunnel_tso_set_portid,
4824 /* *** SET GRO FOR A PORT *** */
4825 struct cmd_gro_enable_result {
4826 cmdline_fixed_string_t cmd_set;
4827 cmdline_fixed_string_t cmd_port;
4828 cmdline_fixed_string_t cmd_keyword;
4829 cmdline_fixed_string_t cmd_onoff;
4834 cmd_gro_enable_parsed(void *parsed_result,
4835 __attribute__((unused)) struct cmdline *cl,
4836 __attribute__((unused)) void *data)
4838 struct cmd_gro_enable_result *res;
4840 res = parsed_result;
4841 if (!strcmp(res->cmd_keyword, "gro"))
4842 setup_gro(res->cmd_onoff, res->cmd_pid);
4845 cmdline_parse_token_string_t cmd_gro_enable_set =
4846 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4848 cmdline_parse_token_string_t cmd_gro_enable_port =
4849 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4850 cmd_keyword, "port");
4851 cmdline_parse_token_num_t cmd_gro_enable_pid =
4852 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4854 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4855 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4856 cmd_keyword, "gro");
4857 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4858 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4859 cmd_onoff, "on#off");
4861 cmdline_parse_inst_t cmd_gro_enable = {
4862 .f = cmd_gro_enable_parsed,
4864 .help_str = "set port <port_id> gro on|off",
4866 (void *)&cmd_gro_enable_set,
4867 (void *)&cmd_gro_enable_port,
4868 (void *)&cmd_gro_enable_pid,
4869 (void *)&cmd_gro_enable_keyword,
4870 (void *)&cmd_gro_enable_onoff,
4875 /* *** DISPLAY GRO CONFIGURATION *** */
4876 struct cmd_gro_show_result {
4877 cmdline_fixed_string_t cmd_show;
4878 cmdline_fixed_string_t cmd_port;
4879 cmdline_fixed_string_t cmd_keyword;
4884 cmd_gro_show_parsed(void *parsed_result,
4885 __attribute__((unused)) struct cmdline *cl,
4886 __attribute__((unused)) void *data)
4888 struct cmd_gro_show_result *res;
4890 res = parsed_result;
4891 if (!strcmp(res->cmd_keyword, "gro"))
4892 show_gro(res->cmd_pid);
4895 cmdline_parse_token_string_t cmd_gro_show_show =
4896 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4898 cmdline_parse_token_string_t cmd_gro_show_port =
4899 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4901 cmdline_parse_token_num_t cmd_gro_show_pid =
4902 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4904 cmdline_parse_token_string_t cmd_gro_show_keyword =
4905 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4906 cmd_keyword, "gro");
4908 cmdline_parse_inst_t cmd_gro_show = {
4909 .f = cmd_gro_show_parsed,
4911 .help_str = "show port <port_id> gro",
4913 (void *)&cmd_gro_show_show,
4914 (void *)&cmd_gro_show_port,
4915 (void *)&cmd_gro_show_pid,
4916 (void *)&cmd_gro_show_keyword,
4921 /* *** SET FLUSH CYCLES FOR GRO *** */
4922 struct cmd_gro_flush_result {
4923 cmdline_fixed_string_t cmd_set;
4924 cmdline_fixed_string_t cmd_keyword;
4925 cmdline_fixed_string_t cmd_flush;
4930 cmd_gro_flush_parsed(void *parsed_result,
4931 __attribute__((unused)) struct cmdline *cl,
4932 __attribute__((unused)) void *data)
4934 struct cmd_gro_flush_result *res;
4936 res = parsed_result;
4937 if ((!strcmp(res->cmd_keyword, "gro")) &&
4938 (!strcmp(res->cmd_flush, "flush")))
4939 setup_gro_flush_cycles(res->cmd_cycles);
4942 cmdline_parse_token_string_t cmd_gro_flush_set =
4943 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4945 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4946 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4947 cmd_keyword, "gro");
4948 cmdline_parse_token_string_t cmd_gro_flush_flush =
4949 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4950 cmd_flush, "flush");
4951 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4952 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4955 cmdline_parse_inst_t cmd_gro_flush = {
4956 .f = cmd_gro_flush_parsed,
4958 .help_str = "set gro flush <cycles>",
4960 (void *)&cmd_gro_flush_set,
4961 (void *)&cmd_gro_flush_keyword,
4962 (void *)&cmd_gro_flush_flush,
4963 (void *)&cmd_gro_flush_cycles,
4968 /* *** ENABLE/DISABLE GSO *** */
4969 struct cmd_gso_enable_result {
4970 cmdline_fixed_string_t cmd_set;
4971 cmdline_fixed_string_t cmd_port;
4972 cmdline_fixed_string_t cmd_keyword;
4973 cmdline_fixed_string_t cmd_mode;
4978 cmd_gso_enable_parsed(void *parsed_result,
4979 __attribute__((unused)) struct cmdline *cl,
4980 __attribute__((unused)) void *data)
4982 struct cmd_gso_enable_result *res;
4984 res = parsed_result;
4985 if (!strcmp(res->cmd_keyword, "gso"))
4986 setup_gso(res->cmd_mode, res->cmd_pid);
4989 cmdline_parse_token_string_t cmd_gso_enable_set =
4990 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4992 cmdline_parse_token_string_t cmd_gso_enable_port =
4993 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4995 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4996 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4997 cmd_keyword, "gso");
4998 cmdline_parse_token_string_t cmd_gso_enable_mode =
4999 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5000 cmd_mode, "on#off");
5001 cmdline_parse_token_num_t cmd_gso_enable_pid =
5002 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5005 cmdline_parse_inst_t cmd_gso_enable = {
5006 .f = cmd_gso_enable_parsed,
5008 .help_str = "set port <port_id> gso on|off",
5010 (void *)&cmd_gso_enable_set,
5011 (void *)&cmd_gso_enable_port,
5012 (void *)&cmd_gso_enable_pid,
5013 (void *)&cmd_gso_enable_keyword,
5014 (void *)&cmd_gso_enable_mode,
5019 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5020 struct cmd_gso_size_result {
5021 cmdline_fixed_string_t cmd_set;
5022 cmdline_fixed_string_t cmd_keyword;
5023 cmdline_fixed_string_t cmd_segsz;
5028 cmd_gso_size_parsed(void *parsed_result,
5029 __attribute__((unused)) struct cmdline *cl,
5030 __attribute__((unused)) void *data)
5032 struct cmd_gso_size_result *res = parsed_result;
5034 if (test_done == 0) {
5035 printf("Before setting GSO segsz, please first"
5036 " stop fowarding\n");
5040 if (!strcmp(res->cmd_keyword, "gso") &&
5041 !strcmp(res->cmd_segsz, "segsz")) {
5042 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5043 printf("gso_size should be larger than %zu."
5044 " Please input a legal value\n",
5045 RTE_GSO_SEG_SIZE_MIN);
5047 gso_max_segment_size = res->cmd_size;
5051 cmdline_parse_token_string_t cmd_gso_size_set =
5052 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5054 cmdline_parse_token_string_t cmd_gso_size_keyword =
5055 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5056 cmd_keyword, "gso");
5057 cmdline_parse_token_string_t cmd_gso_size_segsz =
5058 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5059 cmd_segsz, "segsz");
5060 cmdline_parse_token_num_t cmd_gso_size_size =
5061 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5064 cmdline_parse_inst_t cmd_gso_size = {
5065 .f = cmd_gso_size_parsed,
5067 .help_str = "set gso segsz <length>",
5069 (void *)&cmd_gso_size_set,
5070 (void *)&cmd_gso_size_keyword,
5071 (void *)&cmd_gso_size_segsz,
5072 (void *)&cmd_gso_size_size,
5077 /* *** SHOW GSO CONFIGURATION *** */
5078 struct cmd_gso_show_result {
5079 cmdline_fixed_string_t cmd_show;
5080 cmdline_fixed_string_t cmd_port;
5081 cmdline_fixed_string_t cmd_keyword;
5086 cmd_gso_show_parsed(void *parsed_result,
5087 __attribute__((unused)) struct cmdline *cl,
5088 __attribute__((unused)) void *data)
5090 struct cmd_gso_show_result *res = parsed_result;
5092 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5093 printf("invalid port id %u\n", res->cmd_pid);
5096 if (!strcmp(res->cmd_keyword, "gso")) {
5097 if (gso_ports[res->cmd_pid].enable) {
5098 printf("Max GSO'd packet size: %uB\n"
5099 "Supported GSO types: TCP/IPv4, "
5100 "UDP/IPv4, VxLAN with inner "
5101 "TCP/IPv4 packet, GRE with inner "
5102 "TCP/IPv4 packet\n",
5103 gso_max_segment_size);
5105 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5109 cmdline_parse_token_string_t cmd_gso_show_show =
5110 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5112 cmdline_parse_token_string_t cmd_gso_show_port =
5113 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5115 cmdline_parse_token_string_t cmd_gso_show_keyword =
5116 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5117 cmd_keyword, "gso");
5118 cmdline_parse_token_num_t cmd_gso_show_pid =
5119 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5122 cmdline_parse_inst_t cmd_gso_show = {
5123 .f = cmd_gso_show_parsed,
5125 .help_str = "show port <port_id> gso",
5127 (void *)&cmd_gso_show_show,
5128 (void *)&cmd_gso_show_port,
5129 (void *)&cmd_gso_show_pid,
5130 (void *)&cmd_gso_show_keyword,
5135 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5136 struct cmd_set_flush_rx {
5137 cmdline_fixed_string_t set;
5138 cmdline_fixed_string_t flush_rx;
5139 cmdline_fixed_string_t mode;
5143 cmd_set_flush_rx_parsed(void *parsed_result,
5144 __attribute__((unused)) struct cmdline *cl,
5145 __attribute__((unused)) void *data)
5147 struct cmd_set_flush_rx *res = parsed_result;
5148 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5151 cmdline_parse_token_string_t cmd_setflushrx_set =
5152 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5154 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5155 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5156 flush_rx, "flush_rx");
5157 cmdline_parse_token_string_t cmd_setflushrx_mode =
5158 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5162 cmdline_parse_inst_t cmd_set_flush_rx = {
5163 .f = cmd_set_flush_rx_parsed,
5164 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5167 (void *)&cmd_setflushrx_set,
5168 (void *)&cmd_setflushrx_flush_rx,
5169 (void *)&cmd_setflushrx_mode,
5174 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5175 struct cmd_set_link_check {
5176 cmdline_fixed_string_t set;
5177 cmdline_fixed_string_t link_check;
5178 cmdline_fixed_string_t mode;
5182 cmd_set_link_check_parsed(void *parsed_result,
5183 __attribute__((unused)) struct cmdline *cl,
5184 __attribute__((unused)) void *data)
5186 struct cmd_set_link_check *res = parsed_result;
5187 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5190 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5191 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5193 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5194 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5195 link_check, "link_check");
5196 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5197 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5201 cmdline_parse_inst_t cmd_set_link_check = {
5202 .f = cmd_set_link_check_parsed,
5203 .help_str = "set link_check on|off: Enable/Disable link status check "
5204 "when starting/stopping a port",
5207 (void *)&cmd_setlinkcheck_set,
5208 (void *)&cmd_setlinkcheck_link_check,
5209 (void *)&cmd_setlinkcheck_mode,
5214 /* *** SET NIC BYPASS MODE *** */
5215 struct cmd_set_bypass_mode_result {
5216 cmdline_fixed_string_t set;
5217 cmdline_fixed_string_t bypass;
5218 cmdline_fixed_string_t mode;
5219 cmdline_fixed_string_t value;
5224 cmd_set_bypass_mode_parsed(void *parsed_result,
5225 __attribute__((unused)) struct cmdline *cl,
5226 __attribute__((unused)) void *data)
5228 struct cmd_set_bypass_mode_result *res = parsed_result;
5229 portid_t port_id = res->port_id;
5230 int32_t rc = -EINVAL;
5232 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5233 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5235 if (!strcmp(res->value, "bypass"))
5236 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5237 else if (!strcmp(res->value, "isolate"))
5238 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5240 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5242 /* Set the bypass mode for the relevant port. */
5243 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5246 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5249 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5250 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5252 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5253 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5255 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5256 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5258 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5259 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5260 value, "normal#bypass#isolate");
5261 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5262 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5265 cmdline_parse_inst_t cmd_set_bypass_mode = {
5266 .f = cmd_set_bypass_mode_parsed,
5267 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5268 "Set the NIC bypass mode for port_id",
5271 (void *)&cmd_setbypass_mode_set,
5272 (void *)&cmd_setbypass_mode_bypass,
5273 (void *)&cmd_setbypass_mode_mode,
5274 (void *)&cmd_setbypass_mode_value,
5275 (void *)&cmd_setbypass_mode_port,
5280 /* *** SET NIC BYPASS EVENT *** */
5281 struct cmd_set_bypass_event_result {
5282 cmdline_fixed_string_t set;
5283 cmdline_fixed_string_t bypass;
5284 cmdline_fixed_string_t event;
5285 cmdline_fixed_string_t event_value;
5286 cmdline_fixed_string_t mode;
5287 cmdline_fixed_string_t mode_value;
5292 cmd_set_bypass_event_parsed(void *parsed_result,
5293 __attribute__((unused)) struct cmdline *cl,
5294 __attribute__((unused)) void *data)
5296 int32_t rc = -EINVAL;
5297 struct cmd_set_bypass_event_result *res = parsed_result;
5298 portid_t port_id = res->port_id;
5300 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5301 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5302 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5304 if (!strcmp(res->event_value, "timeout"))
5305 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5306 else if (!strcmp(res->event_value, "os_on"))
5307 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5308 else if (!strcmp(res->event_value, "os_off"))
5309 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5310 else if (!strcmp(res->event_value, "power_on"))
5311 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5312 else if (!strcmp(res->event_value, "power_off"))
5313 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5315 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5317 if (!strcmp(res->mode_value, "bypass"))
5318 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5319 else if (!strcmp(res->mode_value, "isolate"))
5320 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5322 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5324 /* Set the watchdog timeout. */
5325 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5328 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5329 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5333 printf("Failed to set timeout value %u "
5334 "for port %d, errto code: %d.\n",
5335 bypass_timeout, port_id, rc);
5339 /* Set the bypass event to transition to bypass mode. */
5340 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5345 printf("\t Failed to set bypass event for port = %d.\n",
5349 cmdline_parse_token_string_t cmd_setbypass_event_set =
5350 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5352 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5353 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5355 cmdline_parse_token_string_t cmd_setbypass_event_event =
5356 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5358 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5359 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5360 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5361 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5362 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5364 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5365 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5366 mode_value, "normal#bypass#isolate");
5367 cmdline_parse_token_num_t cmd_setbypass_event_port =
5368 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5371 cmdline_parse_inst_t cmd_set_bypass_event = {
5372 .f = cmd_set_bypass_event_parsed,
5373 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5374 "power_off mode normal|bypass|isolate <port_id>: "
5375 "Set the NIC bypass event mode for port_id",
5378 (void *)&cmd_setbypass_event_set,
5379 (void *)&cmd_setbypass_event_bypass,
5380 (void *)&cmd_setbypass_event_event,
5381 (void *)&cmd_setbypass_event_event_value,
5382 (void *)&cmd_setbypass_event_mode,
5383 (void *)&cmd_setbypass_event_mode_value,
5384 (void *)&cmd_setbypass_event_port,
5390 /* *** SET NIC BYPASS TIMEOUT *** */
5391 struct cmd_set_bypass_timeout_result {
5392 cmdline_fixed_string_t set;
5393 cmdline_fixed_string_t bypass;
5394 cmdline_fixed_string_t timeout;
5395 cmdline_fixed_string_t value;
5399 cmd_set_bypass_timeout_parsed(void *parsed_result,
5400 __attribute__((unused)) struct cmdline *cl,
5401 __attribute__((unused)) void *data)
5403 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5405 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5406 if (!strcmp(res->value, "1.5"))
5407 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5408 else if (!strcmp(res->value, "2"))
5409 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5410 else if (!strcmp(res->value, "3"))
5411 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5412 else if (!strcmp(res->value, "4"))
5413 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5414 else if (!strcmp(res->value, "8"))
5415 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5416 else if (!strcmp(res->value, "16"))
5417 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5418 else if (!strcmp(res->value, "32"))
5419 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5421 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5425 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5426 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5428 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5429 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5431 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5432 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5433 timeout, "timeout");
5434 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5435 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5436 value, "0#1.5#2#3#4#8#16#32");
5438 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5439 .f = cmd_set_bypass_timeout_parsed,
5440 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5441 "Set the NIC bypass watchdog timeout in seconds",
5444 (void *)&cmd_setbypass_timeout_set,
5445 (void *)&cmd_setbypass_timeout_bypass,
5446 (void *)&cmd_setbypass_timeout_timeout,
5447 (void *)&cmd_setbypass_timeout_value,
5452 /* *** SHOW NIC BYPASS MODE *** */
5453 struct cmd_show_bypass_config_result {
5454 cmdline_fixed_string_t show;
5455 cmdline_fixed_string_t bypass;
5456 cmdline_fixed_string_t config;
5461 cmd_show_bypass_config_parsed(void *parsed_result,
5462 __attribute__((unused)) struct cmdline *cl,
5463 __attribute__((unused)) void *data)
5465 struct cmd_show_bypass_config_result *res = parsed_result;
5466 portid_t port_id = res->port_id;
5468 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5469 uint32_t event_mode;
5470 uint32_t bypass_mode;
5471 uint32_t timeout = bypass_timeout;
5474 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5475 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5476 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5477 {"UNKNOWN", "normal", "bypass", "isolate"};
5478 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5485 int num_events = (sizeof events) / (sizeof events[0]);
5487 /* Display the bypass mode.*/
5488 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5489 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5493 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5494 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5496 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5499 /* Display the bypass timeout.*/
5500 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5501 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5503 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5505 /* Display the bypass events and associated modes. */
5506 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5508 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5509 printf("\tFailed to get bypass mode for event = %s\n",
5512 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5513 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5515 printf("\tbypass event: %-16s = %s\n", events[i],
5521 printf("\tFailed to get bypass configuration for port = %d\n",
5525 cmdline_parse_token_string_t cmd_showbypass_config_show =
5526 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5528 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5529 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5531 cmdline_parse_token_string_t cmd_showbypass_config_config =
5532 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5534 cmdline_parse_token_num_t cmd_showbypass_config_port =
5535 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5538 cmdline_parse_inst_t cmd_show_bypass_config = {
5539 .f = cmd_show_bypass_config_parsed,
5540 .help_str = "show bypass config <port_id>: "
5541 "Show the NIC bypass config for port_id",
5544 (void *)&cmd_showbypass_config_show,
5545 (void *)&cmd_showbypass_config_bypass,
5546 (void *)&cmd_showbypass_config_config,
5547 (void *)&cmd_showbypass_config_port,
5552 #ifdef RTE_LIBRTE_PMD_BOND
5553 /* *** SET BONDING MODE *** */
5554 struct cmd_set_bonding_mode_result {
5555 cmdline_fixed_string_t set;
5556 cmdline_fixed_string_t bonding;
5557 cmdline_fixed_string_t mode;
5562 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5563 __attribute__((unused)) struct cmdline *cl,
5564 __attribute__((unused)) void *data)
5566 struct cmd_set_bonding_mode_result *res = parsed_result;
5567 portid_t port_id = res->port_id;
5569 /* Set the bonding mode for the relevant port. */
5570 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5571 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5574 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5575 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5577 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5578 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5579 bonding, "bonding");
5580 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5581 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5583 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5584 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5586 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5587 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5590 cmdline_parse_inst_t cmd_set_bonding_mode = {
5591 .f = cmd_set_bonding_mode_parsed,
5592 .help_str = "set bonding mode <mode_value> <port_id>: "
5593 "Set the bonding mode for port_id",
5596 (void *) &cmd_setbonding_mode_set,
5597 (void *) &cmd_setbonding_mode_bonding,
5598 (void *) &cmd_setbonding_mode_mode,
5599 (void *) &cmd_setbonding_mode_value,
5600 (void *) &cmd_setbonding_mode_port,
5605 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5606 struct cmd_set_bonding_lacp_dedicated_queues_result {
5607 cmdline_fixed_string_t set;
5608 cmdline_fixed_string_t bonding;
5609 cmdline_fixed_string_t lacp;
5610 cmdline_fixed_string_t dedicated_queues;
5612 cmdline_fixed_string_t mode;
5615 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5616 __attribute__((unused)) struct cmdline *cl,
5617 __attribute__((unused)) void *data)
5619 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5620 portid_t port_id = res->port_id;
5621 struct rte_port *port;
5623 port = &ports[port_id];
5625 /** Check if the port is not started **/
5626 if (port->port_status != RTE_PORT_STOPPED) {
5627 printf("Please stop port %d first\n", port_id);
5631 if (!strcmp(res->mode, "enable")) {
5632 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5633 printf("Dedicate queues for LACP control packets"
5636 printf("Enabling dedicate queues for LACP control "
5637 "packets on port %d failed\n", port_id);
5638 } else if (!strcmp(res->mode, "disable")) {
5639 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5640 printf("Dedicated queues for LACP control packets "
5643 printf("Disabling dedicated queues for LACP control "
5644 "traffic on port %d failed\n", port_id);
5648 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5649 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5651 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5652 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5653 bonding, "bonding");
5654 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5655 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5657 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5658 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5659 dedicated_queues, "dedicated_queues");
5660 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5661 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5663 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5664 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5665 mode, "enable#disable");
5667 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5668 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5669 .help_str = "set bonding lacp dedicated_queues <port_id> "
5671 "Enable/disable dedicated queues for LACP control traffic for port_id",
5674 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5675 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5676 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5677 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5678 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5679 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5684 /* *** SET BALANCE XMIT POLICY *** */
5685 struct cmd_set_bonding_balance_xmit_policy_result {
5686 cmdline_fixed_string_t set;
5687 cmdline_fixed_string_t bonding;
5688 cmdline_fixed_string_t balance_xmit_policy;
5690 cmdline_fixed_string_t policy;
5693 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5694 __attribute__((unused)) struct cmdline *cl,
5695 __attribute__((unused)) void *data)
5697 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5698 portid_t port_id = res->port_id;
5701 if (!strcmp(res->policy, "l2")) {
5702 policy = BALANCE_XMIT_POLICY_LAYER2;
5703 } else if (!strcmp(res->policy, "l23")) {
5704 policy = BALANCE_XMIT_POLICY_LAYER23;
5705 } else if (!strcmp(res->policy, "l34")) {
5706 policy = BALANCE_XMIT_POLICY_LAYER34;
5708 printf("\t Invalid xmit policy selection");
5712 /* Set the bonding mode for the relevant port. */
5713 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5714 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5719 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5720 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5722 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5723 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5724 bonding, "bonding");
5725 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5726 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5727 balance_xmit_policy, "balance_xmit_policy");
5728 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5729 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5731 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5732 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5733 policy, "l2#l23#l34");
5735 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5736 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5737 .help_str = "set bonding balance_xmit_policy <port_id> "
5739 "Set the bonding balance_xmit_policy for port_id",
5742 (void *)&cmd_setbonding_balance_xmit_policy_set,
5743 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5744 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5745 (void *)&cmd_setbonding_balance_xmit_policy_port,
5746 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5751 /* *** SHOW NIC BONDING CONFIGURATION *** */
5752 struct cmd_show_bonding_config_result {
5753 cmdline_fixed_string_t show;
5754 cmdline_fixed_string_t bonding;
5755 cmdline_fixed_string_t config;
5759 static void cmd_show_bonding_config_parsed(void *parsed_result,
5760 __attribute__((unused)) struct cmdline *cl,
5761 __attribute__((unused)) void *data)
5763 struct cmd_show_bonding_config_result *res = parsed_result;
5764 int bonding_mode, agg_mode;
5765 portid_t slaves[RTE_MAX_ETHPORTS];
5766 int num_slaves, num_active_slaves;
5769 portid_t port_id = res->port_id;
5771 /* Display the bonding mode.*/
5772 bonding_mode = rte_eth_bond_mode_get(port_id);
5773 if (bonding_mode < 0) {
5774 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5777 printf("\tBonding mode: %d\n", bonding_mode);
5779 if (bonding_mode == BONDING_MODE_BALANCE) {
5780 int balance_xmit_policy;
5782 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5783 if (balance_xmit_policy < 0) {
5784 printf("\tFailed to get balance xmit policy for port = %d\n",
5788 printf("\tBalance Xmit Policy: ");
5790 switch (balance_xmit_policy) {
5791 case BALANCE_XMIT_POLICY_LAYER2:
5792 printf("BALANCE_XMIT_POLICY_LAYER2");
5794 case BALANCE_XMIT_POLICY_LAYER23:
5795 printf("BALANCE_XMIT_POLICY_LAYER23");
5797 case BALANCE_XMIT_POLICY_LAYER34:
5798 printf("BALANCE_XMIT_POLICY_LAYER34");
5805 if (bonding_mode == BONDING_MODE_8023AD) {
5806 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5807 printf("\tIEEE802.3AD Aggregator Mode: ");
5810 printf("bandwidth");
5822 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5824 if (num_slaves < 0) {
5825 printf("\tFailed to get slave list for port = %d\n", port_id);
5828 if (num_slaves > 0) {
5829 printf("\tSlaves (%d): [", num_slaves);
5830 for (i = 0; i < num_slaves - 1; i++)
5831 printf("%d ", slaves[i]);
5833 printf("%d]\n", slaves[num_slaves - 1]);
5835 printf("\tSlaves: []\n");
5839 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5842 if (num_active_slaves < 0) {
5843 printf("\tFailed to get active slave list for port = %d\n", port_id);
5846 if (num_active_slaves > 0) {
5847 printf("\tActive Slaves (%d): [", num_active_slaves);
5848 for (i = 0; i < num_active_slaves - 1; i++)
5849 printf("%d ", slaves[i]);
5851 printf("%d]\n", slaves[num_active_slaves - 1]);
5854 printf("\tActive Slaves: []\n");
5858 primary_id = rte_eth_bond_primary_get(port_id);
5859 if (primary_id < 0) {
5860 printf("\tFailed to get primary slave for port = %d\n", port_id);
5863 printf("\tPrimary: [%d]\n", primary_id);
5867 cmdline_parse_token_string_t cmd_showbonding_config_show =
5868 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5870 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5871 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5872 bonding, "bonding");
5873 cmdline_parse_token_string_t cmd_showbonding_config_config =
5874 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5876 cmdline_parse_token_num_t cmd_showbonding_config_port =
5877 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5880 cmdline_parse_inst_t cmd_show_bonding_config = {
5881 .f = cmd_show_bonding_config_parsed,
5882 .help_str = "show bonding config <port_id>: "
5883 "Show the bonding config for port_id",
5886 (void *)&cmd_showbonding_config_show,
5887 (void *)&cmd_showbonding_config_bonding,
5888 (void *)&cmd_showbonding_config_config,
5889 (void *)&cmd_showbonding_config_port,
5894 /* *** SET BONDING PRIMARY *** */
5895 struct cmd_set_bonding_primary_result {
5896 cmdline_fixed_string_t set;
5897 cmdline_fixed_string_t bonding;
5898 cmdline_fixed_string_t primary;
5903 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5904 __attribute__((unused)) struct cmdline *cl,
5905 __attribute__((unused)) void *data)
5907 struct cmd_set_bonding_primary_result *res = parsed_result;
5908 portid_t master_port_id = res->port_id;
5909 portid_t slave_port_id = res->slave_id;
5911 /* Set the primary slave for a bonded device. */
5912 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5913 printf("\t Failed to set primary slave for port = %d.\n",
5920 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5921 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5923 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5924 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5925 bonding, "bonding");
5926 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5927 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5928 primary, "primary");
5929 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5930 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5932 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5933 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5936 cmdline_parse_inst_t cmd_set_bonding_primary = {
5937 .f = cmd_set_bonding_primary_parsed,
5938 .help_str = "set bonding primary <slave_id> <port_id>: "
5939 "Set the primary slave for port_id",
5942 (void *)&cmd_setbonding_primary_set,
5943 (void *)&cmd_setbonding_primary_bonding,
5944 (void *)&cmd_setbonding_primary_primary,
5945 (void *)&cmd_setbonding_primary_slave,
5946 (void *)&cmd_setbonding_primary_port,
5951 /* *** ADD SLAVE *** */
5952 struct cmd_add_bonding_slave_result {
5953 cmdline_fixed_string_t add;
5954 cmdline_fixed_string_t bonding;
5955 cmdline_fixed_string_t slave;
5960 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5961 __attribute__((unused)) struct cmdline *cl,
5962 __attribute__((unused)) void *data)
5964 struct cmd_add_bonding_slave_result *res = parsed_result;
5965 portid_t master_port_id = res->port_id;
5966 portid_t slave_port_id = res->slave_id;
5968 /* add the slave for a bonded device. */
5969 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5970 printf("\t Failed to add slave %d to master port = %d.\n",
5971 slave_port_id, master_port_id);
5975 set_port_slave_flag(slave_port_id);
5978 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5979 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5981 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5982 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5983 bonding, "bonding");
5984 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5985 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5987 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5988 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5990 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5991 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5994 cmdline_parse_inst_t cmd_add_bonding_slave = {
5995 .f = cmd_add_bonding_slave_parsed,
5996 .help_str = "add bonding slave <slave_id> <port_id>: "
5997 "Add a slave device to a bonded device",
6000 (void *)&cmd_addbonding_slave_add,
6001 (void *)&cmd_addbonding_slave_bonding,
6002 (void *)&cmd_addbonding_slave_slave,
6003 (void *)&cmd_addbonding_slave_slaveid,
6004 (void *)&cmd_addbonding_slave_port,
6009 /* *** REMOVE SLAVE *** */
6010 struct cmd_remove_bonding_slave_result {
6011 cmdline_fixed_string_t remove;
6012 cmdline_fixed_string_t bonding;
6013 cmdline_fixed_string_t slave;
6018 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6019 __attribute__((unused)) struct cmdline *cl,
6020 __attribute__((unused)) void *data)
6022 struct cmd_remove_bonding_slave_result *res = parsed_result;
6023 portid_t master_port_id = res->port_id;
6024 portid_t slave_port_id = res->slave_id;
6026 /* remove the slave from a bonded device. */
6027 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6028 printf("\t Failed to remove slave %d from master port = %d.\n",
6029 slave_port_id, master_port_id);
6033 clear_port_slave_flag(slave_port_id);
6036 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6037 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6039 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6040 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6041 bonding, "bonding");
6042 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6043 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6045 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6046 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6048 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6049 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6052 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6053 .f = cmd_remove_bonding_slave_parsed,
6054 .help_str = "remove bonding slave <slave_id> <port_id>: "
6055 "Remove a slave device from a bonded device",
6058 (void *)&cmd_removebonding_slave_remove,
6059 (void *)&cmd_removebonding_slave_bonding,
6060 (void *)&cmd_removebonding_slave_slave,
6061 (void *)&cmd_removebonding_slave_slaveid,
6062 (void *)&cmd_removebonding_slave_port,
6067 /* *** CREATE BONDED DEVICE *** */
6068 struct cmd_create_bonded_device_result {
6069 cmdline_fixed_string_t create;
6070 cmdline_fixed_string_t bonded;
6071 cmdline_fixed_string_t device;
6076 static int bond_dev_num = 0;
6078 static void cmd_create_bonded_device_parsed(void *parsed_result,
6079 __attribute__((unused)) struct cmdline *cl,
6080 __attribute__((unused)) void *data)
6082 struct cmd_create_bonded_device_result *res = parsed_result;
6083 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6087 if (test_done == 0) {
6088 printf("Please stop forwarding first\n");
6092 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6095 /* Create a new bonded device. */
6096 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6098 printf("\t Failed to create bonded device.\n");
6101 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6104 /* Update number of ports */
6105 nb_ports = rte_eth_dev_count_avail();
6106 reconfig(port_id, res->socket);
6107 ret = rte_eth_promiscuous_enable(port_id);
6109 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6110 port_id, rte_strerror(-ret));
6112 ports[port_id].need_setup = 0;
6113 ports[port_id].port_status = RTE_PORT_STOPPED;
6118 cmdline_parse_token_string_t cmd_createbonded_device_create =
6119 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6121 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6122 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6124 cmdline_parse_token_string_t cmd_createbonded_device_device =
6125 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6127 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6128 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6130 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6131 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6134 cmdline_parse_inst_t cmd_create_bonded_device = {
6135 .f = cmd_create_bonded_device_parsed,
6136 .help_str = "create bonded device <mode> <socket>: "
6137 "Create a new bonded device with specific bonding mode and socket",
6140 (void *)&cmd_createbonded_device_create,
6141 (void *)&cmd_createbonded_device_bonded,
6142 (void *)&cmd_createbonded_device_device,
6143 (void *)&cmd_createbonded_device_mode,
6144 (void *)&cmd_createbonded_device_socket,
6149 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6150 struct cmd_set_bond_mac_addr_result {
6151 cmdline_fixed_string_t set;
6152 cmdline_fixed_string_t bonding;
6153 cmdline_fixed_string_t mac_addr;
6155 struct rte_ether_addr address;
6158 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6159 __attribute__((unused)) struct cmdline *cl,
6160 __attribute__((unused)) void *data)
6162 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6165 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6168 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6170 /* check the return value and print it if is < 0 */
6172 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6175 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6176 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6177 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6178 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6180 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6181 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6183 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6184 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6186 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6187 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6189 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6190 .f = cmd_set_bond_mac_addr_parsed,
6192 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6194 (void *)&cmd_set_bond_mac_addr_set,
6195 (void *)&cmd_set_bond_mac_addr_bonding,
6196 (void *)&cmd_set_bond_mac_addr_mac,
6197 (void *)&cmd_set_bond_mac_addr_portnum,
6198 (void *)&cmd_set_bond_mac_addr_addr,
6204 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6205 struct cmd_set_bond_mon_period_result {
6206 cmdline_fixed_string_t set;
6207 cmdline_fixed_string_t bonding;
6208 cmdline_fixed_string_t mon_period;
6213 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6214 __attribute__((unused)) struct cmdline *cl,
6215 __attribute__((unused)) void *data)
6217 struct cmd_set_bond_mon_period_result *res = parsed_result;
6220 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6222 /* check the return value and print it if is < 0 */
6224 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6227 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6228 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6230 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6231 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6232 bonding, "bonding");
6233 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6234 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6235 mon_period, "mon_period");
6236 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6237 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6239 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6240 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6243 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6244 .f = cmd_set_bond_mon_period_parsed,
6246 .help_str = "set bonding mon_period <port_id> <period_ms>",
6248 (void *)&cmd_set_bond_mon_period_set,
6249 (void *)&cmd_set_bond_mon_period_bonding,
6250 (void *)&cmd_set_bond_mon_period_mon_period,
6251 (void *)&cmd_set_bond_mon_period_portnum,
6252 (void *)&cmd_set_bond_mon_period_period_ms,
6259 struct cmd_set_bonding_agg_mode_policy_result {
6260 cmdline_fixed_string_t set;
6261 cmdline_fixed_string_t bonding;
6262 cmdline_fixed_string_t agg_mode;
6264 cmdline_fixed_string_t policy;
6269 cmd_set_bonding_agg_mode(void *parsed_result,
6270 __attribute__((unused)) struct cmdline *cl,
6271 __attribute__((unused)) void *data)
6273 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6274 uint8_t policy = AGG_BANDWIDTH;
6276 if (!strcmp(res->policy, "bandwidth"))
6277 policy = AGG_BANDWIDTH;
6278 else if (!strcmp(res->policy, "stable"))
6279 policy = AGG_STABLE;
6280 else if (!strcmp(res->policy, "count"))
6283 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6287 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6288 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6290 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6291 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6292 bonding, "bonding");
6294 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6295 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6296 agg_mode, "agg_mode");
6298 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6299 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6302 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6303 TOKEN_STRING_INITIALIZER(
6304 struct cmd_set_bonding_balance_xmit_policy_result,
6305 policy, "stable#bandwidth#count");
6307 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6308 .f = cmd_set_bonding_agg_mode,
6310 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6312 (void *)&cmd_set_bonding_agg_mode_set,
6313 (void *)&cmd_set_bonding_agg_mode_bonding,
6314 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6315 (void *)&cmd_set_bonding_agg_mode_portnum,
6316 (void *)&cmd_set_bonding_agg_mode_policy_string,
6322 #endif /* RTE_LIBRTE_PMD_BOND */
6324 /* *** SET FORWARDING MODE *** */
6325 struct cmd_set_fwd_mode_result {
6326 cmdline_fixed_string_t set;
6327 cmdline_fixed_string_t fwd;
6328 cmdline_fixed_string_t mode;
6331 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6332 __attribute__((unused)) struct cmdline *cl,
6333 __attribute__((unused)) void *data)
6335 struct cmd_set_fwd_mode_result *res = parsed_result;
6338 set_pkt_forwarding_mode(res->mode);
6341 cmdline_parse_token_string_t cmd_setfwd_set =
6342 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6343 cmdline_parse_token_string_t cmd_setfwd_fwd =
6344 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6345 cmdline_parse_token_string_t cmd_setfwd_mode =
6346 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6347 "" /* defined at init */);
6349 cmdline_parse_inst_t cmd_set_fwd_mode = {
6350 .f = cmd_set_fwd_mode_parsed,
6352 .help_str = NULL, /* defined at init */
6354 (void *)&cmd_setfwd_set,
6355 (void *)&cmd_setfwd_fwd,
6356 (void *)&cmd_setfwd_mode,
6361 static void cmd_set_fwd_mode_init(void)
6364 static char token[128];
6365 static char help[256];
6366 cmdline_parse_token_string_t *token_struct;
6368 modes = list_pkt_forwarding_modes();
6369 snprintf(help, sizeof(help), "set fwd %s: "
6370 "Set packet forwarding mode", modes);
6371 cmd_set_fwd_mode.help_str = help;
6373 /* string token separator is # */
6374 for (c = token; *modes != '\0'; modes++)
6379 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6380 token_struct->string_data.str = token;
6383 /* *** SET RETRY FORWARDING MODE *** */
6384 struct cmd_set_fwd_retry_mode_result {
6385 cmdline_fixed_string_t set;
6386 cmdline_fixed_string_t fwd;
6387 cmdline_fixed_string_t mode;
6388 cmdline_fixed_string_t retry;
6391 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6392 __attribute__((unused)) struct cmdline *cl,
6393 __attribute__((unused)) void *data)
6395 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6398 set_pkt_forwarding_mode(res->mode);
6401 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6402 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6404 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6405 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6407 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6408 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6410 "" /* defined at init */);
6411 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6412 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6415 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6416 .f = cmd_set_fwd_retry_mode_parsed,
6418 .help_str = NULL, /* defined at init */
6420 (void *)&cmd_setfwd_retry_set,
6421 (void *)&cmd_setfwd_retry_fwd,
6422 (void *)&cmd_setfwd_retry_mode,
6423 (void *)&cmd_setfwd_retry_retry,
6428 static void cmd_set_fwd_retry_mode_init(void)
6431 static char token[128];
6432 static char help[256];
6433 cmdline_parse_token_string_t *token_struct;
6435 modes = list_pkt_forwarding_retry_modes();
6436 snprintf(help, sizeof(help), "set fwd %s retry: "
6437 "Set packet forwarding mode with retry", modes);
6438 cmd_set_fwd_retry_mode.help_str = help;
6440 /* string token separator is # */
6441 for (c = token; *modes != '\0'; modes++)
6446 token_struct = (cmdline_parse_token_string_t *)
6447 cmd_set_fwd_retry_mode.tokens[2];
6448 token_struct->string_data.str = token;
6451 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6452 struct cmd_set_burst_tx_retry_result {
6453 cmdline_fixed_string_t set;
6454 cmdline_fixed_string_t burst;
6455 cmdline_fixed_string_t tx;
6456 cmdline_fixed_string_t delay;
6458 cmdline_fixed_string_t retry;
6462 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6463 __attribute__((unused)) struct cmdline *cl,
6464 __attribute__((unused)) void *data)
6466 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6468 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6469 && !strcmp(res->tx, "tx")) {
6470 if (!strcmp(res->delay, "delay"))
6471 burst_tx_delay_time = res->time;
6472 if (!strcmp(res->retry, "retry"))
6473 burst_tx_retry_num = res->retry_num;
6478 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6479 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6480 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6481 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6483 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6484 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6485 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6486 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6487 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6488 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6489 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6490 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6491 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6492 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6494 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6495 .f = cmd_set_burst_tx_retry_parsed,
6496 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6498 (void *)&cmd_set_burst_tx_retry_set,
6499 (void *)&cmd_set_burst_tx_retry_burst,
6500 (void *)&cmd_set_burst_tx_retry_tx,
6501 (void *)&cmd_set_burst_tx_retry_delay,
6502 (void *)&cmd_set_burst_tx_retry_time,
6503 (void *)&cmd_set_burst_tx_retry_retry,
6504 (void *)&cmd_set_burst_tx_retry_retry_num,
6509 /* *** SET PROMISC MODE *** */
6510 struct cmd_set_promisc_mode_result {
6511 cmdline_fixed_string_t set;
6512 cmdline_fixed_string_t promisc;
6513 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6514 uint16_t port_num; /* valid if "allports" argument == 0 */
6515 cmdline_fixed_string_t mode;
6518 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6519 __attribute__((unused)) struct cmdline *cl,
6522 struct cmd_set_promisc_mode_result *res = parsed_result;
6526 if (!strcmp(res->mode, "on"))
6533 RTE_ETH_FOREACH_DEV(i)
6534 eth_set_promisc_mode(i, enable);
6536 eth_set_promisc_mode(res->port_num, enable);
6540 cmdline_parse_token_string_t cmd_setpromisc_set =
6541 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6542 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6543 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6545 cmdline_parse_token_string_t cmd_setpromisc_portall =
6546 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6548 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6549 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6551 cmdline_parse_token_string_t cmd_setpromisc_mode =
6552 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6555 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6556 .f = cmd_set_promisc_mode_parsed,
6558 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6560 (void *)&cmd_setpromisc_set,
6561 (void *)&cmd_setpromisc_promisc,
6562 (void *)&cmd_setpromisc_portall,
6563 (void *)&cmd_setpromisc_mode,
6568 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6569 .f = cmd_set_promisc_mode_parsed,
6571 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6573 (void *)&cmd_setpromisc_set,
6574 (void *)&cmd_setpromisc_promisc,
6575 (void *)&cmd_setpromisc_portnum,
6576 (void *)&cmd_setpromisc_mode,
6581 /* *** SET ALLMULTI MODE *** */
6582 struct cmd_set_allmulti_mode_result {
6583 cmdline_fixed_string_t set;
6584 cmdline_fixed_string_t allmulti;
6585 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6586 uint16_t port_num; /* valid if "allports" argument == 0 */
6587 cmdline_fixed_string_t mode;
6590 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6591 __attribute__((unused)) struct cmdline *cl,
6594 struct cmd_set_allmulti_mode_result *res = parsed_result;
6598 if (!strcmp(res->mode, "on"))
6605 RTE_ETH_FOREACH_DEV(i) {
6606 eth_set_allmulticast_mode(i, enable);
6610 eth_set_allmulticast_mode(res->port_num, enable);
6614 cmdline_parse_token_string_t cmd_setallmulti_set =
6615 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6616 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6617 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6619 cmdline_parse_token_string_t cmd_setallmulti_portall =
6620 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6622 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6623 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6625 cmdline_parse_token_string_t cmd_setallmulti_mode =
6626 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6629 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6630 .f = cmd_set_allmulti_mode_parsed,
6632 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6634 (void *)&cmd_setallmulti_set,
6635 (void *)&cmd_setallmulti_allmulti,
6636 (void *)&cmd_setallmulti_portall,
6637 (void *)&cmd_setallmulti_mode,
6642 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6643 .f = cmd_set_allmulti_mode_parsed,
6645 .help_str = "set allmulti <port_id> on|off: "
6646 "Set allmulti mode on port_id",
6648 (void *)&cmd_setallmulti_set,
6649 (void *)&cmd_setallmulti_allmulti,
6650 (void *)&cmd_setallmulti_portnum,
6651 (void *)&cmd_setallmulti_mode,
6656 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6657 struct cmd_link_flow_ctrl_set_result {
6658 cmdline_fixed_string_t set;
6659 cmdline_fixed_string_t flow_ctrl;
6660 cmdline_fixed_string_t rx;
6661 cmdline_fixed_string_t rx_lfc_mode;
6662 cmdline_fixed_string_t tx;
6663 cmdline_fixed_string_t tx_lfc_mode;
6664 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6665 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6666 cmdline_fixed_string_t autoneg_str;
6667 cmdline_fixed_string_t autoneg;
6668 cmdline_fixed_string_t hw_str;
6669 uint32_t high_water;
6670 cmdline_fixed_string_t lw_str;
6672 cmdline_fixed_string_t pt_str;
6673 uint16_t pause_time;
6674 cmdline_fixed_string_t xon_str;
6679 cmdline_parse_token_string_t cmd_lfc_set_set =
6680 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6682 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6683 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6684 flow_ctrl, "flow_ctrl");
6685 cmdline_parse_token_string_t cmd_lfc_set_rx =
6686 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6688 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6689 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6690 rx_lfc_mode, "on#off");
6691 cmdline_parse_token_string_t cmd_lfc_set_tx =
6692 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6694 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6695 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6696 tx_lfc_mode, "on#off");
6697 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6698 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6699 hw_str, "high_water");
6700 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6701 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6702 high_water, UINT32);
6703 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6704 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6705 lw_str, "low_water");
6706 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6707 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6709 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6710 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6711 pt_str, "pause_time");
6712 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6713 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6714 pause_time, UINT16);
6715 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6716 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6717 xon_str, "send_xon");
6718 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6719 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6721 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6722 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6723 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6724 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6725 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6726 mac_ctrl_frame_fwd_mode, "on#off");
6727 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6728 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6729 autoneg_str, "autoneg");
6730 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6731 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6733 cmdline_parse_token_num_t cmd_lfc_set_portid =
6734 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6737 /* forward declaration */
6739 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6742 cmdline_parse_inst_t cmd_link_flow_control_set = {
6743 .f = cmd_link_flow_ctrl_set_parsed,
6745 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6746 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6747 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6749 (void *)&cmd_lfc_set_set,
6750 (void *)&cmd_lfc_set_flow_ctrl,
6751 (void *)&cmd_lfc_set_rx,
6752 (void *)&cmd_lfc_set_rx_mode,
6753 (void *)&cmd_lfc_set_tx,
6754 (void *)&cmd_lfc_set_tx_mode,
6755 (void *)&cmd_lfc_set_high_water,
6756 (void *)&cmd_lfc_set_low_water,
6757 (void *)&cmd_lfc_set_pause_time,
6758 (void *)&cmd_lfc_set_send_xon,
6759 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6760 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6761 (void *)&cmd_lfc_set_autoneg_str,
6762 (void *)&cmd_lfc_set_autoneg,
6763 (void *)&cmd_lfc_set_portid,
6768 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6769 .f = cmd_link_flow_ctrl_set_parsed,
6770 .data = (void *)&cmd_link_flow_control_set_rx,
6771 .help_str = "set flow_ctrl rx on|off <port_id>: "
6772 "Change rx flow control parameter",
6774 (void *)&cmd_lfc_set_set,
6775 (void *)&cmd_lfc_set_flow_ctrl,
6776 (void *)&cmd_lfc_set_rx,
6777 (void *)&cmd_lfc_set_rx_mode,
6778 (void *)&cmd_lfc_set_portid,
6783 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6784 .f = cmd_link_flow_ctrl_set_parsed,
6785 .data = (void *)&cmd_link_flow_control_set_tx,
6786 .help_str = "set flow_ctrl tx on|off <port_id>: "
6787 "Change tx flow control parameter",
6789 (void *)&cmd_lfc_set_set,
6790 (void *)&cmd_lfc_set_flow_ctrl,
6791 (void *)&cmd_lfc_set_tx,
6792 (void *)&cmd_lfc_set_tx_mode,
6793 (void *)&cmd_lfc_set_portid,
6798 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6799 .f = cmd_link_flow_ctrl_set_parsed,
6800 .data = (void *)&cmd_link_flow_control_set_hw,
6801 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6802 "Change high water flow control parameter",
6804 (void *)&cmd_lfc_set_set,
6805 (void *)&cmd_lfc_set_flow_ctrl,
6806 (void *)&cmd_lfc_set_high_water_str,
6807 (void *)&cmd_lfc_set_high_water,
6808 (void *)&cmd_lfc_set_portid,
6813 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6814 .f = cmd_link_flow_ctrl_set_parsed,
6815 .data = (void *)&cmd_link_flow_control_set_lw,
6816 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6817 "Change low water flow control parameter",
6819 (void *)&cmd_lfc_set_set,
6820 (void *)&cmd_lfc_set_flow_ctrl,
6821 (void *)&cmd_lfc_set_low_water_str,
6822 (void *)&cmd_lfc_set_low_water,
6823 (void *)&cmd_lfc_set_portid,
6828 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6829 .f = cmd_link_flow_ctrl_set_parsed,
6830 .data = (void *)&cmd_link_flow_control_set_pt,
6831 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6832 "Change pause time flow control parameter",
6834 (void *)&cmd_lfc_set_set,
6835 (void *)&cmd_lfc_set_flow_ctrl,
6836 (void *)&cmd_lfc_set_pause_time_str,
6837 (void *)&cmd_lfc_set_pause_time,
6838 (void *)&cmd_lfc_set_portid,
6843 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6844 .f = cmd_link_flow_ctrl_set_parsed,
6845 .data = (void *)&cmd_link_flow_control_set_xon,
6846 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6847 "Change send_xon flow control parameter",
6849 (void *)&cmd_lfc_set_set,
6850 (void *)&cmd_lfc_set_flow_ctrl,
6851 (void *)&cmd_lfc_set_send_xon_str,
6852 (void *)&cmd_lfc_set_send_xon,
6853 (void *)&cmd_lfc_set_portid,
6858 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6859 .f = cmd_link_flow_ctrl_set_parsed,
6860 .data = (void *)&cmd_link_flow_control_set_macfwd,
6861 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6862 "Change mac ctrl fwd flow control parameter",
6864 (void *)&cmd_lfc_set_set,
6865 (void *)&cmd_lfc_set_flow_ctrl,
6866 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6867 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6868 (void *)&cmd_lfc_set_portid,
6873 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6874 .f = cmd_link_flow_ctrl_set_parsed,
6875 .data = (void *)&cmd_link_flow_control_set_autoneg,
6876 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6877 "Change autoneg flow control parameter",
6879 (void *)&cmd_lfc_set_set,
6880 (void *)&cmd_lfc_set_flow_ctrl,
6881 (void *)&cmd_lfc_set_autoneg_str,
6882 (void *)&cmd_lfc_set_autoneg,
6883 (void *)&cmd_lfc_set_portid,
6889 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6890 __attribute__((unused)) struct cmdline *cl,
6893 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6894 cmdline_parse_inst_t *cmd = data;
6895 struct rte_eth_fc_conf fc_conf;
6901 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6902 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6903 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6904 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6906 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6907 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6910 /* Partial command line, retrieve current configuration */
6912 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6914 printf("cannot get current flow ctrl parameters, return"
6915 "code = %d\n", ret);
6919 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6920 (fc_conf.mode == RTE_FC_FULL))
6922 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6923 (fc_conf.mode == RTE_FC_FULL))
6927 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6928 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6930 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6931 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6933 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6935 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6936 fc_conf.high_water = res->high_water;
6938 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6939 fc_conf.low_water = res->low_water;
6941 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6942 fc_conf.pause_time = res->pause_time;
6944 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6945 fc_conf.send_xon = res->send_xon;
6947 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6948 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6949 fc_conf.mac_ctrl_frame_fwd = 1;
6951 fc_conf.mac_ctrl_frame_fwd = 0;
6954 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6955 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6957 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6959 printf("bad flow contrl parameter, return code = %d \n", ret);
6962 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6963 struct cmd_priority_flow_ctrl_set_result {
6964 cmdline_fixed_string_t set;
6965 cmdline_fixed_string_t pfc_ctrl;
6966 cmdline_fixed_string_t rx;
6967 cmdline_fixed_string_t rx_pfc_mode;
6968 cmdline_fixed_string_t tx;
6969 cmdline_fixed_string_t tx_pfc_mode;
6970 uint32_t high_water;
6972 uint16_t pause_time;
6978 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6979 __attribute__((unused)) struct cmdline *cl,
6980 __attribute__((unused)) void *data)
6982 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6983 struct rte_eth_pfc_conf pfc_conf;
6984 int rx_fc_enable, tx_fc_enable;
6988 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6989 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6990 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6991 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6993 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6994 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6997 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6998 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6999 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7000 pfc_conf.fc.high_water = res->high_water;
7001 pfc_conf.fc.low_water = res->low_water;
7002 pfc_conf.fc.pause_time = res->pause_time;
7003 pfc_conf.priority = res->priority;
7005 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7007 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7010 cmdline_parse_token_string_t cmd_pfc_set_set =
7011 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7013 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7014 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7015 pfc_ctrl, "pfc_ctrl");
7016 cmdline_parse_token_string_t cmd_pfc_set_rx =
7017 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7019 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7020 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7021 rx_pfc_mode, "on#off");
7022 cmdline_parse_token_string_t cmd_pfc_set_tx =
7023 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7025 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7026 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7027 tx_pfc_mode, "on#off");
7028 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7029 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7030 high_water, UINT32);
7031 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7032 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7034 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7035 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7036 pause_time, UINT16);
7037 cmdline_parse_token_num_t cmd_pfc_set_priority =
7038 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7040 cmdline_parse_token_num_t cmd_pfc_set_portid =
7041 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7044 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7045 .f = cmd_priority_flow_ctrl_set_parsed,
7047 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7048 "<pause_time> <priority> <port_id>: "
7049 "Configure the Ethernet priority flow control",
7051 (void *)&cmd_pfc_set_set,
7052 (void *)&cmd_pfc_set_flow_ctrl,
7053 (void *)&cmd_pfc_set_rx,
7054 (void *)&cmd_pfc_set_rx_mode,
7055 (void *)&cmd_pfc_set_tx,
7056 (void *)&cmd_pfc_set_tx_mode,
7057 (void *)&cmd_pfc_set_high_water,
7058 (void *)&cmd_pfc_set_low_water,
7059 (void *)&cmd_pfc_set_pause_time,
7060 (void *)&cmd_pfc_set_priority,
7061 (void *)&cmd_pfc_set_portid,
7066 /* *** RESET CONFIGURATION *** */
7067 struct cmd_reset_result {
7068 cmdline_fixed_string_t reset;
7069 cmdline_fixed_string_t def;
7072 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
7074 __attribute__((unused)) void *data)
7076 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7077 set_def_fwd_config();
7080 cmdline_parse_token_string_t cmd_reset_set =
7081 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7082 cmdline_parse_token_string_t cmd_reset_def =
7083 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7086 cmdline_parse_inst_t cmd_reset = {
7087 .f = cmd_reset_parsed,
7089 .help_str = "set default: Reset default forwarding configuration",
7091 (void *)&cmd_reset_set,
7092 (void *)&cmd_reset_def,
7097 /* *** START FORWARDING *** */
7098 struct cmd_start_result {
7099 cmdline_fixed_string_t start;
7102 cmdline_parse_token_string_t cmd_start_start =
7103 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7105 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
7106 __attribute__((unused)) struct cmdline *cl,
7107 __attribute__((unused)) void *data)
7109 start_packet_forwarding(0);
7112 cmdline_parse_inst_t cmd_start = {
7113 .f = cmd_start_parsed,
7115 .help_str = "start: Start packet forwarding",
7117 (void *)&cmd_start_start,
7122 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7123 struct cmd_start_tx_first_result {
7124 cmdline_fixed_string_t start;
7125 cmdline_fixed_string_t tx_first;
7129 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
7130 __attribute__((unused)) struct cmdline *cl,
7131 __attribute__((unused)) void *data)
7133 start_packet_forwarding(1);
7136 cmdline_parse_token_string_t cmd_start_tx_first_start =
7137 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7139 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7140 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7141 tx_first, "tx_first");
7143 cmdline_parse_inst_t cmd_start_tx_first = {
7144 .f = cmd_start_tx_first_parsed,
7146 .help_str = "start tx_first: Start packet forwarding, "
7147 "after sending 1 burst of packets",
7149 (void *)&cmd_start_tx_first_start,
7150 (void *)&cmd_start_tx_first_tx_first,
7155 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7156 struct cmd_start_tx_first_n_result {
7157 cmdline_fixed_string_t start;
7158 cmdline_fixed_string_t tx_first;
7163 cmd_start_tx_first_n_parsed(void *parsed_result,
7164 __attribute__((unused)) struct cmdline *cl,
7165 __attribute__((unused)) void *data)
7167 struct cmd_start_tx_first_n_result *res = parsed_result;
7169 start_packet_forwarding(res->tx_num);
7172 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7173 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7175 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7176 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7177 tx_first, "tx_first");
7178 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7179 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7182 cmdline_parse_inst_t cmd_start_tx_first_n = {
7183 .f = cmd_start_tx_first_n_parsed,
7185 .help_str = "start tx_first <num>: "
7186 "packet forwarding, after sending <num> bursts of packets",
7188 (void *)&cmd_start_tx_first_n_start,
7189 (void *)&cmd_start_tx_first_n_tx_first,
7190 (void *)&cmd_start_tx_first_n_tx_num,
7195 /* *** SET LINK UP *** */
7196 struct cmd_set_link_up_result {
7197 cmdline_fixed_string_t set;
7198 cmdline_fixed_string_t link_up;
7199 cmdline_fixed_string_t port;
7203 cmdline_parse_token_string_t cmd_set_link_up_set =
7204 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7205 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7206 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7208 cmdline_parse_token_string_t cmd_set_link_up_port =
7209 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7210 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7211 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7213 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
7214 __attribute__((unused)) struct cmdline *cl,
7215 __attribute__((unused)) void *data)
7217 struct cmd_set_link_up_result *res = parsed_result;
7218 dev_set_link_up(res->port_id);
7221 cmdline_parse_inst_t cmd_set_link_up = {
7222 .f = cmd_set_link_up_parsed,
7224 .help_str = "set link-up port <port id>",
7226 (void *)&cmd_set_link_up_set,
7227 (void *)&cmd_set_link_up_link_up,
7228 (void *)&cmd_set_link_up_port,
7229 (void *)&cmd_set_link_up_port_id,
7234 /* *** SET LINK DOWN *** */
7235 struct cmd_set_link_down_result {
7236 cmdline_fixed_string_t set;
7237 cmdline_fixed_string_t link_down;
7238 cmdline_fixed_string_t port;
7242 cmdline_parse_token_string_t cmd_set_link_down_set =
7243 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7244 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7245 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7247 cmdline_parse_token_string_t cmd_set_link_down_port =
7248 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7249 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7250 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7252 static void cmd_set_link_down_parsed(
7253 __attribute__((unused)) void *parsed_result,
7254 __attribute__((unused)) struct cmdline *cl,
7255 __attribute__((unused)) void *data)
7257 struct cmd_set_link_down_result *res = parsed_result;
7258 dev_set_link_down(res->port_id);
7261 cmdline_parse_inst_t cmd_set_link_down = {
7262 .f = cmd_set_link_down_parsed,
7264 .help_str = "set link-down port <port id>",
7266 (void *)&cmd_set_link_down_set,
7267 (void *)&cmd_set_link_down_link_down,
7268 (void *)&cmd_set_link_down_port,
7269 (void *)&cmd_set_link_down_port_id,
7274 /* *** SHOW CFG *** */
7275 struct cmd_showcfg_result {
7276 cmdline_fixed_string_t show;
7277 cmdline_fixed_string_t cfg;
7278 cmdline_fixed_string_t what;
7281 static void cmd_showcfg_parsed(void *parsed_result,
7282 __attribute__((unused)) struct cmdline *cl,
7283 __attribute__((unused)) void *data)
7285 struct cmd_showcfg_result *res = parsed_result;
7286 if (!strcmp(res->what, "rxtx"))
7287 rxtx_config_display();
7288 else if (!strcmp(res->what, "cores"))
7289 fwd_lcores_config_display();
7290 else if (!strcmp(res->what, "fwd"))
7291 pkt_fwd_config_display(&cur_fwd_config);
7292 else if (!strcmp(res->what, "txpkts"))
7293 show_tx_pkt_segments();
7296 cmdline_parse_token_string_t cmd_showcfg_show =
7297 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7298 cmdline_parse_token_string_t cmd_showcfg_port =
7299 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7300 cmdline_parse_token_string_t cmd_showcfg_what =
7301 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7302 "rxtx#cores#fwd#txpkts");
7304 cmdline_parse_inst_t cmd_showcfg = {
7305 .f = cmd_showcfg_parsed,
7307 .help_str = "show config rxtx|cores|fwd|txpkts",
7309 (void *)&cmd_showcfg_show,
7310 (void *)&cmd_showcfg_port,
7311 (void *)&cmd_showcfg_what,
7316 /* *** SHOW ALL PORT INFO *** */
7317 struct cmd_showportall_result {
7318 cmdline_fixed_string_t show;
7319 cmdline_fixed_string_t port;
7320 cmdline_fixed_string_t what;
7321 cmdline_fixed_string_t all;
7324 static void cmd_showportall_parsed(void *parsed_result,
7325 __attribute__((unused)) struct cmdline *cl,
7326 __attribute__((unused)) void *data)
7330 struct cmd_showportall_result *res = parsed_result;
7331 if (!strcmp(res->show, "clear")) {
7332 if (!strcmp(res->what, "stats"))
7333 RTE_ETH_FOREACH_DEV(i)
7335 else if (!strcmp(res->what, "xstats"))
7336 RTE_ETH_FOREACH_DEV(i)
7337 nic_xstats_clear(i);
7338 } else if (!strcmp(res->what, "info"))
7339 RTE_ETH_FOREACH_DEV(i)
7340 port_infos_display(i);
7341 else if (!strcmp(res->what, "summary")) {
7342 port_summary_header_display();
7343 RTE_ETH_FOREACH_DEV(i)
7344 port_summary_display(i);
7346 else if (!strcmp(res->what, "stats"))
7347 RTE_ETH_FOREACH_DEV(i)
7348 nic_stats_display(i);
7349 else if (!strcmp(res->what, "xstats"))
7350 RTE_ETH_FOREACH_DEV(i)
7351 nic_xstats_display(i);
7352 else if (!strcmp(res->what, "fdir"))
7353 RTE_ETH_FOREACH_DEV(i)
7355 else if (!strcmp(res->what, "stat_qmap"))
7356 RTE_ETH_FOREACH_DEV(i)
7357 nic_stats_mapping_display(i);
7358 else if (!strcmp(res->what, "dcb_tc"))
7359 RTE_ETH_FOREACH_DEV(i)
7360 port_dcb_info_display(i);
7361 else if (!strcmp(res->what, "cap"))
7362 RTE_ETH_FOREACH_DEV(i)
7363 port_offload_cap_display(i);
7366 cmdline_parse_token_string_t cmd_showportall_show =
7367 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7369 cmdline_parse_token_string_t cmd_showportall_port =
7370 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7371 cmdline_parse_token_string_t cmd_showportall_what =
7372 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7373 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7374 cmdline_parse_token_string_t cmd_showportall_all =
7375 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7376 cmdline_parse_inst_t cmd_showportall = {
7377 .f = cmd_showportall_parsed,
7379 .help_str = "show|clear port "
7380 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7382 (void *)&cmd_showportall_show,
7383 (void *)&cmd_showportall_port,
7384 (void *)&cmd_showportall_what,
7385 (void *)&cmd_showportall_all,
7390 /* *** SHOW PORT INFO *** */
7391 struct cmd_showport_result {
7392 cmdline_fixed_string_t show;
7393 cmdline_fixed_string_t port;
7394 cmdline_fixed_string_t what;
7398 static void cmd_showport_parsed(void *parsed_result,
7399 __attribute__((unused)) struct cmdline *cl,
7400 __attribute__((unused)) void *data)
7402 struct cmd_showport_result *res = parsed_result;
7403 if (!strcmp(res->show, "clear")) {
7404 if (!strcmp(res->what, "stats"))
7405 nic_stats_clear(res->portnum);
7406 else if (!strcmp(res->what, "xstats"))
7407 nic_xstats_clear(res->portnum);
7408 } else if (!strcmp(res->what, "info"))
7409 port_infos_display(res->portnum);
7410 else if (!strcmp(res->what, "summary")) {
7411 port_summary_header_display();
7412 port_summary_display(res->portnum);
7414 else if (!strcmp(res->what, "stats"))
7415 nic_stats_display(res->portnum);
7416 else if (!strcmp(res->what, "xstats"))
7417 nic_xstats_display(res->portnum);
7418 else if (!strcmp(res->what, "fdir"))
7419 fdir_get_infos(res->portnum);
7420 else if (!strcmp(res->what, "stat_qmap"))
7421 nic_stats_mapping_display(res->portnum);
7422 else if (!strcmp(res->what, "dcb_tc"))
7423 port_dcb_info_display(res->portnum);
7424 else if (!strcmp(res->what, "cap"))
7425 port_offload_cap_display(res->portnum);
7428 cmdline_parse_token_string_t cmd_showport_show =
7429 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7431 cmdline_parse_token_string_t cmd_showport_port =
7432 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7433 cmdline_parse_token_string_t cmd_showport_what =
7434 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7435 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7436 cmdline_parse_token_num_t cmd_showport_portnum =
7437 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7439 cmdline_parse_inst_t cmd_showport = {
7440 .f = cmd_showport_parsed,
7442 .help_str = "show|clear port "
7443 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7446 (void *)&cmd_showport_show,
7447 (void *)&cmd_showport_port,
7448 (void *)&cmd_showport_what,
7449 (void *)&cmd_showport_portnum,
7454 /* *** SHOW DEVICE INFO *** */
7455 struct cmd_showdevice_result {
7456 cmdline_fixed_string_t show;
7457 cmdline_fixed_string_t device;
7458 cmdline_fixed_string_t what;
7459 cmdline_fixed_string_t identifier;
7462 static void cmd_showdevice_parsed(void *parsed_result,
7463 __attribute__((unused)) struct cmdline *cl,
7464 __attribute__((unused)) void *data)
7466 struct cmd_showdevice_result *res = parsed_result;
7467 if (!strcmp(res->what, "info")) {
7468 if (!strcmp(res->identifier, "all"))
7469 device_infos_display(NULL);
7471 device_infos_display(res->identifier);
7475 cmdline_parse_token_string_t cmd_showdevice_show =
7476 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7478 cmdline_parse_token_string_t cmd_showdevice_device =
7479 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7480 cmdline_parse_token_string_t cmd_showdevice_what =
7481 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7483 cmdline_parse_token_string_t cmd_showdevice_identifier =
7484 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7487 cmdline_parse_inst_t cmd_showdevice = {
7488 .f = cmd_showdevice_parsed,
7490 .help_str = "show device info <identifier>|all",
7492 (void *)&cmd_showdevice_show,
7493 (void *)&cmd_showdevice_device,
7494 (void *)&cmd_showdevice_what,
7495 (void *)&cmd_showdevice_identifier,
7499 /* *** SHOW QUEUE INFO *** */
7500 struct cmd_showqueue_result {
7501 cmdline_fixed_string_t show;
7502 cmdline_fixed_string_t type;
7503 cmdline_fixed_string_t what;
7509 cmd_showqueue_parsed(void *parsed_result,
7510 __attribute__((unused)) struct cmdline *cl,
7511 __attribute__((unused)) void *data)
7513 struct cmd_showqueue_result *res = parsed_result;
7515 if (!strcmp(res->type, "rxq"))
7516 rx_queue_infos_display(res->portnum, res->queuenum);
7517 else if (!strcmp(res->type, "txq"))
7518 tx_queue_infos_display(res->portnum, res->queuenum);
7521 cmdline_parse_token_string_t cmd_showqueue_show =
7522 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7523 cmdline_parse_token_string_t cmd_showqueue_type =
7524 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7525 cmdline_parse_token_string_t cmd_showqueue_what =
7526 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7527 cmdline_parse_token_num_t cmd_showqueue_portnum =
7528 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7529 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7530 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7532 cmdline_parse_inst_t cmd_showqueue = {
7533 .f = cmd_showqueue_parsed,
7535 .help_str = "show rxq|txq info <port_id> <queue_id>",
7537 (void *)&cmd_showqueue_show,
7538 (void *)&cmd_showqueue_type,
7539 (void *)&cmd_showqueue_what,
7540 (void *)&cmd_showqueue_portnum,
7541 (void *)&cmd_showqueue_queuenum,
7546 /* show/clear fwd engine statistics */
7548 cmdline_fixed_string_t action;
7549 cmdline_fixed_string_t fwd;
7550 cmdline_fixed_string_t stats;
7551 cmdline_fixed_string_t all;
7554 cmdline_parse_token_string_t cmd_fwd_action =
7555 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7556 cmdline_parse_token_string_t cmd_fwd_fwd =
7557 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7558 cmdline_parse_token_string_t cmd_fwd_stats =
7559 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7560 cmdline_parse_token_string_t cmd_fwd_all =
7561 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7564 cmd_showfwdall_parsed(void *parsed_result,
7565 __rte_unused struct cmdline *cl,
7566 __rte_unused void *data)
7568 struct fwd_result *res = parsed_result;
7570 if (!strcmp(res->action, "show"))
7571 fwd_stats_display();
7576 static cmdline_parse_inst_t cmd_showfwdall = {
7577 .f = cmd_showfwdall_parsed,
7579 .help_str = "show|clear fwd stats all",
7581 (void *)&cmd_fwd_action,
7582 (void *)&cmd_fwd_fwd,
7583 (void *)&cmd_fwd_stats,
7584 (void *)&cmd_fwd_all,
7589 /* *** READ PORT REGISTER *** */
7590 struct cmd_read_reg_result {
7591 cmdline_fixed_string_t read;
7592 cmdline_fixed_string_t reg;
7598 cmd_read_reg_parsed(void *parsed_result,
7599 __attribute__((unused)) struct cmdline *cl,
7600 __attribute__((unused)) void *data)
7602 struct cmd_read_reg_result *res = parsed_result;
7603 port_reg_display(res->port_id, res->reg_off);
7606 cmdline_parse_token_string_t cmd_read_reg_read =
7607 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7608 cmdline_parse_token_string_t cmd_read_reg_reg =
7609 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7610 cmdline_parse_token_num_t cmd_read_reg_port_id =
7611 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7612 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7613 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7615 cmdline_parse_inst_t cmd_read_reg = {
7616 .f = cmd_read_reg_parsed,
7618 .help_str = "read reg <port_id> <reg_off>",
7620 (void *)&cmd_read_reg_read,
7621 (void *)&cmd_read_reg_reg,
7622 (void *)&cmd_read_reg_port_id,
7623 (void *)&cmd_read_reg_reg_off,
7628 /* *** READ PORT REGISTER BIT FIELD *** */
7629 struct cmd_read_reg_bit_field_result {
7630 cmdline_fixed_string_t read;
7631 cmdline_fixed_string_t regfield;
7639 cmd_read_reg_bit_field_parsed(void *parsed_result,
7640 __attribute__((unused)) struct cmdline *cl,
7641 __attribute__((unused)) void *data)
7643 struct cmd_read_reg_bit_field_result *res = parsed_result;
7644 port_reg_bit_field_display(res->port_id, res->reg_off,
7645 res->bit1_pos, res->bit2_pos);
7648 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7649 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7651 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7652 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7653 regfield, "regfield");
7654 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7655 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7657 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7658 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7660 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7661 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7663 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7664 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7667 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7668 .f = cmd_read_reg_bit_field_parsed,
7670 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7671 "Read register bit field between bit_x and bit_y included",
7673 (void *)&cmd_read_reg_bit_field_read,
7674 (void *)&cmd_read_reg_bit_field_regfield,
7675 (void *)&cmd_read_reg_bit_field_port_id,
7676 (void *)&cmd_read_reg_bit_field_reg_off,
7677 (void *)&cmd_read_reg_bit_field_bit1_pos,
7678 (void *)&cmd_read_reg_bit_field_bit2_pos,
7683 /* *** READ PORT REGISTER BIT *** */
7684 struct cmd_read_reg_bit_result {
7685 cmdline_fixed_string_t read;
7686 cmdline_fixed_string_t regbit;
7693 cmd_read_reg_bit_parsed(void *parsed_result,
7694 __attribute__((unused)) struct cmdline *cl,
7695 __attribute__((unused)) void *data)
7697 struct cmd_read_reg_bit_result *res = parsed_result;
7698 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7701 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7702 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7703 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7704 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7706 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7707 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7708 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7709 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7710 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7711 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7713 cmdline_parse_inst_t cmd_read_reg_bit = {
7714 .f = cmd_read_reg_bit_parsed,
7716 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7718 (void *)&cmd_read_reg_bit_read,
7719 (void *)&cmd_read_reg_bit_regbit,
7720 (void *)&cmd_read_reg_bit_port_id,
7721 (void *)&cmd_read_reg_bit_reg_off,
7722 (void *)&cmd_read_reg_bit_bit_pos,
7727 /* *** WRITE PORT REGISTER *** */
7728 struct cmd_write_reg_result {
7729 cmdline_fixed_string_t write;
7730 cmdline_fixed_string_t reg;
7737 cmd_write_reg_parsed(void *parsed_result,
7738 __attribute__((unused)) struct cmdline *cl,
7739 __attribute__((unused)) void *data)
7741 struct cmd_write_reg_result *res = parsed_result;
7742 port_reg_set(res->port_id, res->reg_off, res->value);
7745 cmdline_parse_token_string_t cmd_write_reg_write =
7746 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7747 cmdline_parse_token_string_t cmd_write_reg_reg =
7748 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7749 cmdline_parse_token_num_t cmd_write_reg_port_id =
7750 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7751 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7752 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7753 cmdline_parse_token_num_t cmd_write_reg_value =
7754 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7756 cmdline_parse_inst_t cmd_write_reg = {
7757 .f = cmd_write_reg_parsed,
7759 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7761 (void *)&cmd_write_reg_write,
7762 (void *)&cmd_write_reg_reg,
7763 (void *)&cmd_write_reg_port_id,
7764 (void *)&cmd_write_reg_reg_off,
7765 (void *)&cmd_write_reg_value,
7770 /* *** WRITE PORT REGISTER BIT FIELD *** */
7771 struct cmd_write_reg_bit_field_result {
7772 cmdline_fixed_string_t write;
7773 cmdline_fixed_string_t regfield;
7782 cmd_write_reg_bit_field_parsed(void *parsed_result,
7783 __attribute__((unused)) struct cmdline *cl,
7784 __attribute__((unused)) void *data)
7786 struct cmd_write_reg_bit_field_result *res = parsed_result;
7787 port_reg_bit_field_set(res->port_id, res->reg_off,
7788 res->bit1_pos, res->bit2_pos, res->value);
7791 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7792 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7794 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7795 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7796 regfield, "regfield");
7797 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7798 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7800 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7801 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7803 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7804 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7806 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7807 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7809 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7810 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7813 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7814 .f = cmd_write_reg_bit_field_parsed,
7816 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7818 "Set register bit field between bit_x and bit_y included",
7820 (void *)&cmd_write_reg_bit_field_write,
7821 (void *)&cmd_write_reg_bit_field_regfield,
7822 (void *)&cmd_write_reg_bit_field_port_id,
7823 (void *)&cmd_write_reg_bit_field_reg_off,
7824 (void *)&cmd_write_reg_bit_field_bit1_pos,
7825 (void *)&cmd_write_reg_bit_field_bit2_pos,
7826 (void *)&cmd_write_reg_bit_field_value,
7831 /* *** WRITE PORT REGISTER BIT *** */
7832 struct cmd_write_reg_bit_result {
7833 cmdline_fixed_string_t write;
7834 cmdline_fixed_string_t regbit;
7842 cmd_write_reg_bit_parsed(void *parsed_result,
7843 __attribute__((unused)) struct cmdline *cl,
7844 __attribute__((unused)) void *data)
7846 struct cmd_write_reg_bit_result *res = parsed_result;
7847 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7850 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7851 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7853 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7854 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7856 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7857 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7858 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7859 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7860 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7861 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7862 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7863 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7865 cmdline_parse_inst_t cmd_write_reg_bit = {
7866 .f = cmd_write_reg_bit_parsed,
7868 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7871 (void *)&cmd_write_reg_bit_write,
7872 (void *)&cmd_write_reg_bit_regbit,
7873 (void *)&cmd_write_reg_bit_port_id,
7874 (void *)&cmd_write_reg_bit_reg_off,
7875 (void *)&cmd_write_reg_bit_bit_pos,
7876 (void *)&cmd_write_reg_bit_value,
7881 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7882 struct cmd_read_rxd_txd_result {
7883 cmdline_fixed_string_t read;
7884 cmdline_fixed_string_t rxd_txd;
7891 cmd_read_rxd_txd_parsed(void *parsed_result,
7892 __attribute__((unused)) struct cmdline *cl,
7893 __attribute__((unused)) void *data)
7895 struct cmd_read_rxd_txd_result *res = parsed_result;
7897 if (!strcmp(res->rxd_txd, "rxd"))
7898 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7899 else if (!strcmp(res->rxd_txd, "txd"))
7900 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7903 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7904 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7905 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7906 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7908 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7909 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7910 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7911 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7912 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7913 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7915 cmdline_parse_inst_t cmd_read_rxd_txd = {
7916 .f = cmd_read_rxd_txd_parsed,
7918 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7920 (void *)&cmd_read_rxd_txd_read,
7921 (void *)&cmd_read_rxd_txd_rxd_txd,
7922 (void *)&cmd_read_rxd_txd_port_id,
7923 (void *)&cmd_read_rxd_txd_queue_id,
7924 (void *)&cmd_read_rxd_txd_desc_id,
7930 struct cmd_quit_result {
7931 cmdline_fixed_string_t quit;
7934 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7936 __attribute__((unused)) void *data)
7941 cmdline_parse_token_string_t cmd_quit_quit =
7942 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7944 cmdline_parse_inst_t cmd_quit = {
7945 .f = cmd_quit_parsed,
7947 .help_str = "quit: Exit application",
7949 (void *)&cmd_quit_quit,
7954 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7955 struct cmd_mac_addr_result {
7956 cmdline_fixed_string_t mac_addr_cmd;
7957 cmdline_fixed_string_t what;
7959 struct rte_ether_addr address;
7962 static void cmd_mac_addr_parsed(void *parsed_result,
7963 __attribute__((unused)) struct cmdline *cl,
7964 __attribute__((unused)) void *data)
7966 struct cmd_mac_addr_result *res = parsed_result;
7969 if (strcmp(res->what, "add") == 0)
7970 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7971 else if (strcmp(res->what, "set") == 0)
7972 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7975 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7977 /* check the return value and print it if is < 0 */
7979 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7983 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7984 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7986 cmdline_parse_token_string_t cmd_mac_addr_what =
7987 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7989 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7990 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7992 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7993 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7995 cmdline_parse_inst_t cmd_mac_addr = {
7996 .f = cmd_mac_addr_parsed,
7998 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7999 "Add/Remove/Set MAC address on port_id",
8001 (void *)&cmd_mac_addr_cmd,
8002 (void *)&cmd_mac_addr_what,
8003 (void *)&cmd_mac_addr_portnum,
8004 (void *)&cmd_mac_addr_addr,
8009 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8010 struct cmd_eth_peer_result {
8011 cmdline_fixed_string_t set;
8012 cmdline_fixed_string_t eth_peer;
8014 cmdline_fixed_string_t peer_addr;
8017 static void cmd_set_eth_peer_parsed(void *parsed_result,
8018 __attribute__((unused)) struct cmdline *cl,
8019 __attribute__((unused)) void *data)
8021 struct cmd_eth_peer_result *res = parsed_result;
8023 if (test_done == 0) {
8024 printf("Please stop forwarding first\n");
8027 if (!strcmp(res->eth_peer, "eth-peer")) {
8028 set_fwd_eth_peer(res->port_id, res->peer_addr);
8032 cmdline_parse_token_string_t cmd_eth_peer_set =
8033 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8034 cmdline_parse_token_string_t cmd_eth_peer =
8035 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8036 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8037 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8038 cmdline_parse_token_string_t cmd_eth_peer_addr =
8039 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8041 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8042 .f = cmd_set_eth_peer_parsed,
8044 .help_str = "set eth-peer <port_id> <peer_mac>",
8046 (void *)&cmd_eth_peer_set,
8047 (void *)&cmd_eth_peer,
8048 (void *)&cmd_eth_peer_port_id,
8049 (void *)&cmd_eth_peer_addr,
8054 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8055 struct cmd_set_qmap_result {
8056 cmdline_fixed_string_t set;
8057 cmdline_fixed_string_t qmap;
8058 cmdline_fixed_string_t what;
8065 cmd_set_qmap_parsed(void *parsed_result,
8066 __attribute__((unused)) struct cmdline *cl,
8067 __attribute__((unused)) void *data)
8069 struct cmd_set_qmap_result *res = parsed_result;
8070 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8072 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8075 cmdline_parse_token_string_t cmd_setqmap_set =
8076 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8078 cmdline_parse_token_string_t cmd_setqmap_qmap =
8079 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8081 cmdline_parse_token_string_t cmd_setqmap_what =
8082 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8084 cmdline_parse_token_num_t cmd_setqmap_portid =
8085 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8087 cmdline_parse_token_num_t cmd_setqmap_queueid =
8088 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8090 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8091 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8094 cmdline_parse_inst_t cmd_set_qmap = {
8095 .f = cmd_set_qmap_parsed,
8097 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8098 "Set statistics mapping value on tx|rx queue_id of port_id",
8100 (void *)&cmd_setqmap_set,
8101 (void *)&cmd_setqmap_qmap,
8102 (void *)&cmd_setqmap_what,
8103 (void *)&cmd_setqmap_portid,
8104 (void *)&cmd_setqmap_queueid,
8105 (void *)&cmd_setqmap_mapvalue,
8110 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8111 struct cmd_set_xstats_hide_zero_result {
8112 cmdline_fixed_string_t keyword;
8113 cmdline_fixed_string_t name;
8114 cmdline_fixed_string_t on_off;
8118 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8119 __attribute__((unused)) struct cmdline *cl,
8120 __attribute__((unused)) void *data)
8122 struct cmd_set_xstats_hide_zero_result *res;
8123 uint16_t on_off = 0;
8125 res = parsed_result;
8126 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8127 set_xstats_hide_zero(on_off);
8130 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8131 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8133 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8134 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8135 name, "xstats-hide-zero");
8136 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8137 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8140 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8141 .f = cmd_set_xstats_hide_zero_parsed,
8143 .help_str = "set xstats-hide-zero on|off",
8145 (void *)&cmd_set_xstats_hide_zero_keyword,
8146 (void *)&cmd_set_xstats_hide_zero_name,
8147 (void *)&cmd_set_xstats_hide_zero_on_off,
8152 /* *** CONFIGURE UNICAST HASH TABLE *** */
8153 struct cmd_set_uc_hash_table {
8154 cmdline_fixed_string_t set;
8155 cmdline_fixed_string_t port;
8157 cmdline_fixed_string_t what;
8158 struct rte_ether_addr address;
8159 cmdline_fixed_string_t mode;
8163 cmd_set_uc_hash_parsed(void *parsed_result,
8164 __attribute__((unused)) struct cmdline *cl,
8165 __attribute__((unused)) void *data)
8168 struct cmd_set_uc_hash_table *res = parsed_result;
8170 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8172 if (strcmp(res->what, "uta") == 0)
8173 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8174 &res->address,(uint8_t)is_on);
8176 printf("bad unicast hash table parameter, return code = %d \n", ret);
8180 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8181 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8183 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8184 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8186 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8187 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8189 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8190 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8192 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8193 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8195 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8196 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8199 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8200 .f = cmd_set_uc_hash_parsed,
8202 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8204 (void *)&cmd_set_uc_hash_set,
8205 (void *)&cmd_set_uc_hash_port,
8206 (void *)&cmd_set_uc_hash_portid,
8207 (void *)&cmd_set_uc_hash_what,
8208 (void *)&cmd_set_uc_hash_mac,
8209 (void *)&cmd_set_uc_hash_mode,
8214 struct cmd_set_uc_all_hash_table {
8215 cmdline_fixed_string_t set;
8216 cmdline_fixed_string_t port;
8218 cmdline_fixed_string_t what;
8219 cmdline_fixed_string_t value;
8220 cmdline_fixed_string_t mode;
8224 cmd_set_uc_all_hash_parsed(void *parsed_result,
8225 __attribute__((unused)) struct cmdline *cl,
8226 __attribute__((unused)) void *data)
8229 struct cmd_set_uc_all_hash_table *res = parsed_result;
8231 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8233 if ((strcmp(res->what, "uta") == 0) &&
8234 (strcmp(res->value, "all") == 0))
8235 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8237 printf("bad unicast hash table parameter,"
8238 "return code = %d \n", ret);
8241 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8242 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8244 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8245 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8247 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8248 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8250 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8251 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8253 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8254 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8256 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8257 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8260 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8261 .f = cmd_set_uc_all_hash_parsed,
8263 .help_str = "set port <port_id> uta all on|off",
8265 (void *)&cmd_set_uc_all_hash_set,
8266 (void *)&cmd_set_uc_all_hash_port,
8267 (void *)&cmd_set_uc_all_hash_portid,
8268 (void *)&cmd_set_uc_all_hash_what,
8269 (void *)&cmd_set_uc_all_hash_value,
8270 (void *)&cmd_set_uc_all_hash_mode,
8275 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8276 struct cmd_set_vf_macvlan_filter {
8277 cmdline_fixed_string_t set;
8278 cmdline_fixed_string_t port;
8280 cmdline_fixed_string_t vf;
8282 struct rte_ether_addr address;
8283 cmdline_fixed_string_t filter_type;
8284 cmdline_fixed_string_t mode;
8288 cmd_set_vf_macvlan_parsed(void *parsed_result,
8289 __attribute__((unused)) struct cmdline *cl,
8290 __attribute__((unused)) void *data)
8293 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8294 struct rte_eth_mac_filter filter;
8296 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8298 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8300 /* set VF MAC filter */
8304 filter.dst_id = res->vf_id;
8306 if (!strcmp(res->filter_type, "exact-mac"))
8307 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8308 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8309 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8310 else if (!strcmp(res->filter_type, "hashmac"))
8311 filter.filter_type = RTE_MAC_HASH_MATCH;
8312 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8313 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8315 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8318 ret = rte_eth_dev_filter_ctrl(res->port_id,
8319 RTE_ETH_FILTER_MACVLAN,
8323 ret = rte_eth_dev_filter_ctrl(res->port_id,
8324 RTE_ETH_FILTER_MACVLAN,
8325 RTE_ETH_FILTER_DELETE,
8329 printf("bad set MAC hash parameter, return code = %d\n", ret);
8333 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8334 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8336 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8337 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8339 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8340 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8342 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8343 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8345 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8346 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8348 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8349 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8351 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8352 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8353 filter_type, "exact-mac#exact-mac-vlan"
8354 "#hashmac#hashmac-vlan");
8355 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8356 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8359 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8360 .f = cmd_set_vf_macvlan_parsed,
8362 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8363 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8364 "Exact match rule: exact match of MAC or MAC and VLAN; "
8365 "hash match rule: hash match of MAC and exact match of VLAN",
8367 (void *)&cmd_set_vf_macvlan_set,
8368 (void *)&cmd_set_vf_macvlan_port,
8369 (void *)&cmd_set_vf_macvlan_portid,
8370 (void *)&cmd_set_vf_macvlan_vf,
8371 (void *)&cmd_set_vf_macvlan_vf_id,
8372 (void *)&cmd_set_vf_macvlan_mac,
8373 (void *)&cmd_set_vf_macvlan_filter_type,
8374 (void *)&cmd_set_vf_macvlan_mode,
8379 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8380 struct cmd_set_vf_traffic {
8381 cmdline_fixed_string_t set;
8382 cmdline_fixed_string_t port;
8384 cmdline_fixed_string_t vf;
8386 cmdline_fixed_string_t what;
8387 cmdline_fixed_string_t mode;
8391 cmd_set_vf_traffic_parsed(void *parsed_result,
8392 __attribute__((unused)) struct cmdline *cl,
8393 __attribute__((unused)) void *data)
8395 struct cmd_set_vf_traffic *res = parsed_result;
8396 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8397 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8399 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8402 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8403 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8405 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8406 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8408 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8409 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8411 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8412 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8414 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8415 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8417 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8418 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8420 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8421 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8424 cmdline_parse_inst_t cmd_set_vf_traffic = {
8425 .f = cmd_set_vf_traffic_parsed,
8427 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8429 (void *)&cmd_setvf_traffic_set,
8430 (void *)&cmd_setvf_traffic_port,
8431 (void *)&cmd_setvf_traffic_portid,
8432 (void *)&cmd_setvf_traffic_vf,
8433 (void *)&cmd_setvf_traffic_vfid,
8434 (void *)&cmd_setvf_traffic_what,
8435 (void *)&cmd_setvf_traffic_mode,
8440 /* *** CONFIGURE VF RECEIVE MODE *** */
8441 struct cmd_set_vf_rxmode {
8442 cmdline_fixed_string_t set;
8443 cmdline_fixed_string_t port;
8445 cmdline_fixed_string_t vf;
8447 cmdline_fixed_string_t what;
8448 cmdline_fixed_string_t mode;
8449 cmdline_fixed_string_t on;
8453 cmd_set_vf_rxmode_parsed(void *parsed_result,
8454 __attribute__((unused)) struct cmdline *cl,
8455 __attribute__((unused)) void *data)
8458 uint16_t vf_rxmode = 0;
8459 struct cmd_set_vf_rxmode *res = parsed_result;
8461 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8462 if (!strcmp(res->what,"rxmode")) {
8463 if (!strcmp(res->mode, "AUPE"))
8464 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8465 else if (!strcmp(res->mode, "ROPE"))
8466 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8467 else if (!strcmp(res->mode, "BAM"))
8468 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8469 else if (!strncmp(res->mode, "MPE",3))
8470 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8473 RTE_SET_USED(is_on);
8475 #ifdef RTE_LIBRTE_IXGBE_PMD
8476 if (ret == -ENOTSUP)
8477 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8478 vf_rxmode, (uint8_t)is_on);
8480 #ifdef RTE_LIBRTE_BNXT_PMD
8481 if (ret == -ENOTSUP)
8482 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8483 vf_rxmode, (uint8_t)is_on);
8486 printf("bad VF receive mode parameter, return code = %d \n",
8490 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8491 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8493 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8494 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8496 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8497 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8499 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8500 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8502 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8503 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8505 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8506 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8508 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8509 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8510 mode, "AUPE#ROPE#BAM#MPE");
8511 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8512 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8515 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8516 .f = cmd_set_vf_rxmode_parsed,
8518 .help_str = "set port <port_id> vf <vf_id> rxmode "
8519 "AUPE|ROPE|BAM|MPE on|off",
8521 (void *)&cmd_set_vf_rxmode_set,
8522 (void *)&cmd_set_vf_rxmode_port,
8523 (void *)&cmd_set_vf_rxmode_portid,
8524 (void *)&cmd_set_vf_rxmode_vf,
8525 (void *)&cmd_set_vf_rxmode_vfid,
8526 (void *)&cmd_set_vf_rxmode_what,
8527 (void *)&cmd_set_vf_rxmode_mode,
8528 (void *)&cmd_set_vf_rxmode_on,
8533 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8534 struct cmd_vf_mac_addr_result {
8535 cmdline_fixed_string_t mac_addr_cmd;
8536 cmdline_fixed_string_t what;
8537 cmdline_fixed_string_t port;
8539 cmdline_fixed_string_t vf;
8541 struct rte_ether_addr address;
8544 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8545 __attribute__((unused)) struct cmdline *cl,
8546 __attribute__((unused)) void *data)
8548 struct cmd_vf_mac_addr_result *res = parsed_result;
8551 if (strcmp(res->what, "add") != 0)
8554 #ifdef RTE_LIBRTE_I40E_PMD
8555 if (ret == -ENOTSUP)
8556 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8559 #ifdef RTE_LIBRTE_BNXT_PMD
8560 if (ret == -ENOTSUP)
8561 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8566 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8570 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8571 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8572 mac_addr_cmd,"mac_addr");
8573 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8574 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8576 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8577 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8579 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8580 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8582 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8583 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8585 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8586 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8588 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8589 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8592 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8593 .f = cmd_vf_mac_addr_parsed,
8595 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8596 "Add MAC address filtering for a VF on port_id",
8598 (void *)&cmd_vf_mac_addr_cmd,
8599 (void *)&cmd_vf_mac_addr_what,
8600 (void *)&cmd_vf_mac_addr_port,
8601 (void *)&cmd_vf_mac_addr_portnum,
8602 (void *)&cmd_vf_mac_addr_vf,
8603 (void *)&cmd_vf_mac_addr_vfnum,
8604 (void *)&cmd_vf_mac_addr_addr,
8609 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8610 struct cmd_vf_rx_vlan_filter {
8611 cmdline_fixed_string_t rx_vlan;
8612 cmdline_fixed_string_t what;
8614 cmdline_fixed_string_t port;
8616 cmdline_fixed_string_t vf;
8621 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8622 __attribute__((unused)) struct cmdline *cl,
8623 __attribute__((unused)) void *data)
8625 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8628 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8630 #ifdef RTE_LIBRTE_IXGBE_PMD
8631 if (ret == -ENOTSUP)
8632 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8633 res->vlan_id, res->vf_mask, is_add);
8635 #ifdef RTE_LIBRTE_I40E_PMD
8636 if (ret == -ENOTSUP)
8637 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8638 res->vlan_id, res->vf_mask, is_add);
8640 #ifdef RTE_LIBRTE_BNXT_PMD
8641 if (ret == -ENOTSUP)
8642 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8643 res->vlan_id, res->vf_mask, is_add);
8650 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8651 res->vlan_id, res->vf_mask);
8654 printf("invalid port_id %d\n", res->port_id);
8657 printf("function not implemented or supported\n");
8660 printf("programming error: (%s)\n", strerror(-ret));
8664 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8665 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8666 rx_vlan, "rx_vlan");
8667 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8668 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8670 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8671 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8673 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8674 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8676 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8677 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8679 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8680 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8682 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8683 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8686 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8687 .f = cmd_vf_rx_vlan_filter_parsed,
8689 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8690 "(vf_mask = hexadecimal VF mask)",
8692 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8693 (void *)&cmd_vf_rx_vlan_filter_what,
8694 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8695 (void *)&cmd_vf_rx_vlan_filter_port,
8696 (void *)&cmd_vf_rx_vlan_filter_portid,
8697 (void *)&cmd_vf_rx_vlan_filter_vf,
8698 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8703 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8704 struct cmd_queue_rate_limit_result {
8705 cmdline_fixed_string_t set;
8706 cmdline_fixed_string_t port;
8708 cmdline_fixed_string_t queue;
8710 cmdline_fixed_string_t rate;
8714 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8715 __attribute__((unused)) struct cmdline *cl,
8716 __attribute__((unused)) void *data)
8718 struct cmd_queue_rate_limit_result *res = parsed_result;
8721 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8722 && (strcmp(res->queue, "queue") == 0)
8723 && (strcmp(res->rate, "rate") == 0))
8724 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8727 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8731 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8732 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8734 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8735 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8737 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8738 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8740 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8741 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8743 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8744 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8746 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8747 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8749 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8750 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8753 cmdline_parse_inst_t cmd_queue_rate_limit = {
8754 .f = cmd_queue_rate_limit_parsed,
8756 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8757 "Set rate limit for a queue on port_id",
8759 (void *)&cmd_queue_rate_limit_set,
8760 (void *)&cmd_queue_rate_limit_port,
8761 (void *)&cmd_queue_rate_limit_portnum,
8762 (void *)&cmd_queue_rate_limit_queue,
8763 (void *)&cmd_queue_rate_limit_queuenum,
8764 (void *)&cmd_queue_rate_limit_rate,
8765 (void *)&cmd_queue_rate_limit_ratenum,
8770 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8771 struct cmd_vf_rate_limit_result {
8772 cmdline_fixed_string_t set;
8773 cmdline_fixed_string_t port;
8775 cmdline_fixed_string_t vf;
8777 cmdline_fixed_string_t rate;
8779 cmdline_fixed_string_t q_msk;
8783 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8784 __attribute__((unused)) struct cmdline *cl,
8785 __attribute__((unused)) void *data)
8787 struct cmd_vf_rate_limit_result *res = parsed_result;
8790 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8791 && (strcmp(res->vf, "vf") == 0)
8792 && (strcmp(res->rate, "rate") == 0)
8793 && (strcmp(res->q_msk, "queue_mask") == 0))
8794 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8795 res->rate_num, res->q_msk_val);
8797 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8801 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8802 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8804 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8805 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8807 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8808 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8810 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8811 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8813 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8814 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8816 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8817 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8819 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8820 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8822 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8823 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8824 q_msk, "queue_mask");
8825 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8826 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8829 cmdline_parse_inst_t cmd_vf_rate_limit = {
8830 .f = cmd_vf_rate_limit_parsed,
8832 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8833 "queue_mask <queue_mask_value>: "
8834 "Set rate limit for queues of VF on port_id",
8836 (void *)&cmd_vf_rate_limit_set,
8837 (void *)&cmd_vf_rate_limit_port,
8838 (void *)&cmd_vf_rate_limit_portnum,
8839 (void *)&cmd_vf_rate_limit_vf,
8840 (void *)&cmd_vf_rate_limit_vfnum,
8841 (void *)&cmd_vf_rate_limit_rate,
8842 (void *)&cmd_vf_rate_limit_ratenum,
8843 (void *)&cmd_vf_rate_limit_q_msk,
8844 (void *)&cmd_vf_rate_limit_q_msk_val,
8849 /* *** ADD TUNNEL FILTER OF A PORT *** */
8850 struct cmd_tunnel_filter_result {
8851 cmdline_fixed_string_t cmd;
8852 cmdline_fixed_string_t what;
8854 struct rte_ether_addr outer_mac;
8855 struct rte_ether_addr inner_mac;
8856 cmdline_ipaddr_t ip_value;
8857 uint16_t inner_vlan;
8858 cmdline_fixed_string_t tunnel_type;
8859 cmdline_fixed_string_t filter_type;
8865 cmd_tunnel_filter_parsed(void *parsed_result,
8866 __attribute__((unused)) struct cmdline *cl,
8867 __attribute__((unused)) void *data)
8869 struct cmd_tunnel_filter_result *res = parsed_result;
8870 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8873 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8875 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8876 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8877 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8879 if (res->ip_value.family == AF_INET) {
8880 tunnel_filter_conf.ip_addr.ipv4_addr =
8881 res->ip_value.addr.ipv4.s_addr;
8882 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8884 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8885 &(res->ip_value.addr.ipv6),
8886 sizeof(struct in6_addr));
8887 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8890 if (!strcmp(res->filter_type, "imac-ivlan"))
8891 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8892 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8893 tunnel_filter_conf.filter_type =
8894 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8895 else if (!strcmp(res->filter_type, "imac-tenid"))
8896 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8897 else if (!strcmp(res->filter_type, "imac"))
8898 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8899 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8900 tunnel_filter_conf.filter_type =
8901 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8902 else if (!strcmp(res->filter_type, "oip"))
8903 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8904 else if (!strcmp(res->filter_type, "iip"))
8905 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8907 printf("The filter type is not supported");
8911 if (!strcmp(res->tunnel_type, "vxlan"))
8912 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8913 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
8914 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
8915 else if (!strcmp(res->tunnel_type, "nvgre"))
8916 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8917 else if (!strcmp(res->tunnel_type, "ipingre"))
8918 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8920 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8924 tunnel_filter_conf.tenant_id = res->tenant_id;
8925 tunnel_filter_conf.queue_id = res->queue_num;
8926 if (!strcmp(res->what, "add"))
8927 ret = rte_eth_dev_filter_ctrl(res->port_id,
8928 RTE_ETH_FILTER_TUNNEL,
8930 &tunnel_filter_conf);
8932 ret = rte_eth_dev_filter_ctrl(res->port_id,
8933 RTE_ETH_FILTER_TUNNEL,
8934 RTE_ETH_FILTER_DELETE,
8935 &tunnel_filter_conf);
8937 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8941 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8942 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8943 cmd, "tunnel_filter");
8944 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8945 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8947 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8948 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8950 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8951 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8953 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8954 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8956 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8957 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8958 inner_vlan, UINT16);
8959 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8960 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8962 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8963 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8964 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
8966 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8967 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8968 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8969 "imac#omac-imac-tenid");
8970 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8971 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8973 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8974 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8977 cmdline_parse_inst_t cmd_tunnel_filter = {
8978 .f = cmd_tunnel_filter_parsed,
8980 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8981 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8982 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8983 "<queue_id>: Add/Rm tunnel filter of a port",
8985 (void *)&cmd_tunnel_filter_cmd,
8986 (void *)&cmd_tunnel_filter_what,
8987 (void *)&cmd_tunnel_filter_port_id,
8988 (void *)&cmd_tunnel_filter_outer_mac,
8989 (void *)&cmd_tunnel_filter_inner_mac,
8990 (void *)&cmd_tunnel_filter_ip_value,
8991 (void *)&cmd_tunnel_filter_innner_vlan,
8992 (void *)&cmd_tunnel_filter_tunnel_type,
8993 (void *)&cmd_tunnel_filter_filter_type,
8994 (void *)&cmd_tunnel_filter_tenant_id,
8995 (void *)&cmd_tunnel_filter_queue_num,
9000 /* *** CONFIGURE TUNNEL UDP PORT *** */
9001 struct cmd_tunnel_udp_config {
9002 cmdline_fixed_string_t cmd;
9003 cmdline_fixed_string_t what;
9009 cmd_tunnel_udp_config_parsed(void *parsed_result,
9010 __attribute__((unused)) struct cmdline *cl,
9011 __attribute__((unused)) void *data)
9013 struct cmd_tunnel_udp_config *res = parsed_result;
9014 struct rte_eth_udp_tunnel tunnel_udp;
9017 tunnel_udp.udp_port = res->udp_port;
9019 if (!strcmp(res->cmd, "rx_vxlan_port"))
9020 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9022 if (!strcmp(res->what, "add"))
9023 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9026 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9030 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9033 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9034 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9035 cmd, "rx_vxlan_port");
9036 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9037 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9039 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9040 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9042 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9043 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9046 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9047 .f = cmd_tunnel_udp_config_parsed,
9049 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9050 "Add/Remove a tunneling UDP port filter",
9052 (void *)&cmd_tunnel_udp_config_cmd,
9053 (void *)&cmd_tunnel_udp_config_what,
9054 (void *)&cmd_tunnel_udp_config_udp_port,
9055 (void *)&cmd_tunnel_udp_config_port_id,
9060 struct cmd_config_tunnel_udp_port {
9061 cmdline_fixed_string_t port;
9062 cmdline_fixed_string_t config;
9064 cmdline_fixed_string_t udp_tunnel_port;
9065 cmdline_fixed_string_t action;
9066 cmdline_fixed_string_t tunnel_type;
9071 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9072 __attribute__((unused)) struct cmdline *cl,
9073 __attribute__((unused)) void *data)
9075 struct cmd_config_tunnel_udp_port *res = parsed_result;
9076 struct rte_eth_udp_tunnel tunnel_udp;
9079 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9082 tunnel_udp.udp_port = res->udp_port;
9084 if (!strcmp(res->tunnel_type, "vxlan")) {
9085 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9086 } else if (!strcmp(res->tunnel_type, "geneve")) {
9087 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9088 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9089 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9091 printf("Invalid tunnel type\n");
9095 if (!strcmp(res->action, "add"))
9096 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9099 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9103 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9106 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9107 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9109 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9110 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9112 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9113 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9115 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9116 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9119 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9120 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9122 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9123 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9124 "vxlan#geneve#vxlan-gpe");
9125 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9126 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9129 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9130 .f = cmd_cfg_tunnel_udp_port_parsed,
9132 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9134 (void *)&cmd_config_tunnel_udp_port_port,
9135 (void *)&cmd_config_tunnel_udp_port_config,
9136 (void *)&cmd_config_tunnel_udp_port_port_id,
9137 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9138 (void *)&cmd_config_tunnel_udp_port_action,
9139 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9140 (void *)&cmd_config_tunnel_udp_port_value,
9145 /* *** GLOBAL CONFIG *** */
9146 struct cmd_global_config_result {
9147 cmdline_fixed_string_t cmd;
9149 cmdline_fixed_string_t cfg_type;
9154 cmd_global_config_parsed(void *parsed_result,
9155 __attribute__((unused)) struct cmdline *cl,
9156 __attribute__((unused)) void *data)
9158 struct cmd_global_config_result *res = parsed_result;
9159 struct rte_eth_global_cfg conf;
9162 memset(&conf, 0, sizeof(conf));
9163 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9164 conf.cfg.gre_key_len = res->len;
9165 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9166 RTE_ETH_FILTER_SET, &conf);
9168 printf("Global config error\n");
9171 cmdline_parse_token_string_t cmd_global_config_cmd =
9172 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9174 cmdline_parse_token_num_t cmd_global_config_port_id =
9175 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9177 cmdline_parse_token_string_t cmd_global_config_type =
9178 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9179 cfg_type, "gre-key-len");
9180 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9181 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9184 cmdline_parse_inst_t cmd_global_config = {
9185 .f = cmd_global_config_parsed,
9186 .data = (void *)NULL,
9187 .help_str = "global_config <port_id> gre-key-len <key_len>",
9189 (void *)&cmd_global_config_cmd,
9190 (void *)&cmd_global_config_port_id,
9191 (void *)&cmd_global_config_type,
9192 (void *)&cmd_global_config_gre_key_len,
9197 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9198 struct cmd_set_mirror_mask_result {
9199 cmdline_fixed_string_t set;
9200 cmdline_fixed_string_t port;
9202 cmdline_fixed_string_t mirror;
9204 cmdline_fixed_string_t what;
9205 cmdline_fixed_string_t value;
9206 cmdline_fixed_string_t dstpool;
9208 cmdline_fixed_string_t on;
9211 cmdline_parse_token_string_t cmd_mirror_mask_set =
9212 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9214 cmdline_parse_token_string_t cmd_mirror_mask_port =
9215 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9217 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9218 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9220 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9221 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9222 mirror, "mirror-rule");
9223 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9224 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9226 cmdline_parse_token_string_t cmd_mirror_mask_what =
9227 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9228 what, "pool-mirror-up#pool-mirror-down"
9230 cmdline_parse_token_string_t cmd_mirror_mask_value =
9231 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9233 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9234 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9235 dstpool, "dst-pool");
9236 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9237 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9239 cmdline_parse_token_string_t cmd_mirror_mask_on =
9240 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9244 cmd_set_mirror_mask_parsed(void *parsed_result,
9245 __attribute__((unused)) struct cmdline *cl,
9246 __attribute__((unused)) void *data)
9249 struct cmd_set_mirror_mask_result *res = parsed_result;
9250 struct rte_eth_mirror_conf mr_conf;
9252 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9254 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9256 mr_conf.dst_pool = res->dstpool_id;
9258 if (!strcmp(res->what, "pool-mirror-up")) {
9259 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9260 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9261 } else if (!strcmp(res->what, "pool-mirror-down")) {
9262 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9263 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9264 } else if (!strcmp(res->what, "vlan-mirror")) {
9265 mr_conf.rule_type = ETH_MIRROR_VLAN;
9266 nb_item = parse_item_list(res->value, "vlan",
9267 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9271 for (i = 0; i < nb_item; i++) {
9272 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9273 printf("Invalid vlan_id: must be < 4096\n");
9277 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9278 mr_conf.vlan.vlan_mask |= 1ULL << i;
9282 if (!strcmp(res->on, "on"))
9283 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9286 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9289 printf("mirror rule add error: (%s)\n", strerror(-ret));
9292 cmdline_parse_inst_t cmd_set_mirror_mask = {
9293 .f = cmd_set_mirror_mask_parsed,
9295 .help_str = "set port <port_id> mirror-rule <rule_id> "
9296 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9297 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9299 (void *)&cmd_mirror_mask_set,
9300 (void *)&cmd_mirror_mask_port,
9301 (void *)&cmd_mirror_mask_portid,
9302 (void *)&cmd_mirror_mask_mirror,
9303 (void *)&cmd_mirror_mask_ruleid,
9304 (void *)&cmd_mirror_mask_what,
9305 (void *)&cmd_mirror_mask_value,
9306 (void *)&cmd_mirror_mask_dstpool,
9307 (void *)&cmd_mirror_mask_poolid,
9308 (void *)&cmd_mirror_mask_on,
9313 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9314 struct cmd_set_mirror_link_result {
9315 cmdline_fixed_string_t set;
9316 cmdline_fixed_string_t port;
9318 cmdline_fixed_string_t mirror;
9320 cmdline_fixed_string_t what;
9321 cmdline_fixed_string_t dstpool;
9323 cmdline_fixed_string_t on;
9326 cmdline_parse_token_string_t cmd_mirror_link_set =
9327 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9329 cmdline_parse_token_string_t cmd_mirror_link_port =
9330 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9332 cmdline_parse_token_num_t cmd_mirror_link_portid =
9333 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9335 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9336 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9337 mirror, "mirror-rule");
9338 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9339 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9341 cmdline_parse_token_string_t cmd_mirror_link_what =
9342 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9343 what, "uplink-mirror#downlink-mirror");
9344 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9345 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9346 dstpool, "dst-pool");
9347 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9348 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9350 cmdline_parse_token_string_t cmd_mirror_link_on =
9351 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9355 cmd_set_mirror_link_parsed(void *parsed_result,
9356 __attribute__((unused)) struct cmdline *cl,
9357 __attribute__((unused)) void *data)
9360 struct cmd_set_mirror_link_result *res = parsed_result;
9361 struct rte_eth_mirror_conf mr_conf;
9363 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9364 if (!strcmp(res->what, "uplink-mirror"))
9365 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9367 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9369 mr_conf.dst_pool = res->dstpool_id;
9371 if (!strcmp(res->on, "on"))
9372 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9375 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9378 /* check the return value and print it if is < 0 */
9380 printf("mirror rule add error: (%s)\n", strerror(-ret));
9384 cmdline_parse_inst_t cmd_set_mirror_link = {
9385 .f = cmd_set_mirror_link_parsed,
9387 .help_str = "set port <port_id> mirror-rule <rule_id> "
9388 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9390 (void *)&cmd_mirror_link_set,
9391 (void *)&cmd_mirror_link_port,
9392 (void *)&cmd_mirror_link_portid,
9393 (void *)&cmd_mirror_link_mirror,
9394 (void *)&cmd_mirror_link_ruleid,
9395 (void *)&cmd_mirror_link_what,
9396 (void *)&cmd_mirror_link_dstpool,
9397 (void *)&cmd_mirror_link_poolid,
9398 (void *)&cmd_mirror_link_on,
9403 /* *** RESET VM MIRROR RULE *** */
9404 struct cmd_rm_mirror_rule_result {
9405 cmdline_fixed_string_t reset;
9406 cmdline_fixed_string_t port;
9408 cmdline_fixed_string_t mirror;
9412 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9413 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9415 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9416 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9418 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9419 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9421 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9422 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9423 mirror, "mirror-rule");
9424 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9425 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9429 cmd_reset_mirror_rule_parsed(void *parsed_result,
9430 __attribute__((unused)) struct cmdline *cl,
9431 __attribute__((unused)) void *data)
9434 struct cmd_set_mirror_link_result *res = parsed_result;
9436 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9438 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9441 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9442 .f = cmd_reset_mirror_rule_parsed,
9444 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9446 (void *)&cmd_rm_mirror_rule_reset,
9447 (void *)&cmd_rm_mirror_rule_port,
9448 (void *)&cmd_rm_mirror_rule_portid,
9449 (void *)&cmd_rm_mirror_rule_mirror,
9450 (void *)&cmd_rm_mirror_rule_ruleid,
9455 /* ******************************************************************************** */
9457 struct cmd_dump_result {
9458 cmdline_fixed_string_t dump;
9462 dump_struct_sizes(void)
9464 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9465 DUMP_SIZE(struct rte_mbuf);
9466 DUMP_SIZE(struct rte_mempool);
9467 DUMP_SIZE(struct rte_ring);
9471 static void cmd_dump_parsed(void *parsed_result,
9472 __attribute__((unused)) struct cmdline *cl,
9473 __attribute__((unused)) void *data)
9475 struct cmd_dump_result *res = parsed_result;
9477 if (!strcmp(res->dump, "dump_physmem"))
9478 rte_dump_physmem_layout(stdout);
9479 else if (!strcmp(res->dump, "dump_memzone"))
9480 rte_memzone_dump(stdout);
9481 else if (!strcmp(res->dump, "dump_struct_sizes"))
9482 dump_struct_sizes();
9483 else if (!strcmp(res->dump, "dump_ring"))
9484 rte_ring_list_dump(stdout);
9485 else if (!strcmp(res->dump, "dump_mempool"))
9486 rte_mempool_list_dump(stdout);
9487 else if (!strcmp(res->dump, "dump_devargs"))
9488 rte_devargs_dump(stdout);
9489 else if (!strcmp(res->dump, "dump_log_types"))
9490 rte_log_dump(stdout);
9493 cmdline_parse_token_string_t cmd_dump_dump =
9494 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9497 "dump_struct_sizes#"
9503 cmdline_parse_inst_t cmd_dump = {
9504 .f = cmd_dump_parsed, /* function to call */
9505 .data = NULL, /* 2nd arg of func */
9506 .help_str = "Dump status",
9507 .tokens = { /* token list, NULL terminated */
9508 (void *)&cmd_dump_dump,
9513 /* ******************************************************************************** */
9515 struct cmd_dump_one_result {
9516 cmdline_fixed_string_t dump;
9517 cmdline_fixed_string_t name;
9520 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9521 __attribute__((unused)) void *data)
9523 struct cmd_dump_one_result *res = parsed_result;
9525 if (!strcmp(res->dump, "dump_ring")) {
9527 r = rte_ring_lookup(res->name);
9529 cmdline_printf(cl, "Cannot find ring\n");
9532 rte_ring_dump(stdout, r);
9533 } else if (!strcmp(res->dump, "dump_mempool")) {
9534 struct rte_mempool *mp;
9535 mp = rte_mempool_lookup(res->name);
9537 cmdline_printf(cl, "Cannot find mempool\n");
9540 rte_mempool_dump(stdout, mp);
9544 cmdline_parse_token_string_t cmd_dump_one_dump =
9545 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9546 "dump_ring#dump_mempool");
9548 cmdline_parse_token_string_t cmd_dump_one_name =
9549 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9551 cmdline_parse_inst_t cmd_dump_one = {
9552 .f = cmd_dump_one_parsed, /* function to call */
9553 .data = NULL, /* 2nd arg of func */
9554 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9555 .tokens = { /* token list, NULL terminated */
9556 (void *)&cmd_dump_one_dump,
9557 (void *)&cmd_dump_one_name,
9562 /* *** Add/Del syn filter *** */
9563 struct cmd_syn_filter_result {
9564 cmdline_fixed_string_t filter;
9566 cmdline_fixed_string_t ops;
9567 cmdline_fixed_string_t priority;
9568 cmdline_fixed_string_t high;
9569 cmdline_fixed_string_t queue;
9574 cmd_syn_filter_parsed(void *parsed_result,
9575 __attribute__((unused)) struct cmdline *cl,
9576 __attribute__((unused)) void *data)
9578 struct cmd_syn_filter_result *res = parsed_result;
9579 struct rte_eth_syn_filter syn_filter;
9582 ret = rte_eth_dev_filter_supported(res->port_id,
9583 RTE_ETH_FILTER_SYN);
9585 printf("syn filter is not supported on port %u.\n",
9590 memset(&syn_filter, 0, sizeof(syn_filter));
9592 if (!strcmp(res->ops, "add")) {
9593 if (!strcmp(res->high, "high"))
9594 syn_filter.hig_pri = 1;
9596 syn_filter.hig_pri = 0;
9598 syn_filter.queue = res->queue_id;
9599 ret = rte_eth_dev_filter_ctrl(res->port_id,
9604 ret = rte_eth_dev_filter_ctrl(res->port_id,
9606 RTE_ETH_FILTER_DELETE,
9610 printf("syn filter programming error: (%s)\n",
9614 cmdline_parse_token_string_t cmd_syn_filter_filter =
9615 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9616 filter, "syn_filter");
9617 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9618 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9620 cmdline_parse_token_string_t cmd_syn_filter_ops =
9621 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9623 cmdline_parse_token_string_t cmd_syn_filter_priority =
9624 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9625 priority, "priority");
9626 cmdline_parse_token_string_t cmd_syn_filter_high =
9627 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9629 cmdline_parse_token_string_t cmd_syn_filter_queue =
9630 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9632 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9633 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9636 cmdline_parse_inst_t cmd_syn_filter = {
9637 .f = cmd_syn_filter_parsed,
9639 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9640 "<queue_id>: Add/Delete syn filter",
9642 (void *)&cmd_syn_filter_filter,
9643 (void *)&cmd_syn_filter_port_id,
9644 (void *)&cmd_syn_filter_ops,
9645 (void *)&cmd_syn_filter_priority,
9646 (void *)&cmd_syn_filter_high,
9647 (void *)&cmd_syn_filter_queue,
9648 (void *)&cmd_syn_filter_queue_id,
9653 /* *** queue region set *** */
9654 struct cmd_queue_region_result {
9655 cmdline_fixed_string_t set;
9656 cmdline_fixed_string_t port;
9658 cmdline_fixed_string_t cmd;
9659 cmdline_fixed_string_t region;
9661 cmdline_fixed_string_t queue_start_index;
9663 cmdline_fixed_string_t queue_num;
9664 uint8_t queue_num_value;
9668 cmd_queue_region_parsed(void *parsed_result,
9669 __attribute__((unused)) struct cmdline *cl,
9670 __attribute__((unused)) void *data)
9672 struct cmd_queue_region_result *res = parsed_result;
9674 #ifdef RTE_LIBRTE_I40E_PMD
9675 struct rte_pmd_i40e_queue_region_conf region_conf;
9676 enum rte_pmd_i40e_queue_region_op op_type;
9679 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9682 #ifdef RTE_LIBRTE_I40E_PMD
9683 memset(®ion_conf, 0, sizeof(region_conf));
9684 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9685 region_conf.region_id = res->region_id;
9686 region_conf.queue_num = res->queue_num_value;
9687 region_conf.queue_start_index = res->queue_id;
9689 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9690 op_type, ®ion_conf);
9697 printf("function not implemented or supported\n");
9700 printf("queue region config error: (%s)\n", strerror(-ret));
9704 cmdline_parse_token_string_t cmd_queue_region_set =
9705 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9707 cmdline_parse_token_string_t cmd_queue_region_port =
9708 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9709 cmdline_parse_token_num_t cmd_queue_region_port_id =
9710 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9712 cmdline_parse_token_string_t cmd_queue_region_cmd =
9713 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9714 cmd, "queue-region");
9715 cmdline_parse_token_string_t cmd_queue_region_id =
9716 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9717 region, "region_id");
9718 cmdline_parse_token_num_t cmd_queue_region_index =
9719 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9721 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9722 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9723 queue_start_index, "queue_start_index");
9724 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9725 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9727 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9728 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9729 queue_num, "queue_num");
9730 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9731 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9732 queue_num_value, UINT8);
9734 cmdline_parse_inst_t cmd_queue_region = {
9735 .f = cmd_queue_region_parsed,
9737 .help_str = "set port <port_id> queue-region region_id <value> "
9738 "queue_start_index <value> queue_num <value>: Set a queue region",
9740 (void *)&cmd_queue_region_set,
9741 (void *)&cmd_queue_region_port,
9742 (void *)&cmd_queue_region_port_id,
9743 (void *)&cmd_queue_region_cmd,
9744 (void *)&cmd_queue_region_id,
9745 (void *)&cmd_queue_region_index,
9746 (void *)&cmd_queue_region_queue_start_index,
9747 (void *)&cmd_queue_region_queue_id,
9748 (void *)&cmd_queue_region_queue_num,
9749 (void *)&cmd_queue_region_queue_num_value,
9754 /* *** queue region and flowtype set *** */
9755 struct cmd_region_flowtype_result {
9756 cmdline_fixed_string_t set;
9757 cmdline_fixed_string_t port;
9759 cmdline_fixed_string_t cmd;
9760 cmdline_fixed_string_t region;
9762 cmdline_fixed_string_t flowtype;
9763 uint8_t flowtype_id;
9767 cmd_region_flowtype_parsed(void *parsed_result,
9768 __attribute__((unused)) struct cmdline *cl,
9769 __attribute__((unused)) void *data)
9771 struct cmd_region_flowtype_result *res = parsed_result;
9773 #ifdef RTE_LIBRTE_I40E_PMD
9774 struct rte_pmd_i40e_queue_region_conf region_conf;
9775 enum rte_pmd_i40e_queue_region_op op_type;
9778 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9781 #ifdef RTE_LIBRTE_I40E_PMD
9782 memset(®ion_conf, 0, sizeof(region_conf));
9784 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9785 region_conf.region_id = res->region_id;
9786 region_conf.hw_flowtype = res->flowtype_id;
9788 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9789 op_type, ®ion_conf);
9796 printf("function not implemented or supported\n");
9799 printf("region flowtype config error: (%s)\n", strerror(-ret));
9803 cmdline_parse_token_string_t cmd_region_flowtype_set =
9804 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9806 cmdline_parse_token_string_t cmd_region_flowtype_port =
9807 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9809 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9810 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9812 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9813 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9814 cmd, "queue-region");
9815 cmdline_parse_token_string_t cmd_region_flowtype_index =
9816 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9817 region, "region_id");
9818 cmdline_parse_token_num_t cmd_region_flowtype_id =
9819 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9821 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9822 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9823 flowtype, "flowtype");
9824 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9825 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9826 flowtype_id, UINT8);
9827 cmdline_parse_inst_t cmd_region_flowtype = {
9828 .f = cmd_region_flowtype_parsed,
9830 .help_str = "set port <port_id> queue-region region_id <value> "
9831 "flowtype <value>: Set a flowtype region index",
9833 (void *)&cmd_region_flowtype_set,
9834 (void *)&cmd_region_flowtype_port,
9835 (void *)&cmd_region_flowtype_port_index,
9836 (void *)&cmd_region_flowtype_cmd,
9837 (void *)&cmd_region_flowtype_index,
9838 (void *)&cmd_region_flowtype_id,
9839 (void *)&cmd_region_flowtype_flow_index,
9840 (void *)&cmd_region_flowtype_flow_id,
9845 /* *** User Priority (UP) to queue region (region_id) set *** */
9846 struct cmd_user_priority_region_result {
9847 cmdline_fixed_string_t set;
9848 cmdline_fixed_string_t port;
9850 cmdline_fixed_string_t cmd;
9851 cmdline_fixed_string_t user_priority;
9852 uint8_t user_priority_id;
9853 cmdline_fixed_string_t region;
9858 cmd_user_priority_region_parsed(void *parsed_result,
9859 __attribute__((unused)) struct cmdline *cl,
9860 __attribute__((unused)) void *data)
9862 struct cmd_user_priority_region_result *res = parsed_result;
9864 #ifdef RTE_LIBRTE_I40E_PMD
9865 struct rte_pmd_i40e_queue_region_conf region_conf;
9866 enum rte_pmd_i40e_queue_region_op op_type;
9869 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9872 #ifdef RTE_LIBRTE_I40E_PMD
9873 memset(®ion_conf, 0, sizeof(region_conf));
9874 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9875 region_conf.user_priority = res->user_priority_id;
9876 region_conf.region_id = res->region_id;
9878 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9879 op_type, ®ion_conf);
9886 printf("function not implemented or supported\n");
9889 printf("user_priority region config error: (%s)\n",
9894 cmdline_parse_token_string_t cmd_user_priority_region_set =
9895 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9897 cmdline_parse_token_string_t cmd_user_priority_region_port =
9898 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9900 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9901 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9903 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9904 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9905 cmd, "queue-region");
9906 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9907 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9908 user_priority, "UP");
9909 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9910 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9911 user_priority_id, UINT8);
9912 cmdline_parse_token_string_t cmd_user_priority_region_region =
9913 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9914 region, "region_id");
9915 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9916 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9919 cmdline_parse_inst_t cmd_user_priority_region = {
9920 .f = cmd_user_priority_region_parsed,
9922 .help_str = "set port <port_id> queue-region UP <value> "
9923 "region_id <value>: Set the mapping of User Priority (UP) "
9924 "to queue region (region_id) ",
9926 (void *)&cmd_user_priority_region_set,
9927 (void *)&cmd_user_priority_region_port,
9928 (void *)&cmd_user_priority_region_port_index,
9929 (void *)&cmd_user_priority_region_cmd,
9930 (void *)&cmd_user_priority_region_UP,
9931 (void *)&cmd_user_priority_region_UP_id,
9932 (void *)&cmd_user_priority_region_region,
9933 (void *)&cmd_user_priority_region_region_id,
9938 /* *** flush all queue region related configuration *** */
9939 struct cmd_flush_queue_region_result {
9940 cmdline_fixed_string_t set;
9941 cmdline_fixed_string_t port;
9943 cmdline_fixed_string_t cmd;
9944 cmdline_fixed_string_t flush;
9945 cmdline_fixed_string_t what;
9949 cmd_flush_queue_region_parsed(void *parsed_result,
9950 __attribute__((unused)) struct cmdline *cl,
9951 __attribute__((unused)) void *data)
9953 struct cmd_flush_queue_region_result *res = parsed_result;
9955 #ifdef RTE_LIBRTE_I40E_PMD
9956 struct rte_pmd_i40e_queue_region_conf region_conf;
9957 enum rte_pmd_i40e_queue_region_op op_type;
9960 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9963 #ifdef RTE_LIBRTE_I40E_PMD
9964 memset(®ion_conf, 0, sizeof(region_conf));
9966 if (strcmp(res->what, "on") == 0)
9967 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9969 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9971 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9972 op_type, ®ion_conf);
9979 printf("function not implemented or supported\n");
9982 printf("queue region config flush error: (%s)\n",
9987 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9988 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9990 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9991 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9993 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9994 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9996 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9997 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9998 cmd, "queue-region");
9999 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10000 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10002 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10003 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10006 cmdline_parse_inst_t cmd_flush_queue_region = {
10007 .f = cmd_flush_queue_region_parsed,
10009 .help_str = "set port <port_id> queue-region flush on|off"
10010 ": flush all queue region related configuration",
10012 (void *)&cmd_flush_queue_region_set,
10013 (void *)&cmd_flush_queue_region_port,
10014 (void *)&cmd_flush_queue_region_port_index,
10015 (void *)&cmd_flush_queue_region_cmd,
10016 (void *)&cmd_flush_queue_region_flush,
10017 (void *)&cmd_flush_queue_region_what,
10022 /* *** get all queue region related configuration info *** */
10023 struct cmd_show_queue_region_info {
10024 cmdline_fixed_string_t show;
10025 cmdline_fixed_string_t port;
10027 cmdline_fixed_string_t cmd;
10031 cmd_show_queue_region_info_parsed(void *parsed_result,
10032 __attribute__((unused)) struct cmdline *cl,
10033 __attribute__((unused)) void *data)
10035 struct cmd_show_queue_region_info *res = parsed_result;
10036 int ret = -ENOTSUP;
10037 #ifdef RTE_LIBRTE_I40E_PMD
10038 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10039 enum rte_pmd_i40e_queue_region_op op_type;
10042 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10045 #ifdef RTE_LIBRTE_I40E_PMD
10046 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10048 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10050 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10051 op_type, &rte_pmd_regions);
10053 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10060 printf("function not implemented or supported\n");
10063 printf("queue region config info show error: (%s)\n",
10068 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10069 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10071 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10072 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10074 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10075 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10077 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10078 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10079 cmd, "queue-region");
10081 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10082 .f = cmd_show_queue_region_info_parsed,
10084 .help_str = "show port <port_id> queue-region"
10085 ": show all queue region related configuration info",
10087 (void *)&cmd_show_queue_region_info_get,
10088 (void *)&cmd_show_queue_region_info_port,
10089 (void *)&cmd_show_queue_region_info_port_index,
10090 (void *)&cmd_show_queue_region_info_cmd,
10095 /* *** ADD/REMOVE A 2tuple FILTER *** */
10096 struct cmd_2tuple_filter_result {
10097 cmdline_fixed_string_t filter;
10099 cmdline_fixed_string_t ops;
10100 cmdline_fixed_string_t dst_port;
10101 uint16_t dst_port_value;
10102 cmdline_fixed_string_t protocol;
10103 uint8_t protocol_value;
10104 cmdline_fixed_string_t mask;
10105 uint8_t mask_value;
10106 cmdline_fixed_string_t tcp_flags;
10107 uint8_t tcp_flags_value;
10108 cmdline_fixed_string_t priority;
10109 uint8_t priority_value;
10110 cmdline_fixed_string_t queue;
10115 cmd_2tuple_filter_parsed(void *parsed_result,
10116 __attribute__((unused)) struct cmdline *cl,
10117 __attribute__((unused)) void *data)
10119 struct rte_eth_ntuple_filter filter;
10120 struct cmd_2tuple_filter_result *res = parsed_result;
10123 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10125 printf("ntuple filter is not supported on port %u.\n",
10130 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10132 filter.flags = RTE_2TUPLE_FLAGS;
10133 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10134 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10135 filter.proto = res->protocol_value;
10136 filter.priority = res->priority_value;
10137 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10138 printf("nonzero tcp_flags is only meaningful"
10139 " when protocol is TCP.\n");
10142 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10143 printf("invalid TCP flags.\n");
10147 if (res->tcp_flags_value != 0) {
10148 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10149 filter.tcp_flags = res->tcp_flags_value;
10152 /* need convert to big endian. */
10153 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10154 filter.queue = res->queue_id;
10156 if (!strcmp(res->ops, "add"))
10157 ret = rte_eth_dev_filter_ctrl(res->port_id,
10158 RTE_ETH_FILTER_NTUPLE,
10159 RTE_ETH_FILTER_ADD,
10162 ret = rte_eth_dev_filter_ctrl(res->port_id,
10163 RTE_ETH_FILTER_NTUPLE,
10164 RTE_ETH_FILTER_DELETE,
10167 printf("2tuple filter programming error: (%s)\n",
10172 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10173 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10174 filter, "2tuple_filter");
10175 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10176 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10178 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10179 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10181 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10182 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10183 dst_port, "dst_port");
10184 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10185 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10186 dst_port_value, UINT16);
10187 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10188 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10189 protocol, "protocol");
10190 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10191 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10192 protocol_value, UINT8);
10193 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10194 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10196 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10197 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10199 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10200 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10201 tcp_flags, "tcp_flags");
10202 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10203 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10204 tcp_flags_value, UINT8);
10205 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10206 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10207 priority, "priority");
10208 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10209 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10210 priority_value, UINT8);
10211 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10212 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10214 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10215 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10218 cmdline_parse_inst_t cmd_2tuple_filter = {
10219 .f = cmd_2tuple_filter_parsed,
10221 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10222 "<value> mask <value> tcp_flags <value> priority <value> queue "
10223 "<queue_id>: Add a 2tuple filter",
10225 (void *)&cmd_2tuple_filter_filter,
10226 (void *)&cmd_2tuple_filter_port_id,
10227 (void *)&cmd_2tuple_filter_ops,
10228 (void *)&cmd_2tuple_filter_dst_port,
10229 (void *)&cmd_2tuple_filter_dst_port_value,
10230 (void *)&cmd_2tuple_filter_protocol,
10231 (void *)&cmd_2tuple_filter_protocol_value,
10232 (void *)&cmd_2tuple_filter_mask,
10233 (void *)&cmd_2tuple_filter_mask_value,
10234 (void *)&cmd_2tuple_filter_tcp_flags,
10235 (void *)&cmd_2tuple_filter_tcp_flags_value,
10236 (void *)&cmd_2tuple_filter_priority,
10237 (void *)&cmd_2tuple_filter_priority_value,
10238 (void *)&cmd_2tuple_filter_queue,
10239 (void *)&cmd_2tuple_filter_queue_id,
10244 /* *** ADD/REMOVE A 5tuple FILTER *** */
10245 struct cmd_5tuple_filter_result {
10246 cmdline_fixed_string_t filter;
10248 cmdline_fixed_string_t ops;
10249 cmdline_fixed_string_t dst_ip;
10250 cmdline_ipaddr_t dst_ip_value;
10251 cmdline_fixed_string_t src_ip;
10252 cmdline_ipaddr_t src_ip_value;
10253 cmdline_fixed_string_t dst_port;
10254 uint16_t dst_port_value;
10255 cmdline_fixed_string_t src_port;
10256 uint16_t src_port_value;
10257 cmdline_fixed_string_t protocol;
10258 uint8_t protocol_value;
10259 cmdline_fixed_string_t mask;
10260 uint8_t mask_value;
10261 cmdline_fixed_string_t tcp_flags;
10262 uint8_t tcp_flags_value;
10263 cmdline_fixed_string_t priority;
10264 uint8_t priority_value;
10265 cmdline_fixed_string_t queue;
10270 cmd_5tuple_filter_parsed(void *parsed_result,
10271 __attribute__((unused)) struct cmdline *cl,
10272 __attribute__((unused)) void *data)
10274 struct rte_eth_ntuple_filter filter;
10275 struct cmd_5tuple_filter_result *res = parsed_result;
10278 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10280 printf("ntuple filter is not supported on port %u.\n",
10285 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10287 filter.flags = RTE_5TUPLE_FLAGS;
10288 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10289 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10290 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10291 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10292 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10293 filter.proto = res->protocol_value;
10294 filter.priority = res->priority_value;
10295 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10296 printf("nonzero tcp_flags is only meaningful"
10297 " when protocol is TCP.\n");
10300 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10301 printf("invalid TCP flags.\n");
10305 if (res->tcp_flags_value != 0) {
10306 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10307 filter.tcp_flags = res->tcp_flags_value;
10310 if (res->dst_ip_value.family == AF_INET)
10311 /* no need to convert, already big endian. */
10312 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10314 if (filter.dst_ip_mask == 0) {
10315 printf("can not support ipv6 involved compare.\n");
10321 if (res->src_ip_value.family == AF_INET)
10322 /* no need to convert, already big endian. */
10323 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10325 if (filter.src_ip_mask == 0) {
10326 printf("can not support ipv6 involved compare.\n");
10331 /* need convert to big endian. */
10332 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10333 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10334 filter.queue = res->queue_id;
10336 if (!strcmp(res->ops, "add"))
10337 ret = rte_eth_dev_filter_ctrl(res->port_id,
10338 RTE_ETH_FILTER_NTUPLE,
10339 RTE_ETH_FILTER_ADD,
10342 ret = rte_eth_dev_filter_ctrl(res->port_id,
10343 RTE_ETH_FILTER_NTUPLE,
10344 RTE_ETH_FILTER_DELETE,
10347 printf("5tuple filter programming error: (%s)\n",
10351 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10352 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10353 filter, "5tuple_filter");
10354 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10355 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10357 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10358 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10360 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10361 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10363 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10364 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10366 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10367 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10369 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10370 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10372 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10373 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10374 dst_port, "dst_port");
10375 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10376 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10377 dst_port_value, UINT16);
10378 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10379 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10380 src_port, "src_port");
10381 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10382 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10383 src_port_value, UINT16);
10384 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10385 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10386 protocol, "protocol");
10387 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10388 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10389 protocol_value, UINT8);
10390 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10391 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10393 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10394 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10396 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10397 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10398 tcp_flags, "tcp_flags");
10399 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10400 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10401 tcp_flags_value, UINT8);
10402 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10403 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10404 priority, "priority");
10405 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10406 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10407 priority_value, UINT8);
10408 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10409 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10411 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10412 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10415 cmdline_parse_inst_t cmd_5tuple_filter = {
10416 .f = cmd_5tuple_filter_parsed,
10418 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10419 "src_ip <value> dst_port <value> src_port <value> "
10420 "protocol <value> mask <value> tcp_flags <value> "
10421 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10423 (void *)&cmd_5tuple_filter_filter,
10424 (void *)&cmd_5tuple_filter_port_id,
10425 (void *)&cmd_5tuple_filter_ops,
10426 (void *)&cmd_5tuple_filter_dst_ip,
10427 (void *)&cmd_5tuple_filter_dst_ip_value,
10428 (void *)&cmd_5tuple_filter_src_ip,
10429 (void *)&cmd_5tuple_filter_src_ip_value,
10430 (void *)&cmd_5tuple_filter_dst_port,
10431 (void *)&cmd_5tuple_filter_dst_port_value,
10432 (void *)&cmd_5tuple_filter_src_port,
10433 (void *)&cmd_5tuple_filter_src_port_value,
10434 (void *)&cmd_5tuple_filter_protocol,
10435 (void *)&cmd_5tuple_filter_protocol_value,
10436 (void *)&cmd_5tuple_filter_mask,
10437 (void *)&cmd_5tuple_filter_mask_value,
10438 (void *)&cmd_5tuple_filter_tcp_flags,
10439 (void *)&cmd_5tuple_filter_tcp_flags_value,
10440 (void *)&cmd_5tuple_filter_priority,
10441 (void *)&cmd_5tuple_filter_priority_value,
10442 (void *)&cmd_5tuple_filter_queue,
10443 (void *)&cmd_5tuple_filter_queue_id,
10448 /* *** ADD/REMOVE A flex FILTER *** */
10449 struct cmd_flex_filter_result {
10450 cmdline_fixed_string_t filter;
10451 cmdline_fixed_string_t ops;
10453 cmdline_fixed_string_t len;
10455 cmdline_fixed_string_t bytes;
10456 cmdline_fixed_string_t bytes_value;
10457 cmdline_fixed_string_t mask;
10458 cmdline_fixed_string_t mask_value;
10459 cmdline_fixed_string_t priority;
10460 uint8_t priority_value;
10461 cmdline_fixed_string_t queue;
10465 static int xdigit2val(unsigned char c)
10470 else if (isupper(c))
10471 val = c - 'A' + 10;
10473 val = c - 'a' + 10;
10478 cmd_flex_filter_parsed(void *parsed_result,
10479 __attribute__((unused)) struct cmdline *cl,
10480 __attribute__((unused)) void *data)
10483 struct rte_eth_flex_filter filter;
10484 struct cmd_flex_filter_result *res = parsed_result;
10485 char *bytes_ptr, *mask_ptr;
10486 uint16_t len, i, j = 0;
10491 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10492 printf("the len exceed the max length 128\n");
10495 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10496 filter.len = res->len_value;
10497 filter.priority = res->priority_value;
10498 filter.queue = res->queue_id;
10499 bytes_ptr = res->bytes_value;
10500 mask_ptr = res->mask_value;
10502 /* translate bytes string to array. */
10503 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10504 (bytes_ptr[1] == 'X')))
10506 len = strnlen(bytes_ptr, res->len_value * 2);
10507 if (len == 0 || (len % 8 != 0)) {
10508 printf("please check len and bytes input\n");
10511 for (i = 0; i < len; i++) {
10513 if (isxdigit(c) == 0) {
10514 /* invalid characters. */
10515 printf("invalid input\n");
10518 val = xdigit2val(c);
10521 filter.bytes[j] = byte;
10522 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10529 /* translate mask string to uint8_t array. */
10530 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10531 (mask_ptr[1] == 'X')))
10533 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10535 printf("invalid input\n");
10540 for (i = 0; i < len; i++) {
10542 if (isxdigit(c) == 0) {
10543 /* invalid characters. */
10544 printf("invalid input\n");
10547 val = xdigit2val(c);
10550 filter.mask[j] = byte;
10551 printf("mask[%d]:%02x ", j, filter.mask[j]);
10559 if (!strcmp(res->ops, "add"))
10560 ret = rte_eth_dev_filter_ctrl(res->port_id,
10561 RTE_ETH_FILTER_FLEXIBLE,
10562 RTE_ETH_FILTER_ADD,
10565 ret = rte_eth_dev_filter_ctrl(res->port_id,
10566 RTE_ETH_FILTER_FLEXIBLE,
10567 RTE_ETH_FILTER_DELETE,
10571 printf("flex filter setting error: (%s)\n", strerror(-ret));
10574 cmdline_parse_token_string_t cmd_flex_filter_filter =
10575 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10576 filter, "flex_filter");
10577 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10578 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10580 cmdline_parse_token_string_t cmd_flex_filter_ops =
10581 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10583 cmdline_parse_token_string_t cmd_flex_filter_len =
10584 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10586 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10587 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10589 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10590 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10592 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10593 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10594 bytes_value, NULL);
10595 cmdline_parse_token_string_t cmd_flex_filter_mask =
10596 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10598 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10599 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10601 cmdline_parse_token_string_t cmd_flex_filter_priority =
10602 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10603 priority, "priority");
10604 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10605 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10606 priority_value, UINT8);
10607 cmdline_parse_token_string_t cmd_flex_filter_queue =
10608 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10610 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10611 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10613 cmdline_parse_inst_t cmd_flex_filter = {
10614 .f = cmd_flex_filter_parsed,
10616 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10617 "<value> mask <value> priority <value> queue <queue_id>: "
10618 "Add/Del a flex filter",
10620 (void *)&cmd_flex_filter_filter,
10621 (void *)&cmd_flex_filter_port_id,
10622 (void *)&cmd_flex_filter_ops,
10623 (void *)&cmd_flex_filter_len,
10624 (void *)&cmd_flex_filter_len_value,
10625 (void *)&cmd_flex_filter_bytes,
10626 (void *)&cmd_flex_filter_bytes_value,
10627 (void *)&cmd_flex_filter_mask,
10628 (void *)&cmd_flex_filter_mask_value,
10629 (void *)&cmd_flex_filter_priority,
10630 (void *)&cmd_flex_filter_priority_value,
10631 (void *)&cmd_flex_filter_queue,
10632 (void *)&cmd_flex_filter_queue_id,
10637 /* *** Filters Control *** */
10639 /* *** deal with ethertype filter *** */
10640 struct cmd_ethertype_filter_result {
10641 cmdline_fixed_string_t filter;
10643 cmdline_fixed_string_t ops;
10644 cmdline_fixed_string_t mac;
10645 struct rte_ether_addr mac_addr;
10646 cmdline_fixed_string_t ethertype;
10647 uint16_t ethertype_value;
10648 cmdline_fixed_string_t drop;
10649 cmdline_fixed_string_t queue;
10653 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10654 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10655 filter, "ethertype_filter");
10656 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10657 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10659 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10660 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10662 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10663 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10664 mac, "mac_addr#mac_ignr");
10665 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10666 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10668 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10669 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10670 ethertype, "ethertype");
10671 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10672 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10673 ethertype_value, UINT16);
10674 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10675 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10677 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10678 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10680 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10681 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10685 cmd_ethertype_filter_parsed(void *parsed_result,
10686 __attribute__((unused)) struct cmdline *cl,
10687 __attribute__((unused)) void *data)
10689 struct cmd_ethertype_filter_result *res = parsed_result;
10690 struct rte_eth_ethertype_filter filter;
10693 ret = rte_eth_dev_filter_supported(res->port_id,
10694 RTE_ETH_FILTER_ETHERTYPE);
10696 printf("ethertype filter is not supported on port %u.\n",
10701 memset(&filter, 0, sizeof(filter));
10702 if (!strcmp(res->mac, "mac_addr")) {
10703 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10704 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10705 sizeof(struct rte_ether_addr));
10707 if (!strcmp(res->drop, "drop"))
10708 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10709 filter.ether_type = res->ethertype_value;
10710 filter.queue = res->queue_id;
10712 if (!strcmp(res->ops, "add"))
10713 ret = rte_eth_dev_filter_ctrl(res->port_id,
10714 RTE_ETH_FILTER_ETHERTYPE,
10715 RTE_ETH_FILTER_ADD,
10718 ret = rte_eth_dev_filter_ctrl(res->port_id,
10719 RTE_ETH_FILTER_ETHERTYPE,
10720 RTE_ETH_FILTER_DELETE,
10723 printf("ethertype filter programming error: (%s)\n",
10727 cmdline_parse_inst_t cmd_ethertype_filter = {
10728 .f = cmd_ethertype_filter_parsed,
10730 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10731 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10732 "Add or delete an ethertype filter entry",
10734 (void *)&cmd_ethertype_filter_filter,
10735 (void *)&cmd_ethertype_filter_port_id,
10736 (void *)&cmd_ethertype_filter_ops,
10737 (void *)&cmd_ethertype_filter_mac,
10738 (void *)&cmd_ethertype_filter_mac_addr,
10739 (void *)&cmd_ethertype_filter_ethertype,
10740 (void *)&cmd_ethertype_filter_ethertype_value,
10741 (void *)&cmd_ethertype_filter_drop,
10742 (void *)&cmd_ethertype_filter_queue,
10743 (void *)&cmd_ethertype_filter_queue_id,
10748 /* *** deal with flow director filter *** */
10749 struct cmd_flow_director_result {
10750 cmdline_fixed_string_t flow_director_filter;
10752 cmdline_fixed_string_t mode;
10753 cmdline_fixed_string_t mode_value;
10754 cmdline_fixed_string_t ops;
10755 cmdline_fixed_string_t flow;
10756 cmdline_fixed_string_t flow_type;
10757 cmdline_fixed_string_t ether;
10758 uint16_t ether_type;
10759 cmdline_fixed_string_t src;
10760 cmdline_ipaddr_t ip_src;
10762 cmdline_fixed_string_t dst;
10763 cmdline_ipaddr_t ip_dst;
10765 cmdline_fixed_string_t verify_tag;
10766 uint32_t verify_tag_value;
10767 cmdline_fixed_string_t tos;
10769 cmdline_fixed_string_t proto;
10770 uint8_t proto_value;
10771 cmdline_fixed_string_t ttl;
10773 cmdline_fixed_string_t vlan;
10774 uint16_t vlan_value;
10775 cmdline_fixed_string_t flexbytes;
10776 cmdline_fixed_string_t flexbytes_value;
10777 cmdline_fixed_string_t pf_vf;
10778 cmdline_fixed_string_t drop;
10779 cmdline_fixed_string_t queue;
10781 cmdline_fixed_string_t fd_id;
10782 uint32_t fd_id_value;
10783 cmdline_fixed_string_t mac;
10784 struct rte_ether_addr mac_addr;
10785 cmdline_fixed_string_t tunnel;
10786 cmdline_fixed_string_t tunnel_type;
10787 cmdline_fixed_string_t tunnel_id;
10788 uint32_t tunnel_id_value;
10789 cmdline_fixed_string_t packet;
10794 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10797 const char *p, *p0 = q_arg;
10799 unsigned long int_fld;
10800 char *str_fld[max_num];
10805 p = strchr(p0, '(');
10809 p0 = strchr(p, ')');
10814 if (size >= sizeof(s))
10817 snprintf(s, sizeof(s), "%.*s", size, p);
10818 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10819 if (ret < 0 || ret > max_num)
10821 for (i = 0; i < ret; i++) {
10823 int_fld = strtoul(str_fld[i], &end, 0);
10824 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10826 flexbytes[i] = (uint8_t)int_fld;
10832 str2flowtype(char *string)
10835 static const struct {
10838 } flowtype_str[] = {
10839 {"raw", RTE_ETH_FLOW_RAW},
10840 {"ipv4", RTE_ETH_FLOW_IPV4},
10841 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10842 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10843 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10844 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10845 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10846 {"ipv6", RTE_ETH_FLOW_IPV6},
10847 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10848 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10849 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10850 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10851 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10852 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10855 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10856 if (!strcmp(flowtype_str[i].str, string))
10857 return flowtype_str[i].type;
10860 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10861 return (uint16_t)atoi(string);
10863 return RTE_ETH_FLOW_UNKNOWN;
10866 static enum rte_eth_fdir_tunnel_type
10867 str2fdir_tunneltype(char *string)
10871 static const struct {
10873 enum rte_eth_fdir_tunnel_type type;
10874 } tunneltype_str[] = {
10875 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10876 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10879 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10880 if (!strcmp(tunneltype_str[i].str, string))
10881 return tunneltype_str[i].type;
10883 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10886 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10888 if ((ip_addr).family == AF_INET) \
10889 (ip) = (ip_addr).addr.ipv4.s_addr; \
10891 printf("invalid parameter.\n"); \
10896 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10898 if ((ip_addr).family == AF_INET6) \
10899 rte_memcpy(&(ip), \
10900 &((ip_addr).addr.ipv6), \
10901 sizeof(struct in6_addr)); \
10903 printf("invalid parameter.\n"); \
10909 cmd_flow_director_filter_parsed(void *parsed_result,
10910 __attribute__((unused)) struct cmdline *cl,
10911 __attribute__((unused)) void *data)
10913 struct cmd_flow_director_result *res = parsed_result;
10914 struct rte_eth_fdir_filter entry;
10915 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10917 unsigned long vf_id;
10920 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10922 printf("flow director is not supported on port %u.\n",
10926 memset(flexbytes, 0, sizeof(flexbytes));
10927 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10929 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10930 if (strcmp(res->mode_value, "MAC-VLAN")) {
10931 printf("Please set mode to MAC-VLAN.\n");
10934 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10935 if (strcmp(res->mode_value, "Tunnel")) {
10936 printf("Please set mode to Tunnel.\n");
10940 if (!strcmp(res->mode_value, "raw")) {
10941 #ifdef RTE_LIBRTE_I40E_PMD
10942 struct rte_pmd_i40e_flow_type_mapping
10943 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10944 struct rte_pmd_i40e_pkt_template_conf conf;
10945 uint16_t flow_type = str2flowtype(res->flow_type);
10946 uint16_t i, port = res->port_id;
10949 memset(&conf, 0, sizeof(conf));
10951 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10952 printf("Invalid flow type specified.\n");
10955 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10959 if (mapping[flow_type].pctype == 0ULL) {
10960 printf("Invalid flow type specified.\n");
10963 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10964 if (mapping[flow_type].pctype & (1ULL << i)) {
10965 conf.input.pctype = i;
10970 conf.input.packet = open_file(res->filepath,
10971 &conf.input.length);
10972 if (!conf.input.packet)
10974 if (!strcmp(res->drop, "drop"))
10975 conf.action.behavior =
10976 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10978 conf.action.behavior =
10979 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10980 conf.action.report_status =
10981 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10982 conf.action.rx_queue = res->queue_id;
10983 conf.soft_id = res->fd_id_value;
10984 add = strcmp(res->ops, "del") ? 1 : 0;
10985 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10989 printf("flow director config error: (%s)\n",
10991 close_file(conf.input.packet);
10994 } else if (strcmp(res->mode_value, "IP")) {
10995 printf("Please set mode to IP or raw.\n");
10998 entry.input.flow_type = str2flowtype(res->flow_type);
11001 ret = parse_flexbytes(res->flexbytes_value,
11003 RTE_ETH_FDIR_MAX_FLEXLEN);
11005 printf("error: Cannot parse flexbytes input.\n");
11009 switch (entry.input.flow_type) {
11010 case RTE_ETH_FLOW_FRAG_IPV4:
11011 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11012 entry.input.flow.ip4_flow.proto = res->proto_value;
11014 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11015 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11016 IPV4_ADDR_TO_UINT(res->ip_dst,
11017 entry.input.flow.ip4_flow.dst_ip);
11018 IPV4_ADDR_TO_UINT(res->ip_src,
11019 entry.input.flow.ip4_flow.src_ip);
11020 entry.input.flow.ip4_flow.tos = res->tos_value;
11021 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11022 /* need convert to big endian. */
11023 entry.input.flow.udp4_flow.dst_port =
11024 rte_cpu_to_be_16(res->port_dst);
11025 entry.input.flow.udp4_flow.src_port =
11026 rte_cpu_to_be_16(res->port_src);
11028 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11029 IPV4_ADDR_TO_UINT(res->ip_dst,
11030 entry.input.flow.sctp4_flow.ip.dst_ip);
11031 IPV4_ADDR_TO_UINT(res->ip_src,
11032 entry.input.flow.sctp4_flow.ip.src_ip);
11033 entry.input.flow.ip4_flow.tos = res->tos_value;
11034 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11035 /* need convert to big endian. */
11036 entry.input.flow.sctp4_flow.dst_port =
11037 rte_cpu_to_be_16(res->port_dst);
11038 entry.input.flow.sctp4_flow.src_port =
11039 rte_cpu_to_be_16(res->port_src);
11040 entry.input.flow.sctp4_flow.verify_tag =
11041 rte_cpu_to_be_32(res->verify_tag_value);
11043 case RTE_ETH_FLOW_FRAG_IPV6:
11044 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11045 entry.input.flow.ipv6_flow.proto = res->proto_value;
11047 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11048 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11049 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11050 entry.input.flow.ipv6_flow.dst_ip);
11051 IPV6_ADDR_TO_ARRAY(res->ip_src,
11052 entry.input.flow.ipv6_flow.src_ip);
11053 entry.input.flow.ipv6_flow.tc = res->tos_value;
11054 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11055 /* need convert to big endian. */
11056 entry.input.flow.udp6_flow.dst_port =
11057 rte_cpu_to_be_16(res->port_dst);
11058 entry.input.flow.udp6_flow.src_port =
11059 rte_cpu_to_be_16(res->port_src);
11061 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11062 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11063 entry.input.flow.sctp6_flow.ip.dst_ip);
11064 IPV6_ADDR_TO_ARRAY(res->ip_src,
11065 entry.input.flow.sctp6_flow.ip.src_ip);
11066 entry.input.flow.ipv6_flow.tc = res->tos_value;
11067 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11068 /* need convert to big endian. */
11069 entry.input.flow.sctp6_flow.dst_port =
11070 rte_cpu_to_be_16(res->port_dst);
11071 entry.input.flow.sctp6_flow.src_port =
11072 rte_cpu_to_be_16(res->port_src);
11073 entry.input.flow.sctp6_flow.verify_tag =
11074 rte_cpu_to_be_32(res->verify_tag_value);
11076 case RTE_ETH_FLOW_L2_PAYLOAD:
11077 entry.input.flow.l2_flow.ether_type =
11078 rte_cpu_to_be_16(res->ether_type);
11084 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11085 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11087 sizeof(struct rte_ether_addr));
11089 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11090 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11092 sizeof(struct rte_ether_addr));
11093 entry.input.flow.tunnel_flow.tunnel_type =
11094 str2fdir_tunneltype(res->tunnel_type);
11095 entry.input.flow.tunnel_flow.tunnel_id =
11096 rte_cpu_to_be_32(res->tunnel_id_value);
11099 rte_memcpy(entry.input.flow_ext.flexbytes,
11101 RTE_ETH_FDIR_MAX_FLEXLEN);
11103 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11105 entry.action.flex_off = 0; /*use 0 by default */
11106 if (!strcmp(res->drop, "drop"))
11107 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11109 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11111 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11112 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11113 if (!strcmp(res->pf_vf, "pf"))
11114 entry.input.flow_ext.is_vf = 0;
11115 else if (!strncmp(res->pf_vf, "vf", 2)) {
11116 struct rte_eth_dev_info dev_info;
11118 ret = eth_dev_info_get_print_err(res->port_id,
11124 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11125 if (errno != 0 || *end != '\0' ||
11126 vf_id >= dev_info.max_vfs) {
11127 printf("invalid parameter %s.\n", res->pf_vf);
11130 entry.input.flow_ext.is_vf = 1;
11131 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11133 printf("invalid parameter %s.\n", res->pf_vf);
11138 /* set to report FD ID by default */
11139 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11140 entry.action.rx_queue = res->queue_id;
11141 entry.soft_id = res->fd_id_value;
11142 if (!strcmp(res->ops, "add"))
11143 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11144 RTE_ETH_FILTER_ADD, &entry);
11145 else if (!strcmp(res->ops, "del"))
11146 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11147 RTE_ETH_FILTER_DELETE, &entry);
11149 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11150 RTE_ETH_FILTER_UPDATE, &entry);
11152 printf("flow director programming error: (%s)\n",
11156 cmdline_parse_token_string_t cmd_flow_director_filter =
11157 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11158 flow_director_filter, "flow_director_filter");
11159 cmdline_parse_token_num_t cmd_flow_director_port_id =
11160 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11162 cmdline_parse_token_string_t cmd_flow_director_ops =
11163 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11164 ops, "add#del#update");
11165 cmdline_parse_token_string_t cmd_flow_director_flow =
11166 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11168 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11169 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11171 cmdline_parse_token_string_t cmd_flow_director_ether =
11172 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11174 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11175 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11176 ether_type, UINT16);
11177 cmdline_parse_token_string_t cmd_flow_director_src =
11178 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11180 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11181 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11183 cmdline_parse_token_num_t cmd_flow_director_port_src =
11184 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11186 cmdline_parse_token_string_t cmd_flow_director_dst =
11187 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11189 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11190 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11192 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11193 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11195 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11196 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11197 verify_tag, "verify_tag");
11198 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11199 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11200 verify_tag_value, UINT32);
11201 cmdline_parse_token_string_t cmd_flow_director_tos =
11202 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11204 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11205 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11207 cmdline_parse_token_string_t cmd_flow_director_proto =
11208 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11210 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11211 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11212 proto_value, UINT8);
11213 cmdline_parse_token_string_t cmd_flow_director_ttl =
11214 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11216 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11217 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11219 cmdline_parse_token_string_t cmd_flow_director_vlan =
11220 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11222 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11223 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11224 vlan_value, UINT16);
11225 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11226 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11227 flexbytes, "flexbytes");
11228 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11229 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11230 flexbytes_value, NULL);
11231 cmdline_parse_token_string_t cmd_flow_director_drop =
11232 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11234 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11235 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11237 cmdline_parse_token_string_t cmd_flow_director_queue =
11238 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11240 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11241 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11243 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11244 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11246 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11247 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11248 fd_id_value, UINT32);
11250 cmdline_parse_token_string_t cmd_flow_director_mode =
11251 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11253 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11254 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11256 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11257 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11258 mode_value, "MAC-VLAN");
11259 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11260 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11261 mode_value, "Tunnel");
11262 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11263 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11264 mode_value, "raw");
11265 cmdline_parse_token_string_t cmd_flow_director_mac =
11266 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11268 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11269 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11271 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11272 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11274 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11275 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11276 tunnel_type, "NVGRE#VxLAN");
11277 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11278 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11279 tunnel_id, "tunnel-id");
11280 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11281 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11282 tunnel_id_value, UINT32);
11283 cmdline_parse_token_string_t cmd_flow_director_packet =
11284 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11286 cmdline_parse_token_string_t cmd_flow_director_filepath =
11287 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11290 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11291 .f = cmd_flow_director_filter_parsed,
11293 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11294 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11295 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11296 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11297 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11298 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11299 "fd_id <fd_id_value>: "
11300 "Add or delete an ip flow director entry on NIC",
11302 (void *)&cmd_flow_director_filter,
11303 (void *)&cmd_flow_director_port_id,
11304 (void *)&cmd_flow_director_mode,
11305 (void *)&cmd_flow_director_mode_ip,
11306 (void *)&cmd_flow_director_ops,
11307 (void *)&cmd_flow_director_flow,
11308 (void *)&cmd_flow_director_flow_type,
11309 (void *)&cmd_flow_director_src,
11310 (void *)&cmd_flow_director_ip_src,
11311 (void *)&cmd_flow_director_dst,
11312 (void *)&cmd_flow_director_ip_dst,
11313 (void *)&cmd_flow_director_tos,
11314 (void *)&cmd_flow_director_tos_value,
11315 (void *)&cmd_flow_director_proto,
11316 (void *)&cmd_flow_director_proto_value,
11317 (void *)&cmd_flow_director_ttl,
11318 (void *)&cmd_flow_director_ttl_value,
11319 (void *)&cmd_flow_director_vlan,
11320 (void *)&cmd_flow_director_vlan_value,
11321 (void *)&cmd_flow_director_flexbytes,
11322 (void *)&cmd_flow_director_flexbytes_value,
11323 (void *)&cmd_flow_director_drop,
11324 (void *)&cmd_flow_director_pf_vf,
11325 (void *)&cmd_flow_director_queue,
11326 (void *)&cmd_flow_director_queue_id,
11327 (void *)&cmd_flow_director_fd_id,
11328 (void *)&cmd_flow_director_fd_id_value,
11333 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11334 .f = cmd_flow_director_filter_parsed,
11336 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11337 "director entry on NIC",
11339 (void *)&cmd_flow_director_filter,
11340 (void *)&cmd_flow_director_port_id,
11341 (void *)&cmd_flow_director_mode,
11342 (void *)&cmd_flow_director_mode_ip,
11343 (void *)&cmd_flow_director_ops,
11344 (void *)&cmd_flow_director_flow,
11345 (void *)&cmd_flow_director_flow_type,
11346 (void *)&cmd_flow_director_src,
11347 (void *)&cmd_flow_director_ip_src,
11348 (void *)&cmd_flow_director_port_src,
11349 (void *)&cmd_flow_director_dst,
11350 (void *)&cmd_flow_director_ip_dst,
11351 (void *)&cmd_flow_director_port_dst,
11352 (void *)&cmd_flow_director_tos,
11353 (void *)&cmd_flow_director_tos_value,
11354 (void *)&cmd_flow_director_ttl,
11355 (void *)&cmd_flow_director_ttl_value,
11356 (void *)&cmd_flow_director_vlan,
11357 (void *)&cmd_flow_director_vlan_value,
11358 (void *)&cmd_flow_director_flexbytes,
11359 (void *)&cmd_flow_director_flexbytes_value,
11360 (void *)&cmd_flow_director_drop,
11361 (void *)&cmd_flow_director_pf_vf,
11362 (void *)&cmd_flow_director_queue,
11363 (void *)&cmd_flow_director_queue_id,
11364 (void *)&cmd_flow_director_fd_id,
11365 (void *)&cmd_flow_director_fd_id_value,
11370 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11371 .f = cmd_flow_director_filter_parsed,
11373 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11374 "director entry on NIC",
11376 (void *)&cmd_flow_director_filter,
11377 (void *)&cmd_flow_director_port_id,
11378 (void *)&cmd_flow_director_mode,
11379 (void *)&cmd_flow_director_mode_ip,
11380 (void *)&cmd_flow_director_ops,
11381 (void *)&cmd_flow_director_flow,
11382 (void *)&cmd_flow_director_flow_type,
11383 (void *)&cmd_flow_director_src,
11384 (void *)&cmd_flow_director_ip_src,
11385 (void *)&cmd_flow_director_port_src,
11386 (void *)&cmd_flow_director_dst,
11387 (void *)&cmd_flow_director_ip_dst,
11388 (void *)&cmd_flow_director_port_dst,
11389 (void *)&cmd_flow_director_verify_tag,
11390 (void *)&cmd_flow_director_verify_tag_value,
11391 (void *)&cmd_flow_director_tos,
11392 (void *)&cmd_flow_director_tos_value,
11393 (void *)&cmd_flow_director_ttl,
11394 (void *)&cmd_flow_director_ttl_value,
11395 (void *)&cmd_flow_director_vlan,
11396 (void *)&cmd_flow_director_vlan_value,
11397 (void *)&cmd_flow_director_flexbytes,
11398 (void *)&cmd_flow_director_flexbytes_value,
11399 (void *)&cmd_flow_director_drop,
11400 (void *)&cmd_flow_director_pf_vf,
11401 (void *)&cmd_flow_director_queue,
11402 (void *)&cmd_flow_director_queue_id,
11403 (void *)&cmd_flow_director_fd_id,
11404 (void *)&cmd_flow_director_fd_id_value,
11409 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11410 .f = cmd_flow_director_filter_parsed,
11412 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11413 "director entry on NIC",
11415 (void *)&cmd_flow_director_filter,
11416 (void *)&cmd_flow_director_port_id,
11417 (void *)&cmd_flow_director_mode,
11418 (void *)&cmd_flow_director_mode_ip,
11419 (void *)&cmd_flow_director_ops,
11420 (void *)&cmd_flow_director_flow,
11421 (void *)&cmd_flow_director_flow_type,
11422 (void *)&cmd_flow_director_ether,
11423 (void *)&cmd_flow_director_ether_type,
11424 (void *)&cmd_flow_director_flexbytes,
11425 (void *)&cmd_flow_director_flexbytes_value,
11426 (void *)&cmd_flow_director_drop,
11427 (void *)&cmd_flow_director_pf_vf,
11428 (void *)&cmd_flow_director_queue,
11429 (void *)&cmd_flow_director_queue_id,
11430 (void *)&cmd_flow_director_fd_id,
11431 (void *)&cmd_flow_director_fd_id_value,
11436 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11437 .f = cmd_flow_director_filter_parsed,
11439 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11440 "director entry on NIC",
11442 (void *)&cmd_flow_director_filter,
11443 (void *)&cmd_flow_director_port_id,
11444 (void *)&cmd_flow_director_mode,
11445 (void *)&cmd_flow_director_mode_mac_vlan,
11446 (void *)&cmd_flow_director_ops,
11447 (void *)&cmd_flow_director_mac,
11448 (void *)&cmd_flow_director_mac_addr,
11449 (void *)&cmd_flow_director_vlan,
11450 (void *)&cmd_flow_director_vlan_value,
11451 (void *)&cmd_flow_director_flexbytes,
11452 (void *)&cmd_flow_director_flexbytes_value,
11453 (void *)&cmd_flow_director_drop,
11454 (void *)&cmd_flow_director_queue,
11455 (void *)&cmd_flow_director_queue_id,
11456 (void *)&cmd_flow_director_fd_id,
11457 (void *)&cmd_flow_director_fd_id_value,
11462 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11463 .f = cmd_flow_director_filter_parsed,
11465 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11466 "director entry on NIC",
11468 (void *)&cmd_flow_director_filter,
11469 (void *)&cmd_flow_director_port_id,
11470 (void *)&cmd_flow_director_mode,
11471 (void *)&cmd_flow_director_mode_tunnel,
11472 (void *)&cmd_flow_director_ops,
11473 (void *)&cmd_flow_director_mac,
11474 (void *)&cmd_flow_director_mac_addr,
11475 (void *)&cmd_flow_director_vlan,
11476 (void *)&cmd_flow_director_vlan_value,
11477 (void *)&cmd_flow_director_tunnel,
11478 (void *)&cmd_flow_director_tunnel_type,
11479 (void *)&cmd_flow_director_tunnel_id,
11480 (void *)&cmd_flow_director_tunnel_id_value,
11481 (void *)&cmd_flow_director_flexbytes,
11482 (void *)&cmd_flow_director_flexbytes_value,
11483 (void *)&cmd_flow_director_drop,
11484 (void *)&cmd_flow_director_queue,
11485 (void *)&cmd_flow_director_queue_id,
11486 (void *)&cmd_flow_director_fd_id,
11487 (void *)&cmd_flow_director_fd_id_value,
11492 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11493 .f = cmd_flow_director_filter_parsed,
11495 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11496 "director entry on NIC",
11498 (void *)&cmd_flow_director_filter,
11499 (void *)&cmd_flow_director_port_id,
11500 (void *)&cmd_flow_director_mode,
11501 (void *)&cmd_flow_director_mode_raw,
11502 (void *)&cmd_flow_director_ops,
11503 (void *)&cmd_flow_director_flow,
11504 (void *)&cmd_flow_director_flow_type,
11505 (void *)&cmd_flow_director_drop,
11506 (void *)&cmd_flow_director_queue,
11507 (void *)&cmd_flow_director_queue_id,
11508 (void *)&cmd_flow_director_fd_id,
11509 (void *)&cmd_flow_director_fd_id_value,
11510 (void *)&cmd_flow_director_packet,
11511 (void *)&cmd_flow_director_filepath,
11516 struct cmd_flush_flow_director_result {
11517 cmdline_fixed_string_t flush_flow_director;
11521 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11522 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11523 flush_flow_director, "flush_flow_director");
11524 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11525 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11529 cmd_flush_flow_director_parsed(void *parsed_result,
11530 __attribute__((unused)) struct cmdline *cl,
11531 __attribute__((unused)) void *data)
11533 struct cmd_flow_director_result *res = parsed_result;
11536 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11538 printf("flow director is not supported on port %u.\n",
11543 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11544 RTE_ETH_FILTER_FLUSH, NULL);
11546 printf("flow director table flushing error: (%s)\n",
11550 cmdline_parse_inst_t cmd_flush_flow_director = {
11551 .f = cmd_flush_flow_director_parsed,
11553 .help_str = "flush_flow_director <port_id>: "
11554 "Flush all flow director entries of a device on NIC",
11556 (void *)&cmd_flush_flow_director_flush,
11557 (void *)&cmd_flush_flow_director_port_id,
11562 /* *** deal with flow director mask *** */
11563 struct cmd_flow_director_mask_result {
11564 cmdline_fixed_string_t flow_director_mask;
11566 cmdline_fixed_string_t mode;
11567 cmdline_fixed_string_t mode_value;
11568 cmdline_fixed_string_t vlan;
11569 uint16_t vlan_mask;
11570 cmdline_fixed_string_t src_mask;
11571 cmdline_ipaddr_t ipv4_src;
11572 cmdline_ipaddr_t ipv6_src;
11574 cmdline_fixed_string_t dst_mask;
11575 cmdline_ipaddr_t ipv4_dst;
11576 cmdline_ipaddr_t ipv6_dst;
11578 cmdline_fixed_string_t mac;
11579 uint8_t mac_addr_byte_mask;
11580 cmdline_fixed_string_t tunnel_id;
11581 uint32_t tunnel_id_mask;
11582 cmdline_fixed_string_t tunnel_type;
11583 uint8_t tunnel_type_mask;
11587 cmd_flow_director_mask_parsed(void *parsed_result,
11588 __attribute__((unused)) struct cmdline *cl,
11589 __attribute__((unused)) void *data)
11591 struct cmd_flow_director_mask_result *res = parsed_result;
11592 struct rte_eth_fdir_masks *mask;
11593 struct rte_port *port;
11595 port = &ports[res->port_id];
11596 /** Check if the port is not started **/
11597 if (port->port_status != RTE_PORT_STOPPED) {
11598 printf("Please stop port %d first\n", res->port_id);
11602 mask = &port->dev_conf.fdir_conf.mask;
11604 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11605 if (strcmp(res->mode_value, "MAC-VLAN")) {
11606 printf("Please set mode to MAC-VLAN.\n");
11610 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11611 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11612 if (strcmp(res->mode_value, "Tunnel")) {
11613 printf("Please set mode to Tunnel.\n");
11617 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11618 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11619 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11620 mask->tunnel_type_mask = res->tunnel_type_mask;
11622 if (strcmp(res->mode_value, "IP")) {
11623 printf("Please set mode to IP.\n");
11627 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11628 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11629 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11630 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11631 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11632 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11633 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11636 cmd_reconfig_device_queue(res->port_id, 1, 1);
11639 cmdline_parse_token_string_t cmd_flow_director_mask =
11640 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11641 flow_director_mask, "flow_director_mask");
11642 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11643 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11645 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11646 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11648 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11649 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11650 vlan_mask, UINT16);
11651 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11652 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11653 src_mask, "src_mask");
11654 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11655 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11657 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11658 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11660 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11661 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11663 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11664 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11665 dst_mask, "dst_mask");
11666 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11667 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11669 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11670 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11672 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11673 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11676 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11677 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11679 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11680 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11682 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11683 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11684 mode_value, "MAC-VLAN");
11685 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11686 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11687 mode_value, "Tunnel");
11688 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11689 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11691 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11692 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11693 mac_addr_byte_mask, UINT8);
11694 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11695 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11696 tunnel_type, "tunnel-type");
11697 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11698 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11699 tunnel_type_mask, UINT8);
11700 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11701 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11702 tunnel_id, "tunnel-id");
11703 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11704 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11705 tunnel_id_mask, UINT32);
11707 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11708 .f = cmd_flow_director_mask_parsed,
11710 .help_str = "flow_director_mask ... : "
11711 "Set IP mode flow director's mask on NIC",
11713 (void *)&cmd_flow_director_mask,
11714 (void *)&cmd_flow_director_mask_port_id,
11715 (void *)&cmd_flow_director_mask_mode,
11716 (void *)&cmd_flow_director_mask_mode_ip,
11717 (void *)&cmd_flow_director_mask_vlan,
11718 (void *)&cmd_flow_director_mask_vlan_value,
11719 (void *)&cmd_flow_director_mask_src,
11720 (void *)&cmd_flow_director_mask_ipv4_src,
11721 (void *)&cmd_flow_director_mask_ipv6_src,
11722 (void *)&cmd_flow_director_mask_port_src,
11723 (void *)&cmd_flow_director_mask_dst,
11724 (void *)&cmd_flow_director_mask_ipv4_dst,
11725 (void *)&cmd_flow_director_mask_ipv6_dst,
11726 (void *)&cmd_flow_director_mask_port_dst,
11731 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11732 .f = cmd_flow_director_mask_parsed,
11734 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11735 "flow director's mask on NIC",
11737 (void *)&cmd_flow_director_mask,
11738 (void *)&cmd_flow_director_mask_port_id,
11739 (void *)&cmd_flow_director_mask_mode,
11740 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11741 (void *)&cmd_flow_director_mask_vlan,
11742 (void *)&cmd_flow_director_mask_vlan_value,
11747 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11748 .f = cmd_flow_director_mask_parsed,
11750 .help_str = "flow_director_mask ... : Set tunnel mode "
11751 "flow director's mask on NIC",
11753 (void *)&cmd_flow_director_mask,
11754 (void *)&cmd_flow_director_mask_port_id,
11755 (void *)&cmd_flow_director_mask_mode,
11756 (void *)&cmd_flow_director_mask_mode_tunnel,
11757 (void *)&cmd_flow_director_mask_vlan,
11758 (void *)&cmd_flow_director_mask_vlan_value,
11759 (void *)&cmd_flow_director_mask_mac,
11760 (void *)&cmd_flow_director_mask_mac_value,
11761 (void *)&cmd_flow_director_mask_tunnel_type,
11762 (void *)&cmd_flow_director_mask_tunnel_type_value,
11763 (void *)&cmd_flow_director_mask_tunnel_id,
11764 (void *)&cmd_flow_director_mask_tunnel_id_value,
11769 /* *** deal with flow director mask on flexible payload *** */
11770 struct cmd_flow_director_flex_mask_result {
11771 cmdline_fixed_string_t flow_director_flexmask;
11773 cmdline_fixed_string_t flow;
11774 cmdline_fixed_string_t flow_type;
11775 cmdline_fixed_string_t mask;
11779 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11780 __attribute__((unused)) struct cmdline *cl,
11781 __attribute__((unused)) void *data)
11783 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11784 struct rte_eth_fdir_info fdir_info;
11785 struct rte_eth_fdir_flex_mask flex_mask;
11786 struct rte_port *port;
11787 uint64_t flow_type_mask;
11791 port = &ports[res->port_id];
11792 /** Check if the port is not started **/
11793 if (port->port_status != RTE_PORT_STOPPED) {
11794 printf("Please stop port %d first\n", res->port_id);
11798 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11799 ret = parse_flexbytes(res->mask,
11801 RTE_ETH_FDIR_MAX_FLEXLEN);
11803 printf("error: Cannot parse mask input.\n");
11807 memset(&fdir_info, 0, sizeof(fdir_info));
11808 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11809 RTE_ETH_FILTER_INFO, &fdir_info);
11811 printf("Cannot get FDir filter info\n");
11815 if (!strcmp(res->flow_type, "none")) {
11816 /* means don't specify the flow type */
11817 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11818 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11819 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11820 0, sizeof(struct rte_eth_fdir_flex_mask));
11821 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11822 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11824 sizeof(struct rte_eth_fdir_flex_mask));
11825 cmd_reconfig_device_queue(res->port_id, 1, 1);
11828 flow_type_mask = fdir_info.flow_types_mask[0];
11829 if (!strcmp(res->flow_type, "all")) {
11830 if (!flow_type_mask) {
11831 printf("No flow type supported\n");
11834 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11835 if (flow_type_mask & (1ULL << i)) {
11836 flex_mask.flow_type = i;
11837 fdir_set_flex_mask(res->port_id, &flex_mask);
11840 cmd_reconfig_device_queue(res->port_id, 1, 1);
11843 flex_mask.flow_type = str2flowtype(res->flow_type);
11844 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11845 printf("Flow type %s not supported on port %d\n",
11846 res->flow_type, res->port_id);
11849 fdir_set_flex_mask(res->port_id, &flex_mask);
11850 cmd_reconfig_device_queue(res->port_id, 1, 1);
11853 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11854 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11855 flow_director_flexmask,
11856 "flow_director_flex_mask");
11857 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11858 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11860 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11861 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11863 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11864 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11865 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11866 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11867 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11868 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11871 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11872 .f = cmd_flow_director_flex_mask_parsed,
11874 .help_str = "flow_director_flex_mask ... : "
11875 "Set flow director's flex mask on NIC",
11877 (void *)&cmd_flow_director_flexmask,
11878 (void *)&cmd_flow_director_flexmask_port_id,
11879 (void *)&cmd_flow_director_flexmask_flow,
11880 (void *)&cmd_flow_director_flexmask_flow_type,
11881 (void *)&cmd_flow_director_flexmask_mask,
11886 /* *** deal with flow director flexible payload configuration *** */
11887 struct cmd_flow_director_flexpayload_result {
11888 cmdline_fixed_string_t flow_director_flexpayload;
11890 cmdline_fixed_string_t payload_layer;
11891 cmdline_fixed_string_t payload_cfg;
11895 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11898 const char *p, *p0 = q_arg;
11900 unsigned long int_fld;
11901 char *str_fld[max_num];
11906 p = strchr(p0, '(');
11910 p0 = strchr(p, ')');
11915 if (size >= sizeof(s))
11918 snprintf(s, sizeof(s), "%.*s", size, p);
11919 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11920 if (ret < 0 || ret > max_num)
11922 for (i = 0; i < ret; i++) {
11924 int_fld = strtoul(str_fld[i], &end, 0);
11925 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11927 offsets[i] = (uint16_t)int_fld;
11933 cmd_flow_director_flxpld_parsed(void *parsed_result,
11934 __attribute__((unused)) struct cmdline *cl,
11935 __attribute__((unused)) void *data)
11937 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11938 struct rte_eth_flex_payload_cfg flex_cfg;
11939 struct rte_port *port;
11942 port = &ports[res->port_id];
11943 /** Check if the port is not started **/
11944 if (port->port_status != RTE_PORT_STOPPED) {
11945 printf("Please stop port %d first\n", res->port_id);
11949 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11951 if (!strcmp(res->payload_layer, "raw"))
11952 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11953 else if (!strcmp(res->payload_layer, "l2"))
11954 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11955 else if (!strcmp(res->payload_layer, "l3"))
11956 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11957 else if (!strcmp(res->payload_layer, "l4"))
11958 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11960 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11961 RTE_ETH_FDIR_MAX_FLEXLEN);
11963 printf("error: Cannot parse flex payload input.\n");
11967 fdir_set_flex_payload(res->port_id, &flex_cfg);
11968 cmd_reconfig_device_queue(res->port_id, 1, 1);
11971 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11972 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11973 flow_director_flexpayload,
11974 "flow_director_flex_payload");
11975 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11976 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11978 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11979 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11980 payload_layer, "raw#l2#l3#l4");
11981 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11982 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11983 payload_cfg, NULL);
11985 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11986 .f = cmd_flow_director_flxpld_parsed,
11988 .help_str = "flow_director_flexpayload ... : "
11989 "Set flow director's flex payload on NIC",
11991 (void *)&cmd_flow_director_flexpayload,
11992 (void *)&cmd_flow_director_flexpayload_port_id,
11993 (void *)&cmd_flow_director_flexpayload_payload_layer,
11994 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11999 /* Generic flow interface command. */
12000 extern cmdline_parse_inst_t cmd_flow;
12002 /* *** Classification Filters Control *** */
12003 /* *** Get symmetric hash enable per port *** */
12004 struct cmd_get_sym_hash_ena_per_port_result {
12005 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12010 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12011 __rte_unused struct cmdline *cl,
12012 __rte_unused void *data)
12014 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12015 struct rte_eth_hash_filter_info info;
12018 if (rte_eth_dev_filter_supported(res->port_id,
12019 RTE_ETH_FILTER_HASH) < 0) {
12020 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12025 memset(&info, 0, sizeof(info));
12026 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12027 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12028 RTE_ETH_FILTER_GET, &info);
12031 printf("Cannot get symmetric hash enable per port "
12032 "on port %u\n", res->port_id);
12036 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12037 "enabled" : "disabled", res->port_id);
12040 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12041 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12042 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12043 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12044 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12047 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12048 .f = cmd_get_sym_hash_per_port_parsed,
12050 .help_str = "get_sym_hash_ena_per_port <port_id>",
12052 (void *)&cmd_get_sym_hash_ena_per_port_all,
12053 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12058 /* *** Set symmetric hash enable per port *** */
12059 struct cmd_set_sym_hash_ena_per_port_result {
12060 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12061 cmdline_fixed_string_t enable;
12066 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12067 __rte_unused struct cmdline *cl,
12068 __rte_unused void *data)
12070 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12071 struct rte_eth_hash_filter_info info;
12074 if (rte_eth_dev_filter_supported(res->port_id,
12075 RTE_ETH_FILTER_HASH) < 0) {
12076 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12081 memset(&info, 0, sizeof(info));
12082 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12083 if (!strcmp(res->enable, "enable"))
12084 info.info.enable = 1;
12085 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12086 RTE_ETH_FILTER_SET, &info);
12088 printf("Cannot set symmetric hash enable per port on "
12089 "port %u\n", res->port_id);
12092 printf("Symmetric hash has been set to %s on port %u\n",
12093 res->enable, res->port_id);
12096 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12097 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12098 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12099 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12100 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12102 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12103 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12104 enable, "enable#disable");
12106 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12107 .f = cmd_set_sym_hash_per_port_parsed,
12109 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12111 (void *)&cmd_set_sym_hash_ena_per_port_all,
12112 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12113 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12118 /* Get global config of hash function */
12119 struct cmd_get_hash_global_config_result {
12120 cmdline_fixed_string_t get_hash_global_config;
12125 flowtype_to_str(uint16_t ftype)
12131 } ftype_table[] = {
12132 {"ipv4", RTE_ETH_FLOW_IPV4},
12133 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12134 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12135 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12136 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12137 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12138 {"ipv6", RTE_ETH_FLOW_IPV6},
12139 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12140 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12141 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12142 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12143 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12144 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12145 {"port", RTE_ETH_FLOW_PORT},
12146 {"vxlan", RTE_ETH_FLOW_VXLAN},
12147 {"geneve", RTE_ETH_FLOW_GENEVE},
12148 {"nvgre", RTE_ETH_FLOW_NVGRE},
12149 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12152 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12153 if (ftype_table[i].ftype == ftype)
12154 return ftype_table[i].str;
12161 cmd_get_hash_global_config_parsed(void *parsed_result,
12162 __rte_unused struct cmdline *cl,
12163 __rte_unused void *data)
12165 struct cmd_get_hash_global_config_result *res = parsed_result;
12166 struct rte_eth_hash_filter_info info;
12167 uint32_t idx, offset;
12172 if (rte_eth_dev_filter_supported(res->port_id,
12173 RTE_ETH_FILTER_HASH) < 0) {
12174 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12179 memset(&info, 0, sizeof(info));
12180 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12181 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12182 RTE_ETH_FILTER_GET, &info);
12184 printf("Cannot get hash global configurations by port %d\n",
12189 switch (info.info.global_conf.hash_func) {
12190 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12191 printf("Hash function is Toeplitz\n");
12193 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12194 printf("Hash function is Simple XOR\n");
12197 printf("Unknown hash function\n");
12201 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12202 idx = i / UINT64_BIT;
12203 offset = i % UINT64_BIT;
12204 if (!(info.info.global_conf.valid_bit_mask[idx] &
12207 str = flowtype_to_str(i);
12210 printf("Symmetric hash is %s globally for flow type %s "
12212 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12213 (1ULL << offset)) ? "enabled" : "disabled"), str,
12218 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12219 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12220 get_hash_global_config, "get_hash_global_config");
12221 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12222 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12225 cmdline_parse_inst_t cmd_get_hash_global_config = {
12226 .f = cmd_get_hash_global_config_parsed,
12228 .help_str = "get_hash_global_config <port_id>",
12230 (void *)&cmd_get_hash_global_config_all,
12231 (void *)&cmd_get_hash_global_config_port_id,
12236 /* Set global config of hash function */
12237 struct cmd_set_hash_global_config_result {
12238 cmdline_fixed_string_t set_hash_global_config;
12240 cmdline_fixed_string_t hash_func;
12241 cmdline_fixed_string_t flow_type;
12242 cmdline_fixed_string_t enable;
12246 cmd_set_hash_global_config_parsed(void *parsed_result,
12247 __rte_unused struct cmdline *cl,
12248 __rte_unused void *data)
12250 struct cmd_set_hash_global_config_result *res = parsed_result;
12251 struct rte_eth_hash_filter_info info;
12252 uint32_t ftype, idx, offset;
12255 if (rte_eth_dev_filter_supported(res->port_id,
12256 RTE_ETH_FILTER_HASH) < 0) {
12257 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12261 memset(&info, 0, sizeof(info));
12262 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12263 if (!strcmp(res->hash_func, "toeplitz"))
12264 info.info.global_conf.hash_func =
12265 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12266 else if (!strcmp(res->hash_func, "simple_xor"))
12267 info.info.global_conf.hash_func =
12268 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12269 else if (!strcmp(res->hash_func, "default"))
12270 info.info.global_conf.hash_func =
12271 RTE_ETH_HASH_FUNCTION_DEFAULT;
12273 ftype = str2flowtype(res->flow_type);
12274 idx = ftype / UINT64_BIT;
12275 offset = ftype % UINT64_BIT;
12276 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12277 if (!strcmp(res->enable, "enable"))
12278 info.info.global_conf.sym_hash_enable_mask[idx] |=
12280 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12281 RTE_ETH_FILTER_SET, &info);
12283 printf("Cannot set global hash configurations by port %d\n",
12286 printf("Global hash configurations have been set "
12287 "successfully by port %d\n", res->port_id);
12290 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12291 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12292 set_hash_global_config, "set_hash_global_config");
12293 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12294 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12296 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12297 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12298 hash_func, "toeplitz#simple_xor#default");
12299 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12300 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12302 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12303 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12304 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12305 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12306 enable, "enable#disable");
12308 cmdline_parse_inst_t cmd_set_hash_global_config = {
12309 .f = cmd_set_hash_global_config_parsed,
12311 .help_str = "set_hash_global_config <port_id> "
12312 "toeplitz|simple_xor|default "
12313 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12314 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12315 "l2_payload enable|disable",
12317 (void *)&cmd_set_hash_global_config_all,
12318 (void *)&cmd_set_hash_global_config_port_id,
12319 (void *)&cmd_set_hash_global_config_hash_func,
12320 (void *)&cmd_set_hash_global_config_flow_type,
12321 (void *)&cmd_set_hash_global_config_enable,
12326 /* Set hash input set */
12327 struct cmd_set_hash_input_set_result {
12328 cmdline_fixed_string_t set_hash_input_set;
12330 cmdline_fixed_string_t flow_type;
12331 cmdline_fixed_string_t inset_field;
12332 cmdline_fixed_string_t select;
12335 static enum rte_eth_input_set_field
12336 str2inset(char *string)
12340 static const struct {
12342 enum rte_eth_input_set_field inset;
12343 } inset_table[] = {
12344 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12345 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12346 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12347 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12348 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12349 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12350 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12351 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12352 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12353 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12354 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12355 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12356 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12357 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12358 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12359 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12360 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12361 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12362 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12363 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12364 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12365 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12366 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12367 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12368 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12369 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12370 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12371 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12372 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12373 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12374 {"none", RTE_ETH_INPUT_SET_NONE},
12377 for (i = 0; i < RTE_DIM(inset_table); i++) {
12378 if (!strcmp(string, inset_table[i].str))
12379 return inset_table[i].inset;
12382 return RTE_ETH_INPUT_SET_UNKNOWN;
12386 cmd_set_hash_input_set_parsed(void *parsed_result,
12387 __rte_unused struct cmdline *cl,
12388 __rte_unused void *data)
12390 struct cmd_set_hash_input_set_result *res = parsed_result;
12391 struct rte_eth_hash_filter_info info;
12393 memset(&info, 0, sizeof(info));
12394 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12395 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12396 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12397 info.info.input_set_conf.inset_size = 1;
12398 if (!strcmp(res->select, "select"))
12399 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12400 else if (!strcmp(res->select, "add"))
12401 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12402 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12403 RTE_ETH_FILTER_SET, &info);
12406 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12407 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12408 set_hash_input_set, "set_hash_input_set");
12409 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12410 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12412 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12413 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12415 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12416 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12418 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12419 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12420 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12421 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12422 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12424 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12425 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12426 select, "select#add");
12428 cmdline_parse_inst_t cmd_set_hash_input_set = {
12429 .f = cmd_set_hash_input_set_parsed,
12431 .help_str = "set_hash_input_set <port_id> "
12432 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12433 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12434 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12435 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12436 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12437 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12438 "fld-7th|fld-8th|none select|add",
12440 (void *)&cmd_set_hash_input_set_cmd,
12441 (void *)&cmd_set_hash_input_set_port_id,
12442 (void *)&cmd_set_hash_input_set_flow_type,
12443 (void *)&cmd_set_hash_input_set_field,
12444 (void *)&cmd_set_hash_input_set_select,
12449 /* Set flow director input set */
12450 struct cmd_set_fdir_input_set_result {
12451 cmdline_fixed_string_t set_fdir_input_set;
12453 cmdline_fixed_string_t flow_type;
12454 cmdline_fixed_string_t inset_field;
12455 cmdline_fixed_string_t select;
12459 cmd_set_fdir_input_set_parsed(void *parsed_result,
12460 __rte_unused struct cmdline *cl,
12461 __rte_unused void *data)
12463 struct cmd_set_fdir_input_set_result *res = parsed_result;
12464 struct rte_eth_fdir_filter_info info;
12466 memset(&info, 0, sizeof(info));
12467 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12468 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12469 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12470 info.info.input_set_conf.inset_size = 1;
12471 if (!strcmp(res->select, "select"))
12472 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12473 else if (!strcmp(res->select, "add"))
12474 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12475 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12476 RTE_ETH_FILTER_SET, &info);
12479 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12480 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12481 set_fdir_input_set, "set_fdir_input_set");
12482 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12483 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12485 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12486 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12488 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12489 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12490 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12491 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12493 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12494 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12495 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12496 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12497 "sctp-veri-tag#none");
12498 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12499 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12500 select, "select#add");
12502 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12503 .f = cmd_set_fdir_input_set_parsed,
12505 .help_str = "set_fdir_input_set <port_id> "
12506 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12507 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12508 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12509 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12510 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12511 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12512 "sctp-veri-tag|none select|add",
12514 (void *)&cmd_set_fdir_input_set_cmd,
12515 (void *)&cmd_set_fdir_input_set_port_id,
12516 (void *)&cmd_set_fdir_input_set_flow_type,
12517 (void *)&cmd_set_fdir_input_set_field,
12518 (void *)&cmd_set_fdir_input_set_select,
12523 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12524 struct cmd_mcast_addr_result {
12525 cmdline_fixed_string_t mcast_addr_cmd;
12526 cmdline_fixed_string_t what;
12528 struct rte_ether_addr mc_addr;
12531 static void cmd_mcast_addr_parsed(void *parsed_result,
12532 __attribute__((unused)) struct cmdline *cl,
12533 __attribute__((unused)) void *data)
12535 struct cmd_mcast_addr_result *res = parsed_result;
12537 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12538 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12539 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12540 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12541 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12544 if (strcmp(res->what, "add") == 0)
12545 mcast_addr_add(res->port_num, &res->mc_addr);
12547 mcast_addr_remove(res->port_num, &res->mc_addr);
12550 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12551 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12552 mcast_addr_cmd, "mcast_addr");
12553 cmdline_parse_token_string_t cmd_mcast_addr_what =
12554 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12556 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12557 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12558 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12559 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12561 cmdline_parse_inst_t cmd_mcast_addr = {
12562 .f = cmd_mcast_addr_parsed,
12564 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12565 "Add/Remove multicast MAC address on port_id",
12567 (void *)&cmd_mcast_addr_cmd,
12568 (void *)&cmd_mcast_addr_what,
12569 (void *)&cmd_mcast_addr_portnum,
12570 (void *)&cmd_mcast_addr_addr,
12575 /* l2 tunnel config
12576 * only support E-tag now.
12579 /* Ether type config */
12580 struct cmd_config_l2_tunnel_eth_type_result {
12581 cmdline_fixed_string_t port;
12582 cmdline_fixed_string_t config;
12583 cmdline_fixed_string_t all;
12585 cmdline_fixed_string_t l2_tunnel;
12586 cmdline_fixed_string_t l2_tunnel_type;
12587 cmdline_fixed_string_t eth_type;
12588 uint16_t eth_type_val;
12591 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12592 TOKEN_STRING_INITIALIZER
12593 (struct cmd_config_l2_tunnel_eth_type_result,
12595 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12596 TOKEN_STRING_INITIALIZER
12597 (struct cmd_config_l2_tunnel_eth_type_result,
12599 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12600 TOKEN_STRING_INITIALIZER
12601 (struct cmd_config_l2_tunnel_eth_type_result,
12603 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12604 TOKEN_NUM_INITIALIZER
12605 (struct cmd_config_l2_tunnel_eth_type_result,
12607 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12608 TOKEN_STRING_INITIALIZER
12609 (struct cmd_config_l2_tunnel_eth_type_result,
12610 l2_tunnel, "l2-tunnel");
12611 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12612 TOKEN_STRING_INITIALIZER
12613 (struct cmd_config_l2_tunnel_eth_type_result,
12614 l2_tunnel_type, "E-tag");
12615 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12616 TOKEN_STRING_INITIALIZER
12617 (struct cmd_config_l2_tunnel_eth_type_result,
12618 eth_type, "ether-type");
12619 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12620 TOKEN_NUM_INITIALIZER
12621 (struct cmd_config_l2_tunnel_eth_type_result,
12622 eth_type_val, UINT16);
12624 static enum rte_eth_tunnel_type
12625 str2fdir_l2_tunnel_type(char *string)
12629 static const struct {
12631 enum rte_eth_tunnel_type type;
12632 } l2_tunnel_type_str[] = {
12633 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12636 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12637 if (!strcmp(l2_tunnel_type_str[i].str, string))
12638 return l2_tunnel_type_str[i].type;
12640 return RTE_TUNNEL_TYPE_NONE;
12643 /* ether type config for all ports */
12645 cmd_config_l2_tunnel_eth_type_all_parsed
12646 (void *parsed_result,
12647 __attribute__((unused)) struct cmdline *cl,
12648 __attribute__((unused)) void *data)
12650 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12651 struct rte_eth_l2_tunnel_conf entry;
12654 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12655 entry.ether_type = res->eth_type_val;
12657 RTE_ETH_FOREACH_DEV(pid) {
12658 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12662 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12663 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12665 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12667 (void *)&cmd_config_l2_tunnel_eth_type_port,
12668 (void *)&cmd_config_l2_tunnel_eth_type_config,
12669 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12670 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12671 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12672 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12673 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12678 /* ether type config for a specific port */
12680 cmd_config_l2_tunnel_eth_type_specific_parsed(
12681 void *parsed_result,
12682 __attribute__((unused)) struct cmdline *cl,
12683 __attribute__((unused)) void *data)
12685 struct cmd_config_l2_tunnel_eth_type_result *res =
12687 struct rte_eth_l2_tunnel_conf entry;
12689 if (port_id_is_invalid(res->id, ENABLED_WARN))
12692 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12693 entry.ether_type = res->eth_type_val;
12695 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12698 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12699 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12701 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12703 (void *)&cmd_config_l2_tunnel_eth_type_port,
12704 (void *)&cmd_config_l2_tunnel_eth_type_config,
12705 (void *)&cmd_config_l2_tunnel_eth_type_id,
12706 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12707 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12708 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12709 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12714 /* Enable/disable l2 tunnel */
12715 struct cmd_config_l2_tunnel_en_dis_result {
12716 cmdline_fixed_string_t port;
12717 cmdline_fixed_string_t config;
12718 cmdline_fixed_string_t all;
12720 cmdline_fixed_string_t l2_tunnel;
12721 cmdline_fixed_string_t l2_tunnel_type;
12722 cmdline_fixed_string_t en_dis;
12725 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12726 TOKEN_STRING_INITIALIZER
12727 (struct cmd_config_l2_tunnel_en_dis_result,
12729 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12730 TOKEN_STRING_INITIALIZER
12731 (struct cmd_config_l2_tunnel_en_dis_result,
12733 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12734 TOKEN_STRING_INITIALIZER
12735 (struct cmd_config_l2_tunnel_en_dis_result,
12737 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12738 TOKEN_NUM_INITIALIZER
12739 (struct cmd_config_l2_tunnel_en_dis_result,
12741 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12742 TOKEN_STRING_INITIALIZER
12743 (struct cmd_config_l2_tunnel_en_dis_result,
12744 l2_tunnel, "l2-tunnel");
12745 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12746 TOKEN_STRING_INITIALIZER
12747 (struct cmd_config_l2_tunnel_en_dis_result,
12748 l2_tunnel_type, "E-tag");
12749 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12750 TOKEN_STRING_INITIALIZER
12751 (struct cmd_config_l2_tunnel_en_dis_result,
12752 en_dis, "enable#disable");
12754 /* enable/disable l2 tunnel for all ports */
12756 cmd_config_l2_tunnel_en_dis_all_parsed(
12757 void *parsed_result,
12758 __attribute__((unused)) struct cmdline *cl,
12759 __attribute__((unused)) void *data)
12761 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12762 struct rte_eth_l2_tunnel_conf entry;
12766 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12768 if (!strcmp("enable", res->en_dis))
12773 RTE_ETH_FOREACH_DEV(pid) {
12774 rte_eth_dev_l2_tunnel_offload_set(pid,
12776 ETH_L2_TUNNEL_ENABLE_MASK,
12781 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12782 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12784 .help_str = "port config all l2-tunnel E-tag enable|disable",
12786 (void *)&cmd_config_l2_tunnel_en_dis_port,
12787 (void *)&cmd_config_l2_tunnel_en_dis_config,
12788 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12789 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12790 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12791 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12796 /* enable/disable l2 tunnel for a port */
12798 cmd_config_l2_tunnel_en_dis_specific_parsed(
12799 void *parsed_result,
12800 __attribute__((unused)) struct cmdline *cl,
12801 __attribute__((unused)) void *data)
12803 struct cmd_config_l2_tunnel_en_dis_result *res =
12805 struct rte_eth_l2_tunnel_conf entry;
12807 if (port_id_is_invalid(res->id, ENABLED_WARN))
12810 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12812 if (!strcmp("enable", res->en_dis))
12813 rte_eth_dev_l2_tunnel_offload_set(res->id,
12815 ETH_L2_TUNNEL_ENABLE_MASK,
12818 rte_eth_dev_l2_tunnel_offload_set(res->id,
12820 ETH_L2_TUNNEL_ENABLE_MASK,
12824 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12825 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12827 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12829 (void *)&cmd_config_l2_tunnel_en_dis_port,
12830 (void *)&cmd_config_l2_tunnel_en_dis_config,
12831 (void *)&cmd_config_l2_tunnel_en_dis_id,
12832 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12833 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12834 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12839 /* E-tag configuration */
12841 /* Common result structure for all E-tag configuration */
12842 struct cmd_config_e_tag_result {
12843 cmdline_fixed_string_t e_tag;
12844 cmdline_fixed_string_t set;
12845 cmdline_fixed_string_t insertion;
12846 cmdline_fixed_string_t stripping;
12847 cmdline_fixed_string_t forwarding;
12848 cmdline_fixed_string_t filter;
12849 cmdline_fixed_string_t add;
12850 cmdline_fixed_string_t del;
12851 cmdline_fixed_string_t on;
12852 cmdline_fixed_string_t off;
12853 cmdline_fixed_string_t on_off;
12854 cmdline_fixed_string_t port_tag_id;
12855 uint32_t port_tag_id_val;
12856 cmdline_fixed_string_t e_tag_id;
12857 uint16_t e_tag_id_val;
12858 cmdline_fixed_string_t dst_pool;
12859 uint8_t dst_pool_val;
12860 cmdline_fixed_string_t port;
12862 cmdline_fixed_string_t vf;
12866 /* Common CLI fields for all E-tag configuration */
12867 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12868 TOKEN_STRING_INITIALIZER
12869 (struct cmd_config_e_tag_result,
12871 cmdline_parse_token_string_t cmd_config_e_tag_set =
12872 TOKEN_STRING_INITIALIZER
12873 (struct cmd_config_e_tag_result,
12875 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12876 TOKEN_STRING_INITIALIZER
12877 (struct cmd_config_e_tag_result,
12878 insertion, "insertion");
12879 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12880 TOKEN_STRING_INITIALIZER
12881 (struct cmd_config_e_tag_result,
12882 stripping, "stripping");
12883 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12884 TOKEN_STRING_INITIALIZER
12885 (struct cmd_config_e_tag_result,
12886 forwarding, "forwarding");
12887 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12888 TOKEN_STRING_INITIALIZER
12889 (struct cmd_config_e_tag_result,
12891 cmdline_parse_token_string_t cmd_config_e_tag_add =
12892 TOKEN_STRING_INITIALIZER
12893 (struct cmd_config_e_tag_result,
12895 cmdline_parse_token_string_t cmd_config_e_tag_del =
12896 TOKEN_STRING_INITIALIZER
12897 (struct cmd_config_e_tag_result,
12899 cmdline_parse_token_string_t cmd_config_e_tag_on =
12900 TOKEN_STRING_INITIALIZER
12901 (struct cmd_config_e_tag_result,
12903 cmdline_parse_token_string_t cmd_config_e_tag_off =
12904 TOKEN_STRING_INITIALIZER
12905 (struct cmd_config_e_tag_result,
12907 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12908 TOKEN_STRING_INITIALIZER
12909 (struct cmd_config_e_tag_result,
12911 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12912 TOKEN_STRING_INITIALIZER
12913 (struct cmd_config_e_tag_result,
12914 port_tag_id, "port-tag-id");
12915 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12916 TOKEN_NUM_INITIALIZER
12917 (struct cmd_config_e_tag_result,
12918 port_tag_id_val, UINT32);
12919 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12920 TOKEN_STRING_INITIALIZER
12921 (struct cmd_config_e_tag_result,
12922 e_tag_id, "e-tag-id");
12923 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12924 TOKEN_NUM_INITIALIZER
12925 (struct cmd_config_e_tag_result,
12926 e_tag_id_val, UINT16);
12927 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12928 TOKEN_STRING_INITIALIZER
12929 (struct cmd_config_e_tag_result,
12930 dst_pool, "dst-pool");
12931 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12932 TOKEN_NUM_INITIALIZER
12933 (struct cmd_config_e_tag_result,
12934 dst_pool_val, UINT8);
12935 cmdline_parse_token_string_t cmd_config_e_tag_port =
12936 TOKEN_STRING_INITIALIZER
12937 (struct cmd_config_e_tag_result,
12939 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12940 TOKEN_NUM_INITIALIZER
12941 (struct cmd_config_e_tag_result,
12943 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12944 TOKEN_STRING_INITIALIZER
12945 (struct cmd_config_e_tag_result,
12947 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12948 TOKEN_NUM_INITIALIZER
12949 (struct cmd_config_e_tag_result,
12952 /* E-tag insertion configuration */
12954 cmd_config_e_tag_insertion_en_parsed(
12955 void *parsed_result,
12956 __attribute__((unused)) struct cmdline *cl,
12957 __attribute__((unused)) void *data)
12959 struct cmd_config_e_tag_result *res =
12961 struct rte_eth_l2_tunnel_conf entry;
12963 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12966 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12967 entry.tunnel_id = res->port_tag_id_val;
12968 entry.vf_id = res->vf_id;
12969 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12971 ETH_L2_TUNNEL_INSERTION_MASK,
12976 cmd_config_e_tag_insertion_dis_parsed(
12977 void *parsed_result,
12978 __attribute__((unused)) struct cmdline *cl,
12979 __attribute__((unused)) void *data)
12981 struct cmd_config_e_tag_result *res =
12983 struct rte_eth_l2_tunnel_conf entry;
12985 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12988 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12989 entry.vf_id = res->vf_id;
12991 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12993 ETH_L2_TUNNEL_INSERTION_MASK,
12997 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12998 .f = cmd_config_e_tag_insertion_en_parsed,
13000 .help_str = "E-tag ... : E-tag insertion enable",
13002 (void *)&cmd_config_e_tag_e_tag,
13003 (void *)&cmd_config_e_tag_set,
13004 (void *)&cmd_config_e_tag_insertion,
13005 (void *)&cmd_config_e_tag_on,
13006 (void *)&cmd_config_e_tag_port_tag_id,
13007 (void *)&cmd_config_e_tag_port_tag_id_val,
13008 (void *)&cmd_config_e_tag_port,
13009 (void *)&cmd_config_e_tag_port_id,
13010 (void *)&cmd_config_e_tag_vf,
13011 (void *)&cmd_config_e_tag_vf_id,
13016 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13017 .f = cmd_config_e_tag_insertion_dis_parsed,
13019 .help_str = "E-tag ... : E-tag insertion disable",
13021 (void *)&cmd_config_e_tag_e_tag,
13022 (void *)&cmd_config_e_tag_set,
13023 (void *)&cmd_config_e_tag_insertion,
13024 (void *)&cmd_config_e_tag_off,
13025 (void *)&cmd_config_e_tag_port,
13026 (void *)&cmd_config_e_tag_port_id,
13027 (void *)&cmd_config_e_tag_vf,
13028 (void *)&cmd_config_e_tag_vf_id,
13033 /* E-tag stripping configuration */
13035 cmd_config_e_tag_stripping_parsed(
13036 void *parsed_result,
13037 __attribute__((unused)) struct cmdline *cl,
13038 __attribute__((unused)) void *data)
13040 struct cmd_config_e_tag_result *res =
13042 struct rte_eth_l2_tunnel_conf entry;
13044 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13047 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13049 if (!strcmp(res->on_off, "on"))
13050 rte_eth_dev_l2_tunnel_offload_set
13053 ETH_L2_TUNNEL_STRIPPING_MASK,
13056 rte_eth_dev_l2_tunnel_offload_set
13059 ETH_L2_TUNNEL_STRIPPING_MASK,
13063 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13064 .f = cmd_config_e_tag_stripping_parsed,
13066 .help_str = "E-tag ... : E-tag stripping enable/disable",
13068 (void *)&cmd_config_e_tag_e_tag,
13069 (void *)&cmd_config_e_tag_set,
13070 (void *)&cmd_config_e_tag_stripping,
13071 (void *)&cmd_config_e_tag_on_off,
13072 (void *)&cmd_config_e_tag_port,
13073 (void *)&cmd_config_e_tag_port_id,
13078 /* E-tag forwarding configuration */
13080 cmd_config_e_tag_forwarding_parsed(
13081 void *parsed_result,
13082 __attribute__((unused)) struct cmdline *cl,
13083 __attribute__((unused)) void *data)
13085 struct cmd_config_e_tag_result *res = parsed_result;
13086 struct rte_eth_l2_tunnel_conf entry;
13088 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13091 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13093 if (!strcmp(res->on_off, "on"))
13094 rte_eth_dev_l2_tunnel_offload_set
13097 ETH_L2_TUNNEL_FORWARDING_MASK,
13100 rte_eth_dev_l2_tunnel_offload_set
13103 ETH_L2_TUNNEL_FORWARDING_MASK,
13107 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13108 .f = cmd_config_e_tag_forwarding_parsed,
13110 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13112 (void *)&cmd_config_e_tag_e_tag,
13113 (void *)&cmd_config_e_tag_set,
13114 (void *)&cmd_config_e_tag_forwarding,
13115 (void *)&cmd_config_e_tag_on_off,
13116 (void *)&cmd_config_e_tag_port,
13117 (void *)&cmd_config_e_tag_port_id,
13122 /* E-tag filter configuration */
13124 cmd_config_e_tag_filter_add_parsed(
13125 void *parsed_result,
13126 __attribute__((unused)) struct cmdline *cl,
13127 __attribute__((unused)) void *data)
13129 struct cmd_config_e_tag_result *res = parsed_result;
13130 struct rte_eth_l2_tunnel_conf entry;
13133 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13136 if (res->e_tag_id_val > 0x3fff) {
13137 printf("e-tag-id must be equal or less than 0x3fff.\n");
13141 ret = rte_eth_dev_filter_supported(res->port_id,
13142 RTE_ETH_FILTER_L2_TUNNEL);
13144 printf("E-tag filter is not supported on port %u.\n",
13149 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13150 entry.tunnel_id = res->e_tag_id_val;
13151 entry.pool = res->dst_pool_val;
13153 ret = rte_eth_dev_filter_ctrl(res->port_id,
13154 RTE_ETH_FILTER_L2_TUNNEL,
13155 RTE_ETH_FILTER_ADD,
13158 printf("E-tag filter programming error: (%s)\n",
13162 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13163 .f = cmd_config_e_tag_filter_add_parsed,
13165 .help_str = "E-tag ... : E-tag filter add",
13167 (void *)&cmd_config_e_tag_e_tag,
13168 (void *)&cmd_config_e_tag_set,
13169 (void *)&cmd_config_e_tag_filter,
13170 (void *)&cmd_config_e_tag_add,
13171 (void *)&cmd_config_e_tag_e_tag_id,
13172 (void *)&cmd_config_e_tag_e_tag_id_val,
13173 (void *)&cmd_config_e_tag_dst_pool,
13174 (void *)&cmd_config_e_tag_dst_pool_val,
13175 (void *)&cmd_config_e_tag_port,
13176 (void *)&cmd_config_e_tag_port_id,
13182 cmd_config_e_tag_filter_del_parsed(
13183 void *parsed_result,
13184 __attribute__((unused)) struct cmdline *cl,
13185 __attribute__((unused)) void *data)
13187 struct cmd_config_e_tag_result *res = parsed_result;
13188 struct rte_eth_l2_tunnel_conf entry;
13191 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13194 if (res->e_tag_id_val > 0x3fff) {
13195 printf("e-tag-id must be less than 0x3fff.\n");
13199 ret = rte_eth_dev_filter_supported(res->port_id,
13200 RTE_ETH_FILTER_L2_TUNNEL);
13202 printf("E-tag filter is not supported on port %u.\n",
13207 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13208 entry.tunnel_id = res->e_tag_id_val;
13210 ret = rte_eth_dev_filter_ctrl(res->port_id,
13211 RTE_ETH_FILTER_L2_TUNNEL,
13212 RTE_ETH_FILTER_DELETE,
13215 printf("E-tag filter programming error: (%s)\n",
13219 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13220 .f = cmd_config_e_tag_filter_del_parsed,
13222 .help_str = "E-tag ... : E-tag filter delete",
13224 (void *)&cmd_config_e_tag_e_tag,
13225 (void *)&cmd_config_e_tag_set,
13226 (void *)&cmd_config_e_tag_filter,
13227 (void *)&cmd_config_e_tag_del,
13228 (void *)&cmd_config_e_tag_e_tag_id,
13229 (void *)&cmd_config_e_tag_e_tag_id_val,
13230 (void *)&cmd_config_e_tag_port,
13231 (void *)&cmd_config_e_tag_port_id,
13236 /* vf vlan anti spoof configuration */
13238 /* Common result structure for vf vlan anti spoof */
13239 struct cmd_vf_vlan_anti_spoof_result {
13240 cmdline_fixed_string_t set;
13241 cmdline_fixed_string_t vf;
13242 cmdline_fixed_string_t vlan;
13243 cmdline_fixed_string_t antispoof;
13246 cmdline_fixed_string_t on_off;
13249 /* Common CLI fields for vf vlan anti spoof enable disable */
13250 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13251 TOKEN_STRING_INITIALIZER
13252 (struct cmd_vf_vlan_anti_spoof_result,
13254 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13255 TOKEN_STRING_INITIALIZER
13256 (struct cmd_vf_vlan_anti_spoof_result,
13258 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13259 TOKEN_STRING_INITIALIZER
13260 (struct cmd_vf_vlan_anti_spoof_result,
13262 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13263 TOKEN_STRING_INITIALIZER
13264 (struct cmd_vf_vlan_anti_spoof_result,
13265 antispoof, "antispoof");
13266 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13267 TOKEN_NUM_INITIALIZER
13268 (struct cmd_vf_vlan_anti_spoof_result,
13270 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13271 TOKEN_NUM_INITIALIZER
13272 (struct cmd_vf_vlan_anti_spoof_result,
13274 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13275 TOKEN_STRING_INITIALIZER
13276 (struct cmd_vf_vlan_anti_spoof_result,
13280 cmd_set_vf_vlan_anti_spoof_parsed(
13281 void *parsed_result,
13282 __attribute__((unused)) struct cmdline *cl,
13283 __attribute__((unused)) void *data)
13285 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13286 int ret = -ENOTSUP;
13288 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13290 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13293 #ifdef RTE_LIBRTE_IXGBE_PMD
13294 if (ret == -ENOTSUP)
13295 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13296 res->vf_id, is_on);
13298 #ifdef RTE_LIBRTE_I40E_PMD
13299 if (ret == -ENOTSUP)
13300 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13301 res->vf_id, is_on);
13303 #ifdef RTE_LIBRTE_BNXT_PMD
13304 if (ret == -ENOTSUP)
13305 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13306 res->vf_id, is_on);
13313 printf("invalid vf_id %d\n", res->vf_id);
13316 printf("invalid port_id %d\n", res->port_id);
13319 printf("function not implemented\n");
13322 printf("programming error: (%s)\n", strerror(-ret));
13326 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13327 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13329 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13331 (void *)&cmd_vf_vlan_anti_spoof_set,
13332 (void *)&cmd_vf_vlan_anti_spoof_vf,
13333 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13334 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13335 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13336 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13337 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13342 /* vf mac anti spoof configuration */
13344 /* Common result structure for vf mac anti spoof */
13345 struct cmd_vf_mac_anti_spoof_result {
13346 cmdline_fixed_string_t set;
13347 cmdline_fixed_string_t vf;
13348 cmdline_fixed_string_t mac;
13349 cmdline_fixed_string_t antispoof;
13352 cmdline_fixed_string_t on_off;
13355 /* Common CLI fields for vf mac anti spoof enable disable */
13356 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13357 TOKEN_STRING_INITIALIZER
13358 (struct cmd_vf_mac_anti_spoof_result,
13360 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13361 TOKEN_STRING_INITIALIZER
13362 (struct cmd_vf_mac_anti_spoof_result,
13364 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13365 TOKEN_STRING_INITIALIZER
13366 (struct cmd_vf_mac_anti_spoof_result,
13368 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13369 TOKEN_STRING_INITIALIZER
13370 (struct cmd_vf_mac_anti_spoof_result,
13371 antispoof, "antispoof");
13372 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13373 TOKEN_NUM_INITIALIZER
13374 (struct cmd_vf_mac_anti_spoof_result,
13376 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13377 TOKEN_NUM_INITIALIZER
13378 (struct cmd_vf_mac_anti_spoof_result,
13380 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13381 TOKEN_STRING_INITIALIZER
13382 (struct cmd_vf_mac_anti_spoof_result,
13386 cmd_set_vf_mac_anti_spoof_parsed(
13387 void *parsed_result,
13388 __attribute__((unused)) struct cmdline *cl,
13389 __attribute__((unused)) void *data)
13391 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13392 int ret = -ENOTSUP;
13394 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13396 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13399 #ifdef RTE_LIBRTE_IXGBE_PMD
13400 if (ret == -ENOTSUP)
13401 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13402 res->vf_id, is_on);
13404 #ifdef RTE_LIBRTE_I40E_PMD
13405 if (ret == -ENOTSUP)
13406 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13407 res->vf_id, is_on);
13409 #ifdef RTE_LIBRTE_BNXT_PMD
13410 if (ret == -ENOTSUP)
13411 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13412 res->vf_id, is_on);
13419 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13422 printf("invalid port_id %d\n", res->port_id);
13425 printf("function not implemented\n");
13428 printf("programming error: (%s)\n", strerror(-ret));
13432 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13433 .f = cmd_set_vf_mac_anti_spoof_parsed,
13435 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13437 (void *)&cmd_vf_mac_anti_spoof_set,
13438 (void *)&cmd_vf_mac_anti_spoof_vf,
13439 (void *)&cmd_vf_mac_anti_spoof_mac,
13440 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13441 (void *)&cmd_vf_mac_anti_spoof_port_id,
13442 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13443 (void *)&cmd_vf_mac_anti_spoof_on_off,
13448 /* vf vlan strip queue configuration */
13450 /* Common result structure for vf mac anti spoof */
13451 struct cmd_vf_vlan_stripq_result {
13452 cmdline_fixed_string_t set;
13453 cmdline_fixed_string_t vf;
13454 cmdline_fixed_string_t vlan;
13455 cmdline_fixed_string_t stripq;
13458 cmdline_fixed_string_t on_off;
13461 /* Common CLI fields for vf vlan strip enable disable */
13462 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13463 TOKEN_STRING_INITIALIZER
13464 (struct cmd_vf_vlan_stripq_result,
13466 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13467 TOKEN_STRING_INITIALIZER
13468 (struct cmd_vf_vlan_stripq_result,
13470 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13471 TOKEN_STRING_INITIALIZER
13472 (struct cmd_vf_vlan_stripq_result,
13474 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13475 TOKEN_STRING_INITIALIZER
13476 (struct cmd_vf_vlan_stripq_result,
13478 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13479 TOKEN_NUM_INITIALIZER
13480 (struct cmd_vf_vlan_stripq_result,
13482 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13483 TOKEN_NUM_INITIALIZER
13484 (struct cmd_vf_vlan_stripq_result,
13486 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13487 TOKEN_STRING_INITIALIZER
13488 (struct cmd_vf_vlan_stripq_result,
13492 cmd_set_vf_vlan_stripq_parsed(
13493 void *parsed_result,
13494 __attribute__((unused)) struct cmdline *cl,
13495 __attribute__((unused)) void *data)
13497 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13498 int ret = -ENOTSUP;
13500 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13502 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13505 #ifdef RTE_LIBRTE_IXGBE_PMD
13506 if (ret == -ENOTSUP)
13507 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13508 res->vf_id, is_on);
13510 #ifdef RTE_LIBRTE_I40E_PMD
13511 if (ret == -ENOTSUP)
13512 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13513 res->vf_id, is_on);
13515 #ifdef RTE_LIBRTE_BNXT_PMD
13516 if (ret == -ENOTSUP)
13517 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13518 res->vf_id, is_on);
13525 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13528 printf("invalid port_id %d\n", res->port_id);
13531 printf("function not implemented\n");
13534 printf("programming error: (%s)\n", strerror(-ret));
13538 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13539 .f = cmd_set_vf_vlan_stripq_parsed,
13541 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13543 (void *)&cmd_vf_vlan_stripq_set,
13544 (void *)&cmd_vf_vlan_stripq_vf,
13545 (void *)&cmd_vf_vlan_stripq_vlan,
13546 (void *)&cmd_vf_vlan_stripq_stripq,
13547 (void *)&cmd_vf_vlan_stripq_port_id,
13548 (void *)&cmd_vf_vlan_stripq_vf_id,
13549 (void *)&cmd_vf_vlan_stripq_on_off,
13554 /* vf vlan insert configuration */
13556 /* Common result structure for vf vlan insert */
13557 struct cmd_vf_vlan_insert_result {
13558 cmdline_fixed_string_t set;
13559 cmdline_fixed_string_t vf;
13560 cmdline_fixed_string_t vlan;
13561 cmdline_fixed_string_t insert;
13567 /* Common CLI fields for vf vlan insert enable disable */
13568 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13569 TOKEN_STRING_INITIALIZER
13570 (struct cmd_vf_vlan_insert_result,
13572 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13573 TOKEN_STRING_INITIALIZER
13574 (struct cmd_vf_vlan_insert_result,
13576 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13577 TOKEN_STRING_INITIALIZER
13578 (struct cmd_vf_vlan_insert_result,
13580 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13581 TOKEN_STRING_INITIALIZER
13582 (struct cmd_vf_vlan_insert_result,
13584 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13585 TOKEN_NUM_INITIALIZER
13586 (struct cmd_vf_vlan_insert_result,
13588 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13589 TOKEN_NUM_INITIALIZER
13590 (struct cmd_vf_vlan_insert_result,
13592 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13593 TOKEN_NUM_INITIALIZER
13594 (struct cmd_vf_vlan_insert_result,
13598 cmd_set_vf_vlan_insert_parsed(
13599 void *parsed_result,
13600 __attribute__((unused)) struct cmdline *cl,
13601 __attribute__((unused)) void *data)
13603 struct cmd_vf_vlan_insert_result *res = parsed_result;
13604 int ret = -ENOTSUP;
13606 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13609 #ifdef RTE_LIBRTE_IXGBE_PMD
13610 if (ret == -ENOTSUP)
13611 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13614 #ifdef RTE_LIBRTE_I40E_PMD
13615 if (ret == -ENOTSUP)
13616 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13619 #ifdef RTE_LIBRTE_BNXT_PMD
13620 if (ret == -ENOTSUP)
13621 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13629 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13632 printf("invalid port_id %d\n", res->port_id);
13635 printf("function not implemented\n");
13638 printf("programming error: (%s)\n", strerror(-ret));
13642 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13643 .f = cmd_set_vf_vlan_insert_parsed,
13645 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13647 (void *)&cmd_vf_vlan_insert_set,
13648 (void *)&cmd_vf_vlan_insert_vf,
13649 (void *)&cmd_vf_vlan_insert_vlan,
13650 (void *)&cmd_vf_vlan_insert_insert,
13651 (void *)&cmd_vf_vlan_insert_port_id,
13652 (void *)&cmd_vf_vlan_insert_vf_id,
13653 (void *)&cmd_vf_vlan_insert_vlan_id,
13658 /* tx loopback configuration */
13660 /* Common result structure for tx loopback */
13661 struct cmd_tx_loopback_result {
13662 cmdline_fixed_string_t set;
13663 cmdline_fixed_string_t tx;
13664 cmdline_fixed_string_t loopback;
13666 cmdline_fixed_string_t on_off;
13669 /* Common CLI fields for tx loopback enable disable */
13670 cmdline_parse_token_string_t cmd_tx_loopback_set =
13671 TOKEN_STRING_INITIALIZER
13672 (struct cmd_tx_loopback_result,
13674 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13675 TOKEN_STRING_INITIALIZER
13676 (struct cmd_tx_loopback_result,
13678 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13679 TOKEN_STRING_INITIALIZER
13680 (struct cmd_tx_loopback_result,
13681 loopback, "loopback");
13682 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13683 TOKEN_NUM_INITIALIZER
13684 (struct cmd_tx_loopback_result,
13686 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13687 TOKEN_STRING_INITIALIZER
13688 (struct cmd_tx_loopback_result,
13692 cmd_set_tx_loopback_parsed(
13693 void *parsed_result,
13694 __attribute__((unused)) struct cmdline *cl,
13695 __attribute__((unused)) void *data)
13697 struct cmd_tx_loopback_result *res = parsed_result;
13698 int ret = -ENOTSUP;
13700 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13702 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13705 #ifdef RTE_LIBRTE_IXGBE_PMD
13706 if (ret == -ENOTSUP)
13707 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13709 #ifdef RTE_LIBRTE_I40E_PMD
13710 if (ret == -ENOTSUP)
13711 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13713 #ifdef RTE_LIBRTE_BNXT_PMD
13714 if (ret == -ENOTSUP)
13715 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13717 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13718 if (ret == -ENOTSUP)
13719 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13726 printf("invalid is_on %d\n", is_on);
13729 printf("invalid port_id %d\n", res->port_id);
13732 printf("function not implemented\n");
13735 printf("programming error: (%s)\n", strerror(-ret));
13739 cmdline_parse_inst_t cmd_set_tx_loopback = {
13740 .f = cmd_set_tx_loopback_parsed,
13742 .help_str = "set tx loopback <port_id> on|off",
13744 (void *)&cmd_tx_loopback_set,
13745 (void *)&cmd_tx_loopback_tx,
13746 (void *)&cmd_tx_loopback_loopback,
13747 (void *)&cmd_tx_loopback_port_id,
13748 (void *)&cmd_tx_loopback_on_off,
13753 /* all queues drop enable configuration */
13755 /* Common result structure for all queues drop enable */
13756 struct cmd_all_queues_drop_en_result {
13757 cmdline_fixed_string_t set;
13758 cmdline_fixed_string_t all;
13759 cmdline_fixed_string_t queues;
13760 cmdline_fixed_string_t drop;
13762 cmdline_fixed_string_t on_off;
13765 /* Common CLI fields for tx loopback enable disable */
13766 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13767 TOKEN_STRING_INITIALIZER
13768 (struct cmd_all_queues_drop_en_result,
13770 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13771 TOKEN_STRING_INITIALIZER
13772 (struct cmd_all_queues_drop_en_result,
13774 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13775 TOKEN_STRING_INITIALIZER
13776 (struct cmd_all_queues_drop_en_result,
13778 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13779 TOKEN_STRING_INITIALIZER
13780 (struct cmd_all_queues_drop_en_result,
13782 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13783 TOKEN_NUM_INITIALIZER
13784 (struct cmd_all_queues_drop_en_result,
13786 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13787 TOKEN_STRING_INITIALIZER
13788 (struct cmd_all_queues_drop_en_result,
13792 cmd_set_all_queues_drop_en_parsed(
13793 void *parsed_result,
13794 __attribute__((unused)) struct cmdline *cl,
13795 __attribute__((unused)) void *data)
13797 struct cmd_all_queues_drop_en_result *res = parsed_result;
13798 int ret = -ENOTSUP;
13799 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13801 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13804 #ifdef RTE_LIBRTE_IXGBE_PMD
13805 if (ret == -ENOTSUP)
13806 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13808 #ifdef RTE_LIBRTE_BNXT_PMD
13809 if (ret == -ENOTSUP)
13810 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13816 printf("invalid is_on %d\n", is_on);
13819 printf("invalid port_id %d\n", res->port_id);
13822 printf("function not implemented\n");
13825 printf("programming error: (%s)\n", strerror(-ret));
13829 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13830 .f = cmd_set_all_queues_drop_en_parsed,
13832 .help_str = "set all queues drop <port_id> on|off",
13834 (void *)&cmd_all_queues_drop_en_set,
13835 (void *)&cmd_all_queues_drop_en_all,
13836 (void *)&cmd_all_queues_drop_en_queues,
13837 (void *)&cmd_all_queues_drop_en_drop,
13838 (void *)&cmd_all_queues_drop_en_port_id,
13839 (void *)&cmd_all_queues_drop_en_on_off,
13844 /* vf split drop enable configuration */
13846 /* Common result structure for vf split drop enable */
13847 struct cmd_vf_split_drop_en_result {
13848 cmdline_fixed_string_t set;
13849 cmdline_fixed_string_t vf;
13850 cmdline_fixed_string_t split;
13851 cmdline_fixed_string_t drop;
13854 cmdline_fixed_string_t on_off;
13857 /* Common CLI fields for vf split drop enable disable */
13858 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13859 TOKEN_STRING_INITIALIZER
13860 (struct cmd_vf_split_drop_en_result,
13862 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13863 TOKEN_STRING_INITIALIZER
13864 (struct cmd_vf_split_drop_en_result,
13866 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13867 TOKEN_STRING_INITIALIZER
13868 (struct cmd_vf_split_drop_en_result,
13870 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13871 TOKEN_STRING_INITIALIZER
13872 (struct cmd_vf_split_drop_en_result,
13874 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13875 TOKEN_NUM_INITIALIZER
13876 (struct cmd_vf_split_drop_en_result,
13878 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13879 TOKEN_NUM_INITIALIZER
13880 (struct cmd_vf_split_drop_en_result,
13882 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13883 TOKEN_STRING_INITIALIZER
13884 (struct cmd_vf_split_drop_en_result,
13888 cmd_set_vf_split_drop_en_parsed(
13889 void *parsed_result,
13890 __attribute__((unused)) struct cmdline *cl,
13891 __attribute__((unused)) void *data)
13893 struct cmd_vf_split_drop_en_result *res = parsed_result;
13894 int ret = -ENOTSUP;
13895 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13897 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13900 #ifdef RTE_LIBRTE_IXGBE_PMD
13901 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13908 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13911 printf("invalid port_id %d\n", res->port_id);
13914 printf("not supported on port %d\n", res->port_id);
13917 printf("programming error: (%s)\n", strerror(-ret));
13921 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13922 .f = cmd_set_vf_split_drop_en_parsed,
13924 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13926 (void *)&cmd_vf_split_drop_en_set,
13927 (void *)&cmd_vf_split_drop_en_vf,
13928 (void *)&cmd_vf_split_drop_en_split,
13929 (void *)&cmd_vf_split_drop_en_drop,
13930 (void *)&cmd_vf_split_drop_en_port_id,
13931 (void *)&cmd_vf_split_drop_en_vf_id,
13932 (void *)&cmd_vf_split_drop_en_on_off,
13937 /* vf mac address configuration */
13939 /* Common result structure for vf mac address */
13940 struct cmd_set_vf_mac_addr_result {
13941 cmdline_fixed_string_t set;
13942 cmdline_fixed_string_t vf;
13943 cmdline_fixed_string_t mac;
13944 cmdline_fixed_string_t addr;
13947 struct rte_ether_addr mac_addr;
13951 /* Common CLI fields for vf split drop enable disable */
13952 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13953 TOKEN_STRING_INITIALIZER
13954 (struct cmd_set_vf_mac_addr_result,
13956 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13957 TOKEN_STRING_INITIALIZER
13958 (struct cmd_set_vf_mac_addr_result,
13960 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13961 TOKEN_STRING_INITIALIZER
13962 (struct cmd_set_vf_mac_addr_result,
13964 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13965 TOKEN_STRING_INITIALIZER
13966 (struct cmd_set_vf_mac_addr_result,
13968 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13969 TOKEN_NUM_INITIALIZER
13970 (struct cmd_set_vf_mac_addr_result,
13972 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13973 TOKEN_NUM_INITIALIZER
13974 (struct cmd_set_vf_mac_addr_result,
13976 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13977 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13981 cmd_set_vf_mac_addr_parsed(
13982 void *parsed_result,
13983 __attribute__((unused)) struct cmdline *cl,
13984 __attribute__((unused)) void *data)
13986 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13987 int ret = -ENOTSUP;
13989 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13992 #ifdef RTE_LIBRTE_IXGBE_PMD
13993 if (ret == -ENOTSUP)
13994 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13997 #ifdef RTE_LIBRTE_I40E_PMD
13998 if (ret == -ENOTSUP)
13999 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14002 #ifdef RTE_LIBRTE_BNXT_PMD
14003 if (ret == -ENOTSUP)
14004 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14012 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14015 printf("invalid port_id %d\n", res->port_id);
14018 printf("function not implemented\n");
14021 printf("programming error: (%s)\n", strerror(-ret));
14025 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14026 .f = cmd_set_vf_mac_addr_parsed,
14028 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14030 (void *)&cmd_set_vf_mac_addr_set,
14031 (void *)&cmd_set_vf_mac_addr_vf,
14032 (void *)&cmd_set_vf_mac_addr_mac,
14033 (void *)&cmd_set_vf_mac_addr_addr,
14034 (void *)&cmd_set_vf_mac_addr_port_id,
14035 (void *)&cmd_set_vf_mac_addr_vf_id,
14036 (void *)&cmd_set_vf_mac_addr_mac_addr,
14041 /* MACsec configuration */
14043 /* Common result structure for MACsec offload enable */
14044 struct cmd_macsec_offload_on_result {
14045 cmdline_fixed_string_t set;
14046 cmdline_fixed_string_t macsec;
14047 cmdline_fixed_string_t offload;
14049 cmdline_fixed_string_t on;
14050 cmdline_fixed_string_t encrypt;
14051 cmdline_fixed_string_t en_on_off;
14052 cmdline_fixed_string_t replay_protect;
14053 cmdline_fixed_string_t rp_on_off;
14056 /* Common CLI fields for MACsec offload disable */
14057 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14058 TOKEN_STRING_INITIALIZER
14059 (struct cmd_macsec_offload_on_result,
14061 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14062 TOKEN_STRING_INITIALIZER
14063 (struct cmd_macsec_offload_on_result,
14065 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14066 TOKEN_STRING_INITIALIZER
14067 (struct cmd_macsec_offload_on_result,
14068 offload, "offload");
14069 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14070 TOKEN_NUM_INITIALIZER
14071 (struct cmd_macsec_offload_on_result,
14073 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14074 TOKEN_STRING_INITIALIZER
14075 (struct cmd_macsec_offload_on_result,
14077 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14078 TOKEN_STRING_INITIALIZER
14079 (struct cmd_macsec_offload_on_result,
14080 encrypt, "encrypt");
14081 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14082 TOKEN_STRING_INITIALIZER
14083 (struct cmd_macsec_offload_on_result,
14084 en_on_off, "on#off");
14085 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14086 TOKEN_STRING_INITIALIZER
14087 (struct cmd_macsec_offload_on_result,
14088 replay_protect, "replay-protect");
14089 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14090 TOKEN_STRING_INITIALIZER
14091 (struct cmd_macsec_offload_on_result,
14092 rp_on_off, "on#off");
14095 cmd_set_macsec_offload_on_parsed(
14096 void *parsed_result,
14097 __attribute__((unused)) struct cmdline *cl,
14098 __attribute__((unused)) void *data)
14100 struct cmd_macsec_offload_on_result *res = parsed_result;
14101 int ret = -ENOTSUP;
14102 portid_t port_id = res->port_id;
14103 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14104 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14105 struct rte_eth_dev_info dev_info;
14107 if (port_id_is_invalid(port_id, ENABLED_WARN))
14109 if (!port_is_stopped(port_id)) {
14110 printf("Please stop port %d first\n", port_id);
14114 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14118 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14119 #ifdef RTE_LIBRTE_IXGBE_PMD
14120 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14128 ports[port_id].dev_conf.txmode.offloads |=
14129 DEV_TX_OFFLOAD_MACSEC_INSERT;
14130 cmd_reconfig_device_queue(port_id, 1, 1);
14133 printf("invalid port_id %d\n", port_id);
14136 printf("not supported on port %d\n", port_id);
14139 printf("programming error: (%s)\n", strerror(-ret));
14143 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14144 .f = cmd_set_macsec_offload_on_parsed,
14146 .help_str = "set macsec offload <port_id> on "
14147 "encrypt on|off replay-protect on|off",
14149 (void *)&cmd_macsec_offload_on_set,
14150 (void *)&cmd_macsec_offload_on_macsec,
14151 (void *)&cmd_macsec_offload_on_offload,
14152 (void *)&cmd_macsec_offload_on_port_id,
14153 (void *)&cmd_macsec_offload_on_on,
14154 (void *)&cmd_macsec_offload_on_encrypt,
14155 (void *)&cmd_macsec_offload_on_en_on_off,
14156 (void *)&cmd_macsec_offload_on_replay_protect,
14157 (void *)&cmd_macsec_offload_on_rp_on_off,
14162 /* Common result structure for MACsec offload disable */
14163 struct cmd_macsec_offload_off_result {
14164 cmdline_fixed_string_t set;
14165 cmdline_fixed_string_t macsec;
14166 cmdline_fixed_string_t offload;
14168 cmdline_fixed_string_t off;
14171 /* Common CLI fields for MACsec offload disable */
14172 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14173 TOKEN_STRING_INITIALIZER
14174 (struct cmd_macsec_offload_off_result,
14176 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14177 TOKEN_STRING_INITIALIZER
14178 (struct cmd_macsec_offload_off_result,
14180 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14181 TOKEN_STRING_INITIALIZER
14182 (struct cmd_macsec_offload_off_result,
14183 offload, "offload");
14184 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14185 TOKEN_NUM_INITIALIZER
14186 (struct cmd_macsec_offload_off_result,
14188 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14189 TOKEN_STRING_INITIALIZER
14190 (struct cmd_macsec_offload_off_result,
14194 cmd_set_macsec_offload_off_parsed(
14195 void *parsed_result,
14196 __attribute__((unused)) struct cmdline *cl,
14197 __attribute__((unused)) void *data)
14199 struct cmd_macsec_offload_off_result *res = parsed_result;
14200 int ret = -ENOTSUP;
14201 struct rte_eth_dev_info dev_info;
14202 portid_t port_id = res->port_id;
14204 if (port_id_is_invalid(port_id, ENABLED_WARN))
14206 if (!port_is_stopped(port_id)) {
14207 printf("Please stop port %d first\n", port_id);
14211 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14215 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14216 #ifdef RTE_LIBRTE_IXGBE_PMD
14217 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14222 ports[port_id].dev_conf.txmode.offloads &=
14223 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14224 cmd_reconfig_device_queue(port_id, 1, 1);
14227 printf("invalid port_id %d\n", port_id);
14230 printf("not supported on port %d\n", port_id);
14233 printf("programming error: (%s)\n", strerror(-ret));
14237 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14238 .f = cmd_set_macsec_offload_off_parsed,
14240 .help_str = "set macsec offload <port_id> off",
14242 (void *)&cmd_macsec_offload_off_set,
14243 (void *)&cmd_macsec_offload_off_macsec,
14244 (void *)&cmd_macsec_offload_off_offload,
14245 (void *)&cmd_macsec_offload_off_port_id,
14246 (void *)&cmd_macsec_offload_off_off,
14251 /* Common result structure for MACsec secure connection configure */
14252 struct cmd_macsec_sc_result {
14253 cmdline_fixed_string_t set;
14254 cmdline_fixed_string_t macsec;
14255 cmdline_fixed_string_t sc;
14256 cmdline_fixed_string_t tx_rx;
14258 struct rte_ether_addr mac;
14262 /* Common CLI fields for MACsec secure connection configure */
14263 cmdline_parse_token_string_t cmd_macsec_sc_set =
14264 TOKEN_STRING_INITIALIZER
14265 (struct cmd_macsec_sc_result,
14267 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14268 TOKEN_STRING_INITIALIZER
14269 (struct cmd_macsec_sc_result,
14271 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14272 TOKEN_STRING_INITIALIZER
14273 (struct cmd_macsec_sc_result,
14275 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14276 TOKEN_STRING_INITIALIZER
14277 (struct cmd_macsec_sc_result,
14279 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14280 TOKEN_NUM_INITIALIZER
14281 (struct cmd_macsec_sc_result,
14283 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14284 TOKEN_ETHERADDR_INITIALIZER
14285 (struct cmd_macsec_sc_result,
14287 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14288 TOKEN_NUM_INITIALIZER
14289 (struct cmd_macsec_sc_result,
14293 cmd_set_macsec_sc_parsed(
14294 void *parsed_result,
14295 __attribute__((unused)) struct cmdline *cl,
14296 __attribute__((unused)) void *data)
14298 struct cmd_macsec_sc_result *res = parsed_result;
14299 int ret = -ENOTSUP;
14300 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14302 #ifdef RTE_LIBRTE_IXGBE_PMD
14304 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14305 res->mac.addr_bytes) :
14306 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14307 res->mac.addr_bytes, res->pi);
14309 RTE_SET_USED(is_tx);
14315 printf("invalid port_id %d\n", res->port_id);
14318 printf("not supported on port %d\n", res->port_id);
14321 printf("programming error: (%s)\n", strerror(-ret));
14325 cmdline_parse_inst_t cmd_set_macsec_sc = {
14326 .f = cmd_set_macsec_sc_parsed,
14328 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14330 (void *)&cmd_macsec_sc_set,
14331 (void *)&cmd_macsec_sc_macsec,
14332 (void *)&cmd_macsec_sc_sc,
14333 (void *)&cmd_macsec_sc_tx_rx,
14334 (void *)&cmd_macsec_sc_port_id,
14335 (void *)&cmd_macsec_sc_mac,
14336 (void *)&cmd_macsec_sc_pi,
14341 /* Common result structure for MACsec secure connection configure */
14342 struct cmd_macsec_sa_result {
14343 cmdline_fixed_string_t set;
14344 cmdline_fixed_string_t macsec;
14345 cmdline_fixed_string_t sa;
14346 cmdline_fixed_string_t tx_rx;
14351 cmdline_fixed_string_t key;
14354 /* Common CLI fields for MACsec secure connection configure */
14355 cmdline_parse_token_string_t cmd_macsec_sa_set =
14356 TOKEN_STRING_INITIALIZER
14357 (struct cmd_macsec_sa_result,
14359 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14360 TOKEN_STRING_INITIALIZER
14361 (struct cmd_macsec_sa_result,
14363 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14364 TOKEN_STRING_INITIALIZER
14365 (struct cmd_macsec_sa_result,
14367 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14368 TOKEN_STRING_INITIALIZER
14369 (struct cmd_macsec_sa_result,
14371 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14372 TOKEN_NUM_INITIALIZER
14373 (struct cmd_macsec_sa_result,
14375 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14376 TOKEN_NUM_INITIALIZER
14377 (struct cmd_macsec_sa_result,
14379 cmdline_parse_token_num_t cmd_macsec_sa_an =
14380 TOKEN_NUM_INITIALIZER
14381 (struct cmd_macsec_sa_result,
14383 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14384 TOKEN_NUM_INITIALIZER
14385 (struct cmd_macsec_sa_result,
14387 cmdline_parse_token_string_t cmd_macsec_sa_key =
14388 TOKEN_STRING_INITIALIZER
14389 (struct cmd_macsec_sa_result,
14393 cmd_set_macsec_sa_parsed(
14394 void *parsed_result,
14395 __attribute__((unused)) struct cmdline *cl,
14396 __attribute__((unused)) void *data)
14398 struct cmd_macsec_sa_result *res = parsed_result;
14399 int ret = -ENOTSUP;
14400 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14401 uint8_t key[16] = { 0 };
14407 key_len = strlen(res->key) / 2;
14411 for (i = 0; i < key_len; i++) {
14412 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14415 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14418 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14421 #ifdef RTE_LIBRTE_IXGBE_PMD
14423 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14424 res->idx, res->an, res->pn, key) :
14425 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14426 res->idx, res->an, res->pn, key);
14428 RTE_SET_USED(is_tx);
14435 printf("invalid idx %d or an %d\n", res->idx, res->an);
14438 printf("invalid port_id %d\n", res->port_id);
14441 printf("not supported on port %d\n", res->port_id);
14444 printf("programming error: (%s)\n", strerror(-ret));
14448 cmdline_parse_inst_t cmd_set_macsec_sa = {
14449 .f = cmd_set_macsec_sa_parsed,
14451 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14453 (void *)&cmd_macsec_sa_set,
14454 (void *)&cmd_macsec_sa_macsec,
14455 (void *)&cmd_macsec_sa_sa,
14456 (void *)&cmd_macsec_sa_tx_rx,
14457 (void *)&cmd_macsec_sa_port_id,
14458 (void *)&cmd_macsec_sa_idx,
14459 (void *)&cmd_macsec_sa_an,
14460 (void *)&cmd_macsec_sa_pn,
14461 (void *)&cmd_macsec_sa_key,
14466 /* VF unicast promiscuous mode configuration */
14468 /* Common result structure for VF unicast promiscuous mode */
14469 struct cmd_vf_promisc_result {
14470 cmdline_fixed_string_t set;
14471 cmdline_fixed_string_t vf;
14472 cmdline_fixed_string_t promisc;
14475 cmdline_fixed_string_t on_off;
14478 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14479 cmdline_parse_token_string_t cmd_vf_promisc_set =
14480 TOKEN_STRING_INITIALIZER
14481 (struct cmd_vf_promisc_result,
14483 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14484 TOKEN_STRING_INITIALIZER
14485 (struct cmd_vf_promisc_result,
14487 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14488 TOKEN_STRING_INITIALIZER
14489 (struct cmd_vf_promisc_result,
14490 promisc, "promisc");
14491 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14492 TOKEN_NUM_INITIALIZER
14493 (struct cmd_vf_promisc_result,
14495 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14496 TOKEN_NUM_INITIALIZER
14497 (struct cmd_vf_promisc_result,
14499 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14500 TOKEN_STRING_INITIALIZER
14501 (struct cmd_vf_promisc_result,
14505 cmd_set_vf_promisc_parsed(
14506 void *parsed_result,
14507 __attribute__((unused)) struct cmdline *cl,
14508 __attribute__((unused)) void *data)
14510 struct cmd_vf_promisc_result *res = parsed_result;
14511 int ret = -ENOTSUP;
14513 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14515 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14518 #ifdef RTE_LIBRTE_I40E_PMD
14519 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14520 res->vf_id, is_on);
14527 printf("invalid vf_id %d\n", res->vf_id);
14530 printf("invalid port_id %d\n", res->port_id);
14533 printf("function not implemented\n");
14536 printf("programming error: (%s)\n", strerror(-ret));
14540 cmdline_parse_inst_t cmd_set_vf_promisc = {
14541 .f = cmd_set_vf_promisc_parsed,
14543 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14544 "Set unicast promiscuous mode for a VF from the PF",
14546 (void *)&cmd_vf_promisc_set,
14547 (void *)&cmd_vf_promisc_vf,
14548 (void *)&cmd_vf_promisc_promisc,
14549 (void *)&cmd_vf_promisc_port_id,
14550 (void *)&cmd_vf_promisc_vf_id,
14551 (void *)&cmd_vf_promisc_on_off,
14556 /* VF multicast promiscuous mode configuration */
14558 /* Common result structure for VF multicast promiscuous mode */
14559 struct cmd_vf_allmulti_result {
14560 cmdline_fixed_string_t set;
14561 cmdline_fixed_string_t vf;
14562 cmdline_fixed_string_t allmulti;
14565 cmdline_fixed_string_t on_off;
14568 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14569 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14570 TOKEN_STRING_INITIALIZER
14571 (struct cmd_vf_allmulti_result,
14573 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14574 TOKEN_STRING_INITIALIZER
14575 (struct cmd_vf_allmulti_result,
14577 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14578 TOKEN_STRING_INITIALIZER
14579 (struct cmd_vf_allmulti_result,
14580 allmulti, "allmulti");
14581 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14582 TOKEN_NUM_INITIALIZER
14583 (struct cmd_vf_allmulti_result,
14585 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14586 TOKEN_NUM_INITIALIZER
14587 (struct cmd_vf_allmulti_result,
14589 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14590 TOKEN_STRING_INITIALIZER
14591 (struct cmd_vf_allmulti_result,
14595 cmd_set_vf_allmulti_parsed(
14596 void *parsed_result,
14597 __attribute__((unused)) struct cmdline *cl,
14598 __attribute__((unused)) void *data)
14600 struct cmd_vf_allmulti_result *res = parsed_result;
14601 int ret = -ENOTSUP;
14603 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14605 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14608 #ifdef RTE_LIBRTE_I40E_PMD
14609 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14610 res->vf_id, is_on);
14617 printf("invalid vf_id %d\n", res->vf_id);
14620 printf("invalid port_id %d\n", res->port_id);
14623 printf("function not implemented\n");
14626 printf("programming error: (%s)\n", strerror(-ret));
14630 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14631 .f = cmd_set_vf_allmulti_parsed,
14633 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14634 "Set multicast promiscuous mode for a VF from the PF",
14636 (void *)&cmd_vf_allmulti_set,
14637 (void *)&cmd_vf_allmulti_vf,
14638 (void *)&cmd_vf_allmulti_allmulti,
14639 (void *)&cmd_vf_allmulti_port_id,
14640 (void *)&cmd_vf_allmulti_vf_id,
14641 (void *)&cmd_vf_allmulti_on_off,
14646 /* vf broadcast mode configuration */
14648 /* Common result structure for vf broadcast */
14649 struct cmd_set_vf_broadcast_result {
14650 cmdline_fixed_string_t set;
14651 cmdline_fixed_string_t vf;
14652 cmdline_fixed_string_t broadcast;
14655 cmdline_fixed_string_t on_off;
14658 /* Common CLI fields for vf broadcast enable disable */
14659 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14660 TOKEN_STRING_INITIALIZER
14661 (struct cmd_set_vf_broadcast_result,
14663 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14664 TOKEN_STRING_INITIALIZER
14665 (struct cmd_set_vf_broadcast_result,
14667 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14668 TOKEN_STRING_INITIALIZER
14669 (struct cmd_set_vf_broadcast_result,
14670 broadcast, "broadcast");
14671 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14672 TOKEN_NUM_INITIALIZER
14673 (struct cmd_set_vf_broadcast_result,
14675 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14676 TOKEN_NUM_INITIALIZER
14677 (struct cmd_set_vf_broadcast_result,
14679 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14680 TOKEN_STRING_INITIALIZER
14681 (struct cmd_set_vf_broadcast_result,
14685 cmd_set_vf_broadcast_parsed(
14686 void *parsed_result,
14687 __attribute__((unused)) struct cmdline *cl,
14688 __attribute__((unused)) void *data)
14690 struct cmd_set_vf_broadcast_result *res = parsed_result;
14691 int ret = -ENOTSUP;
14693 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14695 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14698 #ifdef RTE_LIBRTE_I40E_PMD
14699 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14700 res->vf_id, is_on);
14707 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14710 printf("invalid port_id %d\n", res->port_id);
14713 printf("function not implemented\n");
14716 printf("programming error: (%s)\n", strerror(-ret));
14720 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14721 .f = cmd_set_vf_broadcast_parsed,
14723 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14725 (void *)&cmd_set_vf_broadcast_set,
14726 (void *)&cmd_set_vf_broadcast_vf,
14727 (void *)&cmd_set_vf_broadcast_broadcast,
14728 (void *)&cmd_set_vf_broadcast_port_id,
14729 (void *)&cmd_set_vf_broadcast_vf_id,
14730 (void *)&cmd_set_vf_broadcast_on_off,
14735 /* vf vlan tag configuration */
14737 /* Common result structure for vf vlan tag */
14738 struct cmd_set_vf_vlan_tag_result {
14739 cmdline_fixed_string_t set;
14740 cmdline_fixed_string_t vf;
14741 cmdline_fixed_string_t vlan;
14742 cmdline_fixed_string_t tag;
14745 cmdline_fixed_string_t on_off;
14748 /* Common CLI fields for vf vlan tag enable disable */
14749 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14750 TOKEN_STRING_INITIALIZER
14751 (struct cmd_set_vf_vlan_tag_result,
14753 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14754 TOKEN_STRING_INITIALIZER
14755 (struct cmd_set_vf_vlan_tag_result,
14757 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14758 TOKEN_STRING_INITIALIZER
14759 (struct cmd_set_vf_vlan_tag_result,
14761 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14762 TOKEN_STRING_INITIALIZER
14763 (struct cmd_set_vf_vlan_tag_result,
14765 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14766 TOKEN_NUM_INITIALIZER
14767 (struct cmd_set_vf_vlan_tag_result,
14769 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14770 TOKEN_NUM_INITIALIZER
14771 (struct cmd_set_vf_vlan_tag_result,
14773 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14774 TOKEN_STRING_INITIALIZER
14775 (struct cmd_set_vf_vlan_tag_result,
14779 cmd_set_vf_vlan_tag_parsed(
14780 void *parsed_result,
14781 __attribute__((unused)) struct cmdline *cl,
14782 __attribute__((unused)) void *data)
14784 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14785 int ret = -ENOTSUP;
14787 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14789 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14792 #ifdef RTE_LIBRTE_I40E_PMD
14793 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14794 res->vf_id, is_on);
14801 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14804 printf("invalid port_id %d\n", res->port_id);
14807 printf("function not implemented\n");
14810 printf("programming error: (%s)\n", strerror(-ret));
14814 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14815 .f = cmd_set_vf_vlan_tag_parsed,
14817 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14819 (void *)&cmd_set_vf_vlan_tag_set,
14820 (void *)&cmd_set_vf_vlan_tag_vf,
14821 (void *)&cmd_set_vf_vlan_tag_vlan,
14822 (void *)&cmd_set_vf_vlan_tag_tag,
14823 (void *)&cmd_set_vf_vlan_tag_port_id,
14824 (void *)&cmd_set_vf_vlan_tag_vf_id,
14825 (void *)&cmd_set_vf_vlan_tag_on_off,
14830 /* Common definition of VF and TC TX bandwidth configuration */
14831 struct cmd_vf_tc_bw_result {
14832 cmdline_fixed_string_t set;
14833 cmdline_fixed_string_t vf;
14834 cmdline_fixed_string_t tc;
14835 cmdline_fixed_string_t tx;
14836 cmdline_fixed_string_t min_bw;
14837 cmdline_fixed_string_t max_bw;
14838 cmdline_fixed_string_t strict_link_prio;
14843 cmdline_fixed_string_t bw_list;
14847 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14848 TOKEN_STRING_INITIALIZER
14849 (struct cmd_vf_tc_bw_result,
14851 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14852 TOKEN_STRING_INITIALIZER
14853 (struct cmd_vf_tc_bw_result,
14855 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14856 TOKEN_STRING_INITIALIZER
14857 (struct cmd_vf_tc_bw_result,
14859 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14860 TOKEN_STRING_INITIALIZER
14861 (struct cmd_vf_tc_bw_result,
14863 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14864 TOKEN_STRING_INITIALIZER
14865 (struct cmd_vf_tc_bw_result,
14866 strict_link_prio, "strict-link-priority");
14867 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14868 TOKEN_STRING_INITIALIZER
14869 (struct cmd_vf_tc_bw_result,
14870 min_bw, "min-bandwidth");
14871 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14872 TOKEN_STRING_INITIALIZER
14873 (struct cmd_vf_tc_bw_result,
14874 max_bw, "max-bandwidth");
14875 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14876 TOKEN_NUM_INITIALIZER
14877 (struct cmd_vf_tc_bw_result,
14879 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14880 TOKEN_NUM_INITIALIZER
14881 (struct cmd_vf_tc_bw_result,
14883 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14884 TOKEN_NUM_INITIALIZER
14885 (struct cmd_vf_tc_bw_result,
14887 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14888 TOKEN_NUM_INITIALIZER
14889 (struct cmd_vf_tc_bw_result,
14891 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14892 TOKEN_STRING_INITIALIZER
14893 (struct cmd_vf_tc_bw_result,
14895 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14896 TOKEN_NUM_INITIALIZER
14897 (struct cmd_vf_tc_bw_result,
14900 /* VF max bandwidth setting */
14902 cmd_vf_max_bw_parsed(
14903 void *parsed_result,
14904 __attribute__((unused)) struct cmdline *cl,
14905 __attribute__((unused)) void *data)
14907 struct cmd_vf_tc_bw_result *res = parsed_result;
14908 int ret = -ENOTSUP;
14910 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14913 #ifdef RTE_LIBRTE_I40E_PMD
14914 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14915 res->vf_id, res->bw);
14922 printf("invalid vf_id %d or bandwidth %d\n",
14923 res->vf_id, res->bw);
14926 printf("invalid port_id %d\n", res->port_id);
14929 printf("function not implemented\n");
14932 printf("programming error: (%s)\n", strerror(-ret));
14936 cmdline_parse_inst_t cmd_vf_max_bw = {
14937 .f = cmd_vf_max_bw_parsed,
14939 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14941 (void *)&cmd_vf_tc_bw_set,
14942 (void *)&cmd_vf_tc_bw_vf,
14943 (void *)&cmd_vf_tc_bw_tx,
14944 (void *)&cmd_vf_tc_bw_max_bw,
14945 (void *)&cmd_vf_tc_bw_port_id,
14946 (void *)&cmd_vf_tc_bw_vf_id,
14947 (void *)&cmd_vf_tc_bw_bw,
14953 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14958 const char *p, *p0 = str;
14965 p = strchr(p0, '(');
14967 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14971 p0 = strchr(p, ')');
14973 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14977 if (size >= sizeof(s)) {
14978 printf("The string size exceeds the internal buffer size\n");
14981 snprintf(s, sizeof(s), "%.*s", size, p);
14982 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14984 printf("Failed to get the bandwidth list. ");
14988 for (i = 0; i < ret; i++)
14989 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14994 /* TC min bandwidth setting */
14996 cmd_vf_tc_min_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;
15004 int ret = -ENOTSUP;
15006 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15009 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15013 #ifdef RTE_LIBRTE_I40E_PMD
15014 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15022 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15025 printf("invalid port_id %d\n", res->port_id);
15028 printf("function not implemented\n");
15031 printf("programming error: (%s)\n", strerror(-ret));
15035 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15036 .f = cmd_vf_tc_min_bw_parsed,
15038 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15039 " <bw1, bw2, ...>",
15041 (void *)&cmd_vf_tc_bw_set,
15042 (void *)&cmd_vf_tc_bw_vf,
15043 (void *)&cmd_vf_tc_bw_tc,
15044 (void *)&cmd_vf_tc_bw_tx,
15045 (void *)&cmd_vf_tc_bw_min_bw,
15046 (void *)&cmd_vf_tc_bw_port_id,
15047 (void *)&cmd_vf_tc_bw_vf_id,
15048 (void *)&cmd_vf_tc_bw_bw_list,
15054 cmd_tc_min_bw_parsed(
15055 void *parsed_result,
15056 __attribute__((unused)) struct cmdline *cl,
15057 __attribute__((unused)) void *data)
15059 struct cmd_vf_tc_bw_result *res = parsed_result;
15060 struct rte_port *port;
15063 int ret = -ENOTSUP;
15065 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15068 port = &ports[res->port_id];
15069 /** Check if the port is not started **/
15070 if (port->port_status != RTE_PORT_STOPPED) {
15071 printf("Please stop port %d first\n", res->port_id);
15075 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15079 #ifdef RTE_LIBRTE_IXGBE_PMD
15080 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15087 printf("invalid bandwidth\n");
15090 printf("invalid port_id %d\n", res->port_id);
15093 printf("function not implemented\n");
15096 printf("programming error: (%s)\n", strerror(-ret));
15100 cmdline_parse_inst_t cmd_tc_min_bw = {
15101 .f = cmd_tc_min_bw_parsed,
15103 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15105 (void *)&cmd_vf_tc_bw_set,
15106 (void *)&cmd_vf_tc_bw_tc,
15107 (void *)&cmd_vf_tc_bw_tx,
15108 (void *)&cmd_vf_tc_bw_min_bw,
15109 (void *)&cmd_vf_tc_bw_port_id,
15110 (void *)&cmd_vf_tc_bw_bw_list,
15115 /* TC max bandwidth setting */
15117 cmd_vf_tc_max_bw_parsed(
15118 void *parsed_result,
15119 __attribute__((unused)) struct cmdline *cl,
15120 __attribute__((unused)) void *data)
15122 struct cmd_vf_tc_bw_result *res = parsed_result;
15123 int ret = -ENOTSUP;
15125 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15128 #ifdef RTE_LIBRTE_I40E_PMD
15129 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15130 res->tc_no, res->bw);
15137 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15138 res->vf_id, res->tc_no, res->bw);
15141 printf("invalid port_id %d\n", res->port_id);
15144 printf("function not implemented\n");
15147 printf("programming error: (%s)\n", strerror(-ret));
15151 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15152 .f = cmd_vf_tc_max_bw_parsed,
15154 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15157 (void *)&cmd_vf_tc_bw_set,
15158 (void *)&cmd_vf_tc_bw_vf,
15159 (void *)&cmd_vf_tc_bw_tc,
15160 (void *)&cmd_vf_tc_bw_tx,
15161 (void *)&cmd_vf_tc_bw_max_bw,
15162 (void *)&cmd_vf_tc_bw_port_id,
15163 (void *)&cmd_vf_tc_bw_vf_id,
15164 (void *)&cmd_vf_tc_bw_tc_no,
15165 (void *)&cmd_vf_tc_bw_bw,
15171 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15173 /* *** Set Port default Traffic Management Hierarchy *** */
15174 struct cmd_set_port_tm_hierarchy_default_result {
15175 cmdline_fixed_string_t set;
15176 cmdline_fixed_string_t port;
15177 cmdline_fixed_string_t tm;
15178 cmdline_fixed_string_t hierarchy;
15179 cmdline_fixed_string_t def;
15183 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15184 TOKEN_STRING_INITIALIZER(
15185 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15186 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15187 TOKEN_STRING_INITIALIZER(
15188 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15189 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15190 TOKEN_STRING_INITIALIZER(
15191 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15192 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15193 TOKEN_STRING_INITIALIZER(
15194 struct cmd_set_port_tm_hierarchy_default_result,
15195 hierarchy, "hierarchy");
15196 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15197 TOKEN_STRING_INITIALIZER(
15198 struct cmd_set_port_tm_hierarchy_default_result,
15200 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15201 TOKEN_NUM_INITIALIZER(
15202 struct cmd_set_port_tm_hierarchy_default_result,
15205 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15206 __attribute__((unused)) struct cmdline *cl,
15207 __attribute__((unused)) void *data)
15209 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15210 struct rte_port *p;
15211 portid_t port_id = res->port_id;
15213 if (port_id_is_invalid(port_id, ENABLED_WARN))
15216 p = &ports[port_id];
15218 /* Forward mode: tm */
15219 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15220 printf(" softnicfwd mode not enabled(error)\n");
15224 /* Set the default tm hierarchy */
15225 p->softport.default_tm_hierarchy_enable = 1;
15228 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15229 .f = cmd_set_port_tm_hierarchy_default_parsed,
15231 .help_str = "set port tm hierarchy default <port_id>",
15233 (void *)&cmd_set_port_tm_hierarchy_default_set,
15234 (void *)&cmd_set_port_tm_hierarchy_default_port,
15235 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15236 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15237 (void *)&cmd_set_port_tm_hierarchy_default_default,
15238 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15244 /** Set VXLAN encapsulation details */
15245 struct cmd_set_vxlan_result {
15246 cmdline_fixed_string_t set;
15247 cmdline_fixed_string_t vxlan;
15248 cmdline_fixed_string_t pos_token;
15249 cmdline_fixed_string_t ip_version;
15250 uint32_t vlan_present:1;
15254 cmdline_ipaddr_t ip_src;
15255 cmdline_ipaddr_t ip_dst;
15259 struct rte_ether_addr eth_src;
15260 struct rte_ether_addr eth_dst;
15263 cmdline_parse_token_string_t cmd_set_vxlan_set =
15264 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15265 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15266 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15267 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15268 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15270 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15271 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15272 "vxlan-with-vlan");
15273 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15274 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15276 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15277 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15279 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15280 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15282 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15283 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15284 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15285 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15287 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15288 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15289 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15290 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15292 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15293 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15294 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15295 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15297 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15298 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15299 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15300 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15302 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15303 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15304 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15305 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15307 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15308 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15309 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15310 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15312 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15313 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15314 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15315 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15317 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15318 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15319 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15320 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15322 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15323 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15324 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15325 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15327 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15328 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15330 static void cmd_set_vxlan_parsed(void *parsed_result,
15331 __attribute__((unused)) struct cmdline *cl,
15332 __attribute__((unused)) void *data)
15334 struct cmd_set_vxlan_result *res = parsed_result;
15339 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15342 vxlan_encap_conf.select_tos_ttl = 0;
15343 if (strcmp(res->vxlan, "vxlan") == 0)
15344 vxlan_encap_conf.select_vlan = 0;
15345 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15346 vxlan_encap_conf.select_vlan = 1;
15347 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15348 vxlan_encap_conf.select_vlan = 0;
15349 vxlan_encap_conf.select_tos_ttl = 1;
15351 if (strcmp(res->ip_version, "ipv4") == 0)
15352 vxlan_encap_conf.select_ipv4 = 1;
15353 else if (strcmp(res->ip_version, "ipv6") == 0)
15354 vxlan_encap_conf.select_ipv4 = 0;
15357 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15358 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15359 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15360 vxlan_encap_conf.ip_tos = res->tos;
15361 vxlan_encap_conf.ip_ttl = res->ttl;
15362 if (vxlan_encap_conf.select_ipv4) {
15363 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15364 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15366 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15367 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15369 if (vxlan_encap_conf.select_vlan)
15370 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15371 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15372 RTE_ETHER_ADDR_LEN);
15373 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15374 RTE_ETHER_ADDR_LEN);
15377 cmdline_parse_inst_t cmd_set_vxlan = {
15378 .f = cmd_set_vxlan_parsed,
15380 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15381 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15382 " eth-src <eth-src> eth-dst <eth-dst>",
15384 (void *)&cmd_set_vxlan_set,
15385 (void *)&cmd_set_vxlan_vxlan,
15386 (void *)&cmd_set_vxlan_ip_version,
15387 (void *)&cmd_set_vxlan_ip_version_value,
15388 (void *)&cmd_set_vxlan_vni,
15389 (void *)&cmd_set_vxlan_vni_value,
15390 (void *)&cmd_set_vxlan_udp_src,
15391 (void *)&cmd_set_vxlan_udp_src_value,
15392 (void *)&cmd_set_vxlan_udp_dst,
15393 (void *)&cmd_set_vxlan_udp_dst_value,
15394 (void *)&cmd_set_vxlan_ip_src,
15395 (void *)&cmd_set_vxlan_ip_src_value,
15396 (void *)&cmd_set_vxlan_ip_dst,
15397 (void *)&cmd_set_vxlan_ip_dst_value,
15398 (void *)&cmd_set_vxlan_eth_src,
15399 (void *)&cmd_set_vxlan_eth_src_value,
15400 (void *)&cmd_set_vxlan_eth_dst,
15401 (void *)&cmd_set_vxlan_eth_dst_value,
15406 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15407 .f = cmd_set_vxlan_parsed,
15409 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15410 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15411 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15412 " eth-dst <eth-dst>",
15414 (void *)&cmd_set_vxlan_set,
15415 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15416 (void *)&cmd_set_vxlan_ip_version,
15417 (void *)&cmd_set_vxlan_ip_version_value,
15418 (void *)&cmd_set_vxlan_vni,
15419 (void *)&cmd_set_vxlan_vni_value,
15420 (void *)&cmd_set_vxlan_udp_src,
15421 (void *)&cmd_set_vxlan_udp_src_value,
15422 (void *)&cmd_set_vxlan_udp_dst,
15423 (void *)&cmd_set_vxlan_udp_dst_value,
15424 (void *)&cmd_set_vxlan_ip_tos,
15425 (void *)&cmd_set_vxlan_ip_tos_value,
15426 (void *)&cmd_set_vxlan_ip_ttl,
15427 (void *)&cmd_set_vxlan_ip_ttl_value,
15428 (void *)&cmd_set_vxlan_ip_src,
15429 (void *)&cmd_set_vxlan_ip_src_value,
15430 (void *)&cmd_set_vxlan_ip_dst,
15431 (void *)&cmd_set_vxlan_ip_dst_value,
15432 (void *)&cmd_set_vxlan_eth_src,
15433 (void *)&cmd_set_vxlan_eth_src_value,
15434 (void *)&cmd_set_vxlan_eth_dst,
15435 (void *)&cmd_set_vxlan_eth_dst_value,
15440 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15441 .f = cmd_set_vxlan_parsed,
15443 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15444 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15445 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15448 (void *)&cmd_set_vxlan_set,
15449 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15450 (void *)&cmd_set_vxlan_ip_version,
15451 (void *)&cmd_set_vxlan_ip_version_value,
15452 (void *)&cmd_set_vxlan_vni,
15453 (void *)&cmd_set_vxlan_vni_value,
15454 (void *)&cmd_set_vxlan_udp_src,
15455 (void *)&cmd_set_vxlan_udp_src_value,
15456 (void *)&cmd_set_vxlan_udp_dst,
15457 (void *)&cmd_set_vxlan_udp_dst_value,
15458 (void *)&cmd_set_vxlan_ip_src,
15459 (void *)&cmd_set_vxlan_ip_src_value,
15460 (void *)&cmd_set_vxlan_ip_dst,
15461 (void *)&cmd_set_vxlan_ip_dst_value,
15462 (void *)&cmd_set_vxlan_vlan,
15463 (void *)&cmd_set_vxlan_vlan_value,
15464 (void *)&cmd_set_vxlan_eth_src,
15465 (void *)&cmd_set_vxlan_eth_src_value,
15466 (void *)&cmd_set_vxlan_eth_dst,
15467 (void *)&cmd_set_vxlan_eth_dst_value,
15472 /** Set NVGRE encapsulation details */
15473 struct cmd_set_nvgre_result {
15474 cmdline_fixed_string_t set;
15475 cmdline_fixed_string_t nvgre;
15476 cmdline_fixed_string_t pos_token;
15477 cmdline_fixed_string_t ip_version;
15479 cmdline_ipaddr_t ip_src;
15480 cmdline_ipaddr_t ip_dst;
15482 struct rte_ether_addr eth_src;
15483 struct rte_ether_addr eth_dst;
15486 cmdline_parse_token_string_t cmd_set_nvgre_set =
15487 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15488 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15489 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15490 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15491 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15492 "nvgre-with-vlan");
15493 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15494 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15496 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15497 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15499 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15500 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15502 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15503 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15504 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15505 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15507 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15508 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15509 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15510 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15512 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15513 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15514 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15515 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15517 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15518 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15519 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15520 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15522 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15523 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15524 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15525 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15527 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15528 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15530 static void cmd_set_nvgre_parsed(void *parsed_result,
15531 __attribute__((unused)) struct cmdline *cl,
15532 __attribute__((unused)) void *data)
15534 struct cmd_set_nvgre_result *res = parsed_result;
15536 uint32_t nvgre_tni;
15539 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15542 if (strcmp(res->nvgre, "nvgre") == 0)
15543 nvgre_encap_conf.select_vlan = 0;
15544 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15545 nvgre_encap_conf.select_vlan = 1;
15546 if (strcmp(res->ip_version, "ipv4") == 0)
15547 nvgre_encap_conf.select_ipv4 = 1;
15548 else if (strcmp(res->ip_version, "ipv6") == 0)
15549 nvgre_encap_conf.select_ipv4 = 0;
15552 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15553 if (nvgre_encap_conf.select_ipv4) {
15554 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15555 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15557 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15558 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15560 if (nvgre_encap_conf.select_vlan)
15561 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15562 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15563 RTE_ETHER_ADDR_LEN);
15564 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15565 RTE_ETHER_ADDR_LEN);
15568 cmdline_parse_inst_t cmd_set_nvgre = {
15569 .f = cmd_set_nvgre_parsed,
15571 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15572 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15573 " eth-dst <eth-dst>",
15575 (void *)&cmd_set_nvgre_set,
15576 (void *)&cmd_set_nvgre_nvgre,
15577 (void *)&cmd_set_nvgre_ip_version,
15578 (void *)&cmd_set_nvgre_ip_version_value,
15579 (void *)&cmd_set_nvgre_tni,
15580 (void *)&cmd_set_nvgre_tni_value,
15581 (void *)&cmd_set_nvgre_ip_src,
15582 (void *)&cmd_set_nvgre_ip_src_value,
15583 (void *)&cmd_set_nvgre_ip_dst,
15584 (void *)&cmd_set_nvgre_ip_dst_value,
15585 (void *)&cmd_set_nvgre_eth_src,
15586 (void *)&cmd_set_nvgre_eth_src_value,
15587 (void *)&cmd_set_nvgre_eth_dst,
15588 (void *)&cmd_set_nvgre_eth_dst_value,
15593 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15594 .f = cmd_set_nvgre_parsed,
15596 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15597 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15598 " eth-src <eth-src> eth-dst <eth-dst>",
15600 (void *)&cmd_set_nvgre_set,
15601 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15602 (void *)&cmd_set_nvgre_ip_version,
15603 (void *)&cmd_set_nvgre_ip_version_value,
15604 (void *)&cmd_set_nvgre_tni,
15605 (void *)&cmd_set_nvgre_tni_value,
15606 (void *)&cmd_set_nvgre_ip_src,
15607 (void *)&cmd_set_nvgre_ip_src_value,
15608 (void *)&cmd_set_nvgre_ip_dst,
15609 (void *)&cmd_set_nvgre_ip_dst_value,
15610 (void *)&cmd_set_nvgre_vlan,
15611 (void *)&cmd_set_nvgre_vlan_value,
15612 (void *)&cmd_set_nvgre_eth_src,
15613 (void *)&cmd_set_nvgre_eth_src_value,
15614 (void *)&cmd_set_nvgre_eth_dst,
15615 (void *)&cmd_set_nvgre_eth_dst_value,
15620 /** Set L2 encapsulation details */
15621 struct cmd_set_l2_encap_result {
15622 cmdline_fixed_string_t set;
15623 cmdline_fixed_string_t l2_encap;
15624 cmdline_fixed_string_t pos_token;
15625 cmdline_fixed_string_t ip_version;
15626 uint32_t vlan_present:1;
15628 struct rte_ether_addr eth_src;
15629 struct rte_ether_addr eth_dst;
15632 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15633 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15634 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15635 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15636 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15637 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15638 "l2_encap-with-vlan");
15639 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15640 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15642 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15643 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15645 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15646 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15648 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15649 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15650 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15651 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15653 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15654 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15655 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15656 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15658 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15659 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15661 static void cmd_set_l2_encap_parsed(void *parsed_result,
15662 __attribute__((unused)) struct cmdline *cl,
15663 __attribute__((unused)) void *data)
15665 struct cmd_set_l2_encap_result *res = parsed_result;
15667 if (strcmp(res->l2_encap, "l2_encap") == 0)
15668 l2_encap_conf.select_vlan = 0;
15669 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15670 l2_encap_conf.select_vlan = 1;
15671 if (strcmp(res->ip_version, "ipv4") == 0)
15672 l2_encap_conf.select_ipv4 = 1;
15673 else if (strcmp(res->ip_version, "ipv6") == 0)
15674 l2_encap_conf.select_ipv4 = 0;
15677 if (l2_encap_conf.select_vlan)
15678 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15679 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15680 RTE_ETHER_ADDR_LEN);
15681 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15682 RTE_ETHER_ADDR_LEN);
15685 cmdline_parse_inst_t cmd_set_l2_encap = {
15686 .f = cmd_set_l2_encap_parsed,
15688 .help_str = "set l2_encap ip-version ipv4|ipv6"
15689 " eth-src <eth-src> eth-dst <eth-dst>",
15691 (void *)&cmd_set_l2_encap_set,
15692 (void *)&cmd_set_l2_encap_l2_encap,
15693 (void *)&cmd_set_l2_encap_ip_version,
15694 (void *)&cmd_set_l2_encap_ip_version_value,
15695 (void *)&cmd_set_l2_encap_eth_src,
15696 (void *)&cmd_set_l2_encap_eth_src_value,
15697 (void *)&cmd_set_l2_encap_eth_dst,
15698 (void *)&cmd_set_l2_encap_eth_dst_value,
15703 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15704 .f = cmd_set_l2_encap_parsed,
15706 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15707 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15709 (void *)&cmd_set_l2_encap_set,
15710 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15711 (void *)&cmd_set_l2_encap_ip_version,
15712 (void *)&cmd_set_l2_encap_ip_version_value,
15713 (void *)&cmd_set_l2_encap_vlan,
15714 (void *)&cmd_set_l2_encap_vlan_value,
15715 (void *)&cmd_set_l2_encap_eth_src,
15716 (void *)&cmd_set_l2_encap_eth_src_value,
15717 (void *)&cmd_set_l2_encap_eth_dst,
15718 (void *)&cmd_set_l2_encap_eth_dst_value,
15723 /** Set L2 decapsulation details */
15724 struct cmd_set_l2_decap_result {
15725 cmdline_fixed_string_t set;
15726 cmdline_fixed_string_t l2_decap;
15727 cmdline_fixed_string_t pos_token;
15728 uint32_t vlan_present:1;
15731 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15732 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15733 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15734 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15736 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15737 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15738 "l2_decap-with-vlan");
15740 static void cmd_set_l2_decap_parsed(void *parsed_result,
15741 __attribute__((unused)) struct cmdline *cl,
15742 __attribute__((unused)) void *data)
15744 struct cmd_set_l2_decap_result *res = parsed_result;
15746 if (strcmp(res->l2_decap, "l2_decap") == 0)
15747 l2_decap_conf.select_vlan = 0;
15748 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15749 l2_decap_conf.select_vlan = 1;
15752 cmdline_parse_inst_t cmd_set_l2_decap = {
15753 .f = cmd_set_l2_decap_parsed,
15755 .help_str = "set l2_decap",
15757 (void *)&cmd_set_l2_decap_set,
15758 (void *)&cmd_set_l2_decap_l2_decap,
15763 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15764 .f = cmd_set_l2_decap_parsed,
15766 .help_str = "set l2_decap-with-vlan",
15768 (void *)&cmd_set_l2_decap_set,
15769 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15774 /** Set MPLSoGRE encapsulation details */
15775 struct cmd_set_mplsogre_encap_result {
15776 cmdline_fixed_string_t set;
15777 cmdline_fixed_string_t mplsogre;
15778 cmdline_fixed_string_t pos_token;
15779 cmdline_fixed_string_t ip_version;
15780 uint32_t vlan_present:1;
15782 cmdline_ipaddr_t ip_src;
15783 cmdline_ipaddr_t ip_dst;
15785 struct rte_ether_addr eth_src;
15786 struct rte_ether_addr eth_dst;
15789 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15790 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15792 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15793 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15795 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15796 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15797 mplsogre, "mplsogre_encap-with-vlan");
15798 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15799 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15800 pos_token, "ip-version");
15801 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15802 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15803 ip_version, "ipv4#ipv6");
15804 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15805 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15806 pos_token, "label");
15807 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15808 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15810 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15811 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15812 pos_token, "ip-src");
15813 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15814 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15815 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15816 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15817 pos_token, "ip-dst");
15818 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15819 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15820 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15821 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15822 pos_token, "vlan-tci");
15823 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15824 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15826 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15827 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15828 pos_token, "eth-src");
15829 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15830 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15832 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15833 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15834 pos_token, "eth-dst");
15835 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15836 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15839 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15840 __attribute__((unused)) struct cmdline *cl,
15841 __attribute__((unused)) void *data)
15843 struct cmd_set_mplsogre_encap_result *res = parsed_result;
15845 uint32_t mplsogre_label;
15848 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15851 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15852 mplsogre_encap_conf.select_vlan = 0;
15853 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15854 mplsogre_encap_conf.select_vlan = 1;
15855 if (strcmp(res->ip_version, "ipv4") == 0)
15856 mplsogre_encap_conf.select_ipv4 = 1;
15857 else if (strcmp(res->ip_version, "ipv6") == 0)
15858 mplsogre_encap_conf.select_ipv4 = 0;
15861 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15862 if (mplsogre_encap_conf.select_ipv4) {
15863 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15864 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15866 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15867 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15869 if (mplsogre_encap_conf.select_vlan)
15870 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15871 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15872 RTE_ETHER_ADDR_LEN);
15873 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15874 RTE_ETHER_ADDR_LEN);
15877 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15878 .f = cmd_set_mplsogre_encap_parsed,
15880 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15881 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15882 " eth-dst <eth-dst>",
15884 (void *)&cmd_set_mplsogre_encap_set,
15885 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15886 (void *)&cmd_set_mplsogre_encap_ip_version,
15887 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15888 (void *)&cmd_set_mplsogre_encap_label,
15889 (void *)&cmd_set_mplsogre_encap_label_value,
15890 (void *)&cmd_set_mplsogre_encap_ip_src,
15891 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15892 (void *)&cmd_set_mplsogre_encap_ip_dst,
15893 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15894 (void *)&cmd_set_mplsogre_encap_eth_src,
15895 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15896 (void *)&cmd_set_mplsogre_encap_eth_dst,
15897 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15902 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
15903 .f = cmd_set_mplsogre_encap_parsed,
15905 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
15906 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
15907 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15909 (void *)&cmd_set_mplsogre_encap_set,
15910 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
15911 (void *)&cmd_set_mplsogre_encap_ip_version,
15912 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15913 (void *)&cmd_set_mplsogre_encap_label,
15914 (void *)&cmd_set_mplsogre_encap_label_value,
15915 (void *)&cmd_set_mplsogre_encap_ip_src,
15916 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15917 (void *)&cmd_set_mplsogre_encap_ip_dst,
15918 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15919 (void *)&cmd_set_mplsogre_encap_vlan,
15920 (void *)&cmd_set_mplsogre_encap_vlan_value,
15921 (void *)&cmd_set_mplsogre_encap_eth_src,
15922 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15923 (void *)&cmd_set_mplsogre_encap_eth_dst,
15924 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15929 /** Set MPLSoGRE decapsulation details */
15930 struct cmd_set_mplsogre_decap_result {
15931 cmdline_fixed_string_t set;
15932 cmdline_fixed_string_t mplsogre;
15933 cmdline_fixed_string_t pos_token;
15934 cmdline_fixed_string_t ip_version;
15935 uint32_t vlan_present:1;
15938 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
15939 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
15941 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
15942 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
15944 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
15945 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15946 mplsogre, "mplsogre_decap-with-vlan");
15947 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
15948 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15949 pos_token, "ip-version");
15950 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
15951 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15952 ip_version, "ipv4#ipv6");
15954 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
15955 __attribute__((unused)) struct cmdline *cl,
15956 __attribute__((unused)) void *data)
15958 struct cmd_set_mplsogre_decap_result *res = parsed_result;
15960 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
15961 mplsogre_decap_conf.select_vlan = 0;
15962 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
15963 mplsogre_decap_conf.select_vlan = 1;
15964 if (strcmp(res->ip_version, "ipv4") == 0)
15965 mplsogre_decap_conf.select_ipv4 = 1;
15966 else if (strcmp(res->ip_version, "ipv6") == 0)
15967 mplsogre_decap_conf.select_ipv4 = 0;
15970 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
15971 .f = cmd_set_mplsogre_decap_parsed,
15973 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
15975 (void *)&cmd_set_mplsogre_decap_set,
15976 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
15977 (void *)&cmd_set_mplsogre_decap_ip_version,
15978 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15983 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
15984 .f = cmd_set_mplsogre_decap_parsed,
15986 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
15988 (void *)&cmd_set_mplsogre_decap_set,
15989 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
15990 (void *)&cmd_set_mplsogre_decap_ip_version,
15991 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15996 /** Set MPLSoUDP encapsulation details */
15997 struct cmd_set_mplsoudp_encap_result {
15998 cmdline_fixed_string_t set;
15999 cmdline_fixed_string_t mplsoudp;
16000 cmdline_fixed_string_t pos_token;
16001 cmdline_fixed_string_t ip_version;
16002 uint32_t vlan_present:1;
16006 cmdline_ipaddr_t ip_src;
16007 cmdline_ipaddr_t ip_dst;
16009 struct rte_ether_addr eth_src;
16010 struct rte_ether_addr eth_dst;
16013 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16014 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16016 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16017 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16019 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16020 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16021 mplsoudp, "mplsoudp_encap-with-vlan");
16022 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16023 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16024 pos_token, "ip-version");
16025 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16026 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16027 ip_version, "ipv4#ipv6");
16028 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16029 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16030 pos_token, "label");
16031 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16032 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16034 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16035 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16036 pos_token, "udp-src");
16037 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16038 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16040 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16041 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16042 pos_token, "udp-dst");
16043 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16044 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16046 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16047 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16048 pos_token, "ip-src");
16049 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16050 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16051 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16052 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16053 pos_token, "ip-dst");
16054 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16055 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16056 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16057 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16058 pos_token, "vlan-tci");
16059 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16060 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16062 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16063 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16064 pos_token, "eth-src");
16065 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16066 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16068 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16069 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16070 pos_token, "eth-dst");
16071 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16072 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16075 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16076 __attribute__((unused)) struct cmdline *cl,
16077 __attribute__((unused)) void *data)
16079 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16081 uint32_t mplsoudp_label;
16084 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16087 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16088 mplsoudp_encap_conf.select_vlan = 0;
16089 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16090 mplsoudp_encap_conf.select_vlan = 1;
16091 if (strcmp(res->ip_version, "ipv4") == 0)
16092 mplsoudp_encap_conf.select_ipv4 = 1;
16093 else if (strcmp(res->ip_version, "ipv6") == 0)
16094 mplsoudp_encap_conf.select_ipv4 = 0;
16097 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16098 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16099 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16100 if (mplsoudp_encap_conf.select_ipv4) {
16101 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16102 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16104 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16105 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16107 if (mplsoudp_encap_conf.select_vlan)
16108 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16109 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16110 RTE_ETHER_ADDR_LEN);
16111 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16112 RTE_ETHER_ADDR_LEN);
16115 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16116 .f = cmd_set_mplsoudp_encap_parsed,
16118 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16119 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16120 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16122 (void *)&cmd_set_mplsoudp_encap_set,
16123 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16124 (void *)&cmd_set_mplsoudp_encap_ip_version,
16125 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16126 (void *)&cmd_set_mplsoudp_encap_label,
16127 (void *)&cmd_set_mplsoudp_encap_label_value,
16128 (void *)&cmd_set_mplsoudp_encap_udp_src,
16129 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16130 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16131 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16132 (void *)&cmd_set_mplsoudp_encap_ip_src,
16133 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16134 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16135 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16136 (void *)&cmd_set_mplsoudp_encap_eth_src,
16137 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16138 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16139 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16144 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16145 .f = cmd_set_mplsoudp_encap_parsed,
16147 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16148 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16149 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16150 " eth-src <eth-src> eth-dst <eth-dst>",
16152 (void *)&cmd_set_mplsoudp_encap_set,
16153 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16154 (void *)&cmd_set_mplsoudp_encap_ip_version,
16155 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16156 (void *)&cmd_set_mplsoudp_encap_label,
16157 (void *)&cmd_set_mplsoudp_encap_label_value,
16158 (void *)&cmd_set_mplsoudp_encap_udp_src,
16159 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16160 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16161 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16162 (void *)&cmd_set_mplsoudp_encap_ip_src,
16163 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16164 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16165 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16166 (void *)&cmd_set_mplsoudp_encap_vlan,
16167 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16168 (void *)&cmd_set_mplsoudp_encap_eth_src,
16169 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16170 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16171 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16176 /** Set MPLSoUDP decapsulation details */
16177 struct cmd_set_mplsoudp_decap_result {
16178 cmdline_fixed_string_t set;
16179 cmdline_fixed_string_t mplsoudp;
16180 cmdline_fixed_string_t pos_token;
16181 cmdline_fixed_string_t ip_version;
16182 uint32_t vlan_present:1;
16185 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16186 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16188 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16189 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16191 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16192 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16193 mplsoudp, "mplsoudp_decap-with-vlan");
16194 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16195 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16196 pos_token, "ip-version");
16197 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16198 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16199 ip_version, "ipv4#ipv6");
16201 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16202 __attribute__((unused)) struct cmdline *cl,
16203 __attribute__((unused)) void *data)
16205 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16207 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16208 mplsoudp_decap_conf.select_vlan = 0;
16209 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16210 mplsoudp_decap_conf.select_vlan = 1;
16211 if (strcmp(res->ip_version, "ipv4") == 0)
16212 mplsoudp_decap_conf.select_ipv4 = 1;
16213 else if (strcmp(res->ip_version, "ipv6") == 0)
16214 mplsoudp_decap_conf.select_ipv4 = 0;
16217 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16218 .f = cmd_set_mplsoudp_decap_parsed,
16220 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16222 (void *)&cmd_set_mplsoudp_decap_set,
16223 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16224 (void *)&cmd_set_mplsoudp_decap_ip_version,
16225 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16230 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16231 .f = cmd_set_mplsoudp_decap_parsed,
16233 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16235 (void *)&cmd_set_mplsoudp_decap_set,
16236 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16237 (void *)&cmd_set_mplsoudp_decap_ip_version,
16238 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16243 /* Strict link priority scheduling mode setting */
16245 cmd_strict_link_prio_parsed(
16246 void *parsed_result,
16247 __attribute__((unused)) struct cmdline *cl,
16248 __attribute__((unused)) void *data)
16250 struct cmd_vf_tc_bw_result *res = parsed_result;
16251 int ret = -ENOTSUP;
16253 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16256 #ifdef RTE_LIBRTE_I40E_PMD
16257 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16264 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16267 printf("invalid port_id %d\n", res->port_id);
16270 printf("function not implemented\n");
16273 printf("programming error: (%s)\n", strerror(-ret));
16277 cmdline_parse_inst_t cmd_strict_link_prio = {
16278 .f = cmd_strict_link_prio_parsed,
16280 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16282 (void *)&cmd_vf_tc_bw_set,
16283 (void *)&cmd_vf_tc_bw_tx,
16284 (void *)&cmd_vf_tc_bw_strict_link_prio,
16285 (void *)&cmd_vf_tc_bw_port_id,
16286 (void *)&cmd_vf_tc_bw_tc_map,
16291 /* Load dynamic device personalization*/
16292 struct cmd_ddp_add_result {
16293 cmdline_fixed_string_t ddp;
16294 cmdline_fixed_string_t add;
16299 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16300 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16301 cmdline_parse_token_string_t cmd_ddp_add_add =
16302 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16303 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16304 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16305 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16306 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16309 cmd_ddp_add_parsed(
16310 void *parsed_result,
16311 __attribute__((unused)) struct cmdline *cl,
16312 __attribute__((unused)) void *data)
16314 struct cmd_ddp_add_result *res = parsed_result;
16320 int ret = -ENOTSUP;
16322 if (!all_ports_stopped()) {
16323 printf("Please stop all ports first\n");
16327 filepath = strdup(res->filepath);
16328 if (filepath == NULL) {
16329 printf("Failed to allocate memory\n");
16332 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16334 buff = open_file(file_fld[0], &size);
16336 free((void *)filepath);
16340 #ifdef RTE_LIBRTE_I40E_PMD
16341 if (ret == -ENOTSUP)
16342 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16344 RTE_PMD_I40E_PKG_OP_WR_ADD);
16347 if (ret == -EEXIST)
16348 printf("Profile has already existed.\n");
16350 printf("Failed to load profile.\n");
16351 else if (file_num == 2)
16352 save_file(file_fld[1], buff, size);
16355 free((void *)filepath);
16358 cmdline_parse_inst_t cmd_ddp_add = {
16359 .f = cmd_ddp_add_parsed,
16361 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16363 (void *)&cmd_ddp_add_ddp,
16364 (void *)&cmd_ddp_add_add,
16365 (void *)&cmd_ddp_add_port_id,
16366 (void *)&cmd_ddp_add_filepath,
16371 /* Delete dynamic device personalization*/
16372 struct cmd_ddp_del_result {
16373 cmdline_fixed_string_t ddp;
16374 cmdline_fixed_string_t del;
16379 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16380 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16381 cmdline_parse_token_string_t cmd_ddp_del_del =
16382 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16383 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16384 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16385 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16386 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16389 cmd_ddp_del_parsed(
16390 void *parsed_result,
16391 __attribute__((unused)) struct cmdline *cl,
16392 __attribute__((unused)) void *data)
16394 struct cmd_ddp_del_result *res = parsed_result;
16397 int ret = -ENOTSUP;
16399 if (!all_ports_stopped()) {
16400 printf("Please stop all ports first\n");
16404 buff = open_file(res->filepath, &size);
16408 #ifdef RTE_LIBRTE_I40E_PMD
16409 if (ret == -ENOTSUP)
16410 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16412 RTE_PMD_I40E_PKG_OP_WR_DEL);
16415 if (ret == -EACCES)
16416 printf("Profile does not exist.\n");
16418 printf("Failed to delete profile.\n");
16423 cmdline_parse_inst_t cmd_ddp_del = {
16424 .f = cmd_ddp_del_parsed,
16426 .help_str = "ddp del <port_id> <backup_profile_path>",
16428 (void *)&cmd_ddp_del_ddp,
16429 (void *)&cmd_ddp_del_del,
16430 (void *)&cmd_ddp_del_port_id,
16431 (void *)&cmd_ddp_del_filepath,
16436 /* Get dynamic device personalization profile info */
16437 struct cmd_ddp_info_result {
16438 cmdline_fixed_string_t ddp;
16439 cmdline_fixed_string_t get;
16440 cmdline_fixed_string_t info;
16444 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16445 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16446 cmdline_parse_token_string_t cmd_ddp_info_get =
16447 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16448 cmdline_parse_token_string_t cmd_ddp_info_info =
16449 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16450 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16451 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16454 cmd_ddp_info_parsed(
16455 void *parsed_result,
16456 __attribute__((unused)) struct cmdline *cl,
16457 __attribute__((unused)) void *data)
16459 struct cmd_ddp_info_result *res = parsed_result;
16462 int ret = -ENOTSUP;
16463 #ifdef RTE_LIBRTE_I40E_PMD
16466 uint32_t buff_size = 0;
16467 struct rte_pmd_i40e_profile_info info;
16468 uint32_t dev_num = 0;
16469 struct rte_pmd_i40e_ddp_device_id *devs;
16470 uint32_t proto_num = 0;
16471 struct rte_pmd_i40e_proto_info *proto = NULL;
16472 uint32_t pctype_num = 0;
16473 struct rte_pmd_i40e_ptype_info *pctype;
16474 uint32_t ptype_num = 0;
16475 struct rte_pmd_i40e_ptype_info *ptype;
16480 pkg = open_file(res->filepath, &pkg_size);
16484 #ifdef RTE_LIBRTE_I40E_PMD
16485 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16486 (uint8_t *)&info, sizeof(info),
16487 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16489 printf("Global Track id: 0x%x\n", info.track_id);
16490 printf("Global Version: %d.%d.%d.%d\n",
16491 info.version.major,
16492 info.version.minor,
16493 info.version.update,
16494 info.version.draft);
16495 printf("Global Package name: %s\n\n", info.name);
16498 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16499 (uint8_t *)&info, sizeof(info),
16500 RTE_PMD_I40E_PKG_INFO_HEADER);
16502 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16503 printf("i40e Profile Version: %d.%d.%d.%d\n",
16504 info.version.major,
16505 info.version.minor,
16506 info.version.update,
16507 info.version.draft);
16508 printf("i40e Profile name: %s\n\n", info.name);
16511 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16512 (uint8_t *)&buff_size, sizeof(buff_size),
16513 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16514 if (!ret && buff_size) {
16515 buff = (uint8_t *)malloc(buff_size);
16517 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16519 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16521 printf("Package Notes:\n%s\n\n", buff);
16526 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16527 (uint8_t *)&dev_num, sizeof(dev_num),
16528 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16529 if (!ret && dev_num) {
16530 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16531 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16533 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16534 (uint8_t *)devs, buff_size,
16535 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16537 printf("List of supported devices:\n");
16538 for (i = 0; i < dev_num; i++) {
16539 printf(" %04X:%04X %04X:%04X\n",
16540 devs[i].vendor_dev_id >> 16,
16541 devs[i].vendor_dev_id & 0xFFFF,
16542 devs[i].sub_vendor_dev_id >> 16,
16543 devs[i].sub_vendor_dev_id & 0xFFFF);
16551 /* get information about protocols and packet types */
16552 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16553 (uint8_t *)&proto_num, sizeof(proto_num),
16554 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16555 if (ret || !proto_num)
16556 goto no_print_return;
16558 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16559 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16561 goto no_print_return;
16563 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16565 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16567 printf("List of used protocols:\n");
16568 for (i = 0; i < proto_num; i++)
16569 printf(" %2u: %s\n", proto[i].proto_id,
16573 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16574 (uint8_t *)&pctype_num, sizeof(pctype_num),
16575 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16576 if (ret || !pctype_num)
16577 goto no_print_pctypes;
16579 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16580 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16582 goto no_print_pctypes;
16584 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16586 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16589 goto no_print_pctypes;
16592 printf("List of defined packet classification types:\n");
16593 for (i = 0; i < pctype_num; i++) {
16594 printf(" %2u:", pctype[i].ptype_id);
16595 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16596 proto_id = pctype[i].protocols[j];
16597 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16598 for (n = 0; n < proto_num; n++) {
16599 if (proto[n].proto_id == proto_id) {
16600 printf(" %s", proto[n].name);
16613 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16615 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16616 if (ret || !ptype_num)
16617 goto no_print_return;
16619 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16620 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16622 goto no_print_return;
16624 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16626 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16629 goto no_print_return;
16631 printf("List of defined packet types:\n");
16632 for (i = 0; i < ptype_num; i++) {
16633 printf(" %2u:", ptype[i].ptype_id);
16634 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16635 proto_id = ptype[i].protocols[j];
16636 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16637 for (n = 0; n < proto_num; n++) {
16638 if (proto[n].proto_id == proto_id) {
16639 printf(" %s", proto[n].name);
16655 if (ret == -ENOTSUP)
16656 printf("Function not supported in PMD driver\n");
16660 cmdline_parse_inst_t cmd_ddp_get_info = {
16661 .f = cmd_ddp_info_parsed,
16663 .help_str = "ddp get info <profile_path>",
16665 (void *)&cmd_ddp_info_ddp,
16666 (void *)&cmd_ddp_info_get,
16667 (void *)&cmd_ddp_info_info,
16668 (void *)&cmd_ddp_info_filepath,
16673 /* Get dynamic device personalization profile info list*/
16674 #define PROFILE_INFO_SIZE 48
16675 #define MAX_PROFILE_NUM 16
16677 struct cmd_ddp_get_list_result {
16678 cmdline_fixed_string_t ddp;
16679 cmdline_fixed_string_t get;
16680 cmdline_fixed_string_t list;
16684 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16685 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16686 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16687 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16688 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16689 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16690 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16691 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16694 cmd_ddp_get_list_parsed(
16695 __attribute__((unused)) void *parsed_result,
16696 __attribute__((unused)) struct cmdline *cl,
16697 __attribute__((unused)) void *data)
16699 #ifdef RTE_LIBRTE_I40E_PMD
16700 struct cmd_ddp_get_list_result *res = parsed_result;
16701 struct rte_pmd_i40e_profile_list *p_list;
16702 struct rte_pmd_i40e_profile_info *p_info;
16707 int ret = -ENOTSUP;
16709 #ifdef RTE_LIBRTE_I40E_PMD
16710 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16711 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16713 printf("%s: Failed to malloc buffer\n", __func__);
16715 if (ret == -ENOTSUP)
16716 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16717 (uint8_t *)p_list, size);
16720 p_num = p_list->p_count;
16721 printf("Profile number is: %d\n\n", p_num);
16723 for (i = 0; i < p_num; i++) {
16724 p_info = &p_list->p_info[i];
16725 printf("Profile %d:\n", i);
16726 printf("Track id: 0x%x\n", p_info->track_id);
16727 printf("Version: %d.%d.%d.%d\n",
16728 p_info->version.major,
16729 p_info->version.minor,
16730 p_info->version.update,
16731 p_info->version.draft);
16732 printf("Profile name: %s\n\n", p_info->name);
16740 printf("Failed to get ddp list\n");
16743 cmdline_parse_inst_t cmd_ddp_get_list = {
16744 .f = cmd_ddp_get_list_parsed,
16746 .help_str = "ddp get list <port_id>",
16748 (void *)&cmd_ddp_get_list_ddp,
16749 (void *)&cmd_ddp_get_list_get,
16750 (void *)&cmd_ddp_get_list_list,
16751 (void *)&cmd_ddp_get_list_port_id,
16756 /* Configure input set */
16757 struct cmd_cfg_input_set_result {
16758 cmdline_fixed_string_t port;
16759 cmdline_fixed_string_t cfg;
16761 cmdline_fixed_string_t pctype;
16763 cmdline_fixed_string_t inset_type;
16764 cmdline_fixed_string_t opt;
16765 cmdline_fixed_string_t field;
16770 cmd_cfg_input_set_parsed(
16771 __attribute__((unused)) void *parsed_result,
16772 __attribute__((unused)) struct cmdline *cl,
16773 __attribute__((unused)) void *data)
16775 #ifdef RTE_LIBRTE_I40E_PMD
16776 struct cmd_cfg_input_set_result *res = parsed_result;
16777 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16778 struct rte_pmd_i40e_inset inset;
16780 int ret = -ENOTSUP;
16782 if (!all_ports_stopped()) {
16783 printf("Please stop all ports first\n");
16787 #ifdef RTE_LIBRTE_I40E_PMD
16788 if (!strcmp(res->inset_type, "hash_inset"))
16789 inset_type = INSET_HASH;
16790 else if (!strcmp(res->inset_type, "fdir_inset"))
16791 inset_type = INSET_FDIR;
16792 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16793 inset_type = INSET_FDIR_FLX;
16794 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16795 &inset, inset_type);
16797 printf("Failed to get input set.\n");
16801 if (!strcmp(res->opt, "get")) {
16802 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16805 printf("Field index %d is enabled.\n", res->field_idx);
16807 printf("Field index %d is disabled.\n", res->field_idx);
16809 } else if (!strcmp(res->opt, "set"))
16810 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16812 else if (!strcmp(res->opt, "clear"))
16813 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16816 printf("Failed to configure input set field.\n");
16820 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16821 &inset, inset_type);
16823 printf("Failed to set input set.\n");
16828 if (ret == -ENOTSUP)
16829 printf("Function not supported\n");
16832 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16833 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16835 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16836 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16838 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16839 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16841 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16842 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16844 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16845 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16847 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16848 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16850 "hash_inset#fdir_inset#fdir_flx_inset");
16851 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16852 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16853 opt, "get#set#clear");
16854 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16855 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16857 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16858 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16861 cmdline_parse_inst_t cmd_cfg_input_set = {
16862 .f = cmd_cfg_input_set_parsed,
16864 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16865 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16867 (void *)&cmd_cfg_input_set_port,
16868 (void *)&cmd_cfg_input_set_cfg,
16869 (void *)&cmd_cfg_input_set_port_id,
16870 (void *)&cmd_cfg_input_set_pctype,
16871 (void *)&cmd_cfg_input_set_pctype_id,
16872 (void *)&cmd_cfg_input_set_inset_type,
16873 (void *)&cmd_cfg_input_set_opt,
16874 (void *)&cmd_cfg_input_set_field,
16875 (void *)&cmd_cfg_input_set_field_idx,
16880 /* Clear input set */
16881 struct cmd_clear_input_set_result {
16882 cmdline_fixed_string_t port;
16883 cmdline_fixed_string_t cfg;
16885 cmdline_fixed_string_t pctype;
16887 cmdline_fixed_string_t inset_type;
16888 cmdline_fixed_string_t clear;
16889 cmdline_fixed_string_t all;
16893 cmd_clear_input_set_parsed(
16894 __attribute__((unused)) void *parsed_result,
16895 __attribute__((unused)) struct cmdline *cl,
16896 __attribute__((unused)) void *data)
16898 #ifdef RTE_LIBRTE_I40E_PMD
16899 struct cmd_clear_input_set_result *res = parsed_result;
16900 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16901 struct rte_pmd_i40e_inset inset;
16903 int ret = -ENOTSUP;
16905 if (!all_ports_stopped()) {
16906 printf("Please stop all ports first\n");
16910 #ifdef RTE_LIBRTE_I40E_PMD
16911 if (!strcmp(res->inset_type, "hash_inset"))
16912 inset_type = INSET_HASH;
16913 else if (!strcmp(res->inset_type, "fdir_inset"))
16914 inset_type = INSET_FDIR;
16915 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16916 inset_type = INSET_FDIR_FLX;
16918 memset(&inset, 0, sizeof(inset));
16920 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16921 &inset, inset_type);
16923 printf("Failed to clear input set.\n");
16929 if (ret == -ENOTSUP)
16930 printf("Function not supported\n");
16933 cmdline_parse_token_string_t cmd_clear_input_set_port =
16934 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16936 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
16937 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16939 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
16940 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16942 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
16943 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16945 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
16946 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16948 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
16949 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16951 "hash_inset#fdir_inset#fdir_flx_inset");
16952 cmdline_parse_token_string_t cmd_clear_input_set_clear =
16953 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16955 cmdline_parse_token_string_t cmd_clear_input_set_all =
16956 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16959 cmdline_parse_inst_t cmd_clear_input_set = {
16960 .f = cmd_clear_input_set_parsed,
16962 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16963 "fdir_inset|fdir_flx_inset clear all",
16965 (void *)&cmd_clear_input_set_port,
16966 (void *)&cmd_clear_input_set_cfg,
16967 (void *)&cmd_clear_input_set_port_id,
16968 (void *)&cmd_clear_input_set_pctype,
16969 (void *)&cmd_clear_input_set_pctype_id,
16970 (void *)&cmd_clear_input_set_inset_type,
16971 (void *)&cmd_clear_input_set_clear,
16972 (void *)&cmd_clear_input_set_all,
16977 /* show vf stats */
16979 /* Common result structure for show vf stats */
16980 struct cmd_show_vf_stats_result {
16981 cmdline_fixed_string_t show;
16982 cmdline_fixed_string_t vf;
16983 cmdline_fixed_string_t stats;
16988 /* Common CLI fields show vf stats*/
16989 cmdline_parse_token_string_t cmd_show_vf_stats_show =
16990 TOKEN_STRING_INITIALIZER
16991 (struct cmd_show_vf_stats_result,
16993 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
16994 TOKEN_STRING_INITIALIZER
16995 (struct cmd_show_vf_stats_result,
16997 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
16998 TOKEN_STRING_INITIALIZER
16999 (struct cmd_show_vf_stats_result,
17001 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17002 TOKEN_NUM_INITIALIZER
17003 (struct cmd_show_vf_stats_result,
17005 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17006 TOKEN_NUM_INITIALIZER
17007 (struct cmd_show_vf_stats_result,
17011 cmd_show_vf_stats_parsed(
17012 void *parsed_result,
17013 __attribute__((unused)) struct cmdline *cl,
17014 __attribute__((unused)) void *data)
17016 struct cmd_show_vf_stats_result *res = parsed_result;
17017 struct rte_eth_stats stats;
17018 int ret = -ENOTSUP;
17019 static const char *nic_stats_border = "########################";
17021 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17024 memset(&stats, 0, sizeof(stats));
17026 #ifdef RTE_LIBRTE_I40E_PMD
17027 if (ret == -ENOTSUP)
17028 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17032 #ifdef RTE_LIBRTE_BNXT_PMD
17033 if (ret == -ENOTSUP)
17034 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17043 printf("invalid vf_id %d\n", res->vf_id);
17046 printf("invalid port_id %d\n", res->port_id);
17049 printf("function not implemented\n");
17052 printf("programming error: (%s)\n", strerror(-ret));
17055 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17056 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17058 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17060 stats.ipackets, stats.imissed, stats.ibytes);
17061 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17062 printf(" RX-nombuf: %-10"PRIu64"\n",
17064 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17066 stats.opackets, stats.oerrors, stats.obytes);
17068 printf(" %s############################%s\n",
17069 nic_stats_border, nic_stats_border);
17072 cmdline_parse_inst_t cmd_show_vf_stats = {
17073 .f = cmd_show_vf_stats_parsed,
17075 .help_str = "show vf stats <port_id> <vf_id>",
17077 (void *)&cmd_show_vf_stats_show,
17078 (void *)&cmd_show_vf_stats_vf,
17079 (void *)&cmd_show_vf_stats_stats,
17080 (void *)&cmd_show_vf_stats_port_id,
17081 (void *)&cmd_show_vf_stats_vf_id,
17086 /* clear vf stats */
17088 /* Common result structure for clear vf stats */
17089 struct cmd_clear_vf_stats_result {
17090 cmdline_fixed_string_t clear;
17091 cmdline_fixed_string_t vf;
17092 cmdline_fixed_string_t stats;
17097 /* Common CLI fields clear vf stats*/
17098 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17099 TOKEN_STRING_INITIALIZER
17100 (struct cmd_clear_vf_stats_result,
17102 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17103 TOKEN_STRING_INITIALIZER
17104 (struct cmd_clear_vf_stats_result,
17106 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17107 TOKEN_STRING_INITIALIZER
17108 (struct cmd_clear_vf_stats_result,
17110 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17111 TOKEN_NUM_INITIALIZER
17112 (struct cmd_clear_vf_stats_result,
17114 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17115 TOKEN_NUM_INITIALIZER
17116 (struct cmd_clear_vf_stats_result,
17120 cmd_clear_vf_stats_parsed(
17121 void *parsed_result,
17122 __attribute__((unused)) struct cmdline *cl,
17123 __attribute__((unused)) void *data)
17125 struct cmd_clear_vf_stats_result *res = parsed_result;
17126 int ret = -ENOTSUP;
17128 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17131 #ifdef RTE_LIBRTE_I40E_PMD
17132 if (ret == -ENOTSUP)
17133 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17136 #ifdef RTE_LIBRTE_BNXT_PMD
17137 if (ret == -ENOTSUP)
17138 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17146 printf("invalid vf_id %d\n", res->vf_id);
17149 printf("invalid port_id %d\n", res->port_id);
17152 printf("function not implemented\n");
17155 printf("programming error: (%s)\n", strerror(-ret));
17159 cmdline_parse_inst_t cmd_clear_vf_stats = {
17160 .f = cmd_clear_vf_stats_parsed,
17162 .help_str = "clear vf stats <port_id> <vf_id>",
17164 (void *)&cmd_clear_vf_stats_clear,
17165 (void *)&cmd_clear_vf_stats_vf,
17166 (void *)&cmd_clear_vf_stats_stats,
17167 (void *)&cmd_clear_vf_stats_port_id,
17168 (void *)&cmd_clear_vf_stats_vf_id,
17173 /* port config pctype mapping reset */
17175 /* Common result structure for port config pctype mapping reset */
17176 struct cmd_pctype_mapping_reset_result {
17177 cmdline_fixed_string_t port;
17178 cmdline_fixed_string_t config;
17180 cmdline_fixed_string_t pctype;
17181 cmdline_fixed_string_t mapping;
17182 cmdline_fixed_string_t reset;
17185 /* Common CLI fields for port config pctype mapping reset*/
17186 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17187 TOKEN_STRING_INITIALIZER
17188 (struct cmd_pctype_mapping_reset_result,
17190 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17191 TOKEN_STRING_INITIALIZER
17192 (struct cmd_pctype_mapping_reset_result,
17194 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17195 TOKEN_NUM_INITIALIZER
17196 (struct cmd_pctype_mapping_reset_result,
17198 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17199 TOKEN_STRING_INITIALIZER
17200 (struct cmd_pctype_mapping_reset_result,
17202 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17203 TOKEN_STRING_INITIALIZER
17204 (struct cmd_pctype_mapping_reset_result,
17205 mapping, "mapping");
17206 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17207 TOKEN_STRING_INITIALIZER
17208 (struct cmd_pctype_mapping_reset_result,
17212 cmd_pctype_mapping_reset_parsed(
17213 void *parsed_result,
17214 __attribute__((unused)) struct cmdline *cl,
17215 __attribute__((unused)) void *data)
17217 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17218 int ret = -ENOTSUP;
17220 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17223 #ifdef RTE_LIBRTE_I40E_PMD
17224 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17231 printf("invalid port_id %d\n", res->port_id);
17234 printf("function not implemented\n");
17237 printf("programming error: (%s)\n", strerror(-ret));
17241 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17242 .f = cmd_pctype_mapping_reset_parsed,
17244 .help_str = "port config <port_id> pctype mapping reset",
17246 (void *)&cmd_pctype_mapping_reset_port,
17247 (void *)&cmd_pctype_mapping_reset_config,
17248 (void *)&cmd_pctype_mapping_reset_port_id,
17249 (void *)&cmd_pctype_mapping_reset_pctype,
17250 (void *)&cmd_pctype_mapping_reset_mapping,
17251 (void *)&cmd_pctype_mapping_reset_reset,
17256 /* show port pctype mapping */
17258 /* Common result structure for show port pctype mapping */
17259 struct cmd_pctype_mapping_get_result {
17260 cmdline_fixed_string_t show;
17261 cmdline_fixed_string_t port;
17263 cmdline_fixed_string_t pctype;
17264 cmdline_fixed_string_t mapping;
17267 /* Common CLI fields for pctype mapping get */
17268 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17269 TOKEN_STRING_INITIALIZER
17270 (struct cmd_pctype_mapping_get_result,
17272 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17273 TOKEN_STRING_INITIALIZER
17274 (struct cmd_pctype_mapping_get_result,
17276 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17277 TOKEN_NUM_INITIALIZER
17278 (struct cmd_pctype_mapping_get_result,
17280 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17281 TOKEN_STRING_INITIALIZER
17282 (struct cmd_pctype_mapping_get_result,
17284 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17285 TOKEN_STRING_INITIALIZER
17286 (struct cmd_pctype_mapping_get_result,
17287 mapping, "mapping");
17290 cmd_pctype_mapping_get_parsed(
17291 void *parsed_result,
17292 __attribute__((unused)) struct cmdline *cl,
17293 __attribute__((unused)) void *data)
17295 struct cmd_pctype_mapping_get_result *res = parsed_result;
17296 int ret = -ENOTSUP;
17297 #ifdef RTE_LIBRTE_I40E_PMD
17298 struct rte_pmd_i40e_flow_type_mapping
17299 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17300 int i, j, first_pctype;
17303 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17306 #ifdef RTE_LIBRTE_I40E_PMD
17307 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17314 printf("invalid port_id %d\n", res->port_id);
17317 printf("function not implemented\n");
17320 printf("programming error: (%s)\n", strerror(-ret));
17324 #ifdef RTE_LIBRTE_I40E_PMD
17325 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17326 if (mapping[i].pctype != 0ULL) {
17329 printf("pctype: ");
17330 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17331 if (mapping[i].pctype & (1ULL << j)) {
17332 printf(first_pctype ?
17333 "%02d" : ",%02d", j);
17337 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17343 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17344 .f = cmd_pctype_mapping_get_parsed,
17346 .help_str = "show port <port_id> pctype mapping",
17348 (void *)&cmd_pctype_mapping_get_show,
17349 (void *)&cmd_pctype_mapping_get_port,
17350 (void *)&cmd_pctype_mapping_get_port_id,
17351 (void *)&cmd_pctype_mapping_get_pctype,
17352 (void *)&cmd_pctype_mapping_get_mapping,
17357 /* port config pctype mapping update */
17359 /* Common result structure for port config pctype mapping update */
17360 struct cmd_pctype_mapping_update_result {
17361 cmdline_fixed_string_t port;
17362 cmdline_fixed_string_t config;
17364 cmdline_fixed_string_t pctype;
17365 cmdline_fixed_string_t mapping;
17366 cmdline_fixed_string_t update;
17367 cmdline_fixed_string_t pctype_list;
17368 uint16_t flow_type;
17371 /* Common CLI fields for pctype mapping update*/
17372 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17373 TOKEN_STRING_INITIALIZER
17374 (struct cmd_pctype_mapping_update_result,
17376 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17377 TOKEN_STRING_INITIALIZER
17378 (struct cmd_pctype_mapping_update_result,
17380 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17381 TOKEN_NUM_INITIALIZER
17382 (struct cmd_pctype_mapping_update_result,
17384 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17385 TOKEN_STRING_INITIALIZER
17386 (struct cmd_pctype_mapping_update_result,
17388 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17389 TOKEN_STRING_INITIALIZER
17390 (struct cmd_pctype_mapping_update_result,
17391 mapping, "mapping");
17392 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17393 TOKEN_STRING_INITIALIZER
17394 (struct cmd_pctype_mapping_update_result,
17396 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17397 TOKEN_STRING_INITIALIZER
17398 (struct cmd_pctype_mapping_update_result,
17399 pctype_list, NULL);
17400 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17401 TOKEN_NUM_INITIALIZER
17402 (struct cmd_pctype_mapping_update_result,
17403 flow_type, UINT16);
17406 cmd_pctype_mapping_update_parsed(
17407 void *parsed_result,
17408 __attribute__((unused)) struct cmdline *cl,
17409 __attribute__((unused)) void *data)
17411 struct cmd_pctype_mapping_update_result *res = parsed_result;
17412 int ret = -ENOTSUP;
17413 #ifdef RTE_LIBRTE_I40E_PMD
17414 struct rte_pmd_i40e_flow_type_mapping mapping;
17416 unsigned int nb_item;
17417 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17420 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17423 #ifdef RTE_LIBRTE_I40E_PMD
17424 nb_item = parse_item_list(res->pctype_list, "pctypes",
17425 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17426 mapping.flow_type = res->flow_type;
17427 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17428 mapping.pctype |= (1ULL << pctype_list[i]);
17429 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17439 printf("invalid pctype or flow type\n");
17442 printf("invalid port_id %d\n", res->port_id);
17445 printf("function not implemented\n");
17448 printf("programming error: (%s)\n", strerror(-ret));
17452 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17453 .f = cmd_pctype_mapping_update_parsed,
17455 .help_str = "port config <port_id> pctype mapping update"
17456 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17458 (void *)&cmd_pctype_mapping_update_port,
17459 (void *)&cmd_pctype_mapping_update_config,
17460 (void *)&cmd_pctype_mapping_update_port_id,
17461 (void *)&cmd_pctype_mapping_update_pctype,
17462 (void *)&cmd_pctype_mapping_update_mapping,
17463 (void *)&cmd_pctype_mapping_update_update,
17464 (void *)&cmd_pctype_mapping_update_pc_type,
17465 (void *)&cmd_pctype_mapping_update_flow_type,
17470 /* ptype mapping get */
17472 /* Common result structure for ptype mapping get */
17473 struct cmd_ptype_mapping_get_result {
17474 cmdline_fixed_string_t ptype;
17475 cmdline_fixed_string_t mapping;
17476 cmdline_fixed_string_t get;
17478 uint8_t valid_only;
17481 /* Common CLI fields for ptype mapping get */
17482 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17483 TOKEN_STRING_INITIALIZER
17484 (struct cmd_ptype_mapping_get_result,
17486 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17487 TOKEN_STRING_INITIALIZER
17488 (struct cmd_ptype_mapping_get_result,
17489 mapping, "mapping");
17490 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17491 TOKEN_STRING_INITIALIZER
17492 (struct cmd_ptype_mapping_get_result,
17494 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17495 TOKEN_NUM_INITIALIZER
17496 (struct cmd_ptype_mapping_get_result,
17498 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17499 TOKEN_NUM_INITIALIZER
17500 (struct cmd_ptype_mapping_get_result,
17501 valid_only, UINT8);
17504 cmd_ptype_mapping_get_parsed(
17505 void *parsed_result,
17506 __attribute__((unused)) struct cmdline *cl,
17507 __attribute__((unused)) void *data)
17509 struct cmd_ptype_mapping_get_result *res = parsed_result;
17510 int ret = -ENOTSUP;
17511 #ifdef RTE_LIBRTE_I40E_PMD
17512 int max_ptype_num = 256;
17513 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17518 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17521 #ifdef RTE_LIBRTE_I40E_PMD
17522 ret = rte_pmd_i40e_ptype_mapping_get(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));
17542 #ifdef RTE_LIBRTE_I40E_PMD
17544 for (i = 0; i < count; i++)
17545 printf("%3d\t0x%08x\n",
17546 mapping[i].hw_ptype, mapping[i].sw_ptype);
17551 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17552 .f = cmd_ptype_mapping_get_parsed,
17554 .help_str = "ptype mapping get <port_id> <valid_only>",
17556 (void *)&cmd_ptype_mapping_get_ptype,
17557 (void *)&cmd_ptype_mapping_get_mapping,
17558 (void *)&cmd_ptype_mapping_get_get,
17559 (void *)&cmd_ptype_mapping_get_port_id,
17560 (void *)&cmd_ptype_mapping_get_valid_only,
17565 /* ptype mapping replace */
17567 /* Common result structure for ptype mapping replace */
17568 struct cmd_ptype_mapping_replace_result {
17569 cmdline_fixed_string_t ptype;
17570 cmdline_fixed_string_t mapping;
17571 cmdline_fixed_string_t replace;
17578 /* Common CLI fields for ptype mapping replace */
17579 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17580 TOKEN_STRING_INITIALIZER
17581 (struct cmd_ptype_mapping_replace_result,
17583 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17584 TOKEN_STRING_INITIALIZER
17585 (struct cmd_ptype_mapping_replace_result,
17586 mapping, "mapping");
17587 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17588 TOKEN_STRING_INITIALIZER
17589 (struct cmd_ptype_mapping_replace_result,
17590 replace, "replace");
17591 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17592 TOKEN_NUM_INITIALIZER
17593 (struct cmd_ptype_mapping_replace_result,
17595 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17596 TOKEN_NUM_INITIALIZER
17597 (struct cmd_ptype_mapping_replace_result,
17599 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17600 TOKEN_NUM_INITIALIZER
17601 (struct cmd_ptype_mapping_replace_result,
17603 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17604 TOKEN_NUM_INITIALIZER
17605 (struct cmd_ptype_mapping_replace_result,
17609 cmd_ptype_mapping_replace_parsed(
17610 void *parsed_result,
17611 __attribute__((unused)) struct cmdline *cl,
17612 __attribute__((unused)) void *data)
17614 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17615 int ret = -ENOTSUP;
17617 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17620 #ifdef RTE_LIBRTE_I40E_PMD
17621 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17631 printf("invalid ptype 0x%8x or 0x%8x\n",
17632 res->target, res->pkt_type);
17635 printf("invalid port_id %d\n", res->port_id);
17638 printf("function not implemented\n");
17641 printf("programming error: (%s)\n", strerror(-ret));
17645 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17646 .f = cmd_ptype_mapping_replace_parsed,
17649 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17651 (void *)&cmd_ptype_mapping_replace_ptype,
17652 (void *)&cmd_ptype_mapping_replace_mapping,
17653 (void *)&cmd_ptype_mapping_replace_replace,
17654 (void *)&cmd_ptype_mapping_replace_port_id,
17655 (void *)&cmd_ptype_mapping_replace_target,
17656 (void *)&cmd_ptype_mapping_replace_mask,
17657 (void *)&cmd_ptype_mapping_replace_pkt_type,
17662 /* ptype mapping reset */
17664 /* Common result structure for ptype mapping reset */
17665 struct cmd_ptype_mapping_reset_result {
17666 cmdline_fixed_string_t ptype;
17667 cmdline_fixed_string_t mapping;
17668 cmdline_fixed_string_t reset;
17672 /* Common CLI fields for ptype mapping reset*/
17673 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17674 TOKEN_STRING_INITIALIZER
17675 (struct cmd_ptype_mapping_reset_result,
17677 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17678 TOKEN_STRING_INITIALIZER
17679 (struct cmd_ptype_mapping_reset_result,
17680 mapping, "mapping");
17681 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17682 TOKEN_STRING_INITIALIZER
17683 (struct cmd_ptype_mapping_reset_result,
17685 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17686 TOKEN_NUM_INITIALIZER
17687 (struct cmd_ptype_mapping_reset_result,
17691 cmd_ptype_mapping_reset_parsed(
17692 void *parsed_result,
17693 __attribute__((unused)) struct cmdline *cl,
17694 __attribute__((unused)) void *data)
17696 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17697 int ret = -ENOTSUP;
17699 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17702 #ifdef RTE_LIBRTE_I40E_PMD
17703 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17710 printf("invalid port_id %d\n", res->port_id);
17713 printf("function not implemented\n");
17716 printf("programming error: (%s)\n", strerror(-ret));
17720 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17721 .f = cmd_ptype_mapping_reset_parsed,
17723 .help_str = "ptype mapping reset <port_id>",
17725 (void *)&cmd_ptype_mapping_reset_ptype,
17726 (void *)&cmd_ptype_mapping_reset_mapping,
17727 (void *)&cmd_ptype_mapping_reset_reset,
17728 (void *)&cmd_ptype_mapping_reset_port_id,
17733 /* ptype mapping update */
17735 /* Common result structure for ptype mapping update */
17736 struct cmd_ptype_mapping_update_result {
17737 cmdline_fixed_string_t ptype;
17738 cmdline_fixed_string_t mapping;
17739 cmdline_fixed_string_t reset;
17745 /* Common CLI fields for ptype mapping update*/
17746 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17747 TOKEN_STRING_INITIALIZER
17748 (struct cmd_ptype_mapping_update_result,
17750 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17751 TOKEN_STRING_INITIALIZER
17752 (struct cmd_ptype_mapping_update_result,
17753 mapping, "mapping");
17754 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17755 TOKEN_STRING_INITIALIZER
17756 (struct cmd_ptype_mapping_update_result,
17758 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17759 TOKEN_NUM_INITIALIZER
17760 (struct cmd_ptype_mapping_update_result,
17762 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17763 TOKEN_NUM_INITIALIZER
17764 (struct cmd_ptype_mapping_update_result,
17766 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17767 TOKEN_NUM_INITIALIZER
17768 (struct cmd_ptype_mapping_update_result,
17772 cmd_ptype_mapping_update_parsed(
17773 void *parsed_result,
17774 __attribute__((unused)) struct cmdline *cl,
17775 __attribute__((unused)) void *data)
17777 struct cmd_ptype_mapping_update_result *res = parsed_result;
17778 int ret = -ENOTSUP;
17779 #ifdef RTE_LIBRTE_I40E_PMD
17780 struct rte_pmd_i40e_ptype_mapping mapping;
17782 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17785 #ifdef RTE_LIBRTE_I40E_PMD
17786 mapping.hw_ptype = res->hw_ptype;
17787 mapping.sw_ptype = res->sw_ptype;
17788 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17798 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17801 printf("invalid port_id %d\n", res->port_id);
17804 printf("function not implemented\n");
17807 printf("programming error: (%s)\n", strerror(-ret));
17811 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17812 .f = cmd_ptype_mapping_update_parsed,
17814 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17816 (void *)&cmd_ptype_mapping_update_ptype,
17817 (void *)&cmd_ptype_mapping_update_mapping,
17818 (void *)&cmd_ptype_mapping_update_update,
17819 (void *)&cmd_ptype_mapping_update_port_id,
17820 (void *)&cmd_ptype_mapping_update_hw_ptype,
17821 (void *)&cmd_ptype_mapping_update_sw_ptype,
17826 /* Common result structure for file commands */
17827 struct cmd_cmdfile_result {
17828 cmdline_fixed_string_t load;
17829 cmdline_fixed_string_t filename;
17832 /* Common CLI fields for file commands */
17833 cmdline_parse_token_string_t cmd_load_cmdfile =
17834 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17835 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17836 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17839 cmd_load_from_file_parsed(
17840 void *parsed_result,
17841 __attribute__((unused)) struct cmdline *cl,
17842 __attribute__((unused)) void *data)
17844 struct cmd_cmdfile_result *res = parsed_result;
17846 cmdline_read_from_file(res->filename);
17849 cmdline_parse_inst_t cmd_load_from_file = {
17850 .f = cmd_load_from_file_parsed,
17852 .help_str = "load <filename>",
17854 (void *)&cmd_load_cmdfile,
17855 (void *)&cmd_load_cmdfile_filename,
17860 /* Get Rx offloads capabilities */
17861 struct cmd_rx_offload_get_capa_result {
17862 cmdline_fixed_string_t show;
17863 cmdline_fixed_string_t port;
17865 cmdline_fixed_string_t rx_offload;
17866 cmdline_fixed_string_t capabilities;
17869 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17870 TOKEN_STRING_INITIALIZER
17871 (struct cmd_rx_offload_get_capa_result,
17873 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17874 TOKEN_STRING_INITIALIZER
17875 (struct cmd_rx_offload_get_capa_result,
17877 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17878 TOKEN_NUM_INITIALIZER
17879 (struct cmd_rx_offload_get_capa_result,
17881 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17882 TOKEN_STRING_INITIALIZER
17883 (struct cmd_rx_offload_get_capa_result,
17884 rx_offload, "rx_offload");
17885 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17886 TOKEN_STRING_INITIALIZER
17887 (struct cmd_rx_offload_get_capa_result,
17888 capabilities, "capabilities");
17891 print_rx_offloads(uint64_t offloads)
17893 uint64_t single_offload;
17901 begin = __builtin_ctzll(offloads);
17902 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17904 single_offload = 1ULL << begin;
17905 for (bit = begin; bit < end; bit++) {
17906 if (offloads & single_offload)
17908 rte_eth_dev_rx_offload_name(single_offload));
17909 single_offload <<= 1;
17914 cmd_rx_offload_get_capa_parsed(
17915 void *parsed_result,
17916 __attribute__((unused)) struct cmdline *cl,
17917 __attribute__((unused)) void *data)
17919 struct cmd_rx_offload_get_capa_result *res = parsed_result;
17920 struct rte_eth_dev_info dev_info;
17921 portid_t port_id = res->port_id;
17922 uint64_t queue_offloads;
17923 uint64_t port_offloads;
17926 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17930 queue_offloads = dev_info.rx_queue_offload_capa;
17931 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
17933 printf("Rx Offloading Capabilities of port %d :\n", port_id);
17934 printf(" Per Queue :");
17935 print_rx_offloads(queue_offloads);
17938 printf(" Per Port :");
17939 print_rx_offloads(port_offloads);
17943 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
17944 .f = cmd_rx_offload_get_capa_parsed,
17946 .help_str = "show port <port_id> rx_offload capabilities",
17948 (void *)&cmd_rx_offload_get_capa_show,
17949 (void *)&cmd_rx_offload_get_capa_port,
17950 (void *)&cmd_rx_offload_get_capa_port_id,
17951 (void *)&cmd_rx_offload_get_capa_rx_offload,
17952 (void *)&cmd_rx_offload_get_capa_capabilities,
17957 /* Get Rx offloads configuration */
17958 struct cmd_rx_offload_get_configuration_result {
17959 cmdline_fixed_string_t show;
17960 cmdline_fixed_string_t port;
17962 cmdline_fixed_string_t rx_offload;
17963 cmdline_fixed_string_t configuration;
17966 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
17967 TOKEN_STRING_INITIALIZER
17968 (struct cmd_rx_offload_get_configuration_result,
17970 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
17971 TOKEN_STRING_INITIALIZER
17972 (struct cmd_rx_offload_get_configuration_result,
17974 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
17975 TOKEN_NUM_INITIALIZER
17976 (struct cmd_rx_offload_get_configuration_result,
17978 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
17979 TOKEN_STRING_INITIALIZER
17980 (struct cmd_rx_offload_get_configuration_result,
17981 rx_offload, "rx_offload");
17982 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
17983 TOKEN_STRING_INITIALIZER
17984 (struct cmd_rx_offload_get_configuration_result,
17985 configuration, "configuration");
17988 cmd_rx_offload_get_configuration_parsed(
17989 void *parsed_result,
17990 __attribute__((unused)) struct cmdline *cl,
17991 __attribute__((unused)) void *data)
17993 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
17994 struct rte_eth_dev_info dev_info;
17995 portid_t port_id = res->port_id;
17996 struct rte_port *port = &ports[port_id];
17997 uint64_t port_offloads;
17998 uint64_t queue_offloads;
17999 uint16_t nb_rx_queues;
18003 printf("Rx Offloading Configuration of port %d :\n", port_id);
18005 port_offloads = port->dev_conf.rxmode.offloads;
18007 print_rx_offloads(port_offloads);
18010 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18014 nb_rx_queues = dev_info.nb_rx_queues;
18015 for (q = 0; q < nb_rx_queues; q++) {
18016 queue_offloads = port->rx_conf[q].offloads;
18017 printf(" Queue[%2d] :", q);
18018 print_rx_offloads(queue_offloads);
18024 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18025 .f = cmd_rx_offload_get_configuration_parsed,
18027 .help_str = "show port <port_id> rx_offload configuration",
18029 (void *)&cmd_rx_offload_get_configuration_show,
18030 (void *)&cmd_rx_offload_get_configuration_port,
18031 (void *)&cmd_rx_offload_get_configuration_port_id,
18032 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18033 (void *)&cmd_rx_offload_get_configuration_configuration,
18038 /* Enable/Disable a per port offloading */
18039 struct cmd_config_per_port_rx_offload_result {
18040 cmdline_fixed_string_t port;
18041 cmdline_fixed_string_t config;
18043 cmdline_fixed_string_t rx_offload;
18044 cmdline_fixed_string_t offload;
18045 cmdline_fixed_string_t on_off;
18048 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18049 TOKEN_STRING_INITIALIZER
18050 (struct cmd_config_per_port_rx_offload_result,
18052 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18053 TOKEN_STRING_INITIALIZER
18054 (struct cmd_config_per_port_rx_offload_result,
18056 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18057 TOKEN_NUM_INITIALIZER
18058 (struct cmd_config_per_port_rx_offload_result,
18060 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18061 TOKEN_STRING_INITIALIZER
18062 (struct cmd_config_per_port_rx_offload_result,
18063 rx_offload, "rx_offload");
18064 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18065 TOKEN_STRING_INITIALIZER
18066 (struct cmd_config_per_port_rx_offload_result,
18067 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18068 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18069 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18070 "crc_strip#scatter#timestamp#security#keep_crc");
18071 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18072 TOKEN_STRING_INITIALIZER
18073 (struct cmd_config_per_port_rx_offload_result,
18077 search_rx_offload(const char *name)
18079 uint64_t single_offload;
18080 const char *single_name;
18084 single_offload = 1;
18085 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18086 single_name = rte_eth_dev_rx_offload_name(single_offload);
18087 if (!strcasecmp(single_name, name)) {
18091 single_offload <<= 1;
18095 return single_offload;
18101 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18102 __attribute__((unused)) struct cmdline *cl,
18103 __attribute__((unused)) void *data)
18105 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18106 portid_t port_id = res->port_id;
18107 struct rte_eth_dev_info dev_info;
18108 struct rte_port *port = &ports[port_id];
18109 uint64_t single_offload;
18110 uint16_t nb_rx_queues;
18114 if (port->port_status != RTE_PORT_STOPPED) {
18115 printf("Error: Can't config offload when Port %d "
18116 "is not stopped\n", port_id);
18120 single_offload = search_rx_offload(res->offload);
18121 if (single_offload == 0) {
18122 printf("Unknown offload name: %s\n", res->offload);
18126 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18130 nb_rx_queues = dev_info.nb_rx_queues;
18131 if (!strcmp(res->on_off, "on")) {
18132 port->dev_conf.rxmode.offloads |= single_offload;
18133 for (q = 0; q < nb_rx_queues; q++)
18134 port->rx_conf[q].offloads |= single_offload;
18136 port->dev_conf.rxmode.offloads &= ~single_offload;
18137 for (q = 0; q < nb_rx_queues; q++)
18138 port->rx_conf[q].offloads &= ~single_offload;
18141 cmd_reconfig_device_queue(port_id, 1, 1);
18144 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18145 .f = cmd_config_per_port_rx_offload_parsed,
18147 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18148 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18149 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18150 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
18153 (void *)&cmd_config_per_port_rx_offload_result_port,
18154 (void *)&cmd_config_per_port_rx_offload_result_config,
18155 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18156 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18157 (void *)&cmd_config_per_port_rx_offload_result_offload,
18158 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18163 /* Enable/Disable a per queue offloading */
18164 struct cmd_config_per_queue_rx_offload_result {
18165 cmdline_fixed_string_t port;
18167 cmdline_fixed_string_t rxq;
18169 cmdline_fixed_string_t rx_offload;
18170 cmdline_fixed_string_t offload;
18171 cmdline_fixed_string_t on_off;
18174 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18175 TOKEN_STRING_INITIALIZER
18176 (struct cmd_config_per_queue_rx_offload_result,
18178 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18179 TOKEN_NUM_INITIALIZER
18180 (struct cmd_config_per_queue_rx_offload_result,
18182 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18183 TOKEN_STRING_INITIALIZER
18184 (struct cmd_config_per_queue_rx_offload_result,
18186 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18187 TOKEN_NUM_INITIALIZER
18188 (struct cmd_config_per_queue_rx_offload_result,
18190 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18191 TOKEN_STRING_INITIALIZER
18192 (struct cmd_config_per_queue_rx_offload_result,
18193 rx_offload, "rx_offload");
18194 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18195 TOKEN_STRING_INITIALIZER
18196 (struct cmd_config_per_queue_rx_offload_result,
18197 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18198 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18199 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18200 "crc_strip#scatter#timestamp#security#keep_crc");
18201 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18202 TOKEN_STRING_INITIALIZER
18203 (struct cmd_config_per_queue_rx_offload_result,
18207 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18208 __attribute__((unused)) struct cmdline *cl,
18209 __attribute__((unused)) void *data)
18211 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18212 struct rte_eth_dev_info dev_info;
18213 portid_t port_id = res->port_id;
18214 uint16_t queue_id = res->queue_id;
18215 struct rte_port *port = &ports[port_id];
18216 uint64_t single_offload;
18219 if (port->port_status != RTE_PORT_STOPPED) {
18220 printf("Error: Can't config offload when Port %d "
18221 "is not stopped\n", port_id);
18225 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18229 if (queue_id >= dev_info.nb_rx_queues) {
18230 printf("Error: input queue_id should be 0 ... "
18231 "%d\n", dev_info.nb_rx_queues - 1);
18235 single_offload = search_rx_offload(res->offload);
18236 if (single_offload == 0) {
18237 printf("Unknown offload name: %s\n", res->offload);
18241 if (!strcmp(res->on_off, "on"))
18242 port->rx_conf[queue_id].offloads |= single_offload;
18244 port->rx_conf[queue_id].offloads &= ~single_offload;
18246 cmd_reconfig_device_queue(port_id, 1, 1);
18249 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18250 .f = cmd_config_per_queue_rx_offload_parsed,
18252 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18253 "vlan_strip|ipv4_cksum|"
18254 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18255 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18256 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
18259 (void *)&cmd_config_per_queue_rx_offload_result_port,
18260 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18261 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18262 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18263 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18264 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18265 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18270 /* Get Tx offloads capabilities */
18271 struct cmd_tx_offload_get_capa_result {
18272 cmdline_fixed_string_t show;
18273 cmdline_fixed_string_t port;
18275 cmdline_fixed_string_t tx_offload;
18276 cmdline_fixed_string_t capabilities;
18279 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18280 TOKEN_STRING_INITIALIZER
18281 (struct cmd_tx_offload_get_capa_result,
18283 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18284 TOKEN_STRING_INITIALIZER
18285 (struct cmd_tx_offload_get_capa_result,
18287 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18288 TOKEN_NUM_INITIALIZER
18289 (struct cmd_tx_offload_get_capa_result,
18291 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18292 TOKEN_STRING_INITIALIZER
18293 (struct cmd_tx_offload_get_capa_result,
18294 tx_offload, "tx_offload");
18295 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18296 TOKEN_STRING_INITIALIZER
18297 (struct cmd_tx_offload_get_capa_result,
18298 capabilities, "capabilities");
18301 print_tx_offloads(uint64_t offloads)
18303 uint64_t single_offload;
18311 begin = __builtin_ctzll(offloads);
18312 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18314 single_offload = 1ULL << begin;
18315 for (bit = begin; bit < end; bit++) {
18316 if (offloads & single_offload)
18318 rte_eth_dev_tx_offload_name(single_offload));
18319 single_offload <<= 1;
18324 cmd_tx_offload_get_capa_parsed(
18325 void *parsed_result,
18326 __attribute__((unused)) struct cmdline *cl,
18327 __attribute__((unused)) void *data)
18329 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18330 struct rte_eth_dev_info dev_info;
18331 portid_t port_id = res->port_id;
18332 uint64_t queue_offloads;
18333 uint64_t port_offloads;
18336 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18340 queue_offloads = dev_info.tx_queue_offload_capa;
18341 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18343 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18344 printf(" Per Queue :");
18345 print_tx_offloads(queue_offloads);
18348 printf(" Per Port :");
18349 print_tx_offloads(port_offloads);
18353 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18354 .f = cmd_tx_offload_get_capa_parsed,
18356 .help_str = "show port <port_id> tx_offload capabilities",
18358 (void *)&cmd_tx_offload_get_capa_show,
18359 (void *)&cmd_tx_offload_get_capa_port,
18360 (void *)&cmd_tx_offload_get_capa_port_id,
18361 (void *)&cmd_tx_offload_get_capa_tx_offload,
18362 (void *)&cmd_tx_offload_get_capa_capabilities,
18367 /* Get Tx offloads configuration */
18368 struct cmd_tx_offload_get_configuration_result {
18369 cmdline_fixed_string_t show;
18370 cmdline_fixed_string_t port;
18372 cmdline_fixed_string_t tx_offload;
18373 cmdline_fixed_string_t configuration;
18376 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18377 TOKEN_STRING_INITIALIZER
18378 (struct cmd_tx_offload_get_configuration_result,
18380 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18381 TOKEN_STRING_INITIALIZER
18382 (struct cmd_tx_offload_get_configuration_result,
18384 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18385 TOKEN_NUM_INITIALIZER
18386 (struct cmd_tx_offload_get_configuration_result,
18388 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18389 TOKEN_STRING_INITIALIZER
18390 (struct cmd_tx_offload_get_configuration_result,
18391 tx_offload, "tx_offload");
18392 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18393 TOKEN_STRING_INITIALIZER
18394 (struct cmd_tx_offload_get_configuration_result,
18395 configuration, "configuration");
18398 cmd_tx_offload_get_configuration_parsed(
18399 void *parsed_result,
18400 __attribute__((unused)) struct cmdline *cl,
18401 __attribute__((unused)) void *data)
18403 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18404 struct rte_eth_dev_info dev_info;
18405 portid_t port_id = res->port_id;
18406 struct rte_port *port = &ports[port_id];
18407 uint64_t port_offloads;
18408 uint64_t queue_offloads;
18409 uint16_t nb_tx_queues;
18413 printf("Tx Offloading Configuration of port %d :\n", port_id);
18415 port_offloads = port->dev_conf.txmode.offloads;
18417 print_tx_offloads(port_offloads);
18420 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18424 nb_tx_queues = dev_info.nb_tx_queues;
18425 for (q = 0; q < nb_tx_queues; q++) {
18426 queue_offloads = port->tx_conf[q].offloads;
18427 printf(" Queue[%2d] :", q);
18428 print_tx_offloads(queue_offloads);
18434 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18435 .f = cmd_tx_offload_get_configuration_parsed,
18437 .help_str = "show port <port_id> tx_offload configuration",
18439 (void *)&cmd_tx_offload_get_configuration_show,
18440 (void *)&cmd_tx_offload_get_configuration_port,
18441 (void *)&cmd_tx_offload_get_configuration_port_id,
18442 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18443 (void *)&cmd_tx_offload_get_configuration_configuration,
18448 /* Enable/Disable a per port offloading */
18449 struct cmd_config_per_port_tx_offload_result {
18450 cmdline_fixed_string_t port;
18451 cmdline_fixed_string_t config;
18453 cmdline_fixed_string_t tx_offload;
18454 cmdline_fixed_string_t offload;
18455 cmdline_fixed_string_t on_off;
18458 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18459 TOKEN_STRING_INITIALIZER
18460 (struct cmd_config_per_port_tx_offload_result,
18462 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18463 TOKEN_STRING_INITIALIZER
18464 (struct cmd_config_per_port_tx_offload_result,
18466 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18467 TOKEN_NUM_INITIALIZER
18468 (struct cmd_config_per_port_tx_offload_result,
18470 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18471 TOKEN_STRING_INITIALIZER
18472 (struct cmd_config_per_port_tx_offload_result,
18473 tx_offload, "tx_offload");
18474 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18475 TOKEN_STRING_INITIALIZER
18476 (struct cmd_config_per_port_tx_offload_result,
18477 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18478 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18479 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18480 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18481 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18483 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18484 TOKEN_STRING_INITIALIZER
18485 (struct cmd_config_per_port_tx_offload_result,
18489 search_tx_offload(const char *name)
18491 uint64_t single_offload;
18492 const char *single_name;
18496 single_offload = 1;
18497 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18498 single_name = rte_eth_dev_tx_offload_name(single_offload);
18499 if (single_name == NULL)
18501 if (!strcasecmp(single_name, name)) {
18504 } else if (!strcasecmp(single_name, "UNKNOWN"))
18506 single_offload <<= 1;
18510 return single_offload;
18516 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18517 __attribute__((unused)) struct cmdline *cl,
18518 __attribute__((unused)) void *data)
18520 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18521 portid_t port_id = res->port_id;
18522 struct rte_eth_dev_info dev_info;
18523 struct rte_port *port = &ports[port_id];
18524 uint64_t single_offload;
18525 uint16_t nb_tx_queues;
18529 if (port->port_status != RTE_PORT_STOPPED) {
18530 printf("Error: Can't config offload when Port %d "
18531 "is not stopped\n", port_id);
18535 single_offload = search_tx_offload(res->offload);
18536 if (single_offload == 0) {
18537 printf("Unknown offload name: %s\n", res->offload);
18541 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18545 nb_tx_queues = dev_info.nb_tx_queues;
18546 if (!strcmp(res->on_off, "on")) {
18547 port->dev_conf.txmode.offloads |= single_offload;
18548 for (q = 0; q < nb_tx_queues; q++)
18549 port->tx_conf[q].offloads |= single_offload;
18551 port->dev_conf.txmode.offloads &= ~single_offload;
18552 for (q = 0; q < nb_tx_queues; q++)
18553 port->tx_conf[q].offloads &= ~single_offload;
18556 cmd_reconfig_device_queue(port_id, 1, 1);
18559 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18560 .f = cmd_config_per_port_tx_offload_parsed,
18562 .help_str = "port config <port_id> tx_offload "
18563 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18564 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18565 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18566 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18567 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18568 "match_metadata on|off",
18570 (void *)&cmd_config_per_port_tx_offload_result_port,
18571 (void *)&cmd_config_per_port_tx_offload_result_config,
18572 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18573 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18574 (void *)&cmd_config_per_port_tx_offload_result_offload,
18575 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18580 /* Enable/Disable a per queue offloading */
18581 struct cmd_config_per_queue_tx_offload_result {
18582 cmdline_fixed_string_t port;
18584 cmdline_fixed_string_t txq;
18586 cmdline_fixed_string_t tx_offload;
18587 cmdline_fixed_string_t offload;
18588 cmdline_fixed_string_t on_off;
18591 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18592 TOKEN_STRING_INITIALIZER
18593 (struct cmd_config_per_queue_tx_offload_result,
18595 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18596 TOKEN_NUM_INITIALIZER
18597 (struct cmd_config_per_queue_tx_offload_result,
18599 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18600 TOKEN_STRING_INITIALIZER
18601 (struct cmd_config_per_queue_tx_offload_result,
18603 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18604 TOKEN_NUM_INITIALIZER
18605 (struct cmd_config_per_queue_tx_offload_result,
18607 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18608 TOKEN_STRING_INITIALIZER
18609 (struct cmd_config_per_queue_tx_offload_result,
18610 tx_offload, "tx_offload");
18611 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18612 TOKEN_STRING_INITIALIZER
18613 (struct cmd_config_per_queue_tx_offload_result,
18614 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18615 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18616 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18617 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18618 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18619 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18620 TOKEN_STRING_INITIALIZER
18621 (struct cmd_config_per_queue_tx_offload_result,
18625 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18626 __attribute__((unused)) struct cmdline *cl,
18627 __attribute__((unused)) void *data)
18629 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18630 struct rte_eth_dev_info dev_info;
18631 portid_t port_id = res->port_id;
18632 uint16_t queue_id = res->queue_id;
18633 struct rte_port *port = &ports[port_id];
18634 uint64_t single_offload;
18637 if (port->port_status != RTE_PORT_STOPPED) {
18638 printf("Error: Can't config offload when Port %d "
18639 "is not stopped\n", port_id);
18643 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18647 if (queue_id >= dev_info.nb_tx_queues) {
18648 printf("Error: input queue_id should be 0 ... "
18649 "%d\n", dev_info.nb_tx_queues - 1);
18653 single_offload = search_tx_offload(res->offload);
18654 if (single_offload == 0) {
18655 printf("Unknown offload name: %s\n", res->offload);
18659 if (!strcmp(res->on_off, "on"))
18660 port->tx_conf[queue_id].offloads |= single_offload;
18662 port->tx_conf[queue_id].offloads &= ~single_offload;
18664 cmd_reconfig_device_queue(port_id, 1, 1);
18667 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18668 .f = cmd_config_per_queue_tx_offload_parsed,
18670 .help_str = "port <port_id> txq <queue_id> tx_offload "
18671 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18672 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18673 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18674 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18675 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18678 (void *)&cmd_config_per_queue_tx_offload_result_port,
18679 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18680 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18681 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18682 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18683 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18684 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18689 /* *** configure tx_metadata for specific port *** */
18690 struct cmd_config_tx_metadata_specific_result {
18691 cmdline_fixed_string_t port;
18692 cmdline_fixed_string_t keyword;
18694 cmdline_fixed_string_t item;
18699 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18700 __attribute__((unused)) struct cmdline *cl,
18701 __attribute__((unused)) void *data)
18703 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18705 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18707 ports[res->port_id].tx_metadata = rte_cpu_to_be_32(res->value);
18708 /* Add/remove callback to insert valid metadata in every Tx packet. */
18709 if (ports[res->port_id].tx_metadata)
18710 add_tx_md_callback(res->port_id);
18712 remove_tx_md_callback(res->port_id);
18715 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18716 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18718 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18719 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18720 keyword, "config");
18721 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18722 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18724 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18725 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18726 item, "tx_metadata");
18727 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18728 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18731 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18732 .f = cmd_config_tx_metadata_specific_parsed,
18734 .help_str = "port config <port_id> tx_metadata <value>",
18736 (void *)&cmd_config_tx_metadata_specific_port,
18737 (void *)&cmd_config_tx_metadata_specific_keyword,
18738 (void *)&cmd_config_tx_metadata_specific_id,
18739 (void *)&cmd_config_tx_metadata_specific_item,
18740 (void *)&cmd_config_tx_metadata_specific_value,
18745 /* *** display tx_metadata per port configuration *** */
18746 struct cmd_show_tx_metadata_result {
18747 cmdline_fixed_string_t cmd_show;
18748 cmdline_fixed_string_t cmd_port;
18749 cmdline_fixed_string_t cmd_keyword;
18754 cmd_show_tx_metadata_parsed(void *parsed_result,
18755 __attribute__((unused)) struct cmdline *cl,
18756 __attribute__((unused)) void *data)
18758 struct cmd_show_tx_metadata_result *res = parsed_result;
18760 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18761 printf("invalid port id %u\n", res->cmd_pid);
18764 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18765 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18766 rte_be_to_cpu_32(ports[res->cmd_pid].tx_metadata));
18770 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18771 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18773 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18774 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18776 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18777 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18779 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18780 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18781 cmd_keyword, "tx_metadata");
18783 cmdline_parse_inst_t cmd_show_tx_metadata = {
18784 .f = cmd_show_tx_metadata_parsed,
18786 .help_str = "show port <port_id> tx_metadata",
18788 (void *)&cmd_show_tx_metadata_show,
18789 (void *)&cmd_show_tx_metadata_port,
18790 (void *)&cmd_show_tx_metadata_pid,
18791 (void *)&cmd_show_tx_metadata_keyword,
18796 /* ******************************************************************************** */
18798 /* list of instructions */
18799 cmdline_parse_ctx_t main_ctx[] = {
18800 (cmdline_parse_inst_t *)&cmd_help_brief,
18801 (cmdline_parse_inst_t *)&cmd_help_long,
18802 (cmdline_parse_inst_t *)&cmd_quit,
18803 (cmdline_parse_inst_t *)&cmd_load_from_file,
18804 (cmdline_parse_inst_t *)&cmd_showport,
18805 (cmdline_parse_inst_t *)&cmd_showqueue,
18806 (cmdline_parse_inst_t *)&cmd_showportall,
18807 (cmdline_parse_inst_t *)&cmd_showdevice,
18808 (cmdline_parse_inst_t *)&cmd_showcfg,
18809 (cmdline_parse_inst_t *)&cmd_showfwdall,
18810 (cmdline_parse_inst_t *)&cmd_start,
18811 (cmdline_parse_inst_t *)&cmd_start_tx_first,
18812 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
18813 (cmdline_parse_inst_t *)&cmd_set_link_up,
18814 (cmdline_parse_inst_t *)&cmd_set_link_down,
18815 (cmdline_parse_inst_t *)&cmd_reset,
18816 (cmdline_parse_inst_t *)&cmd_set_numbers,
18817 (cmdline_parse_inst_t *)&cmd_set_log,
18818 (cmdline_parse_inst_t *)&cmd_set_txpkts,
18819 (cmdline_parse_inst_t *)&cmd_set_txsplit,
18820 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
18821 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
18822 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
18823 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
18824 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
18825 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
18826 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
18827 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
18828 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
18829 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
18830 (cmdline_parse_inst_t *)&cmd_set_link_check,
18831 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
18832 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
18833 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
18834 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
18835 #ifdef RTE_LIBRTE_PMD_BOND
18836 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
18837 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
18838 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
18839 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
18840 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
18841 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
18842 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
18843 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
18844 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
18845 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
18846 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
18848 (cmdline_parse_inst_t *)&cmd_vlan_offload,
18849 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
18850 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
18851 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
18852 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
18853 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
18854 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
18855 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
18856 (cmdline_parse_inst_t *)&cmd_csum_set,
18857 (cmdline_parse_inst_t *)&cmd_csum_show,
18858 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
18859 (cmdline_parse_inst_t *)&cmd_tso_set,
18860 (cmdline_parse_inst_t *)&cmd_tso_show,
18861 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
18862 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
18863 (cmdline_parse_inst_t *)&cmd_gro_enable,
18864 (cmdline_parse_inst_t *)&cmd_gro_flush,
18865 (cmdline_parse_inst_t *)&cmd_gro_show,
18866 (cmdline_parse_inst_t *)&cmd_gso_enable,
18867 (cmdline_parse_inst_t *)&cmd_gso_size,
18868 (cmdline_parse_inst_t *)&cmd_gso_show,
18869 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
18870 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
18871 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
18872 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
18873 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
18874 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
18875 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
18876 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
18877 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
18878 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
18879 (cmdline_parse_inst_t *)&cmd_config_dcb,
18880 (cmdline_parse_inst_t *)&cmd_read_reg,
18881 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
18882 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
18883 (cmdline_parse_inst_t *)&cmd_write_reg,
18884 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
18885 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
18886 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
18887 (cmdline_parse_inst_t *)&cmd_stop,
18888 (cmdline_parse_inst_t *)&cmd_mac_addr,
18889 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
18890 (cmdline_parse_inst_t *)&cmd_set_qmap,
18891 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
18892 (cmdline_parse_inst_t *)&cmd_operate_port,
18893 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
18894 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
18895 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
18896 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
18897 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
18898 (cmdline_parse_inst_t *)&cmd_config_speed_all,
18899 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
18900 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
18901 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
18902 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
18903 (cmdline_parse_inst_t *)&cmd_config_mtu,
18904 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
18905 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
18906 (cmdline_parse_inst_t *)&cmd_config_rss,
18907 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
18908 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
18909 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
18910 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
18911 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
18912 (cmdline_parse_inst_t *)&cmd_showport_reta,
18913 (cmdline_parse_inst_t *)&cmd_config_burst,
18914 (cmdline_parse_inst_t *)&cmd_config_thresh,
18915 (cmdline_parse_inst_t *)&cmd_config_threshold,
18916 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
18917 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
18918 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
18919 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
18920 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
18921 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
18922 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
18923 (cmdline_parse_inst_t *)&cmd_global_config,
18924 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
18925 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
18926 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
18927 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
18928 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
18929 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
18930 (cmdline_parse_inst_t *)&cmd_dump,
18931 (cmdline_parse_inst_t *)&cmd_dump_one,
18932 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
18933 (cmdline_parse_inst_t *)&cmd_syn_filter,
18934 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
18935 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
18936 (cmdline_parse_inst_t *)&cmd_flex_filter,
18937 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
18938 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
18939 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
18940 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
18941 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
18942 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
18943 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
18944 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
18945 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
18946 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
18947 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
18948 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
18949 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
18950 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
18951 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
18952 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
18953 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
18954 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
18955 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
18956 (cmdline_parse_inst_t *)&cmd_flow,
18957 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
18958 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
18959 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
18960 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
18961 (cmdline_parse_inst_t *)&cmd_create_port_meter,
18962 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
18963 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
18964 (cmdline_parse_inst_t *)&cmd_del_port_meter,
18965 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
18966 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
18967 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
18968 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
18969 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
18970 (cmdline_parse_inst_t *)&cmd_mcast_addr,
18971 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
18972 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
18973 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
18974 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
18975 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
18976 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
18977 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
18978 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
18979 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
18980 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
18981 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
18982 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
18983 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
18984 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
18985 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
18986 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
18987 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
18988 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
18989 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
18990 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
18991 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
18992 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
18993 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
18994 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
18995 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
18996 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
18997 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
18998 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
18999 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19000 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19001 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19002 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19003 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19004 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19005 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19006 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
19007 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
19009 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19010 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19011 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19012 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19013 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19014 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19015 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19016 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19017 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19018 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19019 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19020 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19021 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19022 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19023 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19024 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19025 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19026 (cmdline_parse_inst_t *)&cmd_ddp_add,
19027 (cmdline_parse_inst_t *)&cmd_ddp_del,
19028 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19029 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19030 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19031 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19032 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19033 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19034 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19035 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19036 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19037 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19039 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19040 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19041 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19042 (cmdline_parse_inst_t *)&cmd_queue_region,
19043 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19044 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19045 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19046 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19047 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19048 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19049 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19050 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19051 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19052 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19053 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19054 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19055 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19056 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19057 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19058 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19059 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19060 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19061 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19062 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19063 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19064 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19065 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19066 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19067 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19068 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19069 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19070 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19071 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19072 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19073 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19074 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19075 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19076 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19077 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19078 #ifdef RTE_LIBRTE_BPF
19079 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19080 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19082 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19083 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19084 (cmdline_parse_inst_t *)&cmd_set_raw,
19088 /* read cmdline commands from file */
19090 cmdline_read_from_file(const char *filename)
19092 struct cmdline *cl;
19094 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19096 printf("Failed to create file based cmdline context: %s\n",
19101 cmdline_interact(cl);
19106 printf("Read CLI commands from %s\n", filename);
19109 /* prompt function, called from main on MASTER lcore */
19113 /* initialize non-constant commands */
19114 cmd_set_fwd_mode_init();
19115 cmd_set_fwd_retry_mode_init();
19117 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19118 if (testpmd_cl == NULL)
19120 cmdline_interact(testpmd_cl);
19121 cmdline_stdin_exit(testpmd_cl);
19127 if (testpmd_cl != NULL)
19128 cmdline_quit(testpmd_cl);
19132 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19134 if (id == (portid_t)RTE_PORT_ALL) {
19137 RTE_ETH_FOREACH_DEV(pid) {
19138 /* check if need_reconfig has been set to 1 */
19139 if (ports[pid].need_reconfig == 0)
19140 ports[pid].need_reconfig = dev;
19141 /* check if need_reconfig_queues has been set to 1 */
19142 if (ports[pid].need_reconfig_queues == 0)
19143 ports[pid].need_reconfig_queues = queue;
19145 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19146 /* check if need_reconfig has been set to 1 */
19147 if (ports[id].need_reconfig == 0)
19148 ports[id].need_reconfig = dev;
19149 /* check if need_reconfig_queues has been set to 1 */
19150 if (ports[id].need_reconfig_queues == 0)
19151 ports[id].need_reconfig_queues = queue;