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 memset(&dev_info, 0, sizeof(dev_info));
2323 rte_eth_dev_info_get(res->port_id, &dev_info);
2324 if (dev_info.hash_key_size > 0 &&
2325 dev_info.hash_key_size <= sizeof(hash_key))
2326 hash_key_size = dev_info.hash_key_size;
2328 printf("dev_info did not provide a valid hash key size\n");
2331 /* Check the length of the RSS hash key */
2332 key_len = strlen(res->key);
2333 if (key_len != (hash_key_size * 2)) {
2334 printf("key length: %d invalid - key must be a string of %d"
2335 " hexa-decimal numbers\n",
2336 (int) key_len, hash_key_size * 2);
2339 /* Translate RSS hash key into binary representation */
2340 for (i = 0; i < hash_key_size; i++) {
2341 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2344 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2347 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2349 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2353 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2354 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2355 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2356 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2358 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2359 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2360 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2361 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2362 rss_hash_key, "rss-hash-key");
2363 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2364 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2365 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2366 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2367 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2368 "ipv6-tcp-ex#ipv6-udp-ex");
2369 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2370 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2372 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2373 .f = cmd_config_rss_hash_key_parsed,
2375 .help_str = "port config <port_id> rss-hash-key "
2376 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2377 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2378 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2379 "<string of hex digits (variable length, NIC dependent)>",
2381 (void *)&cmd_config_rss_hash_key_port,
2382 (void *)&cmd_config_rss_hash_key_config,
2383 (void *)&cmd_config_rss_hash_key_port_id,
2384 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2385 (void *)&cmd_config_rss_hash_key_rss_type,
2386 (void *)&cmd_config_rss_hash_key_value,
2391 /* *** configure port rxq/txq ring size *** */
2392 struct cmd_config_rxtx_ring_size {
2393 cmdline_fixed_string_t port;
2394 cmdline_fixed_string_t config;
2396 cmdline_fixed_string_t rxtxq;
2398 cmdline_fixed_string_t rsize;
2403 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2404 __attribute__((unused)) struct cmdline *cl,
2405 __attribute__((unused)) void *data)
2407 struct cmd_config_rxtx_ring_size *res = parsed_result;
2408 struct rte_port *port;
2411 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2414 if (res->portid == (portid_t)RTE_PORT_ALL) {
2415 printf("Invalid port id\n");
2419 port = &ports[res->portid];
2421 if (!strcmp(res->rxtxq, "rxq"))
2423 else if (!strcmp(res->rxtxq, "txq"))
2426 printf("Unknown parameter\n");
2430 if (isrx && rx_queue_id_is_invalid(res->qid))
2432 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2435 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2436 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2442 port->nb_rx_desc[res->qid] = res->size;
2444 port->nb_tx_desc[res->qid] = res->size;
2446 cmd_reconfig_device_queue(res->portid, 0, 1);
2449 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2450 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2452 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2453 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2455 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2456 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2458 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2459 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2461 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2462 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2464 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2465 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2466 rsize, "ring_size");
2467 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2468 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2471 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2472 .f = cmd_config_rxtx_ring_size_parsed,
2474 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2476 (void *)&cmd_config_rxtx_ring_size_port,
2477 (void *)&cmd_config_rxtx_ring_size_config,
2478 (void *)&cmd_config_rxtx_ring_size_portid,
2479 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2480 (void *)&cmd_config_rxtx_ring_size_qid,
2481 (void *)&cmd_config_rxtx_ring_size_rsize,
2482 (void *)&cmd_config_rxtx_ring_size_size,
2487 /* *** configure port rxq/txq start/stop *** */
2488 struct cmd_config_rxtx_queue {
2489 cmdline_fixed_string_t port;
2491 cmdline_fixed_string_t rxtxq;
2493 cmdline_fixed_string_t opname;
2497 cmd_config_rxtx_queue_parsed(void *parsed_result,
2498 __attribute__((unused)) struct cmdline *cl,
2499 __attribute__((unused)) void *data)
2501 struct cmd_config_rxtx_queue *res = parsed_result;
2506 if (test_done == 0) {
2507 printf("Please stop forwarding first\n");
2511 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2514 if (port_is_started(res->portid) != 1) {
2515 printf("Please start port %u first\n", res->portid);
2519 if (!strcmp(res->rxtxq, "rxq"))
2521 else if (!strcmp(res->rxtxq, "txq"))
2524 printf("Unknown parameter\n");
2528 if (isrx && rx_queue_id_is_invalid(res->qid))
2530 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2533 if (!strcmp(res->opname, "start"))
2535 else if (!strcmp(res->opname, "stop"))
2538 printf("Unknown parameter\n");
2542 if (isstart && isrx)
2543 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2544 else if (!isstart && isrx)
2545 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2546 else if (isstart && !isrx)
2547 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2549 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2551 if (ret == -ENOTSUP)
2552 printf("Function not supported in PMD driver\n");
2555 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2556 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2557 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2558 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2559 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2560 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2561 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2562 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2563 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2564 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2567 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2568 .f = cmd_config_rxtx_queue_parsed,
2570 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2572 (void *)&cmd_config_rxtx_queue_port,
2573 (void *)&cmd_config_rxtx_queue_portid,
2574 (void *)&cmd_config_rxtx_queue_rxtxq,
2575 (void *)&cmd_config_rxtx_queue_qid,
2576 (void *)&cmd_config_rxtx_queue_opname,
2581 /* *** configure port rxq/txq deferred start on/off *** */
2582 struct cmd_config_deferred_start_rxtx_queue {
2583 cmdline_fixed_string_t port;
2585 cmdline_fixed_string_t rxtxq;
2587 cmdline_fixed_string_t opname;
2588 cmdline_fixed_string_t state;
2592 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2593 __attribute__((unused)) struct cmdline *cl,
2594 __attribute__((unused)) void *data)
2596 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2597 struct rte_port *port;
2600 uint8_t needreconfig = 0;
2602 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2605 if (port_is_started(res->port_id) != 0) {
2606 printf("Please stop port %u first\n", res->port_id);
2610 port = &ports[res->port_id];
2612 isrx = !strcmp(res->rxtxq, "rxq");
2614 if (isrx && rx_queue_id_is_invalid(res->qid))
2616 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2619 ison = !strcmp(res->state, "on");
2621 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2622 port->rx_conf[res->qid].rx_deferred_start = ison;
2624 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2625 port->tx_conf[res->qid].tx_deferred_start = ison;
2630 cmd_reconfig_device_queue(res->port_id, 0, 1);
2633 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2634 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2636 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2637 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2639 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2640 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2642 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2643 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2645 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2646 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2647 opname, "deferred_start");
2648 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2649 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2652 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2653 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2655 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2657 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2658 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2659 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2660 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2661 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2662 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2667 /* *** configure port rxq/txq setup *** */
2668 struct cmd_setup_rxtx_queue {
2669 cmdline_fixed_string_t port;
2671 cmdline_fixed_string_t rxtxq;
2673 cmdline_fixed_string_t setup;
2676 /* Common CLI fields for queue setup */
2677 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2678 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2679 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2680 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2681 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2682 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2683 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2684 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2685 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2686 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2689 cmd_setup_rxtx_queue_parsed(
2690 void *parsed_result,
2691 __attribute__((unused)) struct cmdline *cl,
2692 __attribute__((unused)) void *data)
2694 struct cmd_setup_rxtx_queue *res = parsed_result;
2695 struct rte_port *port;
2696 struct rte_mempool *mp;
2697 unsigned int socket_id;
2701 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2704 if (res->portid == (portid_t)RTE_PORT_ALL) {
2705 printf("Invalid port id\n");
2709 if (!strcmp(res->rxtxq, "rxq"))
2711 else if (!strcmp(res->rxtxq, "txq"))
2714 printf("Unknown parameter\n");
2718 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2719 printf("Invalid rx queue\n");
2721 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2722 printf("Invalid tx queue\n");
2726 port = &ports[res->portid];
2728 socket_id = rxring_numa[res->portid];
2729 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2730 socket_id = port->socket_id;
2732 mp = mbuf_pool_find(socket_id);
2734 printf("Failed to setup RX queue: "
2735 "No mempool allocation"
2736 " on the socket %d\n",
2737 rxring_numa[res->portid]);
2740 ret = rte_eth_rx_queue_setup(res->portid,
2742 port->nb_rx_desc[res->qid],
2744 &port->rx_conf[res->qid],
2747 printf("Failed to setup RX queue\n");
2749 socket_id = txring_numa[res->portid];
2750 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2751 socket_id = port->socket_id;
2753 ret = rte_eth_tx_queue_setup(res->portid,
2755 port->nb_tx_desc[res->qid],
2757 &port->tx_conf[res->qid]);
2759 printf("Failed to setup TX queue\n");
2763 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2764 .f = cmd_setup_rxtx_queue_parsed,
2766 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2768 (void *)&cmd_setup_rxtx_queue_port,
2769 (void *)&cmd_setup_rxtx_queue_portid,
2770 (void *)&cmd_setup_rxtx_queue_rxtxq,
2771 (void *)&cmd_setup_rxtx_queue_qid,
2772 (void *)&cmd_setup_rxtx_queue_setup,
2778 /* *** Configure RSS RETA *** */
2779 struct cmd_config_rss_reta {
2780 cmdline_fixed_string_t port;
2781 cmdline_fixed_string_t keyword;
2783 cmdline_fixed_string_t name;
2784 cmdline_fixed_string_t list_name;
2785 cmdline_fixed_string_t list_of_items;
2789 parse_reta_config(const char *str,
2790 struct rte_eth_rss_reta_entry64 *reta_conf,
2791 uint16_t nb_entries)
2795 uint16_t hash_index, idx, shift;
2798 const char *p, *p0 = str;
2805 unsigned long int_fld[_NUM_FLD];
2806 char *str_fld[_NUM_FLD];
2808 while ((p = strchr(p0,'(')) != NULL) {
2810 if((p0 = strchr(p,')')) == NULL)
2814 if(size >= sizeof(s))
2817 snprintf(s, sizeof(s), "%.*s", size, p);
2818 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2820 for (i = 0; i < _NUM_FLD; i++) {
2822 int_fld[i] = strtoul(str_fld[i], &end, 0);
2823 if (errno != 0 || end == str_fld[i] ||
2828 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2829 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2831 if (hash_index >= nb_entries) {
2832 printf("Invalid RETA hash index=%d\n", hash_index);
2836 idx = hash_index / RTE_RETA_GROUP_SIZE;
2837 shift = hash_index % RTE_RETA_GROUP_SIZE;
2838 reta_conf[idx].mask |= (1ULL << shift);
2839 reta_conf[idx].reta[shift] = nb_queue;
2846 cmd_set_rss_reta_parsed(void *parsed_result,
2847 __attribute__((unused)) struct cmdline *cl,
2848 __attribute__((unused)) void *data)
2851 struct rte_eth_dev_info dev_info;
2852 struct rte_eth_rss_reta_entry64 reta_conf[8];
2853 struct cmd_config_rss_reta *res = parsed_result;
2855 memset(&dev_info, 0, sizeof(dev_info));
2856 rte_eth_dev_info_get(res->port_id, &dev_info);
2857 if (dev_info.reta_size == 0) {
2858 printf("Redirection table size is 0 which is "
2859 "invalid for RSS\n");
2862 printf("The reta size of port %d is %u\n",
2863 res->port_id, dev_info.reta_size);
2864 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2865 printf("Currently do not support more than %u entries of "
2866 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2870 memset(reta_conf, 0, sizeof(reta_conf));
2871 if (!strcmp(res->list_name, "reta")) {
2872 if (parse_reta_config(res->list_of_items, reta_conf,
2873 dev_info.reta_size)) {
2874 printf("Invalid RSS Redirection Table "
2875 "config entered\n");
2878 ret = rte_eth_dev_rss_reta_update(res->port_id,
2879 reta_conf, dev_info.reta_size);
2881 printf("Bad redirection table parameter, "
2882 "return code = %d \n", ret);
2886 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2887 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2888 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2889 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2890 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2891 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2892 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2893 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2894 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2895 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2896 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2897 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2899 cmdline_parse_inst_t cmd_config_rss_reta = {
2900 .f = cmd_set_rss_reta_parsed,
2902 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2904 (void *)&cmd_config_rss_reta_port,
2905 (void *)&cmd_config_rss_reta_keyword,
2906 (void *)&cmd_config_rss_reta_port_id,
2907 (void *)&cmd_config_rss_reta_name,
2908 (void *)&cmd_config_rss_reta_list_name,
2909 (void *)&cmd_config_rss_reta_list_of_items,
2914 /* *** SHOW PORT RETA INFO *** */
2915 struct cmd_showport_reta {
2916 cmdline_fixed_string_t show;
2917 cmdline_fixed_string_t port;
2919 cmdline_fixed_string_t rss;
2920 cmdline_fixed_string_t reta;
2922 cmdline_fixed_string_t list_of_items;
2926 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2927 uint16_t nb_entries,
2931 const char *p, *p0 = str;
2936 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2937 RTE_RETA_GROUP_SIZE;
2940 p = strchr(p0, '(');
2944 p0 = strchr(p, ')');
2948 if (size >= sizeof(s)) {
2949 printf("The string size exceeds the internal buffer size\n");
2952 snprintf(s, sizeof(s), "%.*s", size, p);
2953 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2954 if (ret <= 0 || ret != num) {
2955 printf("The bits of masks do not match the number of "
2956 "reta entries: %u\n", num);
2959 for (i = 0; i < ret; i++)
2960 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2966 cmd_showport_reta_parsed(void *parsed_result,
2967 __attribute__((unused)) struct cmdline *cl,
2968 __attribute__((unused)) void *data)
2970 struct cmd_showport_reta *res = parsed_result;
2971 struct rte_eth_rss_reta_entry64 reta_conf[8];
2972 struct rte_eth_dev_info dev_info;
2973 uint16_t max_reta_size;
2975 memset(&dev_info, 0, sizeof(dev_info));
2976 rte_eth_dev_info_get(res->port_id, &dev_info);
2977 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2978 if (res->size == 0 || res->size > max_reta_size) {
2979 printf("Invalid redirection table size: %u (1-%u)\n",
2980 res->size, max_reta_size);
2984 memset(reta_conf, 0, sizeof(reta_conf));
2985 if (showport_parse_reta_config(reta_conf, res->size,
2986 res->list_of_items) < 0) {
2987 printf("Invalid string: %s for reta masks\n",
2988 res->list_of_items);
2991 port_rss_reta_info(res->port_id, reta_conf, res->size);
2994 cmdline_parse_token_string_t cmd_showport_reta_show =
2995 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2996 cmdline_parse_token_string_t cmd_showport_reta_port =
2997 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2998 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2999 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3000 cmdline_parse_token_string_t cmd_showport_reta_rss =
3001 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3002 cmdline_parse_token_string_t cmd_showport_reta_reta =
3003 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3004 cmdline_parse_token_num_t cmd_showport_reta_size =
3005 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3006 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3007 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3008 list_of_items, NULL);
3010 cmdline_parse_inst_t cmd_showport_reta = {
3011 .f = cmd_showport_reta_parsed,
3013 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3015 (void *)&cmd_showport_reta_show,
3016 (void *)&cmd_showport_reta_port,
3017 (void *)&cmd_showport_reta_port_id,
3018 (void *)&cmd_showport_reta_rss,
3019 (void *)&cmd_showport_reta_reta,
3020 (void *)&cmd_showport_reta_size,
3021 (void *)&cmd_showport_reta_list_of_items,
3026 /* *** Show RSS hash configuration *** */
3027 struct cmd_showport_rss_hash {
3028 cmdline_fixed_string_t show;
3029 cmdline_fixed_string_t port;
3031 cmdline_fixed_string_t rss_hash;
3032 cmdline_fixed_string_t rss_type;
3033 cmdline_fixed_string_t key; /* optional argument */
3036 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3037 __attribute__((unused)) struct cmdline *cl,
3040 struct cmd_showport_rss_hash *res = parsed_result;
3042 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3045 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3046 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3047 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3048 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3049 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3050 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3051 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3052 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3054 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3055 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3057 cmdline_parse_inst_t cmd_showport_rss_hash = {
3058 .f = cmd_showport_rss_hash_parsed,
3060 .help_str = "show port <port_id> rss-hash",
3062 (void *)&cmd_showport_rss_hash_show,
3063 (void *)&cmd_showport_rss_hash_port,
3064 (void *)&cmd_showport_rss_hash_port_id,
3065 (void *)&cmd_showport_rss_hash_rss_hash,
3070 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3071 .f = cmd_showport_rss_hash_parsed,
3073 .help_str = "show port <port_id> rss-hash key",
3075 (void *)&cmd_showport_rss_hash_show,
3076 (void *)&cmd_showport_rss_hash_port,
3077 (void *)&cmd_showport_rss_hash_port_id,
3078 (void *)&cmd_showport_rss_hash_rss_hash,
3079 (void *)&cmd_showport_rss_hash_rss_key,
3084 /* *** Configure DCB *** */
3085 struct cmd_config_dcb {
3086 cmdline_fixed_string_t port;
3087 cmdline_fixed_string_t config;
3089 cmdline_fixed_string_t dcb;
3090 cmdline_fixed_string_t vt;
3091 cmdline_fixed_string_t vt_en;
3093 cmdline_fixed_string_t pfc;
3094 cmdline_fixed_string_t pfc_en;
3098 cmd_config_dcb_parsed(void *parsed_result,
3099 __attribute__((unused)) struct cmdline *cl,
3100 __attribute__((unused)) void *data)
3102 struct cmd_config_dcb *res = parsed_result;
3103 portid_t port_id = res->port_id;
3104 struct rte_port *port;
3108 port = &ports[port_id];
3109 /** Check if the port is not started **/
3110 if (port->port_status != RTE_PORT_STOPPED) {
3111 printf("Please stop port %d first\n", port_id);
3115 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3116 printf("The invalid number of traffic class,"
3117 " only 4 or 8 allowed.\n");
3121 if (nb_fwd_lcores < res->num_tcs) {
3122 printf("nb_cores shouldn't be less than number of TCs.\n");
3125 if (!strncmp(res->pfc_en, "on", 2))
3130 /* DCB in VT mode */
3131 if (!strncmp(res->vt_en, "on", 2))
3132 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3133 (enum rte_eth_nb_tcs)res->num_tcs,
3136 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3137 (enum rte_eth_nb_tcs)res->num_tcs,
3142 printf("Cannot initialize network ports.\n");
3146 cmd_reconfig_device_queue(port_id, 1, 1);
3149 cmdline_parse_token_string_t cmd_config_dcb_port =
3150 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3151 cmdline_parse_token_string_t cmd_config_dcb_config =
3152 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3153 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3154 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3155 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3156 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3157 cmdline_parse_token_string_t cmd_config_dcb_vt =
3158 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3159 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3160 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3161 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3162 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3163 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3164 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3165 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3166 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3168 cmdline_parse_inst_t cmd_config_dcb = {
3169 .f = cmd_config_dcb_parsed,
3171 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3173 (void *)&cmd_config_dcb_port,
3174 (void *)&cmd_config_dcb_config,
3175 (void *)&cmd_config_dcb_port_id,
3176 (void *)&cmd_config_dcb_dcb,
3177 (void *)&cmd_config_dcb_vt,
3178 (void *)&cmd_config_dcb_vt_en,
3179 (void *)&cmd_config_dcb_num_tcs,
3180 (void *)&cmd_config_dcb_pfc,
3181 (void *)&cmd_config_dcb_pfc_en,
3186 /* *** configure number of packets per burst *** */
3187 struct cmd_config_burst {
3188 cmdline_fixed_string_t port;
3189 cmdline_fixed_string_t keyword;
3190 cmdline_fixed_string_t all;
3191 cmdline_fixed_string_t name;
3196 cmd_config_burst_parsed(void *parsed_result,
3197 __attribute__((unused)) struct cmdline *cl,
3198 __attribute__((unused)) void *data)
3200 struct cmd_config_burst *res = parsed_result;
3201 struct rte_eth_dev_info dev_info;
3202 uint16_t rec_nb_pkts;
3204 if (!all_ports_stopped()) {
3205 printf("Please stop all ports first\n");
3209 if (!strcmp(res->name, "burst")) {
3210 if (res->value == 0) {
3211 /* If user gives a value of zero, query the PMD for
3212 * its recommended Rx burst size. Testpmd uses a single
3213 * size for all ports, so assume all ports are the same
3214 * NIC model and use the values from Port 0.
3216 rte_eth_dev_info_get(0, &dev_info);
3217 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3219 if (rec_nb_pkts == 0) {
3220 printf("PMD does not recommend a burst size.\n"
3221 "User provided value must be between"
3222 " 1 and %d\n", MAX_PKT_BURST);
3224 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3225 printf("PMD recommended burst size of %d"
3226 " exceeds maximum value of %d\n",
3227 rec_nb_pkts, MAX_PKT_BURST);
3230 printf("Using PMD-provided burst value of %d\n",
3232 nb_pkt_per_burst = rec_nb_pkts;
3233 } else if (res->value > MAX_PKT_BURST) {
3234 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3237 nb_pkt_per_burst = res->value;
3239 printf("Unknown parameter\n");
3245 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3248 cmdline_parse_token_string_t cmd_config_burst_port =
3249 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3250 cmdline_parse_token_string_t cmd_config_burst_keyword =
3251 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3252 cmdline_parse_token_string_t cmd_config_burst_all =
3253 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3254 cmdline_parse_token_string_t cmd_config_burst_name =
3255 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3256 cmdline_parse_token_num_t cmd_config_burst_value =
3257 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3259 cmdline_parse_inst_t cmd_config_burst = {
3260 .f = cmd_config_burst_parsed,
3262 .help_str = "port config all burst <value>",
3264 (void *)&cmd_config_burst_port,
3265 (void *)&cmd_config_burst_keyword,
3266 (void *)&cmd_config_burst_all,
3267 (void *)&cmd_config_burst_name,
3268 (void *)&cmd_config_burst_value,
3273 /* *** configure rx/tx queues *** */
3274 struct cmd_config_thresh {
3275 cmdline_fixed_string_t port;
3276 cmdline_fixed_string_t keyword;
3277 cmdline_fixed_string_t all;
3278 cmdline_fixed_string_t name;
3283 cmd_config_thresh_parsed(void *parsed_result,
3284 __attribute__((unused)) struct cmdline *cl,
3285 __attribute__((unused)) void *data)
3287 struct cmd_config_thresh *res = parsed_result;
3289 if (!all_ports_stopped()) {
3290 printf("Please stop all ports first\n");
3294 if (!strcmp(res->name, "txpt"))
3295 tx_pthresh = res->value;
3296 else if(!strcmp(res->name, "txht"))
3297 tx_hthresh = res->value;
3298 else if(!strcmp(res->name, "txwt"))
3299 tx_wthresh = res->value;
3300 else if(!strcmp(res->name, "rxpt"))
3301 rx_pthresh = res->value;
3302 else if(!strcmp(res->name, "rxht"))
3303 rx_hthresh = res->value;
3304 else if(!strcmp(res->name, "rxwt"))
3305 rx_wthresh = res->value;
3307 printf("Unknown parameter\n");
3313 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3316 cmdline_parse_token_string_t cmd_config_thresh_port =
3317 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3318 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3319 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3320 cmdline_parse_token_string_t cmd_config_thresh_all =
3321 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3322 cmdline_parse_token_string_t cmd_config_thresh_name =
3323 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3324 "txpt#txht#txwt#rxpt#rxht#rxwt");
3325 cmdline_parse_token_num_t cmd_config_thresh_value =
3326 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3328 cmdline_parse_inst_t cmd_config_thresh = {
3329 .f = cmd_config_thresh_parsed,
3331 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3333 (void *)&cmd_config_thresh_port,
3334 (void *)&cmd_config_thresh_keyword,
3335 (void *)&cmd_config_thresh_all,
3336 (void *)&cmd_config_thresh_name,
3337 (void *)&cmd_config_thresh_value,
3342 /* *** configure free/rs threshold *** */
3343 struct cmd_config_threshold {
3344 cmdline_fixed_string_t port;
3345 cmdline_fixed_string_t keyword;
3346 cmdline_fixed_string_t all;
3347 cmdline_fixed_string_t name;
3352 cmd_config_threshold_parsed(void *parsed_result,
3353 __attribute__((unused)) struct cmdline *cl,
3354 __attribute__((unused)) void *data)
3356 struct cmd_config_threshold *res = parsed_result;
3358 if (!all_ports_stopped()) {
3359 printf("Please stop all ports first\n");
3363 if (!strcmp(res->name, "txfreet"))
3364 tx_free_thresh = res->value;
3365 else if (!strcmp(res->name, "txrst"))
3366 tx_rs_thresh = res->value;
3367 else if (!strcmp(res->name, "rxfreet"))
3368 rx_free_thresh = res->value;
3370 printf("Unknown parameter\n");
3376 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3379 cmdline_parse_token_string_t cmd_config_threshold_port =
3380 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3381 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3382 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3384 cmdline_parse_token_string_t cmd_config_threshold_all =
3385 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3386 cmdline_parse_token_string_t cmd_config_threshold_name =
3387 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3388 "txfreet#txrst#rxfreet");
3389 cmdline_parse_token_num_t cmd_config_threshold_value =
3390 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3392 cmdline_parse_inst_t cmd_config_threshold = {
3393 .f = cmd_config_threshold_parsed,
3395 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3397 (void *)&cmd_config_threshold_port,
3398 (void *)&cmd_config_threshold_keyword,
3399 (void *)&cmd_config_threshold_all,
3400 (void *)&cmd_config_threshold_name,
3401 (void *)&cmd_config_threshold_value,
3407 struct cmd_stop_result {
3408 cmdline_fixed_string_t stop;
3411 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3412 __attribute__((unused)) struct cmdline *cl,
3413 __attribute__((unused)) void *data)
3415 stop_packet_forwarding();
3418 cmdline_parse_token_string_t cmd_stop_stop =
3419 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3421 cmdline_parse_inst_t cmd_stop = {
3422 .f = cmd_stop_parsed,
3424 .help_str = "stop: Stop packet forwarding",
3426 (void *)&cmd_stop_stop,
3431 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3434 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3435 unsigned int *parsed_items, int check_unique_values)
3437 unsigned int nb_item;
3445 * First parse all items in the list and store their value.
3450 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3452 if ((c >= '0') && (c <= '9')) {
3453 value = (unsigned int) (value * 10 + (c - '0'));
3458 printf("character %c is not a decimal digit\n", c);
3462 printf("No valid value before comma\n");
3465 if (nb_item < max_items) {
3466 parsed_items[nb_item] = value;
3472 if (nb_item >= max_items) {
3473 printf("Number of %s = %u > %u (maximum items)\n",
3474 item_name, nb_item + 1, max_items);
3477 parsed_items[nb_item++] = value;
3478 if (! check_unique_values)
3482 * Then, check that all values in the list are differents.
3483 * No optimization here...
3485 for (i = 0; i < nb_item; i++) {
3486 for (j = i + 1; j < nb_item; j++) {
3487 if (parsed_items[j] == parsed_items[i]) {
3488 printf("duplicated %s %u at index %u and %u\n",
3489 item_name, parsed_items[i], i, j);
3497 struct cmd_set_list_result {
3498 cmdline_fixed_string_t cmd_keyword;
3499 cmdline_fixed_string_t list_name;
3500 cmdline_fixed_string_t list_of_items;
3503 static void cmd_set_list_parsed(void *parsed_result,
3504 __attribute__((unused)) struct cmdline *cl,
3505 __attribute__((unused)) void *data)
3507 struct cmd_set_list_result *res;
3509 unsigned int lcorelist[RTE_MAX_LCORE];
3510 unsigned int portlist[RTE_MAX_ETHPORTS];
3512 unsigned int nb_item;
3514 if (test_done == 0) {
3515 printf("Please stop forwarding first\n");
3519 res = parsed_result;
3520 if (!strcmp(res->list_name, "corelist")) {
3521 nb_item = parse_item_list(res->list_of_items, "core",
3523 parsed_items.lcorelist, 1);
3525 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3530 if (!strcmp(res->list_name, "portlist")) {
3531 nb_item = parse_item_list(res->list_of_items, "port",
3533 parsed_items.portlist, 1);
3535 set_fwd_ports_list(parsed_items.portlist, nb_item);
3541 cmdline_parse_token_string_t cmd_set_list_keyword =
3542 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3544 cmdline_parse_token_string_t cmd_set_list_name =
3545 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3546 "corelist#portlist");
3547 cmdline_parse_token_string_t cmd_set_list_of_items =
3548 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3551 cmdline_parse_inst_t cmd_set_fwd_list = {
3552 .f = cmd_set_list_parsed,
3554 .help_str = "set corelist|portlist <list0[,list1]*>",
3556 (void *)&cmd_set_list_keyword,
3557 (void *)&cmd_set_list_name,
3558 (void *)&cmd_set_list_of_items,
3563 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3565 struct cmd_setmask_result {
3566 cmdline_fixed_string_t set;
3567 cmdline_fixed_string_t mask;
3571 static void cmd_set_mask_parsed(void *parsed_result,
3572 __attribute__((unused)) struct cmdline *cl,
3573 __attribute__((unused)) void *data)
3575 struct cmd_setmask_result *res = parsed_result;
3577 if (test_done == 0) {
3578 printf("Please stop forwarding first\n");
3581 if (!strcmp(res->mask, "coremask")) {
3582 set_fwd_lcores_mask(res->hexavalue);
3584 } else if (!strcmp(res->mask, "portmask")) {
3585 set_fwd_ports_mask(res->hexavalue);
3590 cmdline_parse_token_string_t cmd_setmask_set =
3591 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3592 cmdline_parse_token_string_t cmd_setmask_mask =
3593 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3594 "coremask#portmask");
3595 cmdline_parse_token_num_t cmd_setmask_value =
3596 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3598 cmdline_parse_inst_t cmd_set_fwd_mask = {
3599 .f = cmd_set_mask_parsed,
3601 .help_str = "set coremask|portmask <hexadecimal value>",
3603 (void *)&cmd_setmask_set,
3604 (void *)&cmd_setmask_mask,
3605 (void *)&cmd_setmask_value,
3611 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3613 struct cmd_set_result {
3614 cmdline_fixed_string_t set;
3615 cmdline_fixed_string_t what;
3619 static void cmd_set_parsed(void *parsed_result,
3620 __attribute__((unused)) struct cmdline *cl,
3621 __attribute__((unused)) void *data)
3623 struct cmd_set_result *res = parsed_result;
3624 if (!strcmp(res->what, "nbport")) {
3625 set_fwd_ports_number(res->value);
3627 } else if (!strcmp(res->what, "nbcore")) {
3628 set_fwd_lcores_number(res->value);
3630 } else if (!strcmp(res->what, "burst"))
3631 set_nb_pkt_per_burst(res->value);
3632 else if (!strcmp(res->what, "verbose"))
3633 set_verbose_level(res->value);
3636 cmdline_parse_token_string_t cmd_set_set =
3637 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3638 cmdline_parse_token_string_t cmd_set_what =
3639 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3640 "nbport#nbcore#burst#verbose");
3641 cmdline_parse_token_num_t cmd_set_value =
3642 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3644 cmdline_parse_inst_t cmd_set_numbers = {
3645 .f = cmd_set_parsed,
3647 .help_str = "set nbport|nbcore|burst|verbose <value>",
3649 (void *)&cmd_set_set,
3650 (void *)&cmd_set_what,
3651 (void *)&cmd_set_value,
3656 /* *** SET LOG LEVEL CONFIGURATION *** */
3658 struct cmd_set_log_result {
3659 cmdline_fixed_string_t set;
3660 cmdline_fixed_string_t log;
3661 cmdline_fixed_string_t type;
3666 cmd_set_log_parsed(void *parsed_result,
3667 __attribute__((unused)) struct cmdline *cl,
3668 __attribute__((unused)) void *data)
3670 struct cmd_set_log_result *res;
3673 res = parsed_result;
3674 if (!strcmp(res->type, "global"))
3675 rte_log_set_global_level(res->level);
3677 ret = rte_log_set_level_regexp(res->type, res->level);
3679 printf("Unable to set log level\n");
3683 cmdline_parse_token_string_t cmd_set_log_set =
3684 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3685 cmdline_parse_token_string_t cmd_set_log_log =
3686 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3687 cmdline_parse_token_string_t cmd_set_log_type =
3688 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3689 cmdline_parse_token_num_t cmd_set_log_level =
3690 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3692 cmdline_parse_inst_t cmd_set_log = {
3693 .f = cmd_set_log_parsed,
3695 .help_str = "set log global|<type> <level>",
3697 (void *)&cmd_set_log_set,
3698 (void *)&cmd_set_log_log,
3699 (void *)&cmd_set_log_type,
3700 (void *)&cmd_set_log_level,
3705 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3707 struct cmd_set_txpkts_result {
3708 cmdline_fixed_string_t cmd_keyword;
3709 cmdline_fixed_string_t txpkts;
3710 cmdline_fixed_string_t seg_lengths;
3714 cmd_set_txpkts_parsed(void *parsed_result,
3715 __attribute__((unused)) struct cmdline *cl,
3716 __attribute__((unused)) void *data)
3718 struct cmd_set_txpkts_result *res;
3719 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3720 unsigned int nb_segs;
3722 res = parsed_result;
3723 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3724 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3726 set_tx_pkt_segments(seg_lengths, nb_segs);
3729 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3730 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3731 cmd_keyword, "set");
3732 cmdline_parse_token_string_t cmd_set_txpkts_name =
3733 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3735 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3736 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3739 cmdline_parse_inst_t cmd_set_txpkts = {
3740 .f = cmd_set_txpkts_parsed,
3742 .help_str = "set txpkts <len0[,len1]*>",
3744 (void *)&cmd_set_txpkts_keyword,
3745 (void *)&cmd_set_txpkts_name,
3746 (void *)&cmd_set_txpkts_lengths,
3751 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3753 struct cmd_set_txsplit_result {
3754 cmdline_fixed_string_t cmd_keyword;
3755 cmdline_fixed_string_t txsplit;
3756 cmdline_fixed_string_t mode;
3760 cmd_set_txsplit_parsed(void *parsed_result,
3761 __attribute__((unused)) struct cmdline *cl,
3762 __attribute__((unused)) void *data)
3764 struct cmd_set_txsplit_result *res;
3766 res = parsed_result;
3767 set_tx_pkt_split(res->mode);
3770 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3771 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3772 cmd_keyword, "set");
3773 cmdline_parse_token_string_t cmd_set_txsplit_name =
3774 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3775 txsplit, "txsplit");
3776 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3777 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3780 cmdline_parse_inst_t cmd_set_txsplit = {
3781 .f = cmd_set_txsplit_parsed,
3783 .help_str = "set txsplit on|off|rand",
3785 (void *)&cmd_set_txsplit_keyword,
3786 (void *)&cmd_set_txsplit_name,
3787 (void *)&cmd_set_txsplit_mode,
3792 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3793 struct cmd_rx_vlan_filter_all_result {
3794 cmdline_fixed_string_t rx_vlan;
3795 cmdline_fixed_string_t what;
3796 cmdline_fixed_string_t all;
3801 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3802 __attribute__((unused)) struct cmdline *cl,
3803 __attribute__((unused)) void *data)
3805 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3807 if (!strcmp(res->what, "add"))
3808 rx_vlan_all_filter_set(res->port_id, 1);
3810 rx_vlan_all_filter_set(res->port_id, 0);
3813 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3814 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3815 rx_vlan, "rx_vlan");
3816 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3817 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3819 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3820 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3822 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3823 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3826 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3827 .f = cmd_rx_vlan_filter_all_parsed,
3829 .help_str = "rx_vlan add|rm all <port_id>: "
3830 "Add/Remove all identifiers to/from the set of VLAN "
3831 "identifiers filtered by a port",
3833 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3834 (void *)&cmd_rx_vlan_filter_all_what,
3835 (void *)&cmd_rx_vlan_filter_all_all,
3836 (void *)&cmd_rx_vlan_filter_all_portid,
3841 /* *** VLAN OFFLOAD SET ON A PORT *** */
3842 struct cmd_vlan_offload_result {
3843 cmdline_fixed_string_t vlan;
3844 cmdline_fixed_string_t set;
3845 cmdline_fixed_string_t vlan_type;
3846 cmdline_fixed_string_t what;
3847 cmdline_fixed_string_t on;
3848 cmdline_fixed_string_t port_id;
3852 cmd_vlan_offload_parsed(void *parsed_result,
3853 __attribute__((unused)) struct cmdline *cl,
3854 __attribute__((unused)) void *data)
3857 struct cmd_vlan_offload_result *res = parsed_result;
3860 portid_t port_id = 0;
3864 len = strnlen(str, STR_TOKEN_SIZE);
3866 /* Get port_id first */
3874 tmp = strtoul(str, NULL, 0);
3875 /* If port_id greater that what portid_t can represent, return */
3876 if(tmp >= RTE_MAX_ETHPORTS)
3878 port_id = (portid_t)tmp;
3880 if (!strcmp(res->on, "on"))
3885 if (!strcmp(res->what, "strip"))
3886 rx_vlan_strip_set(port_id, on);
3887 else if(!strcmp(res->what, "stripq")){
3888 uint16_t queue_id = 0;
3890 /* No queue_id, return */
3892 printf("must specify (port,queue_id)\n");
3895 tmp = strtoul(str + i + 1, NULL, 0);
3896 /* If queue_id greater that what 16-bits can represent, return */
3900 queue_id = (uint16_t)tmp;
3901 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3903 else if (!strcmp(res->what, "filter"))
3904 rx_vlan_filter_set(port_id, on);
3906 vlan_extend_set(port_id, on);
3911 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3912 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3914 cmdline_parse_token_string_t cmd_vlan_offload_set =
3915 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3917 cmdline_parse_token_string_t cmd_vlan_offload_what =
3918 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3919 what, "strip#filter#qinq#stripq");
3920 cmdline_parse_token_string_t cmd_vlan_offload_on =
3921 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3923 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3924 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3927 cmdline_parse_inst_t cmd_vlan_offload = {
3928 .f = cmd_vlan_offload_parsed,
3930 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3931 "<port_id[,queue_id]>: "
3932 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3934 (void *)&cmd_vlan_offload_vlan,
3935 (void *)&cmd_vlan_offload_set,
3936 (void *)&cmd_vlan_offload_what,
3937 (void *)&cmd_vlan_offload_on,
3938 (void *)&cmd_vlan_offload_portid,
3943 /* *** VLAN TPID SET ON A PORT *** */
3944 struct cmd_vlan_tpid_result {
3945 cmdline_fixed_string_t vlan;
3946 cmdline_fixed_string_t set;
3947 cmdline_fixed_string_t vlan_type;
3948 cmdline_fixed_string_t what;
3954 cmd_vlan_tpid_parsed(void *parsed_result,
3955 __attribute__((unused)) struct cmdline *cl,
3956 __attribute__((unused)) void *data)
3958 struct cmd_vlan_tpid_result *res = parsed_result;
3959 enum rte_vlan_type vlan_type;
3961 if (!strcmp(res->vlan_type, "inner"))
3962 vlan_type = ETH_VLAN_TYPE_INNER;
3963 else if (!strcmp(res->vlan_type, "outer"))
3964 vlan_type = ETH_VLAN_TYPE_OUTER;
3966 printf("Unknown vlan type\n");
3969 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3972 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3973 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3975 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3976 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3978 cmdline_parse_token_string_t cmd_vlan_type =
3979 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3980 vlan_type, "inner#outer");
3981 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3982 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3984 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3985 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3987 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3988 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3991 cmdline_parse_inst_t cmd_vlan_tpid = {
3992 .f = cmd_vlan_tpid_parsed,
3994 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3995 "Set the VLAN Ether type",
3997 (void *)&cmd_vlan_tpid_vlan,
3998 (void *)&cmd_vlan_tpid_set,
3999 (void *)&cmd_vlan_type,
4000 (void *)&cmd_vlan_tpid_what,
4001 (void *)&cmd_vlan_tpid_tpid,
4002 (void *)&cmd_vlan_tpid_portid,
4007 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4008 struct cmd_rx_vlan_filter_result {
4009 cmdline_fixed_string_t rx_vlan;
4010 cmdline_fixed_string_t what;
4016 cmd_rx_vlan_filter_parsed(void *parsed_result,
4017 __attribute__((unused)) struct cmdline *cl,
4018 __attribute__((unused)) void *data)
4020 struct cmd_rx_vlan_filter_result *res = parsed_result;
4022 if (!strcmp(res->what, "add"))
4023 rx_vft_set(res->port_id, res->vlan_id, 1);
4025 rx_vft_set(res->port_id, res->vlan_id, 0);
4028 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4029 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4030 rx_vlan, "rx_vlan");
4031 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4032 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4034 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4035 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4037 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4038 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4041 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4042 .f = cmd_rx_vlan_filter_parsed,
4044 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4045 "Add/Remove a VLAN identifier to/from the set of VLAN "
4046 "identifiers filtered by a port",
4048 (void *)&cmd_rx_vlan_filter_rx_vlan,
4049 (void *)&cmd_rx_vlan_filter_what,
4050 (void *)&cmd_rx_vlan_filter_vlanid,
4051 (void *)&cmd_rx_vlan_filter_portid,
4056 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4057 struct cmd_tx_vlan_set_result {
4058 cmdline_fixed_string_t tx_vlan;
4059 cmdline_fixed_string_t set;
4065 cmd_tx_vlan_set_parsed(void *parsed_result,
4066 __attribute__((unused)) struct cmdline *cl,
4067 __attribute__((unused)) void *data)
4069 struct cmd_tx_vlan_set_result *res = parsed_result;
4071 if (!port_is_stopped(res->port_id)) {
4072 printf("Please stop port %d first\n", res->port_id);
4076 tx_vlan_set(res->port_id, res->vlan_id);
4078 cmd_reconfig_device_queue(res->port_id, 1, 1);
4081 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4082 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4083 tx_vlan, "tx_vlan");
4084 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4085 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4087 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4088 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4090 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4091 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4094 cmdline_parse_inst_t cmd_tx_vlan_set = {
4095 .f = cmd_tx_vlan_set_parsed,
4097 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4098 "Enable hardware insertion of a single VLAN header "
4099 "with a given TAG Identifier in packets sent on a port",
4101 (void *)&cmd_tx_vlan_set_tx_vlan,
4102 (void *)&cmd_tx_vlan_set_set,
4103 (void *)&cmd_tx_vlan_set_portid,
4104 (void *)&cmd_tx_vlan_set_vlanid,
4109 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4110 struct cmd_tx_vlan_set_qinq_result {
4111 cmdline_fixed_string_t tx_vlan;
4112 cmdline_fixed_string_t set;
4115 uint16_t vlan_id_outer;
4119 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4120 __attribute__((unused)) struct cmdline *cl,
4121 __attribute__((unused)) void *data)
4123 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4125 if (!port_is_stopped(res->port_id)) {
4126 printf("Please stop port %d first\n", res->port_id);
4130 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4132 cmd_reconfig_device_queue(res->port_id, 1, 1);
4135 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4136 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4137 tx_vlan, "tx_vlan");
4138 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4139 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4141 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4142 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4144 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4145 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4147 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4148 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4149 vlan_id_outer, UINT16);
4151 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4152 .f = cmd_tx_vlan_set_qinq_parsed,
4154 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4155 "Enable hardware insertion of double VLAN header "
4156 "with given TAG Identifiers in packets sent on a port",
4158 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4159 (void *)&cmd_tx_vlan_set_qinq_set,
4160 (void *)&cmd_tx_vlan_set_qinq_portid,
4161 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4162 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4167 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4168 struct cmd_tx_vlan_set_pvid_result {
4169 cmdline_fixed_string_t tx_vlan;
4170 cmdline_fixed_string_t set;
4171 cmdline_fixed_string_t pvid;
4174 cmdline_fixed_string_t mode;
4178 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4179 __attribute__((unused)) struct cmdline *cl,
4180 __attribute__((unused)) void *data)
4182 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4184 if (strcmp(res->mode, "on") == 0)
4185 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4187 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4190 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4191 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4192 tx_vlan, "tx_vlan");
4193 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4194 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4196 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4197 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4199 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4200 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4202 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4203 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4205 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4206 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4209 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4210 .f = cmd_tx_vlan_set_pvid_parsed,
4212 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4214 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4215 (void *)&cmd_tx_vlan_set_pvid_set,
4216 (void *)&cmd_tx_vlan_set_pvid_pvid,
4217 (void *)&cmd_tx_vlan_set_pvid_port_id,
4218 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4219 (void *)&cmd_tx_vlan_set_pvid_mode,
4224 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4225 struct cmd_tx_vlan_reset_result {
4226 cmdline_fixed_string_t tx_vlan;
4227 cmdline_fixed_string_t reset;
4232 cmd_tx_vlan_reset_parsed(void *parsed_result,
4233 __attribute__((unused)) struct cmdline *cl,
4234 __attribute__((unused)) void *data)
4236 struct cmd_tx_vlan_reset_result *res = parsed_result;
4238 if (!port_is_stopped(res->port_id)) {
4239 printf("Please stop port %d first\n", res->port_id);
4243 tx_vlan_reset(res->port_id);
4245 cmd_reconfig_device_queue(res->port_id, 1, 1);
4248 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4249 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4250 tx_vlan, "tx_vlan");
4251 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4252 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4254 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4255 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4258 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4259 .f = cmd_tx_vlan_reset_parsed,
4261 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4262 "VLAN header in packets sent on a port",
4264 (void *)&cmd_tx_vlan_reset_tx_vlan,
4265 (void *)&cmd_tx_vlan_reset_reset,
4266 (void *)&cmd_tx_vlan_reset_portid,
4272 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4273 struct cmd_csum_result {
4274 cmdline_fixed_string_t csum;
4275 cmdline_fixed_string_t mode;
4276 cmdline_fixed_string_t proto;
4277 cmdline_fixed_string_t hwsw;
4282 csum_show(int port_id)
4284 struct rte_eth_dev_info dev_info;
4285 uint64_t tx_offloads;
4287 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4288 printf("Parse tunnel is %s\n",
4289 (ports[port_id].parse_tunnel) ? "on" : "off");
4290 printf("IP checksum offload is %s\n",
4291 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4292 printf("UDP checksum offload is %s\n",
4293 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4294 printf("TCP checksum offload is %s\n",
4295 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4296 printf("SCTP checksum offload is %s\n",
4297 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4298 printf("Outer-Ip checksum offload is %s\n",
4299 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4300 printf("Outer-Udp checksum offload is %s\n",
4301 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4303 /* display warnings if configuration is not supported by the NIC */
4304 rte_eth_dev_info_get(port_id, &dev_info);
4305 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4306 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4307 printf("Warning: hardware IP checksum enabled but not "
4308 "supported by port %d\n", port_id);
4310 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4311 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4312 printf("Warning: hardware UDP checksum enabled but not "
4313 "supported by port %d\n", port_id);
4315 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4316 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4317 printf("Warning: hardware TCP checksum enabled but not "
4318 "supported by port %d\n", port_id);
4320 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4321 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4322 printf("Warning: hardware SCTP checksum enabled but not "
4323 "supported by port %d\n", port_id);
4325 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4326 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4327 printf("Warning: hardware outer IP checksum enabled but not "
4328 "supported by port %d\n", port_id);
4330 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4331 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4333 printf("Warning: hardware outer UDP checksum enabled but not "
4334 "supported by port %d\n", port_id);
4339 cmd_config_queue_tx_offloads(struct rte_port *port)
4343 /* Apply queue tx offloads configuration */
4344 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4345 port->tx_conf[k].offloads =
4346 port->dev_conf.txmode.offloads;
4350 cmd_csum_parsed(void *parsed_result,
4351 __attribute__((unused)) struct cmdline *cl,
4352 __attribute__((unused)) void *data)
4354 struct cmd_csum_result *res = parsed_result;
4356 uint64_t csum_offloads = 0;
4357 struct rte_eth_dev_info dev_info;
4359 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4360 printf("invalid port %d\n", res->port_id);
4363 if (!port_is_stopped(res->port_id)) {
4364 printf("Please stop port %d first\n", res->port_id);
4368 rte_eth_dev_info_get(res->port_id, &dev_info);
4369 if (!strcmp(res->mode, "set")) {
4371 if (!strcmp(res->hwsw, "hw"))
4374 if (!strcmp(res->proto, "ip")) {
4375 if (hw == 0 || (dev_info.tx_offload_capa &
4376 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4377 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4379 printf("IP checksum offload is not supported "
4380 "by port %u\n", res->port_id);
4382 } else if (!strcmp(res->proto, "udp")) {
4383 if (hw == 0 || (dev_info.tx_offload_capa &
4384 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4385 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4387 printf("UDP checksum offload is not supported "
4388 "by port %u\n", res->port_id);
4390 } else if (!strcmp(res->proto, "tcp")) {
4391 if (hw == 0 || (dev_info.tx_offload_capa &
4392 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4393 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4395 printf("TCP checksum offload is not supported "
4396 "by port %u\n", res->port_id);
4398 } else if (!strcmp(res->proto, "sctp")) {
4399 if (hw == 0 || (dev_info.tx_offload_capa &
4400 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4401 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4403 printf("SCTP checksum offload is not supported "
4404 "by port %u\n", res->port_id);
4406 } else if (!strcmp(res->proto, "outer-ip")) {
4407 if (hw == 0 || (dev_info.tx_offload_capa &
4408 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4410 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4412 printf("Outer IP checksum offload is not "
4413 "supported by port %u\n", res->port_id);
4415 } else if (!strcmp(res->proto, "outer-udp")) {
4416 if (hw == 0 || (dev_info.tx_offload_capa &
4417 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4419 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4421 printf("Outer UDP checksum offload is not "
4422 "supported by port %u\n", res->port_id);
4427 ports[res->port_id].dev_conf.txmode.offloads |=
4430 ports[res->port_id].dev_conf.txmode.offloads &=
4433 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4435 csum_show(res->port_id);
4437 cmd_reconfig_device_queue(res->port_id, 1, 1);
4440 cmdline_parse_token_string_t cmd_csum_csum =
4441 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4443 cmdline_parse_token_string_t cmd_csum_mode =
4444 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4446 cmdline_parse_token_string_t cmd_csum_proto =
4447 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4448 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4449 cmdline_parse_token_string_t cmd_csum_hwsw =
4450 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4452 cmdline_parse_token_num_t cmd_csum_portid =
4453 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4456 cmdline_parse_inst_t cmd_csum_set = {
4457 .f = cmd_csum_parsed,
4459 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4460 "Enable/Disable hardware calculation of L3/L4 checksum when "
4461 "using csum forward engine",
4463 (void *)&cmd_csum_csum,
4464 (void *)&cmd_csum_mode,
4465 (void *)&cmd_csum_proto,
4466 (void *)&cmd_csum_hwsw,
4467 (void *)&cmd_csum_portid,
4472 cmdline_parse_token_string_t cmd_csum_mode_show =
4473 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4476 cmdline_parse_inst_t cmd_csum_show = {
4477 .f = cmd_csum_parsed,
4479 .help_str = "csum show <port_id>: Show checksum offload configuration",
4481 (void *)&cmd_csum_csum,
4482 (void *)&cmd_csum_mode_show,
4483 (void *)&cmd_csum_portid,
4488 /* Enable/disable tunnel parsing */
4489 struct cmd_csum_tunnel_result {
4490 cmdline_fixed_string_t csum;
4491 cmdline_fixed_string_t parse;
4492 cmdline_fixed_string_t onoff;
4497 cmd_csum_tunnel_parsed(void *parsed_result,
4498 __attribute__((unused)) struct cmdline *cl,
4499 __attribute__((unused)) void *data)
4501 struct cmd_csum_tunnel_result *res = parsed_result;
4503 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4506 if (!strcmp(res->onoff, "on"))
4507 ports[res->port_id].parse_tunnel = 1;
4509 ports[res->port_id].parse_tunnel = 0;
4511 csum_show(res->port_id);
4514 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4515 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4517 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4518 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4519 parse, "parse-tunnel");
4520 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4521 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4523 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4524 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4527 cmdline_parse_inst_t cmd_csum_tunnel = {
4528 .f = cmd_csum_tunnel_parsed,
4530 .help_str = "csum parse-tunnel on|off <port_id>: "
4531 "Enable/Disable parsing of tunnels for csum engine",
4533 (void *)&cmd_csum_tunnel_csum,
4534 (void *)&cmd_csum_tunnel_parse,
4535 (void *)&cmd_csum_tunnel_onoff,
4536 (void *)&cmd_csum_tunnel_portid,
4541 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4542 struct cmd_tso_set_result {
4543 cmdline_fixed_string_t tso;
4544 cmdline_fixed_string_t mode;
4550 cmd_tso_set_parsed(void *parsed_result,
4551 __attribute__((unused)) struct cmdline *cl,
4552 __attribute__((unused)) void *data)
4554 struct cmd_tso_set_result *res = parsed_result;
4555 struct rte_eth_dev_info dev_info;
4557 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4559 if (!port_is_stopped(res->port_id)) {
4560 printf("Please stop port %d first\n", res->port_id);
4564 if (!strcmp(res->mode, "set"))
4565 ports[res->port_id].tso_segsz = res->tso_segsz;
4567 rte_eth_dev_info_get(res->port_id, &dev_info);
4568 if ((ports[res->port_id].tso_segsz != 0) &&
4569 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4570 printf("Error: TSO is not supported by port %d\n",
4575 if (ports[res->port_id].tso_segsz == 0) {
4576 ports[res->port_id].dev_conf.txmode.offloads &=
4577 ~DEV_TX_OFFLOAD_TCP_TSO;
4578 printf("TSO for non-tunneled packets is disabled\n");
4580 ports[res->port_id].dev_conf.txmode.offloads |=
4581 DEV_TX_OFFLOAD_TCP_TSO;
4582 printf("TSO segment size for non-tunneled packets is %d\n",
4583 ports[res->port_id].tso_segsz);
4585 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4587 /* display warnings if configuration is not supported by the NIC */
4588 rte_eth_dev_info_get(res->port_id, &dev_info);
4589 if ((ports[res->port_id].tso_segsz != 0) &&
4590 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4591 printf("Warning: TSO enabled but not "
4592 "supported by port %d\n", res->port_id);
4595 cmd_reconfig_device_queue(res->port_id, 1, 1);
4598 cmdline_parse_token_string_t cmd_tso_set_tso =
4599 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4601 cmdline_parse_token_string_t cmd_tso_set_mode =
4602 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4604 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4605 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4607 cmdline_parse_token_num_t cmd_tso_set_portid =
4608 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4611 cmdline_parse_inst_t cmd_tso_set = {
4612 .f = cmd_tso_set_parsed,
4614 .help_str = "tso set <tso_segsz> <port_id>: "
4615 "Set TSO segment size of non-tunneled packets for csum engine "
4618 (void *)&cmd_tso_set_tso,
4619 (void *)&cmd_tso_set_mode,
4620 (void *)&cmd_tso_set_tso_segsz,
4621 (void *)&cmd_tso_set_portid,
4626 cmdline_parse_token_string_t cmd_tso_show_mode =
4627 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4631 cmdline_parse_inst_t cmd_tso_show = {
4632 .f = cmd_tso_set_parsed,
4634 .help_str = "tso show <port_id>: "
4635 "Show TSO segment size of non-tunneled packets for csum engine",
4637 (void *)&cmd_tso_set_tso,
4638 (void *)&cmd_tso_show_mode,
4639 (void *)&cmd_tso_set_portid,
4644 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4645 struct cmd_tunnel_tso_set_result {
4646 cmdline_fixed_string_t tso;
4647 cmdline_fixed_string_t mode;
4652 static struct rte_eth_dev_info
4653 check_tunnel_tso_nic_support(portid_t port_id)
4655 struct rte_eth_dev_info dev_info;
4657 rte_eth_dev_info_get(port_id, &dev_info);
4658 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4659 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4660 "not enabled for port %d\n", port_id);
4661 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4662 printf("Warning: GRE TUNNEL TSO not supported therefore "
4663 "not enabled for port %d\n", port_id);
4664 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4665 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4666 "not enabled for port %d\n", port_id);
4667 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4668 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4669 "not enabled for port %d\n", port_id);
4670 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4671 printf("Warning: IP TUNNEL TSO not supported therefore "
4672 "not enabled for port %d\n", port_id);
4673 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4674 printf("Warning: UDP TUNNEL TSO not supported therefore "
4675 "not enabled for port %d\n", port_id);
4680 cmd_tunnel_tso_set_parsed(void *parsed_result,
4681 __attribute__((unused)) struct cmdline *cl,
4682 __attribute__((unused)) void *data)
4684 struct cmd_tunnel_tso_set_result *res = parsed_result;
4685 struct rte_eth_dev_info dev_info;
4687 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4689 if (!port_is_stopped(res->port_id)) {
4690 printf("Please stop port %d first\n", res->port_id);
4694 if (!strcmp(res->mode, "set"))
4695 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4697 dev_info = check_tunnel_tso_nic_support(res->port_id);
4698 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4699 ports[res->port_id].dev_conf.txmode.offloads &=
4700 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4701 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4702 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4703 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4704 DEV_TX_OFFLOAD_IP_TNL_TSO |
4705 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4706 printf("TSO for tunneled packets is disabled\n");
4708 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4709 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4710 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4711 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4712 DEV_TX_OFFLOAD_IP_TNL_TSO |
4713 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4715 ports[res->port_id].dev_conf.txmode.offloads |=
4716 (tso_offloads & dev_info.tx_offload_capa);
4717 printf("TSO segment size for tunneled packets is %d\n",
4718 ports[res->port_id].tunnel_tso_segsz);
4720 /* Below conditions are needed to make it work:
4721 * (1) tunnel TSO is supported by the NIC;
4722 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4724 * (3) for tunneled pkts with outer L3 of IPv4,
4725 * "csum set outer-ip" must be set to hw, because after tso,
4726 * total_len of outer IP header is changed, and the checksum
4727 * of outer IP header calculated by sw should be wrong; that
4728 * is not necessary for IPv6 tunneled pkts because there's no
4729 * checksum in IP header anymore.
4732 if (!ports[res->port_id].parse_tunnel)
4733 printf("Warning: csum parse_tunnel must be set "
4734 "so that tunneled packets are recognized\n");
4735 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4736 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4737 printf("Warning: csum set outer-ip must be set to hw "
4738 "if outer L3 is IPv4; not necessary for IPv6\n");
4741 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4742 cmd_reconfig_device_queue(res->port_id, 1, 1);
4745 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4746 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4748 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4749 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4751 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4752 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4754 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4755 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4758 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4759 .f = cmd_tunnel_tso_set_parsed,
4761 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4762 "Set TSO segment size of tunneled packets for csum engine "
4765 (void *)&cmd_tunnel_tso_set_tso,
4766 (void *)&cmd_tunnel_tso_set_mode,
4767 (void *)&cmd_tunnel_tso_set_tso_segsz,
4768 (void *)&cmd_tunnel_tso_set_portid,
4773 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4774 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4778 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4779 .f = cmd_tunnel_tso_set_parsed,
4781 .help_str = "tunnel_tso show <port_id> "
4782 "Show TSO segment size of tunneled packets for csum engine",
4784 (void *)&cmd_tunnel_tso_set_tso,
4785 (void *)&cmd_tunnel_tso_show_mode,
4786 (void *)&cmd_tunnel_tso_set_portid,
4791 /* *** SET GRO FOR A PORT *** */
4792 struct cmd_gro_enable_result {
4793 cmdline_fixed_string_t cmd_set;
4794 cmdline_fixed_string_t cmd_port;
4795 cmdline_fixed_string_t cmd_keyword;
4796 cmdline_fixed_string_t cmd_onoff;
4801 cmd_gro_enable_parsed(void *parsed_result,
4802 __attribute__((unused)) struct cmdline *cl,
4803 __attribute__((unused)) void *data)
4805 struct cmd_gro_enable_result *res;
4807 res = parsed_result;
4808 if (!strcmp(res->cmd_keyword, "gro"))
4809 setup_gro(res->cmd_onoff, res->cmd_pid);
4812 cmdline_parse_token_string_t cmd_gro_enable_set =
4813 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4815 cmdline_parse_token_string_t cmd_gro_enable_port =
4816 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4817 cmd_keyword, "port");
4818 cmdline_parse_token_num_t cmd_gro_enable_pid =
4819 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4821 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4822 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4823 cmd_keyword, "gro");
4824 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4825 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4826 cmd_onoff, "on#off");
4828 cmdline_parse_inst_t cmd_gro_enable = {
4829 .f = cmd_gro_enable_parsed,
4831 .help_str = "set port <port_id> gro on|off",
4833 (void *)&cmd_gro_enable_set,
4834 (void *)&cmd_gro_enable_port,
4835 (void *)&cmd_gro_enable_pid,
4836 (void *)&cmd_gro_enable_keyword,
4837 (void *)&cmd_gro_enable_onoff,
4842 /* *** DISPLAY GRO CONFIGURATION *** */
4843 struct cmd_gro_show_result {
4844 cmdline_fixed_string_t cmd_show;
4845 cmdline_fixed_string_t cmd_port;
4846 cmdline_fixed_string_t cmd_keyword;
4851 cmd_gro_show_parsed(void *parsed_result,
4852 __attribute__((unused)) struct cmdline *cl,
4853 __attribute__((unused)) void *data)
4855 struct cmd_gro_show_result *res;
4857 res = parsed_result;
4858 if (!strcmp(res->cmd_keyword, "gro"))
4859 show_gro(res->cmd_pid);
4862 cmdline_parse_token_string_t cmd_gro_show_show =
4863 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4865 cmdline_parse_token_string_t cmd_gro_show_port =
4866 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4868 cmdline_parse_token_num_t cmd_gro_show_pid =
4869 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4871 cmdline_parse_token_string_t cmd_gro_show_keyword =
4872 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4873 cmd_keyword, "gro");
4875 cmdline_parse_inst_t cmd_gro_show = {
4876 .f = cmd_gro_show_parsed,
4878 .help_str = "show port <port_id> gro",
4880 (void *)&cmd_gro_show_show,
4881 (void *)&cmd_gro_show_port,
4882 (void *)&cmd_gro_show_pid,
4883 (void *)&cmd_gro_show_keyword,
4888 /* *** SET FLUSH CYCLES FOR GRO *** */
4889 struct cmd_gro_flush_result {
4890 cmdline_fixed_string_t cmd_set;
4891 cmdline_fixed_string_t cmd_keyword;
4892 cmdline_fixed_string_t cmd_flush;
4897 cmd_gro_flush_parsed(void *parsed_result,
4898 __attribute__((unused)) struct cmdline *cl,
4899 __attribute__((unused)) void *data)
4901 struct cmd_gro_flush_result *res;
4903 res = parsed_result;
4904 if ((!strcmp(res->cmd_keyword, "gro")) &&
4905 (!strcmp(res->cmd_flush, "flush")))
4906 setup_gro_flush_cycles(res->cmd_cycles);
4909 cmdline_parse_token_string_t cmd_gro_flush_set =
4910 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4912 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4913 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4914 cmd_keyword, "gro");
4915 cmdline_parse_token_string_t cmd_gro_flush_flush =
4916 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4917 cmd_flush, "flush");
4918 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4919 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4922 cmdline_parse_inst_t cmd_gro_flush = {
4923 .f = cmd_gro_flush_parsed,
4925 .help_str = "set gro flush <cycles>",
4927 (void *)&cmd_gro_flush_set,
4928 (void *)&cmd_gro_flush_keyword,
4929 (void *)&cmd_gro_flush_flush,
4930 (void *)&cmd_gro_flush_cycles,
4935 /* *** ENABLE/DISABLE GSO *** */
4936 struct cmd_gso_enable_result {
4937 cmdline_fixed_string_t cmd_set;
4938 cmdline_fixed_string_t cmd_port;
4939 cmdline_fixed_string_t cmd_keyword;
4940 cmdline_fixed_string_t cmd_mode;
4945 cmd_gso_enable_parsed(void *parsed_result,
4946 __attribute__((unused)) struct cmdline *cl,
4947 __attribute__((unused)) void *data)
4949 struct cmd_gso_enable_result *res;
4951 res = parsed_result;
4952 if (!strcmp(res->cmd_keyword, "gso"))
4953 setup_gso(res->cmd_mode, res->cmd_pid);
4956 cmdline_parse_token_string_t cmd_gso_enable_set =
4957 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4959 cmdline_parse_token_string_t cmd_gso_enable_port =
4960 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4962 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4963 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4964 cmd_keyword, "gso");
4965 cmdline_parse_token_string_t cmd_gso_enable_mode =
4966 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4967 cmd_mode, "on#off");
4968 cmdline_parse_token_num_t cmd_gso_enable_pid =
4969 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4972 cmdline_parse_inst_t cmd_gso_enable = {
4973 .f = cmd_gso_enable_parsed,
4975 .help_str = "set port <port_id> gso on|off",
4977 (void *)&cmd_gso_enable_set,
4978 (void *)&cmd_gso_enable_port,
4979 (void *)&cmd_gso_enable_pid,
4980 (void *)&cmd_gso_enable_keyword,
4981 (void *)&cmd_gso_enable_mode,
4986 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4987 struct cmd_gso_size_result {
4988 cmdline_fixed_string_t cmd_set;
4989 cmdline_fixed_string_t cmd_keyword;
4990 cmdline_fixed_string_t cmd_segsz;
4995 cmd_gso_size_parsed(void *parsed_result,
4996 __attribute__((unused)) struct cmdline *cl,
4997 __attribute__((unused)) void *data)
4999 struct cmd_gso_size_result *res = parsed_result;
5001 if (test_done == 0) {
5002 printf("Before setting GSO segsz, please first"
5003 " stop fowarding\n");
5007 if (!strcmp(res->cmd_keyword, "gso") &&
5008 !strcmp(res->cmd_segsz, "segsz")) {
5009 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5010 printf("gso_size should be larger than %zu."
5011 " Please input a legal value\n",
5012 RTE_GSO_SEG_SIZE_MIN);
5014 gso_max_segment_size = res->cmd_size;
5018 cmdline_parse_token_string_t cmd_gso_size_set =
5019 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5021 cmdline_parse_token_string_t cmd_gso_size_keyword =
5022 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5023 cmd_keyword, "gso");
5024 cmdline_parse_token_string_t cmd_gso_size_segsz =
5025 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5026 cmd_segsz, "segsz");
5027 cmdline_parse_token_num_t cmd_gso_size_size =
5028 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5031 cmdline_parse_inst_t cmd_gso_size = {
5032 .f = cmd_gso_size_parsed,
5034 .help_str = "set gso segsz <length>",
5036 (void *)&cmd_gso_size_set,
5037 (void *)&cmd_gso_size_keyword,
5038 (void *)&cmd_gso_size_segsz,
5039 (void *)&cmd_gso_size_size,
5044 /* *** SHOW GSO CONFIGURATION *** */
5045 struct cmd_gso_show_result {
5046 cmdline_fixed_string_t cmd_show;
5047 cmdline_fixed_string_t cmd_port;
5048 cmdline_fixed_string_t cmd_keyword;
5053 cmd_gso_show_parsed(void *parsed_result,
5054 __attribute__((unused)) struct cmdline *cl,
5055 __attribute__((unused)) void *data)
5057 struct cmd_gso_show_result *res = parsed_result;
5059 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5060 printf("invalid port id %u\n", res->cmd_pid);
5063 if (!strcmp(res->cmd_keyword, "gso")) {
5064 if (gso_ports[res->cmd_pid].enable) {
5065 printf("Max GSO'd packet size: %uB\n"
5066 "Supported GSO types: TCP/IPv4, "
5067 "UDP/IPv4, VxLAN with inner "
5068 "TCP/IPv4 packet, GRE with inner "
5069 "TCP/IPv4 packet\n",
5070 gso_max_segment_size);
5072 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5076 cmdline_parse_token_string_t cmd_gso_show_show =
5077 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5079 cmdline_parse_token_string_t cmd_gso_show_port =
5080 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5082 cmdline_parse_token_string_t cmd_gso_show_keyword =
5083 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5084 cmd_keyword, "gso");
5085 cmdline_parse_token_num_t cmd_gso_show_pid =
5086 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5089 cmdline_parse_inst_t cmd_gso_show = {
5090 .f = cmd_gso_show_parsed,
5092 .help_str = "show port <port_id> gso",
5094 (void *)&cmd_gso_show_show,
5095 (void *)&cmd_gso_show_port,
5096 (void *)&cmd_gso_show_pid,
5097 (void *)&cmd_gso_show_keyword,
5102 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5103 struct cmd_set_flush_rx {
5104 cmdline_fixed_string_t set;
5105 cmdline_fixed_string_t flush_rx;
5106 cmdline_fixed_string_t mode;
5110 cmd_set_flush_rx_parsed(void *parsed_result,
5111 __attribute__((unused)) struct cmdline *cl,
5112 __attribute__((unused)) void *data)
5114 struct cmd_set_flush_rx *res = parsed_result;
5115 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5118 cmdline_parse_token_string_t cmd_setflushrx_set =
5119 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5121 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5122 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5123 flush_rx, "flush_rx");
5124 cmdline_parse_token_string_t cmd_setflushrx_mode =
5125 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5129 cmdline_parse_inst_t cmd_set_flush_rx = {
5130 .f = cmd_set_flush_rx_parsed,
5131 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5134 (void *)&cmd_setflushrx_set,
5135 (void *)&cmd_setflushrx_flush_rx,
5136 (void *)&cmd_setflushrx_mode,
5141 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5142 struct cmd_set_link_check {
5143 cmdline_fixed_string_t set;
5144 cmdline_fixed_string_t link_check;
5145 cmdline_fixed_string_t mode;
5149 cmd_set_link_check_parsed(void *parsed_result,
5150 __attribute__((unused)) struct cmdline *cl,
5151 __attribute__((unused)) void *data)
5153 struct cmd_set_link_check *res = parsed_result;
5154 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5157 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5158 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5160 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5161 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5162 link_check, "link_check");
5163 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5164 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5168 cmdline_parse_inst_t cmd_set_link_check = {
5169 .f = cmd_set_link_check_parsed,
5170 .help_str = "set link_check on|off: Enable/Disable link status check "
5171 "when starting/stopping a port",
5174 (void *)&cmd_setlinkcheck_set,
5175 (void *)&cmd_setlinkcheck_link_check,
5176 (void *)&cmd_setlinkcheck_mode,
5181 /* *** SET NIC BYPASS MODE *** */
5182 struct cmd_set_bypass_mode_result {
5183 cmdline_fixed_string_t set;
5184 cmdline_fixed_string_t bypass;
5185 cmdline_fixed_string_t mode;
5186 cmdline_fixed_string_t value;
5191 cmd_set_bypass_mode_parsed(void *parsed_result,
5192 __attribute__((unused)) struct cmdline *cl,
5193 __attribute__((unused)) void *data)
5195 struct cmd_set_bypass_mode_result *res = parsed_result;
5196 portid_t port_id = res->port_id;
5197 int32_t rc = -EINVAL;
5199 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5200 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5202 if (!strcmp(res->value, "bypass"))
5203 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5204 else if (!strcmp(res->value, "isolate"))
5205 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5207 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5209 /* Set the bypass mode for the relevant port. */
5210 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5213 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5216 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5217 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5219 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5220 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5222 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5223 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5225 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5226 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5227 value, "normal#bypass#isolate");
5228 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5229 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5232 cmdline_parse_inst_t cmd_set_bypass_mode = {
5233 .f = cmd_set_bypass_mode_parsed,
5234 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5235 "Set the NIC bypass mode for port_id",
5238 (void *)&cmd_setbypass_mode_set,
5239 (void *)&cmd_setbypass_mode_bypass,
5240 (void *)&cmd_setbypass_mode_mode,
5241 (void *)&cmd_setbypass_mode_value,
5242 (void *)&cmd_setbypass_mode_port,
5247 /* *** SET NIC BYPASS EVENT *** */
5248 struct cmd_set_bypass_event_result {
5249 cmdline_fixed_string_t set;
5250 cmdline_fixed_string_t bypass;
5251 cmdline_fixed_string_t event;
5252 cmdline_fixed_string_t event_value;
5253 cmdline_fixed_string_t mode;
5254 cmdline_fixed_string_t mode_value;
5259 cmd_set_bypass_event_parsed(void *parsed_result,
5260 __attribute__((unused)) struct cmdline *cl,
5261 __attribute__((unused)) void *data)
5263 int32_t rc = -EINVAL;
5264 struct cmd_set_bypass_event_result *res = parsed_result;
5265 portid_t port_id = res->port_id;
5267 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5268 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5269 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5271 if (!strcmp(res->event_value, "timeout"))
5272 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5273 else if (!strcmp(res->event_value, "os_on"))
5274 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5275 else if (!strcmp(res->event_value, "os_off"))
5276 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5277 else if (!strcmp(res->event_value, "power_on"))
5278 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5279 else if (!strcmp(res->event_value, "power_off"))
5280 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5282 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5284 if (!strcmp(res->mode_value, "bypass"))
5285 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5286 else if (!strcmp(res->mode_value, "isolate"))
5287 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5289 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5291 /* Set the watchdog timeout. */
5292 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5295 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5296 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5300 printf("Failed to set timeout value %u "
5301 "for port %d, errto code: %d.\n",
5302 bypass_timeout, port_id, rc);
5306 /* Set the bypass event to transition to bypass mode. */
5307 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5312 printf("\t Failed to set bypass event for port = %d.\n",
5316 cmdline_parse_token_string_t cmd_setbypass_event_set =
5317 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5319 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5320 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5322 cmdline_parse_token_string_t cmd_setbypass_event_event =
5323 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5325 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5326 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5327 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5328 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5329 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5331 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5332 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5333 mode_value, "normal#bypass#isolate");
5334 cmdline_parse_token_num_t cmd_setbypass_event_port =
5335 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5338 cmdline_parse_inst_t cmd_set_bypass_event = {
5339 .f = cmd_set_bypass_event_parsed,
5340 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5341 "power_off mode normal|bypass|isolate <port_id>: "
5342 "Set the NIC bypass event mode for port_id",
5345 (void *)&cmd_setbypass_event_set,
5346 (void *)&cmd_setbypass_event_bypass,
5347 (void *)&cmd_setbypass_event_event,
5348 (void *)&cmd_setbypass_event_event_value,
5349 (void *)&cmd_setbypass_event_mode,
5350 (void *)&cmd_setbypass_event_mode_value,
5351 (void *)&cmd_setbypass_event_port,
5357 /* *** SET NIC BYPASS TIMEOUT *** */
5358 struct cmd_set_bypass_timeout_result {
5359 cmdline_fixed_string_t set;
5360 cmdline_fixed_string_t bypass;
5361 cmdline_fixed_string_t timeout;
5362 cmdline_fixed_string_t value;
5366 cmd_set_bypass_timeout_parsed(void *parsed_result,
5367 __attribute__((unused)) struct cmdline *cl,
5368 __attribute__((unused)) void *data)
5370 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5372 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5373 if (!strcmp(res->value, "1.5"))
5374 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5375 else if (!strcmp(res->value, "2"))
5376 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5377 else if (!strcmp(res->value, "3"))
5378 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5379 else if (!strcmp(res->value, "4"))
5380 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5381 else if (!strcmp(res->value, "8"))
5382 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5383 else if (!strcmp(res->value, "16"))
5384 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5385 else if (!strcmp(res->value, "32"))
5386 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5388 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5392 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5393 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5395 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5396 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5398 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5399 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5400 timeout, "timeout");
5401 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5402 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5403 value, "0#1.5#2#3#4#8#16#32");
5405 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5406 .f = cmd_set_bypass_timeout_parsed,
5407 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5408 "Set the NIC bypass watchdog timeout in seconds",
5411 (void *)&cmd_setbypass_timeout_set,
5412 (void *)&cmd_setbypass_timeout_bypass,
5413 (void *)&cmd_setbypass_timeout_timeout,
5414 (void *)&cmd_setbypass_timeout_value,
5419 /* *** SHOW NIC BYPASS MODE *** */
5420 struct cmd_show_bypass_config_result {
5421 cmdline_fixed_string_t show;
5422 cmdline_fixed_string_t bypass;
5423 cmdline_fixed_string_t config;
5428 cmd_show_bypass_config_parsed(void *parsed_result,
5429 __attribute__((unused)) struct cmdline *cl,
5430 __attribute__((unused)) void *data)
5432 struct cmd_show_bypass_config_result *res = parsed_result;
5433 portid_t port_id = res->port_id;
5435 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5436 uint32_t event_mode;
5437 uint32_t bypass_mode;
5438 uint32_t timeout = bypass_timeout;
5441 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5442 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5443 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5444 {"UNKNOWN", "normal", "bypass", "isolate"};
5445 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5452 int num_events = (sizeof events) / (sizeof events[0]);
5454 /* Display the bypass mode.*/
5455 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5456 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5460 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5461 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5463 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5466 /* Display the bypass timeout.*/
5467 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5468 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5470 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5472 /* Display the bypass events and associated modes. */
5473 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5475 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5476 printf("\tFailed to get bypass mode for event = %s\n",
5479 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5480 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5482 printf("\tbypass event: %-16s = %s\n", events[i],
5488 printf("\tFailed to get bypass configuration for port = %d\n",
5492 cmdline_parse_token_string_t cmd_showbypass_config_show =
5493 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5495 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5496 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5498 cmdline_parse_token_string_t cmd_showbypass_config_config =
5499 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5501 cmdline_parse_token_num_t cmd_showbypass_config_port =
5502 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5505 cmdline_parse_inst_t cmd_show_bypass_config = {
5506 .f = cmd_show_bypass_config_parsed,
5507 .help_str = "show bypass config <port_id>: "
5508 "Show the NIC bypass config for port_id",
5511 (void *)&cmd_showbypass_config_show,
5512 (void *)&cmd_showbypass_config_bypass,
5513 (void *)&cmd_showbypass_config_config,
5514 (void *)&cmd_showbypass_config_port,
5519 #ifdef RTE_LIBRTE_PMD_BOND
5520 /* *** SET BONDING MODE *** */
5521 struct cmd_set_bonding_mode_result {
5522 cmdline_fixed_string_t set;
5523 cmdline_fixed_string_t bonding;
5524 cmdline_fixed_string_t mode;
5529 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5530 __attribute__((unused)) struct cmdline *cl,
5531 __attribute__((unused)) void *data)
5533 struct cmd_set_bonding_mode_result *res = parsed_result;
5534 portid_t port_id = res->port_id;
5536 /* Set the bonding mode for the relevant port. */
5537 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5538 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5541 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5542 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5544 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5545 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5546 bonding, "bonding");
5547 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5548 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5550 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5551 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5553 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5554 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5557 cmdline_parse_inst_t cmd_set_bonding_mode = {
5558 .f = cmd_set_bonding_mode_parsed,
5559 .help_str = "set bonding mode <mode_value> <port_id>: "
5560 "Set the bonding mode for port_id",
5563 (void *) &cmd_setbonding_mode_set,
5564 (void *) &cmd_setbonding_mode_bonding,
5565 (void *) &cmd_setbonding_mode_mode,
5566 (void *) &cmd_setbonding_mode_value,
5567 (void *) &cmd_setbonding_mode_port,
5572 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5573 struct cmd_set_bonding_lacp_dedicated_queues_result {
5574 cmdline_fixed_string_t set;
5575 cmdline_fixed_string_t bonding;
5576 cmdline_fixed_string_t lacp;
5577 cmdline_fixed_string_t dedicated_queues;
5579 cmdline_fixed_string_t mode;
5582 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5583 __attribute__((unused)) struct cmdline *cl,
5584 __attribute__((unused)) void *data)
5586 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5587 portid_t port_id = res->port_id;
5588 struct rte_port *port;
5590 port = &ports[port_id];
5592 /** Check if the port is not started **/
5593 if (port->port_status != RTE_PORT_STOPPED) {
5594 printf("Please stop port %d first\n", port_id);
5598 if (!strcmp(res->mode, "enable")) {
5599 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5600 printf("Dedicate queues for LACP control packets"
5603 printf("Enabling dedicate queues for LACP control "
5604 "packets on port %d failed\n", port_id);
5605 } else if (!strcmp(res->mode, "disable")) {
5606 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5607 printf("Dedicated queues for LACP control packets "
5610 printf("Disabling dedicated queues for LACP control "
5611 "traffic on port %d failed\n", port_id);
5615 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5616 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5618 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5619 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5620 bonding, "bonding");
5621 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5622 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5624 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5625 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5626 dedicated_queues, "dedicated_queues");
5627 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5628 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5630 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5631 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5632 mode, "enable#disable");
5634 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5635 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5636 .help_str = "set bonding lacp dedicated_queues <port_id> "
5638 "Enable/disable dedicated queues for LACP control traffic for port_id",
5641 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5642 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5643 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5644 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5645 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5646 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5651 /* *** SET BALANCE XMIT POLICY *** */
5652 struct cmd_set_bonding_balance_xmit_policy_result {
5653 cmdline_fixed_string_t set;
5654 cmdline_fixed_string_t bonding;
5655 cmdline_fixed_string_t balance_xmit_policy;
5657 cmdline_fixed_string_t policy;
5660 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5661 __attribute__((unused)) struct cmdline *cl,
5662 __attribute__((unused)) void *data)
5664 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5665 portid_t port_id = res->port_id;
5668 if (!strcmp(res->policy, "l2")) {
5669 policy = BALANCE_XMIT_POLICY_LAYER2;
5670 } else if (!strcmp(res->policy, "l23")) {
5671 policy = BALANCE_XMIT_POLICY_LAYER23;
5672 } else if (!strcmp(res->policy, "l34")) {
5673 policy = BALANCE_XMIT_POLICY_LAYER34;
5675 printf("\t Invalid xmit policy selection");
5679 /* Set the bonding mode for the relevant port. */
5680 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5681 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5686 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5687 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5689 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5690 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5691 bonding, "bonding");
5692 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5693 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5694 balance_xmit_policy, "balance_xmit_policy");
5695 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5696 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5698 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5699 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5700 policy, "l2#l23#l34");
5702 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5703 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5704 .help_str = "set bonding balance_xmit_policy <port_id> "
5706 "Set the bonding balance_xmit_policy for port_id",
5709 (void *)&cmd_setbonding_balance_xmit_policy_set,
5710 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5711 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5712 (void *)&cmd_setbonding_balance_xmit_policy_port,
5713 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5718 /* *** SHOW NIC BONDING CONFIGURATION *** */
5719 struct cmd_show_bonding_config_result {
5720 cmdline_fixed_string_t show;
5721 cmdline_fixed_string_t bonding;
5722 cmdline_fixed_string_t config;
5726 static void cmd_show_bonding_config_parsed(void *parsed_result,
5727 __attribute__((unused)) struct cmdline *cl,
5728 __attribute__((unused)) void *data)
5730 struct cmd_show_bonding_config_result *res = parsed_result;
5731 int bonding_mode, agg_mode;
5732 portid_t slaves[RTE_MAX_ETHPORTS];
5733 int num_slaves, num_active_slaves;
5736 portid_t port_id = res->port_id;
5738 /* Display the bonding mode.*/
5739 bonding_mode = rte_eth_bond_mode_get(port_id);
5740 if (bonding_mode < 0) {
5741 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5744 printf("\tBonding mode: %d\n", bonding_mode);
5746 if (bonding_mode == BONDING_MODE_BALANCE) {
5747 int balance_xmit_policy;
5749 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5750 if (balance_xmit_policy < 0) {
5751 printf("\tFailed to get balance xmit policy for port = %d\n",
5755 printf("\tBalance Xmit Policy: ");
5757 switch (balance_xmit_policy) {
5758 case BALANCE_XMIT_POLICY_LAYER2:
5759 printf("BALANCE_XMIT_POLICY_LAYER2");
5761 case BALANCE_XMIT_POLICY_LAYER23:
5762 printf("BALANCE_XMIT_POLICY_LAYER23");
5764 case BALANCE_XMIT_POLICY_LAYER34:
5765 printf("BALANCE_XMIT_POLICY_LAYER34");
5772 if (bonding_mode == BONDING_MODE_8023AD) {
5773 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5774 printf("\tIEEE802.3AD Aggregator Mode: ");
5777 printf("bandwidth");
5789 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5791 if (num_slaves < 0) {
5792 printf("\tFailed to get slave list for port = %d\n", port_id);
5795 if (num_slaves > 0) {
5796 printf("\tSlaves (%d): [", num_slaves);
5797 for (i = 0; i < num_slaves - 1; i++)
5798 printf("%d ", slaves[i]);
5800 printf("%d]\n", slaves[num_slaves - 1]);
5802 printf("\tSlaves: []\n");
5806 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5809 if (num_active_slaves < 0) {
5810 printf("\tFailed to get active slave list for port = %d\n", port_id);
5813 if (num_active_slaves > 0) {
5814 printf("\tActive Slaves (%d): [", num_active_slaves);
5815 for (i = 0; i < num_active_slaves - 1; i++)
5816 printf("%d ", slaves[i]);
5818 printf("%d]\n", slaves[num_active_slaves - 1]);
5821 printf("\tActive Slaves: []\n");
5825 primary_id = rte_eth_bond_primary_get(port_id);
5826 if (primary_id < 0) {
5827 printf("\tFailed to get primary slave for port = %d\n", port_id);
5830 printf("\tPrimary: [%d]\n", primary_id);
5834 cmdline_parse_token_string_t cmd_showbonding_config_show =
5835 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5837 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5838 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5839 bonding, "bonding");
5840 cmdline_parse_token_string_t cmd_showbonding_config_config =
5841 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5843 cmdline_parse_token_num_t cmd_showbonding_config_port =
5844 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5847 cmdline_parse_inst_t cmd_show_bonding_config = {
5848 .f = cmd_show_bonding_config_parsed,
5849 .help_str = "show bonding config <port_id>: "
5850 "Show the bonding config for port_id",
5853 (void *)&cmd_showbonding_config_show,
5854 (void *)&cmd_showbonding_config_bonding,
5855 (void *)&cmd_showbonding_config_config,
5856 (void *)&cmd_showbonding_config_port,
5861 /* *** SET BONDING PRIMARY *** */
5862 struct cmd_set_bonding_primary_result {
5863 cmdline_fixed_string_t set;
5864 cmdline_fixed_string_t bonding;
5865 cmdline_fixed_string_t primary;
5870 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5871 __attribute__((unused)) struct cmdline *cl,
5872 __attribute__((unused)) void *data)
5874 struct cmd_set_bonding_primary_result *res = parsed_result;
5875 portid_t master_port_id = res->port_id;
5876 portid_t slave_port_id = res->slave_id;
5878 /* Set the primary slave for a bonded device. */
5879 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5880 printf("\t Failed to set primary slave for port = %d.\n",
5887 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5888 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5890 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5891 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5892 bonding, "bonding");
5893 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5894 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5895 primary, "primary");
5896 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5897 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5899 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5900 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5903 cmdline_parse_inst_t cmd_set_bonding_primary = {
5904 .f = cmd_set_bonding_primary_parsed,
5905 .help_str = "set bonding primary <slave_id> <port_id>: "
5906 "Set the primary slave for port_id",
5909 (void *)&cmd_setbonding_primary_set,
5910 (void *)&cmd_setbonding_primary_bonding,
5911 (void *)&cmd_setbonding_primary_primary,
5912 (void *)&cmd_setbonding_primary_slave,
5913 (void *)&cmd_setbonding_primary_port,
5918 /* *** ADD SLAVE *** */
5919 struct cmd_add_bonding_slave_result {
5920 cmdline_fixed_string_t add;
5921 cmdline_fixed_string_t bonding;
5922 cmdline_fixed_string_t slave;
5927 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5928 __attribute__((unused)) struct cmdline *cl,
5929 __attribute__((unused)) void *data)
5931 struct cmd_add_bonding_slave_result *res = parsed_result;
5932 portid_t master_port_id = res->port_id;
5933 portid_t slave_port_id = res->slave_id;
5935 /* add the slave for a bonded device. */
5936 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5937 printf("\t Failed to add slave %d to master port = %d.\n",
5938 slave_port_id, master_port_id);
5942 set_port_slave_flag(slave_port_id);
5945 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5946 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5948 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5949 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5950 bonding, "bonding");
5951 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5952 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5954 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5955 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5957 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5958 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5961 cmdline_parse_inst_t cmd_add_bonding_slave = {
5962 .f = cmd_add_bonding_slave_parsed,
5963 .help_str = "add bonding slave <slave_id> <port_id>: "
5964 "Add a slave device to a bonded device",
5967 (void *)&cmd_addbonding_slave_add,
5968 (void *)&cmd_addbonding_slave_bonding,
5969 (void *)&cmd_addbonding_slave_slave,
5970 (void *)&cmd_addbonding_slave_slaveid,
5971 (void *)&cmd_addbonding_slave_port,
5976 /* *** REMOVE SLAVE *** */
5977 struct cmd_remove_bonding_slave_result {
5978 cmdline_fixed_string_t remove;
5979 cmdline_fixed_string_t bonding;
5980 cmdline_fixed_string_t slave;
5985 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5986 __attribute__((unused)) struct cmdline *cl,
5987 __attribute__((unused)) void *data)
5989 struct cmd_remove_bonding_slave_result *res = parsed_result;
5990 portid_t master_port_id = res->port_id;
5991 portid_t slave_port_id = res->slave_id;
5993 /* remove the slave from a bonded device. */
5994 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5995 printf("\t Failed to remove slave %d from master port = %d.\n",
5996 slave_port_id, master_port_id);
6000 clear_port_slave_flag(slave_port_id);
6003 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6004 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6006 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6007 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6008 bonding, "bonding");
6009 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6010 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6012 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6013 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6015 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6016 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6019 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6020 .f = cmd_remove_bonding_slave_parsed,
6021 .help_str = "remove bonding slave <slave_id> <port_id>: "
6022 "Remove a slave device from a bonded device",
6025 (void *)&cmd_removebonding_slave_remove,
6026 (void *)&cmd_removebonding_slave_bonding,
6027 (void *)&cmd_removebonding_slave_slave,
6028 (void *)&cmd_removebonding_slave_slaveid,
6029 (void *)&cmd_removebonding_slave_port,
6034 /* *** CREATE BONDED DEVICE *** */
6035 struct cmd_create_bonded_device_result {
6036 cmdline_fixed_string_t create;
6037 cmdline_fixed_string_t bonded;
6038 cmdline_fixed_string_t device;
6043 static int bond_dev_num = 0;
6045 static void cmd_create_bonded_device_parsed(void *parsed_result,
6046 __attribute__((unused)) struct cmdline *cl,
6047 __attribute__((unused)) void *data)
6049 struct cmd_create_bonded_device_result *res = parsed_result;
6050 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6053 if (test_done == 0) {
6054 printf("Please stop forwarding first\n");
6058 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6061 /* Create a new bonded device. */
6062 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6064 printf("\t Failed to create bonded device.\n");
6067 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6070 /* Update number of ports */
6071 nb_ports = rte_eth_dev_count_avail();
6072 reconfig(port_id, res->socket);
6073 rte_eth_promiscuous_enable(port_id);
6074 ports[port_id].need_setup = 0;
6075 ports[port_id].port_status = RTE_PORT_STOPPED;
6080 cmdline_parse_token_string_t cmd_createbonded_device_create =
6081 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6083 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6084 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6086 cmdline_parse_token_string_t cmd_createbonded_device_device =
6087 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6089 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6090 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6092 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6093 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6096 cmdline_parse_inst_t cmd_create_bonded_device = {
6097 .f = cmd_create_bonded_device_parsed,
6098 .help_str = "create bonded device <mode> <socket>: "
6099 "Create a new bonded device with specific bonding mode and socket",
6102 (void *)&cmd_createbonded_device_create,
6103 (void *)&cmd_createbonded_device_bonded,
6104 (void *)&cmd_createbonded_device_device,
6105 (void *)&cmd_createbonded_device_mode,
6106 (void *)&cmd_createbonded_device_socket,
6111 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6112 struct cmd_set_bond_mac_addr_result {
6113 cmdline_fixed_string_t set;
6114 cmdline_fixed_string_t bonding;
6115 cmdline_fixed_string_t mac_addr;
6117 struct rte_ether_addr address;
6120 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6121 __attribute__((unused)) struct cmdline *cl,
6122 __attribute__((unused)) void *data)
6124 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6127 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6130 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6132 /* check the return value and print it if is < 0 */
6134 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6137 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6138 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6139 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6140 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6142 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6143 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6145 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6146 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6148 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6149 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6151 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6152 .f = cmd_set_bond_mac_addr_parsed,
6154 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6156 (void *)&cmd_set_bond_mac_addr_set,
6157 (void *)&cmd_set_bond_mac_addr_bonding,
6158 (void *)&cmd_set_bond_mac_addr_mac,
6159 (void *)&cmd_set_bond_mac_addr_portnum,
6160 (void *)&cmd_set_bond_mac_addr_addr,
6166 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6167 struct cmd_set_bond_mon_period_result {
6168 cmdline_fixed_string_t set;
6169 cmdline_fixed_string_t bonding;
6170 cmdline_fixed_string_t mon_period;
6175 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6176 __attribute__((unused)) struct cmdline *cl,
6177 __attribute__((unused)) void *data)
6179 struct cmd_set_bond_mon_period_result *res = parsed_result;
6182 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6184 /* check the return value and print it if is < 0 */
6186 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6189 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6190 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6192 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6193 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6194 bonding, "bonding");
6195 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6196 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6197 mon_period, "mon_period");
6198 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6199 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6201 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6202 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6205 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6206 .f = cmd_set_bond_mon_period_parsed,
6208 .help_str = "set bonding mon_period <port_id> <period_ms>",
6210 (void *)&cmd_set_bond_mon_period_set,
6211 (void *)&cmd_set_bond_mon_period_bonding,
6212 (void *)&cmd_set_bond_mon_period_mon_period,
6213 (void *)&cmd_set_bond_mon_period_portnum,
6214 (void *)&cmd_set_bond_mon_period_period_ms,
6221 struct cmd_set_bonding_agg_mode_policy_result {
6222 cmdline_fixed_string_t set;
6223 cmdline_fixed_string_t bonding;
6224 cmdline_fixed_string_t agg_mode;
6226 cmdline_fixed_string_t policy;
6231 cmd_set_bonding_agg_mode(void *parsed_result,
6232 __attribute__((unused)) struct cmdline *cl,
6233 __attribute__((unused)) void *data)
6235 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6236 uint8_t policy = AGG_BANDWIDTH;
6238 if (!strcmp(res->policy, "bandwidth"))
6239 policy = AGG_BANDWIDTH;
6240 else if (!strcmp(res->policy, "stable"))
6241 policy = AGG_STABLE;
6242 else if (!strcmp(res->policy, "count"))
6245 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6249 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6250 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6252 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6253 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6254 bonding, "bonding");
6256 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6257 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6258 agg_mode, "agg_mode");
6260 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6261 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6264 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6265 TOKEN_STRING_INITIALIZER(
6266 struct cmd_set_bonding_balance_xmit_policy_result,
6267 policy, "stable#bandwidth#count");
6269 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6270 .f = cmd_set_bonding_agg_mode,
6272 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6274 (void *)&cmd_set_bonding_agg_mode_set,
6275 (void *)&cmd_set_bonding_agg_mode_bonding,
6276 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6277 (void *)&cmd_set_bonding_agg_mode_portnum,
6278 (void *)&cmd_set_bonding_agg_mode_policy_string,
6284 #endif /* RTE_LIBRTE_PMD_BOND */
6286 /* *** SET FORWARDING MODE *** */
6287 struct cmd_set_fwd_mode_result {
6288 cmdline_fixed_string_t set;
6289 cmdline_fixed_string_t fwd;
6290 cmdline_fixed_string_t mode;
6293 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6294 __attribute__((unused)) struct cmdline *cl,
6295 __attribute__((unused)) void *data)
6297 struct cmd_set_fwd_mode_result *res = parsed_result;
6300 set_pkt_forwarding_mode(res->mode);
6303 cmdline_parse_token_string_t cmd_setfwd_set =
6304 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6305 cmdline_parse_token_string_t cmd_setfwd_fwd =
6306 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6307 cmdline_parse_token_string_t cmd_setfwd_mode =
6308 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6309 "" /* defined at init */);
6311 cmdline_parse_inst_t cmd_set_fwd_mode = {
6312 .f = cmd_set_fwd_mode_parsed,
6314 .help_str = NULL, /* defined at init */
6316 (void *)&cmd_setfwd_set,
6317 (void *)&cmd_setfwd_fwd,
6318 (void *)&cmd_setfwd_mode,
6323 static void cmd_set_fwd_mode_init(void)
6326 static char token[128];
6327 static char help[256];
6328 cmdline_parse_token_string_t *token_struct;
6330 modes = list_pkt_forwarding_modes();
6331 snprintf(help, sizeof(help), "set fwd %s: "
6332 "Set packet forwarding mode", modes);
6333 cmd_set_fwd_mode.help_str = help;
6335 /* string token separator is # */
6336 for (c = token; *modes != '\0'; modes++)
6341 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6342 token_struct->string_data.str = token;
6345 /* *** SET RETRY FORWARDING MODE *** */
6346 struct cmd_set_fwd_retry_mode_result {
6347 cmdline_fixed_string_t set;
6348 cmdline_fixed_string_t fwd;
6349 cmdline_fixed_string_t mode;
6350 cmdline_fixed_string_t retry;
6353 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6354 __attribute__((unused)) struct cmdline *cl,
6355 __attribute__((unused)) void *data)
6357 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6360 set_pkt_forwarding_mode(res->mode);
6363 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6364 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6366 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6367 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6369 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6370 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6372 "" /* defined at init */);
6373 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6374 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6377 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6378 .f = cmd_set_fwd_retry_mode_parsed,
6380 .help_str = NULL, /* defined at init */
6382 (void *)&cmd_setfwd_retry_set,
6383 (void *)&cmd_setfwd_retry_fwd,
6384 (void *)&cmd_setfwd_retry_mode,
6385 (void *)&cmd_setfwd_retry_retry,
6390 static void cmd_set_fwd_retry_mode_init(void)
6393 static char token[128];
6394 static char help[256];
6395 cmdline_parse_token_string_t *token_struct;
6397 modes = list_pkt_forwarding_retry_modes();
6398 snprintf(help, sizeof(help), "set fwd %s retry: "
6399 "Set packet forwarding mode with retry", modes);
6400 cmd_set_fwd_retry_mode.help_str = help;
6402 /* string token separator is # */
6403 for (c = token; *modes != '\0'; modes++)
6408 token_struct = (cmdline_parse_token_string_t *)
6409 cmd_set_fwd_retry_mode.tokens[2];
6410 token_struct->string_data.str = token;
6413 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6414 struct cmd_set_burst_tx_retry_result {
6415 cmdline_fixed_string_t set;
6416 cmdline_fixed_string_t burst;
6417 cmdline_fixed_string_t tx;
6418 cmdline_fixed_string_t delay;
6420 cmdline_fixed_string_t retry;
6424 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6425 __attribute__((unused)) struct cmdline *cl,
6426 __attribute__((unused)) void *data)
6428 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6430 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6431 && !strcmp(res->tx, "tx")) {
6432 if (!strcmp(res->delay, "delay"))
6433 burst_tx_delay_time = res->time;
6434 if (!strcmp(res->retry, "retry"))
6435 burst_tx_retry_num = res->retry_num;
6440 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6441 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6442 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6443 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6445 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6446 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6447 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6448 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6449 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6450 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6451 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6452 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6453 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6454 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6456 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6457 .f = cmd_set_burst_tx_retry_parsed,
6458 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6460 (void *)&cmd_set_burst_tx_retry_set,
6461 (void *)&cmd_set_burst_tx_retry_burst,
6462 (void *)&cmd_set_burst_tx_retry_tx,
6463 (void *)&cmd_set_burst_tx_retry_delay,
6464 (void *)&cmd_set_burst_tx_retry_time,
6465 (void *)&cmd_set_burst_tx_retry_retry,
6466 (void *)&cmd_set_burst_tx_retry_retry_num,
6471 /* *** SET PROMISC MODE *** */
6472 struct cmd_set_promisc_mode_result {
6473 cmdline_fixed_string_t set;
6474 cmdline_fixed_string_t promisc;
6475 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6476 uint16_t port_num; /* valid if "allports" argument == 0 */
6477 cmdline_fixed_string_t mode;
6480 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6481 __attribute__((unused)) struct cmdline *cl,
6484 struct cmd_set_promisc_mode_result *res = parsed_result;
6488 if (!strcmp(res->mode, "on"))
6495 RTE_ETH_FOREACH_DEV(i) {
6497 rte_eth_promiscuous_enable(i);
6499 rte_eth_promiscuous_disable(i);
6504 rte_eth_promiscuous_enable(res->port_num);
6506 rte_eth_promiscuous_disable(res->port_num);
6510 cmdline_parse_token_string_t cmd_setpromisc_set =
6511 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6512 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6513 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6515 cmdline_parse_token_string_t cmd_setpromisc_portall =
6516 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6518 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6519 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6521 cmdline_parse_token_string_t cmd_setpromisc_mode =
6522 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6525 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6526 .f = cmd_set_promisc_mode_parsed,
6528 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6530 (void *)&cmd_setpromisc_set,
6531 (void *)&cmd_setpromisc_promisc,
6532 (void *)&cmd_setpromisc_portall,
6533 (void *)&cmd_setpromisc_mode,
6538 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6539 .f = cmd_set_promisc_mode_parsed,
6541 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6543 (void *)&cmd_setpromisc_set,
6544 (void *)&cmd_setpromisc_promisc,
6545 (void *)&cmd_setpromisc_portnum,
6546 (void *)&cmd_setpromisc_mode,
6551 /* *** SET ALLMULTI MODE *** */
6552 struct cmd_set_allmulti_mode_result {
6553 cmdline_fixed_string_t set;
6554 cmdline_fixed_string_t allmulti;
6555 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6556 uint16_t port_num; /* valid if "allports" argument == 0 */
6557 cmdline_fixed_string_t mode;
6560 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6561 __attribute__((unused)) struct cmdline *cl,
6564 struct cmd_set_allmulti_mode_result *res = parsed_result;
6568 if (!strcmp(res->mode, "on"))
6575 RTE_ETH_FOREACH_DEV(i) {
6577 rte_eth_allmulticast_enable(i);
6579 rte_eth_allmulticast_disable(i);
6584 rte_eth_allmulticast_enable(res->port_num);
6586 rte_eth_allmulticast_disable(res->port_num);
6590 cmdline_parse_token_string_t cmd_setallmulti_set =
6591 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6592 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6593 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6595 cmdline_parse_token_string_t cmd_setallmulti_portall =
6596 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6598 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6599 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6601 cmdline_parse_token_string_t cmd_setallmulti_mode =
6602 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6605 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6606 .f = cmd_set_allmulti_mode_parsed,
6608 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6610 (void *)&cmd_setallmulti_set,
6611 (void *)&cmd_setallmulti_allmulti,
6612 (void *)&cmd_setallmulti_portall,
6613 (void *)&cmd_setallmulti_mode,
6618 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6619 .f = cmd_set_allmulti_mode_parsed,
6621 .help_str = "set allmulti <port_id> on|off: "
6622 "Set allmulti mode on port_id",
6624 (void *)&cmd_setallmulti_set,
6625 (void *)&cmd_setallmulti_allmulti,
6626 (void *)&cmd_setallmulti_portnum,
6627 (void *)&cmd_setallmulti_mode,
6632 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6633 struct cmd_link_flow_ctrl_set_result {
6634 cmdline_fixed_string_t set;
6635 cmdline_fixed_string_t flow_ctrl;
6636 cmdline_fixed_string_t rx;
6637 cmdline_fixed_string_t rx_lfc_mode;
6638 cmdline_fixed_string_t tx;
6639 cmdline_fixed_string_t tx_lfc_mode;
6640 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6641 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6642 cmdline_fixed_string_t autoneg_str;
6643 cmdline_fixed_string_t autoneg;
6644 cmdline_fixed_string_t hw_str;
6645 uint32_t high_water;
6646 cmdline_fixed_string_t lw_str;
6648 cmdline_fixed_string_t pt_str;
6649 uint16_t pause_time;
6650 cmdline_fixed_string_t xon_str;
6655 cmdline_parse_token_string_t cmd_lfc_set_set =
6656 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6658 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6659 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6660 flow_ctrl, "flow_ctrl");
6661 cmdline_parse_token_string_t cmd_lfc_set_rx =
6662 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6664 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6665 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6666 rx_lfc_mode, "on#off");
6667 cmdline_parse_token_string_t cmd_lfc_set_tx =
6668 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6670 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6671 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6672 tx_lfc_mode, "on#off");
6673 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6674 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6675 hw_str, "high_water");
6676 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6677 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6678 high_water, UINT32);
6679 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6680 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6681 lw_str, "low_water");
6682 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6683 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6685 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6686 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6687 pt_str, "pause_time");
6688 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6689 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6690 pause_time, UINT16);
6691 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6692 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6693 xon_str, "send_xon");
6694 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6695 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6697 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6698 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6699 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6700 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6701 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6702 mac_ctrl_frame_fwd_mode, "on#off");
6703 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6704 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6705 autoneg_str, "autoneg");
6706 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6707 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6709 cmdline_parse_token_num_t cmd_lfc_set_portid =
6710 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6713 /* forward declaration */
6715 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6718 cmdline_parse_inst_t cmd_link_flow_control_set = {
6719 .f = cmd_link_flow_ctrl_set_parsed,
6721 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6722 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6723 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6725 (void *)&cmd_lfc_set_set,
6726 (void *)&cmd_lfc_set_flow_ctrl,
6727 (void *)&cmd_lfc_set_rx,
6728 (void *)&cmd_lfc_set_rx_mode,
6729 (void *)&cmd_lfc_set_tx,
6730 (void *)&cmd_lfc_set_tx_mode,
6731 (void *)&cmd_lfc_set_high_water,
6732 (void *)&cmd_lfc_set_low_water,
6733 (void *)&cmd_lfc_set_pause_time,
6734 (void *)&cmd_lfc_set_send_xon,
6735 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6736 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6737 (void *)&cmd_lfc_set_autoneg_str,
6738 (void *)&cmd_lfc_set_autoneg,
6739 (void *)&cmd_lfc_set_portid,
6744 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6745 .f = cmd_link_flow_ctrl_set_parsed,
6746 .data = (void *)&cmd_link_flow_control_set_rx,
6747 .help_str = "set flow_ctrl rx on|off <port_id>: "
6748 "Change rx flow control parameter",
6750 (void *)&cmd_lfc_set_set,
6751 (void *)&cmd_lfc_set_flow_ctrl,
6752 (void *)&cmd_lfc_set_rx,
6753 (void *)&cmd_lfc_set_rx_mode,
6754 (void *)&cmd_lfc_set_portid,
6759 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6760 .f = cmd_link_flow_ctrl_set_parsed,
6761 .data = (void *)&cmd_link_flow_control_set_tx,
6762 .help_str = "set flow_ctrl tx on|off <port_id>: "
6763 "Change tx flow control parameter",
6765 (void *)&cmd_lfc_set_set,
6766 (void *)&cmd_lfc_set_flow_ctrl,
6767 (void *)&cmd_lfc_set_tx,
6768 (void *)&cmd_lfc_set_tx_mode,
6769 (void *)&cmd_lfc_set_portid,
6774 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6775 .f = cmd_link_flow_ctrl_set_parsed,
6776 .data = (void *)&cmd_link_flow_control_set_hw,
6777 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6778 "Change high water flow control parameter",
6780 (void *)&cmd_lfc_set_set,
6781 (void *)&cmd_lfc_set_flow_ctrl,
6782 (void *)&cmd_lfc_set_high_water_str,
6783 (void *)&cmd_lfc_set_high_water,
6784 (void *)&cmd_lfc_set_portid,
6789 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6790 .f = cmd_link_flow_ctrl_set_parsed,
6791 .data = (void *)&cmd_link_flow_control_set_lw,
6792 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6793 "Change low water flow control parameter",
6795 (void *)&cmd_lfc_set_set,
6796 (void *)&cmd_lfc_set_flow_ctrl,
6797 (void *)&cmd_lfc_set_low_water_str,
6798 (void *)&cmd_lfc_set_low_water,
6799 (void *)&cmd_lfc_set_portid,
6804 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6805 .f = cmd_link_flow_ctrl_set_parsed,
6806 .data = (void *)&cmd_link_flow_control_set_pt,
6807 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6808 "Change pause time flow control parameter",
6810 (void *)&cmd_lfc_set_set,
6811 (void *)&cmd_lfc_set_flow_ctrl,
6812 (void *)&cmd_lfc_set_pause_time_str,
6813 (void *)&cmd_lfc_set_pause_time,
6814 (void *)&cmd_lfc_set_portid,
6819 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6820 .f = cmd_link_flow_ctrl_set_parsed,
6821 .data = (void *)&cmd_link_flow_control_set_xon,
6822 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6823 "Change send_xon flow control parameter",
6825 (void *)&cmd_lfc_set_set,
6826 (void *)&cmd_lfc_set_flow_ctrl,
6827 (void *)&cmd_lfc_set_send_xon_str,
6828 (void *)&cmd_lfc_set_send_xon,
6829 (void *)&cmd_lfc_set_portid,
6834 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6835 .f = cmd_link_flow_ctrl_set_parsed,
6836 .data = (void *)&cmd_link_flow_control_set_macfwd,
6837 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6838 "Change mac ctrl fwd flow control parameter",
6840 (void *)&cmd_lfc_set_set,
6841 (void *)&cmd_lfc_set_flow_ctrl,
6842 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6843 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6844 (void *)&cmd_lfc_set_portid,
6849 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6850 .f = cmd_link_flow_ctrl_set_parsed,
6851 .data = (void *)&cmd_link_flow_control_set_autoneg,
6852 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6853 "Change autoneg flow control parameter",
6855 (void *)&cmd_lfc_set_set,
6856 (void *)&cmd_lfc_set_flow_ctrl,
6857 (void *)&cmd_lfc_set_autoneg_str,
6858 (void *)&cmd_lfc_set_autoneg,
6859 (void *)&cmd_lfc_set_portid,
6865 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6866 __attribute__((unused)) struct cmdline *cl,
6869 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6870 cmdline_parse_inst_t *cmd = data;
6871 struct rte_eth_fc_conf fc_conf;
6877 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6878 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6879 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6880 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6882 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6883 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6886 /* Partial command line, retrieve current configuration */
6888 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6890 printf("cannot get current flow ctrl parameters, return"
6891 "code = %d\n", ret);
6895 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6896 (fc_conf.mode == RTE_FC_FULL))
6898 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6899 (fc_conf.mode == RTE_FC_FULL))
6903 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6904 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6906 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6907 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6909 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6911 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6912 fc_conf.high_water = res->high_water;
6914 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6915 fc_conf.low_water = res->low_water;
6917 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6918 fc_conf.pause_time = res->pause_time;
6920 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6921 fc_conf.send_xon = res->send_xon;
6923 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6924 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6925 fc_conf.mac_ctrl_frame_fwd = 1;
6927 fc_conf.mac_ctrl_frame_fwd = 0;
6930 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6931 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6933 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6935 printf("bad flow contrl parameter, return code = %d \n", ret);
6938 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6939 struct cmd_priority_flow_ctrl_set_result {
6940 cmdline_fixed_string_t set;
6941 cmdline_fixed_string_t pfc_ctrl;
6942 cmdline_fixed_string_t rx;
6943 cmdline_fixed_string_t rx_pfc_mode;
6944 cmdline_fixed_string_t tx;
6945 cmdline_fixed_string_t tx_pfc_mode;
6946 uint32_t high_water;
6948 uint16_t pause_time;
6954 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6955 __attribute__((unused)) struct cmdline *cl,
6956 __attribute__((unused)) void *data)
6958 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6959 struct rte_eth_pfc_conf pfc_conf;
6960 int rx_fc_enable, tx_fc_enable;
6964 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6965 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6966 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6967 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6969 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6970 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6973 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6974 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6975 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6976 pfc_conf.fc.high_water = res->high_water;
6977 pfc_conf.fc.low_water = res->low_water;
6978 pfc_conf.fc.pause_time = res->pause_time;
6979 pfc_conf.priority = res->priority;
6981 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6983 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6986 cmdline_parse_token_string_t cmd_pfc_set_set =
6987 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6989 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6990 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6991 pfc_ctrl, "pfc_ctrl");
6992 cmdline_parse_token_string_t cmd_pfc_set_rx =
6993 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6995 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6996 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6997 rx_pfc_mode, "on#off");
6998 cmdline_parse_token_string_t cmd_pfc_set_tx =
6999 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7001 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7002 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7003 tx_pfc_mode, "on#off");
7004 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7005 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7006 high_water, UINT32);
7007 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7008 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7010 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7011 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7012 pause_time, UINT16);
7013 cmdline_parse_token_num_t cmd_pfc_set_priority =
7014 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7016 cmdline_parse_token_num_t cmd_pfc_set_portid =
7017 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7020 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7021 .f = cmd_priority_flow_ctrl_set_parsed,
7023 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7024 "<pause_time> <priority> <port_id>: "
7025 "Configure the Ethernet priority flow control",
7027 (void *)&cmd_pfc_set_set,
7028 (void *)&cmd_pfc_set_flow_ctrl,
7029 (void *)&cmd_pfc_set_rx,
7030 (void *)&cmd_pfc_set_rx_mode,
7031 (void *)&cmd_pfc_set_tx,
7032 (void *)&cmd_pfc_set_tx_mode,
7033 (void *)&cmd_pfc_set_high_water,
7034 (void *)&cmd_pfc_set_low_water,
7035 (void *)&cmd_pfc_set_pause_time,
7036 (void *)&cmd_pfc_set_priority,
7037 (void *)&cmd_pfc_set_portid,
7042 /* *** RESET CONFIGURATION *** */
7043 struct cmd_reset_result {
7044 cmdline_fixed_string_t reset;
7045 cmdline_fixed_string_t def;
7048 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
7050 __attribute__((unused)) void *data)
7052 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7053 set_def_fwd_config();
7056 cmdline_parse_token_string_t cmd_reset_set =
7057 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7058 cmdline_parse_token_string_t cmd_reset_def =
7059 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7062 cmdline_parse_inst_t cmd_reset = {
7063 .f = cmd_reset_parsed,
7065 .help_str = "set default: Reset default forwarding configuration",
7067 (void *)&cmd_reset_set,
7068 (void *)&cmd_reset_def,
7073 /* *** START FORWARDING *** */
7074 struct cmd_start_result {
7075 cmdline_fixed_string_t start;
7078 cmdline_parse_token_string_t cmd_start_start =
7079 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7081 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
7082 __attribute__((unused)) struct cmdline *cl,
7083 __attribute__((unused)) void *data)
7085 start_packet_forwarding(0);
7088 cmdline_parse_inst_t cmd_start = {
7089 .f = cmd_start_parsed,
7091 .help_str = "start: Start packet forwarding",
7093 (void *)&cmd_start_start,
7098 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7099 struct cmd_start_tx_first_result {
7100 cmdline_fixed_string_t start;
7101 cmdline_fixed_string_t tx_first;
7105 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
7106 __attribute__((unused)) struct cmdline *cl,
7107 __attribute__((unused)) void *data)
7109 start_packet_forwarding(1);
7112 cmdline_parse_token_string_t cmd_start_tx_first_start =
7113 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7115 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7116 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7117 tx_first, "tx_first");
7119 cmdline_parse_inst_t cmd_start_tx_first = {
7120 .f = cmd_start_tx_first_parsed,
7122 .help_str = "start tx_first: Start packet forwarding, "
7123 "after sending 1 burst of packets",
7125 (void *)&cmd_start_tx_first_start,
7126 (void *)&cmd_start_tx_first_tx_first,
7131 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7132 struct cmd_start_tx_first_n_result {
7133 cmdline_fixed_string_t start;
7134 cmdline_fixed_string_t tx_first;
7139 cmd_start_tx_first_n_parsed(void *parsed_result,
7140 __attribute__((unused)) struct cmdline *cl,
7141 __attribute__((unused)) void *data)
7143 struct cmd_start_tx_first_n_result *res = parsed_result;
7145 start_packet_forwarding(res->tx_num);
7148 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7149 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7151 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7152 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7153 tx_first, "tx_first");
7154 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7155 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7158 cmdline_parse_inst_t cmd_start_tx_first_n = {
7159 .f = cmd_start_tx_first_n_parsed,
7161 .help_str = "start tx_first <num>: "
7162 "packet forwarding, after sending <num> bursts of packets",
7164 (void *)&cmd_start_tx_first_n_start,
7165 (void *)&cmd_start_tx_first_n_tx_first,
7166 (void *)&cmd_start_tx_first_n_tx_num,
7171 /* *** SET LINK UP *** */
7172 struct cmd_set_link_up_result {
7173 cmdline_fixed_string_t set;
7174 cmdline_fixed_string_t link_up;
7175 cmdline_fixed_string_t port;
7179 cmdline_parse_token_string_t cmd_set_link_up_set =
7180 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7181 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7182 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7184 cmdline_parse_token_string_t cmd_set_link_up_port =
7185 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7186 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7187 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7189 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
7190 __attribute__((unused)) struct cmdline *cl,
7191 __attribute__((unused)) void *data)
7193 struct cmd_set_link_up_result *res = parsed_result;
7194 dev_set_link_up(res->port_id);
7197 cmdline_parse_inst_t cmd_set_link_up = {
7198 .f = cmd_set_link_up_parsed,
7200 .help_str = "set link-up port <port id>",
7202 (void *)&cmd_set_link_up_set,
7203 (void *)&cmd_set_link_up_link_up,
7204 (void *)&cmd_set_link_up_port,
7205 (void *)&cmd_set_link_up_port_id,
7210 /* *** SET LINK DOWN *** */
7211 struct cmd_set_link_down_result {
7212 cmdline_fixed_string_t set;
7213 cmdline_fixed_string_t link_down;
7214 cmdline_fixed_string_t port;
7218 cmdline_parse_token_string_t cmd_set_link_down_set =
7219 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7220 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7221 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7223 cmdline_parse_token_string_t cmd_set_link_down_port =
7224 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7225 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7226 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7228 static void cmd_set_link_down_parsed(
7229 __attribute__((unused)) void *parsed_result,
7230 __attribute__((unused)) struct cmdline *cl,
7231 __attribute__((unused)) void *data)
7233 struct cmd_set_link_down_result *res = parsed_result;
7234 dev_set_link_down(res->port_id);
7237 cmdline_parse_inst_t cmd_set_link_down = {
7238 .f = cmd_set_link_down_parsed,
7240 .help_str = "set link-down port <port id>",
7242 (void *)&cmd_set_link_down_set,
7243 (void *)&cmd_set_link_down_link_down,
7244 (void *)&cmd_set_link_down_port,
7245 (void *)&cmd_set_link_down_port_id,
7250 /* *** SHOW CFG *** */
7251 struct cmd_showcfg_result {
7252 cmdline_fixed_string_t show;
7253 cmdline_fixed_string_t cfg;
7254 cmdline_fixed_string_t what;
7257 static void cmd_showcfg_parsed(void *parsed_result,
7258 __attribute__((unused)) struct cmdline *cl,
7259 __attribute__((unused)) void *data)
7261 struct cmd_showcfg_result *res = parsed_result;
7262 if (!strcmp(res->what, "rxtx"))
7263 rxtx_config_display();
7264 else if (!strcmp(res->what, "cores"))
7265 fwd_lcores_config_display();
7266 else if (!strcmp(res->what, "fwd"))
7267 pkt_fwd_config_display(&cur_fwd_config);
7268 else if (!strcmp(res->what, "txpkts"))
7269 show_tx_pkt_segments();
7272 cmdline_parse_token_string_t cmd_showcfg_show =
7273 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7274 cmdline_parse_token_string_t cmd_showcfg_port =
7275 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7276 cmdline_parse_token_string_t cmd_showcfg_what =
7277 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7278 "rxtx#cores#fwd#txpkts");
7280 cmdline_parse_inst_t cmd_showcfg = {
7281 .f = cmd_showcfg_parsed,
7283 .help_str = "show config rxtx|cores|fwd|txpkts",
7285 (void *)&cmd_showcfg_show,
7286 (void *)&cmd_showcfg_port,
7287 (void *)&cmd_showcfg_what,
7292 /* *** SHOW ALL PORT INFO *** */
7293 struct cmd_showportall_result {
7294 cmdline_fixed_string_t show;
7295 cmdline_fixed_string_t port;
7296 cmdline_fixed_string_t what;
7297 cmdline_fixed_string_t all;
7300 static void cmd_showportall_parsed(void *parsed_result,
7301 __attribute__((unused)) struct cmdline *cl,
7302 __attribute__((unused)) void *data)
7306 struct cmd_showportall_result *res = parsed_result;
7307 if (!strcmp(res->show, "clear")) {
7308 if (!strcmp(res->what, "stats"))
7309 RTE_ETH_FOREACH_DEV(i)
7311 else if (!strcmp(res->what, "xstats"))
7312 RTE_ETH_FOREACH_DEV(i)
7313 nic_xstats_clear(i);
7314 } else if (!strcmp(res->what, "info"))
7315 RTE_ETH_FOREACH_DEV(i)
7316 port_infos_display(i);
7317 else if (!strcmp(res->what, "summary")) {
7318 port_summary_header_display();
7319 RTE_ETH_FOREACH_DEV(i)
7320 port_summary_display(i);
7322 else if (!strcmp(res->what, "stats"))
7323 RTE_ETH_FOREACH_DEV(i)
7324 nic_stats_display(i);
7325 else if (!strcmp(res->what, "xstats"))
7326 RTE_ETH_FOREACH_DEV(i)
7327 nic_xstats_display(i);
7328 else if (!strcmp(res->what, "fdir"))
7329 RTE_ETH_FOREACH_DEV(i)
7331 else if (!strcmp(res->what, "stat_qmap"))
7332 RTE_ETH_FOREACH_DEV(i)
7333 nic_stats_mapping_display(i);
7334 else if (!strcmp(res->what, "dcb_tc"))
7335 RTE_ETH_FOREACH_DEV(i)
7336 port_dcb_info_display(i);
7337 else if (!strcmp(res->what, "cap"))
7338 RTE_ETH_FOREACH_DEV(i)
7339 port_offload_cap_display(i);
7342 cmdline_parse_token_string_t cmd_showportall_show =
7343 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7345 cmdline_parse_token_string_t cmd_showportall_port =
7346 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7347 cmdline_parse_token_string_t cmd_showportall_what =
7348 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7349 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7350 cmdline_parse_token_string_t cmd_showportall_all =
7351 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7352 cmdline_parse_inst_t cmd_showportall = {
7353 .f = cmd_showportall_parsed,
7355 .help_str = "show|clear port "
7356 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7358 (void *)&cmd_showportall_show,
7359 (void *)&cmd_showportall_port,
7360 (void *)&cmd_showportall_what,
7361 (void *)&cmd_showportall_all,
7366 /* *** SHOW PORT INFO *** */
7367 struct cmd_showport_result {
7368 cmdline_fixed_string_t show;
7369 cmdline_fixed_string_t port;
7370 cmdline_fixed_string_t what;
7374 static void cmd_showport_parsed(void *parsed_result,
7375 __attribute__((unused)) struct cmdline *cl,
7376 __attribute__((unused)) void *data)
7378 struct cmd_showport_result *res = parsed_result;
7379 if (!strcmp(res->show, "clear")) {
7380 if (!strcmp(res->what, "stats"))
7381 nic_stats_clear(res->portnum);
7382 else if (!strcmp(res->what, "xstats"))
7383 nic_xstats_clear(res->portnum);
7384 } else if (!strcmp(res->what, "info"))
7385 port_infos_display(res->portnum);
7386 else if (!strcmp(res->what, "summary")) {
7387 port_summary_header_display();
7388 port_summary_display(res->portnum);
7390 else if (!strcmp(res->what, "stats"))
7391 nic_stats_display(res->portnum);
7392 else if (!strcmp(res->what, "xstats"))
7393 nic_xstats_display(res->portnum);
7394 else if (!strcmp(res->what, "fdir"))
7395 fdir_get_infos(res->portnum);
7396 else if (!strcmp(res->what, "stat_qmap"))
7397 nic_stats_mapping_display(res->portnum);
7398 else if (!strcmp(res->what, "dcb_tc"))
7399 port_dcb_info_display(res->portnum);
7400 else if (!strcmp(res->what, "cap"))
7401 port_offload_cap_display(res->portnum);
7404 cmdline_parse_token_string_t cmd_showport_show =
7405 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7407 cmdline_parse_token_string_t cmd_showport_port =
7408 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7409 cmdline_parse_token_string_t cmd_showport_what =
7410 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7411 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7412 cmdline_parse_token_num_t cmd_showport_portnum =
7413 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7415 cmdline_parse_inst_t cmd_showport = {
7416 .f = cmd_showport_parsed,
7418 .help_str = "show|clear port "
7419 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7422 (void *)&cmd_showport_show,
7423 (void *)&cmd_showport_port,
7424 (void *)&cmd_showport_what,
7425 (void *)&cmd_showport_portnum,
7430 /* *** SHOW DEVICE INFO *** */
7431 struct cmd_showdevice_result {
7432 cmdline_fixed_string_t show;
7433 cmdline_fixed_string_t device;
7434 cmdline_fixed_string_t what;
7435 cmdline_fixed_string_t identifier;
7438 static void cmd_showdevice_parsed(void *parsed_result,
7439 __attribute__((unused)) struct cmdline *cl,
7440 __attribute__((unused)) void *data)
7442 struct cmd_showdevice_result *res = parsed_result;
7443 if (!strcmp(res->what, "info")) {
7444 if (!strcmp(res->identifier, "all"))
7445 device_infos_display(NULL);
7447 device_infos_display(res->identifier);
7451 cmdline_parse_token_string_t cmd_showdevice_show =
7452 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7454 cmdline_parse_token_string_t cmd_showdevice_device =
7455 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7456 cmdline_parse_token_string_t cmd_showdevice_what =
7457 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7459 cmdline_parse_token_string_t cmd_showdevice_identifier =
7460 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7463 cmdline_parse_inst_t cmd_showdevice = {
7464 .f = cmd_showdevice_parsed,
7466 .help_str = "show device info <identifier>|all",
7468 (void *)&cmd_showdevice_show,
7469 (void *)&cmd_showdevice_device,
7470 (void *)&cmd_showdevice_what,
7471 (void *)&cmd_showdevice_identifier,
7475 /* *** SHOW QUEUE INFO *** */
7476 struct cmd_showqueue_result {
7477 cmdline_fixed_string_t show;
7478 cmdline_fixed_string_t type;
7479 cmdline_fixed_string_t what;
7485 cmd_showqueue_parsed(void *parsed_result,
7486 __attribute__((unused)) struct cmdline *cl,
7487 __attribute__((unused)) void *data)
7489 struct cmd_showqueue_result *res = parsed_result;
7491 if (!strcmp(res->type, "rxq"))
7492 rx_queue_infos_display(res->portnum, res->queuenum);
7493 else if (!strcmp(res->type, "txq"))
7494 tx_queue_infos_display(res->portnum, res->queuenum);
7497 cmdline_parse_token_string_t cmd_showqueue_show =
7498 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7499 cmdline_parse_token_string_t cmd_showqueue_type =
7500 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7501 cmdline_parse_token_string_t cmd_showqueue_what =
7502 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7503 cmdline_parse_token_num_t cmd_showqueue_portnum =
7504 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7505 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7506 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7508 cmdline_parse_inst_t cmd_showqueue = {
7509 .f = cmd_showqueue_parsed,
7511 .help_str = "show rxq|txq info <port_id> <queue_id>",
7513 (void *)&cmd_showqueue_show,
7514 (void *)&cmd_showqueue_type,
7515 (void *)&cmd_showqueue_what,
7516 (void *)&cmd_showqueue_portnum,
7517 (void *)&cmd_showqueue_queuenum,
7522 /* show/clear fwd engine statistics */
7524 cmdline_fixed_string_t action;
7525 cmdline_fixed_string_t fwd;
7526 cmdline_fixed_string_t stats;
7527 cmdline_fixed_string_t all;
7530 cmdline_parse_token_string_t cmd_fwd_action =
7531 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7532 cmdline_parse_token_string_t cmd_fwd_fwd =
7533 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7534 cmdline_parse_token_string_t cmd_fwd_stats =
7535 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7536 cmdline_parse_token_string_t cmd_fwd_all =
7537 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7540 cmd_showfwdall_parsed(void *parsed_result,
7541 __rte_unused struct cmdline *cl,
7542 __rte_unused void *data)
7544 struct fwd_result *res = parsed_result;
7546 if (!strcmp(res->action, "show"))
7547 fwd_stats_display();
7552 static cmdline_parse_inst_t cmd_showfwdall = {
7553 .f = cmd_showfwdall_parsed,
7555 .help_str = "show|clear fwd stats all",
7557 (void *)&cmd_fwd_action,
7558 (void *)&cmd_fwd_fwd,
7559 (void *)&cmd_fwd_stats,
7560 (void *)&cmd_fwd_all,
7565 /* *** READ PORT REGISTER *** */
7566 struct cmd_read_reg_result {
7567 cmdline_fixed_string_t read;
7568 cmdline_fixed_string_t reg;
7574 cmd_read_reg_parsed(void *parsed_result,
7575 __attribute__((unused)) struct cmdline *cl,
7576 __attribute__((unused)) void *data)
7578 struct cmd_read_reg_result *res = parsed_result;
7579 port_reg_display(res->port_id, res->reg_off);
7582 cmdline_parse_token_string_t cmd_read_reg_read =
7583 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7584 cmdline_parse_token_string_t cmd_read_reg_reg =
7585 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7586 cmdline_parse_token_num_t cmd_read_reg_port_id =
7587 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7588 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7589 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7591 cmdline_parse_inst_t cmd_read_reg = {
7592 .f = cmd_read_reg_parsed,
7594 .help_str = "read reg <port_id> <reg_off>",
7596 (void *)&cmd_read_reg_read,
7597 (void *)&cmd_read_reg_reg,
7598 (void *)&cmd_read_reg_port_id,
7599 (void *)&cmd_read_reg_reg_off,
7604 /* *** READ PORT REGISTER BIT FIELD *** */
7605 struct cmd_read_reg_bit_field_result {
7606 cmdline_fixed_string_t read;
7607 cmdline_fixed_string_t regfield;
7615 cmd_read_reg_bit_field_parsed(void *parsed_result,
7616 __attribute__((unused)) struct cmdline *cl,
7617 __attribute__((unused)) void *data)
7619 struct cmd_read_reg_bit_field_result *res = parsed_result;
7620 port_reg_bit_field_display(res->port_id, res->reg_off,
7621 res->bit1_pos, res->bit2_pos);
7624 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7625 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7627 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7628 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7629 regfield, "regfield");
7630 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7631 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7633 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7634 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7636 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7637 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7639 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7640 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7643 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7644 .f = cmd_read_reg_bit_field_parsed,
7646 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7647 "Read register bit field between bit_x and bit_y included",
7649 (void *)&cmd_read_reg_bit_field_read,
7650 (void *)&cmd_read_reg_bit_field_regfield,
7651 (void *)&cmd_read_reg_bit_field_port_id,
7652 (void *)&cmd_read_reg_bit_field_reg_off,
7653 (void *)&cmd_read_reg_bit_field_bit1_pos,
7654 (void *)&cmd_read_reg_bit_field_bit2_pos,
7659 /* *** READ PORT REGISTER BIT *** */
7660 struct cmd_read_reg_bit_result {
7661 cmdline_fixed_string_t read;
7662 cmdline_fixed_string_t regbit;
7669 cmd_read_reg_bit_parsed(void *parsed_result,
7670 __attribute__((unused)) struct cmdline *cl,
7671 __attribute__((unused)) void *data)
7673 struct cmd_read_reg_bit_result *res = parsed_result;
7674 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7677 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7678 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7679 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7680 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7682 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7683 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7684 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7685 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7686 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7687 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7689 cmdline_parse_inst_t cmd_read_reg_bit = {
7690 .f = cmd_read_reg_bit_parsed,
7692 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7694 (void *)&cmd_read_reg_bit_read,
7695 (void *)&cmd_read_reg_bit_regbit,
7696 (void *)&cmd_read_reg_bit_port_id,
7697 (void *)&cmd_read_reg_bit_reg_off,
7698 (void *)&cmd_read_reg_bit_bit_pos,
7703 /* *** WRITE PORT REGISTER *** */
7704 struct cmd_write_reg_result {
7705 cmdline_fixed_string_t write;
7706 cmdline_fixed_string_t reg;
7713 cmd_write_reg_parsed(void *parsed_result,
7714 __attribute__((unused)) struct cmdline *cl,
7715 __attribute__((unused)) void *data)
7717 struct cmd_write_reg_result *res = parsed_result;
7718 port_reg_set(res->port_id, res->reg_off, res->value);
7721 cmdline_parse_token_string_t cmd_write_reg_write =
7722 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7723 cmdline_parse_token_string_t cmd_write_reg_reg =
7724 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7725 cmdline_parse_token_num_t cmd_write_reg_port_id =
7726 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7727 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7728 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7729 cmdline_parse_token_num_t cmd_write_reg_value =
7730 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7732 cmdline_parse_inst_t cmd_write_reg = {
7733 .f = cmd_write_reg_parsed,
7735 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7737 (void *)&cmd_write_reg_write,
7738 (void *)&cmd_write_reg_reg,
7739 (void *)&cmd_write_reg_port_id,
7740 (void *)&cmd_write_reg_reg_off,
7741 (void *)&cmd_write_reg_value,
7746 /* *** WRITE PORT REGISTER BIT FIELD *** */
7747 struct cmd_write_reg_bit_field_result {
7748 cmdline_fixed_string_t write;
7749 cmdline_fixed_string_t regfield;
7758 cmd_write_reg_bit_field_parsed(void *parsed_result,
7759 __attribute__((unused)) struct cmdline *cl,
7760 __attribute__((unused)) void *data)
7762 struct cmd_write_reg_bit_field_result *res = parsed_result;
7763 port_reg_bit_field_set(res->port_id, res->reg_off,
7764 res->bit1_pos, res->bit2_pos, res->value);
7767 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7768 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7770 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7771 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7772 regfield, "regfield");
7773 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7774 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7776 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7777 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7779 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7780 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7782 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7783 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7785 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7786 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7789 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7790 .f = cmd_write_reg_bit_field_parsed,
7792 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7794 "Set register bit field between bit_x and bit_y included",
7796 (void *)&cmd_write_reg_bit_field_write,
7797 (void *)&cmd_write_reg_bit_field_regfield,
7798 (void *)&cmd_write_reg_bit_field_port_id,
7799 (void *)&cmd_write_reg_bit_field_reg_off,
7800 (void *)&cmd_write_reg_bit_field_bit1_pos,
7801 (void *)&cmd_write_reg_bit_field_bit2_pos,
7802 (void *)&cmd_write_reg_bit_field_value,
7807 /* *** WRITE PORT REGISTER BIT *** */
7808 struct cmd_write_reg_bit_result {
7809 cmdline_fixed_string_t write;
7810 cmdline_fixed_string_t regbit;
7818 cmd_write_reg_bit_parsed(void *parsed_result,
7819 __attribute__((unused)) struct cmdline *cl,
7820 __attribute__((unused)) void *data)
7822 struct cmd_write_reg_bit_result *res = parsed_result;
7823 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7826 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7827 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7829 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7830 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7832 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7833 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7834 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7835 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7836 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7837 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7838 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7839 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7841 cmdline_parse_inst_t cmd_write_reg_bit = {
7842 .f = cmd_write_reg_bit_parsed,
7844 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7847 (void *)&cmd_write_reg_bit_write,
7848 (void *)&cmd_write_reg_bit_regbit,
7849 (void *)&cmd_write_reg_bit_port_id,
7850 (void *)&cmd_write_reg_bit_reg_off,
7851 (void *)&cmd_write_reg_bit_bit_pos,
7852 (void *)&cmd_write_reg_bit_value,
7857 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7858 struct cmd_read_rxd_txd_result {
7859 cmdline_fixed_string_t read;
7860 cmdline_fixed_string_t rxd_txd;
7867 cmd_read_rxd_txd_parsed(void *parsed_result,
7868 __attribute__((unused)) struct cmdline *cl,
7869 __attribute__((unused)) void *data)
7871 struct cmd_read_rxd_txd_result *res = parsed_result;
7873 if (!strcmp(res->rxd_txd, "rxd"))
7874 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7875 else if (!strcmp(res->rxd_txd, "txd"))
7876 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7879 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7880 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7881 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7882 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7884 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7885 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7886 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7887 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7888 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7889 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7891 cmdline_parse_inst_t cmd_read_rxd_txd = {
7892 .f = cmd_read_rxd_txd_parsed,
7894 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7896 (void *)&cmd_read_rxd_txd_read,
7897 (void *)&cmd_read_rxd_txd_rxd_txd,
7898 (void *)&cmd_read_rxd_txd_port_id,
7899 (void *)&cmd_read_rxd_txd_queue_id,
7900 (void *)&cmd_read_rxd_txd_desc_id,
7906 struct cmd_quit_result {
7907 cmdline_fixed_string_t quit;
7910 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7912 __attribute__((unused)) void *data)
7917 cmdline_parse_token_string_t cmd_quit_quit =
7918 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7920 cmdline_parse_inst_t cmd_quit = {
7921 .f = cmd_quit_parsed,
7923 .help_str = "quit: Exit application",
7925 (void *)&cmd_quit_quit,
7930 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7931 struct cmd_mac_addr_result {
7932 cmdline_fixed_string_t mac_addr_cmd;
7933 cmdline_fixed_string_t what;
7935 struct rte_ether_addr address;
7938 static void cmd_mac_addr_parsed(void *parsed_result,
7939 __attribute__((unused)) struct cmdline *cl,
7940 __attribute__((unused)) void *data)
7942 struct cmd_mac_addr_result *res = parsed_result;
7945 if (strcmp(res->what, "add") == 0)
7946 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7947 else if (strcmp(res->what, "set") == 0)
7948 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7951 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7953 /* check the return value and print it if is < 0 */
7955 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7959 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7960 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7962 cmdline_parse_token_string_t cmd_mac_addr_what =
7963 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7965 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7966 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7968 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7969 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7971 cmdline_parse_inst_t cmd_mac_addr = {
7972 .f = cmd_mac_addr_parsed,
7974 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7975 "Add/Remove/Set MAC address on port_id",
7977 (void *)&cmd_mac_addr_cmd,
7978 (void *)&cmd_mac_addr_what,
7979 (void *)&cmd_mac_addr_portnum,
7980 (void *)&cmd_mac_addr_addr,
7985 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7986 struct cmd_eth_peer_result {
7987 cmdline_fixed_string_t set;
7988 cmdline_fixed_string_t eth_peer;
7990 cmdline_fixed_string_t peer_addr;
7993 static void cmd_set_eth_peer_parsed(void *parsed_result,
7994 __attribute__((unused)) struct cmdline *cl,
7995 __attribute__((unused)) void *data)
7997 struct cmd_eth_peer_result *res = parsed_result;
7999 if (test_done == 0) {
8000 printf("Please stop forwarding first\n");
8003 if (!strcmp(res->eth_peer, "eth-peer")) {
8004 set_fwd_eth_peer(res->port_id, res->peer_addr);
8008 cmdline_parse_token_string_t cmd_eth_peer_set =
8009 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8010 cmdline_parse_token_string_t cmd_eth_peer =
8011 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8012 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8013 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8014 cmdline_parse_token_string_t cmd_eth_peer_addr =
8015 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8017 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8018 .f = cmd_set_eth_peer_parsed,
8020 .help_str = "set eth-peer <port_id> <peer_mac>",
8022 (void *)&cmd_eth_peer_set,
8023 (void *)&cmd_eth_peer,
8024 (void *)&cmd_eth_peer_port_id,
8025 (void *)&cmd_eth_peer_addr,
8030 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8031 struct cmd_set_qmap_result {
8032 cmdline_fixed_string_t set;
8033 cmdline_fixed_string_t qmap;
8034 cmdline_fixed_string_t what;
8041 cmd_set_qmap_parsed(void *parsed_result,
8042 __attribute__((unused)) struct cmdline *cl,
8043 __attribute__((unused)) void *data)
8045 struct cmd_set_qmap_result *res = parsed_result;
8046 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8048 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8051 cmdline_parse_token_string_t cmd_setqmap_set =
8052 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8054 cmdline_parse_token_string_t cmd_setqmap_qmap =
8055 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8057 cmdline_parse_token_string_t cmd_setqmap_what =
8058 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8060 cmdline_parse_token_num_t cmd_setqmap_portid =
8061 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8063 cmdline_parse_token_num_t cmd_setqmap_queueid =
8064 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8066 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8067 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8070 cmdline_parse_inst_t cmd_set_qmap = {
8071 .f = cmd_set_qmap_parsed,
8073 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8074 "Set statistics mapping value on tx|rx queue_id of port_id",
8076 (void *)&cmd_setqmap_set,
8077 (void *)&cmd_setqmap_qmap,
8078 (void *)&cmd_setqmap_what,
8079 (void *)&cmd_setqmap_portid,
8080 (void *)&cmd_setqmap_queueid,
8081 (void *)&cmd_setqmap_mapvalue,
8086 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8087 struct cmd_set_xstats_hide_zero_result {
8088 cmdline_fixed_string_t keyword;
8089 cmdline_fixed_string_t name;
8090 cmdline_fixed_string_t on_off;
8094 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8095 __attribute__((unused)) struct cmdline *cl,
8096 __attribute__((unused)) void *data)
8098 struct cmd_set_xstats_hide_zero_result *res;
8099 uint16_t on_off = 0;
8101 res = parsed_result;
8102 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8103 set_xstats_hide_zero(on_off);
8106 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8107 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8109 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8110 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8111 name, "xstats-hide-zero");
8112 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8113 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8116 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8117 .f = cmd_set_xstats_hide_zero_parsed,
8119 .help_str = "set xstats-hide-zero on|off",
8121 (void *)&cmd_set_xstats_hide_zero_keyword,
8122 (void *)&cmd_set_xstats_hide_zero_name,
8123 (void *)&cmd_set_xstats_hide_zero_on_off,
8128 /* *** CONFIGURE UNICAST HASH TABLE *** */
8129 struct cmd_set_uc_hash_table {
8130 cmdline_fixed_string_t set;
8131 cmdline_fixed_string_t port;
8133 cmdline_fixed_string_t what;
8134 struct rte_ether_addr address;
8135 cmdline_fixed_string_t mode;
8139 cmd_set_uc_hash_parsed(void *parsed_result,
8140 __attribute__((unused)) struct cmdline *cl,
8141 __attribute__((unused)) void *data)
8144 struct cmd_set_uc_hash_table *res = parsed_result;
8146 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8148 if (strcmp(res->what, "uta") == 0)
8149 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8150 &res->address,(uint8_t)is_on);
8152 printf("bad unicast hash table parameter, return code = %d \n", ret);
8156 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8157 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8159 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8160 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8162 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8163 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8165 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8166 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8168 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8169 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8171 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8172 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8175 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8176 .f = cmd_set_uc_hash_parsed,
8178 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8180 (void *)&cmd_set_uc_hash_set,
8181 (void *)&cmd_set_uc_hash_port,
8182 (void *)&cmd_set_uc_hash_portid,
8183 (void *)&cmd_set_uc_hash_what,
8184 (void *)&cmd_set_uc_hash_mac,
8185 (void *)&cmd_set_uc_hash_mode,
8190 struct cmd_set_uc_all_hash_table {
8191 cmdline_fixed_string_t set;
8192 cmdline_fixed_string_t port;
8194 cmdline_fixed_string_t what;
8195 cmdline_fixed_string_t value;
8196 cmdline_fixed_string_t mode;
8200 cmd_set_uc_all_hash_parsed(void *parsed_result,
8201 __attribute__((unused)) struct cmdline *cl,
8202 __attribute__((unused)) void *data)
8205 struct cmd_set_uc_all_hash_table *res = parsed_result;
8207 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8209 if ((strcmp(res->what, "uta") == 0) &&
8210 (strcmp(res->value, "all") == 0))
8211 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8213 printf("bad unicast hash table parameter,"
8214 "return code = %d \n", ret);
8217 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8218 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8220 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8221 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8223 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8224 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8226 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8227 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8229 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8230 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8232 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8233 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8236 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8237 .f = cmd_set_uc_all_hash_parsed,
8239 .help_str = "set port <port_id> uta all on|off",
8241 (void *)&cmd_set_uc_all_hash_set,
8242 (void *)&cmd_set_uc_all_hash_port,
8243 (void *)&cmd_set_uc_all_hash_portid,
8244 (void *)&cmd_set_uc_all_hash_what,
8245 (void *)&cmd_set_uc_all_hash_value,
8246 (void *)&cmd_set_uc_all_hash_mode,
8251 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8252 struct cmd_set_vf_macvlan_filter {
8253 cmdline_fixed_string_t set;
8254 cmdline_fixed_string_t port;
8256 cmdline_fixed_string_t vf;
8258 struct rte_ether_addr address;
8259 cmdline_fixed_string_t filter_type;
8260 cmdline_fixed_string_t mode;
8264 cmd_set_vf_macvlan_parsed(void *parsed_result,
8265 __attribute__((unused)) struct cmdline *cl,
8266 __attribute__((unused)) void *data)
8269 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8270 struct rte_eth_mac_filter filter;
8272 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8274 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8276 /* set VF MAC filter */
8280 filter.dst_id = res->vf_id;
8282 if (!strcmp(res->filter_type, "exact-mac"))
8283 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8284 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8285 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8286 else if (!strcmp(res->filter_type, "hashmac"))
8287 filter.filter_type = RTE_MAC_HASH_MATCH;
8288 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8289 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8291 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8294 ret = rte_eth_dev_filter_ctrl(res->port_id,
8295 RTE_ETH_FILTER_MACVLAN,
8299 ret = rte_eth_dev_filter_ctrl(res->port_id,
8300 RTE_ETH_FILTER_MACVLAN,
8301 RTE_ETH_FILTER_DELETE,
8305 printf("bad set MAC hash parameter, return code = %d\n", ret);
8309 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8310 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8312 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8313 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8315 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8316 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8318 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8319 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8321 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8322 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8324 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8325 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8327 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8328 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8329 filter_type, "exact-mac#exact-mac-vlan"
8330 "#hashmac#hashmac-vlan");
8331 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8332 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8335 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8336 .f = cmd_set_vf_macvlan_parsed,
8338 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8339 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8340 "Exact match rule: exact match of MAC or MAC and VLAN; "
8341 "hash match rule: hash match of MAC and exact match of VLAN",
8343 (void *)&cmd_set_vf_macvlan_set,
8344 (void *)&cmd_set_vf_macvlan_port,
8345 (void *)&cmd_set_vf_macvlan_portid,
8346 (void *)&cmd_set_vf_macvlan_vf,
8347 (void *)&cmd_set_vf_macvlan_vf_id,
8348 (void *)&cmd_set_vf_macvlan_mac,
8349 (void *)&cmd_set_vf_macvlan_filter_type,
8350 (void *)&cmd_set_vf_macvlan_mode,
8355 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8356 struct cmd_set_vf_traffic {
8357 cmdline_fixed_string_t set;
8358 cmdline_fixed_string_t port;
8360 cmdline_fixed_string_t vf;
8362 cmdline_fixed_string_t what;
8363 cmdline_fixed_string_t mode;
8367 cmd_set_vf_traffic_parsed(void *parsed_result,
8368 __attribute__((unused)) struct cmdline *cl,
8369 __attribute__((unused)) void *data)
8371 struct cmd_set_vf_traffic *res = parsed_result;
8372 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8373 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8375 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8378 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8379 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8381 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8382 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8384 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8385 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8387 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8388 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8390 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8391 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8393 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8394 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8396 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8397 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8400 cmdline_parse_inst_t cmd_set_vf_traffic = {
8401 .f = cmd_set_vf_traffic_parsed,
8403 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8405 (void *)&cmd_setvf_traffic_set,
8406 (void *)&cmd_setvf_traffic_port,
8407 (void *)&cmd_setvf_traffic_portid,
8408 (void *)&cmd_setvf_traffic_vf,
8409 (void *)&cmd_setvf_traffic_vfid,
8410 (void *)&cmd_setvf_traffic_what,
8411 (void *)&cmd_setvf_traffic_mode,
8416 /* *** CONFIGURE VF RECEIVE MODE *** */
8417 struct cmd_set_vf_rxmode {
8418 cmdline_fixed_string_t set;
8419 cmdline_fixed_string_t port;
8421 cmdline_fixed_string_t vf;
8423 cmdline_fixed_string_t what;
8424 cmdline_fixed_string_t mode;
8425 cmdline_fixed_string_t on;
8429 cmd_set_vf_rxmode_parsed(void *parsed_result,
8430 __attribute__((unused)) struct cmdline *cl,
8431 __attribute__((unused)) void *data)
8434 uint16_t vf_rxmode = 0;
8435 struct cmd_set_vf_rxmode *res = parsed_result;
8437 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8438 if (!strcmp(res->what,"rxmode")) {
8439 if (!strcmp(res->mode, "AUPE"))
8440 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8441 else if (!strcmp(res->mode, "ROPE"))
8442 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8443 else if (!strcmp(res->mode, "BAM"))
8444 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8445 else if (!strncmp(res->mode, "MPE",3))
8446 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8449 RTE_SET_USED(is_on);
8451 #ifdef RTE_LIBRTE_IXGBE_PMD
8452 if (ret == -ENOTSUP)
8453 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8454 vf_rxmode, (uint8_t)is_on);
8456 #ifdef RTE_LIBRTE_BNXT_PMD
8457 if (ret == -ENOTSUP)
8458 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8459 vf_rxmode, (uint8_t)is_on);
8462 printf("bad VF receive mode parameter, return code = %d \n",
8466 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8467 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8469 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8470 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8472 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8473 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8475 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8476 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8478 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8479 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8481 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8482 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8484 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8485 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8486 mode, "AUPE#ROPE#BAM#MPE");
8487 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8488 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8491 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8492 .f = cmd_set_vf_rxmode_parsed,
8494 .help_str = "set port <port_id> vf <vf_id> rxmode "
8495 "AUPE|ROPE|BAM|MPE on|off",
8497 (void *)&cmd_set_vf_rxmode_set,
8498 (void *)&cmd_set_vf_rxmode_port,
8499 (void *)&cmd_set_vf_rxmode_portid,
8500 (void *)&cmd_set_vf_rxmode_vf,
8501 (void *)&cmd_set_vf_rxmode_vfid,
8502 (void *)&cmd_set_vf_rxmode_what,
8503 (void *)&cmd_set_vf_rxmode_mode,
8504 (void *)&cmd_set_vf_rxmode_on,
8509 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8510 struct cmd_vf_mac_addr_result {
8511 cmdline_fixed_string_t mac_addr_cmd;
8512 cmdline_fixed_string_t what;
8513 cmdline_fixed_string_t port;
8515 cmdline_fixed_string_t vf;
8517 struct rte_ether_addr address;
8520 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8521 __attribute__((unused)) struct cmdline *cl,
8522 __attribute__((unused)) void *data)
8524 struct cmd_vf_mac_addr_result *res = parsed_result;
8527 if (strcmp(res->what, "add") != 0)
8530 #ifdef RTE_LIBRTE_I40E_PMD
8531 if (ret == -ENOTSUP)
8532 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8535 #ifdef RTE_LIBRTE_BNXT_PMD
8536 if (ret == -ENOTSUP)
8537 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8542 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8546 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8547 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8548 mac_addr_cmd,"mac_addr");
8549 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8550 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8552 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8553 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8555 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8556 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8558 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8559 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8561 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8562 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8564 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8565 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8568 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8569 .f = cmd_vf_mac_addr_parsed,
8571 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8572 "Add MAC address filtering for a VF on port_id",
8574 (void *)&cmd_vf_mac_addr_cmd,
8575 (void *)&cmd_vf_mac_addr_what,
8576 (void *)&cmd_vf_mac_addr_port,
8577 (void *)&cmd_vf_mac_addr_portnum,
8578 (void *)&cmd_vf_mac_addr_vf,
8579 (void *)&cmd_vf_mac_addr_vfnum,
8580 (void *)&cmd_vf_mac_addr_addr,
8585 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8586 struct cmd_vf_rx_vlan_filter {
8587 cmdline_fixed_string_t rx_vlan;
8588 cmdline_fixed_string_t what;
8590 cmdline_fixed_string_t port;
8592 cmdline_fixed_string_t vf;
8597 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8598 __attribute__((unused)) struct cmdline *cl,
8599 __attribute__((unused)) void *data)
8601 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8604 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8606 #ifdef RTE_LIBRTE_IXGBE_PMD
8607 if (ret == -ENOTSUP)
8608 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8609 res->vlan_id, res->vf_mask, is_add);
8611 #ifdef RTE_LIBRTE_I40E_PMD
8612 if (ret == -ENOTSUP)
8613 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8614 res->vlan_id, res->vf_mask, is_add);
8616 #ifdef RTE_LIBRTE_BNXT_PMD
8617 if (ret == -ENOTSUP)
8618 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8619 res->vlan_id, res->vf_mask, is_add);
8626 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8627 res->vlan_id, res->vf_mask);
8630 printf("invalid port_id %d\n", res->port_id);
8633 printf("function not implemented or supported\n");
8636 printf("programming error: (%s)\n", strerror(-ret));
8640 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8641 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8642 rx_vlan, "rx_vlan");
8643 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8644 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8646 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8647 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8649 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8650 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8652 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8653 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8655 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8656 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8658 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8659 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8662 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8663 .f = cmd_vf_rx_vlan_filter_parsed,
8665 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8666 "(vf_mask = hexadecimal VF mask)",
8668 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8669 (void *)&cmd_vf_rx_vlan_filter_what,
8670 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8671 (void *)&cmd_vf_rx_vlan_filter_port,
8672 (void *)&cmd_vf_rx_vlan_filter_portid,
8673 (void *)&cmd_vf_rx_vlan_filter_vf,
8674 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8679 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8680 struct cmd_queue_rate_limit_result {
8681 cmdline_fixed_string_t set;
8682 cmdline_fixed_string_t port;
8684 cmdline_fixed_string_t queue;
8686 cmdline_fixed_string_t rate;
8690 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8691 __attribute__((unused)) struct cmdline *cl,
8692 __attribute__((unused)) void *data)
8694 struct cmd_queue_rate_limit_result *res = parsed_result;
8697 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8698 && (strcmp(res->queue, "queue") == 0)
8699 && (strcmp(res->rate, "rate") == 0))
8700 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8703 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8707 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8708 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8710 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8711 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8713 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8714 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8716 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8717 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8719 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8720 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8722 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8723 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8725 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8726 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8729 cmdline_parse_inst_t cmd_queue_rate_limit = {
8730 .f = cmd_queue_rate_limit_parsed,
8732 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8733 "Set rate limit for a queue on port_id",
8735 (void *)&cmd_queue_rate_limit_set,
8736 (void *)&cmd_queue_rate_limit_port,
8737 (void *)&cmd_queue_rate_limit_portnum,
8738 (void *)&cmd_queue_rate_limit_queue,
8739 (void *)&cmd_queue_rate_limit_queuenum,
8740 (void *)&cmd_queue_rate_limit_rate,
8741 (void *)&cmd_queue_rate_limit_ratenum,
8746 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8747 struct cmd_vf_rate_limit_result {
8748 cmdline_fixed_string_t set;
8749 cmdline_fixed_string_t port;
8751 cmdline_fixed_string_t vf;
8753 cmdline_fixed_string_t rate;
8755 cmdline_fixed_string_t q_msk;
8759 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8760 __attribute__((unused)) struct cmdline *cl,
8761 __attribute__((unused)) void *data)
8763 struct cmd_vf_rate_limit_result *res = parsed_result;
8766 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8767 && (strcmp(res->vf, "vf") == 0)
8768 && (strcmp(res->rate, "rate") == 0)
8769 && (strcmp(res->q_msk, "queue_mask") == 0))
8770 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8771 res->rate_num, res->q_msk_val);
8773 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8777 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8778 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8780 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8781 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8783 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8784 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8786 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8787 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8789 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8790 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8792 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8793 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8795 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8796 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8798 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8799 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8800 q_msk, "queue_mask");
8801 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8802 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8805 cmdline_parse_inst_t cmd_vf_rate_limit = {
8806 .f = cmd_vf_rate_limit_parsed,
8808 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8809 "queue_mask <queue_mask_value>: "
8810 "Set rate limit for queues of VF on port_id",
8812 (void *)&cmd_vf_rate_limit_set,
8813 (void *)&cmd_vf_rate_limit_port,
8814 (void *)&cmd_vf_rate_limit_portnum,
8815 (void *)&cmd_vf_rate_limit_vf,
8816 (void *)&cmd_vf_rate_limit_vfnum,
8817 (void *)&cmd_vf_rate_limit_rate,
8818 (void *)&cmd_vf_rate_limit_ratenum,
8819 (void *)&cmd_vf_rate_limit_q_msk,
8820 (void *)&cmd_vf_rate_limit_q_msk_val,
8825 /* *** ADD TUNNEL FILTER OF A PORT *** */
8826 struct cmd_tunnel_filter_result {
8827 cmdline_fixed_string_t cmd;
8828 cmdline_fixed_string_t what;
8830 struct rte_ether_addr outer_mac;
8831 struct rte_ether_addr inner_mac;
8832 cmdline_ipaddr_t ip_value;
8833 uint16_t inner_vlan;
8834 cmdline_fixed_string_t tunnel_type;
8835 cmdline_fixed_string_t filter_type;
8841 cmd_tunnel_filter_parsed(void *parsed_result,
8842 __attribute__((unused)) struct cmdline *cl,
8843 __attribute__((unused)) void *data)
8845 struct cmd_tunnel_filter_result *res = parsed_result;
8846 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8849 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8851 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8852 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8853 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8855 if (res->ip_value.family == AF_INET) {
8856 tunnel_filter_conf.ip_addr.ipv4_addr =
8857 res->ip_value.addr.ipv4.s_addr;
8858 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8860 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8861 &(res->ip_value.addr.ipv6),
8862 sizeof(struct in6_addr));
8863 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8866 if (!strcmp(res->filter_type, "imac-ivlan"))
8867 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8868 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8869 tunnel_filter_conf.filter_type =
8870 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8871 else if (!strcmp(res->filter_type, "imac-tenid"))
8872 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8873 else if (!strcmp(res->filter_type, "imac"))
8874 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8875 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8876 tunnel_filter_conf.filter_type =
8877 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8878 else if (!strcmp(res->filter_type, "oip"))
8879 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8880 else if (!strcmp(res->filter_type, "iip"))
8881 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8883 printf("The filter type is not supported");
8887 if (!strcmp(res->tunnel_type, "vxlan"))
8888 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8889 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
8890 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
8891 else if (!strcmp(res->tunnel_type, "nvgre"))
8892 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8893 else if (!strcmp(res->tunnel_type, "ipingre"))
8894 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8896 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8900 tunnel_filter_conf.tenant_id = res->tenant_id;
8901 tunnel_filter_conf.queue_id = res->queue_num;
8902 if (!strcmp(res->what, "add"))
8903 ret = rte_eth_dev_filter_ctrl(res->port_id,
8904 RTE_ETH_FILTER_TUNNEL,
8906 &tunnel_filter_conf);
8908 ret = rte_eth_dev_filter_ctrl(res->port_id,
8909 RTE_ETH_FILTER_TUNNEL,
8910 RTE_ETH_FILTER_DELETE,
8911 &tunnel_filter_conf);
8913 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8917 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8918 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8919 cmd, "tunnel_filter");
8920 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8921 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8923 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8924 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8926 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8927 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8929 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8930 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8932 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8933 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8934 inner_vlan, UINT16);
8935 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8936 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8938 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8939 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8940 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
8942 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8943 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8944 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8945 "imac#omac-imac-tenid");
8946 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8947 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8949 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8950 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8953 cmdline_parse_inst_t cmd_tunnel_filter = {
8954 .f = cmd_tunnel_filter_parsed,
8956 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8957 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8958 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8959 "<queue_id>: Add/Rm tunnel filter of a port",
8961 (void *)&cmd_tunnel_filter_cmd,
8962 (void *)&cmd_tunnel_filter_what,
8963 (void *)&cmd_tunnel_filter_port_id,
8964 (void *)&cmd_tunnel_filter_outer_mac,
8965 (void *)&cmd_tunnel_filter_inner_mac,
8966 (void *)&cmd_tunnel_filter_ip_value,
8967 (void *)&cmd_tunnel_filter_innner_vlan,
8968 (void *)&cmd_tunnel_filter_tunnel_type,
8969 (void *)&cmd_tunnel_filter_filter_type,
8970 (void *)&cmd_tunnel_filter_tenant_id,
8971 (void *)&cmd_tunnel_filter_queue_num,
8976 /* *** CONFIGURE TUNNEL UDP PORT *** */
8977 struct cmd_tunnel_udp_config {
8978 cmdline_fixed_string_t cmd;
8979 cmdline_fixed_string_t what;
8985 cmd_tunnel_udp_config_parsed(void *parsed_result,
8986 __attribute__((unused)) struct cmdline *cl,
8987 __attribute__((unused)) void *data)
8989 struct cmd_tunnel_udp_config *res = parsed_result;
8990 struct rte_eth_udp_tunnel tunnel_udp;
8993 tunnel_udp.udp_port = res->udp_port;
8995 if (!strcmp(res->cmd, "rx_vxlan_port"))
8996 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8998 if (!strcmp(res->what, "add"))
8999 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9002 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9006 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9009 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9010 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9011 cmd, "rx_vxlan_port");
9012 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9013 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9015 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9016 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9018 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9019 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9022 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9023 .f = cmd_tunnel_udp_config_parsed,
9025 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9026 "Add/Remove a tunneling UDP port filter",
9028 (void *)&cmd_tunnel_udp_config_cmd,
9029 (void *)&cmd_tunnel_udp_config_what,
9030 (void *)&cmd_tunnel_udp_config_udp_port,
9031 (void *)&cmd_tunnel_udp_config_port_id,
9036 struct cmd_config_tunnel_udp_port {
9037 cmdline_fixed_string_t port;
9038 cmdline_fixed_string_t config;
9040 cmdline_fixed_string_t udp_tunnel_port;
9041 cmdline_fixed_string_t action;
9042 cmdline_fixed_string_t tunnel_type;
9047 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9048 __attribute__((unused)) struct cmdline *cl,
9049 __attribute__((unused)) void *data)
9051 struct cmd_config_tunnel_udp_port *res = parsed_result;
9052 struct rte_eth_udp_tunnel tunnel_udp;
9055 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9058 tunnel_udp.udp_port = res->udp_port;
9060 if (!strcmp(res->tunnel_type, "vxlan")) {
9061 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9062 } else if (!strcmp(res->tunnel_type, "geneve")) {
9063 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9064 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9065 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9067 printf("Invalid tunnel type\n");
9071 if (!strcmp(res->action, "add"))
9072 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9075 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9079 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9082 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9083 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9085 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9086 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9088 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9089 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9091 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9092 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9095 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9096 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9098 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9099 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9100 "vxlan#geneve#vxlan-gpe");
9101 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9102 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9105 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9106 .f = cmd_cfg_tunnel_udp_port_parsed,
9108 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9110 (void *)&cmd_config_tunnel_udp_port_port,
9111 (void *)&cmd_config_tunnel_udp_port_config,
9112 (void *)&cmd_config_tunnel_udp_port_port_id,
9113 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9114 (void *)&cmd_config_tunnel_udp_port_action,
9115 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9116 (void *)&cmd_config_tunnel_udp_port_value,
9121 /* *** GLOBAL CONFIG *** */
9122 struct cmd_global_config_result {
9123 cmdline_fixed_string_t cmd;
9125 cmdline_fixed_string_t cfg_type;
9130 cmd_global_config_parsed(void *parsed_result,
9131 __attribute__((unused)) struct cmdline *cl,
9132 __attribute__((unused)) void *data)
9134 struct cmd_global_config_result *res = parsed_result;
9135 struct rte_eth_global_cfg conf;
9138 memset(&conf, 0, sizeof(conf));
9139 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9140 conf.cfg.gre_key_len = res->len;
9141 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9142 RTE_ETH_FILTER_SET, &conf);
9144 printf("Global config error\n");
9147 cmdline_parse_token_string_t cmd_global_config_cmd =
9148 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9150 cmdline_parse_token_num_t cmd_global_config_port_id =
9151 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9153 cmdline_parse_token_string_t cmd_global_config_type =
9154 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9155 cfg_type, "gre-key-len");
9156 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9157 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9160 cmdline_parse_inst_t cmd_global_config = {
9161 .f = cmd_global_config_parsed,
9162 .data = (void *)NULL,
9163 .help_str = "global_config <port_id> gre-key-len <key_len>",
9165 (void *)&cmd_global_config_cmd,
9166 (void *)&cmd_global_config_port_id,
9167 (void *)&cmd_global_config_type,
9168 (void *)&cmd_global_config_gre_key_len,
9173 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9174 struct cmd_set_mirror_mask_result {
9175 cmdline_fixed_string_t set;
9176 cmdline_fixed_string_t port;
9178 cmdline_fixed_string_t mirror;
9180 cmdline_fixed_string_t what;
9181 cmdline_fixed_string_t value;
9182 cmdline_fixed_string_t dstpool;
9184 cmdline_fixed_string_t on;
9187 cmdline_parse_token_string_t cmd_mirror_mask_set =
9188 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9190 cmdline_parse_token_string_t cmd_mirror_mask_port =
9191 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9193 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9194 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9196 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9197 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9198 mirror, "mirror-rule");
9199 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9200 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9202 cmdline_parse_token_string_t cmd_mirror_mask_what =
9203 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9204 what, "pool-mirror-up#pool-mirror-down"
9206 cmdline_parse_token_string_t cmd_mirror_mask_value =
9207 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9209 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9210 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9211 dstpool, "dst-pool");
9212 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9213 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9215 cmdline_parse_token_string_t cmd_mirror_mask_on =
9216 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9220 cmd_set_mirror_mask_parsed(void *parsed_result,
9221 __attribute__((unused)) struct cmdline *cl,
9222 __attribute__((unused)) void *data)
9225 struct cmd_set_mirror_mask_result *res = parsed_result;
9226 struct rte_eth_mirror_conf mr_conf;
9228 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9230 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9232 mr_conf.dst_pool = res->dstpool_id;
9234 if (!strcmp(res->what, "pool-mirror-up")) {
9235 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9236 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9237 } else if (!strcmp(res->what, "pool-mirror-down")) {
9238 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9239 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9240 } else if (!strcmp(res->what, "vlan-mirror")) {
9241 mr_conf.rule_type = ETH_MIRROR_VLAN;
9242 nb_item = parse_item_list(res->value, "vlan",
9243 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9247 for (i = 0; i < nb_item; i++) {
9248 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9249 printf("Invalid vlan_id: must be < 4096\n");
9253 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9254 mr_conf.vlan.vlan_mask |= 1ULL << i;
9258 if (!strcmp(res->on, "on"))
9259 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9262 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9265 printf("mirror rule add error: (%s)\n", strerror(-ret));
9268 cmdline_parse_inst_t cmd_set_mirror_mask = {
9269 .f = cmd_set_mirror_mask_parsed,
9271 .help_str = "set port <port_id> mirror-rule <rule_id> "
9272 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9273 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9275 (void *)&cmd_mirror_mask_set,
9276 (void *)&cmd_mirror_mask_port,
9277 (void *)&cmd_mirror_mask_portid,
9278 (void *)&cmd_mirror_mask_mirror,
9279 (void *)&cmd_mirror_mask_ruleid,
9280 (void *)&cmd_mirror_mask_what,
9281 (void *)&cmd_mirror_mask_value,
9282 (void *)&cmd_mirror_mask_dstpool,
9283 (void *)&cmd_mirror_mask_poolid,
9284 (void *)&cmd_mirror_mask_on,
9289 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9290 struct cmd_set_mirror_link_result {
9291 cmdline_fixed_string_t set;
9292 cmdline_fixed_string_t port;
9294 cmdline_fixed_string_t mirror;
9296 cmdline_fixed_string_t what;
9297 cmdline_fixed_string_t dstpool;
9299 cmdline_fixed_string_t on;
9302 cmdline_parse_token_string_t cmd_mirror_link_set =
9303 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9305 cmdline_parse_token_string_t cmd_mirror_link_port =
9306 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9308 cmdline_parse_token_num_t cmd_mirror_link_portid =
9309 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9311 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9312 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9313 mirror, "mirror-rule");
9314 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9315 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9317 cmdline_parse_token_string_t cmd_mirror_link_what =
9318 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9319 what, "uplink-mirror#downlink-mirror");
9320 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9321 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9322 dstpool, "dst-pool");
9323 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9324 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9326 cmdline_parse_token_string_t cmd_mirror_link_on =
9327 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9331 cmd_set_mirror_link_parsed(void *parsed_result,
9332 __attribute__((unused)) struct cmdline *cl,
9333 __attribute__((unused)) void *data)
9336 struct cmd_set_mirror_link_result *res = parsed_result;
9337 struct rte_eth_mirror_conf mr_conf;
9339 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9340 if (!strcmp(res->what, "uplink-mirror"))
9341 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9343 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9345 mr_conf.dst_pool = res->dstpool_id;
9347 if (!strcmp(res->on, "on"))
9348 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9351 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9354 /* check the return value and print it if is < 0 */
9356 printf("mirror rule add error: (%s)\n", strerror(-ret));
9360 cmdline_parse_inst_t cmd_set_mirror_link = {
9361 .f = cmd_set_mirror_link_parsed,
9363 .help_str = "set port <port_id> mirror-rule <rule_id> "
9364 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9366 (void *)&cmd_mirror_link_set,
9367 (void *)&cmd_mirror_link_port,
9368 (void *)&cmd_mirror_link_portid,
9369 (void *)&cmd_mirror_link_mirror,
9370 (void *)&cmd_mirror_link_ruleid,
9371 (void *)&cmd_mirror_link_what,
9372 (void *)&cmd_mirror_link_dstpool,
9373 (void *)&cmd_mirror_link_poolid,
9374 (void *)&cmd_mirror_link_on,
9379 /* *** RESET VM MIRROR RULE *** */
9380 struct cmd_rm_mirror_rule_result {
9381 cmdline_fixed_string_t reset;
9382 cmdline_fixed_string_t port;
9384 cmdline_fixed_string_t mirror;
9388 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9389 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9391 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9392 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9394 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9395 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9397 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9398 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9399 mirror, "mirror-rule");
9400 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9401 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9405 cmd_reset_mirror_rule_parsed(void *parsed_result,
9406 __attribute__((unused)) struct cmdline *cl,
9407 __attribute__((unused)) void *data)
9410 struct cmd_set_mirror_link_result *res = parsed_result;
9412 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9414 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9417 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9418 .f = cmd_reset_mirror_rule_parsed,
9420 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9422 (void *)&cmd_rm_mirror_rule_reset,
9423 (void *)&cmd_rm_mirror_rule_port,
9424 (void *)&cmd_rm_mirror_rule_portid,
9425 (void *)&cmd_rm_mirror_rule_mirror,
9426 (void *)&cmd_rm_mirror_rule_ruleid,
9431 /* ******************************************************************************** */
9433 struct cmd_dump_result {
9434 cmdline_fixed_string_t dump;
9438 dump_struct_sizes(void)
9440 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9441 DUMP_SIZE(struct rte_mbuf);
9442 DUMP_SIZE(struct rte_mempool);
9443 DUMP_SIZE(struct rte_ring);
9447 static void cmd_dump_parsed(void *parsed_result,
9448 __attribute__((unused)) struct cmdline *cl,
9449 __attribute__((unused)) void *data)
9451 struct cmd_dump_result *res = parsed_result;
9453 if (!strcmp(res->dump, "dump_physmem"))
9454 rte_dump_physmem_layout(stdout);
9455 else if (!strcmp(res->dump, "dump_memzone"))
9456 rte_memzone_dump(stdout);
9457 else if (!strcmp(res->dump, "dump_struct_sizes"))
9458 dump_struct_sizes();
9459 else if (!strcmp(res->dump, "dump_ring"))
9460 rte_ring_list_dump(stdout);
9461 else if (!strcmp(res->dump, "dump_mempool"))
9462 rte_mempool_list_dump(stdout);
9463 else if (!strcmp(res->dump, "dump_devargs"))
9464 rte_devargs_dump(stdout);
9465 else if (!strcmp(res->dump, "dump_log_types"))
9466 rte_log_dump(stdout);
9469 cmdline_parse_token_string_t cmd_dump_dump =
9470 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9473 "dump_struct_sizes#"
9479 cmdline_parse_inst_t cmd_dump = {
9480 .f = cmd_dump_parsed, /* function to call */
9481 .data = NULL, /* 2nd arg of func */
9482 .help_str = "Dump status",
9483 .tokens = { /* token list, NULL terminated */
9484 (void *)&cmd_dump_dump,
9489 /* ******************************************************************************** */
9491 struct cmd_dump_one_result {
9492 cmdline_fixed_string_t dump;
9493 cmdline_fixed_string_t name;
9496 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9497 __attribute__((unused)) void *data)
9499 struct cmd_dump_one_result *res = parsed_result;
9501 if (!strcmp(res->dump, "dump_ring")) {
9503 r = rte_ring_lookup(res->name);
9505 cmdline_printf(cl, "Cannot find ring\n");
9508 rte_ring_dump(stdout, r);
9509 } else if (!strcmp(res->dump, "dump_mempool")) {
9510 struct rte_mempool *mp;
9511 mp = rte_mempool_lookup(res->name);
9513 cmdline_printf(cl, "Cannot find mempool\n");
9516 rte_mempool_dump(stdout, mp);
9520 cmdline_parse_token_string_t cmd_dump_one_dump =
9521 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9522 "dump_ring#dump_mempool");
9524 cmdline_parse_token_string_t cmd_dump_one_name =
9525 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9527 cmdline_parse_inst_t cmd_dump_one = {
9528 .f = cmd_dump_one_parsed, /* function to call */
9529 .data = NULL, /* 2nd arg of func */
9530 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9531 .tokens = { /* token list, NULL terminated */
9532 (void *)&cmd_dump_one_dump,
9533 (void *)&cmd_dump_one_name,
9538 /* *** Add/Del syn filter *** */
9539 struct cmd_syn_filter_result {
9540 cmdline_fixed_string_t filter;
9542 cmdline_fixed_string_t ops;
9543 cmdline_fixed_string_t priority;
9544 cmdline_fixed_string_t high;
9545 cmdline_fixed_string_t queue;
9550 cmd_syn_filter_parsed(void *parsed_result,
9551 __attribute__((unused)) struct cmdline *cl,
9552 __attribute__((unused)) void *data)
9554 struct cmd_syn_filter_result *res = parsed_result;
9555 struct rte_eth_syn_filter syn_filter;
9558 ret = rte_eth_dev_filter_supported(res->port_id,
9559 RTE_ETH_FILTER_SYN);
9561 printf("syn filter is not supported on port %u.\n",
9566 memset(&syn_filter, 0, sizeof(syn_filter));
9568 if (!strcmp(res->ops, "add")) {
9569 if (!strcmp(res->high, "high"))
9570 syn_filter.hig_pri = 1;
9572 syn_filter.hig_pri = 0;
9574 syn_filter.queue = res->queue_id;
9575 ret = rte_eth_dev_filter_ctrl(res->port_id,
9580 ret = rte_eth_dev_filter_ctrl(res->port_id,
9582 RTE_ETH_FILTER_DELETE,
9586 printf("syn filter programming error: (%s)\n",
9590 cmdline_parse_token_string_t cmd_syn_filter_filter =
9591 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9592 filter, "syn_filter");
9593 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9594 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9596 cmdline_parse_token_string_t cmd_syn_filter_ops =
9597 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9599 cmdline_parse_token_string_t cmd_syn_filter_priority =
9600 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9601 priority, "priority");
9602 cmdline_parse_token_string_t cmd_syn_filter_high =
9603 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9605 cmdline_parse_token_string_t cmd_syn_filter_queue =
9606 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9608 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9609 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9612 cmdline_parse_inst_t cmd_syn_filter = {
9613 .f = cmd_syn_filter_parsed,
9615 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9616 "<queue_id>: Add/Delete syn filter",
9618 (void *)&cmd_syn_filter_filter,
9619 (void *)&cmd_syn_filter_port_id,
9620 (void *)&cmd_syn_filter_ops,
9621 (void *)&cmd_syn_filter_priority,
9622 (void *)&cmd_syn_filter_high,
9623 (void *)&cmd_syn_filter_queue,
9624 (void *)&cmd_syn_filter_queue_id,
9629 /* *** queue region set *** */
9630 struct cmd_queue_region_result {
9631 cmdline_fixed_string_t set;
9632 cmdline_fixed_string_t port;
9634 cmdline_fixed_string_t cmd;
9635 cmdline_fixed_string_t region;
9637 cmdline_fixed_string_t queue_start_index;
9639 cmdline_fixed_string_t queue_num;
9640 uint8_t queue_num_value;
9644 cmd_queue_region_parsed(void *parsed_result,
9645 __attribute__((unused)) struct cmdline *cl,
9646 __attribute__((unused)) void *data)
9648 struct cmd_queue_region_result *res = parsed_result;
9650 #ifdef RTE_LIBRTE_I40E_PMD
9651 struct rte_pmd_i40e_queue_region_conf region_conf;
9652 enum rte_pmd_i40e_queue_region_op op_type;
9655 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9658 #ifdef RTE_LIBRTE_I40E_PMD
9659 memset(®ion_conf, 0, sizeof(region_conf));
9660 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9661 region_conf.region_id = res->region_id;
9662 region_conf.queue_num = res->queue_num_value;
9663 region_conf.queue_start_index = res->queue_id;
9665 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9666 op_type, ®ion_conf);
9673 printf("function not implemented or supported\n");
9676 printf("queue region config error: (%s)\n", strerror(-ret));
9680 cmdline_parse_token_string_t cmd_queue_region_set =
9681 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9683 cmdline_parse_token_string_t cmd_queue_region_port =
9684 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9685 cmdline_parse_token_num_t cmd_queue_region_port_id =
9686 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9688 cmdline_parse_token_string_t cmd_queue_region_cmd =
9689 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9690 cmd, "queue-region");
9691 cmdline_parse_token_string_t cmd_queue_region_id =
9692 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9693 region, "region_id");
9694 cmdline_parse_token_num_t cmd_queue_region_index =
9695 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9697 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9698 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9699 queue_start_index, "queue_start_index");
9700 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9701 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9703 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9704 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9705 queue_num, "queue_num");
9706 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9707 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9708 queue_num_value, UINT8);
9710 cmdline_parse_inst_t cmd_queue_region = {
9711 .f = cmd_queue_region_parsed,
9713 .help_str = "set port <port_id> queue-region region_id <value> "
9714 "queue_start_index <value> queue_num <value>: Set a queue region",
9716 (void *)&cmd_queue_region_set,
9717 (void *)&cmd_queue_region_port,
9718 (void *)&cmd_queue_region_port_id,
9719 (void *)&cmd_queue_region_cmd,
9720 (void *)&cmd_queue_region_id,
9721 (void *)&cmd_queue_region_index,
9722 (void *)&cmd_queue_region_queue_start_index,
9723 (void *)&cmd_queue_region_queue_id,
9724 (void *)&cmd_queue_region_queue_num,
9725 (void *)&cmd_queue_region_queue_num_value,
9730 /* *** queue region and flowtype set *** */
9731 struct cmd_region_flowtype_result {
9732 cmdline_fixed_string_t set;
9733 cmdline_fixed_string_t port;
9735 cmdline_fixed_string_t cmd;
9736 cmdline_fixed_string_t region;
9738 cmdline_fixed_string_t flowtype;
9739 uint8_t flowtype_id;
9743 cmd_region_flowtype_parsed(void *parsed_result,
9744 __attribute__((unused)) struct cmdline *cl,
9745 __attribute__((unused)) void *data)
9747 struct cmd_region_flowtype_result *res = parsed_result;
9749 #ifdef RTE_LIBRTE_I40E_PMD
9750 struct rte_pmd_i40e_queue_region_conf region_conf;
9751 enum rte_pmd_i40e_queue_region_op op_type;
9754 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9757 #ifdef RTE_LIBRTE_I40E_PMD
9758 memset(®ion_conf, 0, sizeof(region_conf));
9760 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9761 region_conf.region_id = res->region_id;
9762 region_conf.hw_flowtype = res->flowtype_id;
9764 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9765 op_type, ®ion_conf);
9772 printf("function not implemented or supported\n");
9775 printf("region flowtype config error: (%s)\n", strerror(-ret));
9779 cmdline_parse_token_string_t cmd_region_flowtype_set =
9780 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9782 cmdline_parse_token_string_t cmd_region_flowtype_port =
9783 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9785 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9786 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9788 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9789 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9790 cmd, "queue-region");
9791 cmdline_parse_token_string_t cmd_region_flowtype_index =
9792 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9793 region, "region_id");
9794 cmdline_parse_token_num_t cmd_region_flowtype_id =
9795 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9797 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9798 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9799 flowtype, "flowtype");
9800 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9801 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9802 flowtype_id, UINT8);
9803 cmdline_parse_inst_t cmd_region_flowtype = {
9804 .f = cmd_region_flowtype_parsed,
9806 .help_str = "set port <port_id> queue-region region_id <value> "
9807 "flowtype <value>: Set a flowtype region index",
9809 (void *)&cmd_region_flowtype_set,
9810 (void *)&cmd_region_flowtype_port,
9811 (void *)&cmd_region_flowtype_port_index,
9812 (void *)&cmd_region_flowtype_cmd,
9813 (void *)&cmd_region_flowtype_index,
9814 (void *)&cmd_region_flowtype_id,
9815 (void *)&cmd_region_flowtype_flow_index,
9816 (void *)&cmd_region_flowtype_flow_id,
9821 /* *** User Priority (UP) to queue region (region_id) set *** */
9822 struct cmd_user_priority_region_result {
9823 cmdline_fixed_string_t set;
9824 cmdline_fixed_string_t port;
9826 cmdline_fixed_string_t cmd;
9827 cmdline_fixed_string_t user_priority;
9828 uint8_t user_priority_id;
9829 cmdline_fixed_string_t region;
9834 cmd_user_priority_region_parsed(void *parsed_result,
9835 __attribute__((unused)) struct cmdline *cl,
9836 __attribute__((unused)) void *data)
9838 struct cmd_user_priority_region_result *res = parsed_result;
9840 #ifdef RTE_LIBRTE_I40E_PMD
9841 struct rte_pmd_i40e_queue_region_conf region_conf;
9842 enum rte_pmd_i40e_queue_region_op op_type;
9845 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9848 #ifdef RTE_LIBRTE_I40E_PMD
9849 memset(®ion_conf, 0, sizeof(region_conf));
9850 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9851 region_conf.user_priority = res->user_priority_id;
9852 region_conf.region_id = res->region_id;
9854 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9855 op_type, ®ion_conf);
9862 printf("function not implemented or supported\n");
9865 printf("user_priority region config error: (%s)\n",
9870 cmdline_parse_token_string_t cmd_user_priority_region_set =
9871 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9873 cmdline_parse_token_string_t cmd_user_priority_region_port =
9874 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9876 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9877 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9879 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9880 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9881 cmd, "queue-region");
9882 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9883 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9884 user_priority, "UP");
9885 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9886 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9887 user_priority_id, UINT8);
9888 cmdline_parse_token_string_t cmd_user_priority_region_region =
9889 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9890 region, "region_id");
9891 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9892 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9895 cmdline_parse_inst_t cmd_user_priority_region = {
9896 .f = cmd_user_priority_region_parsed,
9898 .help_str = "set port <port_id> queue-region UP <value> "
9899 "region_id <value>: Set the mapping of User Priority (UP) "
9900 "to queue region (region_id) ",
9902 (void *)&cmd_user_priority_region_set,
9903 (void *)&cmd_user_priority_region_port,
9904 (void *)&cmd_user_priority_region_port_index,
9905 (void *)&cmd_user_priority_region_cmd,
9906 (void *)&cmd_user_priority_region_UP,
9907 (void *)&cmd_user_priority_region_UP_id,
9908 (void *)&cmd_user_priority_region_region,
9909 (void *)&cmd_user_priority_region_region_id,
9914 /* *** flush all queue region related configuration *** */
9915 struct cmd_flush_queue_region_result {
9916 cmdline_fixed_string_t set;
9917 cmdline_fixed_string_t port;
9919 cmdline_fixed_string_t cmd;
9920 cmdline_fixed_string_t flush;
9921 cmdline_fixed_string_t what;
9925 cmd_flush_queue_region_parsed(void *parsed_result,
9926 __attribute__((unused)) struct cmdline *cl,
9927 __attribute__((unused)) void *data)
9929 struct cmd_flush_queue_region_result *res = parsed_result;
9931 #ifdef RTE_LIBRTE_I40E_PMD
9932 struct rte_pmd_i40e_queue_region_conf region_conf;
9933 enum rte_pmd_i40e_queue_region_op op_type;
9936 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9939 #ifdef RTE_LIBRTE_I40E_PMD
9940 memset(®ion_conf, 0, sizeof(region_conf));
9942 if (strcmp(res->what, "on") == 0)
9943 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9945 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9947 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9948 op_type, ®ion_conf);
9955 printf("function not implemented or supported\n");
9958 printf("queue region config flush error: (%s)\n",
9963 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9964 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9966 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9967 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9969 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9970 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9972 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9973 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9974 cmd, "queue-region");
9975 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9976 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9978 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9979 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9982 cmdline_parse_inst_t cmd_flush_queue_region = {
9983 .f = cmd_flush_queue_region_parsed,
9985 .help_str = "set port <port_id> queue-region flush on|off"
9986 ": flush all queue region related configuration",
9988 (void *)&cmd_flush_queue_region_set,
9989 (void *)&cmd_flush_queue_region_port,
9990 (void *)&cmd_flush_queue_region_port_index,
9991 (void *)&cmd_flush_queue_region_cmd,
9992 (void *)&cmd_flush_queue_region_flush,
9993 (void *)&cmd_flush_queue_region_what,
9998 /* *** get all queue region related configuration info *** */
9999 struct cmd_show_queue_region_info {
10000 cmdline_fixed_string_t show;
10001 cmdline_fixed_string_t port;
10003 cmdline_fixed_string_t cmd;
10007 cmd_show_queue_region_info_parsed(void *parsed_result,
10008 __attribute__((unused)) struct cmdline *cl,
10009 __attribute__((unused)) void *data)
10011 struct cmd_show_queue_region_info *res = parsed_result;
10012 int ret = -ENOTSUP;
10013 #ifdef RTE_LIBRTE_I40E_PMD
10014 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10015 enum rte_pmd_i40e_queue_region_op op_type;
10018 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10021 #ifdef RTE_LIBRTE_I40E_PMD
10022 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10024 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10026 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10027 op_type, &rte_pmd_regions);
10029 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10036 printf("function not implemented or supported\n");
10039 printf("queue region config info show error: (%s)\n",
10044 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10045 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10047 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10048 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10050 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10051 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10053 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10054 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10055 cmd, "queue-region");
10057 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10058 .f = cmd_show_queue_region_info_parsed,
10060 .help_str = "show port <port_id> queue-region"
10061 ": show all queue region related configuration info",
10063 (void *)&cmd_show_queue_region_info_get,
10064 (void *)&cmd_show_queue_region_info_port,
10065 (void *)&cmd_show_queue_region_info_port_index,
10066 (void *)&cmd_show_queue_region_info_cmd,
10071 /* *** ADD/REMOVE A 2tuple FILTER *** */
10072 struct cmd_2tuple_filter_result {
10073 cmdline_fixed_string_t filter;
10075 cmdline_fixed_string_t ops;
10076 cmdline_fixed_string_t dst_port;
10077 uint16_t dst_port_value;
10078 cmdline_fixed_string_t protocol;
10079 uint8_t protocol_value;
10080 cmdline_fixed_string_t mask;
10081 uint8_t mask_value;
10082 cmdline_fixed_string_t tcp_flags;
10083 uint8_t tcp_flags_value;
10084 cmdline_fixed_string_t priority;
10085 uint8_t priority_value;
10086 cmdline_fixed_string_t queue;
10091 cmd_2tuple_filter_parsed(void *parsed_result,
10092 __attribute__((unused)) struct cmdline *cl,
10093 __attribute__((unused)) void *data)
10095 struct rte_eth_ntuple_filter filter;
10096 struct cmd_2tuple_filter_result *res = parsed_result;
10099 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10101 printf("ntuple filter is not supported on port %u.\n",
10106 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10108 filter.flags = RTE_2TUPLE_FLAGS;
10109 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10110 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10111 filter.proto = res->protocol_value;
10112 filter.priority = res->priority_value;
10113 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10114 printf("nonzero tcp_flags is only meaningful"
10115 " when protocol is TCP.\n");
10118 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10119 printf("invalid TCP flags.\n");
10123 if (res->tcp_flags_value != 0) {
10124 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10125 filter.tcp_flags = res->tcp_flags_value;
10128 /* need convert to big endian. */
10129 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10130 filter.queue = res->queue_id;
10132 if (!strcmp(res->ops, "add"))
10133 ret = rte_eth_dev_filter_ctrl(res->port_id,
10134 RTE_ETH_FILTER_NTUPLE,
10135 RTE_ETH_FILTER_ADD,
10138 ret = rte_eth_dev_filter_ctrl(res->port_id,
10139 RTE_ETH_FILTER_NTUPLE,
10140 RTE_ETH_FILTER_DELETE,
10143 printf("2tuple filter programming error: (%s)\n",
10148 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10149 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10150 filter, "2tuple_filter");
10151 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10152 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10154 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10155 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10157 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10158 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10159 dst_port, "dst_port");
10160 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10161 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10162 dst_port_value, UINT16);
10163 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10164 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10165 protocol, "protocol");
10166 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10167 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10168 protocol_value, UINT8);
10169 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10170 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10172 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10173 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10175 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10176 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10177 tcp_flags, "tcp_flags");
10178 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10179 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10180 tcp_flags_value, UINT8);
10181 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10182 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10183 priority, "priority");
10184 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10185 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10186 priority_value, UINT8);
10187 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10188 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10190 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10191 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10194 cmdline_parse_inst_t cmd_2tuple_filter = {
10195 .f = cmd_2tuple_filter_parsed,
10197 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10198 "<value> mask <value> tcp_flags <value> priority <value> queue "
10199 "<queue_id>: Add a 2tuple filter",
10201 (void *)&cmd_2tuple_filter_filter,
10202 (void *)&cmd_2tuple_filter_port_id,
10203 (void *)&cmd_2tuple_filter_ops,
10204 (void *)&cmd_2tuple_filter_dst_port,
10205 (void *)&cmd_2tuple_filter_dst_port_value,
10206 (void *)&cmd_2tuple_filter_protocol,
10207 (void *)&cmd_2tuple_filter_protocol_value,
10208 (void *)&cmd_2tuple_filter_mask,
10209 (void *)&cmd_2tuple_filter_mask_value,
10210 (void *)&cmd_2tuple_filter_tcp_flags,
10211 (void *)&cmd_2tuple_filter_tcp_flags_value,
10212 (void *)&cmd_2tuple_filter_priority,
10213 (void *)&cmd_2tuple_filter_priority_value,
10214 (void *)&cmd_2tuple_filter_queue,
10215 (void *)&cmd_2tuple_filter_queue_id,
10220 /* *** ADD/REMOVE A 5tuple FILTER *** */
10221 struct cmd_5tuple_filter_result {
10222 cmdline_fixed_string_t filter;
10224 cmdline_fixed_string_t ops;
10225 cmdline_fixed_string_t dst_ip;
10226 cmdline_ipaddr_t dst_ip_value;
10227 cmdline_fixed_string_t src_ip;
10228 cmdline_ipaddr_t src_ip_value;
10229 cmdline_fixed_string_t dst_port;
10230 uint16_t dst_port_value;
10231 cmdline_fixed_string_t src_port;
10232 uint16_t src_port_value;
10233 cmdline_fixed_string_t protocol;
10234 uint8_t protocol_value;
10235 cmdline_fixed_string_t mask;
10236 uint8_t mask_value;
10237 cmdline_fixed_string_t tcp_flags;
10238 uint8_t tcp_flags_value;
10239 cmdline_fixed_string_t priority;
10240 uint8_t priority_value;
10241 cmdline_fixed_string_t queue;
10246 cmd_5tuple_filter_parsed(void *parsed_result,
10247 __attribute__((unused)) struct cmdline *cl,
10248 __attribute__((unused)) void *data)
10250 struct rte_eth_ntuple_filter filter;
10251 struct cmd_5tuple_filter_result *res = parsed_result;
10254 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10256 printf("ntuple filter is not supported on port %u.\n",
10261 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10263 filter.flags = RTE_5TUPLE_FLAGS;
10264 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10265 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10266 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10267 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10268 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10269 filter.proto = res->protocol_value;
10270 filter.priority = res->priority_value;
10271 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10272 printf("nonzero tcp_flags is only meaningful"
10273 " when protocol is TCP.\n");
10276 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10277 printf("invalid TCP flags.\n");
10281 if (res->tcp_flags_value != 0) {
10282 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10283 filter.tcp_flags = res->tcp_flags_value;
10286 if (res->dst_ip_value.family == AF_INET)
10287 /* no need to convert, already big endian. */
10288 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10290 if (filter.dst_ip_mask == 0) {
10291 printf("can not support ipv6 involved compare.\n");
10297 if (res->src_ip_value.family == AF_INET)
10298 /* no need to convert, already big endian. */
10299 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10301 if (filter.src_ip_mask == 0) {
10302 printf("can not support ipv6 involved compare.\n");
10307 /* need convert to big endian. */
10308 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10309 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10310 filter.queue = res->queue_id;
10312 if (!strcmp(res->ops, "add"))
10313 ret = rte_eth_dev_filter_ctrl(res->port_id,
10314 RTE_ETH_FILTER_NTUPLE,
10315 RTE_ETH_FILTER_ADD,
10318 ret = rte_eth_dev_filter_ctrl(res->port_id,
10319 RTE_ETH_FILTER_NTUPLE,
10320 RTE_ETH_FILTER_DELETE,
10323 printf("5tuple filter programming error: (%s)\n",
10327 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10328 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10329 filter, "5tuple_filter");
10330 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10331 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10333 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10334 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10336 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10337 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10339 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10340 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10342 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10343 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10345 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10346 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10348 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10349 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10350 dst_port, "dst_port");
10351 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10352 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10353 dst_port_value, UINT16);
10354 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10355 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10356 src_port, "src_port");
10357 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10358 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10359 src_port_value, UINT16);
10360 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10361 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10362 protocol, "protocol");
10363 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10364 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10365 protocol_value, UINT8);
10366 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10367 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10369 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10370 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10372 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10373 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10374 tcp_flags, "tcp_flags");
10375 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10376 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10377 tcp_flags_value, UINT8);
10378 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10379 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10380 priority, "priority");
10381 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10382 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10383 priority_value, UINT8);
10384 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10385 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10387 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10388 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10391 cmdline_parse_inst_t cmd_5tuple_filter = {
10392 .f = cmd_5tuple_filter_parsed,
10394 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10395 "src_ip <value> dst_port <value> src_port <value> "
10396 "protocol <value> mask <value> tcp_flags <value> "
10397 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10399 (void *)&cmd_5tuple_filter_filter,
10400 (void *)&cmd_5tuple_filter_port_id,
10401 (void *)&cmd_5tuple_filter_ops,
10402 (void *)&cmd_5tuple_filter_dst_ip,
10403 (void *)&cmd_5tuple_filter_dst_ip_value,
10404 (void *)&cmd_5tuple_filter_src_ip,
10405 (void *)&cmd_5tuple_filter_src_ip_value,
10406 (void *)&cmd_5tuple_filter_dst_port,
10407 (void *)&cmd_5tuple_filter_dst_port_value,
10408 (void *)&cmd_5tuple_filter_src_port,
10409 (void *)&cmd_5tuple_filter_src_port_value,
10410 (void *)&cmd_5tuple_filter_protocol,
10411 (void *)&cmd_5tuple_filter_protocol_value,
10412 (void *)&cmd_5tuple_filter_mask,
10413 (void *)&cmd_5tuple_filter_mask_value,
10414 (void *)&cmd_5tuple_filter_tcp_flags,
10415 (void *)&cmd_5tuple_filter_tcp_flags_value,
10416 (void *)&cmd_5tuple_filter_priority,
10417 (void *)&cmd_5tuple_filter_priority_value,
10418 (void *)&cmd_5tuple_filter_queue,
10419 (void *)&cmd_5tuple_filter_queue_id,
10424 /* *** ADD/REMOVE A flex FILTER *** */
10425 struct cmd_flex_filter_result {
10426 cmdline_fixed_string_t filter;
10427 cmdline_fixed_string_t ops;
10429 cmdline_fixed_string_t len;
10431 cmdline_fixed_string_t bytes;
10432 cmdline_fixed_string_t bytes_value;
10433 cmdline_fixed_string_t mask;
10434 cmdline_fixed_string_t mask_value;
10435 cmdline_fixed_string_t priority;
10436 uint8_t priority_value;
10437 cmdline_fixed_string_t queue;
10441 static int xdigit2val(unsigned char c)
10446 else if (isupper(c))
10447 val = c - 'A' + 10;
10449 val = c - 'a' + 10;
10454 cmd_flex_filter_parsed(void *parsed_result,
10455 __attribute__((unused)) struct cmdline *cl,
10456 __attribute__((unused)) void *data)
10459 struct rte_eth_flex_filter filter;
10460 struct cmd_flex_filter_result *res = parsed_result;
10461 char *bytes_ptr, *mask_ptr;
10462 uint16_t len, i, j = 0;
10467 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10468 printf("the len exceed the max length 128\n");
10471 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10472 filter.len = res->len_value;
10473 filter.priority = res->priority_value;
10474 filter.queue = res->queue_id;
10475 bytes_ptr = res->bytes_value;
10476 mask_ptr = res->mask_value;
10478 /* translate bytes string to array. */
10479 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10480 (bytes_ptr[1] == 'X')))
10482 len = strnlen(bytes_ptr, res->len_value * 2);
10483 if (len == 0 || (len % 8 != 0)) {
10484 printf("please check len and bytes input\n");
10487 for (i = 0; i < len; i++) {
10489 if (isxdigit(c) == 0) {
10490 /* invalid characters. */
10491 printf("invalid input\n");
10494 val = xdigit2val(c);
10497 filter.bytes[j] = byte;
10498 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10505 /* translate mask string to uint8_t array. */
10506 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10507 (mask_ptr[1] == 'X')))
10509 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10511 printf("invalid input\n");
10516 for (i = 0; i < len; i++) {
10518 if (isxdigit(c) == 0) {
10519 /* invalid characters. */
10520 printf("invalid input\n");
10523 val = xdigit2val(c);
10526 filter.mask[j] = byte;
10527 printf("mask[%d]:%02x ", j, filter.mask[j]);
10535 if (!strcmp(res->ops, "add"))
10536 ret = rte_eth_dev_filter_ctrl(res->port_id,
10537 RTE_ETH_FILTER_FLEXIBLE,
10538 RTE_ETH_FILTER_ADD,
10541 ret = rte_eth_dev_filter_ctrl(res->port_id,
10542 RTE_ETH_FILTER_FLEXIBLE,
10543 RTE_ETH_FILTER_DELETE,
10547 printf("flex filter setting error: (%s)\n", strerror(-ret));
10550 cmdline_parse_token_string_t cmd_flex_filter_filter =
10551 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10552 filter, "flex_filter");
10553 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10554 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10556 cmdline_parse_token_string_t cmd_flex_filter_ops =
10557 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10559 cmdline_parse_token_string_t cmd_flex_filter_len =
10560 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10562 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10563 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10565 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10566 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10568 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10569 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10570 bytes_value, NULL);
10571 cmdline_parse_token_string_t cmd_flex_filter_mask =
10572 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10574 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10575 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10577 cmdline_parse_token_string_t cmd_flex_filter_priority =
10578 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10579 priority, "priority");
10580 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10581 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10582 priority_value, UINT8);
10583 cmdline_parse_token_string_t cmd_flex_filter_queue =
10584 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10586 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10587 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10589 cmdline_parse_inst_t cmd_flex_filter = {
10590 .f = cmd_flex_filter_parsed,
10592 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10593 "<value> mask <value> priority <value> queue <queue_id>: "
10594 "Add/Del a flex filter",
10596 (void *)&cmd_flex_filter_filter,
10597 (void *)&cmd_flex_filter_port_id,
10598 (void *)&cmd_flex_filter_ops,
10599 (void *)&cmd_flex_filter_len,
10600 (void *)&cmd_flex_filter_len_value,
10601 (void *)&cmd_flex_filter_bytes,
10602 (void *)&cmd_flex_filter_bytes_value,
10603 (void *)&cmd_flex_filter_mask,
10604 (void *)&cmd_flex_filter_mask_value,
10605 (void *)&cmd_flex_filter_priority,
10606 (void *)&cmd_flex_filter_priority_value,
10607 (void *)&cmd_flex_filter_queue,
10608 (void *)&cmd_flex_filter_queue_id,
10613 /* *** Filters Control *** */
10615 /* *** deal with ethertype filter *** */
10616 struct cmd_ethertype_filter_result {
10617 cmdline_fixed_string_t filter;
10619 cmdline_fixed_string_t ops;
10620 cmdline_fixed_string_t mac;
10621 struct rte_ether_addr mac_addr;
10622 cmdline_fixed_string_t ethertype;
10623 uint16_t ethertype_value;
10624 cmdline_fixed_string_t drop;
10625 cmdline_fixed_string_t queue;
10629 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10630 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10631 filter, "ethertype_filter");
10632 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10633 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10635 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10636 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10638 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10639 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10640 mac, "mac_addr#mac_ignr");
10641 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10642 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10644 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10645 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10646 ethertype, "ethertype");
10647 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10648 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10649 ethertype_value, UINT16);
10650 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10651 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10653 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10654 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10656 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10657 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10661 cmd_ethertype_filter_parsed(void *parsed_result,
10662 __attribute__((unused)) struct cmdline *cl,
10663 __attribute__((unused)) void *data)
10665 struct cmd_ethertype_filter_result *res = parsed_result;
10666 struct rte_eth_ethertype_filter filter;
10669 ret = rte_eth_dev_filter_supported(res->port_id,
10670 RTE_ETH_FILTER_ETHERTYPE);
10672 printf("ethertype filter is not supported on port %u.\n",
10677 memset(&filter, 0, sizeof(filter));
10678 if (!strcmp(res->mac, "mac_addr")) {
10679 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10680 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10681 sizeof(struct rte_ether_addr));
10683 if (!strcmp(res->drop, "drop"))
10684 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10685 filter.ether_type = res->ethertype_value;
10686 filter.queue = res->queue_id;
10688 if (!strcmp(res->ops, "add"))
10689 ret = rte_eth_dev_filter_ctrl(res->port_id,
10690 RTE_ETH_FILTER_ETHERTYPE,
10691 RTE_ETH_FILTER_ADD,
10694 ret = rte_eth_dev_filter_ctrl(res->port_id,
10695 RTE_ETH_FILTER_ETHERTYPE,
10696 RTE_ETH_FILTER_DELETE,
10699 printf("ethertype filter programming error: (%s)\n",
10703 cmdline_parse_inst_t cmd_ethertype_filter = {
10704 .f = cmd_ethertype_filter_parsed,
10706 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10707 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10708 "Add or delete an ethertype filter entry",
10710 (void *)&cmd_ethertype_filter_filter,
10711 (void *)&cmd_ethertype_filter_port_id,
10712 (void *)&cmd_ethertype_filter_ops,
10713 (void *)&cmd_ethertype_filter_mac,
10714 (void *)&cmd_ethertype_filter_mac_addr,
10715 (void *)&cmd_ethertype_filter_ethertype,
10716 (void *)&cmd_ethertype_filter_ethertype_value,
10717 (void *)&cmd_ethertype_filter_drop,
10718 (void *)&cmd_ethertype_filter_queue,
10719 (void *)&cmd_ethertype_filter_queue_id,
10724 /* *** deal with flow director filter *** */
10725 struct cmd_flow_director_result {
10726 cmdline_fixed_string_t flow_director_filter;
10728 cmdline_fixed_string_t mode;
10729 cmdline_fixed_string_t mode_value;
10730 cmdline_fixed_string_t ops;
10731 cmdline_fixed_string_t flow;
10732 cmdline_fixed_string_t flow_type;
10733 cmdline_fixed_string_t ether;
10734 uint16_t ether_type;
10735 cmdline_fixed_string_t src;
10736 cmdline_ipaddr_t ip_src;
10738 cmdline_fixed_string_t dst;
10739 cmdline_ipaddr_t ip_dst;
10741 cmdline_fixed_string_t verify_tag;
10742 uint32_t verify_tag_value;
10743 cmdline_fixed_string_t tos;
10745 cmdline_fixed_string_t proto;
10746 uint8_t proto_value;
10747 cmdline_fixed_string_t ttl;
10749 cmdline_fixed_string_t vlan;
10750 uint16_t vlan_value;
10751 cmdline_fixed_string_t flexbytes;
10752 cmdline_fixed_string_t flexbytes_value;
10753 cmdline_fixed_string_t pf_vf;
10754 cmdline_fixed_string_t drop;
10755 cmdline_fixed_string_t queue;
10757 cmdline_fixed_string_t fd_id;
10758 uint32_t fd_id_value;
10759 cmdline_fixed_string_t mac;
10760 struct rte_ether_addr mac_addr;
10761 cmdline_fixed_string_t tunnel;
10762 cmdline_fixed_string_t tunnel_type;
10763 cmdline_fixed_string_t tunnel_id;
10764 uint32_t tunnel_id_value;
10765 cmdline_fixed_string_t packet;
10770 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10773 const char *p, *p0 = q_arg;
10775 unsigned long int_fld;
10776 char *str_fld[max_num];
10781 p = strchr(p0, '(');
10785 p0 = strchr(p, ')');
10790 if (size >= sizeof(s))
10793 snprintf(s, sizeof(s), "%.*s", size, p);
10794 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10795 if (ret < 0 || ret > max_num)
10797 for (i = 0; i < ret; i++) {
10799 int_fld = strtoul(str_fld[i], &end, 0);
10800 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10802 flexbytes[i] = (uint8_t)int_fld;
10808 str2flowtype(char *string)
10811 static const struct {
10814 } flowtype_str[] = {
10815 {"raw", RTE_ETH_FLOW_RAW},
10816 {"ipv4", RTE_ETH_FLOW_IPV4},
10817 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10818 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10819 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10820 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10821 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10822 {"ipv6", RTE_ETH_FLOW_IPV6},
10823 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10824 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10825 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10826 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10827 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10828 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10831 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10832 if (!strcmp(flowtype_str[i].str, string))
10833 return flowtype_str[i].type;
10836 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10837 return (uint16_t)atoi(string);
10839 return RTE_ETH_FLOW_UNKNOWN;
10842 static enum rte_eth_fdir_tunnel_type
10843 str2fdir_tunneltype(char *string)
10847 static const struct {
10849 enum rte_eth_fdir_tunnel_type type;
10850 } tunneltype_str[] = {
10851 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10852 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10855 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10856 if (!strcmp(tunneltype_str[i].str, string))
10857 return tunneltype_str[i].type;
10859 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10862 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10864 if ((ip_addr).family == AF_INET) \
10865 (ip) = (ip_addr).addr.ipv4.s_addr; \
10867 printf("invalid parameter.\n"); \
10872 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10874 if ((ip_addr).family == AF_INET6) \
10875 rte_memcpy(&(ip), \
10876 &((ip_addr).addr.ipv6), \
10877 sizeof(struct in6_addr)); \
10879 printf("invalid parameter.\n"); \
10885 cmd_flow_director_filter_parsed(void *parsed_result,
10886 __attribute__((unused)) struct cmdline *cl,
10887 __attribute__((unused)) void *data)
10889 struct cmd_flow_director_result *res = parsed_result;
10890 struct rte_eth_fdir_filter entry;
10891 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10893 unsigned long vf_id;
10896 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10898 printf("flow director is not supported on port %u.\n",
10902 memset(flexbytes, 0, sizeof(flexbytes));
10903 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10905 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10906 if (strcmp(res->mode_value, "MAC-VLAN")) {
10907 printf("Please set mode to MAC-VLAN.\n");
10910 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10911 if (strcmp(res->mode_value, "Tunnel")) {
10912 printf("Please set mode to Tunnel.\n");
10916 if (!strcmp(res->mode_value, "raw")) {
10917 #ifdef RTE_LIBRTE_I40E_PMD
10918 struct rte_pmd_i40e_flow_type_mapping
10919 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10920 struct rte_pmd_i40e_pkt_template_conf conf;
10921 uint16_t flow_type = str2flowtype(res->flow_type);
10922 uint16_t i, port = res->port_id;
10925 memset(&conf, 0, sizeof(conf));
10927 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10928 printf("Invalid flow type specified.\n");
10931 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10935 if (mapping[flow_type].pctype == 0ULL) {
10936 printf("Invalid flow type specified.\n");
10939 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10940 if (mapping[flow_type].pctype & (1ULL << i)) {
10941 conf.input.pctype = i;
10946 conf.input.packet = open_file(res->filepath,
10947 &conf.input.length);
10948 if (!conf.input.packet)
10950 if (!strcmp(res->drop, "drop"))
10951 conf.action.behavior =
10952 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10954 conf.action.behavior =
10955 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10956 conf.action.report_status =
10957 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10958 conf.action.rx_queue = res->queue_id;
10959 conf.soft_id = res->fd_id_value;
10960 add = strcmp(res->ops, "del") ? 1 : 0;
10961 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10965 printf("flow director config error: (%s)\n",
10967 close_file(conf.input.packet);
10970 } else if (strcmp(res->mode_value, "IP")) {
10971 printf("Please set mode to IP or raw.\n");
10974 entry.input.flow_type = str2flowtype(res->flow_type);
10977 ret = parse_flexbytes(res->flexbytes_value,
10979 RTE_ETH_FDIR_MAX_FLEXLEN);
10981 printf("error: Cannot parse flexbytes input.\n");
10985 switch (entry.input.flow_type) {
10986 case RTE_ETH_FLOW_FRAG_IPV4:
10987 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10988 entry.input.flow.ip4_flow.proto = res->proto_value;
10990 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10991 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10992 IPV4_ADDR_TO_UINT(res->ip_dst,
10993 entry.input.flow.ip4_flow.dst_ip);
10994 IPV4_ADDR_TO_UINT(res->ip_src,
10995 entry.input.flow.ip4_flow.src_ip);
10996 entry.input.flow.ip4_flow.tos = res->tos_value;
10997 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10998 /* need convert to big endian. */
10999 entry.input.flow.udp4_flow.dst_port =
11000 rte_cpu_to_be_16(res->port_dst);
11001 entry.input.flow.udp4_flow.src_port =
11002 rte_cpu_to_be_16(res->port_src);
11004 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11005 IPV4_ADDR_TO_UINT(res->ip_dst,
11006 entry.input.flow.sctp4_flow.ip.dst_ip);
11007 IPV4_ADDR_TO_UINT(res->ip_src,
11008 entry.input.flow.sctp4_flow.ip.src_ip);
11009 entry.input.flow.ip4_flow.tos = res->tos_value;
11010 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11011 /* need convert to big endian. */
11012 entry.input.flow.sctp4_flow.dst_port =
11013 rte_cpu_to_be_16(res->port_dst);
11014 entry.input.flow.sctp4_flow.src_port =
11015 rte_cpu_to_be_16(res->port_src);
11016 entry.input.flow.sctp4_flow.verify_tag =
11017 rte_cpu_to_be_32(res->verify_tag_value);
11019 case RTE_ETH_FLOW_FRAG_IPV6:
11020 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11021 entry.input.flow.ipv6_flow.proto = res->proto_value;
11023 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11024 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11025 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11026 entry.input.flow.ipv6_flow.dst_ip);
11027 IPV6_ADDR_TO_ARRAY(res->ip_src,
11028 entry.input.flow.ipv6_flow.src_ip);
11029 entry.input.flow.ipv6_flow.tc = res->tos_value;
11030 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11031 /* need convert to big endian. */
11032 entry.input.flow.udp6_flow.dst_port =
11033 rte_cpu_to_be_16(res->port_dst);
11034 entry.input.flow.udp6_flow.src_port =
11035 rte_cpu_to_be_16(res->port_src);
11037 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11038 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11039 entry.input.flow.sctp6_flow.ip.dst_ip);
11040 IPV6_ADDR_TO_ARRAY(res->ip_src,
11041 entry.input.flow.sctp6_flow.ip.src_ip);
11042 entry.input.flow.ipv6_flow.tc = res->tos_value;
11043 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11044 /* need convert to big endian. */
11045 entry.input.flow.sctp6_flow.dst_port =
11046 rte_cpu_to_be_16(res->port_dst);
11047 entry.input.flow.sctp6_flow.src_port =
11048 rte_cpu_to_be_16(res->port_src);
11049 entry.input.flow.sctp6_flow.verify_tag =
11050 rte_cpu_to_be_32(res->verify_tag_value);
11052 case RTE_ETH_FLOW_L2_PAYLOAD:
11053 entry.input.flow.l2_flow.ether_type =
11054 rte_cpu_to_be_16(res->ether_type);
11060 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11061 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11063 sizeof(struct rte_ether_addr));
11065 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11066 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11068 sizeof(struct rte_ether_addr));
11069 entry.input.flow.tunnel_flow.tunnel_type =
11070 str2fdir_tunneltype(res->tunnel_type);
11071 entry.input.flow.tunnel_flow.tunnel_id =
11072 rte_cpu_to_be_32(res->tunnel_id_value);
11075 rte_memcpy(entry.input.flow_ext.flexbytes,
11077 RTE_ETH_FDIR_MAX_FLEXLEN);
11079 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11081 entry.action.flex_off = 0; /*use 0 by default */
11082 if (!strcmp(res->drop, "drop"))
11083 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11085 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11087 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11088 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11089 if (!strcmp(res->pf_vf, "pf"))
11090 entry.input.flow_ext.is_vf = 0;
11091 else if (!strncmp(res->pf_vf, "vf", 2)) {
11092 struct rte_eth_dev_info dev_info;
11094 memset(&dev_info, 0, sizeof(dev_info));
11095 rte_eth_dev_info_get(res->port_id, &dev_info);
11097 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11098 if (errno != 0 || *end != '\0' ||
11099 vf_id >= dev_info.max_vfs) {
11100 printf("invalid parameter %s.\n", res->pf_vf);
11103 entry.input.flow_ext.is_vf = 1;
11104 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11106 printf("invalid parameter %s.\n", res->pf_vf);
11111 /* set to report FD ID by default */
11112 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11113 entry.action.rx_queue = res->queue_id;
11114 entry.soft_id = res->fd_id_value;
11115 if (!strcmp(res->ops, "add"))
11116 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11117 RTE_ETH_FILTER_ADD, &entry);
11118 else if (!strcmp(res->ops, "del"))
11119 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11120 RTE_ETH_FILTER_DELETE, &entry);
11122 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11123 RTE_ETH_FILTER_UPDATE, &entry);
11125 printf("flow director programming error: (%s)\n",
11129 cmdline_parse_token_string_t cmd_flow_director_filter =
11130 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11131 flow_director_filter, "flow_director_filter");
11132 cmdline_parse_token_num_t cmd_flow_director_port_id =
11133 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11135 cmdline_parse_token_string_t cmd_flow_director_ops =
11136 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11137 ops, "add#del#update");
11138 cmdline_parse_token_string_t cmd_flow_director_flow =
11139 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11141 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11142 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11144 cmdline_parse_token_string_t cmd_flow_director_ether =
11145 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11147 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11148 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11149 ether_type, UINT16);
11150 cmdline_parse_token_string_t cmd_flow_director_src =
11151 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11153 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11154 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11156 cmdline_parse_token_num_t cmd_flow_director_port_src =
11157 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11159 cmdline_parse_token_string_t cmd_flow_director_dst =
11160 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11162 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11163 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11165 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11166 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11168 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11169 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11170 verify_tag, "verify_tag");
11171 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11172 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11173 verify_tag_value, UINT32);
11174 cmdline_parse_token_string_t cmd_flow_director_tos =
11175 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11177 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11178 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11180 cmdline_parse_token_string_t cmd_flow_director_proto =
11181 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11183 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11184 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11185 proto_value, UINT8);
11186 cmdline_parse_token_string_t cmd_flow_director_ttl =
11187 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11189 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11190 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11192 cmdline_parse_token_string_t cmd_flow_director_vlan =
11193 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11195 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11196 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11197 vlan_value, UINT16);
11198 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11199 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11200 flexbytes, "flexbytes");
11201 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11202 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11203 flexbytes_value, NULL);
11204 cmdline_parse_token_string_t cmd_flow_director_drop =
11205 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11207 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11208 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11210 cmdline_parse_token_string_t cmd_flow_director_queue =
11211 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11213 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11214 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11216 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11217 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11219 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11220 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11221 fd_id_value, UINT32);
11223 cmdline_parse_token_string_t cmd_flow_director_mode =
11224 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11226 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11227 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11229 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11230 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11231 mode_value, "MAC-VLAN");
11232 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11233 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11234 mode_value, "Tunnel");
11235 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11236 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11237 mode_value, "raw");
11238 cmdline_parse_token_string_t cmd_flow_director_mac =
11239 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11241 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11242 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11244 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11245 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11247 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11248 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11249 tunnel_type, "NVGRE#VxLAN");
11250 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11251 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11252 tunnel_id, "tunnel-id");
11253 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11254 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11255 tunnel_id_value, UINT32);
11256 cmdline_parse_token_string_t cmd_flow_director_packet =
11257 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11259 cmdline_parse_token_string_t cmd_flow_director_filepath =
11260 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11263 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11264 .f = cmd_flow_director_filter_parsed,
11266 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11267 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11268 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11269 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11270 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11271 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11272 "fd_id <fd_id_value>: "
11273 "Add or delete an ip flow director entry on NIC",
11275 (void *)&cmd_flow_director_filter,
11276 (void *)&cmd_flow_director_port_id,
11277 (void *)&cmd_flow_director_mode,
11278 (void *)&cmd_flow_director_mode_ip,
11279 (void *)&cmd_flow_director_ops,
11280 (void *)&cmd_flow_director_flow,
11281 (void *)&cmd_flow_director_flow_type,
11282 (void *)&cmd_flow_director_src,
11283 (void *)&cmd_flow_director_ip_src,
11284 (void *)&cmd_flow_director_dst,
11285 (void *)&cmd_flow_director_ip_dst,
11286 (void *)&cmd_flow_director_tos,
11287 (void *)&cmd_flow_director_tos_value,
11288 (void *)&cmd_flow_director_proto,
11289 (void *)&cmd_flow_director_proto_value,
11290 (void *)&cmd_flow_director_ttl,
11291 (void *)&cmd_flow_director_ttl_value,
11292 (void *)&cmd_flow_director_vlan,
11293 (void *)&cmd_flow_director_vlan_value,
11294 (void *)&cmd_flow_director_flexbytes,
11295 (void *)&cmd_flow_director_flexbytes_value,
11296 (void *)&cmd_flow_director_drop,
11297 (void *)&cmd_flow_director_pf_vf,
11298 (void *)&cmd_flow_director_queue,
11299 (void *)&cmd_flow_director_queue_id,
11300 (void *)&cmd_flow_director_fd_id,
11301 (void *)&cmd_flow_director_fd_id_value,
11306 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11307 .f = cmd_flow_director_filter_parsed,
11309 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11310 "director entry on NIC",
11312 (void *)&cmd_flow_director_filter,
11313 (void *)&cmd_flow_director_port_id,
11314 (void *)&cmd_flow_director_mode,
11315 (void *)&cmd_flow_director_mode_ip,
11316 (void *)&cmd_flow_director_ops,
11317 (void *)&cmd_flow_director_flow,
11318 (void *)&cmd_flow_director_flow_type,
11319 (void *)&cmd_flow_director_src,
11320 (void *)&cmd_flow_director_ip_src,
11321 (void *)&cmd_flow_director_port_src,
11322 (void *)&cmd_flow_director_dst,
11323 (void *)&cmd_flow_director_ip_dst,
11324 (void *)&cmd_flow_director_port_dst,
11325 (void *)&cmd_flow_director_tos,
11326 (void *)&cmd_flow_director_tos_value,
11327 (void *)&cmd_flow_director_ttl,
11328 (void *)&cmd_flow_director_ttl_value,
11329 (void *)&cmd_flow_director_vlan,
11330 (void *)&cmd_flow_director_vlan_value,
11331 (void *)&cmd_flow_director_flexbytes,
11332 (void *)&cmd_flow_director_flexbytes_value,
11333 (void *)&cmd_flow_director_drop,
11334 (void *)&cmd_flow_director_pf_vf,
11335 (void *)&cmd_flow_director_queue,
11336 (void *)&cmd_flow_director_queue_id,
11337 (void *)&cmd_flow_director_fd_id,
11338 (void *)&cmd_flow_director_fd_id_value,
11343 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11344 .f = cmd_flow_director_filter_parsed,
11346 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11347 "director entry on NIC",
11349 (void *)&cmd_flow_director_filter,
11350 (void *)&cmd_flow_director_port_id,
11351 (void *)&cmd_flow_director_mode,
11352 (void *)&cmd_flow_director_mode_ip,
11353 (void *)&cmd_flow_director_ops,
11354 (void *)&cmd_flow_director_flow,
11355 (void *)&cmd_flow_director_flow_type,
11356 (void *)&cmd_flow_director_src,
11357 (void *)&cmd_flow_director_ip_src,
11358 (void *)&cmd_flow_director_port_src,
11359 (void *)&cmd_flow_director_dst,
11360 (void *)&cmd_flow_director_ip_dst,
11361 (void *)&cmd_flow_director_port_dst,
11362 (void *)&cmd_flow_director_verify_tag,
11363 (void *)&cmd_flow_director_verify_tag_value,
11364 (void *)&cmd_flow_director_tos,
11365 (void *)&cmd_flow_director_tos_value,
11366 (void *)&cmd_flow_director_ttl,
11367 (void *)&cmd_flow_director_ttl_value,
11368 (void *)&cmd_flow_director_vlan,
11369 (void *)&cmd_flow_director_vlan_value,
11370 (void *)&cmd_flow_director_flexbytes,
11371 (void *)&cmd_flow_director_flexbytes_value,
11372 (void *)&cmd_flow_director_drop,
11373 (void *)&cmd_flow_director_pf_vf,
11374 (void *)&cmd_flow_director_queue,
11375 (void *)&cmd_flow_director_queue_id,
11376 (void *)&cmd_flow_director_fd_id,
11377 (void *)&cmd_flow_director_fd_id_value,
11382 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11383 .f = cmd_flow_director_filter_parsed,
11385 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11386 "director entry on NIC",
11388 (void *)&cmd_flow_director_filter,
11389 (void *)&cmd_flow_director_port_id,
11390 (void *)&cmd_flow_director_mode,
11391 (void *)&cmd_flow_director_mode_ip,
11392 (void *)&cmd_flow_director_ops,
11393 (void *)&cmd_flow_director_flow,
11394 (void *)&cmd_flow_director_flow_type,
11395 (void *)&cmd_flow_director_ether,
11396 (void *)&cmd_flow_director_ether_type,
11397 (void *)&cmd_flow_director_flexbytes,
11398 (void *)&cmd_flow_director_flexbytes_value,
11399 (void *)&cmd_flow_director_drop,
11400 (void *)&cmd_flow_director_pf_vf,
11401 (void *)&cmd_flow_director_queue,
11402 (void *)&cmd_flow_director_queue_id,
11403 (void *)&cmd_flow_director_fd_id,
11404 (void *)&cmd_flow_director_fd_id_value,
11409 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11410 .f = cmd_flow_director_filter_parsed,
11412 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11413 "director entry on NIC",
11415 (void *)&cmd_flow_director_filter,
11416 (void *)&cmd_flow_director_port_id,
11417 (void *)&cmd_flow_director_mode,
11418 (void *)&cmd_flow_director_mode_mac_vlan,
11419 (void *)&cmd_flow_director_ops,
11420 (void *)&cmd_flow_director_mac,
11421 (void *)&cmd_flow_director_mac_addr,
11422 (void *)&cmd_flow_director_vlan,
11423 (void *)&cmd_flow_director_vlan_value,
11424 (void *)&cmd_flow_director_flexbytes,
11425 (void *)&cmd_flow_director_flexbytes_value,
11426 (void *)&cmd_flow_director_drop,
11427 (void *)&cmd_flow_director_queue,
11428 (void *)&cmd_flow_director_queue_id,
11429 (void *)&cmd_flow_director_fd_id,
11430 (void *)&cmd_flow_director_fd_id_value,
11435 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11436 .f = cmd_flow_director_filter_parsed,
11438 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11439 "director entry on NIC",
11441 (void *)&cmd_flow_director_filter,
11442 (void *)&cmd_flow_director_port_id,
11443 (void *)&cmd_flow_director_mode,
11444 (void *)&cmd_flow_director_mode_tunnel,
11445 (void *)&cmd_flow_director_ops,
11446 (void *)&cmd_flow_director_mac,
11447 (void *)&cmd_flow_director_mac_addr,
11448 (void *)&cmd_flow_director_vlan,
11449 (void *)&cmd_flow_director_vlan_value,
11450 (void *)&cmd_flow_director_tunnel,
11451 (void *)&cmd_flow_director_tunnel_type,
11452 (void *)&cmd_flow_director_tunnel_id,
11453 (void *)&cmd_flow_director_tunnel_id_value,
11454 (void *)&cmd_flow_director_flexbytes,
11455 (void *)&cmd_flow_director_flexbytes_value,
11456 (void *)&cmd_flow_director_drop,
11457 (void *)&cmd_flow_director_queue,
11458 (void *)&cmd_flow_director_queue_id,
11459 (void *)&cmd_flow_director_fd_id,
11460 (void *)&cmd_flow_director_fd_id_value,
11465 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11466 .f = cmd_flow_director_filter_parsed,
11468 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11469 "director entry on NIC",
11471 (void *)&cmd_flow_director_filter,
11472 (void *)&cmd_flow_director_port_id,
11473 (void *)&cmd_flow_director_mode,
11474 (void *)&cmd_flow_director_mode_raw,
11475 (void *)&cmd_flow_director_ops,
11476 (void *)&cmd_flow_director_flow,
11477 (void *)&cmd_flow_director_flow_type,
11478 (void *)&cmd_flow_director_drop,
11479 (void *)&cmd_flow_director_queue,
11480 (void *)&cmd_flow_director_queue_id,
11481 (void *)&cmd_flow_director_fd_id,
11482 (void *)&cmd_flow_director_fd_id_value,
11483 (void *)&cmd_flow_director_packet,
11484 (void *)&cmd_flow_director_filepath,
11489 struct cmd_flush_flow_director_result {
11490 cmdline_fixed_string_t flush_flow_director;
11494 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11495 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11496 flush_flow_director, "flush_flow_director");
11497 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11498 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11502 cmd_flush_flow_director_parsed(void *parsed_result,
11503 __attribute__((unused)) struct cmdline *cl,
11504 __attribute__((unused)) void *data)
11506 struct cmd_flow_director_result *res = parsed_result;
11509 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11511 printf("flow director is not supported on port %u.\n",
11516 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11517 RTE_ETH_FILTER_FLUSH, NULL);
11519 printf("flow director table flushing error: (%s)\n",
11523 cmdline_parse_inst_t cmd_flush_flow_director = {
11524 .f = cmd_flush_flow_director_parsed,
11526 .help_str = "flush_flow_director <port_id>: "
11527 "Flush all flow director entries of a device on NIC",
11529 (void *)&cmd_flush_flow_director_flush,
11530 (void *)&cmd_flush_flow_director_port_id,
11535 /* *** deal with flow director mask *** */
11536 struct cmd_flow_director_mask_result {
11537 cmdline_fixed_string_t flow_director_mask;
11539 cmdline_fixed_string_t mode;
11540 cmdline_fixed_string_t mode_value;
11541 cmdline_fixed_string_t vlan;
11542 uint16_t vlan_mask;
11543 cmdline_fixed_string_t src_mask;
11544 cmdline_ipaddr_t ipv4_src;
11545 cmdline_ipaddr_t ipv6_src;
11547 cmdline_fixed_string_t dst_mask;
11548 cmdline_ipaddr_t ipv4_dst;
11549 cmdline_ipaddr_t ipv6_dst;
11551 cmdline_fixed_string_t mac;
11552 uint8_t mac_addr_byte_mask;
11553 cmdline_fixed_string_t tunnel_id;
11554 uint32_t tunnel_id_mask;
11555 cmdline_fixed_string_t tunnel_type;
11556 uint8_t tunnel_type_mask;
11560 cmd_flow_director_mask_parsed(void *parsed_result,
11561 __attribute__((unused)) struct cmdline *cl,
11562 __attribute__((unused)) void *data)
11564 struct cmd_flow_director_mask_result *res = parsed_result;
11565 struct rte_eth_fdir_masks *mask;
11566 struct rte_port *port;
11568 port = &ports[res->port_id];
11569 /** Check if the port is not started **/
11570 if (port->port_status != RTE_PORT_STOPPED) {
11571 printf("Please stop port %d first\n", res->port_id);
11575 mask = &port->dev_conf.fdir_conf.mask;
11577 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11578 if (strcmp(res->mode_value, "MAC-VLAN")) {
11579 printf("Please set mode to MAC-VLAN.\n");
11583 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11584 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11585 if (strcmp(res->mode_value, "Tunnel")) {
11586 printf("Please set mode to Tunnel.\n");
11590 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11591 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11592 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11593 mask->tunnel_type_mask = res->tunnel_type_mask;
11595 if (strcmp(res->mode_value, "IP")) {
11596 printf("Please set mode to IP.\n");
11600 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11601 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11602 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11603 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11604 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11605 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11606 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11609 cmd_reconfig_device_queue(res->port_id, 1, 1);
11612 cmdline_parse_token_string_t cmd_flow_director_mask =
11613 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11614 flow_director_mask, "flow_director_mask");
11615 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11616 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11618 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11619 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11621 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11622 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11623 vlan_mask, UINT16);
11624 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11625 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11626 src_mask, "src_mask");
11627 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11628 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11630 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11631 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11633 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11634 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11636 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11637 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11638 dst_mask, "dst_mask");
11639 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11640 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11642 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11643 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11645 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11646 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11649 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11650 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11652 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11653 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11655 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11656 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11657 mode_value, "MAC-VLAN");
11658 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11659 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11660 mode_value, "Tunnel");
11661 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11662 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11664 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11665 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11666 mac_addr_byte_mask, UINT8);
11667 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11668 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11669 tunnel_type, "tunnel-type");
11670 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11671 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11672 tunnel_type_mask, UINT8);
11673 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11674 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11675 tunnel_id, "tunnel-id");
11676 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11677 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11678 tunnel_id_mask, UINT32);
11680 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11681 .f = cmd_flow_director_mask_parsed,
11683 .help_str = "flow_director_mask ... : "
11684 "Set IP mode flow director's mask on NIC",
11686 (void *)&cmd_flow_director_mask,
11687 (void *)&cmd_flow_director_mask_port_id,
11688 (void *)&cmd_flow_director_mask_mode,
11689 (void *)&cmd_flow_director_mask_mode_ip,
11690 (void *)&cmd_flow_director_mask_vlan,
11691 (void *)&cmd_flow_director_mask_vlan_value,
11692 (void *)&cmd_flow_director_mask_src,
11693 (void *)&cmd_flow_director_mask_ipv4_src,
11694 (void *)&cmd_flow_director_mask_ipv6_src,
11695 (void *)&cmd_flow_director_mask_port_src,
11696 (void *)&cmd_flow_director_mask_dst,
11697 (void *)&cmd_flow_director_mask_ipv4_dst,
11698 (void *)&cmd_flow_director_mask_ipv6_dst,
11699 (void *)&cmd_flow_director_mask_port_dst,
11704 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11705 .f = cmd_flow_director_mask_parsed,
11707 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11708 "flow director's mask on NIC",
11710 (void *)&cmd_flow_director_mask,
11711 (void *)&cmd_flow_director_mask_port_id,
11712 (void *)&cmd_flow_director_mask_mode,
11713 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11714 (void *)&cmd_flow_director_mask_vlan,
11715 (void *)&cmd_flow_director_mask_vlan_value,
11720 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11721 .f = cmd_flow_director_mask_parsed,
11723 .help_str = "flow_director_mask ... : Set tunnel mode "
11724 "flow director's mask on NIC",
11726 (void *)&cmd_flow_director_mask,
11727 (void *)&cmd_flow_director_mask_port_id,
11728 (void *)&cmd_flow_director_mask_mode,
11729 (void *)&cmd_flow_director_mask_mode_tunnel,
11730 (void *)&cmd_flow_director_mask_vlan,
11731 (void *)&cmd_flow_director_mask_vlan_value,
11732 (void *)&cmd_flow_director_mask_mac,
11733 (void *)&cmd_flow_director_mask_mac_value,
11734 (void *)&cmd_flow_director_mask_tunnel_type,
11735 (void *)&cmd_flow_director_mask_tunnel_type_value,
11736 (void *)&cmd_flow_director_mask_tunnel_id,
11737 (void *)&cmd_flow_director_mask_tunnel_id_value,
11742 /* *** deal with flow director mask on flexible payload *** */
11743 struct cmd_flow_director_flex_mask_result {
11744 cmdline_fixed_string_t flow_director_flexmask;
11746 cmdline_fixed_string_t flow;
11747 cmdline_fixed_string_t flow_type;
11748 cmdline_fixed_string_t mask;
11752 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11753 __attribute__((unused)) struct cmdline *cl,
11754 __attribute__((unused)) void *data)
11756 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11757 struct rte_eth_fdir_info fdir_info;
11758 struct rte_eth_fdir_flex_mask flex_mask;
11759 struct rte_port *port;
11760 uint64_t flow_type_mask;
11764 port = &ports[res->port_id];
11765 /** Check if the port is not started **/
11766 if (port->port_status != RTE_PORT_STOPPED) {
11767 printf("Please stop port %d first\n", res->port_id);
11771 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11772 ret = parse_flexbytes(res->mask,
11774 RTE_ETH_FDIR_MAX_FLEXLEN);
11776 printf("error: Cannot parse mask input.\n");
11780 memset(&fdir_info, 0, sizeof(fdir_info));
11781 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11782 RTE_ETH_FILTER_INFO, &fdir_info);
11784 printf("Cannot get FDir filter info\n");
11788 if (!strcmp(res->flow_type, "none")) {
11789 /* means don't specify the flow type */
11790 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11791 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11792 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11793 0, sizeof(struct rte_eth_fdir_flex_mask));
11794 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11795 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11797 sizeof(struct rte_eth_fdir_flex_mask));
11798 cmd_reconfig_device_queue(res->port_id, 1, 1);
11801 flow_type_mask = fdir_info.flow_types_mask[0];
11802 if (!strcmp(res->flow_type, "all")) {
11803 if (!flow_type_mask) {
11804 printf("No flow type supported\n");
11807 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11808 if (flow_type_mask & (1ULL << i)) {
11809 flex_mask.flow_type = i;
11810 fdir_set_flex_mask(res->port_id, &flex_mask);
11813 cmd_reconfig_device_queue(res->port_id, 1, 1);
11816 flex_mask.flow_type = str2flowtype(res->flow_type);
11817 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11818 printf("Flow type %s not supported on port %d\n",
11819 res->flow_type, res->port_id);
11822 fdir_set_flex_mask(res->port_id, &flex_mask);
11823 cmd_reconfig_device_queue(res->port_id, 1, 1);
11826 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11827 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11828 flow_director_flexmask,
11829 "flow_director_flex_mask");
11830 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11831 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11833 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11834 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11836 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11837 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11838 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11839 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11840 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11841 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11844 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11845 .f = cmd_flow_director_flex_mask_parsed,
11847 .help_str = "flow_director_flex_mask ... : "
11848 "Set flow director's flex mask on NIC",
11850 (void *)&cmd_flow_director_flexmask,
11851 (void *)&cmd_flow_director_flexmask_port_id,
11852 (void *)&cmd_flow_director_flexmask_flow,
11853 (void *)&cmd_flow_director_flexmask_flow_type,
11854 (void *)&cmd_flow_director_flexmask_mask,
11859 /* *** deal with flow director flexible payload configuration *** */
11860 struct cmd_flow_director_flexpayload_result {
11861 cmdline_fixed_string_t flow_director_flexpayload;
11863 cmdline_fixed_string_t payload_layer;
11864 cmdline_fixed_string_t payload_cfg;
11868 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11871 const char *p, *p0 = q_arg;
11873 unsigned long int_fld;
11874 char *str_fld[max_num];
11879 p = strchr(p0, '(');
11883 p0 = strchr(p, ')');
11888 if (size >= sizeof(s))
11891 snprintf(s, sizeof(s), "%.*s", size, p);
11892 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11893 if (ret < 0 || ret > max_num)
11895 for (i = 0; i < ret; i++) {
11897 int_fld = strtoul(str_fld[i], &end, 0);
11898 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11900 offsets[i] = (uint16_t)int_fld;
11906 cmd_flow_director_flxpld_parsed(void *parsed_result,
11907 __attribute__((unused)) struct cmdline *cl,
11908 __attribute__((unused)) void *data)
11910 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11911 struct rte_eth_flex_payload_cfg flex_cfg;
11912 struct rte_port *port;
11915 port = &ports[res->port_id];
11916 /** Check if the port is not started **/
11917 if (port->port_status != RTE_PORT_STOPPED) {
11918 printf("Please stop port %d first\n", res->port_id);
11922 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11924 if (!strcmp(res->payload_layer, "raw"))
11925 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11926 else if (!strcmp(res->payload_layer, "l2"))
11927 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11928 else if (!strcmp(res->payload_layer, "l3"))
11929 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11930 else if (!strcmp(res->payload_layer, "l4"))
11931 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11933 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11934 RTE_ETH_FDIR_MAX_FLEXLEN);
11936 printf("error: Cannot parse flex payload input.\n");
11940 fdir_set_flex_payload(res->port_id, &flex_cfg);
11941 cmd_reconfig_device_queue(res->port_id, 1, 1);
11944 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11945 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11946 flow_director_flexpayload,
11947 "flow_director_flex_payload");
11948 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11949 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11951 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11952 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11953 payload_layer, "raw#l2#l3#l4");
11954 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11955 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11956 payload_cfg, NULL);
11958 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11959 .f = cmd_flow_director_flxpld_parsed,
11961 .help_str = "flow_director_flexpayload ... : "
11962 "Set flow director's flex payload on NIC",
11964 (void *)&cmd_flow_director_flexpayload,
11965 (void *)&cmd_flow_director_flexpayload_port_id,
11966 (void *)&cmd_flow_director_flexpayload_payload_layer,
11967 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11972 /* Generic flow interface command. */
11973 extern cmdline_parse_inst_t cmd_flow;
11975 /* *** Classification Filters Control *** */
11976 /* *** Get symmetric hash enable per port *** */
11977 struct cmd_get_sym_hash_ena_per_port_result {
11978 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11983 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11984 __rte_unused struct cmdline *cl,
11985 __rte_unused void *data)
11987 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11988 struct rte_eth_hash_filter_info info;
11991 if (rte_eth_dev_filter_supported(res->port_id,
11992 RTE_ETH_FILTER_HASH) < 0) {
11993 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11998 memset(&info, 0, sizeof(info));
11999 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12000 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12001 RTE_ETH_FILTER_GET, &info);
12004 printf("Cannot get symmetric hash enable per port "
12005 "on port %u\n", res->port_id);
12009 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12010 "enabled" : "disabled", res->port_id);
12013 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12014 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12015 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12016 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12017 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12020 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12021 .f = cmd_get_sym_hash_per_port_parsed,
12023 .help_str = "get_sym_hash_ena_per_port <port_id>",
12025 (void *)&cmd_get_sym_hash_ena_per_port_all,
12026 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12031 /* *** Set symmetric hash enable per port *** */
12032 struct cmd_set_sym_hash_ena_per_port_result {
12033 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12034 cmdline_fixed_string_t enable;
12039 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12040 __rte_unused struct cmdline *cl,
12041 __rte_unused void *data)
12043 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12044 struct rte_eth_hash_filter_info info;
12047 if (rte_eth_dev_filter_supported(res->port_id,
12048 RTE_ETH_FILTER_HASH) < 0) {
12049 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12054 memset(&info, 0, sizeof(info));
12055 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12056 if (!strcmp(res->enable, "enable"))
12057 info.info.enable = 1;
12058 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12059 RTE_ETH_FILTER_SET, &info);
12061 printf("Cannot set symmetric hash enable per port on "
12062 "port %u\n", res->port_id);
12065 printf("Symmetric hash has been set to %s on port %u\n",
12066 res->enable, res->port_id);
12069 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12070 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12071 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12072 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12073 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12075 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12076 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12077 enable, "enable#disable");
12079 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12080 .f = cmd_set_sym_hash_per_port_parsed,
12082 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12084 (void *)&cmd_set_sym_hash_ena_per_port_all,
12085 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12086 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12091 /* Get global config of hash function */
12092 struct cmd_get_hash_global_config_result {
12093 cmdline_fixed_string_t get_hash_global_config;
12098 flowtype_to_str(uint16_t ftype)
12104 } ftype_table[] = {
12105 {"ipv4", RTE_ETH_FLOW_IPV4},
12106 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12107 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12108 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12109 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12110 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12111 {"ipv6", RTE_ETH_FLOW_IPV6},
12112 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12113 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12114 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12115 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12116 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12117 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12118 {"port", RTE_ETH_FLOW_PORT},
12119 {"vxlan", RTE_ETH_FLOW_VXLAN},
12120 {"geneve", RTE_ETH_FLOW_GENEVE},
12121 {"nvgre", RTE_ETH_FLOW_NVGRE},
12122 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12125 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12126 if (ftype_table[i].ftype == ftype)
12127 return ftype_table[i].str;
12134 cmd_get_hash_global_config_parsed(void *parsed_result,
12135 __rte_unused struct cmdline *cl,
12136 __rte_unused void *data)
12138 struct cmd_get_hash_global_config_result *res = parsed_result;
12139 struct rte_eth_hash_filter_info info;
12140 uint32_t idx, offset;
12145 if (rte_eth_dev_filter_supported(res->port_id,
12146 RTE_ETH_FILTER_HASH) < 0) {
12147 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12152 memset(&info, 0, sizeof(info));
12153 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12154 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12155 RTE_ETH_FILTER_GET, &info);
12157 printf("Cannot get hash global configurations by port %d\n",
12162 switch (info.info.global_conf.hash_func) {
12163 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12164 printf("Hash function is Toeplitz\n");
12166 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12167 printf("Hash function is Simple XOR\n");
12170 printf("Unknown hash function\n");
12174 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12175 idx = i / UINT64_BIT;
12176 offset = i % UINT64_BIT;
12177 if (!(info.info.global_conf.valid_bit_mask[idx] &
12180 str = flowtype_to_str(i);
12183 printf("Symmetric hash is %s globally for flow type %s "
12185 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12186 (1ULL << offset)) ? "enabled" : "disabled"), str,
12191 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12192 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12193 get_hash_global_config, "get_hash_global_config");
12194 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12195 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12198 cmdline_parse_inst_t cmd_get_hash_global_config = {
12199 .f = cmd_get_hash_global_config_parsed,
12201 .help_str = "get_hash_global_config <port_id>",
12203 (void *)&cmd_get_hash_global_config_all,
12204 (void *)&cmd_get_hash_global_config_port_id,
12209 /* Set global config of hash function */
12210 struct cmd_set_hash_global_config_result {
12211 cmdline_fixed_string_t set_hash_global_config;
12213 cmdline_fixed_string_t hash_func;
12214 cmdline_fixed_string_t flow_type;
12215 cmdline_fixed_string_t enable;
12219 cmd_set_hash_global_config_parsed(void *parsed_result,
12220 __rte_unused struct cmdline *cl,
12221 __rte_unused void *data)
12223 struct cmd_set_hash_global_config_result *res = parsed_result;
12224 struct rte_eth_hash_filter_info info;
12225 uint32_t ftype, idx, offset;
12228 if (rte_eth_dev_filter_supported(res->port_id,
12229 RTE_ETH_FILTER_HASH) < 0) {
12230 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12234 memset(&info, 0, sizeof(info));
12235 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12236 if (!strcmp(res->hash_func, "toeplitz"))
12237 info.info.global_conf.hash_func =
12238 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12239 else if (!strcmp(res->hash_func, "simple_xor"))
12240 info.info.global_conf.hash_func =
12241 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12242 else if (!strcmp(res->hash_func, "default"))
12243 info.info.global_conf.hash_func =
12244 RTE_ETH_HASH_FUNCTION_DEFAULT;
12246 ftype = str2flowtype(res->flow_type);
12247 idx = ftype / UINT64_BIT;
12248 offset = ftype % UINT64_BIT;
12249 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12250 if (!strcmp(res->enable, "enable"))
12251 info.info.global_conf.sym_hash_enable_mask[idx] |=
12253 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12254 RTE_ETH_FILTER_SET, &info);
12256 printf("Cannot set global hash configurations by port %d\n",
12259 printf("Global hash configurations have been set "
12260 "successfully by port %d\n", res->port_id);
12263 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12264 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12265 set_hash_global_config, "set_hash_global_config");
12266 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12267 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12269 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12270 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12271 hash_func, "toeplitz#simple_xor#default");
12272 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12273 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12275 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12276 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12277 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12278 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12279 enable, "enable#disable");
12281 cmdline_parse_inst_t cmd_set_hash_global_config = {
12282 .f = cmd_set_hash_global_config_parsed,
12284 .help_str = "set_hash_global_config <port_id> "
12285 "toeplitz|simple_xor|default "
12286 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12287 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12288 "l2_payload enable|disable",
12290 (void *)&cmd_set_hash_global_config_all,
12291 (void *)&cmd_set_hash_global_config_port_id,
12292 (void *)&cmd_set_hash_global_config_hash_func,
12293 (void *)&cmd_set_hash_global_config_flow_type,
12294 (void *)&cmd_set_hash_global_config_enable,
12299 /* Set hash input set */
12300 struct cmd_set_hash_input_set_result {
12301 cmdline_fixed_string_t set_hash_input_set;
12303 cmdline_fixed_string_t flow_type;
12304 cmdline_fixed_string_t inset_field;
12305 cmdline_fixed_string_t select;
12308 static enum rte_eth_input_set_field
12309 str2inset(char *string)
12313 static const struct {
12315 enum rte_eth_input_set_field inset;
12316 } inset_table[] = {
12317 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12318 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12319 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12320 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12321 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12322 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12323 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12324 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12325 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12326 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12327 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12328 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12329 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12330 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12331 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12332 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12333 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12334 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12335 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12336 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12337 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12338 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12339 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12340 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12341 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12342 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12343 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12344 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12345 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12346 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12347 {"none", RTE_ETH_INPUT_SET_NONE},
12350 for (i = 0; i < RTE_DIM(inset_table); i++) {
12351 if (!strcmp(string, inset_table[i].str))
12352 return inset_table[i].inset;
12355 return RTE_ETH_INPUT_SET_UNKNOWN;
12359 cmd_set_hash_input_set_parsed(void *parsed_result,
12360 __rte_unused struct cmdline *cl,
12361 __rte_unused void *data)
12363 struct cmd_set_hash_input_set_result *res = parsed_result;
12364 struct rte_eth_hash_filter_info info;
12366 memset(&info, 0, sizeof(info));
12367 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12368 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12369 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12370 info.info.input_set_conf.inset_size = 1;
12371 if (!strcmp(res->select, "select"))
12372 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12373 else if (!strcmp(res->select, "add"))
12374 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12375 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12376 RTE_ETH_FILTER_SET, &info);
12379 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12380 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12381 set_hash_input_set, "set_hash_input_set");
12382 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12383 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12385 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12386 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12388 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12389 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12391 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12392 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12393 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12394 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12395 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12397 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12398 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12399 select, "select#add");
12401 cmdline_parse_inst_t cmd_set_hash_input_set = {
12402 .f = cmd_set_hash_input_set_parsed,
12404 .help_str = "set_hash_input_set <port_id> "
12405 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12406 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12407 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12408 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12409 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12410 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12411 "fld-7th|fld-8th|none select|add",
12413 (void *)&cmd_set_hash_input_set_cmd,
12414 (void *)&cmd_set_hash_input_set_port_id,
12415 (void *)&cmd_set_hash_input_set_flow_type,
12416 (void *)&cmd_set_hash_input_set_field,
12417 (void *)&cmd_set_hash_input_set_select,
12422 /* Set flow director input set */
12423 struct cmd_set_fdir_input_set_result {
12424 cmdline_fixed_string_t set_fdir_input_set;
12426 cmdline_fixed_string_t flow_type;
12427 cmdline_fixed_string_t inset_field;
12428 cmdline_fixed_string_t select;
12432 cmd_set_fdir_input_set_parsed(void *parsed_result,
12433 __rte_unused struct cmdline *cl,
12434 __rte_unused void *data)
12436 struct cmd_set_fdir_input_set_result *res = parsed_result;
12437 struct rte_eth_fdir_filter_info info;
12439 memset(&info, 0, sizeof(info));
12440 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12441 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12442 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12443 info.info.input_set_conf.inset_size = 1;
12444 if (!strcmp(res->select, "select"))
12445 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12446 else if (!strcmp(res->select, "add"))
12447 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12448 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12449 RTE_ETH_FILTER_SET, &info);
12452 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12453 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12454 set_fdir_input_set, "set_fdir_input_set");
12455 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12456 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12458 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12459 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12461 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12462 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12463 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12464 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12466 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12467 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12468 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12469 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12470 "sctp-veri-tag#none");
12471 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12472 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12473 select, "select#add");
12475 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12476 .f = cmd_set_fdir_input_set_parsed,
12478 .help_str = "set_fdir_input_set <port_id> "
12479 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12480 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12481 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12482 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12483 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12484 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12485 "sctp-veri-tag|none select|add",
12487 (void *)&cmd_set_fdir_input_set_cmd,
12488 (void *)&cmd_set_fdir_input_set_port_id,
12489 (void *)&cmd_set_fdir_input_set_flow_type,
12490 (void *)&cmd_set_fdir_input_set_field,
12491 (void *)&cmd_set_fdir_input_set_select,
12496 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12497 struct cmd_mcast_addr_result {
12498 cmdline_fixed_string_t mcast_addr_cmd;
12499 cmdline_fixed_string_t what;
12501 struct rte_ether_addr mc_addr;
12504 static void cmd_mcast_addr_parsed(void *parsed_result,
12505 __attribute__((unused)) struct cmdline *cl,
12506 __attribute__((unused)) void *data)
12508 struct cmd_mcast_addr_result *res = parsed_result;
12510 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12511 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12512 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12513 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12514 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12517 if (strcmp(res->what, "add") == 0)
12518 mcast_addr_add(res->port_num, &res->mc_addr);
12520 mcast_addr_remove(res->port_num, &res->mc_addr);
12523 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12524 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12525 mcast_addr_cmd, "mcast_addr");
12526 cmdline_parse_token_string_t cmd_mcast_addr_what =
12527 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12529 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12530 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12531 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12532 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12534 cmdline_parse_inst_t cmd_mcast_addr = {
12535 .f = cmd_mcast_addr_parsed,
12537 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12538 "Add/Remove multicast MAC address on port_id",
12540 (void *)&cmd_mcast_addr_cmd,
12541 (void *)&cmd_mcast_addr_what,
12542 (void *)&cmd_mcast_addr_portnum,
12543 (void *)&cmd_mcast_addr_addr,
12548 /* l2 tunnel config
12549 * only support E-tag now.
12552 /* Ether type config */
12553 struct cmd_config_l2_tunnel_eth_type_result {
12554 cmdline_fixed_string_t port;
12555 cmdline_fixed_string_t config;
12556 cmdline_fixed_string_t all;
12558 cmdline_fixed_string_t l2_tunnel;
12559 cmdline_fixed_string_t l2_tunnel_type;
12560 cmdline_fixed_string_t eth_type;
12561 uint16_t eth_type_val;
12564 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
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_config =
12569 TOKEN_STRING_INITIALIZER
12570 (struct cmd_config_l2_tunnel_eth_type_result,
12572 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12573 TOKEN_STRING_INITIALIZER
12574 (struct cmd_config_l2_tunnel_eth_type_result,
12576 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12577 TOKEN_NUM_INITIALIZER
12578 (struct cmd_config_l2_tunnel_eth_type_result,
12580 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12581 TOKEN_STRING_INITIALIZER
12582 (struct cmd_config_l2_tunnel_eth_type_result,
12583 l2_tunnel, "l2-tunnel");
12584 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12585 TOKEN_STRING_INITIALIZER
12586 (struct cmd_config_l2_tunnel_eth_type_result,
12587 l2_tunnel_type, "E-tag");
12588 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12589 TOKEN_STRING_INITIALIZER
12590 (struct cmd_config_l2_tunnel_eth_type_result,
12591 eth_type, "ether-type");
12592 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12593 TOKEN_NUM_INITIALIZER
12594 (struct cmd_config_l2_tunnel_eth_type_result,
12595 eth_type_val, UINT16);
12597 static enum rte_eth_tunnel_type
12598 str2fdir_l2_tunnel_type(char *string)
12602 static const struct {
12604 enum rte_eth_tunnel_type type;
12605 } l2_tunnel_type_str[] = {
12606 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12609 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12610 if (!strcmp(l2_tunnel_type_str[i].str, string))
12611 return l2_tunnel_type_str[i].type;
12613 return RTE_TUNNEL_TYPE_NONE;
12616 /* ether type config for all ports */
12618 cmd_config_l2_tunnel_eth_type_all_parsed
12619 (void *parsed_result,
12620 __attribute__((unused)) struct cmdline *cl,
12621 __attribute__((unused)) void *data)
12623 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12624 struct rte_eth_l2_tunnel_conf entry;
12627 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12628 entry.ether_type = res->eth_type_val;
12630 RTE_ETH_FOREACH_DEV(pid) {
12631 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12635 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12636 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12638 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12640 (void *)&cmd_config_l2_tunnel_eth_type_port,
12641 (void *)&cmd_config_l2_tunnel_eth_type_config,
12642 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12643 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12644 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12645 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12646 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12651 /* ether type config for a specific port */
12653 cmd_config_l2_tunnel_eth_type_specific_parsed(
12654 void *parsed_result,
12655 __attribute__((unused)) struct cmdline *cl,
12656 __attribute__((unused)) void *data)
12658 struct cmd_config_l2_tunnel_eth_type_result *res =
12660 struct rte_eth_l2_tunnel_conf entry;
12662 if (port_id_is_invalid(res->id, ENABLED_WARN))
12665 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12666 entry.ether_type = res->eth_type_val;
12668 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12671 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12672 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12674 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12676 (void *)&cmd_config_l2_tunnel_eth_type_port,
12677 (void *)&cmd_config_l2_tunnel_eth_type_config,
12678 (void *)&cmd_config_l2_tunnel_eth_type_id,
12679 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12680 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12681 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12682 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12687 /* Enable/disable l2 tunnel */
12688 struct cmd_config_l2_tunnel_en_dis_result {
12689 cmdline_fixed_string_t port;
12690 cmdline_fixed_string_t config;
12691 cmdline_fixed_string_t all;
12693 cmdline_fixed_string_t l2_tunnel;
12694 cmdline_fixed_string_t l2_tunnel_type;
12695 cmdline_fixed_string_t en_dis;
12698 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
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_config =
12703 TOKEN_STRING_INITIALIZER
12704 (struct cmd_config_l2_tunnel_en_dis_result,
12706 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12707 TOKEN_STRING_INITIALIZER
12708 (struct cmd_config_l2_tunnel_en_dis_result,
12710 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12711 TOKEN_NUM_INITIALIZER
12712 (struct cmd_config_l2_tunnel_en_dis_result,
12714 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12715 TOKEN_STRING_INITIALIZER
12716 (struct cmd_config_l2_tunnel_en_dis_result,
12717 l2_tunnel, "l2-tunnel");
12718 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12719 TOKEN_STRING_INITIALIZER
12720 (struct cmd_config_l2_tunnel_en_dis_result,
12721 l2_tunnel_type, "E-tag");
12722 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12723 TOKEN_STRING_INITIALIZER
12724 (struct cmd_config_l2_tunnel_en_dis_result,
12725 en_dis, "enable#disable");
12727 /* enable/disable l2 tunnel for all ports */
12729 cmd_config_l2_tunnel_en_dis_all_parsed(
12730 void *parsed_result,
12731 __attribute__((unused)) struct cmdline *cl,
12732 __attribute__((unused)) void *data)
12734 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12735 struct rte_eth_l2_tunnel_conf entry;
12739 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12741 if (!strcmp("enable", res->en_dis))
12746 RTE_ETH_FOREACH_DEV(pid) {
12747 rte_eth_dev_l2_tunnel_offload_set(pid,
12749 ETH_L2_TUNNEL_ENABLE_MASK,
12754 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12755 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12757 .help_str = "port config all l2-tunnel E-tag enable|disable",
12759 (void *)&cmd_config_l2_tunnel_en_dis_port,
12760 (void *)&cmd_config_l2_tunnel_en_dis_config,
12761 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12762 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12763 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12764 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12769 /* enable/disable l2 tunnel for a port */
12771 cmd_config_l2_tunnel_en_dis_specific_parsed(
12772 void *parsed_result,
12773 __attribute__((unused)) struct cmdline *cl,
12774 __attribute__((unused)) void *data)
12776 struct cmd_config_l2_tunnel_en_dis_result *res =
12778 struct rte_eth_l2_tunnel_conf entry;
12780 if (port_id_is_invalid(res->id, ENABLED_WARN))
12783 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12785 if (!strcmp("enable", res->en_dis))
12786 rte_eth_dev_l2_tunnel_offload_set(res->id,
12788 ETH_L2_TUNNEL_ENABLE_MASK,
12791 rte_eth_dev_l2_tunnel_offload_set(res->id,
12793 ETH_L2_TUNNEL_ENABLE_MASK,
12797 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12798 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12800 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12802 (void *)&cmd_config_l2_tunnel_en_dis_port,
12803 (void *)&cmd_config_l2_tunnel_en_dis_config,
12804 (void *)&cmd_config_l2_tunnel_en_dis_id,
12805 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12806 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12807 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12812 /* E-tag configuration */
12814 /* Common result structure for all E-tag configuration */
12815 struct cmd_config_e_tag_result {
12816 cmdline_fixed_string_t e_tag;
12817 cmdline_fixed_string_t set;
12818 cmdline_fixed_string_t insertion;
12819 cmdline_fixed_string_t stripping;
12820 cmdline_fixed_string_t forwarding;
12821 cmdline_fixed_string_t filter;
12822 cmdline_fixed_string_t add;
12823 cmdline_fixed_string_t del;
12824 cmdline_fixed_string_t on;
12825 cmdline_fixed_string_t off;
12826 cmdline_fixed_string_t on_off;
12827 cmdline_fixed_string_t port_tag_id;
12828 uint32_t port_tag_id_val;
12829 cmdline_fixed_string_t e_tag_id;
12830 uint16_t e_tag_id_val;
12831 cmdline_fixed_string_t dst_pool;
12832 uint8_t dst_pool_val;
12833 cmdline_fixed_string_t port;
12835 cmdline_fixed_string_t vf;
12839 /* Common CLI fields for all E-tag configuration */
12840 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12841 TOKEN_STRING_INITIALIZER
12842 (struct cmd_config_e_tag_result,
12844 cmdline_parse_token_string_t cmd_config_e_tag_set =
12845 TOKEN_STRING_INITIALIZER
12846 (struct cmd_config_e_tag_result,
12848 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12849 TOKEN_STRING_INITIALIZER
12850 (struct cmd_config_e_tag_result,
12851 insertion, "insertion");
12852 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12853 TOKEN_STRING_INITIALIZER
12854 (struct cmd_config_e_tag_result,
12855 stripping, "stripping");
12856 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12857 TOKEN_STRING_INITIALIZER
12858 (struct cmd_config_e_tag_result,
12859 forwarding, "forwarding");
12860 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12861 TOKEN_STRING_INITIALIZER
12862 (struct cmd_config_e_tag_result,
12864 cmdline_parse_token_string_t cmd_config_e_tag_add =
12865 TOKEN_STRING_INITIALIZER
12866 (struct cmd_config_e_tag_result,
12868 cmdline_parse_token_string_t cmd_config_e_tag_del =
12869 TOKEN_STRING_INITIALIZER
12870 (struct cmd_config_e_tag_result,
12872 cmdline_parse_token_string_t cmd_config_e_tag_on =
12873 TOKEN_STRING_INITIALIZER
12874 (struct cmd_config_e_tag_result,
12876 cmdline_parse_token_string_t cmd_config_e_tag_off =
12877 TOKEN_STRING_INITIALIZER
12878 (struct cmd_config_e_tag_result,
12880 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12881 TOKEN_STRING_INITIALIZER
12882 (struct cmd_config_e_tag_result,
12884 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12885 TOKEN_STRING_INITIALIZER
12886 (struct cmd_config_e_tag_result,
12887 port_tag_id, "port-tag-id");
12888 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12889 TOKEN_NUM_INITIALIZER
12890 (struct cmd_config_e_tag_result,
12891 port_tag_id_val, UINT32);
12892 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12893 TOKEN_STRING_INITIALIZER
12894 (struct cmd_config_e_tag_result,
12895 e_tag_id, "e-tag-id");
12896 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12897 TOKEN_NUM_INITIALIZER
12898 (struct cmd_config_e_tag_result,
12899 e_tag_id_val, UINT16);
12900 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12901 TOKEN_STRING_INITIALIZER
12902 (struct cmd_config_e_tag_result,
12903 dst_pool, "dst-pool");
12904 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12905 TOKEN_NUM_INITIALIZER
12906 (struct cmd_config_e_tag_result,
12907 dst_pool_val, UINT8);
12908 cmdline_parse_token_string_t cmd_config_e_tag_port =
12909 TOKEN_STRING_INITIALIZER
12910 (struct cmd_config_e_tag_result,
12912 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12913 TOKEN_NUM_INITIALIZER
12914 (struct cmd_config_e_tag_result,
12916 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12917 TOKEN_STRING_INITIALIZER
12918 (struct cmd_config_e_tag_result,
12920 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12921 TOKEN_NUM_INITIALIZER
12922 (struct cmd_config_e_tag_result,
12925 /* E-tag insertion configuration */
12927 cmd_config_e_tag_insertion_en_parsed(
12928 void *parsed_result,
12929 __attribute__((unused)) struct cmdline *cl,
12930 __attribute__((unused)) void *data)
12932 struct cmd_config_e_tag_result *res =
12934 struct rte_eth_l2_tunnel_conf entry;
12936 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12939 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12940 entry.tunnel_id = res->port_tag_id_val;
12941 entry.vf_id = res->vf_id;
12942 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12944 ETH_L2_TUNNEL_INSERTION_MASK,
12949 cmd_config_e_tag_insertion_dis_parsed(
12950 void *parsed_result,
12951 __attribute__((unused)) struct cmdline *cl,
12952 __attribute__((unused)) void *data)
12954 struct cmd_config_e_tag_result *res =
12956 struct rte_eth_l2_tunnel_conf entry;
12958 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12961 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12962 entry.vf_id = res->vf_id;
12964 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12966 ETH_L2_TUNNEL_INSERTION_MASK,
12970 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12971 .f = cmd_config_e_tag_insertion_en_parsed,
12973 .help_str = "E-tag ... : E-tag insertion enable",
12975 (void *)&cmd_config_e_tag_e_tag,
12976 (void *)&cmd_config_e_tag_set,
12977 (void *)&cmd_config_e_tag_insertion,
12978 (void *)&cmd_config_e_tag_on,
12979 (void *)&cmd_config_e_tag_port_tag_id,
12980 (void *)&cmd_config_e_tag_port_tag_id_val,
12981 (void *)&cmd_config_e_tag_port,
12982 (void *)&cmd_config_e_tag_port_id,
12983 (void *)&cmd_config_e_tag_vf,
12984 (void *)&cmd_config_e_tag_vf_id,
12989 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12990 .f = cmd_config_e_tag_insertion_dis_parsed,
12992 .help_str = "E-tag ... : E-tag insertion disable",
12994 (void *)&cmd_config_e_tag_e_tag,
12995 (void *)&cmd_config_e_tag_set,
12996 (void *)&cmd_config_e_tag_insertion,
12997 (void *)&cmd_config_e_tag_off,
12998 (void *)&cmd_config_e_tag_port,
12999 (void *)&cmd_config_e_tag_port_id,
13000 (void *)&cmd_config_e_tag_vf,
13001 (void *)&cmd_config_e_tag_vf_id,
13006 /* E-tag stripping configuration */
13008 cmd_config_e_tag_stripping_parsed(
13009 void *parsed_result,
13010 __attribute__((unused)) struct cmdline *cl,
13011 __attribute__((unused)) void *data)
13013 struct cmd_config_e_tag_result *res =
13015 struct rte_eth_l2_tunnel_conf entry;
13017 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13020 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13022 if (!strcmp(res->on_off, "on"))
13023 rte_eth_dev_l2_tunnel_offload_set
13026 ETH_L2_TUNNEL_STRIPPING_MASK,
13029 rte_eth_dev_l2_tunnel_offload_set
13032 ETH_L2_TUNNEL_STRIPPING_MASK,
13036 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13037 .f = cmd_config_e_tag_stripping_parsed,
13039 .help_str = "E-tag ... : E-tag stripping enable/disable",
13041 (void *)&cmd_config_e_tag_e_tag,
13042 (void *)&cmd_config_e_tag_set,
13043 (void *)&cmd_config_e_tag_stripping,
13044 (void *)&cmd_config_e_tag_on_off,
13045 (void *)&cmd_config_e_tag_port,
13046 (void *)&cmd_config_e_tag_port_id,
13051 /* E-tag forwarding configuration */
13053 cmd_config_e_tag_forwarding_parsed(
13054 void *parsed_result,
13055 __attribute__((unused)) struct cmdline *cl,
13056 __attribute__((unused)) void *data)
13058 struct cmd_config_e_tag_result *res = parsed_result;
13059 struct rte_eth_l2_tunnel_conf entry;
13061 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13064 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13066 if (!strcmp(res->on_off, "on"))
13067 rte_eth_dev_l2_tunnel_offload_set
13070 ETH_L2_TUNNEL_FORWARDING_MASK,
13073 rte_eth_dev_l2_tunnel_offload_set
13076 ETH_L2_TUNNEL_FORWARDING_MASK,
13080 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13081 .f = cmd_config_e_tag_forwarding_parsed,
13083 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13085 (void *)&cmd_config_e_tag_e_tag,
13086 (void *)&cmd_config_e_tag_set,
13087 (void *)&cmd_config_e_tag_forwarding,
13088 (void *)&cmd_config_e_tag_on_off,
13089 (void *)&cmd_config_e_tag_port,
13090 (void *)&cmd_config_e_tag_port_id,
13095 /* E-tag filter configuration */
13097 cmd_config_e_tag_filter_add_parsed(
13098 void *parsed_result,
13099 __attribute__((unused)) struct cmdline *cl,
13100 __attribute__((unused)) void *data)
13102 struct cmd_config_e_tag_result *res = parsed_result;
13103 struct rte_eth_l2_tunnel_conf entry;
13106 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13109 if (res->e_tag_id_val > 0x3fff) {
13110 printf("e-tag-id must be equal or less than 0x3fff.\n");
13114 ret = rte_eth_dev_filter_supported(res->port_id,
13115 RTE_ETH_FILTER_L2_TUNNEL);
13117 printf("E-tag filter is not supported on port %u.\n",
13122 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13123 entry.tunnel_id = res->e_tag_id_val;
13124 entry.pool = res->dst_pool_val;
13126 ret = rte_eth_dev_filter_ctrl(res->port_id,
13127 RTE_ETH_FILTER_L2_TUNNEL,
13128 RTE_ETH_FILTER_ADD,
13131 printf("E-tag filter programming error: (%s)\n",
13135 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13136 .f = cmd_config_e_tag_filter_add_parsed,
13138 .help_str = "E-tag ... : E-tag filter add",
13140 (void *)&cmd_config_e_tag_e_tag,
13141 (void *)&cmd_config_e_tag_set,
13142 (void *)&cmd_config_e_tag_filter,
13143 (void *)&cmd_config_e_tag_add,
13144 (void *)&cmd_config_e_tag_e_tag_id,
13145 (void *)&cmd_config_e_tag_e_tag_id_val,
13146 (void *)&cmd_config_e_tag_dst_pool,
13147 (void *)&cmd_config_e_tag_dst_pool_val,
13148 (void *)&cmd_config_e_tag_port,
13149 (void *)&cmd_config_e_tag_port_id,
13155 cmd_config_e_tag_filter_del_parsed(
13156 void *parsed_result,
13157 __attribute__((unused)) struct cmdline *cl,
13158 __attribute__((unused)) void *data)
13160 struct cmd_config_e_tag_result *res = parsed_result;
13161 struct rte_eth_l2_tunnel_conf entry;
13164 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13167 if (res->e_tag_id_val > 0x3fff) {
13168 printf("e-tag-id must be less than 0x3fff.\n");
13172 ret = rte_eth_dev_filter_supported(res->port_id,
13173 RTE_ETH_FILTER_L2_TUNNEL);
13175 printf("E-tag filter is not supported on port %u.\n",
13180 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13181 entry.tunnel_id = res->e_tag_id_val;
13183 ret = rte_eth_dev_filter_ctrl(res->port_id,
13184 RTE_ETH_FILTER_L2_TUNNEL,
13185 RTE_ETH_FILTER_DELETE,
13188 printf("E-tag filter programming error: (%s)\n",
13192 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13193 .f = cmd_config_e_tag_filter_del_parsed,
13195 .help_str = "E-tag ... : E-tag filter delete",
13197 (void *)&cmd_config_e_tag_e_tag,
13198 (void *)&cmd_config_e_tag_set,
13199 (void *)&cmd_config_e_tag_filter,
13200 (void *)&cmd_config_e_tag_del,
13201 (void *)&cmd_config_e_tag_e_tag_id,
13202 (void *)&cmd_config_e_tag_e_tag_id_val,
13203 (void *)&cmd_config_e_tag_port,
13204 (void *)&cmd_config_e_tag_port_id,
13209 /* vf vlan anti spoof configuration */
13211 /* Common result structure for vf vlan anti spoof */
13212 struct cmd_vf_vlan_anti_spoof_result {
13213 cmdline_fixed_string_t set;
13214 cmdline_fixed_string_t vf;
13215 cmdline_fixed_string_t vlan;
13216 cmdline_fixed_string_t antispoof;
13219 cmdline_fixed_string_t on_off;
13222 /* Common CLI fields for vf vlan anti spoof enable disable */
13223 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13224 TOKEN_STRING_INITIALIZER
13225 (struct cmd_vf_vlan_anti_spoof_result,
13227 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13228 TOKEN_STRING_INITIALIZER
13229 (struct cmd_vf_vlan_anti_spoof_result,
13231 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13232 TOKEN_STRING_INITIALIZER
13233 (struct cmd_vf_vlan_anti_spoof_result,
13235 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13236 TOKEN_STRING_INITIALIZER
13237 (struct cmd_vf_vlan_anti_spoof_result,
13238 antispoof, "antispoof");
13239 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13240 TOKEN_NUM_INITIALIZER
13241 (struct cmd_vf_vlan_anti_spoof_result,
13243 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13244 TOKEN_NUM_INITIALIZER
13245 (struct cmd_vf_vlan_anti_spoof_result,
13247 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13248 TOKEN_STRING_INITIALIZER
13249 (struct cmd_vf_vlan_anti_spoof_result,
13253 cmd_set_vf_vlan_anti_spoof_parsed(
13254 void *parsed_result,
13255 __attribute__((unused)) struct cmdline *cl,
13256 __attribute__((unused)) void *data)
13258 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13259 int ret = -ENOTSUP;
13261 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13263 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13266 #ifdef RTE_LIBRTE_IXGBE_PMD
13267 if (ret == -ENOTSUP)
13268 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13269 res->vf_id, is_on);
13271 #ifdef RTE_LIBRTE_I40E_PMD
13272 if (ret == -ENOTSUP)
13273 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13274 res->vf_id, is_on);
13276 #ifdef RTE_LIBRTE_BNXT_PMD
13277 if (ret == -ENOTSUP)
13278 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13279 res->vf_id, is_on);
13286 printf("invalid vf_id %d\n", res->vf_id);
13289 printf("invalid port_id %d\n", res->port_id);
13292 printf("function not implemented\n");
13295 printf("programming error: (%s)\n", strerror(-ret));
13299 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13300 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13302 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13304 (void *)&cmd_vf_vlan_anti_spoof_set,
13305 (void *)&cmd_vf_vlan_anti_spoof_vf,
13306 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13307 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13308 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13309 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13310 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13315 /* vf mac anti spoof configuration */
13317 /* Common result structure for vf mac anti spoof */
13318 struct cmd_vf_mac_anti_spoof_result {
13319 cmdline_fixed_string_t set;
13320 cmdline_fixed_string_t vf;
13321 cmdline_fixed_string_t mac;
13322 cmdline_fixed_string_t antispoof;
13325 cmdline_fixed_string_t on_off;
13328 /* Common CLI fields for vf mac anti spoof enable disable */
13329 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13330 TOKEN_STRING_INITIALIZER
13331 (struct cmd_vf_mac_anti_spoof_result,
13333 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13334 TOKEN_STRING_INITIALIZER
13335 (struct cmd_vf_mac_anti_spoof_result,
13337 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13338 TOKEN_STRING_INITIALIZER
13339 (struct cmd_vf_mac_anti_spoof_result,
13341 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13342 TOKEN_STRING_INITIALIZER
13343 (struct cmd_vf_mac_anti_spoof_result,
13344 antispoof, "antispoof");
13345 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13346 TOKEN_NUM_INITIALIZER
13347 (struct cmd_vf_mac_anti_spoof_result,
13349 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13350 TOKEN_NUM_INITIALIZER
13351 (struct cmd_vf_mac_anti_spoof_result,
13353 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13354 TOKEN_STRING_INITIALIZER
13355 (struct cmd_vf_mac_anti_spoof_result,
13359 cmd_set_vf_mac_anti_spoof_parsed(
13360 void *parsed_result,
13361 __attribute__((unused)) struct cmdline *cl,
13362 __attribute__((unused)) void *data)
13364 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13365 int ret = -ENOTSUP;
13367 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13369 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13372 #ifdef RTE_LIBRTE_IXGBE_PMD
13373 if (ret == -ENOTSUP)
13374 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13375 res->vf_id, is_on);
13377 #ifdef RTE_LIBRTE_I40E_PMD
13378 if (ret == -ENOTSUP)
13379 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13380 res->vf_id, is_on);
13382 #ifdef RTE_LIBRTE_BNXT_PMD
13383 if (ret == -ENOTSUP)
13384 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13385 res->vf_id, is_on);
13392 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13395 printf("invalid port_id %d\n", res->port_id);
13398 printf("function not implemented\n");
13401 printf("programming error: (%s)\n", strerror(-ret));
13405 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13406 .f = cmd_set_vf_mac_anti_spoof_parsed,
13408 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13410 (void *)&cmd_vf_mac_anti_spoof_set,
13411 (void *)&cmd_vf_mac_anti_spoof_vf,
13412 (void *)&cmd_vf_mac_anti_spoof_mac,
13413 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13414 (void *)&cmd_vf_mac_anti_spoof_port_id,
13415 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13416 (void *)&cmd_vf_mac_anti_spoof_on_off,
13421 /* vf vlan strip queue configuration */
13423 /* Common result structure for vf mac anti spoof */
13424 struct cmd_vf_vlan_stripq_result {
13425 cmdline_fixed_string_t set;
13426 cmdline_fixed_string_t vf;
13427 cmdline_fixed_string_t vlan;
13428 cmdline_fixed_string_t stripq;
13431 cmdline_fixed_string_t on_off;
13434 /* Common CLI fields for vf vlan strip enable disable */
13435 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13436 TOKEN_STRING_INITIALIZER
13437 (struct cmd_vf_vlan_stripq_result,
13439 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13440 TOKEN_STRING_INITIALIZER
13441 (struct cmd_vf_vlan_stripq_result,
13443 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13444 TOKEN_STRING_INITIALIZER
13445 (struct cmd_vf_vlan_stripq_result,
13447 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13448 TOKEN_STRING_INITIALIZER
13449 (struct cmd_vf_vlan_stripq_result,
13451 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13452 TOKEN_NUM_INITIALIZER
13453 (struct cmd_vf_vlan_stripq_result,
13455 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13456 TOKEN_NUM_INITIALIZER
13457 (struct cmd_vf_vlan_stripq_result,
13459 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13460 TOKEN_STRING_INITIALIZER
13461 (struct cmd_vf_vlan_stripq_result,
13465 cmd_set_vf_vlan_stripq_parsed(
13466 void *parsed_result,
13467 __attribute__((unused)) struct cmdline *cl,
13468 __attribute__((unused)) void *data)
13470 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13471 int ret = -ENOTSUP;
13473 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13475 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13478 #ifdef RTE_LIBRTE_IXGBE_PMD
13479 if (ret == -ENOTSUP)
13480 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13481 res->vf_id, is_on);
13483 #ifdef RTE_LIBRTE_I40E_PMD
13484 if (ret == -ENOTSUP)
13485 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13486 res->vf_id, is_on);
13488 #ifdef RTE_LIBRTE_BNXT_PMD
13489 if (ret == -ENOTSUP)
13490 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13491 res->vf_id, is_on);
13498 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13501 printf("invalid port_id %d\n", res->port_id);
13504 printf("function not implemented\n");
13507 printf("programming error: (%s)\n", strerror(-ret));
13511 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13512 .f = cmd_set_vf_vlan_stripq_parsed,
13514 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13516 (void *)&cmd_vf_vlan_stripq_set,
13517 (void *)&cmd_vf_vlan_stripq_vf,
13518 (void *)&cmd_vf_vlan_stripq_vlan,
13519 (void *)&cmd_vf_vlan_stripq_stripq,
13520 (void *)&cmd_vf_vlan_stripq_port_id,
13521 (void *)&cmd_vf_vlan_stripq_vf_id,
13522 (void *)&cmd_vf_vlan_stripq_on_off,
13527 /* vf vlan insert configuration */
13529 /* Common result structure for vf vlan insert */
13530 struct cmd_vf_vlan_insert_result {
13531 cmdline_fixed_string_t set;
13532 cmdline_fixed_string_t vf;
13533 cmdline_fixed_string_t vlan;
13534 cmdline_fixed_string_t insert;
13540 /* Common CLI fields for vf vlan insert enable disable */
13541 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13542 TOKEN_STRING_INITIALIZER
13543 (struct cmd_vf_vlan_insert_result,
13545 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13546 TOKEN_STRING_INITIALIZER
13547 (struct cmd_vf_vlan_insert_result,
13549 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13550 TOKEN_STRING_INITIALIZER
13551 (struct cmd_vf_vlan_insert_result,
13553 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13554 TOKEN_STRING_INITIALIZER
13555 (struct cmd_vf_vlan_insert_result,
13557 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13558 TOKEN_NUM_INITIALIZER
13559 (struct cmd_vf_vlan_insert_result,
13561 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13562 TOKEN_NUM_INITIALIZER
13563 (struct cmd_vf_vlan_insert_result,
13565 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13566 TOKEN_NUM_INITIALIZER
13567 (struct cmd_vf_vlan_insert_result,
13571 cmd_set_vf_vlan_insert_parsed(
13572 void *parsed_result,
13573 __attribute__((unused)) struct cmdline *cl,
13574 __attribute__((unused)) void *data)
13576 struct cmd_vf_vlan_insert_result *res = parsed_result;
13577 int ret = -ENOTSUP;
13579 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13582 #ifdef RTE_LIBRTE_IXGBE_PMD
13583 if (ret == -ENOTSUP)
13584 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13587 #ifdef RTE_LIBRTE_I40E_PMD
13588 if (ret == -ENOTSUP)
13589 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13592 #ifdef RTE_LIBRTE_BNXT_PMD
13593 if (ret == -ENOTSUP)
13594 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13602 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13605 printf("invalid port_id %d\n", res->port_id);
13608 printf("function not implemented\n");
13611 printf("programming error: (%s)\n", strerror(-ret));
13615 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13616 .f = cmd_set_vf_vlan_insert_parsed,
13618 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13620 (void *)&cmd_vf_vlan_insert_set,
13621 (void *)&cmd_vf_vlan_insert_vf,
13622 (void *)&cmd_vf_vlan_insert_vlan,
13623 (void *)&cmd_vf_vlan_insert_insert,
13624 (void *)&cmd_vf_vlan_insert_port_id,
13625 (void *)&cmd_vf_vlan_insert_vf_id,
13626 (void *)&cmd_vf_vlan_insert_vlan_id,
13631 /* tx loopback configuration */
13633 /* Common result structure for tx loopback */
13634 struct cmd_tx_loopback_result {
13635 cmdline_fixed_string_t set;
13636 cmdline_fixed_string_t tx;
13637 cmdline_fixed_string_t loopback;
13639 cmdline_fixed_string_t on_off;
13642 /* Common CLI fields for tx loopback enable disable */
13643 cmdline_parse_token_string_t cmd_tx_loopback_set =
13644 TOKEN_STRING_INITIALIZER
13645 (struct cmd_tx_loopback_result,
13647 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13648 TOKEN_STRING_INITIALIZER
13649 (struct cmd_tx_loopback_result,
13651 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13652 TOKEN_STRING_INITIALIZER
13653 (struct cmd_tx_loopback_result,
13654 loopback, "loopback");
13655 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13656 TOKEN_NUM_INITIALIZER
13657 (struct cmd_tx_loopback_result,
13659 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13660 TOKEN_STRING_INITIALIZER
13661 (struct cmd_tx_loopback_result,
13665 cmd_set_tx_loopback_parsed(
13666 void *parsed_result,
13667 __attribute__((unused)) struct cmdline *cl,
13668 __attribute__((unused)) void *data)
13670 struct cmd_tx_loopback_result *res = parsed_result;
13671 int ret = -ENOTSUP;
13673 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13675 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13678 #ifdef RTE_LIBRTE_IXGBE_PMD
13679 if (ret == -ENOTSUP)
13680 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13682 #ifdef RTE_LIBRTE_I40E_PMD
13683 if (ret == -ENOTSUP)
13684 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13686 #ifdef RTE_LIBRTE_BNXT_PMD
13687 if (ret == -ENOTSUP)
13688 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13690 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13691 if (ret == -ENOTSUP)
13692 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13699 printf("invalid is_on %d\n", is_on);
13702 printf("invalid port_id %d\n", res->port_id);
13705 printf("function not implemented\n");
13708 printf("programming error: (%s)\n", strerror(-ret));
13712 cmdline_parse_inst_t cmd_set_tx_loopback = {
13713 .f = cmd_set_tx_loopback_parsed,
13715 .help_str = "set tx loopback <port_id> on|off",
13717 (void *)&cmd_tx_loopback_set,
13718 (void *)&cmd_tx_loopback_tx,
13719 (void *)&cmd_tx_loopback_loopback,
13720 (void *)&cmd_tx_loopback_port_id,
13721 (void *)&cmd_tx_loopback_on_off,
13726 /* all queues drop enable configuration */
13728 /* Common result structure for all queues drop enable */
13729 struct cmd_all_queues_drop_en_result {
13730 cmdline_fixed_string_t set;
13731 cmdline_fixed_string_t all;
13732 cmdline_fixed_string_t queues;
13733 cmdline_fixed_string_t drop;
13735 cmdline_fixed_string_t on_off;
13738 /* Common CLI fields for tx loopback enable disable */
13739 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13740 TOKEN_STRING_INITIALIZER
13741 (struct cmd_all_queues_drop_en_result,
13743 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13744 TOKEN_STRING_INITIALIZER
13745 (struct cmd_all_queues_drop_en_result,
13747 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13748 TOKEN_STRING_INITIALIZER
13749 (struct cmd_all_queues_drop_en_result,
13751 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13752 TOKEN_STRING_INITIALIZER
13753 (struct cmd_all_queues_drop_en_result,
13755 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13756 TOKEN_NUM_INITIALIZER
13757 (struct cmd_all_queues_drop_en_result,
13759 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13760 TOKEN_STRING_INITIALIZER
13761 (struct cmd_all_queues_drop_en_result,
13765 cmd_set_all_queues_drop_en_parsed(
13766 void *parsed_result,
13767 __attribute__((unused)) struct cmdline *cl,
13768 __attribute__((unused)) void *data)
13770 struct cmd_all_queues_drop_en_result *res = parsed_result;
13771 int ret = -ENOTSUP;
13772 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13774 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13777 #ifdef RTE_LIBRTE_IXGBE_PMD
13778 if (ret == -ENOTSUP)
13779 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13781 #ifdef RTE_LIBRTE_BNXT_PMD
13782 if (ret == -ENOTSUP)
13783 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13789 printf("invalid is_on %d\n", is_on);
13792 printf("invalid port_id %d\n", res->port_id);
13795 printf("function not implemented\n");
13798 printf("programming error: (%s)\n", strerror(-ret));
13802 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13803 .f = cmd_set_all_queues_drop_en_parsed,
13805 .help_str = "set all queues drop <port_id> on|off",
13807 (void *)&cmd_all_queues_drop_en_set,
13808 (void *)&cmd_all_queues_drop_en_all,
13809 (void *)&cmd_all_queues_drop_en_queues,
13810 (void *)&cmd_all_queues_drop_en_drop,
13811 (void *)&cmd_all_queues_drop_en_port_id,
13812 (void *)&cmd_all_queues_drop_en_on_off,
13817 /* vf split drop enable configuration */
13819 /* Common result structure for vf split drop enable */
13820 struct cmd_vf_split_drop_en_result {
13821 cmdline_fixed_string_t set;
13822 cmdline_fixed_string_t vf;
13823 cmdline_fixed_string_t split;
13824 cmdline_fixed_string_t drop;
13827 cmdline_fixed_string_t on_off;
13830 /* Common CLI fields for vf split drop enable disable */
13831 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13832 TOKEN_STRING_INITIALIZER
13833 (struct cmd_vf_split_drop_en_result,
13835 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13836 TOKEN_STRING_INITIALIZER
13837 (struct cmd_vf_split_drop_en_result,
13839 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13840 TOKEN_STRING_INITIALIZER
13841 (struct cmd_vf_split_drop_en_result,
13843 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13844 TOKEN_STRING_INITIALIZER
13845 (struct cmd_vf_split_drop_en_result,
13847 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13848 TOKEN_NUM_INITIALIZER
13849 (struct cmd_vf_split_drop_en_result,
13851 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13852 TOKEN_NUM_INITIALIZER
13853 (struct cmd_vf_split_drop_en_result,
13855 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13856 TOKEN_STRING_INITIALIZER
13857 (struct cmd_vf_split_drop_en_result,
13861 cmd_set_vf_split_drop_en_parsed(
13862 void *parsed_result,
13863 __attribute__((unused)) struct cmdline *cl,
13864 __attribute__((unused)) void *data)
13866 struct cmd_vf_split_drop_en_result *res = parsed_result;
13867 int ret = -ENOTSUP;
13868 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13870 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13873 #ifdef RTE_LIBRTE_IXGBE_PMD
13874 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13881 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13884 printf("invalid port_id %d\n", res->port_id);
13887 printf("not supported on port %d\n", res->port_id);
13890 printf("programming error: (%s)\n", strerror(-ret));
13894 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13895 .f = cmd_set_vf_split_drop_en_parsed,
13897 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13899 (void *)&cmd_vf_split_drop_en_set,
13900 (void *)&cmd_vf_split_drop_en_vf,
13901 (void *)&cmd_vf_split_drop_en_split,
13902 (void *)&cmd_vf_split_drop_en_drop,
13903 (void *)&cmd_vf_split_drop_en_port_id,
13904 (void *)&cmd_vf_split_drop_en_vf_id,
13905 (void *)&cmd_vf_split_drop_en_on_off,
13910 /* vf mac address configuration */
13912 /* Common result structure for vf mac address */
13913 struct cmd_set_vf_mac_addr_result {
13914 cmdline_fixed_string_t set;
13915 cmdline_fixed_string_t vf;
13916 cmdline_fixed_string_t mac;
13917 cmdline_fixed_string_t addr;
13920 struct rte_ether_addr mac_addr;
13924 /* Common CLI fields for vf split drop enable disable */
13925 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13926 TOKEN_STRING_INITIALIZER
13927 (struct cmd_set_vf_mac_addr_result,
13929 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13930 TOKEN_STRING_INITIALIZER
13931 (struct cmd_set_vf_mac_addr_result,
13933 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13934 TOKEN_STRING_INITIALIZER
13935 (struct cmd_set_vf_mac_addr_result,
13937 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13938 TOKEN_STRING_INITIALIZER
13939 (struct cmd_set_vf_mac_addr_result,
13941 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13942 TOKEN_NUM_INITIALIZER
13943 (struct cmd_set_vf_mac_addr_result,
13945 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13946 TOKEN_NUM_INITIALIZER
13947 (struct cmd_set_vf_mac_addr_result,
13949 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13950 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13954 cmd_set_vf_mac_addr_parsed(
13955 void *parsed_result,
13956 __attribute__((unused)) struct cmdline *cl,
13957 __attribute__((unused)) void *data)
13959 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13960 int ret = -ENOTSUP;
13962 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13965 #ifdef RTE_LIBRTE_IXGBE_PMD
13966 if (ret == -ENOTSUP)
13967 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13970 #ifdef RTE_LIBRTE_I40E_PMD
13971 if (ret == -ENOTSUP)
13972 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13975 #ifdef RTE_LIBRTE_BNXT_PMD
13976 if (ret == -ENOTSUP)
13977 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13985 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13988 printf("invalid port_id %d\n", res->port_id);
13991 printf("function not implemented\n");
13994 printf("programming error: (%s)\n", strerror(-ret));
13998 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13999 .f = cmd_set_vf_mac_addr_parsed,
14001 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14003 (void *)&cmd_set_vf_mac_addr_set,
14004 (void *)&cmd_set_vf_mac_addr_vf,
14005 (void *)&cmd_set_vf_mac_addr_mac,
14006 (void *)&cmd_set_vf_mac_addr_addr,
14007 (void *)&cmd_set_vf_mac_addr_port_id,
14008 (void *)&cmd_set_vf_mac_addr_vf_id,
14009 (void *)&cmd_set_vf_mac_addr_mac_addr,
14014 /* MACsec configuration */
14016 /* Common result structure for MACsec offload enable */
14017 struct cmd_macsec_offload_on_result {
14018 cmdline_fixed_string_t set;
14019 cmdline_fixed_string_t macsec;
14020 cmdline_fixed_string_t offload;
14022 cmdline_fixed_string_t on;
14023 cmdline_fixed_string_t encrypt;
14024 cmdline_fixed_string_t en_on_off;
14025 cmdline_fixed_string_t replay_protect;
14026 cmdline_fixed_string_t rp_on_off;
14029 /* Common CLI fields for MACsec offload disable */
14030 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14031 TOKEN_STRING_INITIALIZER
14032 (struct cmd_macsec_offload_on_result,
14034 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14035 TOKEN_STRING_INITIALIZER
14036 (struct cmd_macsec_offload_on_result,
14038 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14039 TOKEN_STRING_INITIALIZER
14040 (struct cmd_macsec_offload_on_result,
14041 offload, "offload");
14042 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14043 TOKEN_NUM_INITIALIZER
14044 (struct cmd_macsec_offload_on_result,
14046 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14047 TOKEN_STRING_INITIALIZER
14048 (struct cmd_macsec_offload_on_result,
14050 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14051 TOKEN_STRING_INITIALIZER
14052 (struct cmd_macsec_offload_on_result,
14053 encrypt, "encrypt");
14054 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14055 TOKEN_STRING_INITIALIZER
14056 (struct cmd_macsec_offload_on_result,
14057 en_on_off, "on#off");
14058 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14059 TOKEN_STRING_INITIALIZER
14060 (struct cmd_macsec_offload_on_result,
14061 replay_protect, "replay-protect");
14062 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14063 TOKEN_STRING_INITIALIZER
14064 (struct cmd_macsec_offload_on_result,
14065 rp_on_off, "on#off");
14068 cmd_set_macsec_offload_on_parsed(
14069 void *parsed_result,
14070 __attribute__((unused)) struct cmdline *cl,
14071 __attribute__((unused)) void *data)
14073 struct cmd_macsec_offload_on_result *res = parsed_result;
14074 int ret = -ENOTSUP;
14075 portid_t port_id = res->port_id;
14076 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14077 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14078 struct rte_eth_dev_info dev_info;
14080 if (port_id_is_invalid(port_id, ENABLED_WARN))
14082 if (!port_is_stopped(port_id)) {
14083 printf("Please stop port %d first\n", port_id);
14087 rte_eth_dev_info_get(port_id, &dev_info);
14088 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14089 #ifdef RTE_LIBRTE_IXGBE_PMD
14090 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14098 ports[port_id].dev_conf.txmode.offloads |=
14099 DEV_TX_OFFLOAD_MACSEC_INSERT;
14100 cmd_reconfig_device_queue(port_id, 1, 1);
14103 printf("invalid port_id %d\n", port_id);
14106 printf("not supported on port %d\n", port_id);
14109 printf("programming error: (%s)\n", strerror(-ret));
14113 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14114 .f = cmd_set_macsec_offload_on_parsed,
14116 .help_str = "set macsec offload <port_id> on "
14117 "encrypt on|off replay-protect on|off",
14119 (void *)&cmd_macsec_offload_on_set,
14120 (void *)&cmd_macsec_offload_on_macsec,
14121 (void *)&cmd_macsec_offload_on_offload,
14122 (void *)&cmd_macsec_offload_on_port_id,
14123 (void *)&cmd_macsec_offload_on_on,
14124 (void *)&cmd_macsec_offload_on_encrypt,
14125 (void *)&cmd_macsec_offload_on_en_on_off,
14126 (void *)&cmd_macsec_offload_on_replay_protect,
14127 (void *)&cmd_macsec_offload_on_rp_on_off,
14132 /* Common result structure for MACsec offload disable */
14133 struct cmd_macsec_offload_off_result {
14134 cmdline_fixed_string_t set;
14135 cmdline_fixed_string_t macsec;
14136 cmdline_fixed_string_t offload;
14138 cmdline_fixed_string_t off;
14141 /* Common CLI fields for MACsec offload disable */
14142 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14143 TOKEN_STRING_INITIALIZER
14144 (struct cmd_macsec_offload_off_result,
14146 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14147 TOKEN_STRING_INITIALIZER
14148 (struct cmd_macsec_offload_off_result,
14150 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14151 TOKEN_STRING_INITIALIZER
14152 (struct cmd_macsec_offload_off_result,
14153 offload, "offload");
14154 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14155 TOKEN_NUM_INITIALIZER
14156 (struct cmd_macsec_offload_off_result,
14158 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14159 TOKEN_STRING_INITIALIZER
14160 (struct cmd_macsec_offload_off_result,
14164 cmd_set_macsec_offload_off_parsed(
14165 void *parsed_result,
14166 __attribute__((unused)) struct cmdline *cl,
14167 __attribute__((unused)) void *data)
14169 struct cmd_macsec_offload_off_result *res = parsed_result;
14170 int ret = -ENOTSUP;
14171 struct rte_eth_dev_info dev_info;
14172 portid_t port_id = res->port_id;
14174 if (port_id_is_invalid(port_id, ENABLED_WARN))
14176 if (!port_is_stopped(port_id)) {
14177 printf("Please stop port %d first\n", port_id);
14181 rte_eth_dev_info_get(port_id, &dev_info);
14182 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14183 #ifdef RTE_LIBRTE_IXGBE_PMD
14184 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14189 ports[port_id].dev_conf.txmode.offloads &=
14190 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14191 cmd_reconfig_device_queue(port_id, 1, 1);
14194 printf("invalid port_id %d\n", port_id);
14197 printf("not supported on port %d\n", port_id);
14200 printf("programming error: (%s)\n", strerror(-ret));
14204 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14205 .f = cmd_set_macsec_offload_off_parsed,
14207 .help_str = "set macsec offload <port_id> off",
14209 (void *)&cmd_macsec_offload_off_set,
14210 (void *)&cmd_macsec_offload_off_macsec,
14211 (void *)&cmd_macsec_offload_off_offload,
14212 (void *)&cmd_macsec_offload_off_port_id,
14213 (void *)&cmd_macsec_offload_off_off,
14218 /* Common result structure for MACsec secure connection configure */
14219 struct cmd_macsec_sc_result {
14220 cmdline_fixed_string_t set;
14221 cmdline_fixed_string_t macsec;
14222 cmdline_fixed_string_t sc;
14223 cmdline_fixed_string_t tx_rx;
14225 struct rte_ether_addr mac;
14229 /* Common CLI fields for MACsec secure connection configure */
14230 cmdline_parse_token_string_t cmd_macsec_sc_set =
14231 TOKEN_STRING_INITIALIZER
14232 (struct cmd_macsec_sc_result,
14234 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14235 TOKEN_STRING_INITIALIZER
14236 (struct cmd_macsec_sc_result,
14238 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14239 TOKEN_STRING_INITIALIZER
14240 (struct cmd_macsec_sc_result,
14242 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14243 TOKEN_STRING_INITIALIZER
14244 (struct cmd_macsec_sc_result,
14246 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14247 TOKEN_NUM_INITIALIZER
14248 (struct cmd_macsec_sc_result,
14250 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14251 TOKEN_ETHERADDR_INITIALIZER
14252 (struct cmd_macsec_sc_result,
14254 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14255 TOKEN_NUM_INITIALIZER
14256 (struct cmd_macsec_sc_result,
14260 cmd_set_macsec_sc_parsed(
14261 void *parsed_result,
14262 __attribute__((unused)) struct cmdline *cl,
14263 __attribute__((unused)) void *data)
14265 struct cmd_macsec_sc_result *res = parsed_result;
14266 int ret = -ENOTSUP;
14267 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14269 #ifdef RTE_LIBRTE_IXGBE_PMD
14271 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14272 res->mac.addr_bytes) :
14273 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14274 res->mac.addr_bytes, res->pi);
14276 RTE_SET_USED(is_tx);
14282 printf("invalid port_id %d\n", res->port_id);
14285 printf("not supported on port %d\n", res->port_id);
14288 printf("programming error: (%s)\n", strerror(-ret));
14292 cmdline_parse_inst_t cmd_set_macsec_sc = {
14293 .f = cmd_set_macsec_sc_parsed,
14295 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14297 (void *)&cmd_macsec_sc_set,
14298 (void *)&cmd_macsec_sc_macsec,
14299 (void *)&cmd_macsec_sc_sc,
14300 (void *)&cmd_macsec_sc_tx_rx,
14301 (void *)&cmd_macsec_sc_port_id,
14302 (void *)&cmd_macsec_sc_mac,
14303 (void *)&cmd_macsec_sc_pi,
14308 /* Common result structure for MACsec secure connection configure */
14309 struct cmd_macsec_sa_result {
14310 cmdline_fixed_string_t set;
14311 cmdline_fixed_string_t macsec;
14312 cmdline_fixed_string_t sa;
14313 cmdline_fixed_string_t tx_rx;
14318 cmdline_fixed_string_t key;
14321 /* Common CLI fields for MACsec secure connection configure */
14322 cmdline_parse_token_string_t cmd_macsec_sa_set =
14323 TOKEN_STRING_INITIALIZER
14324 (struct cmd_macsec_sa_result,
14326 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14327 TOKEN_STRING_INITIALIZER
14328 (struct cmd_macsec_sa_result,
14330 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14331 TOKEN_STRING_INITIALIZER
14332 (struct cmd_macsec_sa_result,
14334 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14335 TOKEN_STRING_INITIALIZER
14336 (struct cmd_macsec_sa_result,
14338 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14339 TOKEN_NUM_INITIALIZER
14340 (struct cmd_macsec_sa_result,
14342 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14343 TOKEN_NUM_INITIALIZER
14344 (struct cmd_macsec_sa_result,
14346 cmdline_parse_token_num_t cmd_macsec_sa_an =
14347 TOKEN_NUM_INITIALIZER
14348 (struct cmd_macsec_sa_result,
14350 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14351 TOKEN_NUM_INITIALIZER
14352 (struct cmd_macsec_sa_result,
14354 cmdline_parse_token_string_t cmd_macsec_sa_key =
14355 TOKEN_STRING_INITIALIZER
14356 (struct cmd_macsec_sa_result,
14360 cmd_set_macsec_sa_parsed(
14361 void *parsed_result,
14362 __attribute__((unused)) struct cmdline *cl,
14363 __attribute__((unused)) void *data)
14365 struct cmd_macsec_sa_result *res = parsed_result;
14366 int ret = -ENOTSUP;
14367 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14368 uint8_t key[16] = { 0 };
14374 key_len = strlen(res->key) / 2;
14378 for (i = 0; i < key_len; i++) {
14379 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14382 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14385 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14388 #ifdef RTE_LIBRTE_IXGBE_PMD
14390 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14391 res->idx, res->an, res->pn, key) :
14392 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14393 res->idx, res->an, res->pn, key);
14395 RTE_SET_USED(is_tx);
14402 printf("invalid idx %d or an %d\n", res->idx, res->an);
14405 printf("invalid port_id %d\n", res->port_id);
14408 printf("not supported on port %d\n", res->port_id);
14411 printf("programming error: (%s)\n", strerror(-ret));
14415 cmdline_parse_inst_t cmd_set_macsec_sa = {
14416 .f = cmd_set_macsec_sa_parsed,
14418 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14420 (void *)&cmd_macsec_sa_set,
14421 (void *)&cmd_macsec_sa_macsec,
14422 (void *)&cmd_macsec_sa_sa,
14423 (void *)&cmd_macsec_sa_tx_rx,
14424 (void *)&cmd_macsec_sa_port_id,
14425 (void *)&cmd_macsec_sa_idx,
14426 (void *)&cmd_macsec_sa_an,
14427 (void *)&cmd_macsec_sa_pn,
14428 (void *)&cmd_macsec_sa_key,
14433 /* VF unicast promiscuous mode configuration */
14435 /* Common result structure for VF unicast promiscuous mode */
14436 struct cmd_vf_promisc_result {
14437 cmdline_fixed_string_t set;
14438 cmdline_fixed_string_t vf;
14439 cmdline_fixed_string_t promisc;
14442 cmdline_fixed_string_t on_off;
14445 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14446 cmdline_parse_token_string_t cmd_vf_promisc_set =
14447 TOKEN_STRING_INITIALIZER
14448 (struct cmd_vf_promisc_result,
14450 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14451 TOKEN_STRING_INITIALIZER
14452 (struct cmd_vf_promisc_result,
14454 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14455 TOKEN_STRING_INITIALIZER
14456 (struct cmd_vf_promisc_result,
14457 promisc, "promisc");
14458 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14459 TOKEN_NUM_INITIALIZER
14460 (struct cmd_vf_promisc_result,
14462 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14463 TOKEN_NUM_INITIALIZER
14464 (struct cmd_vf_promisc_result,
14466 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14467 TOKEN_STRING_INITIALIZER
14468 (struct cmd_vf_promisc_result,
14472 cmd_set_vf_promisc_parsed(
14473 void *parsed_result,
14474 __attribute__((unused)) struct cmdline *cl,
14475 __attribute__((unused)) void *data)
14477 struct cmd_vf_promisc_result *res = parsed_result;
14478 int ret = -ENOTSUP;
14480 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14482 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14485 #ifdef RTE_LIBRTE_I40E_PMD
14486 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14487 res->vf_id, is_on);
14494 printf("invalid vf_id %d\n", res->vf_id);
14497 printf("invalid port_id %d\n", res->port_id);
14500 printf("function not implemented\n");
14503 printf("programming error: (%s)\n", strerror(-ret));
14507 cmdline_parse_inst_t cmd_set_vf_promisc = {
14508 .f = cmd_set_vf_promisc_parsed,
14510 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14511 "Set unicast promiscuous mode for a VF from the PF",
14513 (void *)&cmd_vf_promisc_set,
14514 (void *)&cmd_vf_promisc_vf,
14515 (void *)&cmd_vf_promisc_promisc,
14516 (void *)&cmd_vf_promisc_port_id,
14517 (void *)&cmd_vf_promisc_vf_id,
14518 (void *)&cmd_vf_promisc_on_off,
14523 /* VF multicast promiscuous mode configuration */
14525 /* Common result structure for VF multicast promiscuous mode */
14526 struct cmd_vf_allmulti_result {
14527 cmdline_fixed_string_t set;
14528 cmdline_fixed_string_t vf;
14529 cmdline_fixed_string_t allmulti;
14532 cmdline_fixed_string_t on_off;
14535 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14536 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14537 TOKEN_STRING_INITIALIZER
14538 (struct cmd_vf_allmulti_result,
14540 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14541 TOKEN_STRING_INITIALIZER
14542 (struct cmd_vf_allmulti_result,
14544 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14545 TOKEN_STRING_INITIALIZER
14546 (struct cmd_vf_allmulti_result,
14547 allmulti, "allmulti");
14548 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14549 TOKEN_NUM_INITIALIZER
14550 (struct cmd_vf_allmulti_result,
14552 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14553 TOKEN_NUM_INITIALIZER
14554 (struct cmd_vf_allmulti_result,
14556 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14557 TOKEN_STRING_INITIALIZER
14558 (struct cmd_vf_allmulti_result,
14562 cmd_set_vf_allmulti_parsed(
14563 void *parsed_result,
14564 __attribute__((unused)) struct cmdline *cl,
14565 __attribute__((unused)) void *data)
14567 struct cmd_vf_allmulti_result *res = parsed_result;
14568 int ret = -ENOTSUP;
14570 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14572 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14575 #ifdef RTE_LIBRTE_I40E_PMD
14576 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14577 res->vf_id, is_on);
14584 printf("invalid vf_id %d\n", res->vf_id);
14587 printf("invalid port_id %d\n", res->port_id);
14590 printf("function not implemented\n");
14593 printf("programming error: (%s)\n", strerror(-ret));
14597 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14598 .f = cmd_set_vf_allmulti_parsed,
14600 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14601 "Set multicast promiscuous mode for a VF from the PF",
14603 (void *)&cmd_vf_allmulti_set,
14604 (void *)&cmd_vf_allmulti_vf,
14605 (void *)&cmd_vf_allmulti_allmulti,
14606 (void *)&cmd_vf_allmulti_port_id,
14607 (void *)&cmd_vf_allmulti_vf_id,
14608 (void *)&cmd_vf_allmulti_on_off,
14613 /* vf broadcast mode configuration */
14615 /* Common result structure for vf broadcast */
14616 struct cmd_set_vf_broadcast_result {
14617 cmdline_fixed_string_t set;
14618 cmdline_fixed_string_t vf;
14619 cmdline_fixed_string_t broadcast;
14622 cmdline_fixed_string_t on_off;
14625 /* Common CLI fields for vf broadcast enable disable */
14626 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14627 TOKEN_STRING_INITIALIZER
14628 (struct cmd_set_vf_broadcast_result,
14630 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14631 TOKEN_STRING_INITIALIZER
14632 (struct cmd_set_vf_broadcast_result,
14634 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14635 TOKEN_STRING_INITIALIZER
14636 (struct cmd_set_vf_broadcast_result,
14637 broadcast, "broadcast");
14638 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14639 TOKEN_NUM_INITIALIZER
14640 (struct cmd_set_vf_broadcast_result,
14642 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14643 TOKEN_NUM_INITIALIZER
14644 (struct cmd_set_vf_broadcast_result,
14646 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14647 TOKEN_STRING_INITIALIZER
14648 (struct cmd_set_vf_broadcast_result,
14652 cmd_set_vf_broadcast_parsed(
14653 void *parsed_result,
14654 __attribute__((unused)) struct cmdline *cl,
14655 __attribute__((unused)) void *data)
14657 struct cmd_set_vf_broadcast_result *res = parsed_result;
14658 int ret = -ENOTSUP;
14660 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14662 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14665 #ifdef RTE_LIBRTE_I40E_PMD
14666 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14667 res->vf_id, is_on);
14674 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14677 printf("invalid port_id %d\n", res->port_id);
14680 printf("function not implemented\n");
14683 printf("programming error: (%s)\n", strerror(-ret));
14687 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14688 .f = cmd_set_vf_broadcast_parsed,
14690 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14692 (void *)&cmd_set_vf_broadcast_set,
14693 (void *)&cmd_set_vf_broadcast_vf,
14694 (void *)&cmd_set_vf_broadcast_broadcast,
14695 (void *)&cmd_set_vf_broadcast_port_id,
14696 (void *)&cmd_set_vf_broadcast_vf_id,
14697 (void *)&cmd_set_vf_broadcast_on_off,
14702 /* vf vlan tag configuration */
14704 /* Common result structure for vf vlan tag */
14705 struct cmd_set_vf_vlan_tag_result {
14706 cmdline_fixed_string_t set;
14707 cmdline_fixed_string_t vf;
14708 cmdline_fixed_string_t vlan;
14709 cmdline_fixed_string_t tag;
14712 cmdline_fixed_string_t on_off;
14715 /* Common CLI fields for vf vlan tag enable disable */
14716 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14717 TOKEN_STRING_INITIALIZER
14718 (struct cmd_set_vf_vlan_tag_result,
14720 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14721 TOKEN_STRING_INITIALIZER
14722 (struct cmd_set_vf_vlan_tag_result,
14724 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14725 TOKEN_STRING_INITIALIZER
14726 (struct cmd_set_vf_vlan_tag_result,
14728 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14729 TOKEN_STRING_INITIALIZER
14730 (struct cmd_set_vf_vlan_tag_result,
14732 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14733 TOKEN_NUM_INITIALIZER
14734 (struct cmd_set_vf_vlan_tag_result,
14736 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14737 TOKEN_NUM_INITIALIZER
14738 (struct cmd_set_vf_vlan_tag_result,
14740 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14741 TOKEN_STRING_INITIALIZER
14742 (struct cmd_set_vf_vlan_tag_result,
14746 cmd_set_vf_vlan_tag_parsed(
14747 void *parsed_result,
14748 __attribute__((unused)) struct cmdline *cl,
14749 __attribute__((unused)) void *data)
14751 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14752 int ret = -ENOTSUP;
14754 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14756 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14759 #ifdef RTE_LIBRTE_I40E_PMD
14760 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14761 res->vf_id, is_on);
14768 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14771 printf("invalid port_id %d\n", res->port_id);
14774 printf("function not implemented\n");
14777 printf("programming error: (%s)\n", strerror(-ret));
14781 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14782 .f = cmd_set_vf_vlan_tag_parsed,
14784 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14786 (void *)&cmd_set_vf_vlan_tag_set,
14787 (void *)&cmd_set_vf_vlan_tag_vf,
14788 (void *)&cmd_set_vf_vlan_tag_vlan,
14789 (void *)&cmd_set_vf_vlan_tag_tag,
14790 (void *)&cmd_set_vf_vlan_tag_port_id,
14791 (void *)&cmd_set_vf_vlan_tag_vf_id,
14792 (void *)&cmd_set_vf_vlan_tag_on_off,
14797 /* Common definition of VF and TC TX bandwidth configuration */
14798 struct cmd_vf_tc_bw_result {
14799 cmdline_fixed_string_t set;
14800 cmdline_fixed_string_t vf;
14801 cmdline_fixed_string_t tc;
14802 cmdline_fixed_string_t tx;
14803 cmdline_fixed_string_t min_bw;
14804 cmdline_fixed_string_t max_bw;
14805 cmdline_fixed_string_t strict_link_prio;
14810 cmdline_fixed_string_t bw_list;
14814 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14815 TOKEN_STRING_INITIALIZER
14816 (struct cmd_vf_tc_bw_result,
14818 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14819 TOKEN_STRING_INITIALIZER
14820 (struct cmd_vf_tc_bw_result,
14822 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14823 TOKEN_STRING_INITIALIZER
14824 (struct cmd_vf_tc_bw_result,
14826 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14827 TOKEN_STRING_INITIALIZER
14828 (struct cmd_vf_tc_bw_result,
14830 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14831 TOKEN_STRING_INITIALIZER
14832 (struct cmd_vf_tc_bw_result,
14833 strict_link_prio, "strict-link-priority");
14834 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14835 TOKEN_STRING_INITIALIZER
14836 (struct cmd_vf_tc_bw_result,
14837 min_bw, "min-bandwidth");
14838 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14839 TOKEN_STRING_INITIALIZER
14840 (struct cmd_vf_tc_bw_result,
14841 max_bw, "max-bandwidth");
14842 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14843 TOKEN_NUM_INITIALIZER
14844 (struct cmd_vf_tc_bw_result,
14846 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14847 TOKEN_NUM_INITIALIZER
14848 (struct cmd_vf_tc_bw_result,
14850 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14851 TOKEN_NUM_INITIALIZER
14852 (struct cmd_vf_tc_bw_result,
14854 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14855 TOKEN_NUM_INITIALIZER
14856 (struct cmd_vf_tc_bw_result,
14858 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14859 TOKEN_STRING_INITIALIZER
14860 (struct cmd_vf_tc_bw_result,
14862 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14863 TOKEN_NUM_INITIALIZER
14864 (struct cmd_vf_tc_bw_result,
14867 /* VF max bandwidth setting */
14869 cmd_vf_max_bw_parsed(
14870 void *parsed_result,
14871 __attribute__((unused)) struct cmdline *cl,
14872 __attribute__((unused)) void *data)
14874 struct cmd_vf_tc_bw_result *res = parsed_result;
14875 int ret = -ENOTSUP;
14877 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14880 #ifdef RTE_LIBRTE_I40E_PMD
14881 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14882 res->vf_id, res->bw);
14889 printf("invalid vf_id %d or bandwidth %d\n",
14890 res->vf_id, res->bw);
14893 printf("invalid port_id %d\n", res->port_id);
14896 printf("function not implemented\n");
14899 printf("programming error: (%s)\n", strerror(-ret));
14903 cmdline_parse_inst_t cmd_vf_max_bw = {
14904 .f = cmd_vf_max_bw_parsed,
14906 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14908 (void *)&cmd_vf_tc_bw_set,
14909 (void *)&cmd_vf_tc_bw_vf,
14910 (void *)&cmd_vf_tc_bw_tx,
14911 (void *)&cmd_vf_tc_bw_max_bw,
14912 (void *)&cmd_vf_tc_bw_port_id,
14913 (void *)&cmd_vf_tc_bw_vf_id,
14914 (void *)&cmd_vf_tc_bw_bw,
14920 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14925 const char *p, *p0 = str;
14932 p = strchr(p0, '(');
14934 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14938 p0 = strchr(p, ')');
14940 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14944 if (size >= sizeof(s)) {
14945 printf("The string size exceeds the internal buffer size\n");
14948 snprintf(s, sizeof(s), "%.*s", size, p);
14949 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14951 printf("Failed to get the bandwidth list. ");
14955 for (i = 0; i < ret; i++)
14956 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14961 /* TC min bandwidth setting */
14963 cmd_vf_tc_min_bw_parsed(
14964 void *parsed_result,
14965 __attribute__((unused)) struct cmdline *cl,
14966 __attribute__((unused)) void *data)
14968 struct cmd_vf_tc_bw_result *res = parsed_result;
14971 int ret = -ENOTSUP;
14973 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14976 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14980 #ifdef RTE_LIBRTE_I40E_PMD
14981 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14989 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14992 printf("invalid port_id %d\n", res->port_id);
14995 printf("function not implemented\n");
14998 printf("programming error: (%s)\n", strerror(-ret));
15002 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15003 .f = cmd_vf_tc_min_bw_parsed,
15005 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15006 " <bw1, bw2, ...>",
15008 (void *)&cmd_vf_tc_bw_set,
15009 (void *)&cmd_vf_tc_bw_vf,
15010 (void *)&cmd_vf_tc_bw_tc,
15011 (void *)&cmd_vf_tc_bw_tx,
15012 (void *)&cmd_vf_tc_bw_min_bw,
15013 (void *)&cmd_vf_tc_bw_port_id,
15014 (void *)&cmd_vf_tc_bw_vf_id,
15015 (void *)&cmd_vf_tc_bw_bw_list,
15021 cmd_tc_min_bw_parsed(
15022 void *parsed_result,
15023 __attribute__((unused)) struct cmdline *cl,
15024 __attribute__((unused)) void *data)
15026 struct cmd_vf_tc_bw_result *res = parsed_result;
15027 struct rte_port *port;
15030 int ret = -ENOTSUP;
15032 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15035 port = &ports[res->port_id];
15036 /** Check if the port is not started **/
15037 if (port->port_status != RTE_PORT_STOPPED) {
15038 printf("Please stop port %d first\n", res->port_id);
15042 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15046 #ifdef RTE_LIBRTE_IXGBE_PMD
15047 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15054 printf("invalid bandwidth\n");
15057 printf("invalid port_id %d\n", res->port_id);
15060 printf("function not implemented\n");
15063 printf("programming error: (%s)\n", strerror(-ret));
15067 cmdline_parse_inst_t cmd_tc_min_bw = {
15068 .f = cmd_tc_min_bw_parsed,
15070 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15072 (void *)&cmd_vf_tc_bw_set,
15073 (void *)&cmd_vf_tc_bw_tc,
15074 (void *)&cmd_vf_tc_bw_tx,
15075 (void *)&cmd_vf_tc_bw_min_bw,
15076 (void *)&cmd_vf_tc_bw_port_id,
15077 (void *)&cmd_vf_tc_bw_bw_list,
15082 /* TC max bandwidth setting */
15084 cmd_vf_tc_max_bw_parsed(
15085 void *parsed_result,
15086 __attribute__((unused)) struct cmdline *cl,
15087 __attribute__((unused)) void *data)
15089 struct cmd_vf_tc_bw_result *res = parsed_result;
15090 int ret = -ENOTSUP;
15092 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15095 #ifdef RTE_LIBRTE_I40E_PMD
15096 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15097 res->tc_no, res->bw);
15104 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15105 res->vf_id, res->tc_no, res->bw);
15108 printf("invalid port_id %d\n", res->port_id);
15111 printf("function not implemented\n");
15114 printf("programming error: (%s)\n", strerror(-ret));
15118 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15119 .f = cmd_vf_tc_max_bw_parsed,
15121 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15124 (void *)&cmd_vf_tc_bw_set,
15125 (void *)&cmd_vf_tc_bw_vf,
15126 (void *)&cmd_vf_tc_bw_tc,
15127 (void *)&cmd_vf_tc_bw_tx,
15128 (void *)&cmd_vf_tc_bw_max_bw,
15129 (void *)&cmd_vf_tc_bw_port_id,
15130 (void *)&cmd_vf_tc_bw_vf_id,
15131 (void *)&cmd_vf_tc_bw_tc_no,
15132 (void *)&cmd_vf_tc_bw_bw,
15138 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15140 /* *** Set Port default Traffic Management Hierarchy *** */
15141 struct cmd_set_port_tm_hierarchy_default_result {
15142 cmdline_fixed_string_t set;
15143 cmdline_fixed_string_t port;
15144 cmdline_fixed_string_t tm;
15145 cmdline_fixed_string_t hierarchy;
15146 cmdline_fixed_string_t def;
15150 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15151 TOKEN_STRING_INITIALIZER(
15152 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15153 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15154 TOKEN_STRING_INITIALIZER(
15155 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15156 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15157 TOKEN_STRING_INITIALIZER(
15158 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15159 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15160 TOKEN_STRING_INITIALIZER(
15161 struct cmd_set_port_tm_hierarchy_default_result,
15162 hierarchy, "hierarchy");
15163 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15164 TOKEN_STRING_INITIALIZER(
15165 struct cmd_set_port_tm_hierarchy_default_result,
15167 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15168 TOKEN_NUM_INITIALIZER(
15169 struct cmd_set_port_tm_hierarchy_default_result,
15172 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15173 __attribute__((unused)) struct cmdline *cl,
15174 __attribute__((unused)) void *data)
15176 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15177 struct rte_port *p;
15178 portid_t port_id = res->port_id;
15180 if (port_id_is_invalid(port_id, ENABLED_WARN))
15183 p = &ports[port_id];
15185 /* Forward mode: tm */
15186 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15187 printf(" softnicfwd mode not enabled(error)\n");
15191 /* Set the default tm hierarchy */
15192 p->softport.default_tm_hierarchy_enable = 1;
15195 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15196 .f = cmd_set_port_tm_hierarchy_default_parsed,
15198 .help_str = "set port tm hierarchy default <port_id>",
15200 (void *)&cmd_set_port_tm_hierarchy_default_set,
15201 (void *)&cmd_set_port_tm_hierarchy_default_port,
15202 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15203 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15204 (void *)&cmd_set_port_tm_hierarchy_default_default,
15205 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15211 /** Set VXLAN encapsulation details */
15212 struct cmd_set_vxlan_result {
15213 cmdline_fixed_string_t set;
15214 cmdline_fixed_string_t vxlan;
15215 cmdline_fixed_string_t pos_token;
15216 cmdline_fixed_string_t ip_version;
15217 uint32_t vlan_present:1;
15221 cmdline_ipaddr_t ip_src;
15222 cmdline_ipaddr_t ip_dst;
15226 struct rte_ether_addr eth_src;
15227 struct rte_ether_addr eth_dst;
15230 cmdline_parse_token_string_t cmd_set_vxlan_set =
15231 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15232 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15233 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15234 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15235 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15237 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15238 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15239 "vxlan-with-vlan");
15240 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15241 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15243 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15244 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15246 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15247 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15249 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15250 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15251 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15252 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15254 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15255 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15256 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15257 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15259 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15260 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15261 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15262 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15264 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15265 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15266 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15267 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15269 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15270 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15271 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15272 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15274 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15275 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15276 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15277 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15279 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15280 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15281 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15282 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15284 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15285 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15286 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15287 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15289 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15290 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15291 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15292 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15294 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15295 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15297 static void cmd_set_vxlan_parsed(void *parsed_result,
15298 __attribute__((unused)) struct cmdline *cl,
15299 __attribute__((unused)) void *data)
15301 struct cmd_set_vxlan_result *res = parsed_result;
15306 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15309 vxlan_encap_conf.select_tos_ttl = 0;
15310 if (strcmp(res->vxlan, "vxlan") == 0)
15311 vxlan_encap_conf.select_vlan = 0;
15312 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15313 vxlan_encap_conf.select_vlan = 1;
15314 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15315 vxlan_encap_conf.select_vlan = 0;
15316 vxlan_encap_conf.select_tos_ttl = 1;
15318 if (strcmp(res->ip_version, "ipv4") == 0)
15319 vxlan_encap_conf.select_ipv4 = 1;
15320 else if (strcmp(res->ip_version, "ipv6") == 0)
15321 vxlan_encap_conf.select_ipv4 = 0;
15324 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15325 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15326 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15327 vxlan_encap_conf.ip_tos = res->tos;
15328 vxlan_encap_conf.ip_ttl = res->ttl;
15329 if (vxlan_encap_conf.select_ipv4) {
15330 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15331 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15333 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15334 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15336 if (vxlan_encap_conf.select_vlan)
15337 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15338 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15339 RTE_ETHER_ADDR_LEN);
15340 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15341 RTE_ETHER_ADDR_LEN);
15344 cmdline_parse_inst_t cmd_set_vxlan = {
15345 .f = cmd_set_vxlan_parsed,
15347 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15348 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15349 " eth-src <eth-src> eth-dst <eth-dst>",
15351 (void *)&cmd_set_vxlan_set,
15352 (void *)&cmd_set_vxlan_vxlan,
15353 (void *)&cmd_set_vxlan_ip_version,
15354 (void *)&cmd_set_vxlan_ip_version_value,
15355 (void *)&cmd_set_vxlan_vni,
15356 (void *)&cmd_set_vxlan_vni_value,
15357 (void *)&cmd_set_vxlan_udp_src,
15358 (void *)&cmd_set_vxlan_udp_src_value,
15359 (void *)&cmd_set_vxlan_udp_dst,
15360 (void *)&cmd_set_vxlan_udp_dst_value,
15361 (void *)&cmd_set_vxlan_ip_src,
15362 (void *)&cmd_set_vxlan_ip_src_value,
15363 (void *)&cmd_set_vxlan_ip_dst,
15364 (void *)&cmd_set_vxlan_ip_dst_value,
15365 (void *)&cmd_set_vxlan_eth_src,
15366 (void *)&cmd_set_vxlan_eth_src_value,
15367 (void *)&cmd_set_vxlan_eth_dst,
15368 (void *)&cmd_set_vxlan_eth_dst_value,
15373 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15374 .f = cmd_set_vxlan_parsed,
15376 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15377 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15378 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15379 " eth-dst <eth-dst>",
15381 (void *)&cmd_set_vxlan_set,
15382 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15383 (void *)&cmd_set_vxlan_ip_version,
15384 (void *)&cmd_set_vxlan_ip_version_value,
15385 (void *)&cmd_set_vxlan_vni,
15386 (void *)&cmd_set_vxlan_vni_value,
15387 (void *)&cmd_set_vxlan_udp_src,
15388 (void *)&cmd_set_vxlan_udp_src_value,
15389 (void *)&cmd_set_vxlan_udp_dst,
15390 (void *)&cmd_set_vxlan_udp_dst_value,
15391 (void *)&cmd_set_vxlan_ip_tos,
15392 (void *)&cmd_set_vxlan_ip_tos_value,
15393 (void *)&cmd_set_vxlan_ip_ttl,
15394 (void *)&cmd_set_vxlan_ip_ttl_value,
15395 (void *)&cmd_set_vxlan_ip_src,
15396 (void *)&cmd_set_vxlan_ip_src_value,
15397 (void *)&cmd_set_vxlan_ip_dst,
15398 (void *)&cmd_set_vxlan_ip_dst_value,
15399 (void *)&cmd_set_vxlan_eth_src,
15400 (void *)&cmd_set_vxlan_eth_src_value,
15401 (void *)&cmd_set_vxlan_eth_dst,
15402 (void *)&cmd_set_vxlan_eth_dst_value,
15407 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15408 .f = cmd_set_vxlan_parsed,
15410 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15411 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15412 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15415 (void *)&cmd_set_vxlan_set,
15416 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15417 (void *)&cmd_set_vxlan_ip_version,
15418 (void *)&cmd_set_vxlan_ip_version_value,
15419 (void *)&cmd_set_vxlan_vni,
15420 (void *)&cmd_set_vxlan_vni_value,
15421 (void *)&cmd_set_vxlan_udp_src,
15422 (void *)&cmd_set_vxlan_udp_src_value,
15423 (void *)&cmd_set_vxlan_udp_dst,
15424 (void *)&cmd_set_vxlan_udp_dst_value,
15425 (void *)&cmd_set_vxlan_ip_src,
15426 (void *)&cmd_set_vxlan_ip_src_value,
15427 (void *)&cmd_set_vxlan_ip_dst,
15428 (void *)&cmd_set_vxlan_ip_dst_value,
15429 (void *)&cmd_set_vxlan_vlan,
15430 (void *)&cmd_set_vxlan_vlan_value,
15431 (void *)&cmd_set_vxlan_eth_src,
15432 (void *)&cmd_set_vxlan_eth_src_value,
15433 (void *)&cmd_set_vxlan_eth_dst,
15434 (void *)&cmd_set_vxlan_eth_dst_value,
15439 /** Set NVGRE encapsulation details */
15440 struct cmd_set_nvgre_result {
15441 cmdline_fixed_string_t set;
15442 cmdline_fixed_string_t nvgre;
15443 cmdline_fixed_string_t pos_token;
15444 cmdline_fixed_string_t ip_version;
15446 cmdline_ipaddr_t ip_src;
15447 cmdline_ipaddr_t ip_dst;
15449 struct rte_ether_addr eth_src;
15450 struct rte_ether_addr eth_dst;
15453 cmdline_parse_token_string_t cmd_set_nvgre_set =
15454 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15455 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15456 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15457 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15458 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15459 "nvgre-with-vlan");
15460 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15461 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15463 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15464 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15466 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15467 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15469 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15470 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15471 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15472 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15474 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15475 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15476 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15477 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15479 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15480 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15481 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15482 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15484 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15485 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15486 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15487 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15489 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15490 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15491 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15492 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15494 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15495 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15497 static void cmd_set_nvgre_parsed(void *parsed_result,
15498 __attribute__((unused)) struct cmdline *cl,
15499 __attribute__((unused)) void *data)
15501 struct cmd_set_nvgre_result *res = parsed_result;
15503 uint32_t nvgre_tni;
15506 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15509 if (strcmp(res->nvgre, "nvgre") == 0)
15510 nvgre_encap_conf.select_vlan = 0;
15511 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15512 nvgre_encap_conf.select_vlan = 1;
15513 if (strcmp(res->ip_version, "ipv4") == 0)
15514 nvgre_encap_conf.select_ipv4 = 1;
15515 else if (strcmp(res->ip_version, "ipv6") == 0)
15516 nvgre_encap_conf.select_ipv4 = 0;
15519 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15520 if (nvgre_encap_conf.select_ipv4) {
15521 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15522 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15524 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15525 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15527 if (nvgre_encap_conf.select_vlan)
15528 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15529 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15530 RTE_ETHER_ADDR_LEN);
15531 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15532 RTE_ETHER_ADDR_LEN);
15535 cmdline_parse_inst_t cmd_set_nvgre = {
15536 .f = cmd_set_nvgre_parsed,
15538 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15539 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15540 " eth-dst <eth-dst>",
15542 (void *)&cmd_set_nvgre_set,
15543 (void *)&cmd_set_nvgre_nvgre,
15544 (void *)&cmd_set_nvgre_ip_version,
15545 (void *)&cmd_set_nvgre_ip_version_value,
15546 (void *)&cmd_set_nvgre_tni,
15547 (void *)&cmd_set_nvgre_tni_value,
15548 (void *)&cmd_set_nvgre_ip_src,
15549 (void *)&cmd_set_nvgre_ip_src_value,
15550 (void *)&cmd_set_nvgre_ip_dst,
15551 (void *)&cmd_set_nvgre_ip_dst_value,
15552 (void *)&cmd_set_nvgre_eth_src,
15553 (void *)&cmd_set_nvgre_eth_src_value,
15554 (void *)&cmd_set_nvgre_eth_dst,
15555 (void *)&cmd_set_nvgre_eth_dst_value,
15560 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15561 .f = cmd_set_nvgre_parsed,
15563 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15564 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15565 " eth-src <eth-src> eth-dst <eth-dst>",
15567 (void *)&cmd_set_nvgre_set,
15568 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15569 (void *)&cmd_set_nvgre_ip_version,
15570 (void *)&cmd_set_nvgre_ip_version_value,
15571 (void *)&cmd_set_nvgre_tni,
15572 (void *)&cmd_set_nvgre_tni_value,
15573 (void *)&cmd_set_nvgre_ip_src,
15574 (void *)&cmd_set_nvgre_ip_src_value,
15575 (void *)&cmd_set_nvgre_ip_dst,
15576 (void *)&cmd_set_nvgre_ip_dst_value,
15577 (void *)&cmd_set_nvgre_vlan,
15578 (void *)&cmd_set_nvgre_vlan_value,
15579 (void *)&cmd_set_nvgre_eth_src,
15580 (void *)&cmd_set_nvgre_eth_src_value,
15581 (void *)&cmd_set_nvgre_eth_dst,
15582 (void *)&cmd_set_nvgre_eth_dst_value,
15587 /** Set L2 encapsulation details */
15588 struct cmd_set_l2_encap_result {
15589 cmdline_fixed_string_t set;
15590 cmdline_fixed_string_t l2_encap;
15591 cmdline_fixed_string_t pos_token;
15592 cmdline_fixed_string_t ip_version;
15593 uint32_t vlan_present:1;
15595 struct rte_ether_addr eth_src;
15596 struct rte_ether_addr eth_dst;
15599 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15600 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15601 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15602 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15603 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15604 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15605 "l2_encap-with-vlan");
15606 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15607 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15609 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15610 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15612 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15613 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15615 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15616 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15617 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15618 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15620 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15621 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15622 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15623 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15625 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15626 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15628 static void cmd_set_l2_encap_parsed(void *parsed_result,
15629 __attribute__((unused)) struct cmdline *cl,
15630 __attribute__((unused)) void *data)
15632 struct cmd_set_l2_encap_result *res = parsed_result;
15634 if (strcmp(res->l2_encap, "l2_encap") == 0)
15635 l2_encap_conf.select_vlan = 0;
15636 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15637 l2_encap_conf.select_vlan = 1;
15638 if (strcmp(res->ip_version, "ipv4") == 0)
15639 l2_encap_conf.select_ipv4 = 1;
15640 else if (strcmp(res->ip_version, "ipv6") == 0)
15641 l2_encap_conf.select_ipv4 = 0;
15644 if (l2_encap_conf.select_vlan)
15645 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15646 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15647 RTE_ETHER_ADDR_LEN);
15648 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15649 RTE_ETHER_ADDR_LEN);
15652 cmdline_parse_inst_t cmd_set_l2_encap = {
15653 .f = cmd_set_l2_encap_parsed,
15655 .help_str = "set l2_encap ip-version ipv4|ipv6"
15656 " eth-src <eth-src> eth-dst <eth-dst>",
15658 (void *)&cmd_set_l2_encap_set,
15659 (void *)&cmd_set_l2_encap_l2_encap,
15660 (void *)&cmd_set_l2_encap_ip_version,
15661 (void *)&cmd_set_l2_encap_ip_version_value,
15662 (void *)&cmd_set_l2_encap_eth_src,
15663 (void *)&cmd_set_l2_encap_eth_src_value,
15664 (void *)&cmd_set_l2_encap_eth_dst,
15665 (void *)&cmd_set_l2_encap_eth_dst_value,
15670 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15671 .f = cmd_set_l2_encap_parsed,
15673 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15674 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15676 (void *)&cmd_set_l2_encap_set,
15677 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15678 (void *)&cmd_set_l2_encap_ip_version,
15679 (void *)&cmd_set_l2_encap_ip_version_value,
15680 (void *)&cmd_set_l2_encap_vlan,
15681 (void *)&cmd_set_l2_encap_vlan_value,
15682 (void *)&cmd_set_l2_encap_eth_src,
15683 (void *)&cmd_set_l2_encap_eth_src_value,
15684 (void *)&cmd_set_l2_encap_eth_dst,
15685 (void *)&cmd_set_l2_encap_eth_dst_value,
15690 /** Set L2 decapsulation details */
15691 struct cmd_set_l2_decap_result {
15692 cmdline_fixed_string_t set;
15693 cmdline_fixed_string_t l2_decap;
15694 cmdline_fixed_string_t pos_token;
15695 uint32_t vlan_present:1;
15698 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15699 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15700 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15701 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15703 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15704 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15705 "l2_decap-with-vlan");
15707 static void cmd_set_l2_decap_parsed(void *parsed_result,
15708 __attribute__((unused)) struct cmdline *cl,
15709 __attribute__((unused)) void *data)
15711 struct cmd_set_l2_decap_result *res = parsed_result;
15713 if (strcmp(res->l2_decap, "l2_decap") == 0)
15714 l2_decap_conf.select_vlan = 0;
15715 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15716 l2_decap_conf.select_vlan = 1;
15719 cmdline_parse_inst_t cmd_set_l2_decap = {
15720 .f = cmd_set_l2_decap_parsed,
15722 .help_str = "set l2_decap",
15724 (void *)&cmd_set_l2_decap_set,
15725 (void *)&cmd_set_l2_decap_l2_decap,
15730 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15731 .f = cmd_set_l2_decap_parsed,
15733 .help_str = "set l2_decap-with-vlan",
15735 (void *)&cmd_set_l2_decap_set,
15736 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15741 /** Set MPLSoGRE encapsulation details */
15742 struct cmd_set_mplsogre_encap_result {
15743 cmdline_fixed_string_t set;
15744 cmdline_fixed_string_t mplsogre;
15745 cmdline_fixed_string_t pos_token;
15746 cmdline_fixed_string_t ip_version;
15747 uint32_t vlan_present:1;
15749 cmdline_ipaddr_t ip_src;
15750 cmdline_ipaddr_t ip_dst;
15752 struct rte_ether_addr eth_src;
15753 struct rte_ether_addr eth_dst;
15756 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15757 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15759 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15760 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15762 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15763 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15764 mplsogre, "mplsogre_encap-with-vlan");
15765 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15766 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15767 pos_token, "ip-version");
15768 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15769 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15770 ip_version, "ipv4#ipv6");
15771 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15772 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15773 pos_token, "label");
15774 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15775 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15777 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15778 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15779 pos_token, "ip-src");
15780 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15781 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15782 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15783 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15784 pos_token, "ip-dst");
15785 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15786 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15787 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15788 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15789 pos_token, "vlan-tci");
15790 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15791 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15793 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15794 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15795 pos_token, "eth-src");
15796 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15797 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15799 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15800 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15801 pos_token, "eth-dst");
15802 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15803 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15806 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15807 __attribute__((unused)) struct cmdline *cl,
15808 __attribute__((unused)) void *data)
15810 struct cmd_set_mplsogre_encap_result *res = parsed_result;
15812 uint32_t mplsogre_label;
15815 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15818 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15819 mplsogre_encap_conf.select_vlan = 0;
15820 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15821 mplsogre_encap_conf.select_vlan = 1;
15822 if (strcmp(res->ip_version, "ipv4") == 0)
15823 mplsogre_encap_conf.select_ipv4 = 1;
15824 else if (strcmp(res->ip_version, "ipv6") == 0)
15825 mplsogre_encap_conf.select_ipv4 = 0;
15828 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15829 if (mplsogre_encap_conf.select_ipv4) {
15830 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15831 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15833 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15834 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15836 if (mplsogre_encap_conf.select_vlan)
15837 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15838 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15839 RTE_ETHER_ADDR_LEN);
15840 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15841 RTE_ETHER_ADDR_LEN);
15844 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15845 .f = cmd_set_mplsogre_encap_parsed,
15847 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15848 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15849 " eth-dst <eth-dst>",
15851 (void *)&cmd_set_mplsogre_encap_set,
15852 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15853 (void *)&cmd_set_mplsogre_encap_ip_version,
15854 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15855 (void *)&cmd_set_mplsogre_encap_label,
15856 (void *)&cmd_set_mplsogre_encap_label_value,
15857 (void *)&cmd_set_mplsogre_encap_ip_src,
15858 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15859 (void *)&cmd_set_mplsogre_encap_ip_dst,
15860 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15861 (void *)&cmd_set_mplsogre_encap_eth_src,
15862 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15863 (void *)&cmd_set_mplsogre_encap_eth_dst,
15864 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15869 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
15870 .f = cmd_set_mplsogre_encap_parsed,
15872 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
15873 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
15874 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15876 (void *)&cmd_set_mplsogre_encap_set,
15877 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
15878 (void *)&cmd_set_mplsogre_encap_ip_version,
15879 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15880 (void *)&cmd_set_mplsogre_encap_label,
15881 (void *)&cmd_set_mplsogre_encap_label_value,
15882 (void *)&cmd_set_mplsogre_encap_ip_src,
15883 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15884 (void *)&cmd_set_mplsogre_encap_ip_dst,
15885 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15886 (void *)&cmd_set_mplsogre_encap_vlan,
15887 (void *)&cmd_set_mplsogre_encap_vlan_value,
15888 (void *)&cmd_set_mplsogre_encap_eth_src,
15889 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15890 (void *)&cmd_set_mplsogre_encap_eth_dst,
15891 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15896 /** Set MPLSoGRE decapsulation details */
15897 struct cmd_set_mplsogre_decap_result {
15898 cmdline_fixed_string_t set;
15899 cmdline_fixed_string_t mplsogre;
15900 cmdline_fixed_string_t pos_token;
15901 cmdline_fixed_string_t ip_version;
15902 uint32_t vlan_present:1;
15905 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
15906 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
15908 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
15909 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
15911 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
15912 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15913 mplsogre, "mplsogre_decap-with-vlan");
15914 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
15915 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15916 pos_token, "ip-version");
15917 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
15918 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15919 ip_version, "ipv4#ipv6");
15921 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
15922 __attribute__((unused)) struct cmdline *cl,
15923 __attribute__((unused)) void *data)
15925 struct cmd_set_mplsogre_decap_result *res = parsed_result;
15927 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
15928 mplsogre_decap_conf.select_vlan = 0;
15929 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
15930 mplsogre_decap_conf.select_vlan = 1;
15931 if (strcmp(res->ip_version, "ipv4") == 0)
15932 mplsogre_decap_conf.select_ipv4 = 1;
15933 else if (strcmp(res->ip_version, "ipv6") == 0)
15934 mplsogre_decap_conf.select_ipv4 = 0;
15937 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
15938 .f = cmd_set_mplsogre_decap_parsed,
15940 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
15942 (void *)&cmd_set_mplsogre_decap_set,
15943 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
15944 (void *)&cmd_set_mplsogre_decap_ip_version,
15945 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15950 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
15951 .f = cmd_set_mplsogre_decap_parsed,
15953 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
15955 (void *)&cmd_set_mplsogre_decap_set,
15956 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
15957 (void *)&cmd_set_mplsogre_decap_ip_version,
15958 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15963 /** Set MPLSoUDP encapsulation details */
15964 struct cmd_set_mplsoudp_encap_result {
15965 cmdline_fixed_string_t set;
15966 cmdline_fixed_string_t mplsoudp;
15967 cmdline_fixed_string_t pos_token;
15968 cmdline_fixed_string_t ip_version;
15969 uint32_t vlan_present:1;
15973 cmdline_ipaddr_t ip_src;
15974 cmdline_ipaddr_t ip_dst;
15976 struct rte_ether_addr eth_src;
15977 struct rte_ether_addr eth_dst;
15980 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
15981 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
15983 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
15984 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
15986 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
15987 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15988 mplsoudp, "mplsoudp_encap-with-vlan");
15989 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
15990 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15991 pos_token, "ip-version");
15992 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
15993 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15994 ip_version, "ipv4#ipv6");
15995 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
15996 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15997 pos_token, "label");
15998 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
15999 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16001 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16002 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16003 pos_token, "udp-src");
16004 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16005 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16007 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16008 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16009 pos_token, "udp-dst");
16010 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16011 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16013 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16014 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16015 pos_token, "ip-src");
16016 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16017 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16018 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16019 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16020 pos_token, "ip-dst");
16021 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16022 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16023 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16024 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16025 pos_token, "vlan-tci");
16026 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16027 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16029 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16030 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16031 pos_token, "eth-src");
16032 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16033 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16035 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16036 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16037 pos_token, "eth-dst");
16038 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16039 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16042 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16043 __attribute__((unused)) struct cmdline *cl,
16044 __attribute__((unused)) void *data)
16046 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16048 uint32_t mplsoudp_label;
16051 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16054 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16055 mplsoudp_encap_conf.select_vlan = 0;
16056 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16057 mplsoudp_encap_conf.select_vlan = 1;
16058 if (strcmp(res->ip_version, "ipv4") == 0)
16059 mplsoudp_encap_conf.select_ipv4 = 1;
16060 else if (strcmp(res->ip_version, "ipv6") == 0)
16061 mplsoudp_encap_conf.select_ipv4 = 0;
16064 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16065 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16066 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16067 if (mplsoudp_encap_conf.select_ipv4) {
16068 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16069 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16071 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16072 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16074 if (mplsoudp_encap_conf.select_vlan)
16075 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16076 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16077 RTE_ETHER_ADDR_LEN);
16078 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16079 RTE_ETHER_ADDR_LEN);
16082 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16083 .f = cmd_set_mplsoudp_encap_parsed,
16085 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16086 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16087 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16089 (void *)&cmd_set_mplsoudp_encap_set,
16090 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16091 (void *)&cmd_set_mplsoudp_encap_ip_version,
16092 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16093 (void *)&cmd_set_mplsoudp_encap_label,
16094 (void *)&cmd_set_mplsoudp_encap_label_value,
16095 (void *)&cmd_set_mplsoudp_encap_udp_src,
16096 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16097 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16098 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16099 (void *)&cmd_set_mplsoudp_encap_ip_src,
16100 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16101 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16102 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16103 (void *)&cmd_set_mplsoudp_encap_eth_src,
16104 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16105 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16106 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16111 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16112 .f = cmd_set_mplsoudp_encap_parsed,
16114 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16115 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16116 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16117 " eth-src <eth-src> eth-dst <eth-dst>",
16119 (void *)&cmd_set_mplsoudp_encap_set,
16120 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16121 (void *)&cmd_set_mplsoudp_encap_ip_version,
16122 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16123 (void *)&cmd_set_mplsoudp_encap_label,
16124 (void *)&cmd_set_mplsoudp_encap_label_value,
16125 (void *)&cmd_set_mplsoudp_encap_udp_src,
16126 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16127 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16128 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16129 (void *)&cmd_set_mplsoudp_encap_ip_src,
16130 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16131 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16132 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16133 (void *)&cmd_set_mplsoudp_encap_vlan,
16134 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16135 (void *)&cmd_set_mplsoudp_encap_eth_src,
16136 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16137 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16138 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16143 /** Set MPLSoUDP decapsulation details */
16144 struct cmd_set_mplsoudp_decap_result {
16145 cmdline_fixed_string_t set;
16146 cmdline_fixed_string_t mplsoudp;
16147 cmdline_fixed_string_t pos_token;
16148 cmdline_fixed_string_t ip_version;
16149 uint32_t vlan_present:1;
16152 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16153 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16155 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16156 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16158 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16159 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16160 mplsoudp, "mplsoudp_decap-with-vlan");
16161 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16162 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16163 pos_token, "ip-version");
16164 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16165 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16166 ip_version, "ipv4#ipv6");
16168 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16169 __attribute__((unused)) struct cmdline *cl,
16170 __attribute__((unused)) void *data)
16172 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16174 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16175 mplsoudp_decap_conf.select_vlan = 0;
16176 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16177 mplsoudp_decap_conf.select_vlan = 1;
16178 if (strcmp(res->ip_version, "ipv4") == 0)
16179 mplsoudp_decap_conf.select_ipv4 = 1;
16180 else if (strcmp(res->ip_version, "ipv6") == 0)
16181 mplsoudp_decap_conf.select_ipv4 = 0;
16184 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16185 .f = cmd_set_mplsoudp_decap_parsed,
16187 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16189 (void *)&cmd_set_mplsoudp_decap_set,
16190 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16191 (void *)&cmd_set_mplsoudp_decap_ip_version,
16192 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16197 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16198 .f = cmd_set_mplsoudp_decap_parsed,
16200 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16202 (void *)&cmd_set_mplsoudp_decap_set,
16203 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16204 (void *)&cmd_set_mplsoudp_decap_ip_version,
16205 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16210 /* Strict link priority scheduling mode setting */
16212 cmd_strict_link_prio_parsed(
16213 void *parsed_result,
16214 __attribute__((unused)) struct cmdline *cl,
16215 __attribute__((unused)) void *data)
16217 struct cmd_vf_tc_bw_result *res = parsed_result;
16218 int ret = -ENOTSUP;
16220 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16223 #ifdef RTE_LIBRTE_I40E_PMD
16224 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16231 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16234 printf("invalid port_id %d\n", res->port_id);
16237 printf("function not implemented\n");
16240 printf("programming error: (%s)\n", strerror(-ret));
16244 cmdline_parse_inst_t cmd_strict_link_prio = {
16245 .f = cmd_strict_link_prio_parsed,
16247 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16249 (void *)&cmd_vf_tc_bw_set,
16250 (void *)&cmd_vf_tc_bw_tx,
16251 (void *)&cmd_vf_tc_bw_strict_link_prio,
16252 (void *)&cmd_vf_tc_bw_port_id,
16253 (void *)&cmd_vf_tc_bw_tc_map,
16258 /* Load dynamic device personalization*/
16259 struct cmd_ddp_add_result {
16260 cmdline_fixed_string_t ddp;
16261 cmdline_fixed_string_t add;
16266 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16267 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16268 cmdline_parse_token_string_t cmd_ddp_add_add =
16269 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16270 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16271 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16272 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16273 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16276 cmd_ddp_add_parsed(
16277 void *parsed_result,
16278 __attribute__((unused)) struct cmdline *cl,
16279 __attribute__((unused)) void *data)
16281 struct cmd_ddp_add_result *res = parsed_result;
16287 int ret = -ENOTSUP;
16289 if (!all_ports_stopped()) {
16290 printf("Please stop all ports first\n");
16294 filepath = strdup(res->filepath);
16295 if (filepath == NULL) {
16296 printf("Failed to allocate memory\n");
16299 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16301 buff = open_file(file_fld[0], &size);
16303 free((void *)filepath);
16307 #ifdef RTE_LIBRTE_I40E_PMD
16308 if (ret == -ENOTSUP)
16309 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16311 RTE_PMD_I40E_PKG_OP_WR_ADD);
16314 if (ret == -EEXIST)
16315 printf("Profile has already existed.\n");
16317 printf("Failed to load profile.\n");
16318 else if (file_num == 2)
16319 save_file(file_fld[1], buff, size);
16322 free((void *)filepath);
16325 cmdline_parse_inst_t cmd_ddp_add = {
16326 .f = cmd_ddp_add_parsed,
16328 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16330 (void *)&cmd_ddp_add_ddp,
16331 (void *)&cmd_ddp_add_add,
16332 (void *)&cmd_ddp_add_port_id,
16333 (void *)&cmd_ddp_add_filepath,
16338 /* Delete dynamic device personalization*/
16339 struct cmd_ddp_del_result {
16340 cmdline_fixed_string_t ddp;
16341 cmdline_fixed_string_t del;
16346 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16347 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16348 cmdline_parse_token_string_t cmd_ddp_del_del =
16349 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16350 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16351 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16352 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16353 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16356 cmd_ddp_del_parsed(
16357 void *parsed_result,
16358 __attribute__((unused)) struct cmdline *cl,
16359 __attribute__((unused)) void *data)
16361 struct cmd_ddp_del_result *res = parsed_result;
16364 int ret = -ENOTSUP;
16366 if (!all_ports_stopped()) {
16367 printf("Please stop all ports first\n");
16371 buff = open_file(res->filepath, &size);
16375 #ifdef RTE_LIBRTE_I40E_PMD
16376 if (ret == -ENOTSUP)
16377 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16379 RTE_PMD_I40E_PKG_OP_WR_DEL);
16382 if (ret == -EACCES)
16383 printf("Profile does not exist.\n");
16385 printf("Failed to delete profile.\n");
16390 cmdline_parse_inst_t cmd_ddp_del = {
16391 .f = cmd_ddp_del_parsed,
16393 .help_str = "ddp del <port_id> <backup_profile_path>",
16395 (void *)&cmd_ddp_del_ddp,
16396 (void *)&cmd_ddp_del_del,
16397 (void *)&cmd_ddp_del_port_id,
16398 (void *)&cmd_ddp_del_filepath,
16403 /* Get dynamic device personalization profile info */
16404 struct cmd_ddp_info_result {
16405 cmdline_fixed_string_t ddp;
16406 cmdline_fixed_string_t get;
16407 cmdline_fixed_string_t info;
16411 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16412 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16413 cmdline_parse_token_string_t cmd_ddp_info_get =
16414 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16415 cmdline_parse_token_string_t cmd_ddp_info_info =
16416 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16417 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16418 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16421 cmd_ddp_info_parsed(
16422 void *parsed_result,
16423 __attribute__((unused)) struct cmdline *cl,
16424 __attribute__((unused)) void *data)
16426 struct cmd_ddp_info_result *res = parsed_result;
16429 int ret = -ENOTSUP;
16430 #ifdef RTE_LIBRTE_I40E_PMD
16433 uint32_t buff_size = 0;
16434 struct rte_pmd_i40e_profile_info info;
16435 uint32_t dev_num = 0;
16436 struct rte_pmd_i40e_ddp_device_id *devs;
16437 uint32_t proto_num = 0;
16438 struct rte_pmd_i40e_proto_info *proto = NULL;
16439 uint32_t pctype_num = 0;
16440 struct rte_pmd_i40e_ptype_info *pctype;
16441 uint32_t ptype_num = 0;
16442 struct rte_pmd_i40e_ptype_info *ptype;
16447 pkg = open_file(res->filepath, &pkg_size);
16451 #ifdef RTE_LIBRTE_I40E_PMD
16452 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16453 (uint8_t *)&info, sizeof(info),
16454 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16456 printf("Global Track id: 0x%x\n", info.track_id);
16457 printf("Global Version: %d.%d.%d.%d\n",
16458 info.version.major,
16459 info.version.minor,
16460 info.version.update,
16461 info.version.draft);
16462 printf("Global Package name: %s\n\n", info.name);
16465 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16466 (uint8_t *)&info, sizeof(info),
16467 RTE_PMD_I40E_PKG_INFO_HEADER);
16469 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16470 printf("i40e Profile Version: %d.%d.%d.%d\n",
16471 info.version.major,
16472 info.version.minor,
16473 info.version.update,
16474 info.version.draft);
16475 printf("i40e Profile name: %s\n\n", info.name);
16478 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16479 (uint8_t *)&buff_size, sizeof(buff_size),
16480 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16481 if (!ret && buff_size) {
16482 buff = (uint8_t *)malloc(buff_size);
16484 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16486 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16488 printf("Package Notes:\n%s\n\n", buff);
16493 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16494 (uint8_t *)&dev_num, sizeof(dev_num),
16495 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16496 if (!ret && dev_num) {
16497 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16498 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16500 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16501 (uint8_t *)devs, buff_size,
16502 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16504 printf("List of supported devices:\n");
16505 for (i = 0; i < dev_num; i++) {
16506 printf(" %04X:%04X %04X:%04X\n",
16507 devs[i].vendor_dev_id >> 16,
16508 devs[i].vendor_dev_id & 0xFFFF,
16509 devs[i].sub_vendor_dev_id >> 16,
16510 devs[i].sub_vendor_dev_id & 0xFFFF);
16518 /* get information about protocols and packet types */
16519 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16520 (uint8_t *)&proto_num, sizeof(proto_num),
16521 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16522 if (ret || !proto_num)
16523 goto no_print_return;
16525 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16526 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16528 goto no_print_return;
16530 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16532 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16534 printf("List of used protocols:\n");
16535 for (i = 0; i < proto_num; i++)
16536 printf(" %2u: %s\n", proto[i].proto_id,
16540 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16541 (uint8_t *)&pctype_num, sizeof(pctype_num),
16542 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16543 if (ret || !pctype_num)
16544 goto no_print_pctypes;
16546 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16547 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16549 goto no_print_pctypes;
16551 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16553 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16556 goto no_print_pctypes;
16559 printf("List of defined packet classification types:\n");
16560 for (i = 0; i < pctype_num; i++) {
16561 printf(" %2u:", pctype[i].ptype_id);
16562 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16563 proto_id = pctype[i].protocols[j];
16564 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16565 for (n = 0; n < proto_num; n++) {
16566 if (proto[n].proto_id == proto_id) {
16567 printf(" %s", proto[n].name);
16580 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16582 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16583 if (ret || !ptype_num)
16584 goto no_print_return;
16586 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16587 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16589 goto no_print_return;
16591 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16593 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16596 goto no_print_return;
16598 printf("List of defined packet types:\n");
16599 for (i = 0; i < ptype_num; i++) {
16600 printf(" %2u:", ptype[i].ptype_id);
16601 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16602 proto_id = ptype[i].protocols[j];
16603 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16604 for (n = 0; n < proto_num; n++) {
16605 if (proto[n].proto_id == proto_id) {
16606 printf(" %s", proto[n].name);
16622 if (ret == -ENOTSUP)
16623 printf("Function not supported in PMD driver\n");
16627 cmdline_parse_inst_t cmd_ddp_get_info = {
16628 .f = cmd_ddp_info_parsed,
16630 .help_str = "ddp get info <profile_path>",
16632 (void *)&cmd_ddp_info_ddp,
16633 (void *)&cmd_ddp_info_get,
16634 (void *)&cmd_ddp_info_info,
16635 (void *)&cmd_ddp_info_filepath,
16640 /* Get dynamic device personalization profile info list*/
16641 #define PROFILE_INFO_SIZE 48
16642 #define MAX_PROFILE_NUM 16
16644 struct cmd_ddp_get_list_result {
16645 cmdline_fixed_string_t ddp;
16646 cmdline_fixed_string_t get;
16647 cmdline_fixed_string_t list;
16651 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16652 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16653 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16654 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16655 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16656 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16657 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16658 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16661 cmd_ddp_get_list_parsed(
16662 __attribute__((unused)) void *parsed_result,
16663 __attribute__((unused)) struct cmdline *cl,
16664 __attribute__((unused)) void *data)
16666 #ifdef RTE_LIBRTE_I40E_PMD
16667 struct cmd_ddp_get_list_result *res = parsed_result;
16668 struct rte_pmd_i40e_profile_list *p_list;
16669 struct rte_pmd_i40e_profile_info *p_info;
16674 int ret = -ENOTSUP;
16676 #ifdef RTE_LIBRTE_I40E_PMD
16677 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16678 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16680 printf("%s: Failed to malloc buffer\n", __func__);
16682 if (ret == -ENOTSUP)
16683 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16684 (uint8_t *)p_list, size);
16687 p_num = p_list->p_count;
16688 printf("Profile number is: %d\n\n", p_num);
16690 for (i = 0; i < p_num; i++) {
16691 p_info = &p_list->p_info[i];
16692 printf("Profile %d:\n", i);
16693 printf("Track id: 0x%x\n", p_info->track_id);
16694 printf("Version: %d.%d.%d.%d\n",
16695 p_info->version.major,
16696 p_info->version.minor,
16697 p_info->version.update,
16698 p_info->version.draft);
16699 printf("Profile name: %s\n\n", p_info->name);
16707 printf("Failed to get ddp list\n");
16710 cmdline_parse_inst_t cmd_ddp_get_list = {
16711 .f = cmd_ddp_get_list_parsed,
16713 .help_str = "ddp get list <port_id>",
16715 (void *)&cmd_ddp_get_list_ddp,
16716 (void *)&cmd_ddp_get_list_get,
16717 (void *)&cmd_ddp_get_list_list,
16718 (void *)&cmd_ddp_get_list_port_id,
16723 /* Configure input set */
16724 struct cmd_cfg_input_set_result {
16725 cmdline_fixed_string_t port;
16726 cmdline_fixed_string_t cfg;
16728 cmdline_fixed_string_t pctype;
16730 cmdline_fixed_string_t inset_type;
16731 cmdline_fixed_string_t opt;
16732 cmdline_fixed_string_t field;
16737 cmd_cfg_input_set_parsed(
16738 __attribute__((unused)) void *parsed_result,
16739 __attribute__((unused)) struct cmdline *cl,
16740 __attribute__((unused)) void *data)
16742 #ifdef RTE_LIBRTE_I40E_PMD
16743 struct cmd_cfg_input_set_result *res = parsed_result;
16744 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16745 struct rte_pmd_i40e_inset inset;
16747 int ret = -ENOTSUP;
16749 if (!all_ports_stopped()) {
16750 printf("Please stop all ports first\n");
16754 #ifdef RTE_LIBRTE_I40E_PMD
16755 if (!strcmp(res->inset_type, "hash_inset"))
16756 inset_type = INSET_HASH;
16757 else if (!strcmp(res->inset_type, "fdir_inset"))
16758 inset_type = INSET_FDIR;
16759 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16760 inset_type = INSET_FDIR_FLX;
16761 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16762 &inset, inset_type);
16764 printf("Failed to get input set.\n");
16768 if (!strcmp(res->opt, "get")) {
16769 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16772 printf("Field index %d is enabled.\n", res->field_idx);
16774 printf("Field index %d is disabled.\n", res->field_idx);
16776 } else if (!strcmp(res->opt, "set"))
16777 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16779 else if (!strcmp(res->opt, "clear"))
16780 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16783 printf("Failed to configure input set field.\n");
16787 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16788 &inset, inset_type);
16790 printf("Failed to set input set.\n");
16795 if (ret == -ENOTSUP)
16796 printf("Function not supported\n");
16799 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16800 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16802 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16803 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16805 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16806 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16808 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16809 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16811 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16812 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16814 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16815 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16817 "hash_inset#fdir_inset#fdir_flx_inset");
16818 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16819 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16820 opt, "get#set#clear");
16821 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16822 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16824 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16825 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16828 cmdline_parse_inst_t cmd_cfg_input_set = {
16829 .f = cmd_cfg_input_set_parsed,
16831 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16832 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16834 (void *)&cmd_cfg_input_set_port,
16835 (void *)&cmd_cfg_input_set_cfg,
16836 (void *)&cmd_cfg_input_set_port_id,
16837 (void *)&cmd_cfg_input_set_pctype,
16838 (void *)&cmd_cfg_input_set_pctype_id,
16839 (void *)&cmd_cfg_input_set_inset_type,
16840 (void *)&cmd_cfg_input_set_opt,
16841 (void *)&cmd_cfg_input_set_field,
16842 (void *)&cmd_cfg_input_set_field_idx,
16847 /* Clear input set */
16848 struct cmd_clear_input_set_result {
16849 cmdline_fixed_string_t port;
16850 cmdline_fixed_string_t cfg;
16852 cmdline_fixed_string_t pctype;
16854 cmdline_fixed_string_t inset_type;
16855 cmdline_fixed_string_t clear;
16856 cmdline_fixed_string_t all;
16860 cmd_clear_input_set_parsed(
16861 __attribute__((unused)) void *parsed_result,
16862 __attribute__((unused)) struct cmdline *cl,
16863 __attribute__((unused)) void *data)
16865 #ifdef RTE_LIBRTE_I40E_PMD
16866 struct cmd_clear_input_set_result *res = parsed_result;
16867 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16868 struct rte_pmd_i40e_inset inset;
16870 int ret = -ENOTSUP;
16872 if (!all_ports_stopped()) {
16873 printf("Please stop all ports first\n");
16877 #ifdef RTE_LIBRTE_I40E_PMD
16878 if (!strcmp(res->inset_type, "hash_inset"))
16879 inset_type = INSET_HASH;
16880 else if (!strcmp(res->inset_type, "fdir_inset"))
16881 inset_type = INSET_FDIR;
16882 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16883 inset_type = INSET_FDIR_FLX;
16885 memset(&inset, 0, sizeof(inset));
16887 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16888 &inset, inset_type);
16890 printf("Failed to clear input set.\n");
16896 if (ret == -ENOTSUP)
16897 printf("Function not supported\n");
16900 cmdline_parse_token_string_t cmd_clear_input_set_port =
16901 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16903 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
16904 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16906 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
16907 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16909 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
16910 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16912 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
16913 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16915 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
16916 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16918 "hash_inset#fdir_inset#fdir_flx_inset");
16919 cmdline_parse_token_string_t cmd_clear_input_set_clear =
16920 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16922 cmdline_parse_token_string_t cmd_clear_input_set_all =
16923 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16926 cmdline_parse_inst_t cmd_clear_input_set = {
16927 .f = cmd_clear_input_set_parsed,
16929 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16930 "fdir_inset|fdir_flx_inset clear all",
16932 (void *)&cmd_clear_input_set_port,
16933 (void *)&cmd_clear_input_set_cfg,
16934 (void *)&cmd_clear_input_set_port_id,
16935 (void *)&cmd_clear_input_set_pctype,
16936 (void *)&cmd_clear_input_set_pctype_id,
16937 (void *)&cmd_clear_input_set_inset_type,
16938 (void *)&cmd_clear_input_set_clear,
16939 (void *)&cmd_clear_input_set_all,
16944 /* show vf stats */
16946 /* Common result structure for show vf stats */
16947 struct cmd_show_vf_stats_result {
16948 cmdline_fixed_string_t show;
16949 cmdline_fixed_string_t vf;
16950 cmdline_fixed_string_t stats;
16955 /* Common CLI fields show vf stats*/
16956 cmdline_parse_token_string_t cmd_show_vf_stats_show =
16957 TOKEN_STRING_INITIALIZER
16958 (struct cmd_show_vf_stats_result,
16960 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
16961 TOKEN_STRING_INITIALIZER
16962 (struct cmd_show_vf_stats_result,
16964 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
16965 TOKEN_STRING_INITIALIZER
16966 (struct cmd_show_vf_stats_result,
16968 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
16969 TOKEN_NUM_INITIALIZER
16970 (struct cmd_show_vf_stats_result,
16972 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
16973 TOKEN_NUM_INITIALIZER
16974 (struct cmd_show_vf_stats_result,
16978 cmd_show_vf_stats_parsed(
16979 void *parsed_result,
16980 __attribute__((unused)) struct cmdline *cl,
16981 __attribute__((unused)) void *data)
16983 struct cmd_show_vf_stats_result *res = parsed_result;
16984 struct rte_eth_stats stats;
16985 int ret = -ENOTSUP;
16986 static const char *nic_stats_border = "########################";
16988 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16991 memset(&stats, 0, sizeof(stats));
16993 #ifdef RTE_LIBRTE_I40E_PMD
16994 if (ret == -ENOTSUP)
16995 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
16999 #ifdef RTE_LIBRTE_BNXT_PMD
17000 if (ret == -ENOTSUP)
17001 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17010 printf("invalid vf_id %d\n", res->vf_id);
17013 printf("invalid port_id %d\n", res->port_id);
17016 printf("function not implemented\n");
17019 printf("programming error: (%s)\n", strerror(-ret));
17022 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17023 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17025 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17027 stats.ipackets, stats.imissed, stats.ibytes);
17028 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17029 printf(" RX-nombuf: %-10"PRIu64"\n",
17031 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17033 stats.opackets, stats.oerrors, stats.obytes);
17035 printf(" %s############################%s\n",
17036 nic_stats_border, nic_stats_border);
17039 cmdline_parse_inst_t cmd_show_vf_stats = {
17040 .f = cmd_show_vf_stats_parsed,
17042 .help_str = "show vf stats <port_id> <vf_id>",
17044 (void *)&cmd_show_vf_stats_show,
17045 (void *)&cmd_show_vf_stats_vf,
17046 (void *)&cmd_show_vf_stats_stats,
17047 (void *)&cmd_show_vf_stats_port_id,
17048 (void *)&cmd_show_vf_stats_vf_id,
17053 /* clear vf stats */
17055 /* Common result structure for clear vf stats */
17056 struct cmd_clear_vf_stats_result {
17057 cmdline_fixed_string_t clear;
17058 cmdline_fixed_string_t vf;
17059 cmdline_fixed_string_t stats;
17064 /* Common CLI fields clear vf stats*/
17065 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17066 TOKEN_STRING_INITIALIZER
17067 (struct cmd_clear_vf_stats_result,
17069 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17070 TOKEN_STRING_INITIALIZER
17071 (struct cmd_clear_vf_stats_result,
17073 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17074 TOKEN_STRING_INITIALIZER
17075 (struct cmd_clear_vf_stats_result,
17077 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17078 TOKEN_NUM_INITIALIZER
17079 (struct cmd_clear_vf_stats_result,
17081 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17082 TOKEN_NUM_INITIALIZER
17083 (struct cmd_clear_vf_stats_result,
17087 cmd_clear_vf_stats_parsed(
17088 void *parsed_result,
17089 __attribute__((unused)) struct cmdline *cl,
17090 __attribute__((unused)) void *data)
17092 struct cmd_clear_vf_stats_result *res = parsed_result;
17093 int ret = -ENOTSUP;
17095 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17098 #ifdef RTE_LIBRTE_I40E_PMD
17099 if (ret == -ENOTSUP)
17100 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17103 #ifdef RTE_LIBRTE_BNXT_PMD
17104 if (ret == -ENOTSUP)
17105 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17113 printf("invalid vf_id %d\n", res->vf_id);
17116 printf("invalid port_id %d\n", res->port_id);
17119 printf("function not implemented\n");
17122 printf("programming error: (%s)\n", strerror(-ret));
17126 cmdline_parse_inst_t cmd_clear_vf_stats = {
17127 .f = cmd_clear_vf_stats_parsed,
17129 .help_str = "clear vf stats <port_id> <vf_id>",
17131 (void *)&cmd_clear_vf_stats_clear,
17132 (void *)&cmd_clear_vf_stats_vf,
17133 (void *)&cmd_clear_vf_stats_stats,
17134 (void *)&cmd_clear_vf_stats_port_id,
17135 (void *)&cmd_clear_vf_stats_vf_id,
17140 /* port config pctype mapping reset */
17142 /* Common result structure for port config pctype mapping reset */
17143 struct cmd_pctype_mapping_reset_result {
17144 cmdline_fixed_string_t port;
17145 cmdline_fixed_string_t config;
17147 cmdline_fixed_string_t pctype;
17148 cmdline_fixed_string_t mapping;
17149 cmdline_fixed_string_t reset;
17152 /* Common CLI fields for port config pctype mapping reset*/
17153 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17154 TOKEN_STRING_INITIALIZER
17155 (struct cmd_pctype_mapping_reset_result,
17157 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17158 TOKEN_STRING_INITIALIZER
17159 (struct cmd_pctype_mapping_reset_result,
17161 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17162 TOKEN_NUM_INITIALIZER
17163 (struct cmd_pctype_mapping_reset_result,
17165 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17166 TOKEN_STRING_INITIALIZER
17167 (struct cmd_pctype_mapping_reset_result,
17169 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17170 TOKEN_STRING_INITIALIZER
17171 (struct cmd_pctype_mapping_reset_result,
17172 mapping, "mapping");
17173 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17174 TOKEN_STRING_INITIALIZER
17175 (struct cmd_pctype_mapping_reset_result,
17179 cmd_pctype_mapping_reset_parsed(
17180 void *parsed_result,
17181 __attribute__((unused)) struct cmdline *cl,
17182 __attribute__((unused)) void *data)
17184 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17185 int ret = -ENOTSUP;
17187 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17190 #ifdef RTE_LIBRTE_I40E_PMD
17191 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17198 printf("invalid port_id %d\n", res->port_id);
17201 printf("function not implemented\n");
17204 printf("programming error: (%s)\n", strerror(-ret));
17208 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17209 .f = cmd_pctype_mapping_reset_parsed,
17211 .help_str = "port config <port_id> pctype mapping reset",
17213 (void *)&cmd_pctype_mapping_reset_port,
17214 (void *)&cmd_pctype_mapping_reset_config,
17215 (void *)&cmd_pctype_mapping_reset_port_id,
17216 (void *)&cmd_pctype_mapping_reset_pctype,
17217 (void *)&cmd_pctype_mapping_reset_mapping,
17218 (void *)&cmd_pctype_mapping_reset_reset,
17223 /* show port pctype mapping */
17225 /* Common result structure for show port pctype mapping */
17226 struct cmd_pctype_mapping_get_result {
17227 cmdline_fixed_string_t show;
17228 cmdline_fixed_string_t port;
17230 cmdline_fixed_string_t pctype;
17231 cmdline_fixed_string_t mapping;
17234 /* Common CLI fields for pctype mapping get */
17235 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17236 TOKEN_STRING_INITIALIZER
17237 (struct cmd_pctype_mapping_get_result,
17239 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17240 TOKEN_STRING_INITIALIZER
17241 (struct cmd_pctype_mapping_get_result,
17243 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17244 TOKEN_NUM_INITIALIZER
17245 (struct cmd_pctype_mapping_get_result,
17247 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17248 TOKEN_STRING_INITIALIZER
17249 (struct cmd_pctype_mapping_get_result,
17251 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17252 TOKEN_STRING_INITIALIZER
17253 (struct cmd_pctype_mapping_get_result,
17254 mapping, "mapping");
17257 cmd_pctype_mapping_get_parsed(
17258 void *parsed_result,
17259 __attribute__((unused)) struct cmdline *cl,
17260 __attribute__((unused)) void *data)
17262 struct cmd_pctype_mapping_get_result *res = parsed_result;
17263 int ret = -ENOTSUP;
17264 #ifdef RTE_LIBRTE_I40E_PMD
17265 struct rte_pmd_i40e_flow_type_mapping
17266 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17267 int i, j, first_pctype;
17270 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17273 #ifdef RTE_LIBRTE_I40E_PMD
17274 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17281 printf("invalid port_id %d\n", res->port_id);
17284 printf("function not implemented\n");
17287 printf("programming error: (%s)\n", strerror(-ret));
17291 #ifdef RTE_LIBRTE_I40E_PMD
17292 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17293 if (mapping[i].pctype != 0ULL) {
17296 printf("pctype: ");
17297 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17298 if (mapping[i].pctype & (1ULL << j)) {
17299 printf(first_pctype ?
17300 "%02d" : ",%02d", j);
17304 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17310 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17311 .f = cmd_pctype_mapping_get_parsed,
17313 .help_str = "show port <port_id> pctype mapping",
17315 (void *)&cmd_pctype_mapping_get_show,
17316 (void *)&cmd_pctype_mapping_get_port,
17317 (void *)&cmd_pctype_mapping_get_port_id,
17318 (void *)&cmd_pctype_mapping_get_pctype,
17319 (void *)&cmd_pctype_mapping_get_mapping,
17324 /* port config pctype mapping update */
17326 /* Common result structure for port config pctype mapping update */
17327 struct cmd_pctype_mapping_update_result {
17328 cmdline_fixed_string_t port;
17329 cmdline_fixed_string_t config;
17331 cmdline_fixed_string_t pctype;
17332 cmdline_fixed_string_t mapping;
17333 cmdline_fixed_string_t update;
17334 cmdline_fixed_string_t pctype_list;
17335 uint16_t flow_type;
17338 /* Common CLI fields for pctype mapping update*/
17339 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17340 TOKEN_STRING_INITIALIZER
17341 (struct cmd_pctype_mapping_update_result,
17343 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17344 TOKEN_STRING_INITIALIZER
17345 (struct cmd_pctype_mapping_update_result,
17347 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17348 TOKEN_NUM_INITIALIZER
17349 (struct cmd_pctype_mapping_update_result,
17351 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17352 TOKEN_STRING_INITIALIZER
17353 (struct cmd_pctype_mapping_update_result,
17355 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17356 TOKEN_STRING_INITIALIZER
17357 (struct cmd_pctype_mapping_update_result,
17358 mapping, "mapping");
17359 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17360 TOKEN_STRING_INITIALIZER
17361 (struct cmd_pctype_mapping_update_result,
17363 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17364 TOKEN_STRING_INITIALIZER
17365 (struct cmd_pctype_mapping_update_result,
17366 pctype_list, NULL);
17367 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17368 TOKEN_NUM_INITIALIZER
17369 (struct cmd_pctype_mapping_update_result,
17370 flow_type, UINT16);
17373 cmd_pctype_mapping_update_parsed(
17374 void *parsed_result,
17375 __attribute__((unused)) struct cmdline *cl,
17376 __attribute__((unused)) void *data)
17378 struct cmd_pctype_mapping_update_result *res = parsed_result;
17379 int ret = -ENOTSUP;
17380 #ifdef RTE_LIBRTE_I40E_PMD
17381 struct rte_pmd_i40e_flow_type_mapping mapping;
17383 unsigned int nb_item;
17384 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17387 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17390 #ifdef RTE_LIBRTE_I40E_PMD
17391 nb_item = parse_item_list(res->pctype_list, "pctypes",
17392 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17393 mapping.flow_type = res->flow_type;
17394 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17395 mapping.pctype |= (1ULL << pctype_list[i]);
17396 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17406 printf("invalid pctype or flow type\n");
17409 printf("invalid port_id %d\n", res->port_id);
17412 printf("function not implemented\n");
17415 printf("programming error: (%s)\n", strerror(-ret));
17419 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17420 .f = cmd_pctype_mapping_update_parsed,
17422 .help_str = "port config <port_id> pctype mapping update"
17423 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17425 (void *)&cmd_pctype_mapping_update_port,
17426 (void *)&cmd_pctype_mapping_update_config,
17427 (void *)&cmd_pctype_mapping_update_port_id,
17428 (void *)&cmd_pctype_mapping_update_pctype,
17429 (void *)&cmd_pctype_mapping_update_mapping,
17430 (void *)&cmd_pctype_mapping_update_update,
17431 (void *)&cmd_pctype_mapping_update_pc_type,
17432 (void *)&cmd_pctype_mapping_update_flow_type,
17437 /* ptype mapping get */
17439 /* Common result structure for ptype mapping get */
17440 struct cmd_ptype_mapping_get_result {
17441 cmdline_fixed_string_t ptype;
17442 cmdline_fixed_string_t mapping;
17443 cmdline_fixed_string_t get;
17445 uint8_t valid_only;
17448 /* Common CLI fields for ptype mapping get */
17449 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17450 TOKEN_STRING_INITIALIZER
17451 (struct cmd_ptype_mapping_get_result,
17453 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17454 TOKEN_STRING_INITIALIZER
17455 (struct cmd_ptype_mapping_get_result,
17456 mapping, "mapping");
17457 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17458 TOKEN_STRING_INITIALIZER
17459 (struct cmd_ptype_mapping_get_result,
17461 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17462 TOKEN_NUM_INITIALIZER
17463 (struct cmd_ptype_mapping_get_result,
17465 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17466 TOKEN_NUM_INITIALIZER
17467 (struct cmd_ptype_mapping_get_result,
17468 valid_only, UINT8);
17471 cmd_ptype_mapping_get_parsed(
17472 void *parsed_result,
17473 __attribute__((unused)) struct cmdline *cl,
17474 __attribute__((unused)) void *data)
17476 struct cmd_ptype_mapping_get_result *res = parsed_result;
17477 int ret = -ENOTSUP;
17478 #ifdef RTE_LIBRTE_I40E_PMD
17479 int max_ptype_num = 256;
17480 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17485 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17488 #ifdef RTE_LIBRTE_I40E_PMD
17489 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17500 printf("invalid port_id %d\n", res->port_id);
17503 printf("function not implemented\n");
17506 printf("programming error: (%s)\n", strerror(-ret));
17509 #ifdef RTE_LIBRTE_I40E_PMD
17511 for (i = 0; i < count; i++)
17512 printf("%3d\t0x%08x\n",
17513 mapping[i].hw_ptype, mapping[i].sw_ptype);
17518 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17519 .f = cmd_ptype_mapping_get_parsed,
17521 .help_str = "ptype mapping get <port_id> <valid_only>",
17523 (void *)&cmd_ptype_mapping_get_ptype,
17524 (void *)&cmd_ptype_mapping_get_mapping,
17525 (void *)&cmd_ptype_mapping_get_get,
17526 (void *)&cmd_ptype_mapping_get_port_id,
17527 (void *)&cmd_ptype_mapping_get_valid_only,
17532 /* ptype mapping replace */
17534 /* Common result structure for ptype mapping replace */
17535 struct cmd_ptype_mapping_replace_result {
17536 cmdline_fixed_string_t ptype;
17537 cmdline_fixed_string_t mapping;
17538 cmdline_fixed_string_t replace;
17545 /* Common CLI fields for ptype mapping replace */
17546 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17547 TOKEN_STRING_INITIALIZER
17548 (struct cmd_ptype_mapping_replace_result,
17550 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17551 TOKEN_STRING_INITIALIZER
17552 (struct cmd_ptype_mapping_replace_result,
17553 mapping, "mapping");
17554 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17555 TOKEN_STRING_INITIALIZER
17556 (struct cmd_ptype_mapping_replace_result,
17557 replace, "replace");
17558 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17559 TOKEN_NUM_INITIALIZER
17560 (struct cmd_ptype_mapping_replace_result,
17562 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17563 TOKEN_NUM_INITIALIZER
17564 (struct cmd_ptype_mapping_replace_result,
17566 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17567 TOKEN_NUM_INITIALIZER
17568 (struct cmd_ptype_mapping_replace_result,
17570 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17571 TOKEN_NUM_INITIALIZER
17572 (struct cmd_ptype_mapping_replace_result,
17576 cmd_ptype_mapping_replace_parsed(
17577 void *parsed_result,
17578 __attribute__((unused)) struct cmdline *cl,
17579 __attribute__((unused)) void *data)
17581 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17582 int ret = -ENOTSUP;
17584 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17587 #ifdef RTE_LIBRTE_I40E_PMD
17588 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17598 printf("invalid ptype 0x%8x or 0x%8x\n",
17599 res->target, res->pkt_type);
17602 printf("invalid port_id %d\n", res->port_id);
17605 printf("function not implemented\n");
17608 printf("programming error: (%s)\n", strerror(-ret));
17612 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17613 .f = cmd_ptype_mapping_replace_parsed,
17616 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17618 (void *)&cmd_ptype_mapping_replace_ptype,
17619 (void *)&cmd_ptype_mapping_replace_mapping,
17620 (void *)&cmd_ptype_mapping_replace_replace,
17621 (void *)&cmd_ptype_mapping_replace_port_id,
17622 (void *)&cmd_ptype_mapping_replace_target,
17623 (void *)&cmd_ptype_mapping_replace_mask,
17624 (void *)&cmd_ptype_mapping_replace_pkt_type,
17629 /* ptype mapping reset */
17631 /* Common result structure for ptype mapping reset */
17632 struct cmd_ptype_mapping_reset_result {
17633 cmdline_fixed_string_t ptype;
17634 cmdline_fixed_string_t mapping;
17635 cmdline_fixed_string_t reset;
17639 /* Common CLI fields for ptype mapping reset*/
17640 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17641 TOKEN_STRING_INITIALIZER
17642 (struct cmd_ptype_mapping_reset_result,
17644 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17645 TOKEN_STRING_INITIALIZER
17646 (struct cmd_ptype_mapping_reset_result,
17647 mapping, "mapping");
17648 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17649 TOKEN_STRING_INITIALIZER
17650 (struct cmd_ptype_mapping_reset_result,
17652 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17653 TOKEN_NUM_INITIALIZER
17654 (struct cmd_ptype_mapping_reset_result,
17658 cmd_ptype_mapping_reset_parsed(
17659 void *parsed_result,
17660 __attribute__((unused)) struct cmdline *cl,
17661 __attribute__((unused)) void *data)
17663 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17664 int ret = -ENOTSUP;
17666 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17669 #ifdef RTE_LIBRTE_I40E_PMD
17670 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17677 printf("invalid port_id %d\n", res->port_id);
17680 printf("function not implemented\n");
17683 printf("programming error: (%s)\n", strerror(-ret));
17687 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17688 .f = cmd_ptype_mapping_reset_parsed,
17690 .help_str = "ptype mapping reset <port_id>",
17692 (void *)&cmd_ptype_mapping_reset_ptype,
17693 (void *)&cmd_ptype_mapping_reset_mapping,
17694 (void *)&cmd_ptype_mapping_reset_reset,
17695 (void *)&cmd_ptype_mapping_reset_port_id,
17700 /* ptype mapping update */
17702 /* Common result structure for ptype mapping update */
17703 struct cmd_ptype_mapping_update_result {
17704 cmdline_fixed_string_t ptype;
17705 cmdline_fixed_string_t mapping;
17706 cmdline_fixed_string_t reset;
17712 /* Common CLI fields for ptype mapping update*/
17713 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17714 TOKEN_STRING_INITIALIZER
17715 (struct cmd_ptype_mapping_update_result,
17717 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17718 TOKEN_STRING_INITIALIZER
17719 (struct cmd_ptype_mapping_update_result,
17720 mapping, "mapping");
17721 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17722 TOKEN_STRING_INITIALIZER
17723 (struct cmd_ptype_mapping_update_result,
17725 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17726 TOKEN_NUM_INITIALIZER
17727 (struct cmd_ptype_mapping_update_result,
17729 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17730 TOKEN_NUM_INITIALIZER
17731 (struct cmd_ptype_mapping_update_result,
17733 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17734 TOKEN_NUM_INITIALIZER
17735 (struct cmd_ptype_mapping_update_result,
17739 cmd_ptype_mapping_update_parsed(
17740 void *parsed_result,
17741 __attribute__((unused)) struct cmdline *cl,
17742 __attribute__((unused)) void *data)
17744 struct cmd_ptype_mapping_update_result *res = parsed_result;
17745 int ret = -ENOTSUP;
17746 #ifdef RTE_LIBRTE_I40E_PMD
17747 struct rte_pmd_i40e_ptype_mapping mapping;
17749 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17752 #ifdef RTE_LIBRTE_I40E_PMD
17753 mapping.hw_ptype = res->hw_ptype;
17754 mapping.sw_ptype = res->sw_ptype;
17755 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17765 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17768 printf("invalid port_id %d\n", res->port_id);
17771 printf("function not implemented\n");
17774 printf("programming error: (%s)\n", strerror(-ret));
17778 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17779 .f = cmd_ptype_mapping_update_parsed,
17781 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17783 (void *)&cmd_ptype_mapping_update_ptype,
17784 (void *)&cmd_ptype_mapping_update_mapping,
17785 (void *)&cmd_ptype_mapping_update_update,
17786 (void *)&cmd_ptype_mapping_update_port_id,
17787 (void *)&cmd_ptype_mapping_update_hw_ptype,
17788 (void *)&cmd_ptype_mapping_update_sw_ptype,
17793 /* Common result structure for file commands */
17794 struct cmd_cmdfile_result {
17795 cmdline_fixed_string_t load;
17796 cmdline_fixed_string_t filename;
17799 /* Common CLI fields for file commands */
17800 cmdline_parse_token_string_t cmd_load_cmdfile =
17801 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17802 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17803 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17806 cmd_load_from_file_parsed(
17807 void *parsed_result,
17808 __attribute__((unused)) struct cmdline *cl,
17809 __attribute__((unused)) void *data)
17811 struct cmd_cmdfile_result *res = parsed_result;
17813 cmdline_read_from_file(res->filename);
17816 cmdline_parse_inst_t cmd_load_from_file = {
17817 .f = cmd_load_from_file_parsed,
17819 .help_str = "load <filename>",
17821 (void *)&cmd_load_cmdfile,
17822 (void *)&cmd_load_cmdfile_filename,
17827 /* Get Rx offloads capabilities */
17828 struct cmd_rx_offload_get_capa_result {
17829 cmdline_fixed_string_t show;
17830 cmdline_fixed_string_t port;
17832 cmdline_fixed_string_t rx_offload;
17833 cmdline_fixed_string_t capabilities;
17836 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17837 TOKEN_STRING_INITIALIZER
17838 (struct cmd_rx_offload_get_capa_result,
17840 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17841 TOKEN_STRING_INITIALIZER
17842 (struct cmd_rx_offload_get_capa_result,
17844 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17845 TOKEN_NUM_INITIALIZER
17846 (struct cmd_rx_offload_get_capa_result,
17848 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17849 TOKEN_STRING_INITIALIZER
17850 (struct cmd_rx_offload_get_capa_result,
17851 rx_offload, "rx_offload");
17852 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17853 TOKEN_STRING_INITIALIZER
17854 (struct cmd_rx_offload_get_capa_result,
17855 capabilities, "capabilities");
17858 print_rx_offloads(uint64_t offloads)
17860 uint64_t single_offload;
17868 begin = __builtin_ctzll(offloads);
17869 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17871 single_offload = 1ULL << begin;
17872 for (bit = begin; bit < end; bit++) {
17873 if (offloads & single_offload)
17875 rte_eth_dev_rx_offload_name(single_offload));
17876 single_offload <<= 1;
17881 cmd_rx_offload_get_capa_parsed(
17882 void *parsed_result,
17883 __attribute__((unused)) struct cmdline *cl,
17884 __attribute__((unused)) void *data)
17886 struct cmd_rx_offload_get_capa_result *res = parsed_result;
17887 struct rte_eth_dev_info dev_info;
17888 portid_t port_id = res->port_id;
17889 uint64_t queue_offloads;
17890 uint64_t port_offloads;
17892 rte_eth_dev_info_get(port_id, &dev_info);
17893 queue_offloads = dev_info.rx_queue_offload_capa;
17894 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
17896 printf("Rx Offloading Capabilities of port %d :\n", port_id);
17897 printf(" Per Queue :");
17898 print_rx_offloads(queue_offloads);
17901 printf(" Per Port :");
17902 print_rx_offloads(port_offloads);
17906 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
17907 .f = cmd_rx_offload_get_capa_parsed,
17909 .help_str = "show port <port_id> rx_offload capabilities",
17911 (void *)&cmd_rx_offload_get_capa_show,
17912 (void *)&cmd_rx_offload_get_capa_port,
17913 (void *)&cmd_rx_offload_get_capa_port_id,
17914 (void *)&cmd_rx_offload_get_capa_rx_offload,
17915 (void *)&cmd_rx_offload_get_capa_capabilities,
17920 /* Get Rx offloads configuration */
17921 struct cmd_rx_offload_get_configuration_result {
17922 cmdline_fixed_string_t show;
17923 cmdline_fixed_string_t port;
17925 cmdline_fixed_string_t rx_offload;
17926 cmdline_fixed_string_t configuration;
17929 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
17930 TOKEN_STRING_INITIALIZER
17931 (struct cmd_rx_offload_get_configuration_result,
17933 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
17934 TOKEN_STRING_INITIALIZER
17935 (struct cmd_rx_offload_get_configuration_result,
17937 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
17938 TOKEN_NUM_INITIALIZER
17939 (struct cmd_rx_offload_get_configuration_result,
17941 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
17942 TOKEN_STRING_INITIALIZER
17943 (struct cmd_rx_offload_get_configuration_result,
17944 rx_offload, "rx_offload");
17945 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
17946 TOKEN_STRING_INITIALIZER
17947 (struct cmd_rx_offload_get_configuration_result,
17948 configuration, "configuration");
17951 cmd_rx_offload_get_configuration_parsed(
17952 void *parsed_result,
17953 __attribute__((unused)) struct cmdline *cl,
17954 __attribute__((unused)) void *data)
17956 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
17957 struct rte_eth_dev_info dev_info;
17958 portid_t port_id = res->port_id;
17959 struct rte_port *port = &ports[port_id];
17960 uint64_t port_offloads;
17961 uint64_t queue_offloads;
17962 uint16_t nb_rx_queues;
17965 printf("Rx Offloading Configuration of port %d :\n", port_id);
17967 port_offloads = port->dev_conf.rxmode.offloads;
17969 print_rx_offloads(port_offloads);
17972 rte_eth_dev_info_get(port_id, &dev_info);
17973 nb_rx_queues = dev_info.nb_rx_queues;
17974 for (q = 0; q < nb_rx_queues; q++) {
17975 queue_offloads = port->rx_conf[q].offloads;
17976 printf(" Queue[%2d] :", q);
17977 print_rx_offloads(queue_offloads);
17983 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
17984 .f = cmd_rx_offload_get_configuration_parsed,
17986 .help_str = "show port <port_id> rx_offload configuration",
17988 (void *)&cmd_rx_offload_get_configuration_show,
17989 (void *)&cmd_rx_offload_get_configuration_port,
17990 (void *)&cmd_rx_offload_get_configuration_port_id,
17991 (void *)&cmd_rx_offload_get_configuration_rx_offload,
17992 (void *)&cmd_rx_offload_get_configuration_configuration,
17997 /* Enable/Disable a per port offloading */
17998 struct cmd_config_per_port_rx_offload_result {
17999 cmdline_fixed_string_t port;
18000 cmdline_fixed_string_t config;
18002 cmdline_fixed_string_t rx_offload;
18003 cmdline_fixed_string_t offload;
18004 cmdline_fixed_string_t on_off;
18007 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18008 TOKEN_STRING_INITIALIZER
18009 (struct cmd_config_per_port_rx_offload_result,
18011 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18012 TOKEN_STRING_INITIALIZER
18013 (struct cmd_config_per_port_rx_offload_result,
18015 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18016 TOKEN_NUM_INITIALIZER
18017 (struct cmd_config_per_port_rx_offload_result,
18019 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18020 TOKEN_STRING_INITIALIZER
18021 (struct cmd_config_per_port_rx_offload_result,
18022 rx_offload, "rx_offload");
18023 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18024 TOKEN_STRING_INITIALIZER
18025 (struct cmd_config_per_port_rx_offload_result,
18026 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18027 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18028 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18029 "crc_strip#scatter#timestamp#security#keep_crc");
18030 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18031 TOKEN_STRING_INITIALIZER
18032 (struct cmd_config_per_port_rx_offload_result,
18036 search_rx_offload(const char *name)
18038 uint64_t single_offload;
18039 const char *single_name;
18043 single_offload = 1;
18044 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18045 single_name = rte_eth_dev_rx_offload_name(single_offload);
18046 if (!strcasecmp(single_name, name)) {
18050 single_offload <<= 1;
18054 return single_offload;
18060 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18061 __attribute__((unused)) struct cmdline *cl,
18062 __attribute__((unused)) void *data)
18064 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18065 portid_t port_id = res->port_id;
18066 struct rte_eth_dev_info dev_info;
18067 struct rte_port *port = &ports[port_id];
18068 uint64_t single_offload;
18069 uint16_t nb_rx_queues;
18072 if (port->port_status != RTE_PORT_STOPPED) {
18073 printf("Error: Can't config offload when Port %d "
18074 "is not stopped\n", port_id);
18078 single_offload = search_rx_offload(res->offload);
18079 if (single_offload == 0) {
18080 printf("Unknown offload name: %s\n", res->offload);
18084 rte_eth_dev_info_get(port_id, &dev_info);
18085 nb_rx_queues = dev_info.nb_rx_queues;
18086 if (!strcmp(res->on_off, "on")) {
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;
18091 port->dev_conf.rxmode.offloads &= ~single_offload;
18092 for (q = 0; q < nb_rx_queues; q++)
18093 port->rx_conf[q].offloads &= ~single_offload;
18096 cmd_reconfig_device_queue(port_id, 1, 1);
18099 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18100 .f = cmd_config_per_port_rx_offload_parsed,
18102 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18103 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18104 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18105 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
18108 (void *)&cmd_config_per_port_rx_offload_result_port,
18109 (void *)&cmd_config_per_port_rx_offload_result_config,
18110 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18111 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18112 (void *)&cmd_config_per_port_rx_offload_result_offload,
18113 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18118 /* Enable/Disable a per queue offloading */
18119 struct cmd_config_per_queue_rx_offload_result {
18120 cmdline_fixed_string_t port;
18122 cmdline_fixed_string_t rxq;
18124 cmdline_fixed_string_t rx_offload;
18125 cmdline_fixed_string_t offload;
18126 cmdline_fixed_string_t on_off;
18129 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18130 TOKEN_STRING_INITIALIZER
18131 (struct cmd_config_per_queue_rx_offload_result,
18133 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18134 TOKEN_NUM_INITIALIZER
18135 (struct cmd_config_per_queue_rx_offload_result,
18137 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18138 TOKEN_STRING_INITIALIZER
18139 (struct cmd_config_per_queue_rx_offload_result,
18141 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18142 TOKEN_NUM_INITIALIZER
18143 (struct cmd_config_per_queue_rx_offload_result,
18145 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18146 TOKEN_STRING_INITIALIZER
18147 (struct cmd_config_per_queue_rx_offload_result,
18148 rx_offload, "rx_offload");
18149 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18150 TOKEN_STRING_INITIALIZER
18151 (struct cmd_config_per_queue_rx_offload_result,
18152 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18153 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18154 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18155 "crc_strip#scatter#timestamp#security#keep_crc");
18156 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18157 TOKEN_STRING_INITIALIZER
18158 (struct cmd_config_per_queue_rx_offload_result,
18162 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18163 __attribute__((unused)) struct cmdline *cl,
18164 __attribute__((unused)) void *data)
18166 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18167 struct rte_eth_dev_info dev_info;
18168 portid_t port_id = res->port_id;
18169 uint16_t queue_id = res->queue_id;
18170 struct rte_port *port = &ports[port_id];
18171 uint64_t single_offload;
18173 if (port->port_status != RTE_PORT_STOPPED) {
18174 printf("Error: Can't config offload when Port %d "
18175 "is not stopped\n", port_id);
18179 rte_eth_dev_info_get(port_id, &dev_info);
18180 if (queue_id >= dev_info.nb_rx_queues) {
18181 printf("Error: input queue_id should be 0 ... "
18182 "%d\n", dev_info.nb_rx_queues - 1);
18186 single_offload = search_rx_offload(res->offload);
18187 if (single_offload == 0) {
18188 printf("Unknown offload name: %s\n", res->offload);
18192 if (!strcmp(res->on_off, "on"))
18193 port->rx_conf[queue_id].offloads |= single_offload;
18195 port->rx_conf[queue_id].offloads &= ~single_offload;
18197 cmd_reconfig_device_queue(port_id, 1, 1);
18200 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18201 .f = cmd_config_per_queue_rx_offload_parsed,
18203 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18204 "vlan_strip|ipv4_cksum|"
18205 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18206 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18207 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
18210 (void *)&cmd_config_per_queue_rx_offload_result_port,
18211 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18212 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18213 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18214 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18215 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18216 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18221 /* Get Tx offloads capabilities */
18222 struct cmd_tx_offload_get_capa_result {
18223 cmdline_fixed_string_t show;
18224 cmdline_fixed_string_t port;
18226 cmdline_fixed_string_t tx_offload;
18227 cmdline_fixed_string_t capabilities;
18230 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18231 TOKEN_STRING_INITIALIZER
18232 (struct cmd_tx_offload_get_capa_result,
18234 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18235 TOKEN_STRING_INITIALIZER
18236 (struct cmd_tx_offload_get_capa_result,
18238 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18239 TOKEN_NUM_INITIALIZER
18240 (struct cmd_tx_offload_get_capa_result,
18242 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18243 TOKEN_STRING_INITIALIZER
18244 (struct cmd_tx_offload_get_capa_result,
18245 tx_offload, "tx_offload");
18246 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18247 TOKEN_STRING_INITIALIZER
18248 (struct cmd_tx_offload_get_capa_result,
18249 capabilities, "capabilities");
18252 print_tx_offloads(uint64_t offloads)
18254 uint64_t single_offload;
18262 begin = __builtin_ctzll(offloads);
18263 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18265 single_offload = 1ULL << begin;
18266 for (bit = begin; bit < end; bit++) {
18267 if (offloads & single_offload)
18269 rte_eth_dev_tx_offload_name(single_offload));
18270 single_offload <<= 1;
18275 cmd_tx_offload_get_capa_parsed(
18276 void *parsed_result,
18277 __attribute__((unused)) struct cmdline *cl,
18278 __attribute__((unused)) void *data)
18280 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18281 struct rte_eth_dev_info dev_info;
18282 portid_t port_id = res->port_id;
18283 uint64_t queue_offloads;
18284 uint64_t port_offloads;
18286 rte_eth_dev_info_get(port_id, &dev_info);
18287 queue_offloads = dev_info.tx_queue_offload_capa;
18288 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18290 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18291 printf(" Per Queue :");
18292 print_tx_offloads(queue_offloads);
18295 printf(" Per Port :");
18296 print_tx_offloads(port_offloads);
18300 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18301 .f = cmd_tx_offload_get_capa_parsed,
18303 .help_str = "show port <port_id> tx_offload capabilities",
18305 (void *)&cmd_tx_offload_get_capa_show,
18306 (void *)&cmd_tx_offload_get_capa_port,
18307 (void *)&cmd_tx_offload_get_capa_port_id,
18308 (void *)&cmd_tx_offload_get_capa_tx_offload,
18309 (void *)&cmd_tx_offload_get_capa_capabilities,
18314 /* Get Tx offloads configuration */
18315 struct cmd_tx_offload_get_configuration_result {
18316 cmdline_fixed_string_t show;
18317 cmdline_fixed_string_t port;
18319 cmdline_fixed_string_t tx_offload;
18320 cmdline_fixed_string_t configuration;
18323 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18324 TOKEN_STRING_INITIALIZER
18325 (struct cmd_tx_offload_get_configuration_result,
18327 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18328 TOKEN_STRING_INITIALIZER
18329 (struct cmd_tx_offload_get_configuration_result,
18331 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18332 TOKEN_NUM_INITIALIZER
18333 (struct cmd_tx_offload_get_configuration_result,
18335 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18336 TOKEN_STRING_INITIALIZER
18337 (struct cmd_tx_offload_get_configuration_result,
18338 tx_offload, "tx_offload");
18339 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18340 TOKEN_STRING_INITIALIZER
18341 (struct cmd_tx_offload_get_configuration_result,
18342 configuration, "configuration");
18345 cmd_tx_offload_get_configuration_parsed(
18346 void *parsed_result,
18347 __attribute__((unused)) struct cmdline *cl,
18348 __attribute__((unused)) void *data)
18350 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18351 struct rte_eth_dev_info dev_info;
18352 portid_t port_id = res->port_id;
18353 struct rte_port *port = &ports[port_id];
18354 uint64_t port_offloads;
18355 uint64_t queue_offloads;
18356 uint16_t nb_tx_queues;
18359 printf("Tx Offloading Configuration of port %d :\n", port_id);
18361 port_offloads = port->dev_conf.txmode.offloads;
18363 print_tx_offloads(port_offloads);
18366 rte_eth_dev_info_get(port_id, &dev_info);
18367 nb_tx_queues = dev_info.nb_tx_queues;
18368 for (q = 0; q < nb_tx_queues; q++) {
18369 queue_offloads = port->tx_conf[q].offloads;
18370 printf(" Queue[%2d] :", q);
18371 print_tx_offloads(queue_offloads);
18377 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18378 .f = cmd_tx_offload_get_configuration_parsed,
18380 .help_str = "show port <port_id> tx_offload configuration",
18382 (void *)&cmd_tx_offload_get_configuration_show,
18383 (void *)&cmd_tx_offload_get_configuration_port,
18384 (void *)&cmd_tx_offload_get_configuration_port_id,
18385 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18386 (void *)&cmd_tx_offload_get_configuration_configuration,
18391 /* Enable/Disable a per port offloading */
18392 struct cmd_config_per_port_tx_offload_result {
18393 cmdline_fixed_string_t port;
18394 cmdline_fixed_string_t config;
18396 cmdline_fixed_string_t tx_offload;
18397 cmdline_fixed_string_t offload;
18398 cmdline_fixed_string_t on_off;
18401 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18402 TOKEN_STRING_INITIALIZER
18403 (struct cmd_config_per_port_tx_offload_result,
18405 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18406 TOKEN_STRING_INITIALIZER
18407 (struct cmd_config_per_port_tx_offload_result,
18409 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18410 TOKEN_NUM_INITIALIZER
18411 (struct cmd_config_per_port_tx_offload_result,
18413 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18414 TOKEN_STRING_INITIALIZER
18415 (struct cmd_config_per_port_tx_offload_result,
18416 tx_offload, "tx_offload");
18417 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18418 TOKEN_STRING_INITIALIZER
18419 (struct cmd_config_per_port_tx_offload_result,
18420 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18421 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18422 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18423 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18424 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18426 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18427 TOKEN_STRING_INITIALIZER
18428 (struct cmd_config_per_port_tx_offload_result,
18432 search_tx_offload(const char *name)
18434 uint64_t single_offload;
18435 const char *single_name;
18439 single_offload = 1;
18440 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18441 single_name = rte_eth_dev_tx_offload_name(single_offload);
18442 if (single_name == NULL)
18444 if (!strcasecmp(single_name, name)) {
18447 } else if (!strcasecmp(single_name, "UNKNOWN"))
18449 single_offload <<= 1;
18453 return single_offload;
18459 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18460 __attribute__((unused)) struct cmdline *cl,
18461 __attribute__((unused)) void *data)
18463 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18464 portid_t port_id = res->port_id;
18465 struct rte_eth_dev_info dev_info;
18466 struct rte_port *port = &ports[port_id];
18467 uint64_t single_offload;
18468 uint16_t nb_tx_queues;
18471 if (port->port_status != RTE_PORT_STOPPED) {
18472 printf("Error: Can't config offload when Port %d "
18473 "is not stopped\n", port_id);
18477 single_offload = search_tx_offload(res->offload);
18478 if (single_offload == 0) {
18479 printf("Unknown offload name: %s\n", res->offload);
18483 rte_eth_dev_info_get(port_id, &dev_info);
18484 nb_tx_queues = dev_info.nb_tx_queues;
18485 if (!strcmp(res->on_off, "on")) {
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;
18490 port->dev_conf.txmode.offloads &= ~single_offload;
18491 for (q = 0; q < nb_tx_queues; q++)
18492 port->tx_conf[q].offloads &= ~single_offload;
18495 cmd_reconfig_device_queue(port_id, 1, 1);
18498 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18499 .f = cmd_config_per_port_tx_offload_parsed,
18501 .help_str = "port config <port_id> tx_offload "
18502 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18503 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18504 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18505 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18506 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18507 "match_metadata on|off",
18509 (void *)&cmd_config_per_port_tx_offload_result_port,
18510 (void *)&cmd_config_per_port_tx_offload_result_config,
18511 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18512 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18513 (void *)&cmd_config_per_port_tx_offload_result_offload,
18514 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18519 /* Enable/Disable a per queue offloading */
18520 struct cmd_config_per_queue_tx_offload_result {
18521 cmdline_fixed_string_t port;
18523 cmdline_fixed_string_t txq;
18525 cmdline_fixed_string_t tx_offload;
18526 cmdline_fixed_string_t offload;
18527 cmdline_fixed_string_t on_off;
18530 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18531 TOKEN_STRING_INITIALIZER
18532 (struct cmd_config_per_queue_tx_offload_result,
18534 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18535 TOKEN_NUM_INITIALIZER
18536 (struct cmd_config_per_queue_tx_offload_result,
18538 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18539 TOKEN_STRING_INITIALIZER
18540 (struct cmd_config_per_queue_tx_offload_result,
18542 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18543 TOKEN_NUM_INITIALIZER
18544 (struct cmd_config_per_queue_tx_offload_result,
18546 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18547 TOKEN_STRING_INITIALIZER
18548 (struct cmd_config_per_queue_tx_offload_result,
18549 tx_offload, "tx_offload");
18550 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18551 TOKEN_STRING_INITIALIZER
18552 (struct cmd_config_per_queue_tx_offload_result,
18553 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18554 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18555 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18556 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18557 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18558 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18559 TOKEN_STRING_INITIALIZER
18560 (struct cmd_config_per_queue_tx_offload_result,
18564 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18565 __attribute__((unused)) struct cmdline *cl,
18566 __attribute__((unused)) void *data)
18568 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18569 struct rte_eth_dev_info dev_info;
18570 portid_t port_id = res->port_id;
18571 uint16_t queue_id = res->queue_id;
18572 struct rte_port *port = &ports[port_id];
18573 uint64_t single_offload;
18575 if (port->port_status != RTE_PORT_STOPPED) {
18576 printf("Error: Can't config offload when Port %d "
18577 "is not stopped\n", port_id);
18581 rte_eth_dev_info_get(port_id, &dev_info);
18582 if (queue_id >= dev_info.nb_tx_queues) {
18583 printf("Error: input queue_id should be 0 ... "
18584 "%d\n", dev_info.nb_tx_queues - 1);
18588 single_offload = search_tx_offload(res->offload);
18589 if (single_offload == 0) {
18590 printf("Unknown offload name: %s\n", res->offload);
18594 if (!strcmp(res->on_off, "on"))
18595 port->tx_conf[queue_id].offloads |= single_offload;
18597 port->tx_conf[queue_id].offloads &= ~single_offload;
18599 cmd_reconfig_device_queue(port_id, 1, 1);
18602 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18603 .f = cmd_config_per_queue_tx_offload_parsed,
18605 .help_str = "port <port_id> txq <queue_id> tx_offload "
18606 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18607 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18608 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18609 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18610 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18613 (void *)&cmd_config_per_queue_tx_offload_result_port,
18614 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18615 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18616 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18617 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18618 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18619 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18624 /* *** configure tx_metadata for specific port *** */
18625 struct cmd_config_tx_metadata_specific_result {
18626 cmdline_fixed_string_t port;
18627 cmdline_fixed_string_t keyword;
18629 cmdline_fixed_string_t item;
18634 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18635 __attribute__((unused)) struct cmdline *cl,
18636 __attribute__((unused)) void *data)
18638 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18640 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18642 ports[res->port_id].tx_metadata = rte_cpu_to_be_32(res->value);
18643 /* Add/remove callback to insert valid metadata in every Tx packet. */
18644 if (ports[res->port_id].tx_metadata)
18645 add_tx_md_callback(res->port_id);
18647 remove_tx_md_callback(res->port_id);
18650 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18651 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18653 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18654 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18655 keyword, "config");
18656 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18657 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18659 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18660 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18661 item, "tx_metadata");
18662 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18663 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18666 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18667 .f = cmd_config_tx_metadata_specific_parsed,
18669 .help_str = "port config <port_id> tx_metadata <value>",
18671 (void *)&cmd_config_tx_metadata_specific_port,
18672 (void *)&cmd_config_tx_metadata_specific_keyword,
18673 (void *)&cmd_config_tx_metadata_specific_id,
18674 (void *)&cmd_config_tx_metadata_specific_item,
18675 (void *)&cmd_config_tx_metadata_specific_value,
18680 /* *** display tx_metadata per port configuration *** */
18681 struct cmd_show_tx_metadata_result {
18682 cmdline_fixed_string_t cmd_show;
18683 cmdline_fixed_string_t cmd_port;
18684 cmdline_fixed_string_t cmd_keyword;
18689 cmd_show_tx_metadata_parsed(void *parsed_result,
18690 __attribute__((unused)) struct cmdline *cl,
18691 __attribute__((unused)) void *data)
18693 struct cmd_show_tx_metadata_result *res = parsed_result;
18695 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18696 printf("invalid port id %u\n", res->cmd_pid);
18699 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18700 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18701 rte_be_to_cpu_32(ports[res->cmd_pid].tx_metadata));
18705 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18706 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18708 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18709 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18711 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18712 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18714 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18715 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18716 cmd_keyword, "tx_metadata");
18718 cmdline_parse_inst_t cmd_show_tx_metadata = {
18719 .f = cmd_show_tx_metadata_parsed,
18721 .help_str = "show port <port_id> tx_metadata",
18723 (void *)&cmd_show_tx_metadata_show,
18724 (void *)&cmd_show_tx_metadata_port,
18725 (void *)&cmd_show_tx_metadata_pid,
18726 (void *)&cmd_show_tx_metadata_keyword,
18731 /* ******************************************************************************** */
18733 /* list of instructions */
18734 cmdline_parse_ctx_t main_ctx[] = {
18735 (cmdline_parse_inst_t *)&cmd_help_brief,
18736 (cmdline_parse_inst_t *)&cmd_help_long,
18737 (cmdline_parse_inst_t *)&cmd_quit,
18738 (cmdline_parse_inst_t *)&cmd_load_from_file,
18739 (cmdline_parse_inst_t *)&cmd_showport,
18740 (cmdline_parse_inst_t *)&cmd_showqueue,
18741 (cmdline_parse_inst_t *)&cmd_showportall,
18742 (cmdline_parse_inst_t *)&cmd_showdevice,
18743 (cmdline_parse_inst_t *)&cmd_showcfg,
18744 (cmdline_parse_inst_t *)&cmd_showfwdall,
18745 (cmdline_parse_inst_t *)&cmd_start,
18746 (cmdline_parse_inst_t *)&cmd_start_tx_first,
18747 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
18748 (cmdline_parse_inst_t *)&cmd_set_link_up,
18749 (cmdline_parse_inst_t *)&cmd_set_link_down,
18750 (cmdline_parse_inst_t *)&cmd_reset,
18751 (cmdline_parse_inst_t *)&cmd_set_numbers,
18752 (cmdline_parse_inst_t *)&cmd_set_log,
18753 (cmdline_parse_inst_t *)&cmd_set_txpkts,
18754 (cmdline_parse_inst_t *)&cmd_set_txsplit,
18755 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
18756 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
18757 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
18758 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
18759 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
18760 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
18761 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
18762 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
18763 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
18764 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
18765 (cmdline_parse_inst_t *)&cmd_set_link_check,
18766 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
18767 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
18768 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
18769 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
18770 #ifdef RTE_LIBRTE_PMD_BOND
18771 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
18772 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
18773 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
18774 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
18775 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
18776 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
18777 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
18778 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
18779 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
18780 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
18781 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
18783 (cmdline_parse_inst_t *)&cmd_vlan_offload,
18784 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
18785 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
18786 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
18787 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
18788 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
18789 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
18790 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
18791 (cmdline_parse_inst_t *)&cmd_csum_set,
18792 (cmdline_parse_inst_t *)&cmd_csum_show,
18793 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
18794 (cmdline_parse_inst_t *)&cmd_tso_set,
18795 (cmdline_parse_inst_t *)&cmd_tso_show,
18796 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
18797 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
18798 (cmdline_parse_inst_t *)&cmd_gro_enable,
18799 (cmdline_parse_inst_t *)&cmd_gro_flush,
18800 (cmdline_parse_inst_t *)&cmd_gro_show,
18801 (cmdline_parse_inst_t *)&cmd_gso_enable,
18802 (cmdline_parse_inst_t *)&cmd_gso_size,
18803 (cmdline_parse_inst_t *)&cmd_gso_show,
18804 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
18805 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
18806 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
18807 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
18808 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
18809 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
18810 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
18811 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
18812 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
18813 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
18814 (cmdline_parse_inst_t *)&cmd_config_dcb,
18815 (cmdline_parse_inst_t *)&cmd_read_reg,
18816 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
18817 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
18818 (cmdline_parse_inst_t *)&cmd_write_reg,
18819 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
18820 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
18821 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
18822 (cmdline_parse_inst_t *)&cmd_stop,
18823 (cmdline_parse_inst_t *)&cmd_mac_addr,
18824 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
18825 (cmdline_parse_inst_t *)&cmd_set_qmap,
18826 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
18827 (cmdline_parse_inst_t *)&cmd_operate_port,
18828 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
18829 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
18830 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
18831 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
18832 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
18833 (cmdline_parse_inst_t *)&cmd_config_speed_all,
18834 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
18835 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
18836 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
18837 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
18838 (cmdline_parse_inst_t *)&cmd_config_mtu,
18839 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
18840 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
18841 (cmdline_parse_inst_t *)&cmd_config_rss,
18842 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
18843 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
18844 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
18845 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
18846 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
18847 (cmdline_parse_inst_t *)&cmd_showport_reta,
18848 (cmdline_parse_inst_t *)&cmd_config_burst,
18849 (cmdline_parse_inst_t *)&cmd_config_thresh,
18850 (cmdline_parse_inst_t *)&cmd_config_threshold,
18851 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
18852 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
18853 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
18854 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
18855 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
18856 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
18857 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
18858 (cmdline_parse_inst_t *)&cmd_global_config,
18859 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
18860 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
18861 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
18862 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
18863 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
18864 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
18865 (cmdline_parse_inst_t *)&cmd_dump,
18866 (cmdline_parse_inst_t *)&cmd_dump_one,
18867 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
18868 (cmdline_parse_inst_t *)&cmd_syn_filter,
18869 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
18870 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
18871 (cmdline_parse_inst_t *)&cmd_flex_filter,
18872 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
18873 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
18874 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
18875 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
18876 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
18877 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
18878 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
18879 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
18880 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
18881 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
18882 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
18883 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
18884 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
18885 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
18886 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
18887 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
18888 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
18889 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
18890 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
18891 (cmdline_parse_inst_t *)&cmd_flow,
18892 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
18893 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
18894 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
18895 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
18896 (cmdline_parse_inst_t *)&cmd_create_port_meter,
18897 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
18898 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
18899 (cmdline_parse_inst_t *)&cmd_del_port_meter,
18900 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
18901 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
18902 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
18903 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
18904 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
18905 (cmdline_parse_inst_t *)&cmd_mcast_addr,
18906 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
18907 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
18908 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
18909 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
18910 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
18911 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
18912 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
18913 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
18914 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
18915 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
18916 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
18917 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
18918 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
18919 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
18920 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
18921 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
18922 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
18923 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
18924 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
18925 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
18926 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
18927 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
18928 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
18929 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
18930 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
18931 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
18932 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
18933 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
18934 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
18935 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
18936 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
18937 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
18938 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
18939 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
18940 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
18941 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
18942 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
18944 (cmdline_parse_inst_t *)&cmd_set_vxlan,
18945 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
18946 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
18947 (cmdline_parse_inst_t *)&cmd_set_nvgre,
18948 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
18949 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
18950 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
18951 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
18952 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
18953 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
18954 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
18955 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
18956 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
18957 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
18958 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
18959 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
18960 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
18961 (cmdline_parse_inst_t *)&cmd_ddp_add,
18962 (cmdline_parse_inst_t *)&cmd_ddp_del,
18963 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
18964 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
18965 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
18966 (cmdline_parse_inst_t *)&cmd_clear_input_set,
18967 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
18968 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
18969 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
18970 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
18971 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
18972 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
18974 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
18975 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
18976 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
18977 (cmdline_parse_inst_t *)&cmd_queue_region,
18978 (cmdline_parse_inst_t *)&cmd_region_flowtype,
18979 (cmdline_parse_inst_t *)&cmd_user_priority_region,
18980 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
18981 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
18982 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
18983 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
18984 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
18985 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
18986 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
18987 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
18988 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
18989 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
18990 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
18991 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
18992 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
18993 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
18994 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
18995 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
18996 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
18997 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
18998 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
18999 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19000 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19001 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19002 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19003 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19004 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19005 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19006 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19007 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19008 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19009 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19010 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19011 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19012 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19013 #ifdef RTE_LIBRTE_BPF
19014 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19015 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19017 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19018 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19019 (cmdline_parse_inst_t *)&cmd_set_raw,
19023 /* read cmdline commands from file */
19025 cmdline_read_from_file(const char *filename)
19027 struct cmdline *cl;
19029 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19031 printf("Failed to create file based cmdline context: %s\n",
19036 cmdline_interact(cl);
19041 printf("Read CLI commands from %s\n", filename);
19044 /* prompt function, called from main on MASTER lcore */
19048 /* initialize non-constant commands */
19049 cmd_set_fwd_mode_init();
19050 cmd_set_fwd_retry_mode_init();
19052 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19053 if (testpmd_cl == NULL)
19055 cmdline_interact(testpmd_cl);
19056 cmdline_stdin_exit(testpmd_cl);
19062 if (testpmd_cl != NULL)
19063 cmdline_quit(testpmd_cl);
19067 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19069 if (id == (portid_t)RTE_PORT_ALL) {
19072 RTE_ETH_FOREACH_DEV(pid) {
19073 /* check if need_reconfig has been set to 1 */
19074 if (ports[pid].need_reconfig == 0)
19075 ports[pid].need_reconfig = dev;
19076 /* check if need_reconfig_queues has been set to 1 */
19077 if (ports[pid].need_reconfig_queues == 0)
19078 ports[pid].need_reconfig_queues = queue;
19080 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19081 /* check if need_reconfig has been set to 1 */
19082 if (ports[id].need_reconfig == 0)
19083 ports[id].need_reconfig = dev;
19084 /* check if need_reconfig_queues has been set to 1 */
19085 if (ports[id].need_reconfig_queues == 0)
19086 ports[id].need_reconfig_queues = queue;