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;
2185 if (!strcmp(res->value, "all"))
2186 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2187 ETH_RSS_UDP | ETH_RSS_SCTP |
2189 else if (!strcmp(res->value, "ip"))
2190 rss_conf.rss_hf = ETH_RSS_IP;
2191 else if (!strcmp(res->value, "udp"))
2192 rss_conf.rss_hf = ETH_RSS_UDP;
2193 else if (!strcmp(res->value, "tcp"))
2194 rss_conf.rss_hf = ETH_RSS_TCP;
2195 else if (!strcmp(res->value, "sctp"))
2196 rss_conf.rss_hf = ETH_RSS_SCTP;
2197 else if (!strcmp(res->value, "ether"))
2198 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2199 else if (!strcmp(res->value, "port"))
2200 rss_conf.rss_hf = ETH_RSS_PORT;
2201 else if (!strcmp(res->value, "vxlan"))
2202 rss_conf.rss_hf = ETH_RSS_VXLAN;
2203 else if (!strcmp(res->value, "geneve"))
2204 rss_conf.rss_hf = ETH_RSS_GENEVE;
2205 else if (!strcmp(res->value, "nvgre"))
2206 rss_conf.rss_hf = ETH_RSS_NVGRE;
2207 else if (!strcmp(res->value, "none"))
2208 rss_conf.rss_hf = 0;
2209 else if (!strcmp(res->value, "default"))
2211 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2212 atoi(res->value) < 64)
2213 rss_conf.rss_hf = 1ULL << atoi(res->value);
2215 printf("Unknown parameter\n");
2218 rss_conf.rss_key = NULL;
2219 /* Update global configuration for RSS types. */
2220 RTE_ETH_FOREACH_DEV(i) {
2221 struct rte_eth_rss_conf local_rss_conf;
2223 rte_eth_dev_info_get(i, &dev_info);
2225 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2227 local_rss_conf = rss_conf;
2228 local_rss_conf.rss_hf = rss_conf.rss_hf &
2229 dev_info.flow_type_rss_offloads;
2230 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2231 printf("Port %u modified RSS hash function based on hardware support,"
2232 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2233 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2235 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2238 printf("Configuration of RSS hash at ethernet port %d "
2239 "failed with error (%d): %s.\n",
2240 i, -diag, strerror(-diag));
2243 if (all_updated && !use_default)
2244 rss_hf = rss_conf.rss_hf;
2247 cmdline_parse_token_string_t cmd_config_rss_port =
2248 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2249 cmdline_parse_token_string_t cmd_config_rss_keyword =
2250 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2251 cmdline_parse_token_string_t cmd_config_rss_all =
2252 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2253 cmdline_parse_token_string_t cmd_config_rss_name =
2254 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2255 cmdline_parse_token_string_t cmd_config_rss_value =
2256 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2258 cmdline_parse_inst_t cmd_config_rss = {
2259 .f = cmd_config_rss_parsed,
2261 .help_str = "port config all rss "
2262 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>",
2264 (void *)&cmd_config_rss_port,
2265 (void *)&cmd_config_rss_keyword,
2266 (void *)&cmd_config_rss_all,
2267 (void *)&cmd_config_rss_name,
2268 (void *)&cmd_config_rss_value,
2273 /* *** configure rss hash key *** */
2274 struct cmd_config_rss_hash_key {
2275 cmdline_fixed_string_t port;
2276 cmdline_fixed_string_t config;
2278 cmdline_fixed_string_t rss_hash_key;
2279 cmdline_fixed_string_t rss_type;
2280 cmdline_fixed_string_t key;
2284 hexa_digit_to_value(char hexa_digit)
2286 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2287 return (uint8_t) (hexa_digit - '0');
2288 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2289 return (uint8_t) ((hexa_digit - 'a') + 10);
2290 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2291 return (uint8_t) ((hexa_digit - 'A') + 10);
2292 /* Invalid hexa digit */
2297 parse_and_check_key_hexa_digit(char *key, int idx)
2301 hexa_v = hexa_digit_to_value(key[idx]);
2303 printf("invalid key: character %c at position %d is not a "
2304 "valid hexa digit\n", key[idx], idx);
2309 cmd_config_rss_hash_key_parsed(void *parsed_result,
2310 __attribute__((unused)) struct cmdline *cl,
2311 __attribute__((unused)) void *data)
2313 struct cmd_config_rss_hash_key *res = parsed_result;
2314 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2318 struct rte_eth_dev_info dev_info;
2319 uint8_t hash_key_size;
2322 rte_eth_dev_info_get(res->port_id, &dev_info);
2323 if (dev_info.hash_key_size > 0 &&
2324 dev_info.hash_key_size <= sizeof(hash_key))
2325 hash_key_size = dev_info.hash_key_size;
2327 printf("dev_info did not provide a valid hash key size\n");
2330 /* Check the length of the RSS hash key */
2331 key_len = strlen(res->key);
2332 if (key_len != (hash_key_size * 2)) {
2333 printf("key length: %d invalid - key must be a string of %d"
2334 " hexa-decimal numbers\n",
2335 (int) key_len, hash_key_size * 2);
2338 /* Translate RSS hash key into binary representation */
2339 for (i = 0; i < hash_key_size; i++) {
2340 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2343 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2346 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2348 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2352 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2353 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2354 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2355 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2357 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2358 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2359 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2360 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2361 rss_hash_key, "rss-hash-key");
2362 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2363 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2364 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2365 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2366 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2367 "ipv6-tcp-ex#ipv6-udp-ex");
2368 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2369 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2371 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2372 .f = cmd_config_rss_hash_key_parsed,
2374 .help_str = "port config <port_id> rss-hash-key "
2375 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2376 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2377 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2378 "<string of hex digits (variable length, NIC dependent)>",
2380 (void *)&cmd_config_rss_hash_key_port,
2381 (void *)&cmd_config_rss_hash_key_config,
2382 (void *)&cmd_config_rss_hash_key_port_id,
2383 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2384 (void *)&cmd_config_rss_hash_key_rss_type,
2385 (void *)&cmd_config_rss_hash_key_value,
2390 /* *** configure port rxq/txq ring size *** */
2391 struct cmd_config_rxtx_ring_size {
2392 cmdline_fixed_string_t port;
2393 cmdline_fixed_string_t config;
2395 cmdline_fixed_string_t rxtxq;
2397 cmdline_fixed_string_t rsize;
2402 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2403 __attribute__((unused)) struct cmdline *cl,
2404 __attribute__((unused)) void *data)
2406 struct cmd_config_rxtx_ring_size *res = parsed_result;
2407 struct rte_port *port;
2410 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2413 if (res->portid == (portid_t)RTE_PORT_ALL) {
2414 printf("Invalid port id\n");
2418 port = &ports[res->portid];
2420 if (!strcmp(res->rxtxq, "rxq"))
2422 else if (!strcmp(res->rxtxq, "txq"))
2425 printf("Unknown parameter\n");
2429 if (isrx && rx_queue_id_is_invalid(res->qid))
2431 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2434 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2435 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2441 port->nb_rx_desc[res->qid] = res->size;
2443 port->nb_tx_desc[res->qid] = res->size;
2445 cmd_reconfig_device_queue(res->portid, 0, 1);
2448 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2449 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2451 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2452 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2454 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2455 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2457 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2458 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2460 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2461 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2463 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2464 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2465 rsize, "ring_size");
2466 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2467 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2470 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2471 .f = cmd_config_rxtx_ring_size_parsed,
2473 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2475 (void *)&cmd_config_rxtx_ring_size_port,
2476 (void *)&cmd_config_rxtx_ring_size_config,
2477 (void *)&cmd_config_rxtx_ring_size_portid,
2478 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2479 (void *)&cmd_config_rxtx_ring_size_qid,
2480 (void *)&cmd_config_rxtx_ring_size_rsize,
2481 (void *)&cmd_config_rxtx_ring_size_size,
2486 /* *** configure port rxq/txq start/stop *** */
2487 struct cmd_config_rxtx_queue {
2488 cmdline_fixed_string_t port;
2490 cmdline_fixed_string_t rxtxq;
2492 cmdline_fixed_string_t opname;
2496 cmd_config_rxtx_queue_parsed(void *parsed_result,
2497 __attribute__((unused)) struct cmdline *cl,
2498 __attribute__((unused)) void *data)
2500 struct cmd_config_rxtx_queue *res = parsed_result;
2505 if (test_done == 0) {
2506 printf("Please stop forwarding first\n");
2510 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2513 if (port_is_started(res->portid) != 1) {
2514 printf("Please start port %u first\n", res->portid);
2518 if (!strcmp(res->rxtxq, "rxq"))
2520 else if (!strcmp(res->rxtxq, "txq"))
2523 printf("Unknown parameter\n");
2527 if (isrx && rx_queue_id_is_invalid(res->qid))
2529 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2532 if (!strcmp(res->opname, "start"))
2534 else if (!strcmp(res->opname, "stop"))
2537 printf("Unknown parameter\n");
2541 if (isstart && isrx)
2542 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2543 else if (!isstart && isrx)
2544 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2545 else if (isstart && !isrx)
2546 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2548 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2550 if (ret == -ENOTSUP)
2551 printf("Function not supported in PMD driver\n");
2554 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2555 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2556 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2557 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2558 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2559 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2560 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2561 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2562 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2563 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2566 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2567 .f = cmd_config_rxtx_queue_parsed,
2569 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2571 (void *)&cmd_config_rxtx_queue_port,
2572 (void *)&cmd_config_rxtx_queue_portid,
2573 (void *)&cmd_config_rxtx_queue_rxtxq,
2574 (void *)&cmd_config_rxtx_queue_qid,
2575 (void *)&cmd_config_rxtx_queue_opname,
2580 /* *** configure port rxq/txq deferred start on/off *** */
2581 struct cmd_config_deferred_start_rxtx_queue {
2582 cmdline_fixed_string_t port;
2584 cmdline_fixed_string_t rxtxq;
2586 cmdline_fixed_string_t opname;
2587 cmdline_fixed_string_t state;
2591 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2592 __attribute__((unused)) struct cmdline *cl,
2593 __attribute__((unused)) void *data)
2595 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2596 struct rte_port *port;
2599 uint8_t needreconfig = 0;
2601 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2604 if (port_is_started(res->port_id) != 0) {
2605 printf("Please stop port %u first\n", res->port_id);
2609 port = &ports[res->port_id];
2611 isrx = !strcmp(res->rxtxq, "rxq");
2613 if (isrx && rx_queue_id_is_invalid(res->qid))
2615 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2618 ison = !strcmp(res->state, "on");
2620 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2621 port->rx_conf[res->qid].rx_deferred_start = ison;
2623 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2624 port->tx_conf[res->qid].tx_deferred_start = ison;
2629 cmd_reconfig_device_queue(res->port_id, 0, 1);
2632 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2633 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2635 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2636 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2638 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2639 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2641 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2642 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2644 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2645 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2646 opname, "deferred_start");
2647 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2648 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2651 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2652 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2654 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2656 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2657 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2658 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2659 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2660 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2661 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2666 /* *** configure port rxq/txq setup *** */
2667 struct cmd_setup_rxtx_queue {
2668 cmdline_fixed_string_t port;
2670 cmdline_fixed_string_t rxtxq;
2672 cmdline_fixed_string_t setup;
2675 /* Common CLI fields for queue setup */
2676 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2677 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2678 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2679 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2680 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2681 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2682 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2683 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2684 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2685 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2688 cmd_setup_rxtx_queue_parsed(
2689 void *parsed_result,
2690 __attribute__((unused)) struct cmdline *cl,
2691 __attribute__((unused)) void *data)
2693 struct cmd_setup_rxtx_queue *res = parsed_result;
2694 struct rte_port *port;
2695 struct rte_mempool *mp;
2696 unsigned int socket_id;
2700 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2703 if (res->portid == (portid_t)RTE_PORT_ALL) {
2704 printf("Invalid port id\n");
2708 if (!strcmp(res->rxtxq, "rxq"))
2710 else if (!strcmp(res->rxtxq, "txq"))
2713 printf("Unknown parameter\n");
2717 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2718 printf("Invalid rx queue\n");
2720 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2721 printf("Invalid tx queue\n");
2725 port = &ports[res->portid];
2727 socket_id = rxring_numa[res->portid];
2728 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2729 socket_id = port->socket_id;
2731 mp = mbuf_pool_find(socket_id);
2733 printf("Failed to setup RX queue: "
2734 "No mempool allocation"
2735 " on the socket %d\n",
2736 rxring_numa[res->portid]);
2739 ret = rte_eth_rx_queue_setup(res->portid,
2741 port->nb_rx_desc[res->qid],
2743 &port->rx_conf[res->qid],
2746 printf("Failed to setup RX queue\n");
2748 socket_id = txring_numa[res->portid];
2749 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2750 socket_id = port->socket_id;
2752 ret = rte_eth_tx_queue_setup(res->portid,
2754 port->nb_tx_desc[res->qid],
2756 &port->tx_conf[res->qid]);
2758 printf("Failed to setup TX queue\n");
2762 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2763 .f = cmd_setup_rxtx_queue_parsed,
2765 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2767 (void *)&cmd_setup_rxtx_queue_port,
2768 (void *)&cmd_setup_rxtx_queue_portid,
2769 (void *)&cmd_setup_rxtx_queue_rxtxq,
2770 (void *)&cmd_setup_rxtx_queue_qid,
2771 (void *)&cmd_setup_rxtx_queue_setup,
2777 /* *** Configure RSS RETA *** */
2778 struct cmd_config_rss_reta {
2779 cmdline_fixed_string_t port;
2780 cmdline_fixed_string_t keyword;
2782 cmdline_fixed_string_t name;
2783 cmdline_fixed_string_t list_name;
2784 cmdline_fixed_string_t list_of_items;
2788 parse_reta_config(const char *str,
2789 struct rte_eth_rss_reta_entry64 *reta_conf,
2790 uint16_t nb_entries)
2794 uint16_t hash_index, idx, shift;
2797 const char *p, *p0 = str;
2804 unsigned long int_fld[_NUM_FLD];
2805 char *str_fld[_NUM_FLD];
2807 while ((p = strchr(p0,'(')) != NULL) {
2809 if((p0 = strchr(p,')')) == NULL)
2813 if(size >= sizeof(s))
2816 snprintf(s, sizeof(s), "%.*s", size, p);
2817 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2819 for (i = 0; i < _NUM_FLD; i++) {
2821 int_fld[i] = strtoul(str_fld[i], &end, 0);
2822 if (errno != 0 || end == str_fld[i] ||
2827 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2828 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2830 if (hash_index >= nb_entries) {
2831 printf("Invalid RETA hash index=%d\n", hash_index);
2835 idx = hash_index / RTE_RETA_GROUP_SIZE;
2836 shift = hash_index % RTE_RETA_GROUP_SIZE;
2837 reta_conf[idx].mask |= (1ULL << shift);
2838 reta_conf[idx].reta[shift] = nb_queue;
2845 cmd_set_rss_reta_parsed(void *parsed_result,
2846 __attribute__((unused)) struct cmdline *cl,
2847 __attribute__((unused)) void *data)
2850 struct rte_eth_dev_info dev_info;
2851 struct rte_eth_rss_reta_entry64 reta_conf[8];
2852 struct cmd_config_rss_reta *res = parsed_result;
2854 rte_eth_dev_info_get(res->port_id, &dev_info);
2855 if (dev_info.reta_size == 0) {
2856 printf("Redirection table size is 0 which is "
2857 "invalid for RSS\n");
2860 printf("The reta size of port %d is %u\n",
2861 res->port_id, dev_info.reta_size);
2862 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2863 printf("Currently do not support more than %u entries of "
2864 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2868 memset(reta_conf, 0, sizeof(reta_conf));
2869 if (!strcmp(res->list_name, "reta")) {
2870 if (parse_reta_config(res->list_of_items, reta_conf,
2871 dev_info.reta_size)) {
2872 printf("Invalid RSS Redirection Table "
2873 "config entered\n");
2876 ret = rte_eth_dev_rss_reta_update(res->port_id,
2877 reta_conf, dev_info.reta_size);
2879 printf("Bad redirection table parameter, "
2880 "return code = %d \n", ret);
2884 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2885 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2886 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2887 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2888 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2889 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2890 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2891 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2892 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2893 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2894 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2895 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2897 cmdline_parse_inst_t cmd_config_rss_reta = {
2898 .f = cmd_set_rss_reta_parsed,
2900 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2902 (void *)&cmd_config_rss_reta_port,
2903 (void *)&cmd_config_rss_reta_keyword,
2904 (void *)&cmd_config_rss_reta_port_id,
2905 (void *)&cmd_config_rss_reta_name,
2906 (void *)&cmd_config_rss_reta_list_name,
2907 (void *)&cmd_config_rss_reta_list_of_items,
2912 /* *** SHOW PORT RETA INFO *** */
2913 struct cmd_showport_reta {
2914 cmdline_fixed_string_t show;
2915 cmdline_fixed_string_t port;
2917 cmdline_fixed_string_t rss;
2918 cmdline_fixed_string_t reta;
2920 cmdline_fixed_string_t list_of_items;
2924 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2925 uint16_t nb_entries,
2929 const char *p, *p0 = str;
2934 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2935 RTE_RETA_GROUP_SIZE;
2938 p = strchr(p0, '(');
2942 p0 = strchr(p, ')');
2946 if (size >= sizeof(s)) {
2947 printf("The string size exceeds the internal buffer size\n");
2950 snprintf(s, sizeof(s), "%.*s", size, p);
2951 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2952 if (ret <= 0 || ret != num) {
2953 printf("The bits of masks do not match the number of "
2954 "reta entries: %u\n", num);
2957 for (i = 0; i < ret; i++)
2958 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2964 cmd_showport_reta_parsed(void *parsed_result,
2965 __attribute__((unused)) struct cmdline *cl,
2966 __attribute__((unused)) void *data)
2968 struct cmd_showport_reta *res = parsed_result;
2969 struct rte_eth_rss_reta_entry64 reta_conf[8];
2970 struct rte_eth_dev_info dev_info;
2971 uint16_t max_reta_size;
2973 rte_eth_dev_info_get(res->port_id, &dev_info);
2974 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2975 if (res->size == 0 || res->size > max_reta_size) {
2976 printf("Invalid redirection table size: %u (1-%u)\n",
2977 res->size, max_reta_size);
2981 memset(reta_conf, 0, sizeof(reta_conf));
2982 if (showport_parse_reta_config(reta_conf, res->size,
2983 res->list_of_items) < 0) {
2984 printf("Invalid string: %s for reta masks\n",
2985 res->list_of_items);
2988 port_rss_reta_info(res->port_id, reta_conf, res->size);
2991 cmdline_parse_token_string_t cmd_showport_reta_show =
2992 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2993 cmdline_parse_token_string_t cmd_showport_reta_port =
2994 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2995 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2996 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2997 cmdline_parse_token_string_t cmd_showport_reta_rss =
2998 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2999 cmdline_parse_token_string_t cmd_showport_reta_reta =
3000 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3001 cmdline_parse_token_num_t cmd_showport_reta_size =
3002 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3003 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3004 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3005 list_of_items, NULL);
3007 cmdline_parse_inst_t cmd_showport_reta = {
3008 .f = cmd_showport_reta_parsed,
3010 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3012 (void *)&cmd_showport_reta_show,
3013 (void *)&cmd_showport_reta_port,
3014 (void *)&cmd_showport_reta_port_id,
3015 (void *)&cmd_showport_reta_rss,
3016 (void *)&cmd_showport_reta_reta,
3017 (void *)&cmd_showport_reta_size,
3018 (void *)&cmd_showport_reta_list_of_items,
3023 /* *** Show RSS hash configuration *** */
3024 struct cmd_showport_rss_hash {
3025 cmdline_fixed_string_t show;
3026 cmdline_fixed_string_t port;
3028 cmdline_fixed_string_t rss_hash;
3029 cmdline_fixed_string_t rss_type;
3030 cmdline_fixed_string_t key; /* optional argument */
3033 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3034 __attribute__((unused)) struct cmdline *cl,
3037 struct cmd_showport_rss_hash *res = parsed_result;
3039 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3042 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3043 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3044 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3045 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3046 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3047 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3048 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3049 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3051 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3052 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3054 cmdline_parse_inst_t cmd_showport_rss_hash = {
3055 .f = cmd_showport_rss_hash_parsed,
3057 .help_str = "show port <port_id> rss-hash",
3059 (void *)&cmd_showport_rss_hash_show,
3060 (void *)&cmd_showport_rss_hash_port,
3061 (void *)&cmd_showport_rss_hash_port_id,
3062 (void *)&cmd_showport_rss_hash_rss_hash,
3067 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3068 .f = cmd_showport_rss_hash_parsed,
3070 .help_str = "show port <port_id> rss-hash key",
3072 (void *)&cmd_showport_rss_hash_show,
3073 (void *)&cmd_showport_rss_hash_port,
3074 (void *)&cmd_showport_rss_hash_port_id,
3075 (void *)&cmd_showport_rss_hash_rss_hash,
3076 (void *)&cmd_showport_rss_hash_rss_key,
3081 /* *** Configure DCB *** */
3082 struct cmd_config_dcb {
3083 cmdline_fixed_string_t port;
3084 cmdline_fixed_string_t config;
3086 cmdline_fixed_string_t dcb;
3087 cmdline_fixed_string_t vt;
3088 cmdline_fixed_string_t vt_en;
3090 cmdline_fixed_string_t pfc;
3091 cmdline_fixed_string_t pfc_en;
3095 cmd_config_dcb_parsed(void *parsed_result,
3096 __attribute__((unused)) struct cmdline *cl,
3097 __attribute__((unused)) void *data)
3099 struct cmd_config_dcb *res = parsed_result;
3100 portid_t port_id = res->port_id;
3101 struct rte_port *port;
3105 port = &ports[port_id];
3106 /** Check if the port is not started **/
3107 if (port->port_status != RTE_PORT_STOPPED) {
3108 printf("Please stop port %d first\n", port_id);
3112 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3113 printf("The invalid number of traffic class,"
3114 " only 4 or 8 allowed.\n");
3118 if (nb_fwd_lcores < res->num_tcs) {
3119 printf("nb_cores shouldn't be less than number of TCs.\n");
3122 if (!strncmp(res->pfc_en, "on", 2))
3127 /* DCB in VT mode */
3128 if (!strncmp(res->vt_en, "on", 2))
3129 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3130 (enum rte_eth_nb_tcs)res->num_tcs,
3133 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3134 (enum rte_eth_nb_tcs)res->num_tcs,
3139 printf("Cannot initialize network ports.\n");
3143 cmd_reconfig_device_queue(port_id, 1, 1);
3146 cmdline_parse_token_string_t cmd_config_dcb_port =
3147 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3148 cmdline_parse_token_string_t cmd_config_dcb_config =
3149 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3150 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3151 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3152 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3153 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3154 cmdline_parse_token_string_t cmd_config_dcb_vt =
3155 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3156 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3157 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3158 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3159 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3160 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3161 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3162 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3163 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3165 cmdline_parse_inst_t cmd_config_dcb = {
3166 .f = cmd_config_dcb_parsed,
3168 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3170 (void *)&cmd_config_dcb_port,
3171 (void *)&cmd_config_dcb_config,
3172 (void *)&cmd_config_dcb_port_id,
3173 (void *)&cmd_config_dcb_dcb,
3174 (void *)&cmd_config_dcb_vt,
3175 (void *)&cmd_config_dcb_vt_en,
3176 (void *)&cmd_config_dcb_num_tcs,
3177 (void *)&cmd_config_dcb_pfc,
3178 (void *)&cmd_config_dcb_pfc_en,
3183 /* *** configure number of packets per burst *** */
3184 struct cmd_config_burst {
3185 cmdline_fixed_string_t port;
3186 cmdline_fixed_string_t keyword;
3187 cmdline_fixed_string_t all;
3188 cmdline_fixed_string_t name;
3193 cmd_config_burst_parsed(void *parsed_result,
3194 __attribute__((unused)) struct cmdline *cl,
3195 __attribute__((unused)) void *data)
3197 struct cmd_config_burst *res = parsed_result;
3198 struct rte_eth_dev_info dev_info;
3199 uint16_t rec_nb_pkts;
3201 if (!all_ports_stopped()) {
3202 printf("Please stop all ports first\n");
3206 if (!strcmp(res->name, "burst")) {
3207 if (res->value == 0) {
3208 /* If user gives a value of zero, query the PMD for
3209 * its recommended Rx burst size. Testpmd uses a single
3210 * size for all ports, so assume all ports are the same
3211 * NIC model and use the values from Port 0.
3213 rte_eth_dev_info_get(0, &dev_info);
3214 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3216 if (rec_nb_pkts == 0) {
3217 printf("PMD does not recommend a burst size.\n"
3218 "User provided value must be between"
3219 " 1 and %d\n", MAX_PKT_BURST);
3221 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3222 printf("PMD recommended burst size of %d"
3223 " exceeds maximum value of %d\n",
3224 rec_nb_pkts, MAX_PKT_BURST);
3227 printf("Using PMD-provided burst value of %d\n",
3229 nb_pkt_per_burst = rec_nb_pkts;
3230 } else if (res->value > MAX_PKT_BURST) {
3231 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3234 nb_pkt_per_burst = res->value;
3236 printf("Unknown parameter\n");
3242 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3245 cmdline_parse_token_string_t cmd_config_burst_port =
3246 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3247 cmdline_parse_token_string_t cmd_config_burst_keyword =
3248 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3249 cmdline_parse_token_string_t cmd_config_burst_all =
3250 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3251 cmdline_parse_token_string_t cmd_config_burst_name =
3252 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3253 cmdline_parse_token_num_t cmd_config_burst_value =
3254 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3256 cmdline_parse_inst_t cmd_config_burst = {
3257 .f = cmd_config_burst_parsed,
3259 .help_str = "port config all burst <value>",
3261 (void *)&cmd_config_burst_port,
3262 (void *)&cmd_config_burst_keyword,
3263 (void *)&cmd_config_burst_all,
3264 (void *)&cmd_config_burst_name,
3265 (void *)&cmd_config_burst_value,
3270 /* *** configure rx/tx queues *** */
3271 struct cmd_config_thresh {
3272 cmdline_fixed_string_t port;
3273 cmdline_fixed_string_t keyword;
3274 cmdline_fixed_string_t all;
3275 cmdline_fixed_string_t name;
3280 cmd_config_thresh_parsed(void *parsed_result,
3281 __attribute__((unused)) struct cmdline *cl,
3282 __attribute__((unused)) void *data)
3284 struct cmd_config_thresh *res = parsed_result;
3286 if (!all_ports_stopped()) {
3287 printf("Please stop all ports first\n");
3291 if (!strcmp(res->name, "txpt"))
3292 tx_pthresh = res->value;
3293 else if(!strcmp(res->name, "txht"))
3294 tx_hthresh = res->value;
3295 else if(!strcmp(res->name, "txwt"))
3296 tx_wthresh = res->value;
3297 else if(!strcmp(res->name, "rxpt"))
3298 rx_pthresh = res->value;
3299 else if(!strcmp(res->name, "rxht"))
3300 rx_hthresh = res->value;
3301 else if(!strcmp(res->name, "rxwt"))
3302 rx_wthresh = res->value;
3304 printf("Unknown parameter\n");
3310 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3313 cmdline_parse_token_string_t cmd_config_thresh_port =
3314 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3315 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3316 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3317 cmdline_parse_token_string_t cmd_config_thresh_all =
3318 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3319 cmdline_parse_token_string_t cmd_config_thresh_name =
3320 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3321 "txpt#txht#txwt#rxpt#rxht#rxwt");
3322 cmdline_parse_token_num_t cmd_config_thresh_value =
3323 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3325 cmdline_parse_inst_t cmd_config_thresh = {
3326 .f = cmd_config_thresh_parsed,
3328 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3330 (void *)&cmd_config_thresh_port,
3331 (void *)&cmd_config_thresh_keyword,
3332 (void *)&cmd_config_thresh_all,
3333 (void *)&cmd_config_thresh_name,
3334 (void *)&cmd_config_thresh_value,
3339 /* *** configure free/rs threshold *** */
3340 struct cmd_config_threshold {
3341 cmdline_fixed_string_t port;
3342 cmdline_fixed_string_t keyword;
3343 cmdline_fixed_string_t all;
3344 cmdline_fixed_string_t name;
3349 cmd_config_threshold_parsed(void *parsed_result,
3350 __attribute__((unused)) struct cmdline *cl,
3351 __attribute__((unused)) void *data)
3353 struct cmd_config_threshold *res = parsed_result;
3355 if (!all_ports_stopped()) {
3356 printf("Please stop all ports first\n");
3360 if (!strcmp(res->name, "txfreet"))
3361 tx_free_thresh = res->value;
3362 else if (!strcmp(res->name, "txrst"))
3363 tx_rs_thresh = res->value;
3364 else if (!strcmp(res->name, "rxfreet"))
3365 rx_free_thresh = res->value;
3367 printf("Unknown parameter\n");
3373 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3376 cmdline_parse_token_string_t cmd_config_threshold_port =
3377 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3378 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3379 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3381 cmdline_parse_token_string_t cmd_config_threshold_all =
3382 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3383 cmdline_parse_token_string_t cmd_config_threshold_name =
3384 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3385 "txfreet#txrst#rxfreet");
3386 cmdline_parse_token_num_t cmd_config_threshold_value =
3387 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3389 cmdline_parse_inst_t cmd_config_threshold = {
3390 .f = cmd_config_threshold_parsed,
3392 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3394 (void *)&cmd_config_threshold_port,
3395 (void *)&cmd_config_threshold_keyword,
3396 (void *)&cmd_config_threshold_all,
3397 (void *)&cmd_config_threshold_name,
3398 (void *)&cmd_config_threshold_value,
3404 struct cmd_stop_result {
3405 cmdline_fixed_string_t stop;
3408 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3409 __attribute__((unused)) struct cmdline *cl,
3410 __attribute__((unused)) void *data)
3412 stop_packet_forwarding();
3415 cmdline_parse_token_string_t cmd_stop_stop =
3416 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3418 cmdline_parse_inst_t cmd_stop = {
3419 .f = cmd_stop_parsed,
3421 .help_str = "stop: Stop packet forwarding",
3423 (void *)&cmd_stop_stop,
3428 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3431 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3432 unsigned int *parsed_items, int check_unique_values)
3434 unsigned int nb_item;
3442 * First parse all items in the list and store their value.
3447 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3449 if ((c >= '0') && (c <= '9')) {
3450 value = (unsigned int) (value * 10 + (c - '0'));
3455 printf("character %c is not a decimal digit\n", c);
3459 printf("No valid value before comma\n");
3462 if (nb_item < max_items) {
3463 parsed_items[nb_item] = value;
3469 if (nb_item >= max_items) {
3470 printf("Number of %s = %u > %u (maximum items)\n",
3471 item_name, nb_item + 1, max_items);
3474 parsed_items[nb_item++] = value;
3475 if (! check_unique_values)
3479 * Then, check that all values in the list are differents.
3480 * No optimization here...
3482 for (i = 0; i < nb_item; i++) {
3483 for (j = i + 1; j < nb_item; j++) {
3484 if (parsed_items[j] == parsed_items[i]) {
3485 printf("duplicated %s %u at index %u and %u\n",
3486 item_name, parsed_items[i], i, j);
3494 struct cmd_set_list_result {
3495 cmdline_fixed_string_t cmd_keyword;
3496 cmdline_fixed_string_t list_name;
3497 cmdline_fixed_string_t list_of_items;
3500 static void cmd_set_list_parsed(void *parsed_result,
3501 __attribute__((unused)) struct cmdline *cl,
3502 __attribute__((unused)) void *data)
3504 struct cmd_set_list_result *res;
3506 unsigned int lcorelist[RTE_MAX_LCORE];
3507 unsigned int portlist[RTE_MAX_ETHPORTS];
3509 unsigned int nb_item;
3511 if (test_done == 0) {
3512 printf("Please stop forwarding first\n");
3516 res = parsed_result;
3517 if (!strcmp(res->list_name, "corelist")) {
3518 nb_item = parse_item_list(res->list_of_items, "core",
3520 parsed_items.lcorelist, 1);
3522 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3527 if (!strcmp(res->list_name, "portlist")) {
3528 nb_item = parse_item_list(res->list_of_items, "port",
3530 parsed_items.portlist, 1);
3532 set_fwd_ports_list(parsed_items.portlist, nb_item);
3538 cmdline_parse_token_string_t cmd_set_list_keyword =
3539 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3541 cmdline_parse_token_string_t cmd_set_list_name =
3542 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3543 "corelist#portlist");
3544 cmdline_parse_token_string_t cmd_set_list_of_items =
3545 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3548 cmdline_parse_inst_t cmd_set_fwd_list = {
3549 .f = cmd_set_list_parsed,
3551 .help_str = "set corelist|portlist <list0[,list1]*>",
3553 (void *)&cmd_set_list_keyword,
3554 (void *)&cmd_set_list_name,
3555 (void *)&cmd_set_list_of_items,
3560 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3562 struct cmd_setmask_result {
3563 cmdline_fixed_string_t set;
3564 cmdline_fixed_string_t mask;
3568 static void cmd_set_mask_parsed(void *parsed_result,
3569 __attribute__((unused)) struct cmdline *cl,
3570 __attribute__((unused)) void *data)
3572 struct cmd_setmask_result *res = parsed_result;
3574 if (test_done == 0) {
3575 printf("Please stop forwarding first\n");
3578 if (!strcmp(res->mask, "coremask")) {
3579 set_fwd_lcores_mask(res->hexavalue);
3581 } else if (!strcmp(res->mask, "portmask")) {
3582 set_fwd_ports_mask(res->hexavalue);
3587 cmdline_parse_token_string_t cmd_setmask_set =
3588 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3589 cmdline_parse_token_string_t cmd_setmask_mask =
3590 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3591 "coremask#portmask");
3592 cmdline_parse_token_num_t cmd_setmask_value =
3593 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3595 cmdline_parse_inst_t cmd_set_fwd_mask = {
3596 .f = cmd_set_mask_parsed,
3598 .help_str = "set coremask|portmask <hexadecimal value>",
3600 (void *)&cmd_setmask_set,
3601 (void *)&cmd_setmask_mask,
3602 (void *)&cmd_setmask_value,
3608 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3610 struct cmd_set_result {
3611 cmdline_fixed_string_t set;
3612 cmdline_fixed_string_t what;
3616 static void cmd_set_parsed(void *parsed_result,
3617 __attribute__((unused)) struct cmdline *cl,
3618 __attribute__((unused)) void *data)
3620 struct cmd_set_result *res = parsed_result;
3621 if (!strcmp(res->what, "nbport")) {
3622 set_fwd_ports_number(res->value);
3624 } else if (!strcmp(res->what, "nbcore")) {
3625 set_fwd_lcores_number(res->value);
3627 } else if (!strcmp(res->what, "burst"))
3628 set_nb_pkt_per_burst(res->value);
3629 else if (!strcmp(res->what, "verbose"))
3630 set_verbose_level(res->value);
3633 cmdline_parse_token_string_t cmd_set_set =
3634 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3635 cmdline_parse_token_string_t cmd_set_what =
3636 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3637 "nbport#nbcore#burst#verbose");
3638 cmdline_parse_token_num_t cmd_set_value =
3639 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3641 cmdline_parse_inst_t cmd_set_numbers = {
3642 .f = cmd_set_parsed,
3644 .help_str = "set nbport|nbcore|burst|verbose <value>",
3646 (void *)&cmd_set_set,
3647 (void *)&cmd_set_what,
3648 (void *)&cmd_set_value,
3653 /* *** SET LOG LEVEL CONFIGURATION *** */
3655 struct cmd_set_log_result {
3656 cmdline_fixed_string_t set;
3657 cmdline_fixed_string_t log;
3658 cmdline_fixed_string_t type;
3663 cmd_set_log_parsed(void *parsed_result,
3664 __attribute__((unused)) struct cmdline *cl,
3665 __attribute__((unused)) void *data)
3667 struct cmd_set_log_result *res;
3670 res = parsed_result;
3671 if (!strcmp(res->type, "global"))
3672 rte_log_set_global_level(res->level);
3674 ret = rte_log_set_level_regexp(res->type, res->level);
3676 printf("Unable to set log level\n");
3680 cmdline_parse_token_string_t cmd_set_log_set =
3681 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3682 cmdline_parse_token_string_t cmd_set_log_log =
3683 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3684 cmdline_parse_token_string_t cmd_set_log_type =
3685 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3686 cmdline_parse_token_num_t cmd_set_log_level =
3687 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3689 cmdline_parse_inst_t cmd_set_log = {
3690 .f = cmd_set_log_parsed,
3692 .help_str = "set log global|<type> <level>",
3694 (void *)&cmd_set_log_set,
3695 (void *)&cmd_set_log_log,
3696 (void *)&cmd_set_log_type,
3697 (void *)&cmd_set_log_level,
3702 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3704 struct cmd_set_txpkts_result {
3705 cmdline_fixed_string_t cmd_keyword;
3706 cmdline_fixed_string_t txpkts;
3707 cmdline_fixed_string_t seg_lengths;
3711 cmd_set_txpkts_parsed(void *parsed_result,
3712 __attribute__((unused)) struct cmdline *cl,
3713 __attribute__((unused)) void *data)
3715 struct cmd_set_txpkts_result *res;
3716 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3717 unsigned int nb_segs;
3719 res = parsed_result;
3720 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3721 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3723 set_tx_pkt_segments(seg_lengths, nb_segs);
3726 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3727 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3728 cmd_keyword, "set");
3729 cmdline_parse_token_string_t cmd_set_txpkts_name =
3730 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3732 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3733 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3736 cmdline_parse_inst_t cmd_set_txpkts = {
3737 .f = cmd_set_txpkts_parsed,
3739 .help_str = "set txpkts <len0[,len1]*>",
3741 (void *)&cmd_set_txpkts_keyword,
3742 (void *)&cmd_set_txpkts_name,
3743 (void *)&cmd_set_txpkts_lengths,
3748 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3750 struct cmd_set_txsplit_result {
3751 cmdline_fixed_string_t cmd_keyword;
3752 cmdline_fixed_string_t txsplit;
3753 cmdline_fixed_string_t mode;
3757 cmd_set_txsplit_parsed(void *parsed_result,
3758 __attribute__((unused)) struct cmdline *cl,
3759 __attribute__((unused)) void *data)
3761 struct cmd_set_txsplit_result *res;
3763 res = parsed_result;
3764 set_tx_pkt_split(res->mode);
3767 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3768 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3769 cmd_keyword, "set");
3770 cmdline_parse_token_string_t cmd_set_txsplit_name =
3771 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3772 txsplit, "txsplit");
3773 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3774 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3777 cmdline_parse_inst_t cmd_set_txsplit = {
3778 .f = cmd_set_txsplit_parsed,
3780 .help_str = "set txsplit on|off|rand",
3782 (void *)&cmd_set_txsplit_keyword,
3783 (void *)&cmd_set_txsplit_name,
3784 (void *)&cmd_set_txsplit_mode,
3789 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3790 struct cmd_rx_vlan_filter_all_result {
3791 cmdline_fixed_string_t rx_vlan;
3792 cmdline_fixed_string_t what;
3793 cmdline_fixed_string_t all;
3798 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3799 __attribute__((unused)) struct cmdline *cl,
3800 __attribute__((unused)) void *data)
3802 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3804 if (!strcmp(res->what, "add"))
3805 rx_vlan_all_filter_set(res->port_id, 1);
3807 rx_vlan_all_filter_set(res->port_id, 0);
3810 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3811 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3812 rx_vlan, "rx_vlan");
3813 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3814 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3816 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3817 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3819 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3820 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3823 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3824 .f = cmd_rx_vlan_filter_all_parsed,
3826 .help_str = "rx_vlan add|rm all <port_id>: "
3827 "Add/Remove all identifiers to/from the set of VLAN "
3828 "identifiers filtered by a port",
3830 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3831 (void *)&cmd_rx_vlan_filter_all_what,
3832 (void *)&cmd_rx_vlan_filter_all_all,
3833 (void *)&cmd_rx_vlan_filter_all_portid,
3838 /* *** VLAN OFFLOAD SET ON A PORT *** */
3839 struct cmd_vlan_offload_result {
3840 cmdline_fixed_string_t vlan;
3841 cmdline_fixed_string_t set;
3842 cmdline_fixed_string_t vlan_type;
3843 cmdline_fixed_string_t what;
3844 cmdline_fixed_string_t on;
3845 cmdline_fixed_string_t port_id;
3849 cmd_vlan_offload_parsed(void *parsed_result,
3850 __attribute__((unused)) struct cmdline *cl,
3851 __attribute__((unused)) void *data)
3854 struct cmd_vlan_offload_result *res = parsed_result;
3857 portid_t port_id = 0;
3861 len = strnlen(str, STR_TOKEN_SIZE);
3863 /* Get port_id first */
3871 tmp = strtoul(str, NULL, 0);
3872 /* If port_id greater that what portid_t can represent, return */
3873 if(tmp >= RTE_MAX_ETHPORTS)
3875 port_id = (portid_t)tmp;
3877 if (!strcmp(res->on, "on"))
3882 if (!strcmp(res->what, "strip"))
3883 rx_vlan_strip_set(port_id, on);
3884 else if(!strcmp(res->what, "stripq")){
3885 uint16_t queue_id = 0;
3887 /* No queue_id, return */
3889 printf("must specify (port,queue_id)\n");
3892 tmp = strtoul(str + i + 1, NULL, 0);
3893 /* If queue_id greater that what 16-bits can represent, return */
3897 queue_id = (uint16_t)tmp;
3898 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3900 else if (!strcmp(res->what, "filter"))
3901 rx_vlan_filter_set(port_id, on);
3903 vlan_extend_set(port_id, on);
3908 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3909 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3911 cmdline_parse_token_string_t cmd_vlan_offload_set =
3912 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3914 cmdline_parse_token_string_t cmd_vlan_offload_what =
3915 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3916 what, "strip#filter#qinq#stripq");
3917 cmdline_parse_token_string_t cmd_vlan_offload_on =
3918 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3920 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3921 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3924 cmdline_parse_inst_t cmd_vlan_offload = {
3925 .f = cmd_vlan_offload_parsed,
3927 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3928 "<port_id[,queue_id]>: "
3929 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3931 (void *)&cmd_vlan_offload_vlan,
3932 (void *)&cmd_vlan_offload_set,
3933 (void *)&cmd_vlan_offload_what,
3934 (void *)&cmd_vlan_offload_on,
3935 (void *)&cmd_vlan_offload_portid,
3940 /* *** VLAN TPID SET ON A PORT *** */
3941 struct cmd_vlan_tpid_result {
3942 cmdline_fixed_string_t vlan;
3943 cmdline_fixed_string_t set;
3944 cmdline_fixed_string_t vlan_type;
3945 cmdline_fixed_string_t what;
3951 cmd_vlan_tpid_parsed(void *parsed_result,
3952 __attribute__((unused)) struct cmdline *cl,
3953 __attribute__((unused)) void *data)
3955 struct cmd_vlan_tpid_result *res = parsed_result;
3956 enum rte_vlan_type vlan_type;
3958 if (!strcmp(res->vlan_type, "inner"))
3959 vlan_type = ETH_VLAN_TYPE_INNER;
3960 else if (!strcmp(res->vlan_type, "outer"))
3961 vlan_type = ETH_VLAN_TYPE_OUTER;
3963 printf("Unknown vlan type\n");
3966 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3969 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3970 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3972 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3973 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3975 cmdline_parse_token_string_t cmd_vlan_type =
3976 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3977 vlan_type, "inner#outer");
3978 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3979 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3981 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3982 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3984 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3985 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3988 cmdline_parse_inst_t cmd_vlan_tpid = {
3989 .f = cmd_vlan_tpid_parsed,
3991 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3992 "Set the VLAN Ether type",
3994 (void *)&cmd_vlan_tpid_vlan,
3995 (void *)&cmd_vlan_tpid_set,
3996 (void *)&cmd_vlan_type,
3997 (void *)&cmd_vlan_tpid_what,
3998 (void *)&cmd_vlan_tpid_tpid,
3999 (void *)&cmd_vlan_tpid_portid,
4004 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4005 struct cmd_rx_vlan_filter_result {
4006 cmdline_fixed_string_t rx_vlan;
4007 cmdline_fixed_string_t what;
4013 cmd_rx_vlan_filter_parsed(void *parsed_result,
4014 __attribute__((unused)) struct cmdline *cl,
4015 __attribute__((unused)) void *data)
4017 struct cmd_rx_vlan_filter_result *res = parsed_result;
4019 if (!strcmp(res->what, "add"))
4020 rx_vft_set(res->port_id, res->vlan_id, 1);
4022 rx_vft_set(res->port_id, res->vlan_id, 0);
4025 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4026 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4027 rx_vlan, "rx_vlan");
4028 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4029 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4031 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4032 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4034 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4035 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4038 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4039 .f = cmd_rx_vlan_filter_parsed,
4041 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4042 "Add/Remove a VLAN identifier to/from the set of VLAN "
4043 "identifiers filtered by a port",
4045 (void *)&cmd_rx_vlan_filter_rx_vlan,
4046 (void *)&cmd_rx_vlan_filter_what,
4047 (void *)&cmd_rx_vlan_filter_vlanid,
4048 (void *)&cmd_rx_vlan_filter_portid,
4053 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4054 struct cmd_tx_vlan_set_result {
4055 cmdline_fixed_string_t tx_vlan;
4056 cmdline_fixed_string_t set;
4062 cmd_tx_vlan_set_parsed(void *parsed_result,
4063 __attribute__((unused)) struct cmdline *cl,
4064 __attribute__((unused)) void *data)
4066 struct cmd_tx_vlan_set_result *res = parsed_result;
4068 if (!port_is_stopped(res->port_id)) {
4069 printf("Please stop port %d first\n", res->port_id);
4073 tx_vlan_set(res->port_id, res->vlan_id);
4075 cmd_reconfig_device_queue(res->port_id, 1, 1);
4078 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4079 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4080 tx_vlan, "tx_vlan");
4081 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4082 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4084 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4085 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4087 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4088 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4091 cmdline_parse_inst_t cmd_tx_vlan_set = {
4092 .f = cmd_tx_vlan_set_parsed,
4094 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4095 "Enable hardware insertion of a single VLAN header "
4096 "with a given TAG Identifier in packets sent on a port",
4098 (void *)&cmd_tx_vlan_set_tx_vlan,
4099 (void *)&cmd_tx_vlan_set_set,
4100 (void *)&cmd_tx_vlan_set_portid,
4101 (void *)&cmd_tx_vlan_set_vlanid,
4106 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4107 struct cmd_tx_vlan_set_qinq_result {
4108 cmdline_fixed_string_t tx_vlan;
4109 cmdline_fixed_string_t set;
4112 uint16_t vlan_id_outer;
4116 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4117 __attribute__((unused)) struct cmdline *cl,
4118 __attribute__((unused)) void *data)
4120 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4122 if (!port_is_stopped(res->port_id)) {
4123 printf("Please stop port %d first\n", res->port_id);
4127 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4129 cmd_reconfig_device_queue(res->port_id, 1, 1);
4132 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4133 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4134 tx_vlan, "tx_vlan");
4135 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4136 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4138 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4139 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4141 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4142 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4144 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4145 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4146 vlan_id_outer, UINT16);
4148 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4149 .f = cmd_tx_vlan_set_qinq_parsed,
4151 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4152 "Enable hardware insertion of double VLAN header "
4153 "with given TAG Identifiers in packets sent on a port",
4155 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4156 (void *)&cmd_tx_vlan_set_qinq_set,
4157 (void *)&cmd_tx_vlan_set_qinq_portid,
4158 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4159 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4164 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4165 struct cmd_tx_vlan_set_pvid_result {
4166 cmdline_fixed_string_t tx_vlan;
4167 cmdline_fixed_string_t set;
4168 cmdline_fixed_string_t pvid;
4171 cmdline_fixed_string_t mode;
4175 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4176 __attribute__((unused)) struct cmdline *cl,
4177 __attribute__((unused)) void *data)
4179 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4181 if (strcmp(res->mode, "on") == 0)
4182 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4184 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4187 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4188 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4189 tx_vlan, "tx_vlan");
4190 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4191 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4193 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4194 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4196 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4197 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4199 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4200 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4202 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4203 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4206 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4207 .f = cmd_tx_vlan_set_pvid_parsed,
4209 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4211 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4212 (void *)&cmd_tx_vlan_set_pvid_set,
4213 (void *)&cmd_tx_vlan_set_pvid_pvid,
4214 (void *)&cmd_tx_vlan_set_pvid_port_id,
4215 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4216 (void *)&cmd_tx_vlan_set_pvid_mode,
4221 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4222 struct cmd_tx_vlan_reset_result {
4223 cmdline_fixed_string_t tx_vlan;
4224 cmdline_fixed_string_t reset;
4229 cmd_tx_vlan_reset_parsed(void *parsed_result,
4230 __attribute__((unused)) struct cmdline *cl,
4231 __attribute__((unused)) void *data)
4233 struct cmd_tx_vlan_reset_result *res = parsed_result;
4235 if (!port_is_stopped(res->port_id)) {
4236 printf("Please stop port %d first\n", res->port_id);
4240 tx_vlan_reset(res->port_id);
4242 cmd_reconfig_device_queue(res->port_id, 1, 1);
4245 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4246 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4247 tx_vlan, "tx_vlan");
4248 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4249 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4251 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4252 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4255 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4256 .f = cmd_tx_vlan_reset_parsed,
4258 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4259 "VLAN header in packets sent on a port",
4261 (void *)&cmd_tx_vlan_reset_tx_vlan,
4262 (void *)&cmd_tx_vlan_reset_reset,
4263 (void *)&cmd_tx_vlan_reset_portid,
4269 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4270 struct cmd_csum_result {
4271 cmdline_fixed_string_t csum;
4272 cmdline_fixed_string_t mode;
4273 cmdline_fixed_string_t proto;
4274 cmdline_fixed_string_t hwsw;
4279 csum_show(int port_id)
4281 struct rte_eth_dev_info dev_info;
4282 uint64_t tx_offloads;
4284 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4285 printf("Parse tunnel is %s\n",
4286 (ports[port_id].parse_tunnel) ? "on" : "off");
4287 printf("IP checksum offload is %s\n",
4288 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4289 printf("UDP checksum offload is %s\n",
4290 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4291 printf("TCP checksum offload is %s\n",
4292 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4293 printf("SCTP checksum offload is %s\n",
4294 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4295 printf("Outer-Ip checksum offload is %s\n",
4296 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4297 printf("Outer-Udp checksum offload is %s\n",
4298 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4300 /* display warnings if configuration is not supported by the NIC */
4301 rte_eth_dev_info_get(port_id, &dev_info);
4302 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4303 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4304 printf("Warning: hardware IP checksum enabled but not "
4305 "supported by port %d\n", port_id);
4307 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4308 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4309 printf("Warning: hardware UDP checksum enabled but not "
4310 "supported by port %d\n", port_id);
4312 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4313 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4314 printf("Warning: hardware TCP checksum enabled but not "
4315 "supported by port %d\n", port_id);
4317 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4318 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4319 printf("Warning: hardware SCTP checksum enabled but not "
4320 "supported by port %d\n", port_id);
4322 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4323 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4324 printf("Warning: hardware outer IP checksum enabled but not "
4325 "supported by port %d\n", port_id);
4327 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4328 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4330 printf("Warning: hardware outer UDP checksum enabled but not "
4331 "supported by port %d\n", port_id);
4336 cmd_config_queue_tx_offloads(struct rte_port *port)
4340 /* Apply queue tx offloads configuration */
4341 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4342 port->tx_conf[k].offloads =
4343 port->dev_conf.txmode.offloads;
4347 cmd_csum_parsed(void *parsed_result,
4348 __attribute__((unused)) struct cmdline *cl,
4349 __attribute__((unused)) void *data)
4351 struct cmd_csum_result *res = parsed_result;
4353 uint64_t csum_offloads = 0;
4354 struct rte_eth_dev_info dev_info;
4356 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4357 printf("invalid port %d\n", res->port_id);
4360 if (!port_is_stopped(res->port_id)) {
4361 printf("Please stop port %d first\n", res->port_id);
4365 rte_eth_dev_info_get(res->port_id, &dev_info);
4366 if (!strcmp(res->mode, "set")) {
4368 if (!strcmp(res->hwsw, "hw"))
4371 if (!strcmp(res->proto, "ip")) {
4372 if (hw == 0 || (dev_info.tx_offload_capa &
4373 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4374 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4376 printf("IP checksum offload is not supported "
4377 "by port %u\n", res->port_id);
4379 } else if (!strcmp(res->proto, "udp")) {
4380 if (hw == 0 || (dev_info.tx_offload_capa &
4381 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4382 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4384 printf("UDP checksum offload is not supported "
4385 "by port %u\n", res->port_id);
4387 } else if (!strcmp(res->proto, "tcp")) {
4388 if (hw == 0 || (dev_info.tx_offload_capa &
4389 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4390 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4392 printf("TCP checksum offload is not supported "
4393 "by port %u\n", res->port_id);
4395 } else if (!strcmp(res->proto, "sctp")) {
4396 if (hw == 0 || (dev_info.tx_offload_capa &
4397 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4398 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4400 printf("SCTP checksum offload is not supported "
4401 "by port %u\n", res->port_id);
4403 } else if (!strcmp(res->proto, "outer-ip")) {
4404 if (hw == 0 || (dev_info.tx_offload_capa &
4405 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4407 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4409 printf("Outer IP checksum offload is not "
4410 "supported by port %u\n", res->port_id);
4412 } else if (!strcmp(res->proto, "outer-udp")) {
4413 if (hw == 0 || (dev_info.tx_offload_capa &
4414 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4416 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4418 printf("Outer UDP checksum offload is not "
4419 "supported by port %u\n", res->port_id);
4424 ports[res->port_id].dev_conf.txmode.offloads |=
4427 ports[res->port_id].dev_conf.txmode.offloads &=
4430 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4432 csum_show(res->port_id);
4434 cmd_reconfig_device_queue(res->port_id, 1, 1);
4437 cmdline_parse_token_string_t cmd_csum_csum =
4438 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4440 cmdline_parse_token_string_t cmd_csum_mode =
4441 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4443 cmdline_parse_token_string_t cmd_csum_proto =
4444 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4445 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4446 cmdline_parse_token_string_t cmd_csum_hwsw =
4447 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4449 cmdline_parse_token_num_t cmd_csum_portid =
4450 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4453 cmdline_parse_inst_t cmd_csum_set = {
4454 .f = cmd_csum_parsed,
4456 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4457 "Enable/Disable hardware calculation of L3/L4 checksum when "
4458 "using csum forward engine",
4460 (void *)&cmd_csum_csum,
4461 (void *)&cmd_csum_mode,
4462 (void *)&cmd_csum_proto,
4463 (void *)&cmd_csum_hwsw,
4464 (void *)&cmd_csum_portid,
4469 cmdline_parse_token_string_t cmd_csum_mode_show =
4470 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4473 cmdline_parse_inst_t cmd_csum_show = {
4474 .f = cmd_csum_parsed,
4476 .help_str = "csum show <port_id>: Show checksum offload configuration",
4478 (void *)&cmd_csum_csum,
4479 (void *)&cmd_csum_mode_show,
4480 (void *)&cmd_csum_portid,
4485 /* Enable/disable tunnel parsing */
4486 struct cmd_csum_tunnel_result {
4487 cmdline_fixed_string_t csum;
4488 cmdline_fixed_string_t parse;
4489 cmdline_fixed_string_t onoff;
4494 cmd_csum_tunnel_parsed(void *parsed_result,
4495 __attribute__((unused)) struct cmdline *cl,
4496 __attribute__((unused)) void *data)
4498 struct cmd_csum_tunnel_result *res = parsed_result;
4500 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4503 if (!strcmp(res->onoff, "on"))
4504 ports[res->port_id].parse_tunnel = 1;
4506 ports[res->port_id].parse_tunnel = 0;
4508 csum_show(res->port_id);
4511 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4512 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4514 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4515 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4516 parse, "parse-tunnel");
4517 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4518 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4520 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4521 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4524 cmdline_parse_inst_t cmd_csum_tunnel = {
4525 .f = cmd_csum_tunnel_parsed,
4527 .help_str = "csum parse-tunnel on|off <port_id>: "
4528 "Enable/Disable parsing of tunnels for csum engine",
4530 (void *)&cmd_csum_tunnel_csum,
4531 (void *)&cmd_csum_tunnel_parse,
4532 (void *)&cmd_csum_tunnel_onoff,
4533 (void *)&cmd_csum_tunnel_portid,
4538 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4539 struct cmd_tso_set_result {
4540 cmdline_fixed_string_t tso;
4541 cmdline_fixed_string_t mode;
4547 cmd_tso_set_parsed(void *parsed_result,
4548 __attribute__((unused)) struct cmdline *cl,
4549 __attribute__((unused)) void *data)
4551 struct cmd_tso_set_result *res = parsed_result;
4552 struct rte_eth_dev_info dev_info;
4554 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4556 if (!port_is_stopped(res->port_id)) {
4557 printf("Please stop port %d first\n", res->port_id);
4561 if (!strcmp(res->mode, "set"))
4562 ports[res->port_id].tso_segsz = res->tso_segsz;
4564 rte_eth_dev_info_get(res->port_id, &dev_info);
4565 if ((ports[res->port_id].tso_segsz != 0) &&
4566 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4567 printf("Error: TSO is not supported by port %d\n",
4572 if (ports[res->port_id].tso_segsz == 0) {
4573 ports[res->port_id].dev_conf.txmode.offloads &=
4574 ~DEV_TX_OFFLOAD_TCP_TSO;
4575 printf("TSO for non-tunneled packets is disabled\n");
4577 ports[res->port_id].dev_conf.txmode.offloads |=
4578 DEV_TX_OFFLOAD_TCP_TSO;
4579 printf("TSO segment size for non-tunneled packets is %d\n",
4580 ports[res->port_id].tso_segsz);
4582 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4584 /* display warnings if configuration is not supported by the NIC */
4585 rte_eth_dev_info_get(res->port_id, &dev_info);
4586 if ((ports[res->port_id].tso_segsz != 0) &&
4587 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4588 printf("Warning: TSO enabled but not "
4589 "supported by port %d\n", res->port_id);
4592 cmd_reconfig_device_queue(res->port_id, 1, 1);
4595 cmdline_parse_token_string_t cmd_tso_set_tso =
4596 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4598 cmdline_parse_token_string_t cmd_tso_set_mode =
4599 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4601 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4602 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4604 cmdline_parse_token_num_t cmd_tso_set_portid =
4605 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4608 cmdline_parse_inst_t cmd_tso_set = {
4609 .f = cmd_tso_set_parsed,
4611 .help_str = "tso set <tso_segsz> <port_id>: "
4612 "Set TSO segment size of non-tunneled packets for csum engine "
4615 (void *)&cmd_tso_set_tso,
4616 (void *)&cmd_tso_set_mode,
4617 (void *)&cmd_tso_set_tso_segsz,
4618 (void *)&cmd_tso_set_portid,
4623 cmdline_parse_token_string_t cmd_tso_show_mode =
4624 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4628 cmdline_parse_inst_t cmd_tso_show = {
4629 .f = cmd_tso_set_parsed,
4631 .help_str = "tso show <port_id>: "
4632 "Show TSO segment size of non-tunneled packets for csum engine",
4634 (void *)&cmd_tso_set_tso,
4635 (void *)&cmd_tso_show_mode,
4636 (void *)&cmd_tso_set_portid,
4641 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4642 struct cmd_tunnel_tso_set_result {
4643 cmdline_fixed_string_t tso;
4644 cmdline_fixed_string_t mode;
4649 static struct rte_eth_dev_info
4650 check_tunnel_tso_nic_support(portid_t port_id)
4652 struct rte_eth_dev_info dev_info;
4654 rte_eth_dev_info_get(port_id, &dev_info);
4655 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4656 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4657 "not enabled for port %d\n", port_id);
4658 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4659 printf("Warning: GRE TUNNEL TSO not supported therefore "
4660 "not enabled for port %d\n", port_id);
4661 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4662 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4663 "not enabled for port %d\n", port_id);
4664 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4665 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4666 "not enabled for port %d\n", port_id);
4667 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4668 printf("Warning: IP TUNNEL TSO not supported therefore "
4669 "not enabled for port %d\n", port_id);
4670 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4671 printf("Warning: UDP TUNNEL TSO not supported therefore "
4672 "not enabled for port %d\n", port_id);
4677 cmd_tunnel_tso_set_parsed(void *parsed_result,
4678 __attribute__((unused)) struct cmdline *cl,
4679 __attribute__((unused)) void *data)
4681 struct cmd_tunnel_tso_set_result *res = parsed_result;
4682 struct rte_eth_dev_info dev_info;
4684 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4686 if (!port_is_stopped(res->port_id)) {
4687 printf("Please stop port %d first\n", res->port_id);
4691 if (!strcmp(res->mode, "set"))
4692 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4694 dev_info = check_tunnel_tso_nic_support(res->port_id);
4695 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4696 ports[res->port_id].dev_conf.txmode.offloads &=
4697 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4698 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4699 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4700 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4701 DEV_TX_OFFLOAD_IP_TNL_TSO |
4702 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4703 printf("TSO for tunneled packets is disabled\n");
4705 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4706 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4707 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4708 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4709 DEV_TX_OFFLOAD_IP_TNL_TSO |
4710 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4712 ports[res->port_id].dev_conf.txmode.offloads |=
4713 (tso_offloads & dev_info.tx_offload_capa);
4714 printf("TSO segment size for tunneled packets is %d\n",
4715 ports[res->port_id].tunnel_tso_segsz);
4717 /* Below conditions are needed to make it work:
4718 * (1) tunnel TSO is supported by the NIC;
4719 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4721 * (3) for tunneled pkts with outer L3 of IPv4,
4722 * "csum set outer-ip" must be set to hw, because after tso,
4723 * total_len of outer IP header is changed, and the checksum
4724 * of outer IP header calculated by sw should be wrong; that
4725 * is not necessary for IPv6 tunneled pkts because there's no
4726 * checksum in IP header anymore.
4729 if (!ports[res->port_id].parse_tunnel)
4730 printf("Warning: csum parse_tunnel must be set "
4731 "so that tunneled packets are recognized\n");
4732 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4733 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4734 printf("Warning: csum set outer-ip must be set to hw "
4735 "if outer L3 is IPv4; not necessary for IPv6\n");
4738 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4739 cmd_reconfig_device_queue(res->port_id, 1, 1);
4742 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4743 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4745 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4746 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4748 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4749 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4751 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4752 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4755 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4756 .f = cmd_tunnel_tso_set_parsed,
4758 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4759 "Set TSO segment size of tunneled packets for csum engine "
4762 (void *)&cmd_tunnel_tso_set_tso,
4763 (void *)&cmd_tunnel_tso_set_mode,
4764 (void *)&cmd_tunnel_tso_set_tso_segsz,
4765 (void *)&cmd_tunnel_tso_set_portid,
4770 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4771 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4775 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4776 .f = cmd_tunnel_tso_set_parsed,
4778 .help_str = "tunnel_tso show <port_id> "
4779 "Show TSO segment size of tunneled packets for csum engine",
4781 (void *)&cmd_tunnel_tso_set_tso,
4782 (void *)&cmd_tunnel_tso_show_mode,
4783 (void *)&cmd_tunnel_tso_set_portid,
4788 /* *** SET GRO FOR A PORT *** */
4789 struct cmd_gro_enable_result {
4790 cmdline_fixed_string_t cmd_set;
4791 cmdline_fixed_string_t cmd_port;
4792 cmdline_fixed_string_t cmd_keyword;
4793 cmdline_fixed_string_t cmd_onoff;
4798 cmd_gro_enable_parsed(void *parsed_result,
4799 __attribute__((unused)) struct cmdline *cl,
4800 __attribute__((unused)) void *data)
4802 struct cmd_gro_enable_result *res;
4804 res = parsed_result;
4805 if (!strcmp(res->cmd_keyword, "gro"))
4806 setup_gro(res->cmd_onoff, res->cmd_pid);
4809 cmdline_parse_token_string_t cmd_gro_enable_set =
4810 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4812 cmdline_parse_token_string_t cmd_gro_enable_port =
4813 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4814 cmd_keyword, "port");
4815 cmdline_parse_token_num_t cmd_gro_enable_pid =
4816 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4818 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4819 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4820 cmd_keyword, "gro");
4821 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4822 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4823 cmd_onoff, "on#off");
4825 cmdline_parse_inst_t cmd_gro_enable = {
4826 .f = cmd_gro_enable_parsed,
4828 .help_str = "set port <port_id> gro on|off",
4830 (void *)&cmd_gro_enable_set,
4831 (void *)&cmd_gro_enable_port,
4832 (void *)&cmd_gro_enable_pid,
4833 (void *)&cmd_gro_enable_keyword,
4834 (void *)&cmd_gro_enable_onoff,
4839 /* *** DISPLAY GRO CONFIGURATION *** */
4840 struct cmd_gro_show_result {
4841 cmdline_fixed_string_t cmd_show;
4842 cmdline_fixed_string_t cmd_port;
4843 cmdline_fixed_string_t cmd_keyword;
4848 cmd_gro_show_parsed(void *parsed_result,
4849 __attribute__((unused)) struct cmdline *cl,
4850 __attribute__((unused)) void *data)
4852 struct cmd_gro_show_result *res;
4854 res = parsed_result;
4855 if (!strcmp(res->cmd_keyword, "gro"))
4856 show_gro(res->cmd_pid);
4859 cmdline_parse_token_string_t cmd_gro_show_show =
4860 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4862 cmdline_parse_token_string_t cmd_gro_show_port =
4863 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4865 cmdline_parse_token_num_t cmd_gro_show_pid =
4866 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4868 cmdline_parse_token_string_t cmd_gro_show_keyword =
4869 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4870 cmd_keyword, "gro");
4872 cmdline_parse_inst_t cmd_gro_show = {
4873 .f = cmd_gro_show_parsed,
4875 .help_str = "show port <port_id> gro",
4877 (void *)&cmd_gro_show_show,
4878 (void *)&cmd_gro_show_port,
4879 (void *)&cmd_gro_show_pid,
4880 (void *)&cmd_gro_show_keyword,
4885 /* *** SET FLUSH CYCLES FOR GRO *** */
4886 struct cmd_gro_flush_result {
4887 cmdline_fixed_string_t cmd_set;
4888 cmdline_fixed_string_t cmd_keyword;
4889 cmdline_fixed_string_t cmd_flush;
4894 cmd_gro_flush_parsed(void *parsed_result,
4895 __attribute__((unused)) struct cmdline *cl,
4896 __attribute__((unused)) void *data)
4898 struct cmd_gro_flush_result *res;
4900 res = parsed_result;
4901 if ((!strcmp(res->cmd_keyword, "gro")) &&
4902 (!strcmp(res->cmd_flush, "flush")))
4903 setup_gro_flush_cycles(res->cmd_cycles);
4906 cmdline_parse_token_string_t cmd_gro_flush_set =
4907 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4909 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4910 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4911 cmd_keyword, "gro");
4912 cmdline_parse_token_string_t cmd_gro_flush_flush =
4913 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4914 cmd_flush, "flush");
4915 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4916 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4919 cmdline_parse_inst_t cmd_gro_flush = {
4920 .f = cmd_gro_flush_parsed,
4922 .help_str = "set gro flush <cycles>",
4924 (void *)&cmd_gro_flush_set,
4925 (void *)&cmd_gro_flush_keyword,
4926 (void *)&cmd_gro_flush_flush,
4927 (void *)&cmd_gro_flush_cycles,
4932 /* *** ENABLE/DISABLE GSO *** */
4933 struct cmd_gso_enable_result {
4934 cmdline_fixed_string_t cmd_set;
4935 cmdline_fixed_string_t cmd_port;
4936 cmdline_fixed_string_t cmd_keyword;
4937 cmdline_fixed_string_t cmd_mode;
4942 cmd_gso_enable_parsed(void *parsed_result,
4943 __attribute__((unused)) struct cmdline *cl,
4944 __attribute__((unused)) void *data)
4946 struct cmd_gso_enable_result *res;
4948 res = parsed_result;
4949 if (!strcmp(res->cmd_keyword, "gso"))
4950 setup_gso(res->cmd_mode, res->cmd_pid);
4953 cmdline_parse_token_string_t cmd_gso_enable_set =
4954 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4956 cmdline_parse_token_string_t cmd_gso_enable_port =
4957 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4959 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4960 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4961 cmd_keyword, "gso");
4962 cmdline_parse_token_string_t cmd_gso_enable_mode =
4963 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4964 cmd_mode, "on#off");
4965 cmdline_parse_token_num_t cmd_gso_enable_pid =
4966 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4969 cmdline_parse_inst_t cmd_gso_enable = {
4970 .f = cmd_gso_enable_parsed,
4972 .help_str = "set port <port_id> gso on|off",
4974 (void *)&cmd_gso_enable_set,
4975 (void *)&cmd_gso_enable_port,
4976 (void *)&cmd_gso_enable_pid,
4977 (void *)&cmd_gso_enable_keyword,
4978 (void *)&cmd_gso_enable_mode,
4983 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4984 struct cmd_gso_size_result {
4985 cmdline_fixed_string_t cmd_set;
4986 cmdline_fixed_string_t cmd_keyword;
4987 cmdline_fixed_string_t cmd_segsz;
4992 cmd_gso_size_parsed(void *parsed_result,
4993 __attribute__((unused)) struct cmdline *cl,
4994 __attribute__((unused)) void *data)
4996 struct cmd_gso_size_result *res = parsed_result;
4998 if (test_done == 0) {
4999 printf("Before setting GSO segsz, please first"
5000 " stop fowarding\n");
5004 if (!strcmp(res->cmd_keyword, "gso") &&
5005 !strcmp(res->cmd_segsz, "segsz")) {
5006 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5007 printf("gso_size should be larger than %zu."
5008 " Please input a legal value\n",
5009 RTE_GSO_SEG_SIZE_MIN);
5011 gso_max_segment_size = res->cmd_size;
5015 cmdline_parse_token_string_t cmd_gso_size_set =
5016 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5018 cmdline_parse_token_string_t cmd_gso_size_keyword =
5019 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5020 cmd_keyword, "gso");
5021 cmdline_parse_token_string_t cmd_gso_size_segsz =
5022 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5023 cmd_segsz, "segsz");
5024 cmdline_parse_token_num_t cmd_gso_size_size =
5025 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5028 cmdline_parse_inst_t cmd_gso_size = {
5029 .f = cmd_gso_size_parsed,
5031 .help_str = "set gso segsz <length>",
5033 (void *)&cmd_gso_size_set,
5034 (void *)&cmd_gso_size_keyword,
5035 (void *)&cmd_gso_size_segsz,
5036 (void *)&cmd_gso_size_size,
5041 /* *** SHOW GSO CONFIGURATION *** */
5042 struct cmd_gso_show_result {
5043 cmdline_fixed_string_t cmd_show;
5044 cmdline_fixed_string_t cmd_port;
5045 cmdline_fixed_string_t cmd_keyword;
5050 cmd_gso_show_parsed(void *parsed_result,
5051 __attribute__((unused)) struct cmdline *cl,
5052 __attribute__((unused)) void *data)
5054 struct cmd_gso_show_result *res = parsed_result;
5056 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5057 printf("invalid port id %u\n", res->cmd_pid);
5060 if (!strcmp(res->cmd_keyword, "gso")) {
5061 if (gso_ports[res->cmd_pid].enable) {
5062 printf("Max GSO'd packet size: %uB\n"
5063 "Supported GSO types: TCP/IPv4, "
5064 "UDP/IPv4, VxLAN with inner "
5065 "TCP/IPv4 packet, GRE with inner "
5066 "TCP/IPv4 packet\n",
5067 gso_max_segment_size);
5069 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5073 cmdline_parse_token_string_t cmd_gso_show_show =
5074 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5076 cmdline_parse_token_string_t cmd_gso_show_port =
5077 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5079 cmdline_parse_token_string_t cmd_gso_show_keyword =
5080 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5081 cmd_keyword, "gso");
5082 cmdline_parse_token_num_t cmd_gso_show_pid =
5083 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5086 cmdline_parse_inst_t cmd_gso_show = {
5087 .f = cmd_gso_show_parsed,
5089 .help_str = "show port <port_id> gso",
5091 (void *)&cmd_gso_show_show,
5092 (void *)&cmd_gso_show_port,
5093 (void *)&cmd_gso_show_pid,
5094 (void *)&cmd_gso_show_keyword,
5099 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5100 struct cmd_set_flush_rx {
5101 cmdline_fixed_string_t set;
5102 cmdline_fixed_string_t flush_rx;
5103 cmdline_fixed_string_t mode;
5107 cmd_set_flush_rx_parsed(void *parsed_result,
5108 __attribute__((unused)) struct cmdline *cl,
5109 __attribute__((unused)) void *data)
5111 struct cmd_set_flush_rx *res = parsed_result;
5112 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5115 cmdline_parse_token_string_t cmd_setflushrx_set =
5116 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5118 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5119 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5120 flush_rx, "flush_rx");
5121 cmdline_parse_token_string_t cmd_setflushrx_mode =
5122 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5126 cmdline_parse_inst_t cmd_set_flush_rx = {
5127 .f = cmd_set_flush_rx_parsed,
5128 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5131 (void *)&cmd_setflushrx_set,
5132 (void *)&cmd_setflushrx_flush_rx,
5133 (void *)&cmd_setflushrx_mode,
5138 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5139 struct cmd_set_link_check {
5140 cmdline_fixed_string_t set;
5141 cmdline_fixed_string_t link_check;
5142 cmdline_fixed_string_t mode;
5146 cmd_set_link_check_parsed(void *parsed_result,
5147 __attribute__((unused)) struct cmdline *cl,
5148 __attribute__((unused)) void *data)
5150 struct cmd_set_link_check *res = parsed_result;
5151 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5154 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5155 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5157 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5158 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5159 link_check, "link_check");
5160 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5161 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5165 cmdline_parse_inst_t cmd_set_link_check = {
5166 .f = cmd_set_link_check_parsed,
5167 .help_str = "set link_check on|off: Enable/Disable link status check "
5168 "when starting/stopping a port",
5171 (void *)&cmd_setlinkcheck_set,
5172 (void *)&cmd_setlinkcheck_link_check,
5173 (void *)&cmd_setlinkcheck_mode,
5178 /* *** SET NIC BYPASS MODE *** */
5179 struct cmd_set_bypass_mode_result {
5180 cmdline_fixed_string_t set;
5181 cmdline_fixed_string_t bypass;
5182 cmdline_fixed_string_t mode;
5183 cmdline_fixed_string_t value;
5188 cmd_set_bypass_mode_parsed(void *parsed_result,
5189 __attribute__((unused)) struct cmdline *cl,
5190 __attribute__((unused)) void *data)
5192 struct cmd_set_bypass_mode_result *res = parsed_result;
5193 portid_t port_id = res->port_id;
5194 int32_t rc = -EINVAL;
5196 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5197 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5199 if (!strcmp(res->value, "bypass"))
5200 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5201 else if (!strcmp(res->value, "isolate"))
5202 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5204 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5206 /* Set the bypass mode for the relevant port. */
5207 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5210 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5213 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5214 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5216 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5217 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5219 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5220 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5222 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5223 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5224 value, "normal#bypass#isolate");
5225 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5226 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5229 cmdline_parse_inst_t cmd_set_bypass_mode = {
5230 .f = cmd_set_bypass_mode_parsed,
5231 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5232 "Set the NIC bypass mode for port_id",
5235 (void *)&cmd_setbypass_mode_set,
5236 (void *)&cmd_setbypass_mode_bypass,
5237 (void *)&cmd_setbypass_mode_mode,
5238 (void *)&cmd_setbypass_mode_value,
5239 (void *)&cmd_setbypass_mode_port,
5244 /* *** SET NIC BYPASS EVENT *** */
5245 struct cmd_set_bypass_event_result {
5246 cmdline_fixed_string_t set;
5247 cmdline_fixed_string_t bypass;
5248 cmdline_fixed_string_t event;
5249 cmdline_fixed_string_t event_value;
5250 cmdline_fixed_string_t mode;
5251 cmdline_fixed_string_t mode_value;
5256 cmd_set_bypass_event_parsed(void *parsed_result,
5257 __attribute__((unused)) struct cmdline *cl,
5258 __attribute__((unused)) void *data)
5260 int32_t rc = -EINVAL;
5261 struct cmd_set_bypass_event_result *res = parsed_result;
5262 portid_t port_id = res->port_id;
5264 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5265 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5266 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5268 if (!strcmp(res->event_value, "timeout"))
5269 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5270 else if (!strcmp(res->event_value, "os_on"))
5271 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5272 else if (!strcmp(res->event_value, "os_off"))
5273 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5274 else if (!strcmp(res->event_value, "power_on"))
5275 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5276 else if (!strcmp(res->event_value, "power_off"))
5277 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5279 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5281 if (!strcmp(res->mode_value, "bypass"))
5282 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5283 else if (!strcmp(res->mode_value, "isolate"))
5284 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5286 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5288 /* Set the watchdog timeout. */
5289 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5292 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5293 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5297 printf("Failed to set timeout value %u "
5298 "for port %d, errto code: %d.\n",
5299 bypass_timeout, port_id, rc);
5303 /* Set the bypass event to transition to bypass mode. */
5304 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5309 printf("\t Failed to set bypass event for port = %d.\n",
5313 cmdline_parse_token_string_t cmd_setbypass_event_set =
5314 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5316 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5317 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5319 cmdline_parse_token_string_t cmd_setbypass_event_event =
5320 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5322 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5323 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5324 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5325 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5326 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5328 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5329 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5330 mode_value, "normal#bypass#isolate");
5331 cmdline_parse_token_num_t cmd_setbypass_event_port =
5332 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5335 cmdline_parse_inst_t cmd_set_bypass_event = {
5336 .f = cmd_set_bypass_event_parsed,
5337 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5338 "power_off mode normal|bypass|isolate <port_id>: "
5339 "Set the NIC bypass event mode for port_id",
5342 (void *)&cmd_setbypass_event_set,
5343 (void *)&cmd_setbypass_event_bypass,
5344 (void *)&cmd_setbypass_event_event,
5345 (void *)&cmd_setbypass_event_event_value,
5346 (void *)&cmd_setbypass_event_mode,
5347 (void *)&cmd_setbypass_event_mode_value,
5348 (void *)&cmd_setbypass_event_port,
5354 /* *** SET NIC BYPASS TIMEOUT *** */
5355 struct cmd_set_bypass_timeout_result {
5356 cmdline_fixed_string_t set;
5357 cmdline_fixed_string_t bypass;
5358 cmdline_fixed_string_t timeout;
5359 cmdline_fixed_string_t value;
5363 cmd_set_bypass_timeout_parsed(void *parsed_result,
5364 __attribute__((unused)) struct cmdline *cl,
5365 __attribute__((unused)) void *data)
5367 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5369 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5370 if (!strcmp(res->value, "1.5"))
5371 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5372 else if (!strcmp(res->value, "2"))
5373 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5374 else if (!strcmp(res->value, "3"))
5375 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5376 else if (!strcmp(res->value, "4"))
5377 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5378 else if (!strcmp(res->value, "8"))
5379 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5380 else if (!strcmp(res->value, "16"))
5381 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5382 else if (!strcmp(res->value, "32"))
5383 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5385 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5389 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5390 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5392 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5393 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5395 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5396 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5397 timeout, "timeout");
5398 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5399 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5400 value, "0#1.5#2#3#4#8#16#32");
5402 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5403 .f = cmd_set_bypass_timeout_parsed,
5404 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5405 "Set the NIC bypass watchdog timeout in seconds",
5408 (void *)&cmd_setbypass_timeout_set,
5409 (void *)&cmd_setbypass_timeout_bypass,
5410 (void *)&cmd_setbypass_timeout_timeout,
5411 (void *)&cmd_setbypass_timeout_value,
5416 /* *** SHOW NIC BYPASS MODE *** */
5417 struct cmd_show_bypass_config_result {
5418 cmdline_fixed_string_t show;
5419 cmdline_fixed_string_t bypass;
5420 cmdline_fixed_string_t config;
5425 cmd_show_bypass_config_parsed(void *parsed_result,
5426 __attribute__((unused)) struct cmdline *cl,
5427 __attribute__((unused)) void *data)
5429 struct cmd_show_bypass_config_result *res = parsed_result;
5430 portid_t port_id = res->port_id;
5432 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5433 uint32_t event_mode;
5434 uint32_t bypass_mode;
5435 uint32_t timeout = bypass_timeout;
5438 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5439 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5440 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5441 {"UNKNOWN", "normal", "bypass", "isolate"};
5442 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5449 int num_events = (sizeof events) / (sizeof events[0]);
5451 /* Display the bypass mode.*/
5452 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5453 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5457 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5458 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5460 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5463 /* Display the bypass timeout.*/
5464 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5465 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5467 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5469 /* Display the bypass events and associated modes. */
5470 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5472 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5473 printf("\tFailed to get bypass mode for event = %s\n",
5476 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5477 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5479 printf("\tbypass event: %-16s = %s\n", events[i],
5485 printf("\tFailed to get bypass configuration for port = %d\n",
5489 cmdline_parse_token_string_t cmd_showbypass_config_show =
5490 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5492 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5493 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5495 cmdline_parse_token_string_t cmd_showbypass_config_config =
5496 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5498 cmdline_parse_token_num_t cmd_showbypass_config_port =
5499 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5502 cmdline_parse_inst_t cmd_show_bypass_config = {
5503 .f = cmd_show_bypass_config_parsed,
5504 .help_str = "show bypass config <port_id>: "
5505 "Show the NIC bypass config for port_id",
5508 (void *)&cmd_showbypass_config_show,
5509 (void *)&cmd_showbypass_config_bypass,
5510 (void *)&cmd_showbypass_config_config,
5511 (void *)&cmd_showbypass_config_port,
5516 #ifdef RTE_LIBRTE_PMD_BOND
5517 /* *** SET BONDING MODE *** */
5518 struct cmd_set_bonding_mode_result {
5519 cmdline_fixed_string_t set;
5520 cmdline_fixed_string_t bonding;
5521 cmdline_fixed_string_t mode;
5526 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5527 __attribute__((unused)) struct cmdline *cl,
5528 __attribute__((unused)) void *data)
5530 struct cmd_set_bonding_mode_result *res = parsed_result;
5531 portid_t port_id = res->port_id;
5533 /* Set the bonding mode for the relevant port. */
5534 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5535 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5538 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5539 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5541 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5542 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5543 bonding, "bonding");
5544 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5545 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5547 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5548 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5550 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5551 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5554 cmdline_parse_inst_t cmd_set_bonding_mode = {
5555 .f = cmd_set_bonding_mode_parsed,
5556 .help_str = "set bonding mode <mode_value> <port_id>: "
5557 "Set the bonding mode for port_id",
5560 (void *) &cmd_setbonding_mode_set,
5561 (void *) &cmd_setbonding_mode_bonding,
5562 (void *) &cmd_setbonding_mode_mode,
5563 (void *) &cmd_setbonding_mode_value,
5564 (void *) &cmd_setbonding_mode_port,
5569 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5570 struct cmd_set_bonding_lacp_dedicated_queues_result {
5571 cmdline_fixed_string_t set;
5572 cmdline_fixed_string_t bonding;
5573 cmdline_fixed_string_t lacp;
5574 cmdline_fixed_string_t dedicated_queues;
5576 cmdline_fixed_string_t mode;
5579 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5580 __attribute__((unused)) struct cmdline *cl,
5581 __attribute__((unused)) void *data)
5583 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5584 portid_t port_id = res->port_id;
5585 struct rte_port *port;
5587 port = &ports[port_id];
5589 /** Check if the port is not started **/
5590 if (port->port_status != RTE_PORT_STOPPED) {
5591 printf("Please stop port %d first\n", port_id);
5595 if (!strcmp(res->mode, "enable")) {
5596 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5597 printf("Dedicate queues for LACP control packets"
5600 printf("Enabling dedicate queues for LACP control "
5601 "packets on port %d failed\n", port_id);
5602 } else if (!strcmp(res->mode, "disable")) {
5603 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5604 printf("Dedicated queues for LACP control packets "
5607 printf("Disabling dedicated queues for LACP control "
5608 "traffic on port %d failed\n", port_id);
5612 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5613 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5615 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5616 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5617 bonding, "bonding");
5618 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5619 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5621 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5622 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5623 dedicated_queues, "dedicated_queues");
5624 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5625 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5627 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5628 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5629 mode, "enable#disable");
5631 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5632 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5633 .help_str = "set bonding lacp dedicated_queues <port_id> "
5635 "Enable/disable dedicated queues for LACP control traffic for port_id",
5638 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5639 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5640 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5641 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5642 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5643 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5648 /* *** SET BALANCE XMIT POLICY *** */
5649 struct cmd_set_bonding_balance_xmit_policy_result {
5650 cmdline_fixed_string_t set;
5651 cmdline_fixed_string_t bonding;
5652 cmdline_fixed_string_t balance_xmit_policy;
5654 cmdline_fixed_string_t policy;
5657 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5658 __attribute__((unused)) struct cmdline *cl,
5659 __attribute__((unused)) void *data)
5661 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5662 portid_t port_id = res->port_id;
5665 if (!strcmp(res->policy, "l2")) {
5666 policy = BALANCE_XMIT_POLICY_LAYER2;
5667 } else if (!strcmp(res->policy, "l23")) {
5668 policy = BALANCE_XMIT_POLICY_LAYER23;
5669 } else if (!strcmp(res->policy, "l34")) {
5670 policy = BALANCE_XMIT_POLICY_LAYER34;
5672 printf("\t Invalid xmit policy selection");
5676 /* Set the bonding mode for the relevant port. */
5677 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5678 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5683 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5684 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5686 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5687 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5688 bonding, "bonding");
5689 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5690 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5691 balance_xmit_policy, "balance_xmit_policy");
5692 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5693 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5695 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5696 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5697 policy, "l2#l23#l34");
5699 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5700 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5701 .help_str = "set bonding balance_xmit_policy <port_id> "
5703 "Set the bonding balance_xmit_policy for port_id",
5706 (void *)&cmd_setbonding_balance_xmit_policy_set,
5707 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5708 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5709 (void *)&cmd_setbonding_balance_xmit_policy_port,
5710 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5715 /* *** SHOW NIC BONDING CONFIGURATION *** */
5716 struct cmd_show_bonding_config_result {
5717 cmdline_fixed_string_t show;
5718 cmdline_fixed_string_t bonding;
5719 cmdline_fixed_string_t config;
5723 static void cmd_show_bonding_config_parsed(void *parsed_result,
5724 __attribute__((unused)) struct cmdline *cl,
5725 __attribute__((unused)) void *data)
5727 struct cmd_show_bonding_config_result *res = parsed_result;
5728 int bonding_mode, agg_mode;
5729 portid_t slaves[RTE_MAX_ETHPORTS];
5730 int num_slaves, num_active_slaves;
5733 portid_t port_id = res->port_id;
5735 /* Display the bonding mode.*/
5736 bonding_mode = rte_eth_bond_mode_get(port_id);
5737 if (bonding_mode < 0) {
5738 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5741 printf("\tBonding mode: %d\n", bonding_mode);
5743 if (bonding_mode == BONDING_MODE_BALANCE) {
5744 int balance_xmit_policy;
5746 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5747 if (balance_xmit_policy < 0) {
5748 printf("\tFailed to get balance xmit policy for port = %d\n",
5752 printf("\tBalance Xmit Policy: ");
5754 switch (balance_xmit_policy) {
5755 case BALANCE_XMIT_POLICY_LAYER2:
5756 printf("BALANCE_XMIT_POLICY_LAYER2");
5758 case BALANCE_XMIT_POLICY_LAYER23:
5759 printf("BALANCE_XMIT_POLICY_LAYER23");
5761 case BALANCE_XMIT_POLICY_LAYER34:
5762 printf("BALANCE_XMIT_POLICY_LAYER34");
5769 if (bonding_mode == BONDING_MODE_8023AD) {
5770 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5771 printf("\tIEEE802.3AD Aggregator Mode: ");
5774 printf("bandwidth");
5786 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5788 if (num_slaves < 0) {
5789 printf("\tFailed to get slave list for port = %d\n", port_id);
5792 if (num_slaves > 0) {
5793 printf("\tSlaves (%d): [", num_slaves);
5794 for (i = 0; i < num_slaves - 1; i++)
5795 printf("%d ", slaves[i]);
5797 printf("%d]\n", slaves[num_slaves - 1]);
5799 printf("\tSlaves: []\n");
5803 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5806 if (num_active_slaves < 0) {
5807 printf("\tFailed to get active slave list for port = %d\n", port_id);
5810 if (num_active_slaves > 0) {
5811 printf("\tActive Slaves (%d): [", num_active_slaves);
5812 for (i = 0; i < num_active_slaves - 1; i++)
5813 printf("%d ", slaves[i]);
5815 printf("%d]\n", slaves[num_active_slaves - 1]);
5818 printf("\tActive Slaves: []\n");
5822 primary_id = rte_eth_bond_primary_get(port_id);
5823 if (primary_id < 0) {
5824 printf("\tFailed to get primary slave for port = %d\n", port_id);
5827 printf("\tPrimary: [%d]\n", primary_id);
5831 cmdline_parse_token_string_t cmd_showbonding_config_show =
5832 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5834 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5835 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5836 bonding, "bonding");
5837 cmdline_parse_token_string_t cmd_showbonding_config_config =
5838 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5840 cmdline_parse_token_num_t cmd_showbonding_config_port =
5841 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5844 cmdline_parse_inst_t cmd_show_bonding_config = {
5845 .f = cmd_show_bonding_config_parsed,
5846 .help_str = "show bonding config <port_id>: "
5847 "Show the bonding config for port_id",
5850 (void *)&cmd_showbonding_config_show,
5851 (void *)&cmd_showbonding_config_bonding,
5852 (void *)&cmd_showbonding_config_config,
5853 (void *)&cmd_showbonding_config_port,
5858 /* *** SET BONDING PRIMARY *** */
5859 struct cmd_set_bonding_primary_result {
5860 cmdline_fixed_string_t set;
5861 cmdline_fixed_string_t bonding;
5862 cmdline_fixed_string_t primary;
5867 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5868 __attribute__((unused)) struct cmdline *cl,
5869 __attribute__((unused)) void *data)
5871 struct cmd_set_bonding_primary_result *res = parsed_result;
5872 portid_t master_port_id = res->port_id;
5873 portid_t slave_port_id = res->slave_id;
5875 /* Set the primary slave for a bonded device. */
5876 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5877 printf("\t Failed to set primary slave for port = %d.\n",
5884 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5885 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5887 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5888 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5889 bonding, "bonding");
5890 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5891 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5892 primary, "primary");
5893 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5894 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5896 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5897 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5900 cmdline_parse_inst_t cmd_set_bonding_primary = {
5901 .f = cmd_set_bonding_primary_parsed,
5902 .help_str = "set bonding primary <slave_id> <port_id>: "
5903 "Set the primary slave for port_id",
5906 (void *)&cmd_setbonding_primary_set,
5907 (void *)&cmd_setbonding_primary_bonding,
5908 (void *)&cmd_setbonding_primary_primary,
5909 (void *)&cmd_setbonding_primary_slave,
5910 (void *)&cmd_setbonding_primary_port,
5915 /* *** ADD SLAVE *** */
5916 struct cmd_add_bonding_slave_result {
5917 cmdline_fixed_string_t add;
5918 cmdline_fixed_string_t bonding;
5919 cmdline_fixed_string_t slave;
5924 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5925 __attribute__((unused)) struct cmdline *cl,
5926 __attribute__((unused)) void *data)
5928 struct cmd_add_bonding_slave_result *res = parsed_result;
5929 portid_t master_port_id = res->port_id;
5930 portid_t slave_port_id = res->slave_id;
5932 /* add the slave for a bonded device. */
5933 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5934 printf("\t Failed to add slave %d to master port = %d.\n",
5935 slave_port_id, master_port_id);
5939 set_port_slave_flag(slave_port_id);
5942 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5943 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5945 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5946 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5947 bonding, "bonding");
5948 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5949 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5951 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5952 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5954 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5955 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5958 cmdline_parse_inst_t cmd_add_bonding_slave = {
5959 .f = cmd_add_bonding_slave_parsed,
5960 .help_str = "add bonding slave <slave_id> <port_id>: "
5961 "Add a slave device to a bonded device",
5964 (void *)&cmd_addbonding_slave_add,
5965 (void *)&cmd_addbonding_slave_bonding,
5966 (void *)&cmd_addbonding_slave_slave,
5967 (void *)&cmd_addbonding_slave_slaveid,
5968 (void *)&cmd_addbonding_slave_port,
5973 /* *** REMOVE SLAVE *** */
5974 struct cmd_remove_bonding_slave_result {
5975 cmdline_fixed_string_t remove;
5976 cmdline_fixed_string_t bonding;
5977 cmdline_fixed_string_t slave;
5982 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5983 __attribute__((unused)) struct cmdline *cl,
5984 __attribute__((unused)) void *data)
5986 struct cmd_remove_bonding_slave_result *res = parsed_result;
5987 portid_t master_port_id = res->port_id;
5988 portid_t slave_port_id = res->slave_id;
5990 /* remove the slave from a bonded device. */
5991 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5992 printf("\t Failed to remove slave %d from master port = %d.\n",
5993 slave_port_id, master_port_id);
5997 clear_port_slave_flag(slave_port_id);
6000 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6001 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6003 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6004 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6005 bonding, "bonding");
6006 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6007 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6009 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6010 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6012 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6013 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6016 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6017 .f = cmd_remove_bonding_slave_parsed,
6018 .help_str = "remove bonding slave <slave_id> <port_id>: "
6019 "Remove a slave device from a bonded device",
6022 (void *)&cmd_removebonding_slave_remove,
6023 (void *)&cmd_removebonding_slave_bonding,
6024 (void *)&cmd_removebonding_slave_slave,
6025 (void *)&cmd_removebonding_slave_slaveid,
6026 (void *)&cmd_removebonding_slave_port,
6031 /* *** CREATE BONDED DEVICE *** */
6032 struct cmd_create_bonded_device_result {
6033 cmdline_fixed_string_t create;
6034 cmdline_fixed_string_t bonded;
6035 cmdline_fixed_string_t device;
6040 static int bond_dev_num = 0;
6042 static void cmd_create_bonded_device_parsed(void *parsed_result,
6043 __attribute__((unused)) struct cmdline *cl,
6044 __attribute__((unused)) void *data)
6046 struct cmd_create_bonded_device_result *res = parsed_result;
6047 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6050 if (test_done == 0) {
6051 printf("Please stop forwarding first\n");
6055 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6058 /* Create a new bonded device. */
6059 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6061 printf("\t Failed to create bonded device.\n");
6064 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6067 /* Update number of ports */
6068 nb_ports = rte_eth_dev_count_avail();
6069 reconfig(port_id, res->socket);
6070 rte_eth_promiscuous_enable(port_id);
6071 ports[port_id].need_setup = 0;
6072 ports[port_id].port_status = RTE_PORT_STOPPED;
6077 cmdline_parse_token_string_t cmd_createbonded_device_create =
6078 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6080 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6081 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6083 cmdline_parse_token_string_t cmd_createbonded_device_device =
6084 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6086 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6087 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6089 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6090 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6093 cmdline_parse_inst_t cmd_create_bonded_device = {
6094 .f = cmd_create_bonded_device_parsed,
6095 .help_str = "create bonded device <mode> <socket>: "
6096 "Create a new bonded device with specific bonding mode and socket",
6099 (void *)&cmd_createbonded_device_create,
6100 (void *)&cmd_createbonded_device_bonded,
6101 (void *)&cmd_createbonded_device_device,
6102 (void *)&cmd_createbonded_device_mode,
6103 (void *)&cmd_createbonded_device_socket,
6108 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6109 struct cmd_set_bond_mac_addr_result {
6110 cmdline_fixed_string_t set;
6111 cmdline_fixed_string_t bonding;
6112 cmdline_fixed_string_t mac_addr;
6114 struct rte_ether_addr address;
6117 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6118 __attribute__((unused)) struct cmdline *cl,
6119 __attribute__((unused)) void *data)
6121 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6124 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6127 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6129 /* check the return value and print it if is < 0 */
6131 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6134 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6135 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6136 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6137 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6139 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6140 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6142 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6143 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6145 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6146 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6148 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6149 .f = cmd_set_bond_mac_addr_parsed,
6151 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6153 (void *)&cmd_set_bond_mac_addr_set,
6154 (void *)&cmd_set_bond_mac_addr_bonding,
6155 (void *)&cmd_set_bond_mac_addr_mac,
6156 (void *)&cmd_set_bond_mac_addr_portnum,
6157 (void *)&cmd_set_bond_mac_addr_addr,
6163 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6164 struct cmd_set_bond_mon_period_result {
6165 cmdline_fixed_string_t set;
6166 cmdline_fixed_string_t bonding;
6167 cmdline_fixed_string_t mon_period;
6172 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6173 __attribute__((unused)) struct cmdline *cl,
6174 __attribute__((unused)) void *data)
6176 struct cmd_set_bond_mon_period_result *res = parsed_result;
6179 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6181 /* check the return value and print it if is < 0 */
6183 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6186 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6187 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6189 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6190 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6191 bonding, "bonding");
6192 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6193 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6194 mon_period, "mon_period");
6195 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6196 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6198 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6199 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6202 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6203 .f = cmd_set_bond_mon_period_parsed,
6205 .help_str = "set bonding mon_period <port_id> <period_ms>",
6207 (void *)&cmd_set_bond_mon_period_set,
6208 (void *)&cmd_set_bond_mon_period_bonding,
6209 (void *)&cmd_set_bond_mon_period_mon_period,
6210 (void *)&cmd_set_bond_mon_period_portnum,
6211 (void *)&cmd_set_bond_mon_period_period_ms,
6218 struct cmd_set_bonding_agg_mode_policy_result {
6219 cmdline_fixed_string_t set;
6220 cmdline_fixed_string_t bonding;
6221 cmdline_fixed_string_t agg_mode;
6223 cmdline_fixed_string_t policy;
6228 cmd_set_bonding_agg_mode(void *parsed_result,
6229 __attribute__((unused)) struct cmdline *cl,
6230 __attribute__((unused)) void *data)
6232 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6233 uint8_t policy = AGG_BANDWIDTH;
6235 if (!strcmp(res->policy, "bandwidth"))
6236 policy = AGG_BANDWIDTH;
6237 else if (!strcmp(res->policy, "stable"))
6238 policy = AGG_STABLE;
6239 else if (!strcmp(res->policy, "count"))
6242 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6246 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6247 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6249 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6250 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6251 bonding, "bonding");
6253 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6254 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6255 agg_mode, "agg_mode");
6257 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6258 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6261 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6262 TOKEN_STRING_INITIALIZER(
6263 struct cmd_set_bonding_balance_xmit_policy_result,
6264 policy, "stable#bandwidth#count");
6266 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6267 .f = cmd_set_bonding_agg_mode,
6269 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6271 (void *)&cmd_set_bonding_agg_mode_set,
6272 (void *)&cmd_set_bonding_agg_mode_bonding,
6273 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6274 (void *)&cmd_set_bonding_agg_mode_portnum,
6275 (void *)&cmd_set_bonding_agg_mode_policy_string,
6281 #endif /* RTE_LIBRTE_PMD_BOND */
6283 /* *** SET FORWARDING MODE *** */
6284 struct cmd_set_fwd_mode_result {
6285 cmdline_fixed_string_t set;
6286 cmdline_fixed_string_t fwd;
6287 cmdline_fixed_string_t mode;
6290 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6291 __attribute__((unused)) struct cmdline *cl,
6292 __attribute__((unused)) void *data)
6294 struct cmd_set_fwd_mode_result *res = parsed_result;
6297 set_pkt_forwarding_mode(res->mode);
6300 cmdline_parse_token_string_t cmd_setfwd_set =
6301 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6302 cmdline_parse_token_string_t cmd_setfwd_fwd =
6303 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6304 cmdline_parse_token_string_t cmd_setfwd_mode =
6305 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6306 "" /* defined at init */);
6308 cmdline_parse_inst_t cmd_set_fwd_mode = {
6309 .f = cmd_set_fwd_mode_parsed,
6311 .help_str = NULL, /* defined at init */
6313 (void *)&cmd_setfwd_set,
6314 (void *)&cmd_setfwd_fwd,
6315 (void *)&cmd_setfwd_mode,
6320 static void cmd_set_fwd_mode_init(void)
6323 static char token[128];
6324 static char help[256];
6325 cmdline_parse_token_string_t *token_struct;
6327 modes = list_pkt_forwarding_modes();
6328 snprintf(help, sizeof(help), "set fwd %s: "
6329 "Set packet forwarding mode", modes);
6330 cmd_set_fwd_mode.help_str = help;
6332 /* string token separator is # */
6333 for (c = token; *modes != '\0'; modes++)
6338 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6339 token_struct->string_data.str = token;
6342 /* *** SET RETRY FORWARDING MODE *** */
6343 struct cmd_set_fwd_retry_mode_result {
6344 cmdline_fixed_string_t set;
6345 cmdline_fixed_string_t fwd;
6346 cmdline_fixed_string_t mode;
6347 cmdline_fixed_string_t retry;
6350 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6351 __attribute__((unused)) struct cmdline *cl,
6352 __attribute__((unused)) void *data)
6354 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6357 set_pkt_forwarding_mode(res->mode);
6360 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6361 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6363 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6364 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6366 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6367 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6369 "" /* defined at init */);
6370 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6371 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6374 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6375 .f = cmd_set_fwd_retry_mode_parsed,
6377 .help_str = NULL, /* defined at init */
6379 (void *)&cmd_setfwd_retry_set,
6380 (void *)&cmd_setfwd_retry_fwd,
6381 (void *)&cmd_setfwd_retry_mode,
6382 (void *)&cmd_setfwd_retry_retry,
6387 static void cmd_set_fwd_retry_mode_init(void)
6390 static char token[128];
6391 static char help[256];
6392 cmdline_parse_token_string_t *token_struct;
6394 modes = list_pkt_forwarding_retry_modes();
6395 snprintf(help, sizeof(help), "set fwd %s retry: "
6396 "Set packet forwarding mode with retry", modes);
6397 cmd_set_fwd_retry_mode.help_str = help;
6399 /* string token separator is # */
6400 for (c = token; *modes != '\0'; modes++)
6405 token_struct = (cmdline_parse_token_string_t *)
6406 cmd_set_fwd_retry_mode.tokens[2];
6407 token_struct->string_data.str = token;
6410 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6411 struct cmd_set_burst_tx_retry_result {
6412 cmdline_fixed_string_t set;
6413 cmdline_fixed_string_t burst;
6414 cmdline_fixed_string_t tx;
6415 cmdline_fixed_string_t delay;
6417 cmdline_fixed_string_t retry;
6421 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6422 __attribute__((unused)) struct cmdline *cl,
6423 __attribute__((unused)) void *data)
6425 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6427 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6428 && !strcmp(res->tx, "tx")) {
6429 if (!strcmp(res->delay, "delay"))
6430 burst_tx_delay_time = res->time;
6431 if (!strcmp(res->retry, "retry"))
6432 burst_tx_retry_num = res->retry_num;
6437 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6438 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6439 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6440 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6442 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6443 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6444 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6445 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6446 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6447 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6448 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6449 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6450 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6451 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6453 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6454 .f = cmd_set_burst_tx_retry_parsed,
6455 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6457 (void *)&cmd_set_burst_tx_retry_set,
6458 (void *)&cmd_set_burst_tx_retry_burst,
6459 (void *)&cmd_set_burst_tx_retry_tx,
6460 (void *)&cmd_set_burst_tx_retry_delay,
6461 (void *)&cmd_set_burst_tx_retry_time,
6462 (void *)&cmd_set_burst_tx_retry_retry,
6463 (void *)&cmd_set_burst_tx_retry_retry_num,
6468 /* *** SET PROMISC MODE *** */
6469 struct cmd_set_promisc_mode_result {
6470 cmdline_fixed_string_t set;
6471 cmdline_fixed_string_t promisc;
6472 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6473 uint16_t port_num; /* valid if "allports" argument == 0 */
6474 cmdline_fixed_string_t mode;
6477 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6478 __attribute__((unused)) struct cmdline *cl,
6481 struct cmd_set_promisc_mode_result *res = parsed_result;
6485 if (!strcmp(res->mode, "on"))
6492 RTE_ETH_FOREACH_DEV(i) {
6494 rte_eth_promiscuous_enable(i);
6496 rte_eth_promiscuous_disable(i);
6501 rte_eth_promiscuous_enable(res->port_num);
6503 rte_eth_promiscuous_disable(res->port_num);
6507 cmdline_parse_token_string_t cmd_setpromisc_set =
6508 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6509 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6510 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6512 cmdline_parse_token_string_t cmd_setpromisc_portall =
6513 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6515 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6516 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6518 cmdline_parse_token_string_t cmd_setpromisc_mode =
6519 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6522 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6523 .f = cmd_set_promisc_mode_parsed,
6525 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6527 (void *)&cmd_setpromisc_set,
6528 (void *)&cmd_setpromisc_promisc,
6529 (void *)&cmd_setpromisc_portall,
6530 (void *)&cmd_setpromisc_mode,
6535 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6536 .f = cmd_set_promisc_mode_parsed,
6538 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6540 (void *)&cmd_setpromisc_set,
6541 (void *)&cmd_setpromisc_promisc,
6542 (void *)&cmd_setpromisc_portnum,
6543 (void *)&cmd_setpromisc_mode,
6548 /* *** SET ALLMULTI MODE *** */
6549 struct cmd_set_allmulti_mode_result {
6550 cmdline_fixed_string_t set;
6551 cmdline_fixed_string_t allmulti;
6552 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6553 uint16_t port_num; /* valid if "allports" argument == 0 */
6554 cmdline_fixed_string_t mode;
6557 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6558 __attribute__((unused)) struct cmdline *cl,
6561 struct cmd_set_allmulti_mode_result *res = parsed_result;
6565 if (!strcmp(res->mode, "on"))
6572 RTE_ETH_FOREACH_DEV(i) {
6574 rte_eth_allmulticast_enable(i);
6576 rte_eth_allmulticast_disable(i);
6581 rte_eth_allmulticast_enable(res->port_num);
6583 rte_eth_allmulticast_disable(res->port_num);
6587 cmdline_parse_token_string_t cmd_setallmulti_set =
6588 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6589 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6590 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6592 cmdline_parse_token_string_t cmd_setallmulti_portall =
6593 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6595 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6596 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6598 cmdline_parse_token_string_t cmd_setallmulti_mode =
6599 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6602 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6603 .f = cmd_set_allmulti_mode_parsed,
6605 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6607 (void *)&cmd_setallmulti_set,
6608 (void *)&cmd_setallmulti_allmulti,
6609 (void *)&cmd_setallmulti_portall,
6610 (void *)&cmd_setallmulti_mode,
6615 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6616 .f = cmd_set_allmulti_mode_parsed,
6618 .help_str = "set allmulti <port_id> on|off: "
6619 "Set allmulti mode on port_id",
6621 (void *)&cmd_setallmulti_set,
6622 (void *)&cmd_setallmulti_allmulti,
6623 (void *)&cmd_setallmulti_portnum,
6624 (void *)&cmd_setallmulti_mode,
6629 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6630 struct cmd_link_flow_ctrl_set_result {
6631 cmdline_fixed_string_t set;
6632 cmdline_fixed_string_t flow_ctrl;
6633 cmdline_fixed_string_t rx;
6634 cmdline_fixed_string_t rx_lfc_mode;
6635 cmdline_fixed_string_t tx;
6636 cmdline_fixed_string_t tx_lfc_mode;
6637 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6638 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6639 cmdline_fixed_string_t autoneg_str;
6640 cmdline_fixed_string_t autoneg;
6641 cmdline_fixed_string_t hw_str;
6642 uint32_t high_water;
6643 cmdline_fixed_string_t lw_str;
6645 cmdline_fixed_string_t pt_str;
6646 uint16_t pause_time;
6647 cmdline_fixed_string_t xon_str;
6652 cmdline_parse_token_string_t cmd_lfc_set_set =
6653 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6655 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6656 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6657 flow_ctrl, "flow_ctrl");
6658 cmdline_parse_token_string_t cmd_lfc_set_rx =
6659 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6661 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6662 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6663 rx_lfc_mode, "on#off");
6664 cmdline_parse_token_string_t cmd_lfc_set_tx =
6665 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6667 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6668 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6669 tx_lfc_mode, "on#off");
6670 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6671 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6672 hw_str, "high_water");
6673 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6674 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6675 high_water, UINT32);
6676 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6677 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6678 lw_str, "low_water");
6679 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6680 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6682 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6683 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6684 pt_str, "pause_time");
6685 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6686 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6687 pause_time, UINT16);
6688 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6689 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6690 xon_str, "send_xon");
6691 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6692 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6694 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6695 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6696 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6697 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6698 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6699 mac_ctrl_frame_fwd_mode, "on#off");
6700 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6701 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6702 autoneg_str, "autoneg");
6703 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6704 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6706 cmdline_parse_token_num_t cmd_lfc_set_portid =
6707 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6710 /* forward declaration */
6712 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6715 cmdline_parse_inst_t cmd_link_flow_control_set = {
6716 .f = cmd_link_flow_ctrl_set_parsed,
6718 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6719 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6720 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6722 (void *)&cmd_lfc_set_set,
6723 (void *)&cmd_lfc_set_flow_ctrl,
6724 (void *)&cmd_lfc_set_rx,
6725 (void *)&cmd_lfc_set_rx_mode,
6726 (void *)&cmd_lfc_set_tx,
6727 (void *)&cmd_lfc_set_tx_mode,
6728 (void *)&cmd_lfc_set_high_water,
6729 (void *)&cmd_lfc_set_low_water,
6730 (void *)&cmd_lfc_set_pause_time,
6731 (void *)&cmd_lfc_set_send_xon,
6732 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6733 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6734 (void *)&cmd_lfc_set_autoneg_str,
6735 (void *)&cmd_lfc_set_autoneg,
6736 (void *)&cmd_lfc_set_portid,
6741 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6742 .f = cmd_link_flow_ctrl_set_parsed,
6743 .data = (void *)&cmd_link_flow_control_set_rx,
6744 .help_str = "set flow_ctrl rx on|off <port_id>: "
6745 "Change rx flow control parameter",
6747 (void *)&cmd_lfc_set_set,
6748 (void *)&cmd_lfc_set_flow_ctrl,
6749 (void *)&cmd_lfc_set_rx,
6750 (void *)&cmd_lfc_set_rx_mode,
6751 (void *)&cmd_lfc_set_portid,
6756 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6757 .f = cmd_link_flow_ctrl_set_parsed,
6758 .data = (void *)&cmd_link_flow_control_set_tx,
6759 .help_str = "set flow_ctrl tx on|off <port_id>: "
6760 "Change tx flow control parameter",
6762 (void *)&cmd_lfc_set_set,
6763 (void *)&cmd_lfc_set_flow_ctrl,
6764 (void *)&cmd_lfc_set_tx,
6765 (void *)&cmd_lfc_set_tx_mode,
6766 (void *)&cmd_lfc_set_portid,
6771 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6772 .f = cmd_link_flow_ctrl_set_parsed,
6773 .data = (void *)&cmd_link_flow_control_set_hw,
6774 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6775 "Change high water flow control parameter",
6777 (void *)&cmd_lfc_set_set,
6778 (void *)&cmd_lfc_set_flow_ctrl,
6779 (void *)&cmd_lfc_set_high_water_str,
6780 (void *)&cmd_lfc_set_high_water,
6781 (void *)&cmd_lfc_set_portid,
6786 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6787 .f = cmd_link_flow_ctrl_set_parsed,
6788 .data = (void *)&cmd_link_flow_control_set_lw,
6789 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6790 "Change low water flow control parameter",
6792 (void *)&cmd_lfc_set_set,
6793 (void *)&cmd_lfc_set_flow_ctrl,
6794 (void *)&cmd_lfc_set_low_water_str,
6795 (void *)&cmd_lfc_set_low_water,
6796 (void *)&cmd_lfc_set_portid,
6801 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6802 .f = cmd_link_flow_ctrl_set_parsed,
6803 .data = (void *)&cmd_link_flow_control_set_pt,
6804 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6805 "Change pause time flow control parameter",
6807 (void *)&cmd_lfc_set_set,
6808 (void *)&cmd_lfc_set_flow_ctrl,
6809 (void *)&cmd_lfc_set_pause_time_str,
6810 (void *)&cmd_lfc_set_pause_time,
6811 (void *)&cmd_lfc_set_portid,
6816 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6817 .f = cmd_link_flow_ctrl_set_parsed,
6818 .data = (void *)&cmd_link_flow_control_set_xon,
6819 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6820 "Change send_xon flow control parameter",
6822 (void *)&cmd_lfc_set_set,
6823 (void *)&cmd_lfc_set_flow_ctrl,
6824 (void *)&cmd_lfc_set_send_xon_str,
6825 (void *)&cmd_lfc_set_send_xon,
6826 (void *)&cmd_lfc_set_portid,
6831 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6832 .f = cmd_link_flow_ctrl_set_parsed,
6833 .data = (void *)&cmd_link_flow_control_set_macfwd,
6834 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6835 "Change mac ctrl fwd flow control parameter",
6837 (void *)&cmd_lfc_set_set,
6838 (void *)&cmd_lfc_set_flow_ctrl,
6839 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6840 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6841 (void *)&cmd_lfc_set_portid,
6846 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6847 .f = cmd_link_flow_ctrl_set_parsed,
6848 .data = (void *)&cmd_link_flow_control_set_autoneg,
6849 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6850 "Change autoneg flow control parameter",
6852 (void *)&cmd_lfc_set_set,
6853 (void *)&cmd_lfc_set_flow_ctrl,
6854 (void *)&cmd_lfc_set_autoneg_str,
6855 (void *)&cmd_lfc_set_autoneg,
6856 (void *)&cmd_lfc_set_portid,
6862 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6863 __attribute__((unused)) struct cmdline *cl,
6866 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6867 cmdline_parse_inst_t *cmd = data;
6868 struct rte_eth_fc_conf fc_conf;
6874 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6875 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6876 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6877 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6879 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6880 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6883 /* Partial command line, retrieve current configuration */
6885 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6887 printf("cannot get current flow ctrl parameters, return"
6888 "code = %d\n", ret);
6892 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6893 (fc_conf.mode == RTE_FC_FULL))
6895 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6896 (fc_conf.mode == RTE_FC_FULL))
6900 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6901 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6903 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6904 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6906 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6908 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6909 fc_conf.high_water = res->high_water;
6911 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6912 fc_conf.low_water = res->low_water;
6914 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6915 fc_conf.pause_time = res->pause_time;
6917 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6918 fc_conf.send_xon = res->send_xon;
6920 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6921 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6922 fc_conf.mac_ctrl_frame_fwd = 1;
6924 fc_conf.mac_ctrl_frame_fwd = 0;
6927 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6928 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6930 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6932 printf("bad flow contrl parameter, return code = %d \n", ret);
6935 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6936 struct cmd_priority_flow_ctrl_set_result {
6937 cmdline_fixed_string_t set;
6938 cmdline_fixed_string_t pfc_ctrl;
6939 cmdline_fixed_string_t rx;
6940 cmdline_fixed_string_t rx_pfc_mode;
6941 cmdline_fixed_string_t tx;
6942 cmdline_fixed_string_t tx_pfc_mode;
6943 uint32_t high_water;
6945 uint16_t pause_time;
6951 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6952 __attribute__((unused)) struct cmdline *cl,
6953 __attribute__((unused)) void *data)
6955 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6956 struct rte_eth_pfc_conf pfc_conf;
6957 int rx_fc_enable, tx_fc_enable;
6961 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6962 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6963 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6964 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6966 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6967 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6970 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6971 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6972 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6973 pfc_conf.fc.high_water = res->high_water;
6974 pfc_conf.fc.low_water = res->low_water;
6975 pfc_conf.fc.pause_time = res->pause_time;
6976 pfc_conf.priority = res->priority;
6978 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6980 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6983 cmdline_parse_token_string_t cmd_pfc_set_set =
6984 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6986 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6987 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6988 pfc_ctrl, "pfc_ctrl");
6989 cmdline_parse_token_string_t cmd_pfc_set_rx =
6990 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6992 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6993 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6994 rx_pfc_mode, "on#off");
6995 cmdline_parse_token_string_t cmd_pfc_set_tx =
6996 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6998 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6999 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7000 tx_pfc_mode, "on#off");
7001 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7002 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7003 high_water, UINT32);
7004 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7005 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7007 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7008 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7009 pause_time, UINT16);
7010 cmdline_parse_token_num_t cmd_pfc_set_priority =
7011 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7013 cmdline_parse_token_num_t cmd_pfc_set_portid =
7014 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7017 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7018 .f = cmd_priority_flow_ctrl_set_parsed,
7020 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7021 "<pause_time> <priority> <port_id>: "
7022 "Configure the Ethernet priority flow control",
7024 (void *)&cmd_pfc_set_set,
7025 (void *)&cmd_pfc_set_flow_ctrl,
7026 (void *)&cmd_pfc_set_rx,
7027 (void *)&cmd_pfc_set_rx_mode,
7028 (void *)&cmd_pfc_set_tx,
7029 (void *)&cmd_pfc_set_tx_mode,
7030 (void *)&cmd_pfc_set_high_water,
7031 (void *)&cmd_pfc_set_low_water,
7032 (void *)&cmd_pfc_set_pause_time,
7033 (void *)&cmd_pfc_set_priority,
7034 (void *)&cmd_pfc_set_portid,
7039 /* *** RESET CONFIGURATION *** */
7040 struct cmd_reset_result {
7041 cmdline_fixed_string_t reset;
7042 cmdline_fixed_string_t def;
7045 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
7047 __attribute__((unused)) void *data)
7049 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7050 set_def_fwd_config();
7053 cmdline_parse_token_string_t cmd_reset_set =
7054 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7055 cmdline_parse_token_string_t cmd_reset_def =
7056 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7059 cmdline_parse_inst_t cmd_reset = {
7060 .f = cmd_reset_parsed,
7062 .help_str = "set default: Reset default forwarding configuration",
7064 (void *)&cmd_reset_set,
7065 (void *)&cmd_reset_def,
7070 /* *** START FORWARDING *** */
7071 struct cmd_start_result {
7072 cmdline_fixed_string_t start;
7075 cmdline_parse_token_string_t cmd_start_start =
7076 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7078 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
7079 __attribute__((unused)) struct cmdline *cl,
7080 __attribute__((unused)) void *data)
7082 start_packet_forwarding(0);
7085 cmdline_parse_inst_t cmd_start = {
7086 .f = cmd_start_parsed,
7088 .help_str = "start: Start packet forwarding",
7090 (void *)&cmd_start_start,
7095 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7096 struct cmd_start_tx_first_result {
7097 cmdline_fixed_string_t start;
7098 cmdline_fixed_string_t tx_first;
7102 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
7103 __attribute__((unused)) struct cmdline *cl,
7104 __attribute__((unused)) void *data)
7106 start_packet_forwarding(1);
7109 cmdline_parse_token_string_t cmd_start_tx_first_start =
7110 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7112 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7113 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7114 tx_first, "tx_first");
7116 cmdline_parse_inst_t cmd_start_tx_first = {
7117 .f = cmd_start_tx_first_parsed,
7119 .help_str = "start tx_first: Start packet forwarding, "
7120 "after sending 1 burst of packets",
7122 (void *)&cmd_start_tx_first_start,
7123 (void *)&cmd_start_tx_first_tx_first,
7128 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7129 struct cmd_start_tx_first_n_result {
7130 cmdline_fixed_string_t start;
7131 cmdline_fixed_string_t tx_first;
7136 cmd_start_tx_first_n_parsed(void *parsed_result,
7137 __attribute__((unused)) struct cmdline *cl,
7138 __attribute__((unused)) void *data)
7140 struct cmd_start_tx_first_n_result *res = parsed_result;
7142 start_packet_forwarding(res->tx_num);
7145 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7146 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7148 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7149 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7150 tx_first, "tx_first");
7151 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7152 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7155 cmdline_parse_inst_t cmd_start_tx_first_n = {
7156 .f = cmd_start_tx_first_n_parsed,
7158 .help_str = "start tx_first <num>: "
7159 "packet forwarding, after sending <num> bursts of packets",
7161 (void *)&cmd_start_tx_first_n_start,
7162 (void *)&cmd_start_tx_first_n_tx_first,
7163 (void *)&cmd_start_tx_first_n_tx_num,
7168 /* *** SET LINK UP *** */
7169 struct cmd_set_link_up_result {
7170 cmdline_fixed_string_t set;
7171 cmdline_fixed_string_t link_up;
7172 cmdline_fixed_string_t port;
7176 cmdline_parse_token_string_t cmd_set_link_up_set =
7177 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7178 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7179 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7181 cmdline_parse_token_string_t cmd_set_link_up_port =
7182 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7183 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7184 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7186 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
7187 __attribute__((unused)) struct cmdline *cl,
7188 __attribute__((unused)) void *data)
7190 struct cmd_set_link_up_result *res = parsed_result;
7191 dev_set_link_up(res->port_id);
7194 cmdline_parse_inst_t cmd_set_link_up = {
7195 .f = cmd_set_link_up_parsed,
7197 .help_str = "set link-up port <port id>",
7199 (void *)&cmd_set_link_up_set,
7200 (void *)&cmd_set_link_up_link_up,
7201 (void *)&cmd_set_link_up_port,
7202 (void *)&cmd_set_link_up_port_id,
7207 /* *** SET LINK DOWN *** */
7208 struct cmd_set_link_down_result {
7209 cmdline_fixed_string_t set;
7210 cmdline_fixed_string_t link_down;
7211 cmdline_fixed_string_t port;
7215 cmdline_parse_token_string_t cmd_set_link_down_set =
7216 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7217 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7218 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7220 cmdline_parse_token_string_t cmd_set_link_down_port =
7221 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7222 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7223 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7225 static void cmd_set_link_down_parsed(
7226 __attribute__((unused)) void *parsed_result,
7227 __attribute__((unused)) struct cmdline *cl,
7228 __attribute__((unused)) void *data)
7230 struct cmd_set_link_down_result *res = parsed_result;
7231 dev_set_link_down(res->port_id);
7234 cmdline_parse_inst_t cmd_set_link_down = {
7235 .f = cmd_set_link_down_parsed,
7237 .help_str = "set link-down port <port id>",
7239 (void *)&cmd_set_link_down_set,
7240 (void *)&cmd_set_link_down_link_down,
7241 (void *)&cmd_set_link_down_port,
7242 (void *)&cmd_set_link_down_port_id,
7247 /* *** SHOW CFG *** */
7248 struct cmd_showcfg_result {
7249 cmdline_fixed_string_t show;
7250 cmdline_fixed_string_t cfg;
7251 cmdline_fixed_string_t what;
7254 static void cmd_showcfg_parsed(void *parsed_result,
7255 __attribute__((unused)) struct cmdline *cl,
7256 __attribute__((unused)) void *data)
7258 struct cmd_showcfg_result *res = parsed_result;
7259 if (!strcmp(res->what, "rxtx"))
7260 rxtx_config_display();
7261 else if (!strcmp(res->what, "cores"))
7262 fwd_lcores_config_display();
7263 else if (!strcmp(res->what, "fwd"))
7264 pkt_fwd_config_display(&cur_fwd_config);
7265 else if (!strcmp(res->what, "txpkts"))
7266 show_tx_pkt_segments();
7269 cmdline_parse_token_string_t cmd_showcfg_show =
7270 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7271 cmdline_parse_token_string_t cmd_showcfg_port =
7272 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7273 cmdline_parse_token_string_t cmd_showcfg_what =
7274 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7275 "rxtx#cores#fwd#txpkts");
7277 cmdline_parse_inst_t cmd_showcfg = {
7278 .f = cmd_showcfg_parsed,
7280 .help_str = "show config rxtx|cores|fwd|txpkts",
7282 (void *)&cmd_showcfg_show,
7283 (void *)&cmd_showcfg_port,
7284 (void *)&cmd_showcfg_what,
7289 /* *** SHOW ALL PORT INFO *** */
7290 struct cmd_showportall_result {
7291 cmdline_fixed_string_t show;
7292 cmdline_fixed_string_t port;
7293 cmdline_fixed_string_t what;
7294 cmdline_fixed_string_t all;
7297 static void cmd_showportall_parsed(void *parsed_result,
7298 __attribute__((unused)) struct cmdline *cl,
7299 __attribute__((unused)) void *data)
7303 struct cmd_showportall_result *res = parsed_result;
7304 if (!strcmp(res->show, "clear")) {
7305 if (!strcmp(res->what, "stats"))
7306 RTE_ETH_FOREACH_DEV(i)
7308 else if (!strcmp(res->what, "xstats"))
7309 RTE_ETH_FOREACH_DEV(i)
7310 nic_xstats_clear(i);
7311 } else if (!strcmp(res->what, "info"))
7312 RTE_ETH_FOREACH_DEV(i)
7313 port_infos_display(i);
7314 else if (!strcmp(res->what, "summary")) {
7315 port_summary_header_display();
7316 RTE_ETH_FOREACH_DEV(i)
7317 port_summary_display(i);
7319 else if (!strcmp(res->what, "stats"))
7320 RTE_ETH_FOREACH_DEV(i)
7321 nic_stats_display(i);
7322 else if (!strcmp(res->what, "xstats"))
7323 RTE_ETH_FOREACH_DEV(i)
7324 nic_xstats_display(i);
7325 else if (!strcmp(res->what, "fdir"))
7326 RTE_ETH_FOREACH_DEV(i)
7328 else if (!strcmp(res->what, "stat_qmap"))
7329 RTE_ETH_FOREACH_DEV(i)
7330 nic_stats_mapping_display(i);
7331 else if (!strcmp(res->what, "dcb_tc"))
7332 RTE_ETH_FOREACH_DEV(i)
7333 port_dcb_info_display(i);
7334 else if (!strcmp(res->what, "cap"))
7335 RTE_ETH_FOREACH_DEV(i)
7336 port_offload_cap_display(i);
7339 cmdline_parse_token_string_t cmd_showportall_show =
7340 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7342 cmdline_parse_token_string_t cmd_showportall_port =
7343 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7344 cmdline_parse_token_string_t cmd_showportall_what =
7345 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7346 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7347 cmdline_parse_token_string_t cmd_showportall_all =
7348 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7349 cmdline_parse_inst_t cmd_showportall = {
7350 .f = cmd_showportall_parsed,
7352 .help_str = "show|clear port "
7353 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7355 (void *)&cmd_showportall_show,
7356 (void *)&cmd_showportall_port,
7357 (void *)&cmd_showportall_what,
7358 (void *)&cmd_showportall_all,
7363 /* *** SHOW PORT INFO *** */
7364 struct cmd_showport_result {
7365 cmdline_fixed_string_t show;
7366 cmdline_fixed_string_t port;
7367 cmdline_fixed_string_t what;
7371 static void cmd_showport_parsed(void *parsed_result,
7372 __attribute__((unused)) struct cmdline *cl,
7373 __attribute__((unused)) void *data)
7375 struct cmd_showport_result *res = parsed_result;
7376 if (!strcmp(res->show, "clear")) {
7377 if (!strcmp(res->what, "stats"))
7378 nic_stats_clear(res->portnum);
7379 else if (!strcmp(res->what, "xstats"))
7380 nic_xstats_clear(res->portnum);
7381 } else if (!strcmp(res->what, "info"))
7382 port_infos_display(res->portnum);
7383 else if (!strcmp(res->what, "summary")) {
7384 port_summary_header_display();
7385 port_summary_display(res->portnum);
7387 else if (!strcmp(res->what, "stats"))
7388 nic_stats_display(res->portnum);
7389 else if (!strcmp(res->what, "xstats"))
7390 nic_xstats_display(res->portnum);
7391 else if (!strcmp(res->what, "fdir"))
7392 fdir_get_infos(res->portnum);
7393 else if (!strcmp(res->what, "stat_qmap"))
7394 nic_stats_mapping_display(res->portnum);
7395 else if (!strcmp(res->what, "dcb_tc"))
7396 port_dcb_info_display(res->portnum);
7397 else if (!strcmp(res->what, "cap"))
7398 port_offload_cap_display(res->portnum);
7401 cmdline_parse_token_string_t cmd_showport_show =
7402 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7404 cmdline_parse_token_string_t cmd_showport_port =
7405 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7406 cmdline_parse_token_string_t cmd_showport_what =
7407 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7408 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7409 cmdline_parse_token_num_t cmd_showport_portnum =
7410 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7412 cmdline_parse_inst_t cmd_showport = {
7413 .f = cmd_showport_parsed,
7415 .help_str = "show|clear port "
7416 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7419 (void *)&cmd_showport_show,
7420 (void *)&cmd_showport_port,
7421 (void *)&cmd_showport_what,
7422 (void *)&cmd_showport_portnum,
7427 /* *** SHOW DEVICE INFO *** */
7428 struct cmd_showdevice_result {
7429 cmdline_fixed_string_t show;
7430 cmdline_fixed_string_t device;
7431 cmdline_fixed_string_t what;
7432 cmdline_fixed_string_t identifier;
7435 static void cmd_showdevice_parsed(void *parsed_result,
7436 __attribute__((unused)) struct cmdline *cl,
7437 __attribute__((unused)) void *data)
7439 struct cmd_showdevice_result *res = parsed_result;
7440 if (!strcmp(res->what, "info")) {
7441 if (!strcmp(res->identifier, "all"))
7442 device_infos_display(NULL);
7444 device_infos_display(res->identifier);
7448 cmdline_parse_token_string_t cmd_showdevice_show =
7449 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7451 cmdline_parse_token_string_t cmd_showdevice_device =
7452 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7453 cmdline_parse_token_string_t cmd_showdevice_what =
7454 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7456 cmdline_parse_token_string_t cmd_showdevice_identifier =
7457 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7460 cmdline_parse_inst_t cmd_showdevice = {
7461 .f = cmd_showdevice_parsed,
7463 .help_str = "show device info <identifier>|all",
7465 (void *)&cmd_showdevice_show,
7466 (void *)&cmd_showdevice_device,
7467 (void *)&cmd_showdevice_what,
7468 (void *)&cmd_showdevice_identifier,
7472 /* *** SHOW QUEUE INFO *** */
7473 struct cmd_showqueue_result {
7474 cmdline_fixed_string_t show;
7475 cmdline_fixed_string_t type;
7476 cmdline_fixed_string_t what;
7482 cmd_showqueue_parsed(void *parsed_result,
7483 __attribute__((unused)) struct cmdline *cl,
7484 __attribute__((unused)) void *data)
7486 struct cmd_showqueue_result *res = parsed_result;
7488 if (!strcmp(res->type, "rxq"))
7489 rx_queue_infos_display(res->portnum, res->queuenum);
7490 else if (!strcmp(res->type, "txq"))
7491 tx_queue_infos_display(res->portnum, res->queuenum);
7494 cmdline_parse_token_string_t cmd_showqueue_show =
7495 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7496 cmdline_parse_token_string_t cmd_showqueue_type =
7497 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7498 cmdline_parse_token_string_t cmd_showqueue_what =
7499 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7500 cmdline_parse_token_num_t cmd_showqueue_portnum =
7501 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7502 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7503 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7505 cmdline_parse_inst_t cmd_showqueue = {
7506 .f = cmd_showqueue_parsed,
7508 .help_str = "show rxq|txq info <port_id> <queue_id>",
7510 (void *)&cmd_showqueue_show,
7511 (void *)&cmd_showqueue_type,
7512 (void *)&cmd_showqueue_what,
7513 (void *)&cmd_showqueue_portnum,
7514 (void *)&cmd_showqueue_queuenum,
7519 /* show/clear fwd engine statistics */
7521 cmdline_fixed_string_t action;
7522 cmdline_fixed_string_t fwd;
7523 cmdline_fixed_string_t stats;
7524 cmdline_fixed_string_t all;
7527 cmdline_parse_token_string_t cmd_fwd_action =
7528 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7529 cmdline_parse_token_string_t cmd_fwd_fwd =
7530 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7531 cmdline_parse_token_string_t cmd_fwd_stats =
7532 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7533 cmdline_parse_token_string_t cmd_fwd_all =
7534 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7537 cmd_showfwdall_parsed(void *parsed_result,
7538 __rte_unused struct cmdline *cl,
7539 __rte_unused void *data)
7541 struct fwd_result *res = parsed_result;
7543 if (!strcmp(res->action, "show"))
7544 fwd_stats_display();
7549 static cmdline_parse_inst_t cmd_showfwdall = {
7550 .f = cmd_showfwdall_parsed,
7552 .help_str = "show|clear fwd stats all",
7554 (void *)&cmd_fwd_action,
7555 (void *)&cmd_fwd_fwd,
7556 (void *)&cmd_fwd_stats,
7557 (void *)&cmd_fwd_all,
7562 /* *** READ PORT REGISTER *** */
7563 struct cmd_read_reg_result {
7564 cmdline_fixed_string_t read;
7565 cmdline_fixed_string_t reg;
7571 cmd_read_reg_parsed(void *parsed_result,
7572 __attribute__((unused)) struct cmdline *cl,
7573 __attribute__((unused)) void *data)
7575 struct cmd_read_reg_result *res = parsed_result;
7576 port_reg_display(res->port_id, res->reg_off);
7579 cmdline_parse_token_string_t cmd_read_reg_read =
7580 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7581 cmdline_parse_token_string_t cmd_read_reg_reg =
7582 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7583 cmdline_parse_token_num_t cmd_read_reg_port_id =
7584 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7585 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7586 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7588 cmdline_parse_inst_t cmd_read_reg = {
7589 .f = cmd_read_reg_parsed,
7591 .help_str = "read reg <port_id> <reg_off>",
7593 (void *)&cmd_read_reg_read,
7594 (void *)&cmd_read_reg_reg,
7595 (void *)&cmd_read_reg_port_id,
7596 (void *)&cmd_read_reg_reg_off,
7601 /* *** READ PORT REGISTER BIT FIELD *** */
7602 struct cmd_read_reg_bit_field_result {
7603 cmdline_fixed_string_t read;
7604 cmdline_fixed_string_t regfield;
7612 cmd_read_reg_bit_field_parsed(void *parsed_result,
7613 __attribute__((unused)) struct cmdline *cl,
7614 __attribute__((unused)) void *data)
7616 struct cmd_read_reg_bit_field_result *res = parsed_result;
7617 port_reg_bit_field_display(res->port_id, res->reg_off,
7618 res->bit1_pos, res->bit2_pos);
7621 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7622 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7624 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7625 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7626 regfield, "regfield");
7627 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7628 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7630 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7631 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7633 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7634 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7636 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7637 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7640 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7641 .f = cmd_read_reg_bit_field_parsed,
7643 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7644 "Read register bit field between bit_x and bit_y included",
7646 (void *)&cmd_read_reg_bit_field_read,
7647 (void *)&cmd_read_reg_bit_field_regfield,
7648 (void *)&cmd_read_reg_bit_field_port_id,
7649 (void *)&cmd_read_reg_bit_field_reg_off,
7650 (void *)&cmd_read_reg_bit_field_bit1_pos,
7651 (void *)&cmd_read_reg_bit_field_bit2_pos,
7656 /* *** READ PORT REGISTER BIT *** */
7657 struct cmd_read_reg_bit_result {
7658 cmdline_fixed_string_t read;
7659 cmdline_fixed_string_t regbit;
7666 cmd_read_reg_bit_parsed(void *parsed_result,
7667 __attribute__((unused)) struct cmdline *cl,
7668 __attribute__((unused)) void *data)
7670 struct cmd_read_reg_bit_result *res = parsed_result;
7671 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7674 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7675 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7676 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7677 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7679 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7680 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7681 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7682 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7683 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7684 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7686 cmdline_parse_inst_t cmd_read_reg_bit = {
7687 .f = cmd_read_reg_bit_parsed,
7689 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7691 (void *)&cmd_read_reg_bit_read,
7692 (void *)&cmd_read_reg_bit_regbit,
7693 (void *)&cmd_read_reg_bit_port_id,
7694 (void *)&cmd_read_reg_bit_reg_off,
7695 (void *)&cmd_read_reg_bit_bit_pos,
7700 /* *** WRITE PORT REGISTER *** */
7701 struct cmd_write_reg_result {
7702 cmdline_fixed_string_t write;
7703 cmdline_fixed_string_t reg;
7710 cmd_write_reg_parsed(void *parsed_result,
7711 __attribute__((unused)) struct cmdline *cl,
7712 __attribute__((unused)) void *data)
7714 struct cmd_write_reg_result *res = parsed_result;
7715 port_reg_set(res->port_id, res->reg_off, res->value);
7718 cmdline_parse_token_string_t cmd_write_reg_write =
7719 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7720 cmdline_parse_token_string_t cmd_write_reg_reg =
7721 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7722 cmdline_parse_token_num_t cmd_write_reg_port_id =
7723 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7724 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7725 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7726 cmdline_parse_token_num_t cmd_write_reg_value =
7727 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7729 cmdline_parse_inst_t cmd_write_reg = {
7730 .f = cmd_write_reg_parsed,
7732 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7734 (void *)&cmd_write_reg_write,
7735 (void *)&cmd_write_reg_reg,
7736 (void *)&cmd_write_reg_port_id,
7737 (void *)&cmd_write_reg_reg_off,
7738 (void *)&cmd_write_reg_value,
7743 /* *** WRITE PORT REGISTER BIT FIELD *** */
7744 struct cmd_write_reg_bit_field_result {
7745 cmdline_fixed_string_t write;
7746 cmdline_fixed_string_t regfield;
7755 cmd_write_reg_bit_field_parsed(void *parsed_result,
7756 __attribute__((unused)) struct cmdline *cl,
7757 __attribute__((unused)) void *data)
7759 struct cmd_write_reg_bit_field_result *res = parsed_result;
7760 port_reg_bit_field_set(res->port_id, res->reg_off,
7761 res->bit1_pos, res->bit2_pos, res->value);
7764 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7765 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7767 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7768 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7769 regfield, "regfield");
7770 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7771 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7773 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7774 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7776 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7777 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7779 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7780 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7782 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7783 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7786 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7787 .f = cmd_write_reg_bit_field_parsed,
7789 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7791 "Set register bit field between bit_x and bit_y included",
7793 (void *)&cmd_write_reg_bit_field_write,
7794 (void *)&cmd_write_reg_bit_field_regfield,
7795 (void *)&cmd_write_reg_bit_field_port_id,
7796 (void *)&cmd_write_reg_bit_field_reg_off,
7797 (void *)&cmd_write_reg_bit_field_bit1_pos,
7798 (void *)&cmd_write_reg_bit_field_bit2_pos,
7799 (void *)&cmd_write_reg_bit_field_value,
7804 /* *** WRITE PORT REGISTER BIT *** */
7805 struct cmd_write_reg_bit_result {
7806 cmdline_fixed_string_t write;
7807 cmdline_fixed_string_t regbit;
7815 cmd_write_reg_bit_parsed(void *parsed_result,
7816 __attribute__((unused)) struct cmdline *cl,
7817 __attribute__((unused)) void *data)
7819 struct cmd_write_reg_bit_result *res = parsed_result;
7820 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7823 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7824 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7826 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7827 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7829 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7830 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7831 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7832 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7833 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7834 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7835 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7836 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7838 cmdline_parse_inst_t cmd_write_reg_bit = {
7839 .f = cmd_write_reg_bit_parsed,
7841 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7844 (void *)&cmd_write_reg_bit_write,
7845 (void *)&cmd_write_reg_bit_regbit,
7846 (void *)&cmd_write_reg_bit_port_id,
7847 (void *)&cmd_write_reg_bit_reg_off,
7848 (void *)&cmd_write_reg_bit_bit_pos,
7849 (void *)&cmd_write_reg_bit_value,
7854 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7855 struct cmd_read_rxd_txd_result {
7856 cmdline_fixed_string_t read;
7857 cmdline_fixed_string_t rxd_txd;
7864 cmd_read_rxd_txd_parsed(void *parsed_result,
7865 __attribute__((unused)) struct cmdline *cl,
7866 __attribute__((unused)) void *data)
7868 struct cmd_read_rxd_txd_result *res = parsed_result;
7870 if (!strcmp(res->rxd_txd, "rxd"))
7871 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7872 else if (!strcmp(res->rxd_txd, "txd"))
7873 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7876 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7877 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7878 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7879 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7881 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7882 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7883 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7884 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7885 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7886 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7888 cmdline_parse_inst_t cmd_read_rxd_txd = {
7889 .f = cmd_read_rxd_txd_parsed,
7891 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7893 (void *)&cmd_read_rxd_txd_read,
7894 (void *)&cmd_read_rxd_txd_rxd_txd,
7895 (void *)&cmd_read_rxd_txd_port_id,
7896 (void *)&cmd_read_rxd_txd_queue_id,
7897 (void *)&cmd_read_rxd_txd_desc_id,
7903 struct cmd_quit_result {
7904 cmdline_fixed_string_t quit;
7907 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7909 __attribute__((unused)) void *data)
7914 cmdline_parse_token_string_t cmd_quit_quit =
7915 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7917 cmdline_parse_inst_t cmd_quit = {
7918 .f = cmd_quit_parsed,
7920 .help_str = "quit: Exit application",
7922 (void *)&cmd_quit_quit,
7927 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7928 struct cmd_mac_addr_result {
7929 cmdline_fixed_string_t mac_addr_cmd;
7930 cmdline_fixed_string_t what;
7932 struct rte_ether_addr address;
7935 static void cmd_mac_addr_parsed(void *parsed_result,
7936 __attribute__((unused)) struct cmdline *cl,
7937 __attribute__((unused)) void *data)
7939 struct cmd_mac_addr_result *res = parsed_result;
7942 if (strcmp(res->what, "add") == 0)
7943 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7944 else if (strcmp(res->what, "set") == 0)
7945 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7948 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7950 /* check the return value and print it if is < 0 */
7952 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7956 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7957 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7959 cmdline_parse_token_string_t cmd_mac_addr_what =
7960 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7962 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7963 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7965 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7966 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7968 cmdline_parse_inst_t cmd_mac_addr = {
7969 .f = cmd_mac_addr_parsed,
7971 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7972 "Add/Remove/Set MAC address on port_id",
7974 (void *)&cmd_mac_addr_cmd,
7975 (void *)&cmd_mac_addr_what,
7976 (void *)&cmd_mac_addr_portnum,
7977 (void *)&cmd_mac_addr_addr,
7982 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7983 struct cmd_eth_peer_result {
7984 cmdline_fixed_string_t set;
7985 cmdline_fixed_string_t eth_peer;
7987 cmdline_fixed_string_t peer_addr;
7990 static void cmd_set_eth_peer_parsed(void *parsed_result,
7991 __attribute__((unused)) struct cmdline *cl,
7992 __attribute__((unused)) void *data)
7994 struct cmd_eth_peer_result *res = parsed_result;
7996 if (test_done == 0) {
7997 printf("Please stop forwarding first\n");
8000 if (!strcmp(res->eth_peer, "eth-peer")) {
8001 set_fwd_eth_peer(res->port_id, res->peer_addr);
8005 cmdline_parse_token_string_t cmd_eth_peer_set =
8006 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8007 cmdline_parse_token_string_t cmd_eth_peer =
8008 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8009 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8010 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8011 cmdline_parse_token_string_t cmd_eth_peer_addr =
8012 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8014 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8015 .f = cmd_set_eth_peer_parsed,
8017 .help_str = "set eth-peer <port_id> <peer_mac>",
8019 (void *)&cmd_eth_peer_set,
8020 (void *)&cmd_eth_peer,
8021 (void *)&cmd_eth_peer_port_id,
8022 (void *)&cmd_eth_peer_addr,
8027 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8028 struct cmd_set_qmap_result {
8029 cmdline_fixed_string_t set;
8030 cmdline_fixed_string_t qmap;
8031 cmdline_fixed_string_t what;
8038 cmd_set_qmap_parsed(void *parsed_result,
8039 __attribute__((unused)) struct cmdline *cl,
8040 __attribute__((unused)) void *data)
8042 struct cmd_set_qmap_result *res = parsed_result;
8043 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8045 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8048 cmdline_parse_token_string_t cmd_setqmap_set =
8049 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8051 cmdline_parse_token_string_t cmd_setqmap_qmap =
8052 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8054 cmdline_parse_token_string_t cmd_setqmap_what =
8055 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8057 cmdline_parse_token_num_t cmd_setqmap_portid =
8058 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8060 cmdline_parse_token_num_t cmd_setqmap_queueid =
8061 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8063 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8064 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8067 cmdline_parse_inst_t cmd_set_qmap = {
8068 .f = cmd_set_qmap_parsed,
8070 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8071 "Set statistics mapping value on tx|rx queue_id of port_id",
8073 (void *)&cmd_setqmap_set,
8074 (void *)&cmd_setqmap_qmap,
8075 (void *)&cmd_setqmap_what,
8076 (void *)&cmd_setqmap_portid,
8077 (void *)&cmd_setqmap_queueid,
8078 (void *)&cmd_setqmap_mapvalue,
8083 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8084 struct cmd_set_xstats_hide_zero_result {
8085 cmdline_fixed_string_t keyword;
8086 cmdline_fixed_string_t name;
8087 cmdline_fixed_string_t on_off;
8091 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8092 __attribute__((unused)) struct cmdline *cl,
8093 __attribute__((unused)) void *data)
8095 struct cmd_set_xstats_hide_zero_result *res;
8096 uint16_t on_off = 0;
8098 res = parsed_result;
8099 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8100 set_xstats_hide_zero(on_off);
8103 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8104 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8106 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8107 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8108 name, "xstats-hide-zero");
8109 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8110 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8113 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8114 .f = cmd_set_xstats_hide_zero_parsed,
8116 .help_str = "set xstats-hide-zero on|off",
8118 (void *)&cmd_set_xstats_hide_zero_keyword,
8119 (void *)&cmd_set_xstats_hide_zero_name,
8120 (void *)&cmd_set_xstats_hide_zero_on_off,
8125 /* *** CONFIGURE UNICAST HASH TABLE *** */
8126 struct cmd_set_uc_hash_table {
8127 cmdline_fixed_string_t set;
8128 cmdline_fixed_string_t port;
8130 cmdline_fixed_string_t what;
8131 struct rte_ether_addr address;
8132 cmdline_fixed_string_t mode;
8136 cmd_set_uc_hash_parsed(void *parsed_result,
8137 __attribute__((unused)) struct cmdline *cl,
8138 __attribute__((unused)) void *data)
8141 struct cmd_set_uc_hash_table *res = parsed_result;
8143 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8145 if (strcmp(res->what, "uta") == 0)
8146 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8147 &res->address,(uint8_t)is_on);
8149 printf("bad unicast hash table parameter, return code = %d \n", ret);
8153 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8154 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8156 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8157 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8159 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8160 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8162 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8163 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8165 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8166 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8168 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8169 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8172 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8173 .f = cmd_set_uc_hash_parsed,
8175 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8177 (void *)&cmd_set_uc_hash_set,
8178 (void *)&cmd_set_uc_hash_port,
8179 (void *)&cmd_set_uc_hash_portid,
8180 (void *)&cmd_set_uc_hash_what,
8181 (void *)&cmd_set_uc_hash_mac,
8182 (void *)&cmd_set_uc_hash_mode,
8187 struct cmd_set_uc_all_hash_table {
8188 cmdline_fixed_string_t set;
8189 cmdline_fixed_string_t port;
8191 cmdline_fixed_string_t what;
8192 cmdline_fixed_string_t value;
8193 cmdline_fixed_string_t mode;
8197 cmd_set_uc_all_hash_parsed(void *parsed_result,
8198 __attribute__((unused)) struct cmdline *cl,
8199 __attribute__((unused)) void *data)
8202 struct cmd_set_uc_all_hash_table *res = parsed_result;
8204 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8206 if ((strcmp(res->what, "uta") == 0) &&
8207 (strcmp(res->value, "all") == 0))
8208 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8210 printf("bad unicast hash table parameter,"
8211 "return code = %d \n", ret);
8214 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8215 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8217 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8218 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8220 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8221 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8223 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8224 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8226 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8227 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8229 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8230 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8233 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8234 .f = cmd_set_uc_all_hash_parsed,
8236 .help_str = "set port <port_id> uta all on|off",
8238 (void *)&cmd_set_uc_all_hash_set,
8239 (void *)&cmd_set_uc_all_hash_port,
8240 (void *)&cmd_set_uc_all_hash_portid,
8241 (void *)&cmd_set_uc_all_hash_what,
8242 (void *)&cmd_set_uc_all_hash_value,
8243 (void *)&cmd_set_uc_all_hash_mode,
8248 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8249 struct cmd_set_vf_macvlan_filter {
8250 cmdline_fixed_string_t set;
8251 cmdline_fixed_string_t port;
8253 cmdline_fixed_string_t vf;
8255 struct rte_ether_addr address;
8256 cmdline_fixed_string_t filter_type;
8257 cmdline_fixed_string_t mode;
8261 cmd_set_vf_macvlan_parsed(void *parsed_result,
8262 __attribute__((unused)) struct cmdline *cl,
8263 __attribute__((unused)) void *data)
8266 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8267 struct rte_eth_mac_filter filter;
8269 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8271 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8273 /* set VF MAC filter */
8277 filter.dst_id = res->vf_id;
8279 if (!strcmp(res->filter_type, "exact-mac"))
8280 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8281 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8282 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8283 else if (!strcmp(res->filter_type, "hashmac"))
8284 filter.filter_type = RTE_MAC_HASH_MATCH;
8285 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8286 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8288 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8291 ret = rte_eth_dev_filter_ctrl(res->port_id,
8292 RTE_ETH_FILTER_MACVLAN,
8296 ret = rte_eth_dev_filter_ctrl(res->port_id,
8297 RTE_ETH_FILTER_MACVLAN,
8298 RTE_ETH_FILTER_DELETE,
8302 printf("bad set MAC hash parameter, return code = %d\n", ret);
8306 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8307 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8309 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8310 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8312 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8313 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8315 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8316 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8318 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8319 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8321 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8322 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8324 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8325 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8326 filter_type, "exact-mac#exact-mac-vlan"
8327 "#hashmac#hashmac-vlan");
8328 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8329 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8332 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8333 .f = cmd_set_vf_macvlan_parsed,
8335 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8336 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8337 "Exact match rule: exact match of MAC or MAC and VLAN; "
8338 "hash match rule: hash match of MAC and exact match of VLAN",
8340 (void *)&cmd_set_vf_macvlan_set,
8341 (void *)&cmd_set_vf_macvlan_port,
8342 (void *)&cmd_set_vf_macvlan_portid,
8343 (void *)&cmd_set_vf_macvlan_vf,
8344 (void *)&cmd_set_vf_macvlan_vf_id,
8345 (void *)&cmd_set_vf_macvlan_mac,
8346 (void *)&cmd_set_vf_macvlan_filter_type,
8347 (void *)&cmd_set_vf_macvlan_mode,
8352 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8353 struct cmd_set_vf_traffic {
8354 cmdline_fixed_string_t set;
8355 cmdline_fixed_string_t port;
8357 cmdline_fixed_string_t vf;
8359 cmdline_fixed_string_t what;
8360 cmdline_fixed_string_t mode;
8364 cmd_set_vf_traffic_parsed(void *parsed_result,
8365 __attribute__((unused)) struct cmdline *cl,
8366 __attribute__((unused)) void *data)
8368 struct cmd_set_vf_traffic *res = parsed_result;
8369 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8370 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8372 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8375 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8376 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8378 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8379 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8381 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8382 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8384 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8385 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8387 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8388 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8390 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8391 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8393 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8394 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8397 cmdline_parse_inst_t cmd_set_vf_traffic = {
8398 .f = cmd_set_vf_traffic_parsed,
8400 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8402 (void *)&cmd_setvf_traffic_set,
8403 (void *)&cmd_setvf_traffic_port,
8404 (void *)&cmd_setvf_traffic_portid,
8405 (void *)&cmd_setvf_traffic_vf,
8406 (void *)&cmd_setvf_traffic_vfid,
8407 (void *)&cmd_setvf_traffic_what,
8408 (void *)&cmd_setvf_traffic_mode,
8413 /* *** CONFIGURE VF RECEIVE MODE *** */
8414 struct cmd_set_vf_rxmode {
8415 cmdline_fixed_string_t set;
8416 cmdline_fixed_string_t port;
8418 cmdline_fixed_string_t vf;
8420 cmdline_fixed_string_t what;
8421 cmdline_fixed_string_t mode;
8422 cmdline_fixed_string_t on;
8426 cmd_set_vf_rxmode_parsed(void *parsed_result,
8427 __attribute__((unused)) struct cmdline *cl,
8428 __attribute__((unused)) void *data)
8431 uint16_t vf_rxmode = 0;
8432 struct cmd_set_vf_rxmode *res = parsed_result;
8434 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8435 if (!strcmp(res->what,"rxmode")) {
8436 if (!strcmp(res->mode, "AUPE"))
8437 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8438 else if (!strcmp(res->mode, "ROPE"))
8439 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8440 else if (!strcmp(res->mode, "BAM"))
8441 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8442 else if (!strncmp(res->mode, "MPE",3))
8443 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8446 RTE_SET_USED(is_on);
8448 #ifdef RTE_LIBRTE_IXGBE_PMD
8449 if (ret == -ENOTSUP)
8450 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8451 vf_rxmode, (uint8_t)is_on);
8453 #ifdef RTE_LIBRTE_BNXT_PMD
8454 if (ret == -ENOTSUP)
8455 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8456 vf_rxmode, (uint8_t)is_on);
8459 printf("bad VF receive mode parameter, return code = %d \n",
8463 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8464 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8466 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8467 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8469 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8470 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8472 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8473 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8475 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8476 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8478 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8479 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8481 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8482 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8483 mode, "AUPE#ROPE#BAM#MPE");
8484 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8485 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8488 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8489 .f = cmd_set_vf_rxmode_parsed,
8491 .help_str = "set port <port_id> vf <vf_id> rxmode "
8492 "AUPE|ROPE|BAM|MPE on|off",
8494 (void *)&cmd_set_vf_rxmode_set,
8495 (void *)&cmd_set_vf_rxmode_port,
8496 (void *)&cmd_set_vf_rxmode_portid,
8497 (void *)&cmd_set_vf_rxmode_vf,
8498 (void *)&cmd_set_vf_rxmode_vfid,
8499 (void *)&cmd_set_vf_rxmode_what,
8500 (void *)&cmd_set_vf_rxmode_mode,
8501 (void *)&cmd_set_vf_rxmode_on,
8506 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8507 struct cmd_vf_mac_addr_result {
8508 cmdline_fixed_string_t mac_addr_cmd;
8509 cmdline_fixed_string_t what;
8510 cmdline_fixed_string_t port;
8512 cmdline_fixed_string_t vf;
8514 struct rte_ether_addr address;
8517 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8518 __attribute__((unused)) struct cmdline *cl,
8519 __attribute__((unused)) void *data)
8521 struct cmd_vf_mac_addr_result *res = parsed_result;
8524 if (strcmp(res->what, "add") != 0)
8527 #ifdef RTE_LIBRTE_I40E_PMD
8528 if (ret == -ENOTSUP)
8529 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8532 #ifdef RTE_LIBRTE_BNXT_PMD
8533 if (ret == -ENOTSUP)
8534 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8539 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8543 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8544 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8545 mac_addr_cmd,"mac_addr");
8546 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8547 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8549 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8550 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8552 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8553 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8555 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8556 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8558 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8559 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8561 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8562 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8565 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8566 .f = cmd_vf_mac_addr_parsed,
8568 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8569 "Add MAC address filtering for a VF on port_id",
8571 (void *)&cmd_vf_mac_addr_cmd,
8572 (void *)&cmd_vf_mac_addr_what,
8573 (void *)&cmd_vf_mac_addr_port,
8574 (void *)&cmd_vf_mac_addr_portnum,
8575 (void *)&cmd_vf_mac_addr_vf,
8576 (void *)&cmd_vf_mac_addr_vfnum,
8577 (void *)&cmd_vf_mac_addr_addr,
8582 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8583 struct cmd_vf_rx_vlan_filter {
8584 cmdline_fixed_string_t rx_vlan;
8585 cmdline_fixed_string_t what;
8587 cmdline_fixed_string_t port;
8589 cmdline_fixed_string_t vf;
8594 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8595 __attribute__((unused)) struct cmdline *cl,
8596 __attribute__((unused)) void *data)
8598 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8601 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8603 #ifdef RTE_LIBRTE_IXGBE_PMD
8604 if (ret == -ENOTSUP)
8605 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8606 res->vlan_id, res->vf_mask, is_add);
8608 #ifdef RTE_LIBRTE_I40E_PMD
8609 if (ret == -ENOTSUP)
8610 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8611 res->vlan_id, res->vf_mask, is_add);
8613 #ifdef RTE_LIBRTE_BNXT_PMD
8614 if (ret == -ENOTSUP)
8615 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8616 res->vlan_id, res->vf_mask, is_add);
8623 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8624 res->vlan_id, res->vf_mask);
8627 printf("invalid port_id %d\n", res->port_id);
8630 printf("function not implemented or supported\n");
8633 printf("programming error: (%s)\n", strerror(-ret));
8637 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8638 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8639 rx_vlan, "rx_vlan");
8640 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8641 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8643 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8644 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8646 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8647 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8649 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8650 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8652 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8653 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8655 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8656 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8659 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8660 .f = cmd_vf_rx_vlan_filter_parsed,
8662 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8663 "(vf_mask = hexadecimal VF mask)",
8665 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8666 (void *)&cmd_vf_rx_vlan_filter_what,
8667 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8668 (void *)&cmd_vf_rx_vlan_filter_port,
8669 (void *)&cmd_vf_rx_vlan_filter_portid,
8670 (void *)&cmd_vf_rx_vlan_filter_vf,
8671 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8676 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8677 struct cmd_queue_rate_limit_result {
8678 cmdline_fixed_string_t set;
8679 cmdline_fixed_string_t port;
8681 cmdline_fixed_string_t queue;
8683 cmdline_fixed_string_t rate;
8687 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8688 __attribute__((unused)) struct cmdline *cl,
8689 __attribute__((unused)) void *data)
8691 struct cmd_queue_rate_limit_result *res = parsed_result;
8694 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8695 && (strcmp(res->queue, "queue") == 0)
8696 && (strcmp(res->rate, "rate") == 0))
8697 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8700 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8704 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8705 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8707 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8708 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8710 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8711 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8713 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8714 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8716 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8717 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8719 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8720 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8722 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8723 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8726 cmdline_parse_inst_t cmd_queue_rate_limit = {
8727 .f = cmd_queue_rate_limit_parsed,
8729 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8730 "Set rate limit for a queue on port_id",
8732 (void *)&cmd_queue_rate_limit_set,
8733 (void *)&cmd_queue_rate_limit_port,
8734 (void *)&cmd_queue_rate_limit_portnum,
8735 (void *)&cmd_queue_rate_limit_queue,
8736 (void *)&cmd_queue_rate_limit_queuenum,
8737 (void *)&cmd_queue_rate_limit_rate,
8738 (void *)&cmd_queue_rate_limit_ratenum,
8743 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8744 struct cmd_vf_rate_limit_result {
8745 cmdline_fixed_string_t set;
8746 cmdline_fixed_string_t port;
8748 cmdline_fixed_string_t vf;
8750 cmdline_fixed_string_t rate;
8752 cmdline_fixed_string_t q_msk;
8756 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8757 __attribute__((unused)) struct cmdline *cl,
8758 __attribute__((unused)) void *data)
8760 struct cmd_vf_rate_limit_result *res = parsed_result;
8763 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8764 && (strcmp(res->vf, "vf") == 0)
8765 && (strcmp(res->rate, "rate") == 0)
8766 && (strcmp(res->q_msk, "queue_mask") == 0))
8767 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8768 res->rate_num, res->q_msk_val);
8770 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8774 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8775 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8777 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8778 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8780 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8781 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8783 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8784 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8786 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8787 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8789 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8790 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8792 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8793 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8795 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8796 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8797 q_msk, "queue_mask");
8798 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8799 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8802 cmdline_parse_inst_t cmd_vf_rate_limit = {
8803 .f = cmd_vf_rate_limit_parsed,
8805 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8806 "queue_mask <queue_mask_value>: "
8807 "Set rate limit for queues of VF on port_id",
8809 (void *)&cmd_vf_rate_limit_set,
8810 (void *)&cmd_vf_rate_limit_port,
8811 (void *)&cmd_vf_rate_limit_portnum,
8812 (void *)&cmd_vf_rate_limit_vf,
8813 (void *)&cmd_vf_rate_limit_vfnum,
8814 (void *)&cmd_vf_rate_limit_rate,
8815 (void *)&cmd_vf_rate_limit_ratenum,
8816 (void *)&cmd_vf_rate_limit_q_msk,
8817 (void *)&cmd_vf_rate_limit_q_msk_val,
8822 /* *** ADD TUNNEL FILTER OF A PORT *** */
8823 struct cmd_tunnel_filter_result {
8824 cmdline_fixed_string_t cmd;
8825 cmdline_fixed_string_t what;
8827 struct rte_ether_addr outer_mac;
8828 struct rte_ether_addr inner_mac;
8829 cmdline_ipaddr_t ip_value;
8830 uint16_t inner_vlan;
8831 cmdline_fixed_string_t tunnel_type;
8832 cmdline_fixed_string_t filter_type;
8838 cmd_tunnel_filter_parsed(void *parsed_result,
8839 __attribute__((unused)) struct cmdline *cl,
8840 __attribute__((unused)) void *data)
8842 struct cmd_tunnel_filter_result *res = parsed_result;
8843 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8846 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8848 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8849 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8850 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8852 if (res->ip_value.family == AF_INET) {
8853 tunnel_filter_conf.ip_addr.ipv4_addr =
8854 res->ip_value.addr.ipv4.s_addr;
8855 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8857 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8858 &(res->ip_value.addr.ipv6),
8859 sizeof(struct in6_addr));
8860 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8863 if (!strcmp(res->filter_type, "imac-ivlan"))
8864 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8865 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8866 tunnel_filter_conf.filter_type =
8867 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8868 else if (!strcmp(res->filter_type, "imac-tenid"))
8869 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8870 else if (!strcmp(res->filter_type, "imac"))
8871 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8872 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8873 tunnel_filter_conf.filter_type =
8874 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8875 else if (!strcmp(res->filter_type, "oip"))
8876 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8877 else if (!strcmp(res->filter_type, "iip"))
8878 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8880 printf("The filter type is not supported");
8884 if (!strcmp(res->tunnel_type, "vxlan"))
8885 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8886 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
8887 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
8888 else if (!strcmp(res->tunnel_type, "nvgre"))
8889 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8890 else if (!strcmp(res->tunnel_type, "ipingre"))
8891 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8893 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8897 tunnel_filter_conf.tenant_id = res->tenant_id;
8898 tunnel_filter_conf.queue_id = res->queue_num;
8899 if (!strcmp(res->what, "add"))
8900 ret = rte_eth_dev_filter_ctrl(res->port_id,
8901 RTE_ETH_FILTER_TUNNEL,
8903 &tunnel_filter_conf);
8905 ret = rte_eth_dev_filter_ctrl(res->port_id,
8906 RTE_ETH_FILTER_TUNNEL,
8907 RTE_ETH_FILTER_DELETE,
8908 &tunnel_filter_conf);
8910 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8914 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8915 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8916 cmd, "tunnel_filter");
8917 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8918 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8920 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8921 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8923 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8924 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8926 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8927 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8929 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8930 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8931 inner_vlan, UINT16);
8932 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8933 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8935 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8936 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8937 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
8939 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8940 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8941 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8942 "imac#omac-imac-tenid");
8943 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8944 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8946 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8947 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8950 cmdline_parse_inst_t cmd_tunnel_filter = {
8951 .f = cmd_tunnel_filter_parsed,
8953 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8954 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8955 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8956 "<queue_id>: Add/Rm tunnel filter of a port",
8958 (void *)&cmd_tunnel_filter_cmd,
8959 (void *)&cmd_tunnel_filter_what,
8960 (void *)&cmd_tunnel_filter_port_id,
8961 (void *)&cmd_tunnel_filter_outer_mac,
8962 (void *)&cmd_tunnel_filter_inner_mac,
8963 (void *)&cmd_tunnel_filter_ip_value,
8964 (void *)&cmd_tunnel_filter_innner_vlan,
8965 (void *)&cmd_tunnel_filter_tunnel_type,
8966 (void *)&cmd_tunnel_filter_filter_type,
8967 (void *)&cmd_tunnel_filter_tenant_id,
8968 (void *)&cmd_tunnel_filter_queue_num,
8973 /* *** CONFIGURE TUNNEL UDP PORT *** */
8974 struct cmd_tunnel_udp_config {
8975 cmdline_fixed_string_t cmd;
8976 cmdline_fixed_string_t what;
8982 cmd_tunnel_udp_config_parsed(void *parsed_result,
8983 __attribute__((unused)) struct cmdline *cl,
8984 __attribute__((unused)) void *data)
8986 struct cmd_tunnel_udp_config *res = parsed_result;
8987 struct rte_eth_udp_tunnel tunnel_udp;
8990 tunnel_udp.udp_port = res->udp_port;
8992 if (!strcmp(res->cmd, "rx_vxlan_port"))
8993 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8995 if (!strcmp(res->what, "add"))
8996 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8999 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9003 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9006 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9007 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9008 cmd, "rx_vxlan_port");
9009 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9010 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9012 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9013 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9015 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9016 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9019 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9020 .f = cmd_tunnel_udp_config_parsed,
9022 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9023 "Add/Remove a tunneling UDP port filter",
9025 (void *)&cmd_tunnel_udp_config_cmd,
9026 (void *)&cmd_tunnel_udp_config_what,
9027 (void *)&cmd_tunnel_udp_config_udp_port,
9028 (void *)&cmd_tunnel_udp_config_port_id,
9033 struct cmd_config_tunnel_udp_port {
9034 cmdline_fixed_string_t port;
9035 cmdline_fixed_string_t config;
9037 cmdline_fixed_string_t udp_tunnel_port;
9038 cmdline_fixed_string_t action;
9039 cmdline_fixed_string_t tunnel_type;
9044 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9045 __attribute__((unused)) struct cmdline *cl,
9046 __attribute__((unused)) void *data)
9048 struct cmd_config_tunnel_udp_port *res = parsed_result;
9049 struct rte_eth_udp_tunnel tunnel_udp;
9052 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9055 tunnel_udp.udp_port = res->udp_port;
9057 if (!strcmp(res->tunnel_type, "vxlan")) {
9058 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9059 } else if (!strcmp(res->tunnel_type, "geneve")) {
9060 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9061 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9062 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9064 printf("Invalid tunnel type\n");
9068 if (!strcmp(res->action, "add"))
9069 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9072 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9076 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9079 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9080 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9082 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9083 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9085 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9086 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9088 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9089 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9092 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9093 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9095 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9096 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9097 "vxlan#geneve#vxlan-gpe");
9098 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9099 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9102 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9103 .f = cmd_cfg_tunnel_udp_port_parsed,
9105 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9107 (void *)&cmd_config_tunnel_udp_port_port,
9108 (void *)&cmd_config_tunnel_udp_port_config,
9109 (void *)&cmd_config_tunnel_udp_port_port_id,
9110 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9111 (void *)&cmd_config_tunnel_udp_port_action,
9112 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9113 (void *)&cmd_config_tunnel_udp_port_value,
9118 /* *** GLOBAL CONFIG *** */
9119 struct cmd_global_config_result {
9120 cmdline_fixed_string_t cmd;
9122 cmdline_fixed_string_t cfg_type;
9127 cmd_global_config_parsed(void *parsed_result,
9128 __attribute__((unused)) struct cmdline *cl,
9129 __attribute__((unused)) void *data)
9131 struct cmd_global_config_result *res = parsed_result;
9132 struct rte_eth_global_cfg conf;
9135 memset(&conf, 0, sizeof(conf));
9136 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9137 conf.cfg.gre_key_len = res->len;
9138 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9139 RTE_ETH_FILTER_SET, &conf);
9141 printf("Global config error\n");
9144 cmdline_parse_token_string_t cmd_global_config_cmd =
9145 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9147 cmdline_parse_token_num_t cmd_global_config_port_id =
9148 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9150 cmdline_parse_token_string_t cmd_global_config_type =
9151 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9152 cfg_type, "gre-key-len");
9153 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9154 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9157 cmdline_parse_inst_t cmd_global_config = {
9158 .f = cmd_global_config_parsed,
9159 .data = (void *)NULL,
9160 .help_str = "global_config <port_id> gre-key-len <key_len>",
9162 (void *)&cmd_global_config_cmd,
9163 (void *)&cmd_global_config_port_id,
9164 (void *)&cmd_global_config_type,
9165 (void *)&cmd_global_config_gre_key_len,
9170 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9171 struct cmd_set_mirror_mask_result {
9172 cmdline_fixed_string_t set;
9173 cmdline_fixed_string_t port;
9175 cmdline_fixed_string_t mirror;
9177 cmdline_fixed_string_t what;
9178 cmdline_fixed_string_t value;
9179 cmdline_fixed_string_t dstpool;
9181 cmdline_fixed_string_t on;
9184 cmdline_parse_token_string_t cmd_mirror_mask_set =
9185 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9187 cmdline_parse_token_string_t cmd_mirror_mask_port =
9188 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9190 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9191 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9193 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9194 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9195 mirror, "mirror-rule");
9196 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9197 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9199 cmdline_parse_token_string_t cmd_mirror_mask_what =
9200 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9201 what, "pool-mirror-up#pool-mirror-down"
9203 cmdline_parse_token_string_t cmd_mirror_mask_value =
9204 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9206 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9207 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9208 dstpool, "dst-pool");
9209 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9210 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9212 cmdline_parse_token_string_t cmd_mirror_mask_on =
9213 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9217 cmd_set_mirror_mask_parsed(void *parsed_result,
9218 __attribute__((unused)) struct cmdline *cl,
9219 __attribute__((unused)) void *data)
9222 struct cmd_set_mirror_mask_result *res = parsed_result;
9223 struct rte_eth_mirror_conf mr_conf;
9225 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9227 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9229 mr_conf.dst_pool = res->dstpool_id;
9231 if (!strcmp(res->what, "pool-mirror-up")) {
9232 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9233 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9234 } else if (!strcmp(res->what, "pool-mirror-down")) {
9235 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9236 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9237 } else if (!strcmp(res->what, "vlan-mirror")) {
9238 mr_conf.rule_type = ETH_MIRROR_VLAN;
9239 nb_item = parse_item_list(res->value, "vlan",
9240 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9244 for (i = 0; i < nb_item; i++) {
9245 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9246 printf("Invalid vlan_id: must be < 4096\n");
9250 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9251 mr_conf.vlan.vlan_mask |= 1ULL << i;
9255 if (!strcmp(res->on, "on"))
9256 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9259 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9262 printf("mirror rule add error: (%s)\n", strerror(-ret));
9265 cmdline_parse_inst_t cmd_set_mirror_mask = {
9266 .f = cmd_set_mirror_mask_parsed,
9268 .help_str = "set port <port_id> mirror-rule <rule_id> "
9269 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9270 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9272 (void *)&cmd_mirror_mask_set,
9273 (void *)&cmd_mirror_mask_port,
9274 (void *)&cmd_mirror_mask_portid,
9275 (void *)&cmd_mirror_mask_mirror,
9276 (void *)&cmd_mirror_mask_ruleid,
9277 (void *)&cmd_mirror_mask_what,
9278 (void *)&cmd_mirror_mask_value,
9279 (void *)&cmd_mirror_mask_dstpool,
9280 (void *)&cmd_mirror_mask_poolid,
9281 (void *)&cmd_mirror_mask_on,
9286 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9287 struct cmd_set_mirror_link_result {
9288 cmdline_fixed_string_t set;
9289 cmdline_fixed_string_t port;
9291 cmdline_fixed_string_t mirror;
9293 cmdline_fixed_string_t what;
9294 cmdline_fixed_string_t dstpool;
9296 cmdline_fixed_string_t on;
9299 cmdline_parse_token_string_t cmd_mirror_link_set =
9300 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9302 cmdline_parse_token_string_t cmd_mirror_link_port =
9303 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9305 cmdline_parse_token_num_t cmd_mirror_link_portid =
9306 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9308 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9309 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9310 mirror, "mirror-rule");
9311 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9312 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9314 cmdline_parse_token_string_t cmd_mirror_link_what =
9315 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9316 what, "uplink-mirror#downlink-mirror");
9317 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9318 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9319 dstpool, "dst-pool");
9320 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9321 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9323 cmdline_parse_token_string_t cmd_mirror_link_on =
9324 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9328 cmd_set_mirror_link_parsed(void *parsed_result,
9329 __attribute__((unused)) struct cmdline *cl,
9330 __attribute__((unused)) void *data)
9333 struct cmd_set_mirror_link_result *res = parsed_result;
9334 struct rte_eth_mirror_conf mr_conf;
9336 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9337 if (!strcmp(res->what, "uplink-mirror"))
9338 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9340 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9342 mr_conf.dst_pool = res->dstpool_id;
9344 if (!strcmp(res->on, "on"))
9345 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9348 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9351 /* check the return value and print it if is < 0 */
9353 printf("mirror rule add error: (%s)\n", strerror(-ret));
9357 cmdline_parse_inst_t cmd_set_mirror_link = {
9358 .f = cmd_set_mirror_link_parsed,
9360 .help_str = "set port <port_id> mirror-rule <rule_id> "
9361 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9363 (void *)&cmd_mirror_link_set,
9364 (void *)&cmd_mirror_link_port,
9365 (void *)&cmd_mirror_link_portid,
9366 (void *)&cmd_mirror_link_mirror,
9367 (void *)&cmd_mirror_link_ruleid,
9368 (void *)&cmd_mirror_link_what,
9369 (void *)&cmd_mirror_link_dstpool,
9370 (void *)&cmd_mirror_link_poolid,
9371 (void *)&cmd_mirror_link_on,
9376 /* *** RESET VM MIRROR RULE *** */
9377 struct cmd_rm_mirror_rule_result {
9378 cmdline_fixed_string_t reset;
9379 cmdline_fixed_string_t port;
9381 cmdline_fixed_string_t mirror;
9385 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9386 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9388 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9389 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9391 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9392 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9394 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9395 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9396 mirror, "mirror-rule");
9397 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9398 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9402 cmd_reset_mirror_rule_parsed(void *parsed_result,
9403 __attribute__((unused)) struct cmdline *cl,
9404 __attribute__((unused)) void *data)
9407 struct cmd_set_mirror_link_result *res = parsed_result;
9409 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9411 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9414 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9415 .f = cmd_reset_mirror_rule_parsed,
9417 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9419 (void *)&cmd_rm_mirror_rule_reset,
9420 (void *)&cmd_rm_mirror_rule_port,
9421 (void *)&cmd_rm_mirror_rule_portid,
9422 (void *)&cmd_rm_mirror_rule_mirror,
9423 (void *)&cmd_rm_mirror_rule_ruleid,
9428 /* ******************************************************************************** */
9430 struct cmd_dump_result {
9431 cmdline_fixed_string_t dump;
9435 dump_struct_sizes(void)
9437 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9438 DUMP_SIZE(struct rte_mbuf);
9439 DUMP_SIZE(struct rte_mempool);
9440 DUMP_SIZE(struct rte_ring);
9444 static void cmd_dump_parsed(void *parsed_result,
9445 __attribute__((unused)) struct cmdline *cl,
9446 __attribute__((unused)) void *data)
9448 struct cmd_dump_result *res = parsed_result;
9450 if (!strcmp(res->dump, "dump_physmem"))
9451 rte_dump_physmem_layout(stdout);
9452 else if (!strcmp(res->dump, "dump_memzone"))
9453 rte_memzone_dump(stdout);
9454 else if (!strcmp(res->dump, "dump_struct_sizes"))
9455 dump_struct_sizes();
9456 else if (!strcmp(res->dump, "dump_ring"))
9457 rte_ring_list_dump(stdout);
9458 else if (!strcmp(res->dump, "dump_mempool"))
9459 rte_mempool_list_dump(stdout);
9460 else if (!strcmp(res->dump, "dump_devargs"))
9461 rte_devargs_dump(stdout);
9462 else if (!strcmp(res->dump, "dump_log_types"))
9463 rte_log_dump(stdout);
9466 cmdline_parse_token_string_t cmd_dump_dump =
9467 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9470 "dump_struct_sizes#"
9476 cmdline_parse_inst_t cmd_dump = {
9477 .f = cmd_dump_parsed, /* function to call */
9478 .data = NULL, /* 2nd arg of func */
9479 .help_str = "Dump status",
9480 .tokens = { /* token list, NULL terminated */
9481 (void *)&cmd_dump_dump,
9486 /* ******************************************************************************** */
9488 struct cmd_dump_one_result {
9489 cmdline_fixed_string_t dump;
9490 cmdline_fixed_string_t name;
9493 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9494 __attribute__((unused)) void *data)
9496 struct cmd_dump_one_result *res = parsed_result;
9498 if (!strcmp(res->dump, "dump_ring")) {
9500 r = rte_ring_lookup(res->name);
9502 cmdline_printf(cl, "Cannot find ring\n");
9505 rte_ring_dump(stdout, r);
9506 } else if (!strcmp(res->dump, "dump_mempool")) {
9507 struct rte_mempool *mp;
9508 mp = rte_mempool_lookup(res->name);
9510 cmdline_printf(cl, "Cannot find mempool\n");
9513 rte_mempool_dump(stdout, mp);
9517 cmdline_parse_token_string_t cmd_dump_one_dump =
9518 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9519 "dump_ring#dump_mempool");
9521 cmdline_parse_token_string_t cmd_dump_one_name =
9522 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9524 cmdline_parse_inst_t cmd_dump_one = {
9525 .f = cmd_dump_one_parsed, /* function to call */
9526 .data = NULL, /* 2nd arg of func */
9527 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9528 .tokens = { /* token list, NULL terminated */
9529 (void *)&cmd_dump_one_dump,
9530 (void *)&cmd_dump_one_name,
9535 /* *** Add/Del syn filter *** */
9536 struct cmd_syn_filter_result {
9537 cmdline_fixed_string_t filter;
9539 cmdline_fixed_string_t ops;
9540 cmdline_fixed_string_t priority;
9541 cmdline_fixed_string_t high;
9542 cmdline_fixed_string_t queue;
9547 cmd_syn_filter_parsed(void *parsed_result,
9548 __attribute__((unused)) struct cmdline *cl,
9549 __attribute__((unused)) void *data)
9551 struct cmd_syn_filter_result *res = parsed_result;
9552 struct rte_eth_syn_filter syn_filter;
9555 ret = rte_eth_dev_filter_supported(res->port_id,
9556 RTE_ETH_FILTER_SYN);
9558 printf("syn filter is not supported on port %u.\n",
9563 memset(&syn_filter, 0, sizeof(syn_filter));
9565 if (!strcmp(res->ops, "add")) {
9566 if (!strcmp(res->high, "high"))
9567 syn_filter.hig_pri = 1;
9569 syn_filter.hig_pri = 0;
9571 syn_filter.queue = res->queue_id;
9572 ret = rte_eth_dev_filter_ctrl(res->port_id,
9577 ret = rte_eth_dev_filter_ctrl(res->port_id,
9579 RTE_ETH_FILTER_DELETE,
9583 printf("syn filter programming error: (%s)\n",
9587 cmdline_parse_token_string_t cmd_syn_filter_filter =
9588 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9589 filter, "syn_filter");
9590 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9591 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9593 cmdline_parse_token_string_t cmd_syn_filter_ops =
9594 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9596 cmdline_parse_token_string_t cmd_syn_filter_priority =
9597 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9598 priority, "priority");
9599 cmdline_parse_token_string_t cmd_syn_filter_high =
9600 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9602 cmdline_parse_token_string_t cmd_syn_filter_queue =
9603 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9605 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9606 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9609 cmdline_parse_inst_t cmd_syn_filter = {
9610 .f = cmd_syn_filter_parsed,
9612 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9613 "<queue_id>: Add/Delete syn filter",
9615 (void *)&cmd_syn_filter_filter,
9616 (void *)&cmd_syn_filter_port_id,
9617 (void *)&cmd_syn_filter_ops,
9618 (void *)&cmd_syn_filter_priority,
9619 (void *)&cmd_syn_filter_high,
9620 (void *)&cmd_syn_filter_queue,
9621 (void *)&cmd_syn_filter_queue_id,
9626 /* *** queue region set *** */
9627 struct cmd_queue_region_result {
9628 cmdline_fixed_string_t set;
9629 cmdline_fixed_string_t port;
9631 cmdline_fixed_string_t cmd;
9632 cmdline_fixed_string_t region;
9634 cmdline_fixed_string_t queue_start_index;
9636 cmdline_fixed_string_t queue_num;
9637 uint8_t queue_num_value;
9641 cmd_queue_region_parsed(void *parsed_result,
9642 __attribute__((unused)) struct cmdline *cl,
9643 __attribute__((unused)) void *data)
9645 struct cmd_queue_region_result *res = parsed_result;
9647 #ifdef RTE_LIBRTE_I40E_PMD
9648 struct rte_pmd_i40e_queue_region_conf region_conf;
9649 enum rte_pmd_i40e_queue_region_op op_type;
9652 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9655 #ifdef RTE_LIBRTE_I40E_PMD
9656 memset(®ion_conf, 0, sizeof(region_conf));
9657 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9658 region_conf.region_id = res->region_id;
9659 region_conf.queue_num = res->queue_num_value;
9660 region_conf.queue_start_index = res->queue_id;
9662 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9663 op_type, ®ion_conf);
9670 printf("function not implemented or supported\n");
9673 printf("queue region config error: (%s)\n", strerror(-ret));
9677 cmdline_parse_token_string_t cmd_queue_region_set =
9678 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9680 cmdline_parse_token_string_t cmd_queue_region_port =
9681 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9682 cmdline_parse_token_num_t cmd_queue_region_port_id =
9683 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9685 cmdline_parse_token_string_t cmd_queue_region_cmd =
9686 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9687 cmd, "queue-region");
9688 cmdline_parse_token_string_t cmd_queue_region_id =
9689 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9690 region, "region_id");
9691 cmdline_parse_token_num_t cmd_queue_region_index =
9692 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9694 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9695 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9696 queue_start_index, "queue_start_index");
9697 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9698 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9700 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9701 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9702 queue_num, "queue_num");
9703 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9704 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9705 queue_num_value, UINT8);
9707 cmdline_parse_inst_t cmd_queue_region = {
9708 .f = cmd_queue_region_parsed,
9710 .help_str = "set port <port_id> queue-region region_id <value> "
9711 "queue_start_index <value> queue_num <value>: Set a queue region",
9713 (void *)&cmd_queue_region_set,
9714 (void *)&cmd_queue_region_port,
9715 (void *)&cmd_queue_region_port_id,
9716 (void *)&cmd_queue_region_cmd,
9717 (void *)&cmd_queue_region_id,
9718 (void *)&cmd_queue_region_index,
9719 (void *)&cmd_queue_region_queue_start_index,
9720 (void *)&cmd_queue_region_queue_id,
9721 (void *)&cmd_queue_region_queue_num,
9722 (void *)&cmd_queue_region_queue_num_value,
9727 /* *** queue region and flowtype set *** */
9728 struct cmd_region_flowtype_result {
9729 cmdline_fixed_string_t set;
9730 cmdline_fixed_string_t port;
9732 cmdline_fixed_string_t cmd;
9733 cmdline_fixed_string_t region;
9735 cmdline_fixed_string_t flowtype;
9736 uint8_t flowtype_id;
9740 cmd_region_flowtype_parsed(void *parsed_result,
9741 __attribute__((unused)) struct cmdline *cl,
9742 __attribute__((unused)) void *data)
9744 struct cmd_region_flowtype_result *res = parsed_result;
9746 #ifdef RTE_LIBRTE_I40E_PMD
9747 struct rte_pmd_i40e_queue_region_conf region_conf;
9748 enum rte_pmd_i40e_queue_region_op op_type;
9751 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9754 #ifdef RTE_LIBRTE_I40E_PMD
9755 memset(®ion_conf, 0, sizeof(region_conf));
9757 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9758 region_conf.region_id = res->region_id;
9759 region_conf.hw_flowtype = res->flowtype_id;
9761 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9762 op_type, ®ion_conf);
9769 printf("function not implemented or supported\n");
9772 printf("region flowtype config error: (%s)\n", strerror(-ret));
9776 cmdline_parse_token_string_t cmd_region_flowtype_set =
9777 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9779 cmdline_parse_token_string_t cmd_region_flowtype_port =
9780 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9782 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9783 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9785 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9786 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9787 cmd, "queue-region");
9788 cmdline_parse_token_string_t cmd_region_flowtype_index =
9789 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9790 region, "region_id");
9791 cmdline_parse_token_num_t cmd_region_flowtype_id =
9792 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9794 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9795 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9796 flowtype, "flowtype");
9797 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9798 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9799 flowtype_id, UINT8);
9800 cmdline_parse_inst_t cmd_region_flowtype = {
9801 .f = cmd_region_flowtype_parsed,
9803 .help_str = "set port <port_id> queue-region region_id <value> "
9804 "flowtype <value>: Set a flowtype region index",
9806 (void *)&cmd_region_flowtype_set,
9807 (void *)&cmd_region_flowtype_port,
9808 (void *)&cmd_region_flowtype_port_index,
9809 (void *)&cmd_region_flowtype_cmd,
9810 (void *)&cmd_region_flowtype_index,
9811 (void *)&cmd_region_flowtype_id,
9812 (void *)&cmd_region_flowtype_flow_index,
9813 (void *)&cmd_region_flowtype_flow_id,
9818 /* *** User Priority (UP) to queue region (region_id) set *** */
9819 struct cmd_user_priority_region_result {
9820 cmdline_fixed_string_t set;
9821 cmdline_fixed_string_t port;
9823 cmdline_fixed_string_t cmd;
9824 cmdline_fixed_string_t user_priority;
9825 uint8_t user_priority_id;
9826 cmdline_fixed_string_t region;
9831 cmd_user_priority_region_parsed(void *parsed_result,
9832 __attribute__((unused)) struct cmdline *cl,
9833 __attribute__((unused)) void *data)
9835 struct cmd_user_priority_region_result *res = parsed_result;
9837 #ifdef RTE_LIBRTE_I40E_PMD
9838 struct rte_pmd_i40e_queue_region_conf region_conf;
9839 enum rte_pmd_i40e_queue_region_op op_type;
9842 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9845 #ifdef RTE_LIBRTE_I40E_PMD
9846 memset(®ion_conf, 0, sizeof(region_conf));
9847 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9848 region_conf.user_priority = res->user_priority_id;
9849 region_conf.region_id = res->region_id;
9851 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9852 op_type, ®ion_conf);
9859 printf("function not implemented or supported\n");
9862 printf("user_priority region config error: (%s)\n",
9867 cmdline_parse_token_string_t cmd_user_priority_region_set =
9868 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9870 cmdline_parse_token_string_t cmd_user_priority_region_port =
9871 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9873 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9874 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9876 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9877 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9878 cmd, "queue-region");
9879 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9880 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9881 user_priority, "UP");
9882 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9883 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9884 user_priority_id, UINT8);
9885 cmdline_parse_token_string_t cmd_user_priority_region_region =
9886 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9887 region, "region_id");
9888 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9889 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9892 cmdline_parse_inst_t cmd_user_priority_region = {
9893 .f = cmd_user_priority_region_parsed,
9895 .help_str = "set port <port_id> queue-region UP <value> "
9896 "region_id <value>: Set the mapping of User Priority (UP) "
9897 "to queue region (region_id) ",
9899 (void *)&cmd_user_priority_region_set,
9900 (void *)&cmd_user_priority_region_port,
9901 (void *)&cmd_user_priority_region_port_index,
9902 (void *)&cmd_user_priority_region_cmd,
9903 (void *)&cmd_user_priority_region_UP,
9904 (void *)&cmd_user_priority_region_UP_id,
9905 (void *)&cmd_user_priority_region_region,
9906 (void *)&cmd_user_priority_region_region_id,
9911 /* *** flush all queue region related configuration *** */
9912 struct cmd_flush_queue_region_result {
9913 cmdline_fixed_string_t set;
9914 cmdline_fixed_string_t port;
9916 cmdline_fixed_string_t cmd;
9917 cmdline_fixed_string_t flush;
9918 cmdline_fixed_string_t what;
9922 cmd_flush_queue_region_parsed(void *parsed_result,
9923 __attribute__((unused)) struct cmdline *cl,
9924 __attribute__((unused)) void *data)
9926 struct cmd_flush_queue_region_result *res = parsed_result;
9928 #ifdef RTE_LIBRTE_I40E_PMD
9929 struct rte_pmd_i40e_queue_region_conf region_conf;
9930 enum rte_pmd_i40e_queue_region_op op_type;
9933 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9936 #ifdef RTE_LIBRTE_I40E_PMD
9937 memset(®ion_conf, 0, sizeof(region_conf));
9939 if (strcmp(res->what, "on") == 0)
9940 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9942 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9944 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9945 op_type, ®ion_conf);
9952 printf("function not implemented or supported\n");
9955 printf("queue region config flush error: (%s)\n",
9960 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9961 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9963 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9964 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9966 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9967 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9969 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9970 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9971 cmd, "queue-region");
9972 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9973 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9975 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9976 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9979 cmdline_parse_inst_t cmd_flush_queue_region = {
9980 .f = cmd_flush_queue_region_parsed,
9982 .help_str = "set port <port_id> queue-region flush on|off"
9983 ": flush all queue region related configuration",
9985 (void *)&cmd_flush_queue_region_set,
9986 (void *)&cmd_flush_queue_region_port,
9987 (void *)&cmd_flush_queue_region_port_index,
9988 (void *)&cmd_flush_queue_region_cmd,
9989 (void *)&cmd_flush_queue_region_flush,
9990 (void *)&cmd_flush_queue_region_what,
9995 /* *** get all queue region related configuration info *** */
9996 struct cmd_show_queue_region_info {
9997 cmdline_fixed_string_t show;
9998 cmdline_fixed_string_t port;
10000 cmdline_fixed_string_t cmd;
10004 cmd_show_queue_region_info_parsed(void *parsed_result,
10005 __attribute__((unused)) struct cmdline *cl,
10006 __attribute__((unused)) void *data)
10008 struct cmd_show_queue_region_info *res = parsed_result;
10009 int ret = -ENOTSUP;
10010 #ifdef RTE_LIBRTE_I40E_PMD
10011 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10012 enum rte_pmd_i40e_queue_region_op op_type;
10015 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10018 #ifdef RTE_LIBRTE_I40E_PMD
10019 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10021 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10023 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10024 op_type, &rte_pmd_regions);
10026 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10033 printf("function not implemented or supported\n");
10036 printf("queue region config info show error: (%s)\n",
10041 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10042 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10044 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10045 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10047 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10048 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10050 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10051 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10052 cmd, "queue-region");
10054 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10055 .f = cmd_show_queue_region_info_parsed,
10057 .help_str = "show port <port_id> queue-region"
10058 ": show all queue region related configuration info",
10060 (void *)&cmd_show_queue_region_info_get,
10061 (void *)&cmd_show_queue_region_info_port,
10062 (void *)&cmd_show_queue_region_info_port_index,
10063 (void *)&cmd_show_queue_region_info_cmd,
10068 /* *** ADD/REMOVE A 2tuple FILTER *** */
10069 struct cmd_2tuple_filter_result {
10070 cmdline_fixed_string_t filter;
10072 cmdline_fixed_string_t ops;
10073 cmdline_fixed_string_t dst_port;
10074 uint16_t dst_port_value;
10075 cmdline_fixed_string_t protocol;
10076 uint8_t protocol_value;
10077 cmdline_fixed_string_t mask;
10078 uint8_t mask_value;
10079 cmdline_fixed_string_t tcp_flags;
10080 uint8_t tcp_flags_value;
10081 cmdline_fixed_string_t priority;
10082 uint8_t priority_value;
10083 cmdline_fixed_string_t queue;
10088 cmd_2tuple_filter_parsed(void *parsed_result,
10089 __attribute__((unused)) struct cmdline *cl,
10090 __attribute__((unused)) void *data)
10092 struct rte_eth_ntuple_filter filter;
10093 struct cmd_2tuple_filter_result *res = parsed_result;
10096 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10098 printf("ntuple filter is not supported on port %u.\n",
10103 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10105 filter.flags = RTE_2TUPLE_FLAGS;
10106 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10107 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10108 filter.proto = res->protocol_value;
10109 filter.priority = res->priority_value;
10110 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10111 printf("nonzero tcp_flags is only meaningful"
10112 " when protocol is TCP.\n");
10115 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10116 printf("invalid TCP flags.\n");
10120 if (res->tcp_flags_value != 0) {
10121 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10122 filter.tcp_flags = res->tcp_flags_value;
10125 /* need convert to big endian. */
10126 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10127 filter.queue = res->queue_id;
10129 if (!strcmp(res->ops, "add"))
10130 ret = rte_eth_dev_filter_ctrl(res->port_id,
10131 RTE_ETH_FILTER_NTUPLE,
10132 RTE_ETH_FILTER_ADD,
10135 ret = rte_eth_dev_filter_ctrl(res->port_id,
10136 RTE_ETH_FILTER_NTUPLE,
10137 RTE_ETH_FILTER_DELETE,
10140 printf("2tuple filter programming error: (%s)\n",
10145 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10146 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10147 filter, "2tuple_filter");
10148 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10149 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10151 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10152 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10154 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10155 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10156 dst_port, "dst_port");
10157 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10158 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10159 dst_port_value, UINT16);
10160 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10161 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10162 protocol, "protocol");
10163 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10164 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10165 protocol_value, UINT8);
10166 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10167 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10169 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10170 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10172 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10173 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10174 tcp_flags, "tcp_flags");
10175 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10176 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10177 tcp_flags_value, UINT8);
10178 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10179 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10180 priority, "priority");
10181 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10182 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10183 priority_value, UINT8);
10184 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10185 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10187 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10188 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10191 cmdline_parse_inst_t cmd_2tuple_filter = {
10192 .f = cmd_2tuple_filter_parsed,
10194 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10195 "<value> mask <value> tcp_flags <value> priority <value> queue "
10196 "<queue_id>: Add a 2tuple filter",
10198 (void *)&cmd_2tuple_filter_filter,
10199 (void *)&cmd_2tuple_filter_port_id,
10200 (void *)&cmd_2tuple_filter_ops,
10201 (void *)&cmd_2tuple_filter_dst_port,
10202 (void *)&cmd_2tuple_filter_dst_port_value,
10203 (void *)&cmd_2tuple_filter_protocol,
10204 (void *)&cmd_2tuple_filter_protocol_value,
10205 (void *)&cmd_2tuple_filter_mask,
10206 (void *)&cmd_2tuple_filter_mask_value,
10207 (void *)&cmd_2tuple_filter_tcp_flags,
10208 (void *)&cmd_2tuple_filter_tcp_flags_value,
10209 (void *)&cmd_2tuple_filter_priority,
10210 (void *)&cmd_2tuple_filter_priority_value,
10211 (void *)&cmd_2tuple_filter_queue,
10212 (void *)&cmd_2tuple_filter_queue_id,
10217 /* *** ADD/REMOVE A 5tuple FILTER *** */
10218 struct cmd_5tuple_filter_result {
10219 cmdline_fixed_string_t filter;
10221 cmdline_fixed_string_t ops;
10222 cmdline_fixed_string_t dst_ip;
10223 cmdline_ipaddr_t dst_ip_value;
10224 cmdline_fixed_string_t src_ip;
10225 cmdline_ipaddr_t src_ip_value;
10226 cmdline_fixed_string_t dst_port;
10227 uint16_t dst_port_value;
10228 cmdline_fixed_string_t src_port;
10229 uint16_t src_port_value;
10230 cmdline_fixed_string_t protocol;
10231 uint8_t protocol_value;
10232 cmdline_fixed_string_t mask;
10233 uint8_t mask_value;
10234 cmdline_fixed_string_t tcp_flags;
10235 uint8_t tcp_flags_value;
10236 cmdline_fixed_string_t priority;
10237 uint8_t priority_value;
10238 cmdline_fixed_string_t queue;
10243 cmd_5tuple_filter_parsed(void *parsed_result,
10244 __attribute__((unused)) struct cmdline *cl,
10245 __attribute__((unused)) void *data)
10247 struct rte_eth_ntuple_filter filter;
10248 struct cmd_5tuple_filter_result *res = parsed_result;
10251 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10253 printf("ntuple filter is not supported on port %u.\n",
10258 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10260 filter.flags = RTE_5TUPLE_FLAGS;
10261 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10262 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10263 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10264 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10265 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10266 filter.proto = res->protocol_value;
10267 filter.priority = res->priority_value;
10268 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10269 printf("nonzero tcp_flags is only meaningful"
10270 " when protocol is TCP.\n");
10273 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10274 printf("invalid TCP flags.\n");
10278 if (res->tcp_flags_value != 0) {
10279 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10280 filter.tcp_flags = res->tcp_flags_value;
10283 if (res->dst_ip_value.family == AF_INET)
10284 /* no need to convert, already big endian. */
10285 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10287 if (filter.dst_ip_mask == 0) {
10288 printf("can not support ipv6 involved compare.\n");
10294 if (res->src_ip_value.family == AF_INET)
10295 /* no need to convert, already big endian. */
10296 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10298 if (filter.src_ip_mask == 0) {
10299 printf("can not support ipv6 involved compare.\n");
10304 /* need convert to big endian. */
10305 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10306 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10307 filter.queue = res->queue_id;
10309 if (!strcmp(res->ops, "add"))
10310 ret = rte_eth_dev_filter_ctrl(res->port_id,
10311 RTE_ETH_FILTER_NTUPLE,
10312 RTE_ETH_FILTER_ADD,
10315 ret = rte_eth_dev_filter_ctrl(res->port_id,
10316 RTE_ETH_FILTER_NTUPLE,
10317 RTE_ETH_FILTER_DELETE,
10320 printf("5tuple filter programming error: (%s)\n",
10324 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10325 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10326 filter, "5tuple_filter");
10327 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10328 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10330 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10331 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10333 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10334 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10336 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10337 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10339 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10340 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10342 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10343 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10345 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10346 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10347 dst_port, "dst_port");
10348 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10349 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10350 dst_port_value, UINT16);
10351 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10352 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10353 src_port, "src_port");
10354 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10355 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10356 src_port_value, UINT16);
10357 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10358 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10359 protocol, "protocol");
10360 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10361 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10362 protocol_value, UINT8);
10363 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10364 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10366 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10367 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10369 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10370 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10371 tcp_flags, "tcp_flags");
10372 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10373 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10374 tcp_flags_value, UINT8);
10375 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10376 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10377 priority, "priority");
10378 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10379 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10380 priority_value, UINT8);
10381 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10382 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10384 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10385 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10388 cmdline_parse_inst_t cmd_5tuple_filter = {
10389 .f = cmd_5tuple_filter_parsed,
10391 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10392 "src_ip <value> dst_port <value> src_port <value> "
10393 "protocol <value> mask <value> tcp_flags <value> "
10394 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10396 (void *)&cmd_5tuple_filter_filter,
10397 (void *)&cmd_5tuple_filter_port_id,
10398 (void *)&cmd_5tuple_filter_ops,
10399 (void *)&cmd_5tuple_filter_dst_ip,
10400 (void *)&cmd_5tuple_filter_dst_ip_value,
10401 (void *)&cmd_5tuple_filter_src_ip,
10402 (void *)&cmd_5tuple_filter_src_ip_value,
10403 (void *)&cmd_5tuple_filter_dst_port,
10404 (void *)&cmd_5tuple_filter_dst_port_value,
10405 (void *)&cmd_5tuple_filter_src_port,
10406 (void *)&cmd_5tuple_filter_src_port_value,
10407 (void *)&cmd_5tuple_filter_protocol,
10408 (void *)&cmd_5tuple_filter_protocol_value,
10409 (void *)&cmd_5tuple_filter_mask,
10410 (void *)&cmd_5tuple_filter_mask_value,
10411 (void *)&cmd_5tuple_filter_tcp_flags,
10412 (void *)&cmd_5tuple_filter_tcp_flags_value,
10413 (void *)&cmd_5tuple_filter_priority,
10414 (void *)&cmd_5tuple_filter_priority_value,
10415 (void *)&cmd_5tuple_filter_queue,
10416 (void *)&cmd_5tuple_filter_queue_id,
10421 /* *** ADD/REMOVE A flex FILTER *** */
10422 struct cmd_flex_filter_result {
10423 cmdline_fixed_string_t filter;
10424 cmdline_fixed_string_t ops;
10426 cmdline_fixed_string_t len;
10428 cmdline_fixed_string_t bytes;
10429 cmdline_fixed_string_t bytes_value;
10430 cmdline_fixed_string_t mask;
10431 cmdline_fixed_string_t mask_value;
10432 cmdline_fixed_string_t priority;
10433 uint8_t priority_value;
10434 cmdline_fixed_string_t queue;
10438 static int xdigit2val(unsigned char c)
10443 else if (isupper(c))
10444 val = c - 'A' + 10;
10446 val = c - 'a' + 10;
10451 cmd_flex_filter_parsed(void *parsed_result,
10452 __attribute__((unused)) struct cmdline *cl,
10453 __attribute__((unused)) void *data)
10456 struct rte_eth_flex_filter filter;
10457 struct cmd_flex_filter_result *res = parsed_result;
10458 char *bytes_ptr, *mask_ptr;
10459 uint16_t len, i, j = 0;
10464 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10465 printf("the len exceed the max length 128\n");
10468 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10469 filter.len = res->len_value;
10470 filter.priority = res->priority_value;
10471 filter.queue = res->queue_id;
10472 bytes_ptr = res->bytes_value;
10473 mask_ptr = res->mask_value;
10475 /* translate bytes string to array. */
10476 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10477 (bytes_ptr[1] == 'X')))
10479 len = strnlen(bytes_ptr, res->len_value * 2);
10480 if (len == 0 || (len % 8 != 0)) {
10481 printf("please check len and bytes input\n");
10484 for (i = 0; i < len; i++) {
10486 if (isxdigit(c) == 0) {
10487 /* invalid characters. */
10488 printf("invalid input\n");
10491 val = xdigit2val(c);
10494 filter.bytes[j] = byte;
10495 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10502 /* translate mask string to uint8_t array. */
10503 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10504 (mask_ptr[1] == 'X')))
10506 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10508 printf("invalid input\n");
10513 for (i = 0; i < len; i++) {
10515 if (isxdigit(c) == 0) {
10516 /* invalid characters. */
10517 printf("invalid input\n");
10520 val = xdigit2val(c);
10523 filter.mask[j] = byte;
10524 printf("mask[%d]:%02x ", j, filter.mask[j]);
10532 if (!strcmp(res->ops, "add"))
10533 ret = rte_eth_dev_filter_ctrl(res->port_id,
10534 RTE_ETH_FILTER_FLEXIBLE,
10535 RTE_ETH_FILTER_ADD,
10538 ret = rte_eth_dev_filter_ctrl(res->port_id,
10539 RTE_ETH_FILTER_FLEXIBLE,
10540 RTE_ETH_FILTER_DELETE,
10544 printf("flex filter setting error: (%s)\n", strerror(-ret));
10547 cmdline_parse_token_string_t cmd_flex_filter_filter =
10548 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10549 filter, "flex_filter");
10550 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10551 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10553 cmdline_parse_token_string_t cmd_flex_filter_ops =
10554 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10556 cmdline_parse_token_string_t cmd_flex_filter_len =
10557 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10559 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10560 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10562 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10563 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10565 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10566 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10567 bytes_value, NULL);
10568 cmdline_parse_token_string_t cmd_flex_filter_mask =
10569 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10571 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10572 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10574 cmdline_parse_token_string_t cmd_flex_filter_priority =
10575 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10576 priority, "priority");
10577 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10578 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10579 priority_value, UINT8);
10580 cmdline_parse_token_string_t cmd_flex_filter_queue =
10581 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10583 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10584 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10586 cmdline_parse_inst_t cmd_flex_filter = {
10587 .f = cmd_flex_filter_parsed,
10589 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10590 "<value> mask <value> priority <value> queue <queue_id>: "
10591 "Add/Del a flex filter",
10593 (void *)&cmd_flex_filter_filter,
10594 (void *)&cmd_flex_filter_port_id,
10595 (void *)&cmd_flex_filter_ops,
10596 (void *)&cmd_flex_filter_len,
10597 (void *)&cmd_flex_filter_len_value,
10598 (void *)&cmd_flex_filter_bytes,
10599 (void *)&cmd_flex_filter_bytes_value,
10600 (void *)&cmd_flex_filter_mask,
10601 (void *)&cmd_flex_filter_mask_value,
10602 (void *)&cmd_flex_filter_priority,
10603 (void *)&cmd_flex_filter_priority_value,
10604 (void *)&cmd_flex_filter_queue,
10605 (void *)&cmd_flex_filter_queue_id,
10610 /* *** Filters Control *** */
10612 /* *** deal with ethertype filter *** */
10613 struct cmd_ethertype_filter_result {
10614 cmdline_fixed_string_t filter;
10616 cmdline_fixed_string_t ops;
10617 cmdline_fixed_string_t mac;
10618 struct rte_ether_addr mac_addr;
10619 cmdline_fixed_string_t ethertype;
10620 uint16_t ethertype_value;
10621 cmdline_fixed_string_t drop;
10622 cmdline_fixed_string_t queue;
10626 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10627 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10628 filter, "ethertype_filter");
10629 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10630 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10632 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10633 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10635 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10636 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10637 mac, "mac_addr#mac_ignr");
10638 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10639 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10641 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10642 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10643 ethertype, "ethertype");
10644 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10645 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10646 ethertype_value, UINT16);
10647 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10648 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10650 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10651 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10653 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10654 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10658 cmd_ethertype_filter_parsed(void *parsed_result,
10659 __attribute__((unused)) struct cmdline *cl,
10660 __attribute__((unused)) void *data)
10662 struct cmd_ethertype_filter_result *res = parsed_result;
10663 struct rte_eth_ethertype_filter filter;
10666 ret = rte_eth_dev_filter_supported(res->port_id,
10667 RTE_ETH_FILTER_ETHERTYPE);
10669 printf("ethertype filter is not supported on port %u.\n",
10674 memset(&filter, 0, sizeof(filter));
10675 if (!strcmp(res->mac, "mac_addr")) {
10676 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10677 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10678 sizeof(struct rte_ether_addr));
10680 if (!strcmp(res->drop, "drop"))
10681 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10682 filter.ether_type = res->ethertype_value;
10683 filter.queue = res->queue_id;
10685 if (!strcmp(res->ops, "add"))
10686 ret = rte_eth_dev_filter_ctrl(res->port_id,
10687 RTE_ETH_FILTER_ETHERTYPE,
10688 RTE_ETH_FILTER_ADD,
10691 ret = rte_eth_dev_filter_ctrl(res->port_id,
10692 RTE_ETH_FILTER_ETHERTYPE,
10693 RTE_ETH_FILTER_DELETE,
10696 printf("ethertype filter programming error: (%s)\n",
10700 cmdline_parse_inst_t cmd_ethertype_filter = {
10701 .f = cmd_ethertype_filter_parsed,
10703 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10704 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10705 "Add or delete an ethertype filter entry",
10707 (void *)&cmd_ethertype_filter_filter,
10708 (void *)&cmd_ethertype_filter_port_id,
10709 (void *)&cmd_ethertype_filter_ops,
10710 (void *)&cmd_ethertype_filter_mac,
10711 (void *)&cmd_ethertype_filter_mac_addr,
10712 (void *)&cmd_ethertype_filter_ethertype,
10713 (void *)&cmd_ethertype_filter_ethertype_value,
10714 (void *)&cmd_ethertype_filter_drop,
10715 (void *)&cmd_ethertype_filter_queue,
10716 (void *)&cmd_ethertype_filter_queue_id,
10721 /* *** deal with flow director filter *** */
10722 struct cmd_flow_director_result {
10723 cmdline_fixed_string_t flow_director_filter;
10725 cmdline_fixed_string_t mode;
10726 cmdline_fixed_string_t mode_value;
10727 cmdline_fixed_string_t ops;
10728 cmdline_fixed_string_t flow;
10729 cmdline_fixed_string_t flow_type;
10730 cmdline_fixed_string_t ether;
10731 uint16_t ether_type;
10732 cmdline_fixed_string_t src;
10733 cmdline_ipaddr_t ip_src;
10735 cmdline_fixed_string_t dst;
10736 cmdline_ipaddr_t ip_dst;
10738 cmdline_fixed_string_t verify_tag;
10739 uint32_t verify_tag_value;
10740 cmdline_fixed_string_t tos;
10742 cmdline_fixed_string_t proto;
10743 uint8_t proto_value;
10744 cmdline_fixed_string_t ttl;
10746 cmdline_fixed_string_t vlan;
10747 uint16_t vlan_value;
10748 cmdline_fixed_string_t flexbytes;
10749 cmdline_fixed_string_t flexbytes_value;
10750 cmdline_fixed_string_t pf_vf;
10751 cmdline_fixed_string_t drop;
10752 cmdline_fixed_string_t queue;
10754 cmdline_fixed_string_t fd_id;
10755 uint32_t fd_id_value;
10756 cmdline_fixed_string_t mac;
10757 struct rte_ether_addr mac_addr;
10758 cmdline_fixed_string_t tunnel;
10759 cmdline_fixed_string_t tunnel_type;
10760 cmdline_fixed_string_t tunnel_id;
10761 uint32_t tunnel_id_value;
10762 cmdline_fixed_string_t packet;
10767 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10770 const char *p, *p0 = q_arg;
10772 unsigned long int_fld;
10773 char *str_fld[max_num];
10778 p = strchr(p0, '(');
10782 p0 = strchr(p, ')');
10787 if (size >= sizeof(s))
10790 snprintf(s, sizeof(s), "%.*s", size, p);
10791 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10792 if (ret < 0 || ret > max_num)
10794 for (i = 0; i < ret; i++) {
10796 int_fld = strtoul(str_fld[i], &end, 0);
10797 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10799 flexbytes[i] = (uint8_t)int_fld;
10805 str2flowtype(char *string)
10808 static const struct {
10811 } flowtype_str[] = {
10812 {"raw", RTE_ETH_FLOW_RAW},
10813 {"ipv4", RTE_ETH_FLOW_IPV4},
10814 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10815 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10816 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10817 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10818 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10819 {"ipv6", RTE_ETH_FLOW_IPV6},
10820 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10821 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10822 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10823 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10824 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10825 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10828 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10829 if (!strcmp(flowtype_str[i].str, string))
10830 return flowtype_str[i].type;
10833 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10834 return (uint16_t)atoi(string);
10836 return RTE_ETH_FLOW_UNKNOWN;
10839 static enum rte_eth_fdir_tunnel_type
10840 str2fdir_tunneltype(char *string)
10844 static const struct {
10846 enum rte_eth_fdir_tunnel_type type;
10847 } tunneltype_str[] = {
10848 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10849 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10852 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10853 if (!strcmp(tunneltype_str[i].str, string))
10854 return tunneltype_str[i].type;
10856 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10859 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10861 if ((ip_addr).family == AF_INET) \
10862 (ip) = (ip_addr).addr.ipv4.s_addr; \
10864 printf("invalid parameter.\n"); \
10869 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10871 if ((ip_addr).family == AF_INET6) \
10872 rte_memcpy(&(ip), \
10873 &((ip_addr).addr.ipv6), \
10874 sizeof(struct in6_addr)); \
10876 printf("invalid parameter.\n"); \
10882 cmd_flow_director_filter_parsed(void *parsed_result,
10883 __attribute__((unused)) struct cmdline *cl,
10884 __attribute__((unused)) void *data)
10886 struct cmd_flow_director_result *res = parsed_result;
10887 struct rte_eth_fdir_filter entry;
10888 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10890 unsigned long vf_id;
10893 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10895 printf("flow director is not supported on port %u.\n",
10899 memset(flexbytes, 0, sizeof(flexbytes));
10900 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10902 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10903 if (strcmp(res->mode_value, "MAC-VLAN")) {
10904 printf("Please set mode to MAC-VLAN.\n");
10907 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10908 if (strcmp(res->mode_value, "Tunnel")) {
10909 printf("Please set mode to Tunnel.\n");
10913 if (!strcmp(res->mode_value, "raw")) {
10914 #ifdef RTE_LIBRTE_I40E_PMD
10915 struct rte_pmd_i40e_flow_type_mapping
10916 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10917 struct rte_pmd_i40e_pkt_template_conf conf;
10918 uint16_t flow_type = str2flowtype(res->flow_type);
10919 uint16_t i, port = res->port_id;
10922 memset(&conf, 0, sizeof(conf));
10924 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10925 printf("Invalid flow type specified.\n");
10928 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10932 if (mapping[flow_type].pctype == 0ULL) {
10933 printf("Invalid flow type specified.\n");
10936 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10937 if (mapping[flow_type].pctype & (1ULL << i)) {
10938 conf.input.pctype = i;
10943 conf.input.packet = open_file(res->filepath,
10944 &conf.input.length);
10945 if (!conf.input.packet)
10947 if (!strcmp(res->drop, "drop"))
10948 conf.action.behavior =
10949 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10951 conf.action.behavior =
10952 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10953 conf.action.report_status =
10954 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10955 conf.action.rx_queue = res->queue_id;
10956 conf.soft_id = res->fd_id_value;
10957 add = strcmp(res->ops, "del") ? 1 : 0;
10958 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10962 printf("flow director config error: (%s)\n",
10964 close_file(conf.input.packet);
10967 } else if (strcmp(res->mode_value, "IP")) {
10968 printf("Please set mode to IP or raw.\n");
10971 entry.input.flow_type = str2flowtype(res->flow_type);
10974 ret = parse_flexbytes(res->flexbytes_value,
10976 RTE_ETH_FDIR_MAX_FLEXLEN);
10978 printf("error: Cannot parse flexbytes input.\n");
10982 switch (entry.input.flow_type) {
10983 case RTE_ETH_FLOW_FRAG_IPV4:
10984 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10985 entry.input.flow.ip4_flow.proto = res->proto_value;
10987 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10988 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10989 IPV4_ADDR_TO_UINT(res->ip_dst,
10990 entry.input.flow.ip4_flow.dst_ip);
10991 IPV4_ADDR_TO_UINT(res->ip_src,
10992 entry.input.flow.ip4_flow.src_ip);
10993 entry.input.flow.ip4_flow.tos = res->tos_value;
10994 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10995 /* need convert to big endian. */
10996 entry.input.flow.udp4_flow.dst_port =
10997 rte_cpu_to_be_16(res->port_dst);
10998 entry.input.flow.udp4_flow.src_port =
10999 rte_cpu_to_be_16(res->port_src);
11001 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11002 IPV4_ADDR_TO_UINT(res->ip_dst,
11003 entry.input.flow.sctp4_flow.ip.dst_ip);
11004 IPV4_ADDR_TO_UINT(res->ip_src,
11005 entry.input.flow.sctp4_flow.ip.src_ip);
11006 entry.input.flow.ip4_flow.tos = res->tos_value;
11007 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11008 /* need convert to big endian. */
11009 entry.input.flow.sctp4_flow.dst_port =
11010 rte_cpu_to_be_16(res->port_dst);
11011 entry.input.flow.sctp4_flow.src_port =
11012 rte_cpu_to_be_16(res->port_src);
11013 entry.input.flow.sctp4_flow.verify_tag =
11014 rte_cpu_to_be_32(res->verify_tag_value);
11016 case RTE_ETH_FLOW_FRAG_IPV6:
11017 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11018 entry.input.flow.ipv6_flow.proto = res->proto_value;
11020 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11021 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11022 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11023 entry.input.flow.ipv6_flow.dst_ip);
11024 IPV6_ADDR_TO_ARRAY(res->ip_src,
11025 entry.input.flow.ipv6_flow.src_ip);
11026 entry.input.flow.ipv6_flow.tc = res->tos_value;
11027 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11028 /* need convert to big endian. */
11029 entry.input.flow.udp6_flow.dst_port =
11030 rte_cpu_to_be_16(res->port_dst);
11031 entry.input.flow.udp6_flow.src_port =
11032 rte_cpu_to_be_16(res->port_src);
11034 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11035 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11036 entry.input.flow.sctp6_flow.ip.dst_ip);
11037 IPV6_ADDR_TO_ARRAY(res->ip_src,
11038 entry.input.flow.sctp6_flow.ip.src_ip);
11039 entry.input.flow.ipv6_flow.tc = res->tos_value;
11040 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11041 /* need convert to big endian. */
11042 entry.input.flow.sctp6_flow.dst_port =
11043 rte_cpu_to_be_16(res->port_dst);
11044 entry.input.flow.sctp6_flow.src_port =
11045 rte_cpu_to_be_16(res->port_src);
11046 entry.input.flow.sctp6_flow.verify_tag =
11047 rte_cpu_to_be_32(res->verify_tag_value);
11049 case RTE_ETH_FLOW_L2_PAYLOAD:
11050 entry.input.flow.l2_flow.ether_type =
11051 rte_cpu_to_be_16(res->ether_type);
11057 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11058 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11060 sizeof(struct rte_ether_addr));
11062 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11063 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11065 sizeof(struct rte_ether_addr));
11066 entry.input.flow.tunnel_flow.tunnel_type =
11067 str2fdir_tunneltype(res->tunnel_type);
11068 entry.input.flow.tunnel_flow.tunnel_id =
11069 rte_cpu_to_be_32(res->tunnel_id_value);
11072 rte_memcpy(entry.input.flow_ext.flexbytes,
11074 RTE_ETH_FDIR_MAX_FLEXLEN);
11076 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11078 entry.action.flex_off = 0; /*use 0 by default */
11079 if (!strcmp(res->drop, "drop"))
11080 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11082 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11084 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11085 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11086 if (!strcmp(res->pf_vf, "pf"))
11087 entry.input.flow_ext.is_vf = 0;
11088 else if (!strncmp(res->pf_vf, "vf", 2)) {
11089 struct rte_eth_dev_info dev_info;
11091 rte_eth_dev_info_get(res->port_id, &dev_info);
11093 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11094 if (errno != 0 || *end != '\0' ||
11095 vf_id >= dev_info.max_vfs) {
11096 printf("invalid parameter %s.\n", res->pf_vf);
11099 entry.input.flow_ext.is_vf = 1;
11100 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11102 printf("invalid parameter %s.\n", res->pf_vf);
11107 /* set to report FD ID by default */
11108 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11109 entry.action.rx_queue = res->queue_id;
11110 entry.soft_id = res->fd_id_value;
11111 if (!strcmp(res->ops, "add"))
11112 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11113 RTE_ETH_FILTER_ADD, &entry);
11114 else if (!strcmp(res->ops, "del"))
11115 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11116 RTE_ETH_FILTER_DELETE, &entry);
11118 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11119 RTE_ETH_FILTER_UPDATE, &entry);
11121 printf("flow director programming error: (%s)\n",
11125 cmdline_parse_token_string_t cmd_flow_director_filter =
11126 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11127 flow_director_filter, "flow_director_filter");
11128 cmdline_parse_token_num_t cmd_flow_director_port_id =
11129 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11131 cmdline_parse_token_string_t cmd_flow_director_ops =
11132 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11133 ops, "add#del#update");
11134 cmdline_parse_token_string_t cmd_flow_director_flow =
11135 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11137 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11138 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11140 cmdline_parse_token_string_t cmd_flow_director_ether =
11141 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11143 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11144 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11145 ether_type, UINT16);
11146 cmdline_parse_token_string_t cmd_flow_director_src =
11147 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11149 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11150 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11152 cmdline_parse_token_num_t cmd_flow_director_port_src =
11153 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11155 cmdline_parse_token_string_t cmd_flow_director_dst =
11156 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11158 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11159 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11161 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11162 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11164 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11165 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11166 verify_tag, "verify_tag");
11167 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11168 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11169 verify_tag_value, UINT32);
11170 cmdline_parse_token_string_t cmd_flow_director_tos =
11171 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11173 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11174 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11176 cmdline_parse_token_string_t cmd_flow_director_proto =
11177 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11179 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11180 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11181 proto_value, UINT8);
11182 cmdline_parse_token_string_t cmd_flow_director_ttl =
11183 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11185 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11186 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11188 cmdline_parse_token_string_t cmd_flow_director_vlan =
11189 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11191 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11192 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11193 vlan_value, UINT16);
11194 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11195 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11196 flexbytes, "flexbytes");
11197 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11198 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11199 flexbytes_value, NULL);
11200 cmdline_parse_token_string_t cmd_flow_director_drop =
11201 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11203 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11204 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11206 cmdline_parse_token_string_t cmd_flow_director_queue =
11207 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11209 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11210 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11212 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11213 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11215 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11216 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11217 fd_id_value, UINT32);
11219 cmdline_parse_token_string_t cmd_flow_director_mode =
11220 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11222 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11223 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11225 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11226 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11227 mode_value, "MAC-VLAN");
11228 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11229 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11230 mode_value, "Tunnel");
11231 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11232 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11233 mode_value, "raw");
11234 cmdline_parse_token_string_t cmd_flow_director_mac =
11235 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11237 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11238 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11240 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11241 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11243 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11244 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11245 tunnel_type, "NVGRE#VxLAN");
11246 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11247 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11248 tunnel_id, "tunnel-id");
11249 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11250 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11251 tunnel_id_value, UINT32);
11252 cmdline_parse_token_string_t cmd_flow_director_packet =
11253 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11255 cmdline_parse_token_string_t cmd_flow_director_filepath =
11256 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11259 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11260 .f = cmd_flow_director_filter_parsed,
11262 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11263 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11264 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11265 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11266 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11267 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11268 "fd_id <fd_id_value>: "
11269 "Add or delete an ip flow director entry on NIC",
11271 (void *)&cmd_flow_director_filter,
11272 (void *)&cmd_flow_director_port_id,
11273 (void *)&cmd_flow_director_mode,
11274 (void *)&cmd_flow_director_mode_ip,
11275 (void *)&cmd_flow_director_ops,
11276 (void *)&cmd_flow_director_flow,
11277 (void *)&cmd_flow_director_flow_type,
11278 (void *)&cmd_flow_director_src,
11279 (void *)&cmd_flow_director_ip_src,
11280 (void *)&cmd_flow_director_dst,
11281 (void *)&cmd_flow_director_ip_dst,
11282 (void *)&cmd_flow_director_tos,
11283 (void *)&cmd_flow_director_tos_value,
11284 (void *)&cmd_flow_director_proto,
11285 (void *)&cmd_flow_director_proto_value,
11286 (void *)&cmd_flow_director_ttl,
11287 (void *)&cmd_flow_director_ttl_value,
11288 (void *)&cmd_flow_director_vlan,
11289 (void *)&cmd_flow_director_vlan_value,
11290 (void *)&cmd_flow_director_flexbytes,
11291 (void *)&cmd_flow_director_flexbytes_value,
11292 (void *)&cmd_flow_director_drop,
11293 (void *)&cmd_flow_director_pf_vf,
11294 (void *)&cmd_flow_director_queue,
11295 (void *)&cmd_flow_director_queue_id,
11296 (void *)&cmd_flow_director_fd_id,
11297 (void *)&cmd_flow_director_fd_id_value,
11302 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11303 .f = cmd_flow_director_filter_parsed,
11305 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11306 "director entry on NIC",
11308 (void *)&cmd_flow_director_filter,
11309 (void *)&cmd_flow_director_port_id,
11310 (void *)&cmd_flow_director_mode,
11311 (void *)&cmd_flow_director_mode_ip,
11312 (void *)&cmd_flow_director_ops,
11313 (void *)&cmd_flow_director_flow,
11314 (void *)&cmd_flow_director_flow_type,
11315 (void *)&cmd_flow_director_src,
11316 (void *)&cmd_flow_director_ip_src,
11317 (void *)&cmd_flow_director_port_src,
11318 (void *)&cmd_flow_director_dst,
11319 (void *)&cmd_flow_director_ip_dst,
11320 (void *)&cmd_flow_director_port_dst,
11321 (void *)&cmd_flow_director_tos,
11322 (void *)&cmd_flow_director_tos_value,
11323 (void *)&cmd_flow_director_ttl,
11324 (void *)&cmd_flow_director_ttl_value,
11325 (void *)&cmd_flow_director_vlan,
11326 (void *)&cmd_flow_director_vlan_value,
11327 (void *)&cmd_flow_director_flexbytes,
11328 (void *)&cmd_flow_director_flexbytes_value,
11329 (void *)&cmd_flow_director_drop,
11330 (void *)&cmd_flow_director_pf_vf,
11331 (void *)&cmd_flow_director_queue,
11332 (void *)&cmd_flow_director_queue_id,
11333 (void *)&cmd_flow_director_fd_id,
11334 (void *)&cmd_flow_director_fd_id_value,
11339 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11340 .f = cmd_flow_director_filter_parsed,
11342 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11343 "director entry on NIC",
11345 (void *)&cmd_flow_director_filter,
11346 (void *)&cmd_flow_director_port_id,
11347 (void *)&cmd_flow_director_mode,
11348 (void *)&cmd_flow_director_mode_ip,
11349 (void *)&cmd_flow_director_ops,
11350 (void *)&cmd_flow_director_flow,
11351 (void *)&cmd_flow_director_flow_type,
11352 (void *)&cmd_flow_director_src,
11353 (void *)&cmd_flow_director_ip_src,
11354 (void *)&cmd_flow_director_port_src,
11355 (void *)&cmd_flow_director_dst,
11356 (void *)&cmd_flow_director_ip_dst,
11357 (void *)&cmd_flow_director_port_dst,
11358 (void *)&cmd_flow_director_verify_tag,
11359 (void *)&cmd_flow_director_verify_tag_value,
11360 (void *)&cmd_flow_director_tos,
11361 (void *)&cmd_flow_director_tos_value,
11362 (void *)&cmd_flow_director_ttl,
11363 (void *)&cmd_flow_director_ttl_value,
11364 (void *)&cmd_flow_director_vlan,
11365 (void *)&cmd_flow_director_vlan_value,
11366 (void *)&cmd_flow_director_flexbytes,
11367 (void *)&cmd_flow_director_flexbytes_value,
11368 (void *)&cmd_flow_director_drop,
11369 (void *)&cmd_flow_director_pf_vf,
11370 (void *)&cmd_flow_director_queue,
11371 (void *)&cmd_flow_director_queue_id,
11372 (void *)&cmd_flow_director_fd_id,
11373 (void *)&cmd_flow_director_fd_id_value,
11378 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11379 .f = cmd_flow_director_filter_parsed,
11381 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11382 "director entry on NIC",
11384 (void *)&cmd_flow_director_filter,
11385 (void *)&cmd_flow_director_port_id,
11386 (void *)&cmd_flow_director_mode,
11387 (void *)&cmd_flow_director_mode_ip,
11388 (void *)&cmd_flow_director_ops,
11389 (void *)&cmd_flow_director_flow,
11390 (void *)&cmd_flow_director_flow_type,
11391 (void *)&cmd_flow_director_ether,
11392 (void *)&cmd_flow_director_ether_type,
11393 (void *)&cmd_flow_director_flexbytes,
11394 (void *)&cmd_flow_director_flexbytes_value,
11395 (void *)&cmd_flow_director_drop,
11396 (void *)&cmd_flow_director_pf_vf,
11397 (void *)&cmd_flow_director_queue,
11398 (void *)&cmd_flow_director_queue_id,
11399 (void *)&cmd_flow_director_fd_id,
11400 (void *)&cmd_flow_director_fd_id_value,
11405 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11406 .f = cmd_flow_director_filter_parsed,
11408 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11409 "director entry on NIC",
11411 (void *)&cmd_flow_director_filter,
11412 (void *)&cmd_flow_director_port_id,
11413 (void *)&cmd_flow_director_mode,
11414 (void *)&cmd_flow_director_mode_mac_vlan,
11415 (void *)&cmd_flow_director_ops,
11416 (void *)&cmd_flow_director_mac,
11417 (void *)&cmd_flow_director_mac_addr,
11418 (void *)&cmd_flow_director_vlan,
11419 (void *)&cmd_flow_director_vlan_value,
11420 (void *)&cmd_flow_director_flexbytes,
11421 (void *)&cmd_flow_director_flexbytes_value,
11422 (void *)&cmd_flow_director_drop,
11423 (void *)&cmd_flow_director_queue,
11424 (void *)&cmd_flow_director_queue_id,
11425 (void *)&cmd_flow_director_fd_id,
11426 (void *)&cmd_flow_director_fd_id_value,
11431 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11432 .f = cmd_flow_director_filter_parsed,
11434 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11435 "director entry on NIC",
11437 (void *)&cmd_flow_director_filter,
11438 (void *)&cmd_flow_director_port_id,
11439 (void *)&cmd_flow_director_mode,
11440 (void *)&cmd_flow_director_mode_tunnel,
11441 (void *)&cmd_flow_director_ops,
11442 (void *)&cmd_flow_director_mac,
11443 (void *)&cmd_flow_director_mac_addr,
11444 (void *)&cmd_flow_director_vlan,
11445 (void *)&cmd_flow_director_vlan_value,
11446 (void *)&cmd_flow_director_tunnel,
11447 (void *)&cmd_flow_director_tunnel_type,
11448 (void *)&cmd_flow_director_tunnel_id,
11449 (void *)&cmd_flow_director_tunnel_id_value,
11450 (void *)&cmd_flow_director_flexbytes,
11451 (void *)&cmd_flow_director_flexbytes_value,
11452 (void *)&cmd_flow_director_drop,
11453 (void *)&cmd_flow_director_queue,
11454 (void *)&cmd_flow_director_queue_id,
11455 (void *)&cmd_flow_director_fd_id,
11456 (void *)&cmd_flow_director_fd_id_value,
11461 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11462 .f = cmd_flow_director_filter_parsed,
11464 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11465 "director entry on NIC",
11467 (void *)&cmd_flow_director_filter,
11468 (void *)&cmd_flow_director_port_id,
11469 (void *)&cmd_flow_director_mode,
11470 (void *)&cmd_flow_director_mode_raw,
11471 (void *)&cmd_flow_director_ops,
11472 (void *)&cmd_flow_director_flow,
11473 (void *)&cmd_flow_director_flow_type,
11474 (void *)&cmd_flow_director_drop,
11475 (void *)&cmd_flow_director_queue,
11476 (void *)&cmd_flow_director_queue_id,
11477 (void *)&cmd_flow_director_fd_id,
11478 (void *)&cmd_flow_director_fd_id_value,
11479 (void *)&cmd_flow_director_packet,
11480 (void *)&cmd_flow_director_filepath,
11485 struct cmd_flush_flow_director_result {
11486 cmdline_fixed_string_t flush_flow_director;
11490 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11491 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11492 flush_flow_director, "flush_flow_director");
11493 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11494 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11498 cmd_flush_flow_director_parsed(void *parsed_result,
11499 __attribute__((unused)) struct cmdline *cl,
11500 __attribute__((unused)) void *data)
11502 struct cmd_flow_director_result *res = parsed_result;
11505 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11507 printf("flow director is not supported on port %u.\n",
11512 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11513 RTE_ETH_FILTER_FLUSH, NULL);
11515 printf("flow director table flushing error: (%s)\n",
11519 cmdline_parse_inst_t cmd_flush_flow_director = {
11520 .f = cmd_flush_flow_director_parsed,
11522 .help_str = "flush_flow_director <port_id>: "
11523 "Flush all flow director entries of a device on NIC",
11525 (void *)&cmd_flush_flow_director_flush,
11526 (void *)&cmd_flush_flow_director_port_id,
11531 /* *** deal with flow director mask *** */
11532 struct cmd_flow_director_mask_result {
11533 cmdline_fixed_string_t flow_director_mask;
11535 cmdline_fixed_string_t mode;
11536 cmdline_fixed_string_t mode_value;
11537 cmdline_fixed_string_t vlan;
11538 uint16_t vlan_mask;
11539 cmdline_fixed_string_t src_mask;
11540 cmdline_ipaddr_t ipv4_src;
11541 cmdline_ipaddr_t ipv6_src;
11543 cmdline_fixed_string_t dst_mask;
11544 cmdline_ipaddr_t ipv4_dst;
11545 cmdline_ipaddr_t ipv6_dst;
11547 cmdline_fixed_string_t mac;
11548 uint8_t mac_addr_byte_mask;
11549 cmdline_fixed_string_t tunnel_id;
11550 uint32_t tunnel_id_mask;
11551 cmdline_fixed_string_t tunnel_type;
11552 uint8_t tunnel_type_mask;
11556 cmd_flow_director_mask_parsed(void *parsed_result,
11557 __attribute__((unused)) struct cmdline *cl,
11558 __attribute__((unused)) void *data)
11560 struct cmd_flow_director_mask_result *res = parsed_result;
11561 struct rte_eth_fdir_masks *mask;
11562 struct rte_port *port;
11564 port = &ports[res->port_id];
11565 /** Check if the port is not started **/
11566 if (port->port_status != RTE_PORT_STOPPED) {
11567 printf("Please stop port %d first\n", res->port_id);
11571 mask = &port->dev_conf.fdir_conf.mask;
11573 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11574 if (strcmp(res->mode_value, "MAC-VLAN")) {
11575 printf("Please set mode to MAC-VLAN.\n");
11579 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11580 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11581 if (strcmp(res->mode_value, "Tunnel")) {
11582 printf("Please set mode to Tunnel.\n");
11586 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11587 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11588 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11589 mask->tunnel_type_mask = res->tunnel_type_mask;
11591 if (strcmp(res->mode_value, "IP")) {
11592 printf("Please set mode to IP.\n");
11596 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11597 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11598 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11599 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11600 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11601 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11602 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11605 cmd_reconfig_device_queue(res->port_id, 1, 1);
11608 cmdline_parse_token_string_t cmd_flow_director_mask =
11609 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11610 flow_director_mask, "flow_director_mask");
11611 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11612 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11614 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11615 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11617 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11618 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11619 vlan_mask, UINT16);
11620 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11621 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11622 src_mask, "src_mask");
11623 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11624 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11626 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11627 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11629 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11630 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11632 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11633 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11634 dst_mask, "dst_mask");
11635 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11636 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11638 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11639 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11641 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11642 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11645 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11646 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11648 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11649 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11651 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11652 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11653 mode_value, "MAC-VLAN");
11654 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11655 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11656 mode_value, "Tunnel");
11657 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11658 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11660 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11661 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11662 mac_addr_byte_mask, UINT8);
11663 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11664 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11665 tunnel_type, "tunnel-type");
11666 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11667 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11668 tunnel_type_mask, UINT8);
11669 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11670 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11671 tunnel_id, "tunnel-id");
11672 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11673 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11674 tunnel_id_mask, UINT32);
11676 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11677 .f = cmd_flow_director_mask_parsed,
11679 .help_str = "flow_director_mask ... : "
11680 "Set IP mode flow director's mask on NIC",
11682 (void *)&cmd_flow_director_mask,
11683 (void *)&cmd_flow_director_mask_port_id,
11684 (void *)&cmd_flow_director_mask_mode,
11685 (void *)&cmd_flow_director_mask_mode_ip,
11686 (void *)&cmd_flow_director_mask_vlan,
11687 (void *)&cmd_flow_director_mask_vlan_value,
11688 (void *)&cmd_flow_director_mask_src,
11689 (void *)&cmd_flow_director_mask_ipv4_src,
11690 (void *)&cmd_flow_director_mask_ipv6_src,
11691 (void *)&cmd_flow_director_mask_port_src,
11692 (void *)&cmd_flow_director_mask_dst,
11693 (void *)&cmd_flow_director_mask_ipv4_dst,
11694 (void *)&cmd_flow_director_mask_ipv6_dst,
11695 (void *)&cmd_flow_director_mask_port_dst,
11700 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11701 .f = cmd_flow_director_mask_parsed,
11703 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11704 "flow director's mask on NIC",
11706 (void *)&cmd_flow_director_mask,
11707 (void *)&cmd_flow_director_mask_port_id,
11708 (void *)&cmd_flow_director_mask_mode,
11709 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11710 (void *)&cmd_flow_director_mask_vlan,
11711 (void *)&cmd_flow_director_mask_vlan_value,
11716 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11717 .f = cmd_flow_director_mask_parsed,
11719 .help_str = "flow_director_mask ... : Set tunnel mode "
11720 "flow director's mask on NIC",
11722 (void *)&cmd_flow_director_mask,
11723 (void *)&cmd_flow_director_mask_port_id,
11724 (void *)&cmd_flow_director_mask_mode,
11725 (void *)&cmd_flow_director_mask_mode_tunnel,
11726 (void *)&cmd_flow_director_mask_vlan,
11727 (void *)&cmd_flow_director_mask_vlan_value,
11728 (void *)&cmd_flow_director_mask_mac,
11729 (void *)&cmd_flow_director_mask_mac_value,
11730 (void *)&cmd_flow_director_mask_tunnel_type,
11731 (void *)&cmd_flow_director_mask_tunnel_type_value,
11732 (void *)&cmd_flow_director_mask_tunnel_id,
11733 (void *)&cmd_flow_director_mask_tunnel_id_value,
11738 /* *** deal with flow director mask on flexible payload *** */
11739 struct cmd_flow_director_flex_mask_result {
11740 cmdline_fixed_string_t flow_director_flexmask;
11742 cmdline_fixed_string_t flow;
11743 cmdline_fixed_string_t flow_type;
11744 cmdline_fixed_string_t mask;
11748 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11749 __attribute__((unused)) struct cmdline *cl,
11750 __attribute__((unused)) void *data)
11752 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11753 struct rte_eth_fdir_info fdir_info;
11754 struct rte_eth_fdir_flex_mask flex_mask;
11755 struct rte_port *port;
11756 uint64_t flow_type_mask;
11760 port = &ports[res->port_id];
11761 /** Check if the port is not started **/
11762 if (port->port_status != RTE_PORT_STOPPED) {
11763 printf("Please stop port %d first\n", res->port_id);
11767 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11768 ret = parse_flexbytes(res->mask,
11770 RTE_ETH_FDIR_MAX_FLEXLEN);
11772 printf("error: Cannot parse mask input.\n");
11776 memset(&fdir_info, 0, sizeof(fdir_info));
11777 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11778 RTE_ETH_FILTER_INFO, &fdir_info);
11780 printf("Cannot get FDir filter info\n");
11784 if (!strcmp(res->flow_type, "none")) {
11785 /* means don't specify the flow type */
11786 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11787 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11788 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11789 0, sizeof(struct rte_eth_fdir_flex_mask));
11790 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11791 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11793 sizeof(struct rte_eth_fdir_flex_mask));
11794 cmd_reconfig_device_queue(res->port_id, 1, 1);
11797 flow_type_mask = fdir_info.flow_types_mask[0];
11798 if (!strcmp(res->flow_type, "all")) {
11799 if (!flow_type_mask) {
11800 printf("No flow type supported\n");
11803 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11804 if (flow_type_mask & (1ULL << i)) {
11805 flex_mask.flow_type = i;
11806 fdir_set_flex_mask(res->port_id, &flex_mask);
11809 cmd_reconfig_device_queue(res->port_id, 1, 1);
11812 flex_mask.flow_type = str2flowtype(res->flow_type);
11813 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11814 printf("Flow type %s not supported on port %d\n",
11815 res->flow_type, res->port_id);
11818 fdir_set_flex_mask(res->port_id, &flex_mask);
11819 cmd_reconfig_device_queue(res->port_id, 1, 1);
11822 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11823 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11824 flow_director_flexmask,
11825 "flow_director_flex_mask");
11826 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11827 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11829 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11830 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11832 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11833 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11834 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11835 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11836 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11837 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11840 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11841 .f = cmd_flow_director_flex_mask_parsed,
11843 .help_str = "flow_director_flex_mask ... : "
11844 "Set flow director's flex mask on NIC",
11846 (void *)&cmd_flow_director_flexmask,
11847 (void *)&cmd_flow_director_flexmask_port_id,
11848 (void *)&cmd_flow_director_flexmask_flow,
11849 (void *)&cmd_flow_director_flexmask_flow_type,
11850 (void *)&cmd_flow_director_flexmask_mask,
11855 /* *** deal with flow director flexible payload configuration *** */
11856 struct cmd_flow_director_flexpayload_result {
11857 cmdline_fixed_string_t flow_director_flexpayload;
11859 cmdline_fixed_string_t payload_layer;
11860 cmdline_fixed_string_t payload_cfg;
11864 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11867 const char *p, *p0 = q_arg;
11869 unsigned long int_fld;
11870 char *str_fld[max_num];
11875 p = strchr(p0, '(');
11879 p0 = strchr(p, ')');
11884 if (size >= sizeof(s))
11887 snprintf(s, sizeof(s), "%.*s", size, p);
11888 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11889 if (ret < 0 || ret > max_num)
11891 for (i = 0; i < ret; i++) {
11893 int_fld = strtoul(str_fld[i], &end, 0);
11894 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11896 offsets[i] = (uint16_t)int_fld;
11902 cmd_flow_director_flxpld_parsed(void *parsed_result,
11903 __attribute__((unused)) struct cmdline *cl,
11904 __attribute__((unused)) void *data)
11906 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11907 struct rte_eth_flex_payload_cfg flex_cfg;
11908 struct rte_port *port;
11911 port = &ports[res->port_id];
11912 /** Check if the port is not started **/
11913 if (port->port_status != RTE_PORT_STOPPED) {
11914 printf("Please stop port %d first\n", res->port_id);
11918 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11920 if (!strcmp(res->payload_layer, "raw"))
11921 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11922 else if (!strcmp(res->payload_layer, "l2"))
11923 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11924 else if (!strcmp(res->payload_layer, "l3"))
11925 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11926 else if (!strcmp(res->payload_layer, "l4"))
11927 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11929 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11930 RTE_ETH_FDIR_MAX_FLEXLEN);
11932 printf("error: Cannot parse flex payload input.\n");
11936 fdir_set_flex_payload(res->port_id, &flex_cfg);
11937 cmd_reconfig_device_queue(res->port_id, 1, 1);
11940 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11941 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11942 flow_director_flexpayload,
11943 "flow_director_flex_payload");
11944 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11945 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11947 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11948 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11949 payload_layer, "raw#l2#l3#l4");
11950 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11951 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11952 payload_cfg, NULL);
11954 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11955 .f = cmd_flow_director_flxpld_parsed,
11957 .help_str = "flow_director_flexpayload ... : "
11958 "Set flow director's flex payload on NIC",
11960 (void *)&cmd_flow_director_flexpayload,
11961 (void *)&cmd_flow_director_flexpayload_port_id,
11962 (void *)&cmd_flow_director_flexpayload_payload_layer,
11963 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11968 /* Generic flow interface command. */
11969 extern cmdline_parse_inst_t cmd_flow;
11971 /* *** Classification Filters Control *** */
11972 /* *** Get symmetric hash enable per port *** */
11973 struct cmd_get_sym_hash_ena_per_port_result {
11974 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11979 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11980 __rte_unused struct cmdline *cl,
11981 __rte_unused void *data)
11983 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11984 struct rte_eth_hash_filter_info info;
11987 if (rte_eth_dev_filter_supported(res->port_id,
11988 RTE_ETH_FILTER_HASH) < 0) {
11989 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11994 memset(&info, 0, sizeof(info));
11995 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11996 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11997 RTE_ETH_FILTER_GET, &info);
12000 printf("Cannot get symmetric hash enable per port "
12001 "on port %u\n", res->port_id);
12005 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12006 "enabled" : "disabled", res->port_id);
12009 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12010 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12011 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12012 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12013 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12016 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12017 .f = cmd_get_sym_hash_per_port_parsed,
12019 .help_str = "get_sym_hash_ena_per_port <port_id>",
12021 (void *)&cmd_get_sym_hash_ena_per_port_all,
12022 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12027 /* *** Set symmetric hash enable per port *** */
12028 struct cmd_set_sym_hash_ena_per_port_result {
12029 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12030 cmdline_fixed_string_t enable;
12035 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12036 __rte_unused struct cmdline *cl,
12037 __rte_unused void *data)
12039 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12040 struct rte_eth_hash_filter_info info;
12043 if (rte_eth_dev_filter_supported(res->port_id,
12044 RTE_ETH_FILTER_HASH) < 0) {
12045 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12050 memset(&info, 0, sizeof(info));
12051 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12052 if (!strcmp(res->enable, "enable"))
12053 info.info.enable = 1;
12054 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12055 RTE_ETH_FILTER_SET, &info);
12057 printf("Cannot set symmetric hash enable per port on "
12058 "port %u\n", res->port_id);
12061 printf("Symmetric hash has been set to %s on port %u\n",
12062 res->enable, res->port_id);
12065 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12066 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12067 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12068 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12069 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12071 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12072 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12073 enable, "enable#disable");
12075 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12076 .f = cmd_set_sym_hash_per_port_parsed,
12078 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12080 (void *)&cmd_set_sym_hash_ena_per_port_all,
12081 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12082 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12087 /* Get global config of hash function */
12088 struct cmd_get_hash_global_config_result {
12089 cmdline_fixed_string_t get_hash_global_config;
12094 flowtype_to_str(uint16_t ftype)
12100 } ftype_table[] = {
12101 {"ipv4", RTE_ETH_FLOW_IPV4},
12102 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12103 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12104 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12105 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12106 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12107 {"ipv6", RTE_ETH_FLOW_IPV6},
12108 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12109 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12110 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12111 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12112 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12113 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12114 {"port", RTE_ETH_FLOW_PORT},
12115 {"vxlan", RTE_ETH_FLOW_VXLAN},
12116 {"geneve", RTE_ETH_FLOW_GENEVE},
12117 {"nvgre", RTE_ETH_FLOW_NVGRE},
12118 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12121 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12122 if (ftype_table[i].ftype == ftype)
12123 return ftype_table[i].str;
12130 cmd_get_hash_global_config_parsed(void *parsed_result,
12131 __rte_unused struct cmdline *cl,
12132 __rte_unused void *data)
12134 struct cmd_get_hash_global_config_result *res = parsed_result;
12135 struct rte_eth_hash_filter_info info;
12136 uint32_t idx, offset;
12141 if (rte_eth_dev_filter_supported(res->port_id,
12142 RTE_ETH_FILTER_HASH) < 0) {
12143 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12148 memset(&info, 0, sizeof(info));
12149 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12150 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12151 RTE_ETH_FILTER_GET, &info);
12153 printf("Cannot get hash global configurations by port %d\n",
12158 switch (info.info.global_conf.hash_func) {
12159 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12160 printf("Hash function is Toeplitz\n");
12162 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12163 printf("Hash function is Simple XOR\n");
12166 printf("Unknown hash function\n");
12170 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12171 idx = i / UINT64_BIT;
12172 offset = i % UINT64_BIT;
12173 if (!(info.info.global_conf.valid_bit_mask[idx] &
12176 str = flowtype_to_str(i);
12179 printf("Symmetric hash is %s globally for flow type %s "
12181 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12182 (1ULL << offset)) ? "enabled" : "disabled"), str,
12187 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12188 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12189 get_hash_global_config, "get_hash_global_config");
12190 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12191 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12194 cmdline_parse_inst_t cmd_get_hash_global_config = {
12195 .f = cmd_get_hash_global_config_parsed,
12197 .help_str = "get_hash_global_config <port_id>",
12199 (void *)&cmd_get_hash_global_config_all,
12200 (void *)&cmd_get_hash_global_config_port_id,
12205 /* Set global config of hash function */
12206 struct cmd_set_hash_global_config_result {
12207 cmdline_fixed_string_t set_hash_global_config;
12209 cmdline_fixed_string_t hash_func;
12210 cmdline_fixed_string_t flow_type;
12211 cmdline_fixed_string_t enable;
12215 cmd_set_hash_global_config_parsed(void *parsed_result,
12216 __rte_unused struct cmdline *cl,
12217 __rte_unused void *data)
12219 struct cmd_set_hash_global_config_result *res = parsed_result;
12220 struct rte_eth_hash_filter_info info;
12221 uint32_t ftype, idx, offset;
12224 if (rte_eth_dev_filter_supported(res->port_id,
12225 RTE_ETH_FILTER_HASH) < 0) {
12226 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12230 memset(&info, 0, sizeof(info));
12231 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12232 if (!strcmp(res->hash_func, "toeplitz"))
12233 info.info.global_conf.hash_func =
12234 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12235 else if (!strcmp(res->hash_func, "simple_xor"))
12236 info.info.global_conf.hash_func =
12237 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12238 else if (!strcmp(res->hash_func, "default"))
12239 info.info.global_conf.hash_func =
12240 RTE_ETH_HASH_FUNCTION_DEFAULT;
12242 ftype = str2flowtype(res->flow_type);
12243 idx = ftype / UINT64_BIT;
12244 offset = ftype % UINT64_BIT;
12245 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12246 if (!strcmp(res->enable, "enable"))
12247 info.info.global_conf.sym_hash_enable_mask[idx] |=
12249 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12250 RTE_ETH_FILTER_SET, &info);
12252 printf("Cannot set global hash configurations by port %d\n",
12255 printf("Global hash configurations have been set "
12256 "successfully by port %d\n", res->port_id);
12259 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12260 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12261 set_hash_global_config, "set_hash_global_config");
12262 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12263 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12265 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12266 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12267 hash_func, "toeplitz#simple_xor#default");
12268 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12269 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12271 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12272 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12273 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12274 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12275 enable, "enable#disable");
12277 cmdline_parse_inst_t cmd_set_hash_global_config = {
12278 .f = cmd_set_hash_global_config_parsed,
12280 .help_str = "set_hash_global_config <port_id> "
12281 "toeplitz|simple_xor|default "
12282 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12283 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12284 "l2_payload enable|disable",
12286 (void *)&cmd_set_hash_global_config_all,
12287 (void *)&cmd_set_hash_global_config_port_id,
12288 (void *)&cmd_set_hash_global_config_hash_func,
12289 (void *)&cmd_set_hash_global_config_flow_type,
12290 (void *)&cmd_set_hash_global_config_enable,
12295 /* Set hash input set */
12296 struct cmd_set_hash_input_set_result {
12297 cmdline_fixed_string_t set_hash_input_set;
12299 cmdline_fixed_string_t flow_type;
12300 cmdline_fixed_string_t inset_field;
12301 cmdline_fixed_string_t select;
12304 static enum rte_eth_input_set_field
12305 str2inset(char *string)
12309 static const struct {
12311 enum rte_eth_input_set_field inset;
12312 } inset_table[] = {
12313 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12314 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12315 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12316 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12317 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12318 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12319 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12320 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12321 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12322 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12323 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12324 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12325 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12326 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12327 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12328 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12329 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12330 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12331 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12332 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12333 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12334 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12335 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12336 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12337 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12338 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12339 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12340 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12341 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12342 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12343 {"none", RTE_ETH_INPUT_SET_NONE},
12346 for (i = 0; i < RTE_DIM(inset_table); i++) {
12347 if (!strcmp(string, inset_table[i].str))
12348 return inset_table[i].inset;
12351 return RTE_ETH_INPUT_SET_UNKNOWN;
12355 cmd_set_hash_input_set_parsed(void *parsed_result,
12356 __rte_unused struct cmdline *cl,
12357 __rte_unused void *data)
12359 struct cmd_set_hash_input_set_result *res = parsed_result;
12360 struct rte_eth_hash_filter_info info;
12362 memset(&info, 0, sizeof(info));
12363 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12364 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12365 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12366 info.info.input_set_conf.inset_size = 1;
12367 if (!strcmp(res->select, "select"))
12368 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12369 else if (!strcmp(res->select, "add"))
12370 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12371 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12372 RTE_ETH_FILTER_SET, &info);
12375 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12376 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12377 set_hash_input_set, "set_hash_input_set");
12378 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12379 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12381 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12382 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12384 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12385 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12387 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12388 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12389 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12390 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12391 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12393 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12394 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12395 select, "select#add");
12397 cmdline_parse_inst_t cmd_set_hash_input_set = {
12398 .f = cmd_set_hash_input_set_parsed,
12400 .help_str = "set_hash_input_set <port_id> "
12401 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12402 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12403 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12404 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12405 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12406 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12407 "fld-7th|fld-8th|none select|add",
12409 (void *)&cmd_set_hash_input_set_cmd,
12410 (void *)&cmd_set_hash_input_set_port_id,
12411 (void *)&cmd_set_hash_input_set_flow_type,
12412 (void *)&cmd_set_hash_input_set_field,
12413 (void *)&cmd_set_hash_input_set_select,
12418 /* Set flow director input set */
12419 struct cmd_set_fdir_input_set_result {
12420 cmdline_fixed_string_t set_fdir_input_set;
12422 cmdline_fixed_string_t flow_type;
12423 cmdline_fixed_string_t inset_field;
12424 cmdline_fixed_string_t select;
12428 cmd_set_fdir_input_set_parsed(void *parsed_result,
12429 __rte_unused struct cmdline *cl,
12430 __rte_unused void *data)
12432 struct cmd_set_fdir_input_set_result *res = parsed_result;
12433 struct rte_eth_fdir_filter_info info;
12435 memset(&info, 0, sizeof(info));
12436 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12437 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12438 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12439 info.info.input_set_conf.inset_size = 1;
12440 if (!strcmp(res->select, "select"))
12441 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12442 else if (!strcmp(res->select, "add"))
12443 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12444 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12445 RTE_ETH_FILTER_SET, &info);
12448 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12449 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12450 set_fdir_input_set, "set_fdir_input_set");
12451 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12452 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12454 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12455 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12457 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12458 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12459 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12460 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12462 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12463 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12464 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12465 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12466 "sctp-veri-tag#none");
12467 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12468 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12469 select, "select#add");
12471 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12472 .f = cmd_set_fdir_input_set_parsed,
12474 .help_str = "set_fdir_input_set <port_id> "
12475 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12476 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12477 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12478 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12479 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12480 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12481 "sctp-veri-tag|none select|add",
12483 (void *)&cmd_set_fdir_input_set_cmd,
12484 (void *)&cmd_set_fdir_input_set_port_id,
12485 (void *)&cmd_set_fdir_input_set_flow_type,
12486 (void *)&cmd_set_fdir_input_set_field,
12487 (void *)&cmd_set_fdir_input_set_select,
12492 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12493 struct cmd_mcast_addr_result {
12494 cmdline_fixed_string_t mcast_addr_cmd;
12495 cmdline_fixed_string_t what;
12497 struct rte_ether_addr mc_addr;
12500 static void cmd_mcast_addr_parsed(void *parsed_result,
12501 __attribute__((unused)) struct cmdline *cl,
12502 __attribute__((unused)) void *data)
12504 struct cmd_mcast_addr_result *res = parsed_result;
12506 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12507 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12508 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12509 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12510 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12513 if (strcmp(res->what, "add") == 0)
12514 mcast_addr_add(res->port_num, &res->mc_addr);
12516 mcast_addr_remove(res->port_num, &res->mc_addr);
12519 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12520 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12521 mcast_addr_cmd, "mcast_addr");
12522 cmdline_parse_token_string_t cmd_mcast_addr_what =
12523 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12525 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12526 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12527 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12528 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12530 cmdline_parse_inst_t cmd_mcast_addr = {
12531 .f = cmd_mcast_addr_parsed,
12533 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12534 "Add/Remove multicast MAC address on port_id",
12536 (void *)&cmd_mcast_addr_cmd,
12537 (void *)&cmd_mcast_addr_what,
12538 (void *)&cmd_mcast_addr_portnum,
12539 (void *)&cmd_mcast_addr_addr,
12544 /* l2 tunnel config
12545 * only support E-tag now.
12548 /* Ether type config */
12549 struct cmd_config_l2_tunnel_eth_type_result {
12550 cmdline_fixed_string_t port;
12551 cmdline_fixed_string_t config;
12552 cmdline_fixed_string_t all;
12554 cmdline_fixed_string_t l2_tunnel;
12555 cmdline_fixed_string_t l2_tunnel_type;
12556 cmdline_fixed_string_t eth_type;
12557 uint16_t eth_type_val;
12560 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12561 TOKEN_STRING_INITIALIZER
12562 (struct cmd_config_l2_tunnel_eth_type_result,
12564 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12565 TOKEN_STRING_INITIALIZER
12566 (struct cmd_config_l2_tunnel_eth_type_result,
12568 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12569 TOKEN_STRING_INITIALIZER
12570 (struct cmd_config_l2_tunnel_eth_type_result,
12572 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12573 TOKEN_NUM_INITIALIZER
12574 (struct cmd_config_l2_tunnel_eth_type_result,
12576 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12577 TOKEN_STRING_INITIALIZER
12578 (struct cmd_config_l2_tunnel_eth_type_result,
12579 l2_tunnel, "l2-tunnel");
12580 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12581 TOKEN_STRING_INITIALIZER
12582 (struct cmd_config_l2_tunnel_eth_type_result,
12583 l2_tunnel_type, "E-tag");
12584 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12585 TOKEN_STRING_INITIALIZER
12586 (struct cmd_config_l2_tunnel_eth_type_result,
12587 eth_type, "ether-type");
12588 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12589 TOKEN_NUM_INITIALIZER
12590 (struct cmd_config_l2_tunnel_eth_type_result,
12591 eth_type_val, UINT16);
12593 static enum rte_eth_tunnel_type
12594 str2fdir_l2_tunnel_type(char *string)
12598 static const struct {
12600 enum rte_eth_tunnel_type type;
12601 } l2_tunnel_type_str[] = {
12602 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12605 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12606 if (!strcmp(l2_tunnel_type_str[i].str, string))
12607 return l2_tunnel_type_str[i].type;
12609 return RTE_TUNNEL_TYPE_NONE;
12612 /* ether type config for all ports */
12614 cmd_config_l2_tunnel_eth_type_all_parsed
12615 (void *parsed_result,
12616 __attribute__((unused)) struct cmdline *cl,
12617 __attribute__((unused)) void *data)
12619 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12620 struct rte_eth_l2_tunnel_conf entry;
12623 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12624 entry.ether_type = res->eth_type_val;
12626 RTE_ETH_FOREACH_DEV(pid) {
12627 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12631 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12632 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12634 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12636 (void *)&cmd_config_l2_tunnel_eth_type_port,
12637 (void *)&cmd_config_l2_tunnel_eth_type_config,
12638 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12639 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12640 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12641 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12642 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12647 /* ether type config for a specific port */
12649 cmd_config_l2_tunnel_eth_type_specific_parsed(
12650 void *parsed_result,
12651 __attribute__((unused)) struct cmdline *cl,
12652 __attribute__((unused)) void *data)
12654 struct cmd_config_l2_tunnel_eth_type_result *res =
12656 struct rte_eth_l2_tunnel_conf entry;
12658 if (port_id_is_invalid(res->id, ENABLED_WARN))
12661 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12662 entry.ether_type = res->eth_type_val;
12664 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12667 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12668 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12670 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12672 (void *)&cmd_config_l2_tunnel_eth_type_port,
12673 (void *)&cmd_config_l2_tunnel_eth_type_config,
12674 (void *)&cmd_config_l2_tunnel_eth_type_id,
12675 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12676 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12677 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12678 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12683 /* Enable/disable l2 tunnel */
12684 struct cmd_config_l2_tunnel_en_dis_result {
12685 cmdline_fixed_string_t port;
12686 cmdline_fixed_string_t config;
12687 cmdline_fixed_string_t all;
12689 cmdline_fixed_string_t l2_tunnel;
12690 cmdline_fixed_string_t l2_tunnel_type;
12691 cmdline_fixed_string_t en_dis;
12694 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12695 TOKEN_STRING_INITIALIZER
12696 (struct cmd_config_l2_tunnel_en_dis_result,
12698 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12699 TOKEN_STRING_INITIALIZER
12700 (struct cmd_config_l2_tunnel_en_dis_result,
12702 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12703 TOKEN_STRING_INITIALIZER
12704 (struct cmd_config_l2_tunnel_en_dis_result,
12706 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12707 TOKEN_NUM_INITIALIZER
12708 (struct cmd_config_l2_tunnel_en_dis_result,
12710 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12711 TOKEN_STRING_INITIALIZER
12712 (struct cmd_config_l2_tunnel_en_dis_result,
12713 l2_tunnel, "l2-tunnel");
12714 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12715 TOKEN_STRING_INITIALIZER
12716 (struct cmd_config_l2_tunnel_en_dis_result,
12717 l2_tunnel_type, "E-tag");
12718 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12719 TOKEN_STRING_INITIALIZER
12720 (struct cmd_config_l2_tunnel_en_dis_result,
12721 en_dis, "enable#disable");
12723 /* enable/disable l2 tunnel for all ports */
12725 cmd_config_l2_tunnel_en_dis_all_parsed(
12726 void *parsed_result,
12727 __attribute__((unused)) struct cmdline *cl,
12728 __attribute__((unused)) void *data)
12730 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12731 struct rte_eth_l2_tunnel_conf entry;
12735 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12737 if (!strcmp("enable", res->en_dis))
12742 RTE_ETH_FOREACH_DEV(pid) {
12743 rte_eth_dev_l2_tunnel_offload_set(pid,
12745 ETH_L2_TUNNEL_ENABLE_MASK,
12750 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12751 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12753 .help_str = "port config all l2-tunnel E-tag enable|disable",
12755 (void *)&cmd_config_l2_tunnel_en_dis_port,
12756 (void *)&cmd_config_l2_tunnel_en_dis_config,
12757 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12758 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12759 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12760 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12765 /* enable/disable l2 tunnel for a port */
12767 cmd_config_l2_tunnel_en_dis_specific_parsed(
12768 void *parsed_result,
12769 __attribute__((unused)) struct cmdline *cl,
12770 __attribute__((unused)) void *data)
12772 struct cmd_config_l2_tunnel_en_dis_result *res =
12774 struct rte_eth_l2_tunnel_conf entry;
12776 if (port_id_is_invalid(res->id, ENABLED_WARN))
12779 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12781 if (!strcmp("enable", res->en_dis))
12782 rte_eth_dev_l2_tunnel_offload_set(res->id,
12784 ETH_L2_TUNNEL_ENABLE_MASK,
12787 rte_eth_dev_l2_tunnel_offload_set(res->id,
12789 ETH_L2_TUNNEL_ENABLE_MASK,
12793 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12794 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12796 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12798 (void *)&cmd_config_l2_tunnel_en_dis_port,
12799 (void *)&cmd_config_l2_tunnel_en_dis_config,
12800 (void *)&cmd_config_l2_tunnel_en_dis_id,
12801 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12802 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12803 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12808 /* E-tag configuration */
12810 /* Common result structure for all E-tag configuration */
12811 struct cmd_config_e_tag_result {
12812 cmdline_fixed_string_t e_tag;
12813 cmdline_fixed_string_t set;
12814 cmdline_fixed_string_t insertion;
12815 cmdline_fixed_string_t stripping;
12816 cmdline_fixed_string_t forwarding;
12817 cmdline_fixed_string_t filter;
12818 cmdline_fixed_string_t add;
12819 cmdline_fixed_string_t del;
12820 cmdline_fixed_string_t on;
12821 cmdline_fixed_string_t off;
12822 cmdline_fixed_string_t on_off;
12823 cmdline_fixed_string_t port_tag_id;
12824 uint32_t port_tag_id_val;
12825 cmdline_fixed_string_t e_tag_id;
12826 uint16_t e_tag_id_val;
12827 cmdline_fixed_string_t dst_pool;
12828 uint8_t dst_pool_val;
12829 cmdline_fixed_string_t port;
12831 cmdline_fixed_string_t vf;
12835 /* Common CLI fields for all E-tag configuration */
12836 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12837 TOKEN_STRING_INITIALIZER
12838 (struct cmd_config_e_tag_result,
12840 cmdline_parse_token_string_t cmd_config_e_tag_set =
12841 TOKEN_STRING_INITIALIZER
12842 (struct cmd_config_e_tag_result,
12844 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12845 TOKEN_STRING_INITIALIZER
12846 (struct cmd_config_e_tag_result,
12847 insertion, "insertion");
12848 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12849 TOKEN_STRING_INITIALIZER
12850 (struct cmd_config_e_tag_result,
12851 stripping, "stripping");
12852 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12853 TOKEN_STRING_INITIALIZER
12854 (struct cmd_config_e_tag_result,
12855 forwarding, "forwarding");
12856 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12857 TOKEN_STRING_INITIALIZER
12858 (struct cmd_config_e_tag_result,
12860 cmdline_parse_token_string_t cmd_config_e_tag_add =
12861 TOKEN_STRING_INITIALIZER
12862 (struct cmd_config_e_tag_result,
12864 cmdline_parse_token_string_t cmd_config_e_tag_del =
12865 TOKEN_STRING_INITIALIZER
12866 (struct cmd_config_e_tag_result,
12868 cmdline_parse_token_string_t cmd_config_e_tag_on =
12869 TOKEN_STRING_INITIALIZER
12870 (struct cmd_config_e_tag_result,
12872 cmdline_parse_token_string_t cmd_config_e_tag_off =
12873 TOKEN_STRING_INITIALIZER
12874 (struct cmd_config_e_tag_result,
12876 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12877 TOKEN_STRING_INITIALIZER
12878 (struct cmd_config_e_tag_result,
12880 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12881 TOKEN_STRING_INITIALIZER
12882 (struct cmd_config_e_tag_result,
12883 port_tag_id, "port-tag-id");
12884 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12885 TOKEN_NUM_INITIALIZER
12886 (struct cmd_config_e_tag_result,
12887 port_tag_id_val, UINT32);
12888 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12889 TOKEN_STRING_INITIALIZER
12890 (struct cmd_config_e_tag_result,
12891 e_tag_id, "e-tag-id");
12892 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12893 TOKEN_NUM_INITIALIZER
12894 (struct cmd_config_e_tag_result,
12895 e_tag_id_val, UINT16);
12896 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12897 TOKEN_STRING_INITIALIZER
12898 (struct cmd_config_e_tag_result,
12899 dst_pool, "dst-pool");
12900 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12901 TOKEN_NUM_INITIALIZER
12902 (struct cmd_config_e_tag_result,
12903 dst_pool_val, UINT8);
12904 cmdline_parse_token_string_t cmd_config_e_tag_port =
12905 TOKEN_STRING_INITIALIZER
12906 (struct cmd_config_e_tag_result,
12908 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12909 TOKEN_NUM_INITIALIZER
12910 (struct cmd_config_e_tag_result,
12912 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12913 TOKEN_STRING_INITIALIZER
12914 (struct cmd_config_e_tag_result,
12916 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12917 TOKEN_NUM_INITIALIZER
12918 (struct cmd_config_e_tag_result,
12921 /* E-tag insertion configuration */
12923 cmd_config_e_tag_insertion_en_parsed(
12924 void *parsed_result,
12925 __attribute__((unused)) struct cmdline *cl,
12926 __attribute__((unused)) void *data)
12928 struct cmd_config_e_tag_result *res =
12930 struct rte_eth_l2_tunnel_conf entry;
12932 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12935 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12936 entry.tunnel_id = res->port_tag_id_val;
12937 entry.vf_id = res->vf_id;
12938 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12940 ETH_L2_TUNNEL_INSERTION_MASK,
12945 cmd_config_e_tag_insertion_dis_parsed(
12946 void *parsed_result,
12947 __attribute__((unused)) struct cmdline *cl,
12948 __attribute__((unused)) void *data)
12950 struct cmd_config_e_tag_result *res =
12952 struct rte_eth_l2_tunnel_conf entry;
12954 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12957 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12958 entry.vf_id = res->vf_id;
12960 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12962 ETH_L2_TUNNEL_INSERTION_MASK,
12966 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12967 .f = cmd_config_e_tag_insertion_en_parsed,
12969 .help_str = "E-tag ... : E-tag insertion enable",
12971 (void *)&cmd_config_e_tag_e_tag,
12972 (void *)&cmd_config_e_tag_set,
12973 (void *)&cmd_config_e_tag_insertion,
12974 (void *)&cmd_config_e_tag_on,
12975 (void *)&cmd_config_e_tag_port_tag_id,
12976 (void *)&cmd_config_e_tag_port_tag_id_val,
12977 (void *)&cmd_config_e_tag_port,
12978 (void *)&cmd_config_e_tag_port_id,
12979 (void *)&cmd_config_e_tag_vf,
12980 (void *)&cmd_config_e_tag_vf_id,
12985 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12986 .f = cmd_config_e_tag_insertion_dis_parsed,
12988 .help_str = "E-tag ... : E-tag insertion disable",
12990 (void *)&cmd_config_e_tag_e_tag,
12991 (void *)&cmd_config_e_tag_set,
12992 (void *)&cmd_config_e_tag_insertion,
12993 (void *)&cmd_config_e_tag_off,
12994 (void *)&cmd_config_e_tag_port,
12995 (void *)&cmd_config_e_tag_port_id,
12996 (void *)&cmd_config_e_tag_vf,
12997 (void *)&cmd_config_e_tag_vf_id,
13002 /* E-tag stripping configuration */
13004 cmd_config_e_tag_stripping_parsed(
13005 void *parsed_result,
13006 __attribute__((unused)) struct cmdline *cl,
13007 __attribute__((unused)) void *data)
13009 struct cmd_config_e_tag_result *res =
13011 struct rte_eth_l2_tunnel_conf entry;
13013 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13016 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13018 if (!strcmp(res->on_off, "on"))
13019 rte_eth_dev_l2_tunnel_offload_set
13022 ETH_L2_TUNNEL_STRIPPING_MASK,
13025 rte_eth_dev_l2_tunnel_offload_set
13028 ETH_L2_TUNNEL_STRIPPING_MASK,
13032 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13033 .f = cmd_config_e_tag_stripping_parsed,
13035 .help_str = "E-tag ... : E-tag stripping enable/disable",
13037 (void *)&cmd_config_e_tag_e_tag,
13038 (void *)&cmd_config_e_tag_set,
13039 (void *)&cmd_config_e_tag_stripping,
13040 (void *)&cmd_config_e_tag_on_off,
13041 (void *)&cmd_config_e_tag_port,
13042 (void *)&cmd_config_e_tag_port_id,
13047 /* E-tag forwarding configuration */
13049 cmd_config_e_tag_forwarding_parsed(
13050 void *parsed_result,
13051 __attribute__((unused)) struct cmdline *cl,
13052 __attribute__((unused)) void *data)
13054 struct cmd_config_e_tag_result *res = parsed_result;
13055 struct rte_eth_l2_tunnel_conf entry;
13057 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13060 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13062 if (!strcmp(res->on_off, "on"))
13063 rte_eth_dev_l2_tunnel_offload_set
13066 ETH_L2_TUNNEL_FORWARDING_MASK,
13069 rte_eth_dev_l2_tunnel_offload_set
13072 ETH_L2_TUNNEL_FORWARDING_MASK,
13076 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13077 .f = cmd_config_e_tag_forwarding_parsed,
13079 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13081 (void *)&cmd_config_e_tag_e_tag,
13082 (void *)&cmd_config_e_tag_set,
13083 (void *)&cmd_config_e_tag_forwarding,
13084 (void *)&cmd_config_e_tag_on_off,
13085 (void *)&cmd_config_e_tag_port,
13086 (void *)&cmd_config_e_tag_port_id,
13091 /* E-tag filter configuration */
13093 cmd_config_e_tag_filter_add_parsed(
13094 void *parsed_result,
13095 __attribute__((unused)) struct cmdline *cl,
13096 __attribute__((unused)) void *data)
13098 struct cmd_config_e_tag_result *res = parsed_result;
13099 struct rte_eth_l2_tunnel_conf entry;
13102 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13105 if (res->e_tag_id_val > 0x3fff) {
13106 printf("e-tag-id must be equal or less than 0x3fff.\n");
13110 ret = rte_eth_dev_filter_supported(res->port_id,
13111 RTE_ETH_FILTER_L2_TUNNEL);
13113 printf("E-tag filter is not supported on port %u.\n",
13118 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13119 entry.tunnel_id = res->e_tag_id_val;
13120 entry.pool = res->dst_pool_val;
13122 ret = rte_eth_dev_filter_ctrl(res->port_id,
13123 RTE_ETH_FILTER_L2_TUNNEL,
13124 RTE_ETH_FILTER_ADD,
13127 printf("E-tag filter programming error: (%s)\n",
13131 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13132 .f = cmd_config_e_tag_filter_add_parsed,
13134 .help_str = "E-tag ... : E-tag filter add",
13136 (void *)&cmd_config_e_tag_e_tag,
13137 (void *)&cmd_config_e_tag_set,
13138 (void *)&cmd_config_e_tag_filter,
13139 (void *)&cmd_config_e_tag_add,
13140 (void *)&cmd_config_e_tag_e_tag_id,
13141 (void *)&cmd_config_e_tag_e_tag_id_val,
13142 (void *)&cmd_config_e_tag_dst_pool,
13143 (void *)&cmd_config_e_tag_dst_pool_val,
13144 (void *)&cmd_config_e_tag_port,
13145 (void *)&cmd_config_e_tag_port_id,
13151 cmd_config_e_tag_filter_del_parsed(
13152 void *parsed_result,
13153 __attribute__((unused)) struct cmdline *cl,
13154 __attribute__((unused)) void *data)
13156 struct cmd_config_e_tag_result *res = parsed_result;
13157 struct rte_eth_l2_tunnel_conf entry;
13160 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13163 if (res->e_tag_id_val > 0x3fff) {
13164 printf("e-tag-id must be less than 0x3fff.\n");
13168 ret = rte_eth_dev_filter_supported(res->port_id,
13169 RTE_ETH_FILTER_L2_TUNNEL);
13171 printf("E-tag filter is not supported on port %u.\n",
13176 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13177 entry.tunnel_id = res->e_tag_id_val;
13179 ret = rte_eth_dev_filter_ctrl(res->port_id,
13180 RTE_ETH_FILTER_L2_TUNNEL,
13181 RTE_ETH_FILTER_DELETE,
13184 printf("E-tag filter programming error: (%s)\n",
13188 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13189 .f = cmd_config_e_tag_filter_del_parsed,
13191 .help_str = "E-tag ... : E-tag filter delete",
13193 (void *)&cmd_config_e_tag_e_tag,
13194 (void *)&cmd_config_e_tag_set,
13195 (void *)&cmd_config_e_tag_filter,
13196 (void *)&cmd_config_e_tag_del,
13197 (void *)&cmd_config_e_tag_e_tag_id,
13198 (void *)&cmd_config_e_tag_e_tag_id_val,
13199 (void *)&cmd_config_e_tag_port,
13200 (void *)&cmd_config_e_tag_port_id,
13205 /* vf vlan anti spoof configuration */
13207 /* Common result structure for vf vlan anti spoof */
13208 struct cmd_vf_vlan_anti_spoof_result {
13209 cmdline_fixed_string_t set;
13210 cmdline_fixed_string_t vf;
13211 cmdline_fixed_string_t vlan;
13212 cmdline_fixed_string_t antispoof;
13215 cmdline_fixed_string_t on_off;
13218 /* Common CLI fields for vf vlan anti spoof enable disable */
13219 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13220 TOKEN_STRING_INITIALIZER
13221 (struct cmd_vf_vlan_anti_spoof_result,
13223 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13224 TOKEN_STRING_INITIALIZER
13225 (struct cmd_vf_vlan_anti_spoof_result,
13227 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13228 TOKEN_STRING_INITIALIZER
13229 (struct cmd_vf_vlan_anti_spoof_result,
13231 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13232 TOKEN_STRING_INITIALIZER
13233 (struct cmd_vf_vlan_anti_spoof_result,
13234 antispoof, "antispoof");
13235 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13236 TOKEN_NUM_INITIALIZER
13237 (struct cmd_vf_vlan_anti_spoof_result,
13239 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13240 TOKEN_NUM_INITIALIZER
13241 (struct cmd_vf_vlan_anti_spoof_result,
13243 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13244 TOKEN_STRING_INITIALIZER
13245 (struct cmd_vf_vlan_anti_spoof_result,
13249 cmd_set_vf_vlan_anti_spoof_parsed(
13250 void *parsed_result,
13251 __attribute__((unused)) struct cmdline *cl,
13252 __attribute__((unused)) void *data)
13254 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13255 int ret = -ENOTSUP;
13257 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13259 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13262 #ifdef RTE_LIBRTE_IXGBE_PMD
13263 if (ret == -ENOTSUP)
13264 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13265 res->vf_id, is_on);
13267 #ifdef RTE_LIBRTE_I40E_PMD
13268 if (ret == -ENOTSUP)
13269 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13270 res->vf_id, is_on);
13272 #ifdef RTE_LIBRTE_BNXT_PMD
13273 if (ret == -ENOTSUP)
13274 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13275 res->vf_id, is_on);
13282 printf("invalid vf_id %d\n", res->vf_id);
13285 printf("invalid port_id %d\n", res->port_id);
13288 printf("function not implemented\n");
13291 printf("programming error: (%s)\n", strerror(-ret));
13295 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13296 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13298 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13300 (void *)&cmd_vf_vlan_anti_spoof_set,
13301 (void *)&cmd_vf_vlan_anti_spoof_vf,
13302 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13303 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13304 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13305 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13306 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13311 /* vf mac anti spoof configuration */
13313 /* Common result structure for vf mac anti spoof */
13314 struct cmd_vf_mac_anti_spoof_result {
13315 cmdline_fixed_string_t set;
13316 cmdline_fixed_string_t vf;
13317 cmdline_fixed_string_t mac;
13318 cmdline_fixed_string_t antispoof;
13321 cmdline_fixed_string_t on_off;
13324 /* Common CLI fields for vf mac anti spoof enable disable */
13325 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13326 TOKEN_STRING_INITIALIZER
13327 (struct cmd_vf_mac_anti_spoof_result,
13329 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13330 TOKEN_STRING_INITIALIZER
13331 (struct cmd_vf_mac_anti_spoof_result,
13333 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13334 TOKEN_STRING_INITIALIZER
13335 (struct cmd_vf_mac_anti_spoof_result,
13337 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13338 TOKEN_STRING_INITIALIZER
13339 (struct cmd_vf_mac_anti_spoof_result,
13340 antispoof, "antispoof");
13341 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13342 TOKEN_NUM_INITIALIZER
13343 (struct cmd_vf_mac_anti_spoof_result,
13345 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13346 TOKEN_NUM_INITIALIZER
13347 (struct cmd_vf_mac_anti_spoof_result,
13349 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13350 TOKEN_STRING_INITIALIZER
13351 (struct cmd_vf_mac_anti_spoof_result,
13355 cmd_set_vf_mac_anti_spoof_parsed(
13356 void *parsed_result,
13357 __attribute__((unused)) struct cmdline *cl,
13358 __attribute__((unused)) void *data)
13360 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13361 int ret = -ENOTSUP;
13363 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13365 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13368 #ifdef RTE_LIBRTE_IXGBE_PMD
13369 if (ret == -ENOTSUP)
13370 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13371 res->vf_id, is_on);
13373 #ifdef RTE_LIBRTE_I40E_PMD
13374 if (ret == -ENOTSUP)
13375 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13376 res->vf_id, is_on);
13378 #ifdef RTE_LIBRTE_BNXT_PMD
13379 if (ret == -ENOTSUP)
13380 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13381 res->vf_id, is_on);
13388 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13391 printf("invalid port_id %d\n", res->port_id);
13394 printf("function not implemented\n");
13397 printf("programming error: (%s)\n", strerror(-ret));
13401 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13402 .f = cmd_set_vf_mac_anti_spoof_parsed,
13404 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13406 (void *)&cmd_vf_mac_anti_spoof_set,
13407 (void *)&cmd_vf_mac_anti_spoof_vf,
13408 (void *)&cmd_vf_mac_anti_spoof_mac,
13409 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13410 (void *)&cmd_vf_mac_anti_spoof_port_id,
13411 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13412 (void *)&cmd_vf_mac_anti_spoof_on_off,
13417 /* vf vlan strip queue configuration */
13419 /* Common result structure for vf mac anti spoof */
13420 struct cmd_vf_vlan_stripq_result {
13421 cmdline_fixed_string_t set;
13422 cmdline_fixed_string_t vf;
13423 cmdline_fixed_string_t vlan;
13424 cmdline_fixed_string_t stripq;
13427 cmdline_fixed_string_t on_off;
13430 /* Common CLI fields for vf vlan strip enable disable */
13431 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13432 TOKEN_STRING_INITIALIZER
13433 (struct cmd_vf_vlan_stripq_result,
13435 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13436 TOKEN_STRING_INITIALIZER
13437 (struct cmd_vf_vlan_stripq_result,
13439 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13440 TOKEN_STRING_INITIALIZER
13441 (struct cmd_vf_vlan_stripq_result,
13443 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13444 TOKEN_STRING_INITIALIZER
13445 (struct cmd_vf_vlan_stripq_result,
13447 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13448 TOKEN_NUM_INITIALIZER
13449 (struct cmd_vf_vlan_stripq_result,
13451 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13452 TOKEN_NUM_INITIALIZER
13453 (struct cmd_vf_vlan_stripq_result,
13455 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13456 TOKEN_STRING_INITIALIZER
13457 (struct cmd_vf_vlan_stripq_result,
13461 cmd_set_vf_vlan_stripq_parsed(
13462 void *parsed_result,
13463 __attribute__((unused)) struct cmdline *cl,
13464 __attribute__((unused)) void *data)
13466 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13467 int ret = -ENOTSUP;
13469 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13471 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13474 #ifdef RTE_LIBRTE_IXGBE_PMD
13475 if (ret == -ENOTSUP)
13476 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13477 res->vf_id, is_on);
13479 #ifdef RTE_LIBRTE_I40E_PMD
13480 if (ret == -ENOTSUP)
13481 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13482 res->vf_id, is_on);
13484 #ifdef RTE_LIBRTE_BNXT_PMD
13485 if (ret == -ENOTSUP)
13486 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13487 res->vf_id, is_on);
13494 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13497 printf("invalid port_id %d\n", res->port_id);
13500 printf("function not implemented\n");
13503 printf("programming error: (%s)\n", strerror(-ret));
13507 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13508 .f = cmd_set_vf_vlan_stripq_parsed,
13510 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13512 (void *)&cmd_vf_vlan_stripq_set,
13513 (void *)&cmd_vf_vlan_stripq_vf,
13514 (void *)&cmd_vf_vlan_stripq_vlan,
13515 (void *)&cmd_vf_vlan_stripq_stripq,
13516 (void *)&cmd_vf_vlan_stripq_port_id,
13517 (void *)&cmd_vf_vlan_stripq_vf_id,
13518 (void *)&cmd_vf_vlan_stripq_on_off,
13523 /* vf vlan insert configuration */
13525 /* Common result structure for vf vlan insert */
13526 struct cmd_vf_vlan_insert_result {
13527 cmdline_fixed_string_t set;
13528 cmdline_fixed_string_t vf;
13529 cmdline_fixed_string_t vlan;
13530 cmdline_fixed_string_t insert;
13536 /* Common CLI fields for vf vlan insert enable disable */
13537 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13538 TOKEN_STRING_INITIALIZER
13539 (struct cmd_vf_vlan_insert_result,
13541 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13542 TOKEN_STRING_INITIALIZER
13543 (struct cmd_vf_vlan_insert_result,
13545 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13546 TOKEN_STRING_INITIALIZER
13547 (struct cmd_vf_vlan_insert_result,
13549 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13550 TOKEN_STRING_INITIALIZER
13551 (struct cmd_vf_vlan_insert_result,
13553 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13554 TOKEN_NUM_INITIALIZER
13555 (struct cmd_vf_vlan_insert_result,
13557 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13558 TOKEN_NUM_INITIALIZER
13559 (struct cmd_vf_vlan_insert_result,
13561 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13562 TOKEN_NUM_INITIALIZER
13563 (struct cmd_vf_vlan_insert_result,
13567 cmd_set_vf_vlan_insert_parsed(
13568 void *parsed_result,
13569 __attribute__((unused)) struct cmdline *cl,
13570 __attribute__((unused)) void *data)
13572 struct cmd_vf_vlan_insert_result *res = parsed_result;
13573 int ret = -ENOTSUP;
13575 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13578 #ifdef RTE_LIBRTE_IXGBE_PMD
13579 if (ret == -ENOTSUP)
13580 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13583 #ifdef RTE_LIBRTE_I40E_PMD
13584 if (ret == -ENOTSUP)
13585 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13588 #ifdef RTE_LIBRTE_BNXT_PMD
13589 if (ret == -ENOTSUP)
13590 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13598 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13601 printf("invalid port_id %d\n", res->port_id);
13604 printf("function not implemented\n");
13607 printf("programming error: (%s)\n", strerror(-ret));
13611 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13612 .f = cmd_set_vf_vlan_insert_parsed,
13614 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13616 (void *)&cmd_vf_vlan_insert_set,
13617 (void *)&cmd_vf_vlan_insert_vf,
13618 (void *)&cmd_vf_vlan_insert_vlan,
13619 (void *)&cmd_vf_vlan_insert_insert,
13620 (void *)&cmd_vf_vlan_insert_port_id,
13621 (void *)&cmd_vf_vlan_insert_vf_id,
13622 (void *)&cmd_vf_vlan_insert_vlan_id,
13627 /* tx loopback configuration */
13629 /* Common result structure for tx loopback */
13630 struct cmd_tx_loopback_result {
13631 cmdline_fixed_string_t set;
13632 cmdline_fixed_string_t tx;
13633 cmdline_fixed_string_t loopback;
13635 cmdline_fixed_string_t on_off;
13638 /* Common CLI fields for tx loopback enable disable */
13639 cmdline_parse_token_string_t cmd_tx_loopback_set =
13640 TOKEN_STRING_INITIALIZER
13641 (struct cmd_tx_loopback_result,
13643 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13644 TOKEN_STRING_INITIALIZER
13645 (struct cmd_tx_loopback_result,
13647 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13648 TOKEN_STRING_INITIALIZER
13649 (struct cmd_tx_loopback_result,
13650 loopback, "loopback");
13651 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13652 TOKEN_NUM_INITIALIZER
13653 (struct cmd_tx_loopback_result,
13655 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13656 TOKEN_STRING_INITIALIZER
13657 (struct cmd_tx_loopback_result,
13661 cmd_set_tx_loopback_parsed(
13662 void *parsed_result,
13663 __attribute__((unused)) struct cmdline *cl,
13664 __attribute__((unused)) void *data)
13666 struct cmd_tx_loopback_result *res = parsed_result;
13667 int ret = -ENOTSUP;
13669 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13671 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13674 #ifdef RTE_LIBRTE_IXGBE_PMD
13675 if (ret == -ENOTSUP)
13676 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13678 #ifdef RTE_LIBRTE_I40E_PMD
13679 if (ret == -ENOTSUP)
13680 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13682 #ifdef RTE_LIBRTE_BNXT_PMD
13683 if (ret == -ENOTSUP)
13684 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13686 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13687 if (ret == -ENOTSUP)
13688 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13695 printf("invalid is_on %d\n", is_on);
13698 printf("invalid port_id %d\n", res->port_id);
13701 printf("function not implemented\n");
13704 printf("programming error: (%s)\n", strerror(-ret));
13708 cmdline_parse_inst_t cmd_set_tx_loopback = {
13709 .f = cmd_set_tx_loopback_parsed,
13711 .help_str = "set tx loopback <port_id> on|off",
13713 (void *)&cmd_tx_loopback_set,
13714 (void *)&cmd_tx_loopback_tx,
13715 (void *)&cmd_tx_loopback_loopback,
13716 (void *)&cmd_tx_loopback_port_id,
13717 (void *)&cmd_tx_loopback_on_off,
13722 /* all queues drop enable configuration */
13724 /* Common result structure for all queues drop enable */
13725 struct cmd_all_queues_drop_en_result {
13726 cmdline_fixed_string_t set;
13727 cmdline_fixed_string_t all;
13728 cmdline_fixed_string_t queues;
13729 cmdline_fixed_string_t drop;
13731 cmdline_fixed_string_t on_off;
13734 /* Common CLI fields for tx loopback enable disable */
13735 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13736 TOKEN_STRING_INITIALIZER
13737 (struct cmd_all_queues_drop_en_result,
13739 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13740 TOKEN_STRING_INITIALIZER
13741 (struct cmd_all_queues_drop_en_result,
13743 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13744 TOKEN_STRING_INITIALIZER
13745 (struct cmd_all_queues_drop_en_result,
13747 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13748 TOKEN_STRING_INITIALIZER
13749 (struct cmd_all_queues_drop_en_result,
13751 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13752 TOKEN_NUM_INITIALIZER
13753 (struct cmd_all_queues_drop_en_result,
13755 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13756 TOKEN_STRING_INITIALIZER
13757 (struct cmd_all_queues_drop_en_result,
13761 cmd_set_all_queues_drop_en_parsed(
13762 void *parsed_result,
13763 __attribute__((unused)) struct cmdline *cl,
13764 __attribute__((unused)) void *data)
13766 struct cmd_all_queues_drop_en_result *res = parsed_result;
13767 int ret = -ENOTSUP;
13768 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13770 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13773 #ifdef RTE_LIBRTE_IXGBE_PMD
13774 if (ret == -ENOTSUP)
13775 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13777 #ifdef RTE_LIBRTE_BNXT_PMD
13778 if (ret == -ENOTSUP)
13779 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13785 printf("invalid is_on %d\n", is_on);
13788 printf("invalid port_id %d\n", res->port_id);
13791 printf("function not implemented\n");
13794 printf("programming error: (%s)\n", strerror(-ret));
13798 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13799 .f = cmd_set_all_queues_drop_en_parsed,
13801 .help_str = "set all queues drop <port_id> on|off",
13803 (void *)&cmd_all_queues_drop_en_set,
13804 (void *)&cmd_all_queues_drop_en_all,
13805 (void *)&cmd_all_queues_drop_en_queues,
13806 (void *)&cmd_all_queues_drop_en_drop,
13807 (void *)&cmd_all_queues_drop_en_port_id,
13808 (void *)&cmd_all_queues_drop_en_on_off,
13813 /* vf split drop enable configuration */
13815 /* Common result structure for vf split drop enable */
13816 struct cmd_vf_split_drop_en_result {
13817 cmdline_fixed_string_t set;
13818 cmdline_fixed_string_t vf;
13819 cmdline_fixed_string_t split;
13820 cmdline_fixed_string_t drop;
13823 cmdline_fixed_string_t on_off;
13826 /* Common CLI fields for vf split drop enable disable */
13827 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13828 TOKEN_STRING_INITIALIZER
13829 (struct cmd_vf_split_drop_en_result,
13831 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13832 TOKEN_STRING_INITIALIZER
13833 (struct cmd_vf_split_drop_en_result,
13835 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13836 TOKEN_STRING_INITIALIZER
13837 (struct cmd_vf_split_drop_en_result,
13839 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13840 TOKEN_STRING_INITIALIZER
13841 (struct cmd_vf_split_drop_en_result,
13843 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13844 TOKEN_NUM_INITIALIZER
13845 (struct cmd_vf_split_drop_en_result,
13847 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13848 TOKEN_NUM_INITIALIZER
13849 (struct cmd_vf_split_drop_en_result,
13851 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13852 TOKEN_STRING_INITIALIZER
13853 (struct cmd_vf_split_drop_en_result,
13857 cmd_set_vf_split_drop_en_parsed(
13858 void *parsed_result,
13859 __attribute__((unused)) struct cmdline *cl,
13860 __attribute__((unused)) void *data)
13862 struct cmd_vf_split_drop_en_result *res = parsed_result;
13863 int ret = -ENOTSUP;
13864 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13866 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13869 #ifdef RTE_LIBRTE_IXGBE_PMD
13870 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13877 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13880 printf("invalid port_id %d\n", res->port_id);
13883 printf("not supported on port %d\n", res->port_id);
13886 printf("programming error: (%s)\n", strerror(-ret));
13890 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13891 .f = cmd_set_vf_split_drop_en_parsed,
13893 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13895 (void *)&cmd_vf_split_drop_en_set,
13896 (void *)&cmd_vf_split_drop_en_vf,
13897 (void *)&cmd_vf_split_drop_en_split,
13898 (void *)&cmd_vf_split_drop_en_drop,
13899 (void *)&cmd_vf_split_drop_en_port_id,
13900 (void *)&cmd_vf_split_drop_en_vf_id,
13901 (void *)&cmd_vf_split_drop_en_on_off,
13906 /* vf mac address configuration */
13908 /* Common result structure for vf mac address */
13909 struct cmd_set_vf_mac_addr_result {
13910 cmdline_fixed_string_t set;
13911 cmdline_fixed_string_t vf;
13912 cmdline_fixed_string_t mac;
13913 cmdline_fixed_string_t addr;
13916 struct rte_ether_addr mac_addr;
13920 /* Common CLI fields for vf split drop enable disable */
13921 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13922 TOKEN_STRING_INITIALIZER
13923 (struct cmd_set_vf_mac_addr_result,
13925 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13926 TOKEN_STRING_INITIALIZER
13927 (struct cmd_set_vf_mac_addr_result,
13929 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13930 TOKEN_STRING_INITIALIZER
13931 (struct cmd_set_vf_mac_addr_result,
13933 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13934 TOKEN_STRING_INITIALIZER
13935 (struct cmd_set_vf_mac_addr_result,
13937 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13938 TOKEN_NUM_INITIALIZER
13939 (struct cmd_set_vf_mac_addr_result,
13941 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13942 TOKEN_NUM_INITIALIZER
13943 (struct cmd_set_vf_mac_addr_result,
13945 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13946 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13950 cmd_set_vf_mac_addr_parsed(
13951 void *parsed_result,
13952 __attribute__((unused)) struct cmdline *cl,
13953 __attribute__((unused)) void *data)
13955 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13956 int ret = -ENOTSUP;
13958 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13961 #ifdef RTE_LIBRTE_IXGBE_PMD
13962 if (ret == -ENOTSUP)
13963 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13966 #ifdef RTE_LIBRTE_I40E_PMD
13967 if (ret == -ENOTSUP)
13968 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13971 #ifdef RTE_LIBRTE_BNXT_PMD
13972 if (ret == -ENOTSUP)
13973 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13981 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13984 printf("invalid port_id %d\n", res->port_id);
13987 printf("function not implemented\n");
13990 printf("programming error: (%s)\n", strerror(-ret));
13994 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13995 .f = cmd_set_vf_mac_addr_parsed,
13997 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13999 (void *)&cmd_set_vf_mac_addr_set,
14000 (void *)&cmd_set_vf_mac_addr_vf,
14001 (void *)&cmd_set_vf_mac_addr_mac,
14002 (void *)&cmd_set_vf_mac_addr_addr,
14003 (void *)&cmd_set_vf_mac_addr_port_id,
14004 (void *)&cmd_set_vf_mac_addr_vf_id,
14005 (void *)&cmd_set_vf_mac_addr_mac_addr,
14010 /* MACsec configuration */
14012 /* Common result structure for MACsec offload enable */
14013 struct cmd_macsec_offload_on_result {
14014 cmdline_fixed_string_t set;
14015 cmdline_fixed_string_t macsec;
14016 cmdline_fixed_string_t offload;
14018 cmdline_fixed_string_t on;
14019 cmdline_fixed_string_t encrypt;
14020 cmdline_fixed_string_t en_on_off;
14021 cmdline_fixed_string_t replay_protect;
14022 cmdline_fixed_string_t rp_on_off;
14025 /* Common CLI fields for MACsec offload disable */
14026 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14027 TOKEN_STRING_INITIALIZER
14028 (struct cmd_macsec_offload_on_result,
14030 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14031 TOKEN_STRING_INITIALIZER
14032 (struct cmd_macsec_offload_on_result,
14034 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14035 TOKEN_STRING_INITIALIZER
14036 (struct cmd_macsec_offload_on_result,
14037 offload, "offload");
14038 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14039 TOKEN_NUM_INITIALIZER
14040 (struct cmd_macsec_offload_on_result,
14042 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14043 TOKEN_STRING_INITIALIZER
14044 (struct cmd_macsec_offload_on_result,
14046 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14047 TOKEN_STRING_INITIALIZER
14048 (struct cmd_macsec_offload_on_result,
14049 encrypt, "encrypt");
14050 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14051 TOKEN_STRING_INITIALIZER
14052 (struct cmd_macsec_offload_on_result,
14053 en_on_off, "on#off");
14054 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14055 TOKEN_STRING_INITIALIZER
14056 (struct cmd_macsec_offload_on_result,
14057 replay_protect, "replay-protect");
14058 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14059 TOKEN_STRING_INITIALIZER
14060 (struct cmd_macsec_offload_on_result,
14061 rp_on_off, "on#off");
14064 cmd_set_macsec_offload_on_parsed(
14065 void *parsed_result,
14066 __attribute__((unused)) struct cmdline *cl,
14067 __attribute__((unused)) void *data)
14069 struct cmd_macsec_offload_on_result *res = parsed_result;
14070 int ret = -ENOTSUP;
14071 portid_t port_id = res->port_id;
14072 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14073 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14074 struct rte_eth_dev_info dev_info;
14076 if (port_id_is_invalid(port_id, ENABLED_WARN))
14078 if (!port_is_stopped(port_id)) {
14079 printf("Please stop port %d first\n", port_id);
14083 rte_eth_dev_info_get(port_id, &dev_info);
14084 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14085 #ifdef RTE_LIBRTE_IXGBE_PMD
14086 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14094 ports[port_id].dev_conf.txmode.offloads |=
14095 DEV_TX_OFFLOAD_MACSEC_INSERT;
14096 cmd_reconfig_device_queue(port_id, 1, 1);
14099 printf("invalid port_id %d\n", port_id);
14102 printf("not supported on port %d\n", port_id);
14105 printf("programming error: (%s)\n", strerror(-ret));
14109 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14110 .f = cmd_set_macsec_offload_on_parsed,
14112 .help_str = "set macsec offload <port_id> on "
14113 "encrypt on|off replay-protect on|off",
14115 (void *)&cmd_macsec_offload_on_set,
14116 (void *)&cmd_macsec_offload_on_macsec,
14117 (void *)&cmd_macsec_offload_on_offload,
14118 (void *)&cmd_macsec_offload_on_port_id,
14119 (void *)&cmd_macsec_offload_on_on,
14120 (void *)&cmd_macsec_offload_on_encrypt,
14121 (void *)&cmd_macsec_offload_on_en_on_off,
14122 (void *)&cmd_macsec_offload_on_replay_protect,
14123 (void *)&cmd_macsec_offload_on_rp_on_off,
14128 /* Common result structure for MACsec offload disable */
14129 struct cmd_macsec_offload_off_result {
14130 cmdline_fixed_string_t set;
14131 cmdline_fixed_string_t macsec;
14132 cmdline_fixed_string_t offload;
14134 cmdline_fixed_string_t off;
14137 /* Common CLI fields for MACsec offload disable */
14138 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14139 TOKEN_STRING_INITIALIZER
14140 (struct cmd_macsec_offload_off_result,
14142 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14143 TOKEN_STRING_INITIALIZER
14144 (struct cmd_macsec_offload_off_result,
14146 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14147 TOKEN_STRING_INITIALIZER
14148 (struct cmd_macsec_offload_off_result,
14149 offload, "offload");
14150 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14151 TOKEN_NUM_INITIALIZER
14152 (struct cmd_macsec_offload_off_result,
14154 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14155 TOKEN_STRING_INITIALIZER
14156 (struct cmd_macsec_offload_off_result,
14160 cmd_set_macsec_offload_off_parsed(
14161 void *parsed_result,
14162 __attribute__((unused)) struct cmdline *cl,
14163 __attribute__((unused)) void *data)
14165 struct cmd_macsec_offload_off_result *res = parsed_result;
14166 int ret = -ENOTSUP;
14167 struct rte_eth_dev_info dev_info;
14168 portid_t port_id = res->port_id;
14170 if (port_id_is_invalid(port_id, ENABLED_WARN))
14172 if (!port_is_stopped(port_id)) {
14173 printf("Please stop port %d first\n", port_id);
14177 rte_eth_dev_info_get(port_id, &dev_info);
14178 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14179 #ifdef RTE_LIBRTE_IXGBE_PMD
14180 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14185 ports[port_id].dev_conf.txmode.offloads &=
14186 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14187 cmd_reconfig_device_queue(port_id, 1, 1);
14190 printf("invalid port_id %d\n", port_id);
14193 printf("not supported on port %d\n", port_id);
14196 printf("programming error: (%s)\n", strerror(-ret));
14200 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14201 .f = cmd_set_macsec_offload_off_parsed,
14203 .help_str = "set macsec offload <port_id> off",
14205 (void *)&cmd_macsec_offload_off_set,
14206 (void *)&cmd_macsec_offload_off_macsec,
14207 (void *)&cmd_macsec_offload_off_offload,
14208 (void *)&cmd_macsec_offload_off_port_id,
14209 (void *)&cmd_macsec_offload_off_off,
14214 /* Common result structure for MACsec secure connection configure */
14215 struct cmd_macsec_sc_result {
14216 cmdline_fixed_string_t set;
14217 cmdline_fixed_string_t macsec;
14218 cmdline_fixed_string_t sc;
14219 cmdline_fixed_string_t tx_rx;
14221 struct rte_ether_addr mac;
14225 /* Common CLI fields for MACsec secure connection configure */
14226 cmdline_parse_token_string_t cmd_macsec_sc_set =
14227 TOKEN_STRING_INITIALIZER
14228 (struct cmd_macsec_sc_result,
14230 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14231 TOKEN_STRING_INITIALIZER
14232 (struct cmd_macsec_sc_result,
14234 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14235 TOKEN_STRING_INITIALIZER
14236 (struct cmd_macsec_sc_result,
14238 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14239 TOKEN_STRING_INITIALIZER
14240 (struct cmd_macsec_sc_result,
14242 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14243 TOKEN_NUM_INITIALIZER
14244 (struct cmd_macsec_sc_result,
14246 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14247 TOKEN_ETHERADDR_INITIALIZER
14248 (struct cmd_macsec_sc_result,
14250 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14251 TOKEN_NUM_INITIALIZER
14252 (struct cmd_macsec_sc_result,
14256 cmd_set_macsec_sc_parsed(
14257 void *parsed_result,
14258 __attribute__((unused)) struct cmdline *cl,
14259 __attribute__((unused)) void *data)
14261 struct cmd_macsec_sc_result *res = parsed_result;
14262 int ret = -ENOTSUP;
14263 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14265 #ifdef RTE_LIBRTE_IXGBE_PMD
14267 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14268 res->mac.addr_bytes) :
14269 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14270 res->mac.addr_bytes, res->pi);
14272 RTE_SET_USED(is_tx);
14278 printf("invalid port_id %d\n", res->port_id);
14281 printf("not supported on port %d\n", res->port_id);
14284 printf("programming error: (%s)\n", strerror(-ret));
14288 cmdline_parse_inst_t cmd_set_macsec_sc = {
14289 .f = cmd_set_macsec_sc_parsed,
14291 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14293 (void *)&cmd_macsec_sc_set,
14294 (void *)&cmd_macsec_sc_macsec,
14295 (void *)&cmd_macsec_sc_sc,
14296 (void *)&cmd_macsec_sc_tx_rx,
14297 (void *)&cmd_macsec_sc_port_id,
14298 (void *)&cmd_macsec_sc_mac,
14299 (void *)&cmd_macsec_sc_pi,
14304 /* Common result structure for MACsec secure connection configure */
14305 struct cmd_macsec_sa_result {
14306 cmdline_fixed_string_t set;
14307 cmdline_fixed_string_t macsec;
14308 cmdline_fixed_string_t sa;
14309 cmdline_fixed_string_t tx_rx;
14314 cmdline_fixed_string_t key;
14317 /* Common CLI fields for MACsec secure connection configure */
14318 cmdline_parse_token_string_t cmd_macsec_sa_set =
14319 TOKEN_STRING_INITIALIZER
14320 (struct cmd_macsec_sa_result,
14322 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14323 TOKEN_STRING_INITIALIZER
14324 (struct cmd_macsec_sa_result,
14326 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14327 TOKEN_STRING_INITIALIZER
14328 (struct cmd_macsec_sa_result,
14330 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14331 TOKEN_STRING_INITIALIZER
14332 (struct cmd_macsec_sa_result,
14334 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14335 TOKEN_NUM_INITIALIZER
14336 (struct cmd_macsec_sa_result,
14338 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14339 TOKEN_NUM_INITIALIZER
14340 (struct cmd_macsec_sa_result,
14342 cmdline_parse_token_num_t cmd_macsec_sa_an =
14343 TOKEN_NUM_INITIALIZER
14344 (struct cmd_macsec_sa_result,
14346 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14347 TOKEN_NUM_INITIALIZER
14348 (struct cmd_macsec_sa_result,
14350 cmdline_parse_token_string_t cmd_macsec_sa_key =
14351 TOKEN_STRING_INITIALIZER
14352 (struct cmd_macsec_sa_result,
14356 cmd_set_macsec_sa_parsed(
14357 void *parsed_result,
14358 __attribute__((unused)) struct cmdline *cl,
14359 __attribute__((unused)) void *data)
14361 struct cmd_macsec_sa_result *res = parsed_result;
14362 int ret = -ENOTSUP;
14363 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14364 uint8_t key[16] = { 0 };
14370 key_len = strlen(res->key) / 2;
14374 for (i = 0; i < key_len; i++) {
14375 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14378 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14381 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14384 #ifdef RTE_LIBRTE_IXGBE_PMD
14386 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14387 res->idx, res->an, res->pn, key) :
14388 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14389 res->idx, res->an, res->pn, key);
14391 RTE_SET_USED(is_tx);
14398 printf("invalid idx %d or an %d\n", res->idx, res->an);
14401 printf("invalid port_id %d\n", res->port_id);
14404 printf("not supported on port %d\n", res->port_id);
14407 printf("programming error: (%s)\n", strerror(-ret));
14411 cmdline_parse_inst_t cmd_set_macsec_sa = {
14412 .f = cmd_set_macsec_sa_parsed,
14414 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14416 (void *)&cmd_macsec_sa_set,
14417 (void *)&cmd_macsec_sa_macsec,
14418 (void *)&cmd_macsec_sa_sa,
14419 (void *)&cmd_macsec_sa_tx_rx,
14420 (void *)&cmd_macsec_sa_port_id,
14421 (void *)&cmd_macsec_sa_idx,
14422 (void *)&cmd_macsec_sa_an,
14423 (void *)&cmd_macsec_sa_pn,
14424 (void *)&cmd_macsec_sa_key,
14429 /* VF unicast promiscuous mode configuration */
14431 /* Common result structure for VF unicast promiscuous mode */
14432 struct cmd_vf_promisc_result {
14433 cmdline_fixed_string_t set;
14434 cmdline_fixed_string_t vf;
14435 cmdline_fixed_string_t promisc;
14438 cmdline_fixed_string_t on_off;
14441 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14442 cmdline_parse_token_string_t cmd_vf_promisc_set =
14443 TOKEN_STRING_INITIALIZER
14444 (struct cmd_vf_promisc_result,
14446 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14447 TOKEN_STRING_INITIALIZER
14448 (struct cmd_vf_promisc_result,
14450 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14451 TOKEN_STRING_INITIALIZER
14452 (struct cmd_vf_promisc_result,
14453 promisc, "promisc");
14454 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14455 TOKEN_NUM_INITIALIZER
14456 (struct cmd_vf_promisc_result,
14458 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14459 TOKEN_NUM_INITIALIZER
14460 (struct cmd_vf_promisc_result,
14462 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14463 TOKEN_STRING_INITIALIZER
14464 (struct cmd_vf_promisc_result,
14468 cmd_set_vf_promisc_parsed(
14469 void *parsed_result,
14470 __attribute__((unused)) struct cmdline *cl,
14471 __attribute__((unused)) void *data)
14473 struct cmd_vf_promisc_result *res = parsed_result;
14474 int ret = -ENOTSUP;
14476 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14478 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14481 #ifdef RTE_LIBRTE_I40E_PMD
14482 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14483 res->vf_id, is_on);
14490 printf("invalid vf_id %d\n", res->vf_id);
14493 printf("invalid port_id %d\n", res->port_id);
14496 printf("function not implemented\n");
14499 printf("programming error: (%s)\n", strerror(-ret));
14503 cmdline_parse_inst_t cmd_set_vf_promisc = {
14504 .f = cmd_set_vf_promisc_parsed,
14506 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14507 "Set unicast promiscuous mode for a VF from the PF",
14509 (void *)&cmd_vf_promisc_set,
14510 (void *)&cmd_vf_promisc_vf,
14511 (void *)&cmd_vf_promisc_promisc,
14512 (void *)&cmd_vf_promisc_port_id,
14513 (void *)&cmd_vf_promisc_vf_id,
14514 (void *)&cmd_vf_promisc_on_off,
14519 /* VF multicast promiscuous mode configuration */
14521 /* Common result structure for VF multicast promiscuous mode */
14522 struct cmd_vf_allmulti_result {
14523 cmdline_fixed_string_t set;
14524 cmdline_fixed_string_t vf;
14525 cmdline_fixed_string_t allmulti;
14528 cmdline_fixed_string_t on_off;
14531 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14532 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14533 TOKEN_STRING_INITIALIZER
14534 (struct cmd_vf_allmulti_result,
14536 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14537 TOKEN_STRING_INITIALIZER
14538 (struct cmd_vf_allmulti_result,
14540 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14541 TOKEN_STRING_INITIALIZER
14542 (struct cmd_vf_allmulti_result,
14543 allmulti, "allmulti");
14544 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14545 TOKEN_NUM_INITIALIZER
14546 (struct cmd_vf_allmulti_result,
14548 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14549 TOKEN_NUM_INITIALIZER
14550 (struct cmd_vf_allmulti_result,
14552 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14553 TOKEN_STRING_INITIALIZER
14554 (struct cmd_vf_allmulti_result,
14558 cmd_set_vf_allmulti_parsed(
14559 void *parsed_result,
14560 __attribute__((unused)) struct cmdline *cl,
14561 __attribute__((unused)) void *data)
14563 struct cmd_vf_allmulti_result *res = parsed_result;
14564 int ret = -ENOTSUP;
14566 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14568 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14571 #ifdef RTE_LIBRTE_I40E_PMD
14572 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14573 res->vf_id, is_on);
14580 printf("invalid vf_id %d\n", res->vf_id);
14583 printf("invalid port_id %d\n", res->port_id);
14586 printf("function not implemented\n");
14589 printf("programming error: (%s)\n", strerror(-ret));
14593 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14594 .f = cmd_set_vf_allmulti_parsed,
14596 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14597 "Set multicast promiscuous mode for a VF from the PF",
14599 (void *)&cmd_vf_allmulti_set,
14600 (void *)&cmd_vf_allmulti_vf,
14601 (void *)&cmd_vf_allmulti_allmulti,
14602 (void *)&cmd_vf_allmulti_port_id,
14603 (void *)&cmd_vf_allmulti_vf_id,
14604 (void *)&cmd_vf_allmulti_on_off,
14609 /* vf broadcast mode configuration */
14611 /* Common result structure for vf broadcast */
14612 struct cmd_set_vf_broadcast_result {
14613 cmdline_fixed_string_t set;
14614 cmdline_fixed_string_t vf;
14615 cmdline_fixed_string_t broadcast;
14618 cmdline_fixed_string_t on_off;
14621 /* Common CLI fields for vf broadcast enable disable */
14622 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14623 TOKEN_STRING_INITIALIZER
14624 (struct cmd_set_vf_broadcast_result,
14626 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14627 TOKEN_STRING_INITIALIZER
14628 (struct cmd_set_vf_broadcast_result,
14630 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14631 TOKEN_STRING_INITIALIZER
14632 (struct cmd_set_vf_broadcast_result,
14633 broadcast, "broadcast");
14634 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14635 TOKEN_NUM_INITIALIZER
14636 (struct cmd_set_vf_broadcast_result,
14638 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14639 TOKEN_NUM_INITIALIZER
14640 (struct cmd_set_vf_broadcast_result,
14642 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14643 TOKEN_STRING_INITIALIZER
14644 (struct cmd_set_vf_broadcast_result,
14648 cmd_set_vf_broadcast_parsed(
14649 void *parsed_result,
14650 __attribute__((unused)) struct cmdline *cl,
14651 __attribute__((unused)) void *data)
14653 struct cmd_set_vf_broadcast_result *res = parsed_result;
14654 int ret = -ENOTSUP;
14656 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14658 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14661 #ifdef RTE_LIBRTE_I40E_PMD
14662 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14663 res->vf_id, is_on);
14670 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14673 printf("invalid port_id %d\n", res->port_id);
14676 printf("function not implemented\n");
14679 printf("programming error: (%s)\n", strerror(-ret));
14683 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14684 .f = cmd_set_vf_broadcast_parsed,
14686 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14688 (void *)&cmd_set_vf_broadcast_set,
14689 (void *)&cmd_set_vf_broadcast_vf,
14690 (void *)&cmd_set_vf_broadcast_broadcast,
14691 (void *)&cmd_set_vf_broadcast_port_id,
14692 (void *)&cmd_set_vf_broadcast_vf_id,
14693 (void *)&cmd_set_vf_broadcast_on_off,
14698 /* vf vlan tag configuration */
14700 /* Common result structure for vf vlan tag */
14701 struct cmd_set_vf_vlan_tag_result {
14702 cmdline_fixed_string_t set;
14703 cmdline_fixed_string_t vf;
14704 cmdline_fixed_string_t vlan;
14705 cmdline_fixed_string_t tag;
14708 cmdline_fixed_string_t on_off;
14711 /* Common CLI fields for vf vlan tag enable disable */
14712 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14713 TOKEN_STRING_INITIALIZER
14714 (struct cmd_set_vf_vlan_tag_result,
14716 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14717 TOKEN_STRING_INITIALIZER
14718 (struct cmd_set_vf_vlan_tag_result,
14720 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14721 TOKEN_STRING_INITIALIZER
14722 (struct cmd_set_vf_vlan_tag_result,
14724 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14725 TOKEN_STRING_INITIALIZER
14726 (struct cmd_set_vf_vlan_tag_result,
14728 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14729 TOKEN_NUM_INITIALIZER
14730 (struct cmd_set_vf_vlan_tag_result,
14732 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14733 TOKEN_NUM_INITIALIZER
14734 (struct cmd_set_vf_vlan_tag_result,
14736 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14737 TOKEN_STRING_INITIALIZER
14738 (struct cmd_set_vf_vlan_tag_result,
14742 cmd_set_vf_vlan_tag_parsed(
14743 void *parsed_result,
14744 __attribute__((unused)) struct cmdline *cl,
14745 __attribute__((unused)) void *data)
14747 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14748 int ret = -ENOTSUP;
14750 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14752 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14755 #ifdef RTE_LIBRTE_I40E_PMD
14756 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14757 res->vf_id, is_on);
14764 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14767 printf("invalid port_id %d\n", res->port_id);
14770 printf("function not implemented\n");
14773 printf("programming error: (%s)\n", strerror(-ret));
14777 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14778 .f = cmd_set_vf_vlan_tag_parsed,
14780 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14782 (void *)&cmd_set_vf_vlan_tag_set,
14783 (void *)&cmd_set_vf_vlan_tag_vf,
14784 (void *)&cmd_set_vf_vlan_tag_vlan,
14785 (void *)&cmd_set_vf_vlan_tag_tag,
14786 (void *)&cmd_set_vf_vlan_tag_port_id,
14787 (void *)&cmd_set_vf_vlan_tag_vf_id,
14788 (void *)&cmd_set_vf_vlan_tag_on_off,
14793 /* Common definition of VF and TC TX bandwidth configuration */
14794 struct cmd_vf_tc_bw_result {
14795 cmdline_fixed_string_t set;
14796 cmdline_fixed_string_t vf;
14797 cmdline_fixed_string_t tc;
14798 cmdline_fixed_string_t tx;
14799 cmdline_fixed_string_t min_bw;
14800 cmdline_fixed_string_t max_bw;
14801 cmdline_fixed_string_t strict_link_prio;
14806 cmdline_fixed_string_t bw_list;
14810 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14811 TOKEN_STRING_INITIALIZER
14812 (struct cmd_vf_tc_bw_result,
14814 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14815 TOKEN_STRING_INITIALIZER
14816 (struct cmd_vf_tc_bw_result,
14818 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14819 TOKEN_STRING_INITIALIZER
14820 (struct cmd_vf_tc_bw_result,
14822 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14823 TOKEN_STRING_INITIALIZER
14824 (struct cmd_vf_tc_bw_result,
14826 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14827 TOKEN_STRING_INITIALIZER
14828 (struct cmd_vf_tc_bw_result,
14829 strict_link_prio, "strict-link-priority");
14830 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14831 TOKEN_STRING_INITIALIZER
14832 (struct cmd_vf_tc_bw_result,
14833 min_bw, "min-bandwidth");
14834 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14835 TOKEN_STRING_INITIALIZER
14836 (struct cmd_vf_tc_bw_result,
14837 max_bw, "max-bandwidth");
14838 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14839 TOKEN_NUM_INITIALIZER
14840 (struct cmd_vf_tc_bw_result,
14842 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14843 TOKEN_NUM_INITIALIZER
14844 (struct cmd_vf_tc_bw_result,
14846 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14847 TOKEN_NUM_INITIALIZER
14848 (struct cmd_vf_tc_bw_result,
14850 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14851 TOKEN_NUM_INITIALIZER
14852 (struct cmd_vf_tc_bw_result,
14854 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14855 TOKEN_STRING_INITIALIZER
14856 (struct cmd_vf_tc_bw_result,
14858 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14859 TOKEN_NUM_INITIALIZER
14860 (struct cmd_vf_tc_bw_result,
14863 /* VF max bandwidth setting */
14865 cmd_vf_max_bw_parsed(
14866 void *parsed_result,
14867 __attribute__((unused)) struct cmdline *cl,
14868 __attribute__((unused)) void *data)
14870 struct cmd_vf_tc_bw_result *res = parsed_result;
14871 int ret = -ENOTSUP;
14873 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14876 #ifdef RTE_LIBRTE_I40E_PMD
14877 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14878 res->vf_id, res->bw);
14885 printf("invalid vf_id %d or bandwidth %d\n",
14886 res->vf_id, res->bw);
14889 printf("invalid port_id %d\n", res->port_id);
14892 printf("function not implemented\n");
14895 printf("programming error: (%s)\n", strerror(-ret));
14899 cmdline_parse_inst_t cmd_vf_max_bw = {
14900 .f = cmd_vf_max_bw_parsed,
14902 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14904 (void *)&cmd_vf_tc_bw_set,
14905 (void *)&cmd_vf_tc_bw_vf,
14906 (void *)&cmd_vf_tc_bw_tx,
14907 (void *)&cmd_vf_tc_bw_max_bw,
14908 (void *)&cmd_vf_tc_bw_port_id,
14909 (void *)&cmd_vf_tc_bw_vf_id,
14910 (void *)&cmd_vf_tc_bw_bw,
14916 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14921 const char *p, *p0 = str;
14928 p = strchr(p0, '(');
14930 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14934 p0 = strchr(p, ')');
14936 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14940 if (size >= sizeof(s)) {
14941 printf("The string size exceeds the internal buffer size\n");
14944 snprintf(s, sizeof(s), "%.*s", size, p);
14945 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14947 printf("Failed to get the bandwidth list. ");
14951 for (i = 0; i < ret; i++)
14952 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14957 /* TC min bandwidth setting */
14959 cmd_vf_tc_min_bw_parsed(
14960 void *parsed_result,
14961 __attribute__((unused)) struct cmdline *cl,
14962 __attribute__((unused)) void *data)
14964 struct cmd_vf_tc_bw_result *res = parsed_result;
14967 int ret = -ENOTSUP;
14969 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14972 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14976 #ifdef RTE_LIBRTE_I40E_PMD
14977 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14985 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14988 printf("invalid port_id %d\n", res->port_id);
14991 printf("function not implemented\n");
14994 printf("programming error: (%s)\n", strerror(-ret));
14998 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14999 .f = cmd_vf_tc_min_bw_parsed,
15001 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15002 " <bw1, bw2, ...>",
15004 (void *)&cmd_vf_tc_bw_set,
15005 (void *)&cmd_vf_tc_bw_vf,
15006 (void *)&cmd_vf_tc_bw_tc,
15007 (void *)&cmd_vf_tc_bw_tx,
15008 (void *)&cmd_vf_tc_bw_min_bw,
15009 (void *)&cmd_vf_tc_bw_port_id,
15010 (void *)&cmd_vf_tc_bw_vf_id,
15011 (void *)&cmd_vf_tc_bw_bw_list,
15017 cmd_tc_min_bw_parsed(
15018 void *parsed_result,
15019 __attribute__((unused)) struct cmdline *cl,
15020 __attribute__((unused)) void *data)
15022 struct cmd_vf_tc_bw_result *res = parsed_result;
15023 struct rte_port *port;
15026 int ret = -ENOTSUP;
15028 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15031 port = &ports[res->port_id];
15032 /** Check if the port is not started **/
15033 if (port->port_status != RTE_PORT_STOPPED) {
15034 printf("Please stop port %d first\n", res->port_id);
15038 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15042 #ifdef RTE_LIBRTE_IXGBE_PMD
15043 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15050 printf("invalid bandwidth\n");
15053 printf("invalid port_id %d\n", res->port_id);
15056 printf("function not implemented\n");
15059 printf("programming error: (%s)\n", strerror(-ret));
15063 cmdline_parse_inst_t cmd_tc_min_bw = {
15064 .f = cmd_tc_min_bw_parsed,
15066 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15068 (void *)&cmd_vf_tc_bw_set,
15069 (void *)&cmd_vf_tc_bw_tc,
15070 (void *)&cmd_vf_tc_bw_tx,
15071 (void *)&cmd_vf_tc_bw_min_bw,
15072 (void *)&cmd_vf_tc_bw_port_id,
15073 (void *)&cmd_vf_tc_bw_bw_list,
15078 /* TC max bandwidth setting */
15080 cmd_vf_tc_max_bw_parsed(
15081 void *parsed_result,
15082 __attribute__((unused)) struct cmdline *cl,
15083 __attribute__((unused)) void *data)
15085 struct cmd_vf_tc_bw_result *res = parsed_result;
15086 int ret = -ENOTSUP;
15088 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15091 #ifdef RTE_LIBRTE_I40E_PMD
15092 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15093 res->tc_no, res->bw);
15100 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15101 res->vf_id, res->tc_no, res->bw);
15104 printf("invalid port_id %d\n", res->port_id);
15107 printf("function not implemented\n");
15110 printf("programming error: (%s)\n", strerror(-ret));
15114 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15115 .f = cmd_vf_tc_max_bw_parsed,
15117 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15120 (void *)&cmd_vf_tc_bw_set,
15121 (void *)&cmd_vf_tc_bw_vf,
15122 (void *)&cmd_vf_tc_bw_tc,
15123 (void *)&cmd_vf_tc_bw_tx,
15124 (void *)&cmd_vf_tc_bw_max_bw,
15125 (void *)&cmd_vf_tc_bw_port_id,
15126 (void *)&cmd_vf_tc_bw_vf_id,
15127 (void *)&cmd_vf_tc_bw_tc_no,
15128 (void *)&cmd_vf_tc_bw_bw,
15134 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15136 /* *** Set Port default Traffic Management Hierarchy *** */
15137 struct cmd_set_port_tm_hierarchy_default_result {
15138 cmdline_fixed_string_t set;
15139 cmdline_fixed_string_t port;
15140 cmdline_fixed_string_t tm;
15141 cmdline_fixed_string_t hierarchy;
15142 cmdline_fixed_string_t def;
15146 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15147 TOKEN_STRING_INITIALIZER(
15148 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15149 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15150 TOKEN_STRING_INITIALIZER(
15151 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15152 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15153 TOKEN_STRING_INITIALIZER(
15154 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15155 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15156 TOKEN_STRING_INITIALIZER(
15157 struct cmd_set_port_tm_hierarchy_default_result,
15158 hierarchy, "hierarchy");
15159 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15160 TOKEN_STRING_INITIALIZER(
15161 struct cmd_set_port_tm_hierarchy_default_result,
15163 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15164 TOKEN_NUM_INITIALIZER(
15165 struct cmd_set_port_tm_hierarchy_default_result,
15168 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15169 __attribute__((unused)) struct cmdline *cl,
15170 __attribute__((unused)) void *data)
15172 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15173 struct rte_port *p;
15174 portid_t port_id = res->port_id;
15176 if (port_id_is_invalid(port_id, ENABLED_WARN))
15179 p = &ports[port_id];
15181 /* Forward mode: tm */
15182 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15183 printf(" softnicfwd mode not enabled(error)\n");
15187 /* Set the default tm hierarchy */
15188 p->softport.default_tm_hierarchy_enable = 1;
15191 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15192 .f = cmd_set_port_tm_hierarchy_default_parsed,
15194 .help_str = "set port tm hierarchy default <port_id>",
15196 (void *)&cmd_set_port_tm_hierarchy_default_set,
15197 (void *)&cmd_set_port_tm_hierarchy_default_port,
15198 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15199 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15200 (void *)&cmd_set_port_tm_hierarchy_default_default,
15201 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15207 /** Set VXLAN encapsulation details */
15208 struct cmd_set_vxlan_result {
15209 cmdline_fixed_string_t set;
15210 cmdline_fixed_string_t vxlan;
15211 cmdline_fixed_string_t pos_token;
15212 cmdline_fixed_string_t ip_version;
15213 uint32_t vlan_present:1;
15217 cmdline_ipaddr_t ip_src;
15218 cmdline_ipaddr_t ip_dst;
15222 struct rte_ether_addr eth_src;
15223 struct rte_ether_addr eth_dst;
15226 cmdline_parse_token_string_t cmd_set_vxlan_set =
15227 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15228 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15229 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15230 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15231 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15233 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15234 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15235 "vxlan-with-vlan");
15236 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15237 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15239 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15240 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15242 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15243 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15245 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15246 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15247 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15248 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15250 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15251 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15252 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15253 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15255 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15256 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15257 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15258 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15260 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15261 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15262 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15263 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15265 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15266 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15267 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15268 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15270 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15271 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15272 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15273 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15275 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15276 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15277 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15278 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15280 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15281 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15282 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15283 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15285 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15286 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15287 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15288 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15290 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15291 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15293 static void cmd_set_vxlan_parsed(void *parsed_result,
15294 __attribute__((unused)) struct cmdline *cl,
15295 __attribute__((unused)) void *data)
15297 struct cmd_set_vxlan_result *res = parsed_result;
15302 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15305 vxlan_encap_conf.select_tos_ttl = 0;
15306 if (strcmp(res->vxlan, "vxlan") == 0)
15307 vxlan_encap_conf.select_vlan = 0;
15308 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15309 vxlan_encap_conf.select_vlan = 1;
15310 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15311 vxlan_encap_conf.select_vlan = 0;
15312 vxlan_encap_conf.select_tos_ttl = 1;
15314 if (strcmp(res->ip_version, "ipv4") == 0)
15315 vxlan_encap_conf.select_ipv4 = 1;
15316 else if (strcmp(res->ip_version, "ipv6") == 0)
15317 vxlan_encap_conf.select_ipv4 = 0;
15320 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15321 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15322 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15323 vxlan_encap_conf.ip_tos = res->tos;
15324 vxlan_encap_conf.ip_ttl = res->ttl;
15325 if (vxlan_encap_conf.select_ipv4) {
15326 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15327 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15329 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15330 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15332 if (vxlan_encap_conf.select_vlan)
15333 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15334 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15335 RTE_ETHER_ADDR_LEN);
15336 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15337 RTE_ETHER_ADDR_LEN);
15340 cmdline_parse_inst_t cmd_set_vxlan = {
15341 .f = cmd_set_vxlan_parsed,
15343 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15344 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15345 " eth-src <eth-src> eth-dst <eth-dst>",
15347 (void *)&cmd_set_vxlan_set,
15348 (void *)&cmd_set_vxlan_vxlan,
15349 (void *)&cmd_set_vxlan_ip_version,
15350 (void *)&cmd_set_vxlan_ip_version_value,
15351 (void *)&cmd_set_vxlan_vni,
15352 (void *)&cmd_set_vxlan_vni_value,
15353 (void *)&cmd_set_vxlan_udp_src,
15354 (void *)&cmd_set_vxlan_udp_src_value,
15355 (void *)&cmd_set_vxlan_udp_dst,
15356 (void *)&cmd_set_vxlan_udp_dst_value,
15357 (void *)&cmd_set_vxlan_ip_src,
15358 (void *)&cmd_set_vxlan_ip_src_value,
15359 (void *)&cmd_set_vxlan_ip_dst,
15360 (void *)&cmd_set_vxlan_ip_dst_value,
15361 (void *)&cmd_set_vxlan_eth_src,
15362 (void *)&cmd_set_vxlan_eth_src_value,
15363 (void *)&cmd_set_vxlan_eth_dst,
15364 (void *)&cmd_set_vxlan_eth_dst_value,
15369 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15370 .f = cmd_set_vxlan_parsed,
15372 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15373 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15374 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15375 " eth-dst <eth-dst>",
15377 (void *)&cmd_set_vxlan_set,
15378 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15379 (void *)&cmd_set_vxlan_ip_version,
15380 (void *)&cmd_set_vxlan_ip_version_value,
15381 (void *)&cmd_set_vxlan_vni,
15382 (void *)&cmd_set_vxlan_vni_value,
15383 (void *)&cmd_set_vxlan_udp_src,
15384 (void *)&cmd_set_vxlan_udp_src_value,
15385 (void *)&cmd_set_vxlan_udp_dst,
15386 (void *)&cmd_set_vxlan_udp_dst_value,
15387 (void *)&cmd_set_vxlan_ip_tos,
15388 (void *)&cmd_set_vxlan_ip_tos_value,
15389 (void *)&cmd_set_vxlan_ip_ttl,
15390 (void *)&cmd_set_vxlan_ip_ttl_value,
15391 (void *)&cmd_set_vxlan_ip_src,
15392 (void *)&cmd_set_vxlan_ip_src_value,
15393 (void *)&cmd_set_vxlan_ip_dst,
15394 (void *)&cmd_set_vxlan_ip_dst_value,
15395 (void *)&cmd_set_vxlan_eth_src,
15396 (void *)&cmd_set_vxlan_eth_src_value,
15397 (void *)&cmd_set_vxlan_eth_dst,
15398 (void *)&cmd_set_vxlan_eth_dst_value,
15403 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15404 .f = cmd_set_vxlan_parsed,
15406 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15407 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15408 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15411 (void *)&cmd_set_vxlan_set,
15412 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15413 (void *)&cmd_set_vxlan_ip_version,
15414 (void *)&cmd_set_vxlan_ip_version_value,
15415 (void *)&cmd_set_vxlan_vni,
15416 (void *)&cmd_set_vxlan_vni_value,
15417 (void *)&cmd_set_vxlan_udp_src,
15418 (void *)&cmd_set_vxlan_udp_src_value,
15419 (void *)&cmd_set_vxlan_udp_dst,
15420 (void *)&cmd_set_vxlan_udp_dst_value,
15421 (void *)&cmd_set_vxlan_ip_src,
15422 (void *)&cmd_set_vxlan_ip_src_value,
15423 (void *)&cmd_set_vxlan_ip_dst,
15424 (void *)&cmd_set_vxlan_ip_dst_value,
15425 (void *)&cmd_set_vxlan_vlan,
15426 (void *)&cmd_set_vxlan_vlan_value,
15427 (void *)&cmd_set_vxlan_eth_src,
15428 (void *)&cmd_set_vxlan_eth_src_value,
15429 (void *)&cmd_set_vxlan_eth_dst,
15430 (void *)&cmd_set_vxlan_eth_dst_value,
15435 /** Set NVGRE encapsulation details */
15436 struct cmd_set_nvgre_result {
15437 cmdline_fixed_string_t set;
15438 cmdline_fixed_string_t nvgre;
15439 cmdline_fixed_string_t pos_token;
15440 cmdline_fixed_string_t ip_version;
15442 cmdline_ipaddr_t ip_src;
15443 cmdline_ipaddr_t ip_dst;
15445 struct rte_ether_addr eth_src;
15446 struct rte_ether_addr eth_dst;
15449 cmdline_parse_token_string_t cmd_set_nvgre_set =
15450 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15451 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15452 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15453 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15454 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15455 "nvgre-with-vlan");
15456 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15457 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15459 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15460 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15462 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15463 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15465 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15466 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15467 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15468 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15470 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15471 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15472 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15473 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15475 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15476 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15477 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15478 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15480 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15481 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15482 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15483 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15485 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15486 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15487 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15488 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15490 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15491 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15493 static void cmd_set_nvgre_parsed(void *parsed_result,
15494 __attribute__((unused)) struct cmdline *cl,
15495 __attribute__((unused)) void *data)
15497 struct cmd_set_nvgre_result *res = parsed_result;
15499 uint32_t nvgre_tni;
15502 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15505 if (strcmp(res->nvgre, "nvgre") == 0)
15506 nvgre_encap_conf.select_vlan = 0;
15507 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15508 nvgre_encap_conf.select_vlan = 1;
15509 if (strcmp(res->ip_version, "ipv4") == 0)
15510 nvgre_encap_conf.select_ipv4 = 1;
15511 else if (strcmp(res->ip_version, "ipv6") == 0)
15512 nvgre_encap_conf.select_ipv4 = 0;
15515 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15516 if (nvgre_encap_conf.select_ipv4) {
15517 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15518 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15520 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15521 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15523 if (nvgre_encap_conf.select_vlan)
15524 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15525 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15526 RTE_ETHER_ADDR_LEN);
15527 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15528 RTE_ETHER_ADDR_LEN);
15531 cmdline_parse_inst_t cmd_set_nvgre = {
15532 .f = cmd_set_nvgre_parsed,
15534 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15535 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15536 " eth-dst <eth-dst>",
15538 (void *)&cmd_set_nvgre_set,
15539 (void *)&cmd_set_nvgre_nvgre,
15540 (void *)&cmd_set_nvgre_ip_version,
15541 (void *)&cmd_set_nvgre_ip_version_value,
15542 (void *)&cmd_set_nvgre_tni,
15543 (void *)&cmd_set_nvgre_tni_value,
15544 (void *)&cmd_set_nvgre_ip_src,
15545 (void *)&cmd_set_nvgre_ip_src_value,
15546 (void *)&cmd_set_nvgre_ip_dst,
15547 (void *)&cmd_set_nvgre_ip_dst_value,
15548 (void *)&cmd_set_nvgre_eth_src,
15549 (void *)&cmd_set_nvgre_eth_src_value,
15550 (void *)&cmd_set_nvgre_eth_dst,
15551 (void *)&cmd_set_nvgre_eth_dst_value,
15556 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15557 .f = cmd_set_nvgre_parsed,
15559 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15560 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15561 " eth-src <eth-src> eth-dst <eth-dst>",
15563 (void *)&cmd_set_nvgre_set,
15564 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15565 (void *)&cmd_set_nvgre_ip_version,
15566 (void *)&cmd_set_nvgre_ip_version_value,
15567 (void *)&cmd_set_nvgre_tni,
15568 (void *)&cmd_set_nvgre_tni_value,
15569 (void *)&cmd_set_nvgre_ip_src,
15570 (void *)&cmd_set_nvgre_ip_src_value,
15571 (void *)&cmd_set_nvgre_ip_dst,
15572 (void *)&cmd_set_nvgre_ip_dst_value,
15573 (void *)&cmd_set_nvgre_vlan,
15574 (void *)&cmd_set_nvgre_vlan_value,
15575 (void *)&cmd_set_nvgre_eth_src,
15576 (void *)&cmd_set_nvgre_eth_src_value,
15577 (void *)&cmd_set_nvgre_eth_dst,
15578 (void *)&cmd_set_nvgre_eth_dst_value,
15583 /** Set L2 encapsulation details */
15584 struct cmd_set_l2_encap_result {
15585 cmdline_fixed_string_t set;
15586 cmdline_fixed_string_t l2_encap;
15587 cmdline_fixed_string_t pos_token;
15588 cmdline_fixed_string_t ip_version;
15589 uint32_t vlan_present:1;
15591 struct rte_ether_addr eth_src;
15592 struct rte_ether_addr eth_dst;
15595 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15596 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15597 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15598 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15599 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15600 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15601 "l2_encap-with-vlan");
15602 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15603 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15605 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15606 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15608 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15609 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15611 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15612 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15613 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15614 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15616 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15617 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15618 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15619 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15621 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15622 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15624 static void cmd_set_l2_encap_parsed(void *parsed_result,
15625 __attribute__((unused)) struct cmdline *cl,
15626 __attribute__((unused)) void *data)
15628 struct cmd_set_l2_encap_result *res = parsed_result;
15630 if (strcmp(res->l2_encap, "l2_encap") == 0)
15631 l2_encap_conf.select_vlan = 0;
15632 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15633 l2_encap_conf.select_vlan = 1;
15634 if (strcmp(res->ip_version, "ipv4") == 0)
15635 l2_encap_conf.select_ipv4 = 1;
15636 else if (strcmp(res->ip_version, "ipv6") == 0)
15637 l2_encap_conf.select_ipv4 = 0;
15640 if (l2_encap_conf.select_vlan)
15641 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15642 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15643 RTE_ETHER_ADDR_LEN);
15644 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15645 RTE_ETHER_ADDR_LEN);
15648 cmdline_parse_inst_t cmd_set_l2_encap = {
15649 .f = cmd_set_l2_encap_parsed,
15651 .help_str = "set l2_encap ip-version ipv4|ipv6"
15652 " eth-src <eth-src> eth-dst <eth-dst>",
15654 (void *)&cmd_set_l2_encap_set,
15655 (void *)&cmd_set_l2_encap_l2_encap,
15656 (void *)&cmd_set_l2_encap_ip_version,
15657 (void *)&cmd_set_l2_encap_ip_version_value,
15658 (void *)&cmd_set_l2_encap_eth_src,
15659 (void *)&cmd_set_l2_encap_eth_src_value,
15660 (void *)&cmd_set_l2_encap_eth_dst,
15661 (void *)&cmd_set_l2_encap_eth_dst_value,
15666 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15667 .f = cmd_set_l2_encap_parsed,
15669 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15670 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15672 (void *)&cmd_set_l2_encap_set,
15673 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15674 (void *)&cmd_set_l2_encap_ip_version,
15675 (void *)&cmd_set_l2_encap_ip_version_value,
15676 (void *)&cmd_set_l2_encap_vlan,
15677 (void *)&cmd_set_l2_encap_vlan_value,
15678 (void *)&cmd_set_l2_encap_eth_src,
15679 (void *)&cmd_set_l2_encap_eth_src_value,
15680 (void *)&cmd_set_l2_encap_eth_dst,
15681 (void *)&cmd_set_l2_encap_eth_dst_value,
15686 /** Set L2 decapsulation details */
15687 struct cmd_set_l2_decap_result {
15688 cmdline_fixed_string_t set;
15689 cmdline_fixed_string_t l2_decap;
15690 cmdline_fixed_string_t pos_token;
15691 uint32_t vlan_present:1;
15694 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15695 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15696 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15697 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15699 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15700 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15701 "l2_decap-with-vlan");
15703 static void cmd_set_l2_decap_parsed(void *parsed_result,
15704 __attribute__((unused)) struct cmdline *cl,
15705 __attribute__((unused)) void *data)
15707 struct cmd_set_l2_decap_result *res = parsed_result;
15709 if (strcmp(res->l2_decap, "l2_decap") == 0)
15710 l2_decap_conf.select_vlan = 0;
15711 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15712 l2_decap_conf.select_vlan = 1;
15715 cmdline_parse_inst_t cmd_set_l2_decap = {
15716 .f = cmd_set_l2_decap_parsed,
15718 .help_str = "set l2_decap",
15720 (void *)&cmd_set_l2_decap_set,
15721 (void *)&cmd_set_l2_decap_l2_decap,
15726 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15727 .f = cmd_set_l2_decap_parsed,
15729 .help_str = "set l2_decap-with-vlan",
15731 (void *)&cmd_set_l2_decap_set,
15732 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15737 /** Set MPLSoGRE encapsulation details */
15738 struct cmd_set_mplsogre_encap_result {
15739 cmdline_fixed_string_t set;
15740 cmdline_fixed_string_t mplsogre;
15741 cmdline_fixed_string_t pos_token;
15742 cmdline_fixed_string_t ip_version;
15743 uint32_t vlan_present:1;
15745 cmdline_ipaddr_t ip_src;
15746 cmdline_ipaddr_t ip_dst;
15748 struct rte_ether_addr eth_src;
15749 struct rte_ether_addr eth_dst;
15752 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15753 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15755 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15756 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15758 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15759 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15760 mplsogre, "mplsogre_encap-with-vlan");
15761 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15762 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15763 pos_token, "ip-version");
15764 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15765 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15766 ip_version, "ipv4#ipv6");
15767 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15768 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15769 pos_token, "label");
15770 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15771 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15773 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15774 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15775 pos_token, "ip-src");
15776 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15777 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15778 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15779 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15780 pos_token, "ip-dst");
15781 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15782 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15783 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15784 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15785 pos_token, "vlan-tci");
15786 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15787 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15789 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15790 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15791 pos_token, "eth-src");
15792 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15793 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15795 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15796 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15797 pos_token, "eth-dst");
15798 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15799 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15802 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15803 __attribute__((unused)) struct cmdline *cl,
15804 __attribute__((unused)) void *data)
15806 struct cmd_set_mplsogre_encap_result *res = parsed_result;
15808 uint32_t mplsogre_label;
15811 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15814 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15815 mplsogre_encap_conf.select_vlan = 0;
15816 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15817 mplsogre_encap_conf.select_vlan = 1;
15818 if (strcmp(res->ip_version, "ipv4") == 0)
15819 mplsogre_encap_conf.select_ipv4 = 1;
15820 else if (strcmp(res->ip_version, "ipv6") == 0)
15821 mplsogre_encap_conf.select_ipv4 = 0;
15824 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15825 if (mplsogre_encap_conf.select_ipv4) {
15826 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15827 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15829 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15830 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15832 if (mplsogre_encap_conf.select_vlan)
15833 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15834 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15835 RTE_ETHER_ADDR_LEN);
15836 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15837 RTE_ETHER_ADDR_LEN);
15840 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15841 .f = cmd_set_mplsogre_encap_parsed,
15843 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15844 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15845 " eth-dst <eth-dst>",
15847 (void *)&cmd_set_mplsogre_encap_set,
15848 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15849 (void *)&cmd_set_mplsogre_encap_ip_version,
15850 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15851 (void *)&cmd_set_mplsogre_encap_label,
15852 (void *)&cmd_set_mplsogre_encap_label_value,
15853 (void *)&cmd_set_mplsogre_encap_ip_src,
15854 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15855 (void *)&cmd_set_mplsogre_encap_ip_dst,
15856 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15857 (void *)&cmd_set_mplsogre_encap_eth_src,
15858 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15859 (void *)&cmd_set_mplsogre_encap_eth_dst,
15860 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15865 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
15866 .f = cmd_set_mplsogre_encap_parsed,
15868 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
15869 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
15870 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15872 (void *)&cmd_set_mplsogre_encap_set,
15873 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
15874 (void *)&cmd_set_mplsogre_encap_ip_version,
15875 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15876 (void *)&cmd_set_mplsogre_encap_label,
15877 (void *)&cmd_set_mplsogre_encap_label_value,
15878 (void *)&cmd_set_mplsogre_encap_ip_src,
15879 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15880 (void *)&cmd_set_mplsogre_encap_ip_dst,
15881 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15882 (void *)&cmd_set_mplsogre_encap_vlan,
15883 (void *)&cmd_set_mplsogre_encap_vlan_value,
15884 (void *)&cmd_set_mplsogre_encap_eth_src,
15885 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15886 (void *)&cmd_set_mplsogre_encap_eth_dst,
15887 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15892 /** Set MPLSoGRE decapsulation details */
15893 struct cmd_set_mplsogre_decap_result {
15894 cmdline_fixed_string_t set;
15895 cmdline_fixed_string_t mplsogre;
15896 cmdline_fixed_string_t pos_token;
15897 cmdline_fixed_string_t ip_version;
15898 uint32_t vlan_present:1;
15901 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
15902 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
15904 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
15905 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
15907 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
15908 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15909 mplsogre, "mplsogre_decap-with-vlan");
15910 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
15911 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15912 pos_token, "ip-version");
15913 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
15914 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15915 ip_version, "ipv4#ipv6");
15917 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
15918 __attribute__((unused)) struct cmdline *cl,
15919 __attribute__((unused)) void *data)
15921 struct cmd_set_mplsogre_decap_result *res = parsed_result;
15923 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
15924 mplsogre_decap_conf.select_vlan = 0;
15925 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
15926 mplsogre_decap_conf.select_vlan = 1;
15927 if (strcmp(res->ip_version, "ipv4") == 0)
15928 mplsogre_decap_conf.select_ipv4 = 1;
15929 else if (strcmp(res->ip_version, "ipv6") == 0)
15930 mplsogre_decap_conf.select_ipv4 = 0;
15933 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
15934 .f = cmd_set_mplsogre_decap_parsed,
15936 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
15938 (void *)&cmd_set_mplsogre_decap_set,
15939 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
15940 (void *)&cmd_set_mplsogre_decap_ip_version,
15941 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15946 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
15947 .f = cmd_set_mplsogre_decap_parsed,
15949 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
15951 (void *)&cmd_set_mplsogre_decap_set,
15952 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
15953 (void *)&cmd_set_mplsogre_decap_ip_version,
15954 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15959 /** Set MPLSoUDP encapsulation details */
15960 struct cmd_set_mplsoudp_encap_result {
15961 cmdline_fixed_string_t set;
15962 cmdline_fixed_string_t mplsoudp;
15963 cmdline_fixed_string_t pos_token;
15964 cmdline_fixed_string_t ip_version;
15965 uint32_t vlan_present:1;
15969 cmdline_ipaddr_t ip_src;
15970 cmdline_ipaddr_t ip_dst;
15972 struct rte_ether_addr eth_src;
15973 struct rte_ether_addr eth_dst;
15976 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
15977 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
15979 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
15980 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
15982 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
15983 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15984 mplsoudp, "mplsoudp_encap-with-vlan");
15985 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
15986 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15987 pos_token, "ip-version");
15988 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
15989 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15990 ip_version, "ipv4#ipv6");
15991 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
15992 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15993 pos_token, "label");
15994 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
15995 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
15997 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
15998 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15999 pos_token, "udp-src");
16000 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16001 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16003 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16004 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16005 pos_token, "udp-dst");
16006 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16007 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16009 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16010 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16011 pos_token, "ip-src");
16012 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16013 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16014 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16015 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16016 pos_token, "ip-dst");
16017 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16018 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16019 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16020 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16021 pos_token, "vlan-tci");
16022 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16023 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16025 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16026 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16027 pos_token, "eth-src");
16028 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16029 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16031 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16032 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16033 pos_token, "eth-dst");
16034 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16035 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16038 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16039 __attribute__((unused)) struct cmdline *cl,
16040 __attribute__((unused)) void *data)
16042 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16044 uint32_t mplsoudp_label;
16047 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16050 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16051 mplsoudp_encap_conf.select_vlan = 0;
16052 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16053 mplsoudp_encap_conf.select_vlan = 1;
16054 if (strcmp(res->ip_version, "ipv4") == 0)
16055 mplsoudp_encap_conf.select_ipv4 = 1;
16056 else if (strcmp(res->ip_version, "ipv6") == 0)
16057 mplsoudp_encap_conf.select_ipv4 = 0;
16060 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16061 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16062 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16063 if (mplsoudp_encap_conf.select_ipv4) {
16064 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16065 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16067 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16068 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16070 if (mplsoudp_encap_conf.select_vlan)
16071 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16072 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16073 RTE_ETHER_ADDR_LEN);
16074 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16075 RTE_ETHER_ADDR_LEN);
16078 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16079 .f = cmd_set_mplsoudp_encap_parsed,
16081 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16082 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16083 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16085 (void *)&cmd_set_mplsoudp_encap_set,
16086 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16087 (void *)&cmd_set_mplsoudp_encap_ip_version,
16088 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16089 (void *)&cmd_set_mplsoudp_encap_label,
16090 (void *)&cmd_set_mplsoudp_encap_label_value,
16091 (void *)&cmd_set_mplsoudp_encap_udp_src,
16092 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16093 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16094 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16095 (void *)&cmd_set_mplsoudp_encap_ip_src,
16096 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16097 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16098 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16099 (void *)&cmd_set_mplsoudp_encap_eth_src,
16100 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16101 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16102 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16107 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16108 .f = cmd_set_mplsoudp_encap_parsed,
16110 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16111 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16112 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16113 " eth-src <eth-src> eth-dst <eth-dst>",
16115 (void *)&cmd_set_mplsoudp_encap_set,
16116 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16117 (void *)&cmd_set_mplsoudp_encap_ip_version,
16118 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16119 (void *)&cmd_set_mplsoudp_encap_label,
16120 (void *)&cmd_set_mplsoudp_encap_label_value,
16121 (void *)&cmd_set_mplsoudp_encap_udp_src,
16122 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16123 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16124 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16125 (void *)&cmd_set_mplsoudp_encap_ip_src,
16126 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16127 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16128 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16129 (void *)&cmd_set_mplsoudp_encap_vlan,
16130 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16131 (void *)&cmd_set_mplsoudp_encap_eth_src,
16132 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16133 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16134 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16139 /** Set MPLSoUDP decapsulation details */
16140 struct cmd_set_mplsoudp_decap_result {
16141 cmdline_fixed_string_t set;
16142 cmdline_fixed_string_t mplsoudp;
16143 cmdline_fixed_string_t pos_token;
16144 cmdline_fixed_string_t ip_version;
16145 uint32_t vlan_present:1;
16148 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16149 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16151 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16152 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16154 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16155 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16156 mplsoudp, "mplsoudp_decap-with-vlan");
16157 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16158 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16159 pos_token, "ip-version");
16160 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16161 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16162 ip_version, "ipv4#ipv6");
16164 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16165 __attribute__((unused)) struct cmdline *cl,
16166 __attribute__((unused)) void *data)
16168 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16170 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16171 mplsoudp_decap_conf.select_vlan = 0;
16172 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16173 mplsoudp_decap_conf.select_vlan = 1;
16174 if (strcmp(res->ip_version, "ipv4") == 0)
16175 mplsoudp_decap_conf.select_ipv4 = 1;
16176 else if (strcmp(res->ip_version, "ipv6") == 0)
16177 mplsoudp_decap_conf.select_ipv4 = 0;
16180 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16181 .f = cmd_set_mplsoudp_decap_parsed,
16183 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16185 (void *)&cmd_set_mplsoudp_decap_set,
16186 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16187 (void *)&cmd_set_mplsoudp_decap_ip_version,
16188 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16193 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16194 .f = cmd_set_mplsoudp_decap_parsed,
16196 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16198 (void *)&cmd_set_mplsoudp_decap_set,
16199 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16200 (void *)&cmd_set_mplsoudp_decap_ip_version,
16201 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16206 /* Strict link priority scheduling mode setting */
16208 cmd_strict_link_prio_parsed(
16209 void *parsed_result,
16210 __attribute__((unused)) struct cmdline *cl,
16211 __attribute__((unused)) void *data)
16213 struct cmd_vf_tc_bw_result *res = parsed_result;
16214 int ret = -ENOTSUP;
16216 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16219 #ifdef RTE_LIBRTE_I40E_PMD
16220 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16227 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16230 printf("invalid port_id %d\n", res->port_id);
16233 printf("function not implemented\n");
16236 printf("programming error: (%s)\n", strerror(-ret));
16240 cmdline_parse_inst_t cmd_strict_link_prio = {
16241 .f = cmd_strict_link_prio_parsed,
16243 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16245 (void *)&cmd_vf_tc_bw_set,
16246 (void *)&cmd_vf_tc_bw_tx,
16247 (void *)&cmd_vf_tc_bw_strict_link_prio,
16248 (void *)&cmd_vf_tc_bw_port_id,
16249 (void *)&cmd_vf_tc_bw_tc_map,
16254 /* Load dynamic device personalization*/
16255 struct cmd_ddp_add_result {
16256 cmdline_fixed_string_t ddp;
16257 cmdline_fixed_string_t add;
16262 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16263 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16264 cmdline_parse_token_string_t cmd_ddp_add_add =
16265 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16266 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16267 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16268 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16269 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16272 cmd_ddp_add_parsed(
16273 void *parsed_result,
16274 __attribute__((unused)) struct cmdline *cl,
16275 __attribute__((unused)) void *data)
16277 struct cmd_ddp_add_result *res = parsed_result;
16283 int ret = -ENOTSUP;
16285 if (!all_ports_stopped()) {
16286 printf("Please stop all ports first\n");
16290 filepath = strdup(res->filepath);
16291 if (filepath == NULL) {
16292 printf("Failed to allocate memory\n");
16295 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16297 buff = open_file(file_fld[0], &size);
16299 free((void *)filepath);
16303 #ifdef RTE_LIBRTE_I40E_PMD
16304 if (ret == -ENOTSUP)
16305 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16307 RTE_PMD_I40E_PKG_OP_WR_ADD);
16310 if (ret == -EEXIST)
16311 printf("Profile has already existed.\n");
16313 printf("Failed to load profile.\n");
16314 else if (file_num == 2)
16315 save_file(file_fld[1], buff, size);
16318 free((void *)filepath);
16321 cmdline_parse_inst_t cmd_ddp_add = {
16322 .f = cmd_ddp_add_parsed,
16324 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16326 (void *)&cmd_ddp_add_ddp,
16327 (void *)&cmd_ddp_add_add,
16328 (void *)&cmd_ddp_add_port_id,
16329 (void *)&cmd_ddp_add_filepath,
16334 /* Delete dynamic device personalization*/
16335 struct cmd_ddp_del_result {
16336 cmdline_fixed_string_t ddp;
16337 cmdline_fixed_string_t del;
16342 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16343 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16344 cmdline_parse_token_string_t cmd_ddp_del_del =
16345 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16346 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16347 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16348 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16349 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16352 cmd_ddp_del_parsed(
16353 void *parsed_result,
16354 __attribute__((unused)) struct cmdline *cl,
16355 __attribute__((unused)) void *data)
16357 struct cmd_ddp_del_result *res = parsed_result;
16360 int ret = -ENOTSUP;
16362 if (!all_ports_stopped()) {
16363 printf("Please stop all ports first\n");
16367 buff = open_file(res->filepath, &size);
16371 #ifdef RTE_LIBRTE_I40E_PMD
16372 if (ret == -ENOTSUP)
16373 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16375 RTE_PMD_I40E_PKG_OP_WR_DEL);
16378 if (ret == -EACCES)
16379 printf("Profile does not exist.\n");
16381 printf("Failed to delete profile.\n");
16386 cmdline_parse_inst_t cmd_ddp_del = {
16387 .f = cmd_ddp_del_parsed,
16389 .help_str = "ddp del <port_id> <backup_profile_path>",
16391 (void *)&cmd_ddp_del_ddp,
16392 (void *)&cmd_ddp_del_del,
16393 (void *)&cmd_ddp_del_port_id,
16394 (void *)&cmd_ddp_del_filepath,
16399 /* Get dynamic device personalization profile info */
16400 struct cmd_ddp_info_result {
16401 cmdline_fixed_string_t ddp;
16402 cmdline_fixed_string_t get;
16403 cmdline_fixed_string_t info;
16407 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16408 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16409 cmdline_parse_token_string_t cmd_ddp_info_get =
16410 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16411 cmdline_parse_token_string_t cmd_ddp_info_info =
16412 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16413 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16414 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16417 cmd_ddp_info_parsed(
16418 void *parsed_result,
16419 __attribute__((unused)) struct cmdline *cl,
16420 __attribute__((unused)) void *data)
16422 struct cmd_ddp_info_result *res = parsed_result;
16425 int ret = -ENOTSUP;
16426 #ifdef RTE_LIBRTE_I40E_PMD
16429 uint32_t buff_size = 0;
16430 struct rte_pmd_i40e_profile_info info;
16431 uint32_t dev_num = 0;
16432 struct rte_pmd_i40e_ddp_device_id *devs;
16433 uint32_t proto_num = 0;
16434 struct rte_pmd_i40e_proto_info *proto = NULL;
16435 uint32_t pctype_num = 0;
16436 struct rte_pmd_i40e_ptype_info *pctype;
16437 uint32_t ptype_num = 0;
16438 struct rte_pmd_i40e_ptype_info *ptype;
16443 pkg = open_file(res->filepath, &pkg_size);
16447 #ifdef RTE_LIBRTE_I40E_PMD
16448 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16449 (uint8_t *)&info, sizeof(info),
16450 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16452 printf("Global Track id: 0x%x\n", info.track_id);
16453 printf("Global Version: %d.%d.%d.%d\n",
16454 info.version.major,
16455 info.version.minor,
16456 info.version.update,
16457 info.version.draft);
16458 printf("Global Package name: %s\n\n", info.name);
16461 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16462 (uint8_t *)&info, sizeof(info),
16463 RTE_PMD_I40E_PKG_INFO_HEADER);
16465 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16466 printf("i40e Profile Version: %d.%d.%d.%d\n",
16467 info.version.major,
16468 info.version.minor,
16469 info.version.update,
16470 info.version.draft);
16471 printf("i40e Profile name: %s\n\n", info.name);
16474 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16475 (uint8_t *)&buff_size, sizeof(buff_size),
16476 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16477 if (!ret && buff_size) {
16478 buff = (uint8_t *)malloc(buff_size);
16480 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16482 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16484 printf("Package Notes:\n%s\n\n", buff);
16489 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16490 (uint8_t *)&dev_num, sizeof(dev_num),
16491 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16492 if (!ret && dev_num) {
16493 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16494 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16496 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16497 (uint8_t *)devs, buff_size,
16498 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16500 printf("List of supported devices:\n");
16501 for (i = 0; i < dev_num; i++) {
16502 printf(" %04X:%04X %04X:%04X\n",
16503 devs[i].vendor_dev_id >> 16,
16504 devs[i].vendor_dev_id & 0xFFFF,
16505 devs[i].sub_vendor_dev_id >> 16,
16506 devs[i].sub_vendor_dev_id & 0xFFFF);
16514 /* get information about protocols and packet types */
16515 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16516 (uint8_t *)&proto_num, sizeof(proto_num),
16517 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16518 if (ret || !proto_num)
16519 goto no_print_return;
16521 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16522 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16524 goto no_print_return;
16526 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16528 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16530 printf("List of used protocols:\n");
16531 for (i = 0; i < proto_num; i++)
16532 printf(" %2u: %s\n", proto[i].proto_id,
16536 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16537 (uint8_t *)&pctype_num, sizeof(pctype_num),
16538 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16539 if (ret || !pctype_num)
16540 goto no_print_pctypes;
16542 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16543 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16545 goto no_print_pctypes;
16547 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16549 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16552 goto no_print_pctypes;
16555 printf("List of defined packet classification types:\n");
16556 for (i = 0; i < pctype_num; i++) {
16557 printf(" %2u:", pctype[i].ptype_id);
16558 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16559 proto_id = pctype[i].protocols[j];
16560 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16561 for (n = 0; n < proto_num; n++) {
16562 if (proto[n].proto_id == proto_id) {
16563 printf(" %s", proto[n].name);
16576 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16578 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16579 if (ret || !ptype_num)
16580 goto no_print_return;
16582 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16583 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16585 goto no_print_return;
16587 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16589 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16592 goto no_print_return;
16594 printf("List of defined packet types:\n");
16595 for (i = 0; i < ptype_num; i++) {
16596 printf(" %2u:", ptype[i].ptype_id);
16597 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16598 proto_id = ptype[i].protocols[j];
16599 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16600 for (n = 0; n < proto_num; n++) {
16601 if (proto[n].proto_id == proto_id) {
16602 printf(" %s", proto[n].name);
16618 if (ret == -ENOTSUP)
16619 printf("Function not supported in PMD driver\n");
16623 cmdline_parse_inst_t cmd_ddp_get_info = {
16624 .f = cmd_ddp_info_parsed,
16626 .help_str = "ddp get info <profile_path>",
16628 (void *)&cmd_ddp_info_ddp,
16629 (void *)&cmd_ddp_info_get,
16630 (void *)&cmd_ddp_info_info,
16631 (void *)&cmd_ddp_info_filepath,
16636 /* Get dynamic device personalization profile info list*/
16637 #define PROFILE_INFO_SIZE 48
16638 #define MAX_PROFILE_NUM 16
16640 struct cmd_ddp_get_list_result {
16641 cmdline_fixed_string_t ddp;
16642 cmdline_fixed_string_t get;
16643 cmdline_fixed_string_t list;
16647 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16648 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16649 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16650 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16651 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16652 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16653 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16654 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16657 cmd_ddp_get_list_parsed(
16658 __attribute__((unused)) void *parsed_result,
16659 __attribute__((unused)) struct cmdline *cl,
16660 __attribute__((unused)) void *data)
16662 #ifdef RTE_LIBRTE_I40E_PMD
16663 struct cmd_ddp_get_list_result *res = parsed_result;
16664 struct rte_pmd_i40e_profile_list *p_list;
16665 struct rte_pmd_i40e_profile_info *p_info;
16670 int ret = -ENOTSUP;
16672 #ifdef RTE_LIBRTE_I40E_PMD
16673 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16674 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16676 printf("%s: Failed to malloc buffer\n", __func__);
16678 if (ret == -ENOTSUP)
16679 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16680 (uint8_t *)p_list, size);
16683 p_num = p_list->p_count;
16684 printf("Profile number is: %d\n\n", p_num);
16686 for (i = 0; i < p_num; i++) {
16687 p_info = &p_list->p_info[i];
16688 printf("Profile %d:\n", i);
16689 printf("Track id: 0x%x\n", p_info->track_id);
16690 printf("Version: %d.%d.%d.%d\n",
16691 p_info->version.major,
16692 p_info->version.minor,
16693 p_info->version.update,
16694 p_info->version.draft);
16695 printf("Profile name: %s\n\n", p_info->name);
16703 printf("Failed to get ddp list\n");
16706 cmdline_parse_inst_t cmd_ddp_get_list = {
16707 .f = cmd_ddp_get_list_parsed,
16709 .help_str = "ddp get list <port_id>",
16711 (void *)&cmd_ddp_get_list_ddp,
16712 (void *)&cmd_ddp_get_list_get,
16713 (void *)&cmd_ddp_get_list_list,
16714 (void *)&cmd_ddp_get_list_port_id,
16719 /* Configure input set */
16720 struct cmd_cfg_input_set_result {
16721 cmdline_fixed_string_t port;
16722 cmdline_fixed_string_t cfg;
16724 cmdline_fixed_string_t pctype;
16726 cmdline_fixed_string_t inset_type;
16727 cmdline_fixed_string_t opt;
16728 cmdline_fixed_string_t field;
16733 cmd_cfg_input_set_parsed(
16734 __attribute__((unused)) void *parsed_result,
16735 __attribute__((unused)) struct cmdline *cl,
16736 __attribute__((unused)) void *data)
16738 #ifdef RTE_LIBRTE_I40E_PMD
16739 struct cmd_cfg_input_set_result *res = parsed_result;
16740 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16741 struct rte_pmd_i40e_inset inset;
16743 int ret = -ENOTSUP;
16745 if (!all_ports_stopped()) {
16746 printf("Please stop all ports first\n");
16750 #ifdef RTE_LIBRTE_I40E_PMD
16751 if (!strcmp(res->inset_type, "hash_inset"))
16752 inset_type = INSET_HASH;
16753 else if (!strcmp(res->inset_type, "fdir_inset"))
16754 inset_type = INSET_FDIR;
16755 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16756 inset_type = INSET_FDIR_FLX;
16757 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16758 &inset, inset_type);
16760 printf("Failed to get input set.\n");
16764 if (!strcmp(res->opt, "get")) {
16765 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16768 printf("Field index %d is enabled.\n", res->field_idx);
16770 printf("Field index %d is disabled.\n", res->field_idx);
16772 } else if (!strcmp(res->opt, "set"))
16773 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16775 else if (!strcmp(res->opt, "clear"))
16776 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16779 printf("Failed to configure input set field.\n");
16783 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16784 &inset, inset_type);
16786 printf("Failed to set input set.\n");
16791 if (ret == -ENOTSUP)
16792 printf("Function not supported\n");
16795 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16796 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16798 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16799 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16801 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16802 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16804 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16805 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16807 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16808 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16810 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16811 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16813 "hash_inset#fdir_inset#fdir_flx_inset");
16814 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16815 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16816 opt, "get#set#clear");
16817 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16818 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16820 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16821 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16824 cmdline_parse_inst_t cmd_cfg_input_set = {
16825 .f = cmd_cfg_input_set_parsed,
16827 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16828 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16830 (void *)&cmd_cfg_input_set_port,
16831 (void *)&cmd_cfg_input_set_cfg,
16832 (void *)&cmd_cfg_input_set_port_id,
16833 (void *)&cmd_cfg_input_set_pctype,
16834 (void *)&cmd_cfg_input_set_pctype_id,
16835 (void *)&cmd_cfg_input_set_inset_type,
16836 (void *)&cmd_cfg_input_set_opt,
16837 (void *)&cmd_cfg_input_set_field,
16838 (void *)&cmd_cfg_input_set_field_idx,
16843 /* Clear input set */
16844 struct cmd_clear_input_set_result {
16845 cmdline_fixed_string_t port;
16846 cmdline_fixed_string_t cfg;
16848 cmdline_fixed_string_t pctype;
16850 cmdline_fixed_string_t inset_type;
16851 cmdline_fixed_string_t clear;
16852 cmdline_fixed_string_t all;
16856 cmd_clear_input_set_parsed(
16857 __attribute__((unused)) void *parsed_result,
16858 __attribute__((unused)) struct cmdline *cl,
16859 __attribute__((unused)) void *data)
16861 #ifdef RTE_LIBRTE_I40E_PMD
16862 struct cmd_clear_input_set_result *res = parsed_result;
16863 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16864 struct rte_pmd_i40e_inset inset;
16866 int ret = -ENOTSUP;
16868 if (!all_ports_stopped()) {
16869 printf("Please stop all ports first\n");
16873 #ifdef RTE_LIBRTE_I40E_PMD
16874 if (!strcmp(res->inset_type, "hash_inset"))
16875 inset_type = INSET_HASH;
16876 else if (!strcmp(res->inset_type, "fdir_inset"))
16877 inset_type = INSET_FDIR;
16878 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16879 inset_type = INSET_FDIR_FLX;
16881 memset(&inset, 0, sizeof(inset));
16883 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16884 &inset, inset_type);
16886 printf("Failed to clear input set.\n");
16892 if (ret == -ENOTSUP)
16893 printf("Function not supported\n");
16896 cmdline_parse_token_string_t cmd_clear_input_set_port =
16897 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16899 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
16900 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16902 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
16903 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16905 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
16906 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16908 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
16909 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16911 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
16912 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16914 "hash_inset#fdir_inset#fdir_flx_inset");
16915 cmdline_parse_token_string_t cmd_clear_input_set_clear =
16916 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16918 cmdline_parse_token_string_t cmd_clear_input_set_all =
16919 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16922 cmdline_parse_inst_t cmd_clear_input_set = {
16923 .f = cmd_clear_input_set_parsed,
16925 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16926 "fdir_inset|fdir_flx_inset clear all",
16928 (void *)&cmd_clear_input_set_port,
16929 (void *)&cmd_clear_input_set_cfg,
16930 (void *)&cmd_clear_input_set_port_id,
16931 (void *)&cmd_clear_input_set_pctype,
16932 (void *)&cmd_clear_input_set_pctype_id,
16933 (void *)&cmd_clear_input_set_inset_type,
16934 (void *)&cmd_clear_input_set_clear,
16935 (void *)&cmd_clear_input_set_all,
16940 /* show vf stats */
16942 /* Common result structure for show vf stats */
16943 struct cmd_show_vf_stats_result {
16944 cmdline_fixed_string_t show;
16945 cmdline_fixed_string_t vf;
16946 cmdline_fixed_string_t stats;
16951 /* Common CLI fields show vf stats*/
16952 cmdline_parse_token_string_t cmd_show_vf_stats_show =
16953 TOKEN_STRING_INITIALIZER
16954 (struct cmd_show_vf_stats_result,
16956 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
16957 TOKEN_STRING_INITIALIZER
16958 (struct cmd_show_vf_stats_result,
16960 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
16961 TOKEN_STRING_INITIALIZER
16962 (struct cmd_show_vf_stats_result,
16964 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
16965 TOKEN_NUM_INITIALIZER
16966 (struct cmd_show_vf_stats_result,
16968 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
16969 TOKEN_NUM_INITIALIZER
16970 (struct cmd_show_vf_stats_result,
16974 cmd_show_vf_stats_parsed(
16975 void *parsed_result,
16976 __attribute__((unused)) struct cmdline *cl,
16977 __attribute__((unused)) void *data)
16979 struct cmd_show_vf_stats_result *res = parsed_result;
16980 struct rte_eth_stats stats;
16981 int ret = -ENOTSUP;
16982 static const char *nic_stats_border = "########################";
16984 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16987 memset(&stats, 0, sizeof(stats));
16989 #ifdef RTE_LIBRTE_I40E_PMD
16990 if (ret == -ENOTSUP)
16991 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
16995 #ifdef RTE_LIBRTE_BNXT_PMD
16996 if (ret == -ENOTSUP)
16997 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17006 printf("invalid vf_id %d\n", res->vf_id);
17009 printf("invalid port_id %d\n", res->port_id);
17012 printf("function not implemented\n");
17015 printf("programming error: (%s)\n", strerror(-ret));
17018 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17019 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17021 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17023 stats.ipackets, stats.imissed, stats.ibytes);
17024 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17025 printf(" RX-nombuf: %-10"PRIu64"\n",
17027 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17029 stats.opackets, stats.oerrors, stats.obytes);
17031 printf(" %s############################%s\n",
17032 nic_stats_border, nic_stats_border);
17035 cmdline_parse_inst_t cmd_show_vf_stats = {
17036 .f = cmd_show_vf_stats_parsed,
17038 .help_str = "show vf stats <port_id> <vf_id>",
17040 (void *)&cmd_show_vf_stats_show,
17041 (void *)&cmd_show_vf_stats_vf,
17042 (void *)&cmd_show_vf_stats_stats,
17043 (void *)&cmd_show_vf_stats_port_id,
17044 (void *)&cmd_show_vf_stats_vf_id,
17049 /* clear vf stats */
17051 /* Common result structure for clear vf stats */
17052 struct cmd_clear_vf_stats_result {
17053 cmdline_fixed_string_t clear;
17054 cmdline_fixed_string_t vf;
17055 cmdline_fixed_string_t stats;
17060 /* Common CLI fields clear vf stats*/
17061 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17062 TOKEN_STRING_INITIALIZER
17063 (struct cmd_clear_vf_stats_result,
17065 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17066 TOKEN_STRING_INITIALIZER
17067 (struct cmd_clear_vf_stats_result,
17069 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17070 TOKEN_STRING_INITIALIZER
17071 (struct cmd_clear_vf_stats_result,
17073 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17074 TOKEN_NUM_INITIALIZER
17075 (struct cmd_clear_vf_stats_result,
17077 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17078 TOKEN_NUM_INITIALIZER
17079 (struct cmd_clear_vf_stats_result,
17083 cmd_clear_vf_stats_parsed(
17084 void *parsed_result,
17085 __attribute__((unused)) struct cmdline *cl,
17086 __attribute__((unused)) void *data)
17088 struct cmd_clear_vf_stats_result *res = parsed_result;
17089 int ret = -ENOTSUP;
17091 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17094 #ifdef RTE_LIBRTE_I40E_PMD
17095 if (ret == -ENOTSUP)
17096 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17099 #ifdef RTE_LIBRTE_BNXT_PMD
17100 if (ret == -ENOTSUP)
17101 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17109 printf("invalid vf_id %d\n", res->vf_id);
17112 printf("invalid port_id %d\n", res->port_id);
17115 printf("function not implemented\n");
17118 printf("programming error: (%s)\n", strerror(-ret));
17122 cmdline_parse_inst_t cmd_clear_vf_stats = {
17123 .f = cmd_clear_vf_stats_parsed,
17125 .help_str = "clear vf stats <port_id> <vf_id>",
17127 (void *)&cmd_clear_vf_stats_clear,
17128 (void *)&cmd_clear_vf_stats_vf,
17129 (void *)&cmd_clear_vf_stats_stats,
17130 (void *)&cmd_clear_vf_stats_port_id,
17131 (void *)&cmd_clear_vf_stats_vf_id,
17136 /* port config pctype mapping reset */
17138 /* Common result structure for port config pctype mapping reset */
17139 struct cmd_pctype_mapping_reset_result {
17140 cmdline_fixed_string_t port;
17141 cmdline_fixed_string_t config;
17143 cmdline_fixed_string_t pctype;
17144 cmdline_fixed_string_t mapping;
17145 cmdline_fixed_string_t reset;
17148 /* Common CLI fields for port config pctype mapping reset*/
17149 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17150 TOKEN_STRING_INITIALIZER
17151 (struct cmd_pctype_mapping_reset_result,
17153 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17154 TOKEN_STRING_INITIALIZER
17155 (struct cmd_pctype_mapping_reset_result,
17157 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17158 TOKEN_NUM_INITIALIZER
17159 (struct cmd_pctype_mapping_reset_result,
17161 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17162 TOKEN_STRING_INITIALIZER
17163 (struct cmd_pctype_mapping_reset_result,
17165 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17166 TOKEN_STRING_INITIALIZER
17167 (struct cmd_pctype_mapping_reset_result,
17168 mapping, "mapping");
17169 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17170 TOKEN_STRING_INITIALIZER
17171 (struct cmd_pctype_mapping_reset_result,
17175 cmd_pctype_mapping_reset_parsed(
17176 void *parsed_result,
17177 __attribute__((unused)) struct cmdline *cl,
17178 __attribute__((unused)) void *data)
17180 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17181 int ret = -ENOTSUP;
17183 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17186 #ifdef RTE_LIBRTE_I40E_PMD
17187 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17194 printf("invalid port_id %d\n", res->port_id);
17197 printf("function not implemented\n");
17200 printf("programming error: (%s)\n", strerror(-ret));
17204 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17205 .f = cmd_pctype_mapping_reset_parsed,
17207 .help_str = "port config <port_id> pctype mapping reset",
17209 (void *)&cmd_pctype_mapping_reset_port,
17210 (void *)&cmd_pctype_mapping_reset_config,
17211 (void *)&cmd_pctype_mapping_reset_port_id,
17212 (void *)&cmd_pctype_mapping_reset_pctype,
17213 (void *)&cmd_pctype_mapping_reset_mapping,
17214 (void *)&cmd_pctype_mapping_reset_reset,
17219 /* show port pctype mapping */
17221 /* Common result structure for show port pctype mapping */
17222 struct cmd_pctype_mapping_get_result {
17223 cmdline_fixed_string_t show;
17224 cmdline_fixed_string_t port;
17226 cmdline_fixed_string_t pctype;
17227 cmdline_fixed_string_t mapping;
17230 /* Common CLI fields for pctype mapping get */
17231 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17232 TOKEN_STRING_INITIALIZER
17233 (struct cmd_pctype_mapping_get_result,
17235 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17236 TOKEN_STRING_INITIALIZER
17237 (struct cmd_pctype_mapping_get_result,
17239 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17240 TOKEN_NUM_INITIALIZER
17241 (struct cmd_pctype_mapping_get_result,
17243 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17244 TOKEN_STRING_INITIALIZER
17245 (struct cmd_pctype_mapping_get_result,
17247 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17248 TOKEN_STRING_INITIALIZER
17249 (struct cmd_pctype_mapping_get_result,
17250 mapping, "mapping");
17253 cmd_pctype_mapping_get_parsed(
17254 void *parsed_result,
17255 __attribute__((unused)) struct cmdline *cl,
17256 __attribute__((unused)) void *data)
17258 struct cmd_pctype_mapping_get_result *res = parsed_result;
17259 int ret = -ENOTSUP;
17260 #ifdef RTE_LIBRTE_I40E_PMD
17261 struct rte_pmd_i40e_flow_type_mapping
17262 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17263 int i, j, first_pctype;
17266 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17269 #ifdef RTE_LIBRTE_I40E_PMD
17270 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17277 printf("invalid port_id %d\n", res->port_id);
17280 printf("function not implemented\n");
17283 printf("programming error: (%s)\n", strerror(-ret));
17287 #ifdef RTE_LIBRTE_I40E_PMD
17288 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17289 if (mapping[i].pctype != 0ULL) {
17292 printf("pctype: ");
17293 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17294 if (mapping[i].pctype & (1ULL << j)) {
17295 printf(first_pctype ?
17296 "%02d" : ",%02d", j);
17300 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17306 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17307 .f = cmd_pctype_mapping_get_parsed,
17309 .help_str = "show port <port_id> pctype mapping",
17311 (void *)&cmd_pctype_mapping_get_show,
17312 (void *)&cmd_pctype_mapping_get_port,
17313 (void *)&cmd_pctype_mapping_get_port_id,
17314 (void *)&cmd_pctype_mapping_get_pctype,
17315 (void *)&cmd_pctype_mapping_get_mapping,
17320 /* port config pctype mapping update */
17322 /* Common result structure for port config pctype mapping update */
17323 struct cmd_pctype_mapping_update_result {
17324 cmdline_fixed_string_t port;
17325 cmdline_fixed_string_t config;
17327 cmdline_fixed_string_t pctype;
17328 cmdline_fixed_string_t mapping;
17329 cmdline_fixed_string_t update;
17330 cmdline_fixed_string_t pctype_list;
17331 uint16_t flow_type;
17334 /* Common CLI fields for pctype mapping update*/
17335 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17336 TOKEN_STRING_INITIALIZER
17337 (struct cmd_pctype_mapping_update_result,
17339 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17340 TOKEN_STRING_INITIALIZER
17341 (struct cmd_pctype_mapping_update_result,
17343 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17344 TOKEN_NUM_INITIALIZER
17345 (struct cmd_pctype_mapping_update_result,
17347 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17348 TOKEN_STRING_INITIALIZER
17349 (struct cmd_pctype_mapping_update_result,
17351 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17352 TOKEN_STRING_INITIALIZER
17353 (struct cmd_pctype_mapping_update_result,
17354 mapping, "mapping");
17355 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17356 TOKEN_STRING_INITIALIZER
17357 (struct cmd_pctype_mapping_update_result,
17359 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17360 TOKEN_STRING_INITIALIZER
17361 (struct cmd_pctype_mapping_update_result,
17362 pctype_list, NULL);
17363 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17364 TOKEN_NUM_INITIALIZER
17365 (struct cmd_pctype_mapping_update_result,
17366 flow_type, UINT16);
17369 cmd_pctype_mapping_update_parsed(
17370 void *parsed_result,
17371 __attribute__((unused)) struct cmdline *cl,
17372 __attribute__((unused)) void *data)
17374 struct cmd_pctype_mapping_update_result *res = parsed_result;
17375 int ret = -ENOTSUP;
17376 #ifdef RTE_LIBRTE_I40E_PMD
17377 struct rte_pmd_i40e_flow_type_mapping mapping;
17379 unsigned int nb_item;
17380 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17383 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17386 #ifdef RTE_LIBRTE_I40E_PMD
17387 nb_item = parse_item_list(res->pctype_list, "pctypes",
17388 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17389 mapping.flow_type = res->flow_type;
17390 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17391 mapping.pctype |= (1ULL << pctype_list[i]);
17392 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17402 printf("invalid pctype or flow type\n");
17405 printf("invalid port_id %d\n", res->port_id);
17408 printf("function not implemented\n");
17411 printf("programming error: (%s)\n", strerror(-ret));
17415 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17416 .f = cmd_pctype_mapping_update_parsed,
17418 .help_str = "port config <port_id> pctype mapping update"
17419 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17421 (void *)&cmd_pctype_mapping_update_port,
17422 (void *)&cmd_pctype_mapping_update_config,
17423 (void *)&cmd_pctype_mapping_update_port_id,
17424 (void *)&cmd_pctype_mapping_update_pctype,
17425 (void *)&cmd_pctype_mapping_update_mapping,
17426 (void *)&cmd_pctype_mapping_update_update,
17427 (void *)&cmd_pctype_mapping_update_pc_type,
17428 (void *)&cmd_pctype_mapping_update_flow_type,
17433 /* ptype mapping get */
17435 /* Common result structure for ptype mapping get */
17436 struct cmd_ptype_mapping_get_result {
17437 cmdline_fixed_string_t ptype;
17438 cmdline_fixed_string_t mapping;
17439 cmdline_fixed_string_t get;
17441 uint8_t valid_only;
17444 /* Common CLI fields for ptype mapping get */
17445 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17446 TOKEN_STRING_INITIALIZER
17447 (struct cmd_ptype_mapping_get_result,
17449 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17450 TOKEN_STRING_INITIALIZER
17451 (struct cmd_ptype_mapping_get_result,
17452 mapping, "mapping");
17453 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17454 TOKEN_STRING_INITIALIZER
17455 (struct cmd_ptype_mapping_get_result,
17457 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17458 TOKEN_NUM_INITIALIZER
17459 (struct cmd_ptype_mapping_get_result,
17461 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17462 TOKEN_NUM_INITIALIZER
17463 (struct cmd_ptype_mapping_get_result,
17464 valid_only, UINT8);
17467 cmd_ptype_mapping_get_parsed(
17468 void *parsed_result,
17469 __attribute__((unused)) struct cmdline *cl,
17470 __attribute__((unused)) void *data)
17472 struct cmd_ptype_mapping_get_result *res = parsed_result;
17473 int ret = -ENOTSUP;
17474 #ifdef RTE_LIBRTE_I40E_PMD
17475 int max_ptype_num = 256;
17476 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17481 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17484 #ifdef RTE_LIBRTE_I40E_PMD
17485 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17496 printf("invalid port_id %d\n", res->port_id);
17499 printf("function not implemented\n");
17502 printf("programming error: (%s)\n", strerror(-ret));
17505 #ifdef RTE_LIBRTE_I40E_PMD
17507 for (i = 0; i < count; i++)
17508 printf("%3d\t0x%08x\n",
17509 mapping[i].hw_ptype, mapping[i].sw_ptype);
17514 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17515 .f = cmd_ptype_mapping_get_parsed,
17517 .help_str = "ptype mapping get <port_id> <valid_only>",
17519 (void *)&cmd_ptype_mapping_get_ptype,
17520 (void *)&cmd_ptype_mapping_get_mapping,
17521 (void *)&cmd_ptype_mapping_get_get,
17522 (void *)&cmd_ptype_mapping_get_port_id,
17523 (void *)&cmd_ptype_mapping_get_valid_only,
17528 /* ptype mapping replace */
17530 /* Common result structure for ptype mapping replace */
17531 struct cmd_ptype_mapping_replace_result {
17532 cmdline_fixed_string_t ptype;
17533 cmdline_fixed_string_t mapping;
17534 cmdline_fixed_string_t replace;
17541 /* Common CLI fields for ptype mapping replace */
17542 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17543 TOKEN_STRING_INITIALIZER
17544 (struct cmd_ptype_mapping_replace_result,
17546 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17547 TOKEN_STRING_INITIALIZER
17548 (struct cmd_ptype_mapping_replace_result,
17549 mapping, "mapping");
17550 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17551 TOKEN_STRING_INITIALIZER
17552 (struct cmd_ptype_mapping_replace_result,
17553 replace, "replace");
17554 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17555 TOKEN_NUM_INITIALIZER
17556 (struct cmd_ptype_mapping_replace_result,
17558 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17559 TOKEN_NUM_INITIALIZER
17560 (struct cmd_ptype_mapping_replace_result,
17562 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17563 TOKEN_NUM_INITIALIZER
17564 (struct cmd_ptype_mapping_replace_result,
17566 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17567 TOKEN_NUM_INITIALIZER
17568 (struct cmd_ptype_mapping_replace_result,
17572 cmd_ptype_mapping_replace_parsed(
17573 void *parsed_result,
17574 __attribute__((unused)) struct cmdline *cl,
17575 __attribute__((unused)) void *data)
17577 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17578 int ret = -ENOTSUP;
17580 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17583 #ifdef RTE_LIBRTE_I40E_PMD
17584 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17594 printf("invalid ptype 0x%8x or 0x%8x\n",
17595 res->target, res->pkt_type);
17598 printf("invalid port_id %d\n", res->port_id);
17601 printf("function not implemented\n");
17604 printf("programming error: (%s)\n", strerror(-ret));
17608 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17609 .f = cmd_ptype_mapping_replace_parsed,
17612 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17614 (void *)&cmd_ptype_mapping_replace_ptype,
17615 (void *)&cmd_ptype_mapping_replace_mapping,
17616 (void *)&cmd_ptype_mapping_replace_replace,
17617 (void *)&cmd_ptype_mapping_replace_port_id,
17618 (void *)&cmd_ptype_mapping_replace_target,
17619 (void *)&cmd_ptype_mapping_replace_mask,
17620 (void *)&cmd_ptype_mapping_replace_pkt_type,
17625 /* ptype mapping reset */
17627 /* Common result structure for ptype mapping reset */
17628 struct cmd_ptype_mapping_reset_result {
17629 cmdline_fixed_string_t ptype;
17630 cmdline_fixed_string_t mapping;
17631 cmdline_fixed_string_t reset;
17635 /* Common CLI fields for ptype mapping reset*/
17636 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17637 TOKEN_STRING_INITIALIZER
17638 (struct cmd_ptype_mapping_reset_result,
17640 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17641 TOKEN_STRING_INITIALIZER
17642 (struct cmd_ptype_mapping_reset_result,
17643 mapping, "mapping");
17644 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17645 TOKEN_STRING_INITIALIZER
17646 (struct cmd_ptype_mapping_reset_result,
17648 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17649 TOKEN_NUM_INITIALIZER
17650 (struct cmd_ptype_mapping_reset_result,
17654 cmd_ptype_mapping_reset_parsed(
17655 void *parsed_result,
17656 __attribute__((unused)) struct cmdline *cl,
17657 __attribute__((unused)) void *data)
17659 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17660 int ret = -ENOTSUP;
17662 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17665 #ifdef RTE_LIBRTE_I40E_PMD
17666 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17673 printf("invalid port_id %d\n", res->port_id);
17676 printf("function not implemented\n");
17679 printf("programming error: (%s)\n", strerror(-ret));
17683 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17684 .f = cmd_ptype_mapping_reset_parsed,
17686 .help_str = "ptype mapping reset <port_id>",
17688 (void *)&cmd_ptype_mapping_reset_ptype,
17689 (void *)&cmd_ptype_mapping_reset_mapping,
17690 (void *)&cmd_ptype_mapping_reset_reset,
17691 (void *)&cmd_ptype_mapping_reset_port_id,
17696 /* ptype mapping update */
17698 /* Common result structure for ptype mapping update */
17699 struct cmd_ptype_mapping_update_result {
17700 cmdline_fixed_string_t ptype;
17701 cmdline_fixed_string_t mapping;
17702 cmdline_fixed_string_t reset;
17708 /* Common CLI fields for ptype mapping update*/
17709 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17710 TOKEN_STRING_INITIALIZER
17711 (struct cmd_ptype_mapping_update_result,
17713 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17714 TOKEN_STRING_INITIALIZER
17715 (struct cmd_ptype_mapping_update_result,
17716 mapping, "mapping");
17717 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17718 TOKEN_STRING_INITIALIZER
17719 (struct cmd_ptype_mapping_update_result,
17721 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17722 TOKEN_NUM_INITIALIZER
17723 (struct cmd_ptype_mapping_update_result,
17725 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17726 TOKEN_NUM_INITIALIZER
17727 (struct cmd_ptype_mapping_update_result,
17729 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17730 TOKEN_NUM_INITIALIZER
17731 (struct cmd_ptype_mapping_update_result,
17735 cmd_ptype_mapping_update_parsed(
17736 void *parsed_result,
17737 __attribute__((unused)) struct cmdline *cl,
17738 __attribute__((unused)) void *data)
17740 struct cmd_ptype_mapping_update_result *res = parsed_result;
17741 int ret = -ENOTSUP;
17742 #ifdef RTE_LIBRTE_I40E_PMD
17743 struct rte_pmd_i40e_ptype_mapping mapping;
17745 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17748 #ifdef RTE_LIBRTE_I40E_PMD
17749 mapping.hw_ptype = res->hw_ptype;
17750 mapping.sw_ptype = res->sw_ptype;
17751 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17761 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17764 printf("invalid port_id %d\n", res->port_id);
17767 printf("function not implemented\n");
17770 printf("programming error: (%s)\n", strerror(-ret));
17774 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17775 .f = cmd_ptype_mapping_update_parsed,
17777 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17779 (void *)&cmd_ptype_mapping_update_ptype,
17780 (void *)&cmd_ptype_mapping_update_mapping,
17781 (void *)&cmd_ptype_mapping_update_update,
17782 (void *)&cmd_ptype_mapping_update_port_id,
17783 (void *)&cmd_ptype_mapping_update_hw_ptype,
17784 (void *)&cmd_ptype_mapping_update_sw_ptype,
17789 /* Common result structure for file commands */
17790 struct cmd_cmdfile_result {
17791 cmdline_fixed_string_t load;
17792 cmdline_fixed_string_t filename;
17795 /* Common CLI fields for file commands */
17796 cmdline_parse_token_string_t cmd_load_cmdfile =
17797 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17798 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17799 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17802 cmd_load_from_file_parsed(
17803 void *parsed_result,
17804 __attribute__((unused)) struct cmdline *cl,
17805 __attribute__((unused)) void *data)
17807 struct cmd_cmdfile_result *res = parsed_result;
17809 cmdline_read_from_file(res->filename);
17812 cmdline_parse_inst_t cmd_load_from_file = {
17813 .f = cmd_load_from_file_parsed,
17815 .help_str = "load <filename>",
17817 (void *)&cmd_load_cmdfile,
17818 (void *)&cmd_load_cmdfile_filename,
17823 /* Get Rx offloads capabilities */
17824 struct cmd_rx_offload_get_capa_result {
17825 cmdline_fixed_string_t show;
17826 cmdline_fixed_string_t port;
17828 cmdline_fixed_string_t rx_offload;
17829 cmdline_fixed_string_t capabilities;
17832 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17833 TOKEN_STRING_INITIALIZER
17834 (struct cmd_rx_offload_get_capa_result,
17836 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17837 TOKEN_STRING_INITIALIZER
17838 (struct cmd_rx_offload_get_capa_result,
17840 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17841 TOKEN_NUM_INITIALIZER
17842 (struct cmd_rx_offload_get_capa_result,
17844 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17845 TOKEN_STRING_INITIALIZER
17846 (struct cmd_rx_offload_get_capa_result,
17847 rx_offload, "rx_offload");
17848 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17849 TOKEN_STRING_INITIALIZER
17850 (struct cmd_rx_offload_get_capa_result,
17851 capabilities, "capabilities");
17854 print_rx_offloads(uint64_t offloads)
17856 uint64_t single_offload;
17864 begin = __builtin_ctzll(offloads);
17865 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17867 single_offload = 1ULL << begin;
17868 for (bit = begin; bit < end; bit++) {
17869 if (offloads & single_offload)
17871 rte_eth_dev_rx_offload_name(single_offload));
17872 single_offload <<= 1;
17877 cmd_rx_offload_get_capa_parsed(
17878 void *parsed_result,
17879 __attribute__((unused)) struct cmdline *cl,
17880 __attribute__((unused)) void *data)
17882 struct cmd_rx_offload_get_capa_result *res = parsed_result;
17883 struct rte_eth_dev_info dev_info;
17884 portid_t port_id = res->port_id;
17885 uint64_t queue_offloads;
17886 uint64_t port_offloads;
17888 rte_eth_dev_info_get(port_id, &dev_info);
17889 queue_offloads = dev_info.rx_queue_offload_capa;
17890 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
17892 printf("Rx Offloading Capabilities of port %d :\n", port_id);
17893 printf(" Per Queue :");
17894 print_rx_offloads(queue_offloads);
17897 printf(" Per Port :");
17898 print_rx_offloads(port_offloads);
17902 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
17903 .f = cmd_rx_offload_get_capa_parsed,
17905 .help_str = "show port <port_id> rx_offload capabilities",
17907 (void *)&cmd_rx_offload_get_capa_show,
17908 (void *)&cmd_rx_offload_get_capa_port,
17909 (void *)&cmd_rx_offload_get_capa_port_id,
17910 (void *)&cmd_rx_offload_get_capa_rx_offload,
17911 (void *)&cmd_rx_offload_get_capa_capabilities,
17916 /* Get Rx offloads configuration */
17917 struct cmd_rx_offload_get_configuration_result {
17918 cmdline_fixed_string_t show;
17919 cmdline_fixed_string_t port;
17921 cmdline_fixed_string_t rx_offload;
17922 cmdline_fixed_string_t configuration;
17925 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
17926 TOKEN_STRING_INITIALIZER
17927 (struct cmd_rx_offload_get_configuration_result,
17929 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
17930 TOKEN_STRING_INITIALIZER
17931 (struct cmd_rx_offload_get_configuration_result,
17933 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
17934 TOKEN_NUM_INITIALIZER
17935 (struct cmd_rx_offload_get_configuration_result,
17937 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
17938 TOKEN_STRING_INITIALIZER
17939 (struct cmd_rx_offload_get_configuration_result,
17940 rx_offload, "rx_offload");
17941 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
17942 TOKEN_STRING_INITIALIZER
17943 (struct cmd_rx_offload_get_configuration_result,
17944 configuration, "configuration");
17947 cmd_rx_offload_get_configuration_parsed(
17948 void *parsed_result,
17949 __attribute__((unused)) struct cmdline *cl,
17950 __attribute__((unused)) void *data)
17952 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
17953 struct rte_eth_dev_info dev_info;
17954 portid_t port_id = res->port_id;
17955 struct rte_port *port = &ports[port_id];
17956 uint64_t port_offloads;
17957 uint64_t queue_offloads;
17958 uint16_t nb_rx_queues;
17961 printf("Rx Offloading Configuration of port %d :\n", port_id);
17963 port_offloads = port->dev_conf.rxmode.offloads;
17965 print_rx_offloads(port_offloads);
17968 rte_eth_dev_info_get(port_id, &dev_info);
17969 nb_rx_queues = dev_info.nb_rx_queues;
17970 for (q = 0; q < nb_rx_queues; q++) {
17971 queue_offloads = port->rx_conf[q].offloads;
17972 printf(" Queue[%2d] :", q);
17973 print_rx_offloads(queue_offloads);
17979 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
17980 .f = cmd_rx_offload_get_configuration_parsed,
17982 .help_str = "show port <port_id> rx_offload configuration",
17984 (void *)&cmd_rx_offload_get_configuration_show,
17985 (void *)&cmd_rx_offload_get_configuration_port,
17986 (void *)&cmd_rx_offload_get_configuration_port_id,
17987 (void *)&cmd_rx_offload_get_configuration_rx_offload,
17988 (void *)&cmd_rx_offload_get_configuration_configuration,
17993 /* Enable/Disable a per port offloading */
17994 struct cmd_config_per_port_rx_offload_result {
17995 cmdline_fixed_string_t port;
17996 cmdline_fixed_string_t config;
17998 cmdline_fixed_string_t rx_offload;
17999 cmdline_fixed_string_t offload;
18000 cmdline_fixed_string_t on_off;
18003 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18004 TOKEN_STRING_INITIALIZER
18005 (struct cmd_config_per_port_rx_offload_result,
18007 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18008 TOKEN_STRING_INITIALIZER
18009 (struct cmd_config_per_port_rx_offload_result,
18011 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18012 TOKEN_NUM_INITIALIZER
18013 (struct cmd_config_per_port_rx_offload_result,
18015 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18016 TOKEN_STRING_INITIALIZER
18017 (struct cmd_config_per_port_rx_offload_result,
18018 rx_offload, "rx_offload");
18019 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18020 TOKEN_STRING_INITIALIZER
18021 (struct cmd_config_per_port_rx_offload_result,
18022 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18023 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18024 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18025 "crc_strip#scatter#timestamp#security#keep_crc");
18026 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18027 TOKEN_STRING_INITIALIZER
18028 (struct cmd_config_per_port_rx_offload_result,
18032 search_rx_offload(const char *name)
18034 uint64_t single_offload;
18035 const char *single_name;
18039 single_offload = 1;
18040 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18041 single_name = rte_eth_dev_rx_offload_name(single_offload);
18042 if (!strcasecmp(single_name, name)) {
18046 single_offload <<= 1;
18050 return single_offload;
18056 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18057 __attribute__((unused)) struct cmdline *cl,
18058 __attribute__((unused)) void *data)
18060 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18061 portid_t port_id = res->port_id;
18062 struct rte_eth_dev_info dev_info;
18063 struct rte_port *port = &ports[port_id];
18064 uint64_t single_offload;
18065 uint16_t nb_rx_queues;
18068 if (port->port_status != RTE_PORT_STOPPED) {
18069 printf("Error: Can't config offload when Port %d "
18070 "is not stopped\n", port_id);
18074 single_offload = search_rx_offload(res->offload);
18075 if (single_offload == 0) {
18076 printf("Unknown offload name: %s\n", res->offload);
18080 rte_eth_dev_info_get(port_id, &dev_info);
18081 nb_rx_queues = dev_info.nb_rx_queues;
18082 if (!strcmp(res->on_off, "on")) {
18083 port->dev_conf.rxmode.offloads |= single_offload;
18084 for (q = 0; q < nb_rx_queues; q++)
18085 port->rx_conf[q].offloads |= single_offload;
18087 port->dev_conf.rxmode.offloads &= ~single_offload;
18088 for (q = 0; q < nb_rx_queues; q++)
18089 port->rx_conf[q].offloads &= ~single_offload;
18092 cmd_reconfig_device_queue(port_id, 1, 1);
18095 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18096 .f = cmd_config_per_port_rx_offload_parsed,
18098 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18099 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18100 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18101 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
18104 (void *)&cmd_config_per_port_rx_offload_result_port,
18105 (void *)&cmd_config_per_port_rx_offload_result_config,
18106 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18107 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18108 (void *)&cmd_config_per_port_rx_offload_result_offload,
18109 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18114 /* Enable/Disable a per queue offloading */
18115 struct cmd_config_per_queue_rx_offload_result {
18116 cmdline_fixed_string_t port;
18118 cmdline_fixed_string_t rxq;
18120 cmdline_fixed_string_t rx_offload;
18121 cmdline_fixed_string_t offload;
18122 cmdline_fixed_string_t on_off;
18125 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18126 TOKEN_STRING_INITIALIZER
18127 (struct cmd_config_per_queue_rx_offload_result,
18129 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18130 TOKEN_NUM_INITIALIZER
18131 (struct cmd_config_per_queue_rx_offload_result,
18133 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18134 TOKEN_STRING_INITIALIZER
18135 (struct cmd_config_per_queue_rx_offload_result,
18137 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18138 TOKEN_NUM_INITIALIZER
18139 (struct cmd_config_per_queue_rx_offload_result,
18141 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18142 TOKEN_STRING_INITIALIZER
18143 (struct cmd_config_per_queue_rx_offload_result,
18144 rx_offload, "rx_offload");
18145 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18146 TOKEN_STRING_INITIALIZER
18147 (struct cmd_config_per_queue_rx_offload_result,
18148 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18149 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18150 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18151 "crc_strip#scatter#timestamp#security#keep_crc");
18152 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18153 TOKEN_STRING_INITIALIZER
18154 (struct cmd_config_per_queue_rx_offload_result,
18158 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18159 __attribute__((unused)) struct cmdline *cl,
18160 __attribute__((unused)) void *data)
18162 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18163 struct rte_eth_dev_info dev_info;
18164 portid_t port_id = res->port_id;
18165 uint16_t queue_id = res->queue_id;
18166 struct rte_port *port = &ports[port_id];
18167 uint64_t single_offload;
18169 if (port->port_status != RTE_PORT_STOPPED) {
18170 printf("Error: Can't config offload when Port %d "
18171 "is not stopped\n", port_id);
18175 rte_eth_dev_info_get(port_id, &dev_info);
18176 if (queue_id >= dev_info.nb_rx_queues) {
18177 printf("Error: input queue_id should be 0 ... "
18178 "%d\n", dev_info.nb_rx_queues - 1);
18182 single_offload = search_rx_offload(res->offload);
18183 if (single_offload == 0) {
18184 printf("Unknown offload name: %s\n", res->offload);
18188 if (!strcmp(res->on_off, "on"))
18189 port->rx_conf[queue_id].offloads |= single_offload;
18191 port->rx_conf[queue_id].offloads &= ~single_offload;
18193 cmd_reconfig_device_queue(port_id, 1, 1);
18196 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18197 .f = cmd_config_per_queue_rx_offload_parsed,
18199 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18200 "vlan_strip|ipv4_cksum|"
18201 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18202 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18203 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
18206 (void *)&cmd_config_per_queue_rx_offload_result_port,
18207 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18208 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18209 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18210 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18211 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18212 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18217 /* Get Tx offloads capabilities */
18218 struct cmd_tx_offload_get_capa_result {
18219 cmdline_fixed_string_t show;
18220 cmdline_fixed_string_t port;
18222 cmdline_fixed_string_t tx_offload;
18223 cmdline_fixed_string_t capabilities;
18226 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18227 TOKEN_STRING_INITIALIZER
18228 (struct cmd_tx_offload_get_capa_result,
18230 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18231 TOKEN_STRING_INITIALIZER
18232 (struct cmd_tx_offload_get_capa_result,
18234 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18235 TOKEN_NUM_INITIALIZER
18236 (struct cmd_tx_offload_get_capa_result,
18238 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18239 TOKEN_STRING_INITIALIZER
18240 (struct cmd_tx_offload_get_capa_result,
18241 tx_offload, "tx_offload");
18242 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18243 TOKEN_STRING_INITIALIZER
18244 (struct cmd_tx_offload_get_capa_result,
18245 capabilities, "capabilities");
18248 print_tx_offloads(uint64_t offloads)
18250 uint64_t single_offload;
18258 begin = __builtin_ctzll(offloads);
18259 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18261 single_offload = 1ULL << begin;
18262 for (bit = begin; bit < end; bit++) {
18263 if (offloads & single_offload)
18265 rte_eth_dev_tx_offload_name(single_offload));
18266 single_offload <<= 1;
18271 cmd_tx_offload_get_capa_parsed(
18272 void *parsed_result,
18273 __attribute__((unused)) struct cmdline *cl,
18274 __attribute__((unused)) void *data)
18276 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18277 struct rte_eth_dev_info dev_info;
18278 portid_t port_id = res->port_id;
18279 uint64_t queue_offloads;
18280 uint64_t port_offloads;
18282 rte_eth_dev_info_get(port_id, &dev_info);
18283 queue_offloads = dev_info.tx_queue_offload_capa;
18284 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18286 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18287 printf(" Per Queue :");
18288 print_tx_offloads(queue_offloads);
18291 printf(" Per Port :");
18292 print_tx_offloads(port_offloads);
18296 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18297 .f = cmd_tx_offload_get_capa_parsed,
18299 .help_str = "show port <port_id> tx_offload capabilities",
18301 (void *)&cmd_tx_offload_get_capa_show,
18302 (void *)&cmd_tx_offload_get_capa_port,
18303 (void *)&cmd_tx_offload_get_capa_port_id,
18304 (void *)&cmd_tx_offload_get_capa_tx_offload,
18305 (void *)&cmd_tx_offload_get_capa_capabilities,
18310 /* Get Tx offloads configuration */
18311 struct cmd_tx_offload_get_configuration_result {
18312 cmdline_fixed_string_t show;
18313 cmdline_fixed_string_t port;
18315 cmdline_fixed_string_t tx_offload;
18316 cmdline_fixed_string_t configuration;
18319 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18320 TOKEN_STRING_INITIALIZER
18321 (struct cmd_tx_offload_get_configuration_result,
18323 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18324 TOKEN_STRING_INITIALIZER
18325 (struct cmd_tx_offload_get_configuration_result,
18327 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18328 TOKEN_NUM_INITIALIZER
18329 (struct cmd_tx_offload_get_configuration_result,
18331 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18332 TOKEN_STRING_INITIALIZER
18333 (struct cmd_tx_offload_get_configuration_result,
18334 tx_offload, "tx_offload");
18335 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18336 TOKEN_STRING_INITIALIZER
18337 (struct cmd_tx_offload_get_configuration_result,
18338 configuration, "configuration");
18341 cmd_tx_offload_get_configuration_parsed(
18342 void *parsed_result,
18343 __attribute__((unused)) struct cmdline *cl,
18344 __attribute__((unused)) void *data)
18346 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18347 struct rte_eth_dev_info dev_info;
18348 portid_t port_id = res->port_id;
18349 struct rte_port *port = &ports[port_id];
18350 uint64_t port_offloads;
18351 uint64_t queue_offloads;
18352 uint16_t nb_tx_queues;
18355 printf("Tx Offloading Configuration of port %d :\n", port_id);
18357 port_offloads = port->dev_conf.txmode.offloads;
18359 print_tx_offloads(port_offloads);
18362 rte_eth_dev_info_get(port_id, &dev_info);
18363 nb_tx_queues = dev_info.nb_tx_queues;
18364 for (q = 0; q < nb_tx_queues; q++) {
18365 queue_offloads = port->tx_conf[q].offloads;
18366 printf(" Queue[%2d] :", q);
18367 print_tx_offloads(queue_offloads);
18373 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18374 .f = cmd_tx_offload_get_configuration_parsed,
18376 .help_str = "show port <port_id> tx_offload configuration",
18378 (void *)&cmd_tx_offload_get_configuration_show,
18379 (void *)&cmd_tx_offload_get_configuration_port,
18380 (void *)&cmd_tx_offload_get_configuration_port_id,
18381 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18382 (void *)&cmd_tx_offload_get_configuration_configuration,
18387 /* Enable/Disable a per port offloading */
18388 struct cmd_config_per_port_tx_offload_result {
18389 cmdline_fixed_string_t port;
18390 cmdline_fixed_string_t config;
18392 cmdline_fixed_string_t tx_offload;
18393 cmdline_fixed_string_t offload;
18394 cmdline_fixed_string_t on_off;
18397 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18398 TOKEN_STRING_INITIALIZER
18399 (struct cmd_config_per_port_tx_offload_result,
18401 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18402 TOKEN_STRING_INITIALIZER
18403 (struct cmd_config_per_port_tx_offload_result,
18405 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18406 TOKEN_NUM_INITIALIZER
18407 (struct cmd_config_per_port_tx_offload_result,
18409 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18410 TOKEN_STRING_INITIALIZER
18411 (struct cmd_config_per_port_tx_offload_result,
18412 tx_offload, "tx_offload");
18413 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18414 TOKEN_STRING_INITIALIZER
18415 (struct cmd_config_per_port_tx_offload_result,
18416 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18417 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18418 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18419 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18420 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18422 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18423 TOKEN_STRING_INITIALIZER
18424 (struct cmd_config_per_port_tx_offload_result,
18428 search_tx_offload(const char *name)
18430 uint64_t single_offload;
18431 const char *single_name;
18435 single_offload = 1;
18436 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18437 single_name = rte_eth_dev_tx_offload_name(single_offload);
18438 if (single_name == NULL)
18440 if (!strcasecmp(single_name, name)) {
18443 } else if (!strcasecmp(single_name, "UNKNOWN"))
18445 single_offload <<= 1;
18449 return single_offload;
18455 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18456 __attribute__((unused)) struct cmdline *cl,
18457 __attribute__((unused)) void *data)
18459 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18460 portid_t port_id = res->port_id;
18461 struct rte_eth_dev_info dev_info;
18462 struct rte_port *port = &ports[port_id];
18463 uint64_t single_offload;
18464 uint16_t nb_tx_queues;
18467 if (port->port_status != RTE_PORT_STOPPED) {
18468 printf("Error: Can't config offload when Port %d "
18469 "is not stopped\n", port_id);
18473 single_offload = search_tx_offload(res->offload);
18474 if (single_offload == 0) {
18475 printf("Unknown offload name: %s\n", res->offload);
18479 rte_eth_dev_info_get(port_id, &dev_info);
18480 nb_tx_queues = dev_info.nb_tx_queues;
18481 if (!strcmp(res->on_off, "on")) {
18482 port->dev_conf.txmode.offloads |= single_offload;
18483 for (q = 0; q < nb_tx_queues; q++)
18484 port->tx_conf[q].offloads |= single_offload;
18486 port->dev_conf.txmode.offloads &= ~single_offload;
18487 for (q = 0; q < nb_tx_queues; q++)
18488 port->tx_conf[q].offloads &= ~single_offload;
18491 cmd_reconfig_device_queue(port_id, 1, 1);
18494 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18495 .f = cmd_config_per_port_tx_offload_parsed,
18497 .help_str = "port config <port_id> tx_offload "
18498 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18499 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18500 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18501 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18502 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18503 "match_metadata on|off",
18505 (void *)&cmd_config_per_port_tx_offload_result_port,
18506 (void *)&cmd_config_per_port_tx_offload_result_config,
18507 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18508 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18509 (void *)&cmd_config_per_port_tx_offload_result_offload,
18510 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18515 /* Enable/Disable a per queue offloading */
18516 struct cmd_config_per_queue_tx_offload_result {
18517 cmdline_fixed_string_t port;
18519 cmdline_fixed_string_t txq;
18521 cmdline_fixed_string_t tx_offload;
18522 cmdline_fixed_string_t offload;
18523 cmdline_fixed_string_t on_off;
18526 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18527 TOKEN_STRING_INITIALIZER
18528 (struct cmd_config_per_queue_tx_offload_result,
18530 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18531 TOKEN_NUM_INITIALIZER
18532 (struct cmd_config_per_queue_tx_offload_result,
18534 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18535 TOKEN_STRING_INITIALIZER
18536 (struct cmd_config_per_queue_tx_offload_result,
18538 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18539 TOKEN_NUM_INITIALIZER
18540 (struct cmd_config_per_queue_tx_offload_result,
18542 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18543 TOKEN_STRING_INITIALIZER
18544 (struct cmd_config_per_queue_tx_offload_result,
18545 tx_offload, "tx_offload");
18546 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18547 TOKEN_STRING_INITIALIZER
18548 (struct cmd_config_per_queue_tx_offload_result,
18549 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18550 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18551 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18552 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18553 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18554 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18555 TOKEN_STRING_INITIALIZER
18556 (struct cmd_config_per_queue_tx_offload_result,
18560 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18561 __attribute__((unused)) struct cmdline *cl,
18562 __attribute__((unused)) void *data)
18564 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18565 struct rte_eth_dev_info dev_info;
18566 portid_t port_id = res->port_id;
18567 uint16_t queue_id = res->queue_id;
18568 struct rte_port *port = &ports[port_id];
18569 uint64_t single_offload;
18571 if (port->port_status != RTE_PORT_STOPPED) {
18572 printf("Error: Can't config offload when Port %d "
18573 "is not stopped\n", port_id);
18577 rte_eth_dev_info_get(port_id, &dev_info);
18578 if (queue_id >= dev_info.nb_tx_queues) {
18579 printf("Error: input queue_id should be 0 ... "
18580 "%d\n", dev_info.nb_tx_queues - 1);
18584 single_offload = search_tx_offload(res->offload);
18585 if (single_offload == 0) {
18586 printf("Unknown offload name: %s\n", res->offload);
18590 if (!strcmp(res->on_off, "on"))
18591 port->tx_conf[queue_id].offloads |= single_offload;
18593 port->tx_conf[queue_id].offloads &= ~single_offload;
18595 cmd_reconfig_device_queue(port_id, 1, 1);
18598 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18599 .f = cmd_config_per_queue_tx_offload_parsed,
18601 .help_str = "port <port_id> txq <queue_id> tx_offload "
18602 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18603 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18604 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18605 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18606 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18609 (void *)&cmd_config_per_queue_tx_offload_result_port,
18610 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18611 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18612 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18613 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18614 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18615 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18620 /* *** configure tx_metadata for specific port *** */
18621 struct cmd_config_tx_metadata_specific_result {
18622 cmdline_fixed_string_t port;
18623 cmdline_fixed_string_t keyword;
18625 cmdline_fixed_string_t item;
18630 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18631 __attribute__((unused)) struct cmdline *cl,
18632 __attribute__((unused)) void *data)
18634 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18636 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18638 ports[res->port_id].tx_metadata = rte_cpu_to_be_32(res->value);
18639 /* Add/remove callback to insert valid metadata in every Tx packet. */
18640 if (ports[res->port_id].tx_metadata)
18641 add_tx_md_callback(res->port_id);
18643 remove_tx_md_callback(res->port_id);
18646 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18647 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18649 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18650 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18651 keyword, "config");
18652 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18653 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18655 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18656 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18657 item, "tx_metadata");
18658 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18659 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18662 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18663 .f = cmd_config_tx_metadata_specific_parsed,
18665 .help_str = "port config <port_id> tx_metadata <value>",
18667 (void *)&cmd_config_tx_metadata_specific_port,
18668 (void *)&cmd_config_tx_metadata_specific_keyword,
18669 (void *)&cmd_config_tx_metadata_specific_id,
18670 (void *)&cmd_config_tx_metadata_specific_item,
18671 (void *)&cmd_config_tx_metadata_specific_value,
18676 /* *** display tx_metadata per port configuration *** */
18677 struct cmd_show_tx_metadata_result {
18678 cmdline_fixed_string_t cmd_show;
18679 cmdline_fixed_string_t cmd_port;
18680 cmdline_fixed_string_t cmd_keyword;
18685 cmd_show_tx_metadata_parsed(void *parsed_result,
18686 __attribute__((unused)) struct cmdline *cl,
18687 __attribute__((unused)) void *data)
18689 struct cmd_show_tx_metadata_result *res = parsed_result;
18691 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18692 printf("invalid port id %u\n", res->cmd_pid);
18695 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18696 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18697 rte_be_to_cpu_32(ports[res->cmd_pid].tx_metadata));
18701 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18702 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18704 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18705 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18707 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18708 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18710 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18711 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18712 cmd_keyword, "tx_metadata");
18714 cmdline_parse_inst_t cmd_show_tx_metadata = {
18715 .f = cmd_show_tx_metadata_parsed,
18717 .help_str = "show port <port_id> tx_metadata",
18719 (void *)&cmd_show_tx_metadata_show,
18720 (void *)&cmd_show_tx_metadata_port,
18721 (void *)&cmd_show_tx_metadata_pid,
18722 (void *)&cmd_show_tx_metadata_keyword,
18727 /* ******************************************************************************** */
18729 /* list of instructions */
18730 cmdline_parse_ctx_t main_ctx[] = {
18731 (cmdline_parse_inst_t *)&cmd_help_brief,
18732 (cmdline_parse_inst_t *)&cmd_help_long,
18733 (cmdline_parse_inst_t *)&cmd_quit,
18734 (cmdline_parse_inst_t *)&cmd_load_from_file,
18735 (cmdline_parse_inst_t *)&cmd_showport,
18736 (cmdline_parse_inst_t *)&cmd_showqueue,
18737 (cmdline_parse_inst_t *)&cmd_showportall,
18738 (cmdline_parse_inst_t *)&cmd_showdevice,
18739 (cmdline_parse_inst_t *)&cmd_showcfg,
18740 (cmdline_parse_inst_t *)&cmd_showfwdall,
18741 (cmdline_parse_inst_t *)&cmd_start,
18742 (cmdline_parse_inst_t *)&cmd_start_tx_first,
18743 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
18744 (cmdline_parse_inst_t *)&cmd_set_link_up,
18745 (cmdline_parse_inst_t *)&cmd_set_link_down,
18746 (cmdline_parse_inst_t *)&cmd_reset,
18747 (cmdline_parse_inst_t *)&cmd_set_numbers,
18748 (cmdline_parse_inst_t *)&cmd_set_log,
18749 (cmdline_parse_inst_t *)&cmd_set_txpkts,
18750 (cmdline_parse_inst_t *)&cmd_set_txsplit,
18751 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
18752 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
18753 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
18754 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
18755 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
18756 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
18757 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
18758 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
18759 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
18760 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
18761 (cmdline_parse_inst_t *)&cmd_set_link_check,
18762 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
18763 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
18764 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
18765 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
18766 #ifdef RTE_LIBRTE_PMD_BOND
18767 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
18768 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
18769 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
18770 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
18771 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
18772 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
18773 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
18774 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
18775 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
18776 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
18777 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
18779 (cmdline_parse_inst_t *)&cmd_vlan_offload,
18780 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
18781 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
18782 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
18783 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
18784 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
18785 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
18786 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
18787 (cmdline_parse_inst_t *)&cmd_csum_set,
18788 (cmdline_parse_inst_t *)&cmd_csum_show,
18789 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
18790 (cmdline_parse_inst_t *)&cmd_tso_set,
18791 (cmdline_parse_inst_t *)&cmd_tso_show,
18792 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
18793 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
18794 (cmdline_parse_inst_t *)&cmd_gro_enable,
18795 (cmdline_parse_inst_t *)&cmd_gro_flush,
18796 (cmdline_parse_inst_t *)&cmd_gro_show,
18797 (cmdline_parse_inst_t *)&cmd_gso_enable,
18798 (cmdline_parse_inst_t *)&cmd_gso_size,
18799 (cmdline_parse_inst_t *)&cmd_gso_show,
18800 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
18801 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
18802 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
18803 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
18804 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
18805 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
18806 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
18807 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
18808 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
18809 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
18810 (cmdline_parse_inst_t *)&cmd_config_dcb,
18811 (cmdline_parse_inst_t *)&cmd_read_reg,
18812 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
18813 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
18814 (cmdline_parse_inst_t *)&cmd_write_reg,
18815 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
18816 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
18817 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
18818 (cmdline_parse_inst_t *)&cmd_stop,
18819 (cmdline_parse_inst_t *)&cmd_mac_addr,
18820 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
18821 (cmdline_parse_inst_t *)&cmd_set_qmap,
18822 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
18823 (cmdline_parse_inst_t *)&cmd_operate_port,
18824 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
18825 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
18826 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
18827 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
18828 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
18829 (cmdline_parse_inst_t *)&cmd_config_speed_all,
18830 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
18831 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
18832 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
18833 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
18834 (cmdline_parse_inst_t *)&cmd_config_mtu,
18835 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
18836 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
18837 (cmdline_parse_inst_t *)&cmd_config_rss,
18838 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
18839 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
18840 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
18841 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
18842 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
18843 (cmdline_parse_inst_t *)&cmd_showport_reta,
18844 (cmdline_parse_inst_t *)&cmd_config_burst,
18845 (cmdline_parse_inst_t *)&cmd_config_thresh,
18846 (cmdline_parse_inst_t *)&cmd_config_threshold,
18847 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
18848 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
18849 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
18850 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
18851 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
18852 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
18853 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
18854 (cmdline_parse_inst_t *)&cmd_global_config,
18855 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
18856 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
18857 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
18858 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
18859 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
18860 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
18861 (cmdline_parse_inst_t *)&cmd_dump,
18862 (cmdline_parse_inst_t *)&cmd_dump_one,
18863 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
18864 (cmdline_parse_inst_t *)&cmd_syn_filter,
18865 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
18866 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
18867 (cmdline_parse_inst_t *)&cmd_flex_filter,
18868 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
18869 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
18870 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
18871 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
18872 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
18873 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
18874 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
18875 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
18876 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
18877 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
18878 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
18879 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
18880 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
18881 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
18882 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
18883 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
18884 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
18885 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
18886 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
18887 (cmdline_parse_inst_t *)&cmd_flow,
18888 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
18889 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
18890 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
18891 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
18892 (cmdline_parse_inst_t *)&cmd_create_port_meter,
18893 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
18894 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
18895 (cmdline_parse_inst_t *)&cmd_del_port_meter,
18896 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
18897 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
18898 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
18899 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
18900 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
18901 (cmdline_parse_inst_t *)&cmd_mcast_addr,
18902 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
18903 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
18904 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
18905 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
18906 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
18907 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
18908 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
18909 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
18910 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
18911 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
18912 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
18913 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
18914 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
18915 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
18916 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
18917 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
18918 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
18919 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
18920 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
18921 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
18922 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
18923 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
18924 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
18925 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
18926 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
18927 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
18928 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
18929 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
18930 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
18931 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
18932 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
18933 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
18934 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
18935 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
18936 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
18937 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
18938 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
18940 (cmdline_parse_inst_t *)&cmd_set_vxlan,
18941 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
18942 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
18943 (cmdline_parse_inst_t *)&cmd_set_nvgre,
18944 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
18945 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
18946 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
18947 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
18948 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
18949 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
18950 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
18951 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
18952 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
18953 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
18954 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
18955 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
18956 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
18957 (cmdline_parse_inst_t *)&cmd_ddp_add,
18958 (cmdline_parse_inst_t *)&cmd_ddp_del,
18959 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
18960 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
18961 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
18962 (cmdline_parse_inst_t *)&cmd_clear_input_set,
18963 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
18964 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
18965 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
18966 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
18967 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
18968 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
18970 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
18971 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
18972 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
18973 (cmdline_parse_inst_t *)&cmd_queue_region,
18974 (cmdline_parse_inst_t *)&cmd_region_flowtype,
18975 (cmdline_parse_inst_t *)&cmd_user_priority_region,
18976 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
18977 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
18978 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
18979 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
18980 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
18981 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
18982 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
18983 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
18984 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
18985 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
18986 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
18987 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
18988 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
18989 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
18990 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
18991 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
18992 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
18993 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
18994 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
18995 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
18996 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
18997 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
18998 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
18999 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19000 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19001 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19002 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19003 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19004 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19005 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19006 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19007 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19008 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19009 #ifdef RTE_LIBRTE_BPF
19010 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19011 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19013 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19014 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19015 (cmdline_parse_inst_t *)&cmd_set_raw,
19019 /* read cmdline commands from file */
19021 cmdline_read_from_file(const char *filename)
19023 struct cmdline *cl;
19025 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19027 printf("Failed to create file based cmdline context: %s\n",
19032 cmdline_interact(cl);
19037 printf("Read CLI commands from %s\n", filename);
19040 /* prompt function, called from main on MASTER lcore */
19044 /* initialize non-constant commands */
19045 cmd_set_fwd_mode_init();
19046 cmd_set_fwd_retry_mode_init();
19048 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19049 if (testpmd_cl == NULL)
19051 cmdline_interact(testpmd_cl);
19052 cmdline_stdin_exit(testpmd_cl);
19058 if (testpmd_cl != NULL)
19059 cmdline_quit(testpmd_cl);
19063 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19065 if (id == (portid_t)RTE_PORT_ALL) {
19068 RTE_ETH_FOREACH_DEV(pid) {
19069 /* check if need_reconfig has been set to 1 */
19070 if (ports[pid].need_reconfig == 0)
19071 ports[pid].need_reconfig = dev;
19072 /* check if need_reconfig_queues has been set to 1 */
19073 if (ports[pid].need_reconfig_queues == 0)
19074 ports[pid].need_reconfig_queues = queue;
19076 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19077 /* check if need_reconfig has been set to 1 */
19078 if (ports[id].need_reconfig == 0)
19079 ports[id].need_reconfig = dev;
19080 /* check if need_reconfig_queues has been set to 1 */
19081 if (ports[id].need_reconfig_queues == 0)
19082 ports[id].need_reconfig_queues = queue;