1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
14 #ifdef RTE_EXEC_ENV_FREEBSD
15 #include <sys/socket.h>
17 #include <netinet/in.h>
19 #include <sys/queue.h>
21 #include <rte_common.h>
22 #include <rte_byteorder.h>
24 #include <rte_debug.h>
25 #include <rte_cycles.h>
26 #include <rte_memory.h>
27 #include <rte_memzone.h>
28 #include <rte_malloc.h>
29 #include <rte_launch.h>
31 #include <rte_per_lcore.h>
32 #include <rte_lcore.h>
33 #include <rte_atomic.h>
34 #include <rte_branch_prediction.h>
36 #include <rte_mempool.h>
37 #include <rte_interrupts.h>
39 #include <rte_ether.h>
40 #include <rte_ethdev.h>
41 #include <rte_string_fns.h>
42 #include <rte_devargs.h>
46 #include <cmdline_rdline.h>
47 #include <cmdline_parse.h>
48 #include <cmdline_parse_num.h>
49 #include <cmdline_parse_string.h>
50 #include <cmdline_parse_ipaddr.h>
51 #include <cmdline_parse_etheraddr.h>
52 #include <cmdline_socket.h>
54 #ifdef RTE_LIBRTE_PMD_BOND
55 #include <rte_eth_bond.h>
56 #include <rte_eth_bond_8023ad.h>
58 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
59 #include <rte_pmd_dpaa.h>
61 #ifdef RTE_LIBRTE_IXGBE_PMD
62 #include <rte_pmd_ixgbe.h>
64 #ifdef RTE_LIBRTE_I40E_PMD
65 #include <rte_pmd_i40e.h>
67 #ifdef RTE_LIBRTE_BNXT_PMD
68 #include <rte_pmd_bnxt.h>
71 #include "cmdline_mtr.h"
72 #include "cmdline_tm.h"
75 static struct cmdline *testpmd_cl;
77 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
79 /* *** Help command with introduction. *** */
80 struct cmd_help_brief_result {
81 cmdline_fixed_string_t help;
84 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
86 __attribute__((unused)) void *data)
91 "Help is available for the following sections:\n\n"
92 " help control : Start and stop forwarding.\n"
93 " help display : Displaying port, stats and config "
95 " help config : Configuration information.\n"
96 " help ports : Configuring ports.\n"
97 " help registers : Reading and setting port registers.\n"
98 " help filters : Filters configuration help.\n"
99 " help traffic_management : Traffic Management commmands.\n"
100 " help devices : Device related cmds.\n"
101 " help all : All of the above sections.\n\n"
106 cmdline_parse_token_string_t cmd_help_brief_help =
107 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
109 cmdline_parse_inst_t cmd_help_brief = {
110 .f = cmd_help_brief_parsed,
112 .help_str = "help: Show help",
114 (void *)&cmd_help_brief_help,
119 /* *** Help command with help sections. *** */
120 struct cmd_help_long_result {
121 cmdline_fixed_string_t help;
122 cmdline_fixed_string_t section;
125 static void cmd_help_long_parsed(void *parsed_result,
127 __attribute__((unused)) void *data)
130 struct cmd_help_long_result *res = parsed_result;
132 if (!strcmp(res->section, "all"))
135 if (show_all || !strcmp(res->section, "control")) {
140 "Control forwarding:\n"
141 "-------------------\n\n"
144 " Start packet forwarding with current configuration.\n\n"
147 " Start packet forwarding with current config"
148 " after sending one burst of packets.\n\n"
151 " Stop packet forwarding, and display accumulated"
155 " Quit to prompt.\n\n"
159 if (show_all || !strcmp(res->section, "display")) {
167 "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
168 " Display information for port_id, or all.\n\n"
170 "show port X rss reta (size) (mask0,mask1,...)\n"
171 " Display the rss redirection table entry indicated"
172 " by masks on port X. size is used to indicate the"
173 " hardware supported reta size\n\n"
175 "show port (port_id) rss-hash [key]\n"
176 " Display the RSS hash functions and RSS hash key of port\n\n"
178 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
179 " Clear information for port_id, or all.\n\n"
181 "show (rxq|txq) info (port_id) (queue_id)\n"
182 " Display information for configured RX/TX queue.\n\n"
184 "show config (rxtx|cores|fwd|txpkts)\n"
185 " Display the given configuration.\n\n"
187 "read rxd (port_id) (queue_id) (rxd_id)\n"
188 " Display an RX descriptor of a port RX queue.\n\n"
190 "read txd (port_id) (queue_id) (txd_id)\n"
191 " Display a TX descriptor of a port TX queue.\n\n"
193 "ddp get list (port_id)\n"
194 " Get ddp profile info list\n\n"
196 "ddp get info (profile_path)\n"
197 " Get ddp profile information.\n\n"
199 "show vf stats (port_id) (vf_id)\n"
200 " Display a VF's statistics.\n\n"
202 "clear vf stats (port_id) (vf_id)\n"
203 " Reset a VF's statistics.\n\n"
205 "show port (port_id) pctype mapping\n"
206 " Get flow ptype to pctype mapping on a port\n\n"
208 "show port meter stats (port_id) (meter_id) (clear)\n"
209 " Get meter stats on a port\n\n"
211 "show fwd stats all\n"
212 " Display statistics for all fwd engines.\n\n"
214 "clear fwd stats all\n"
215 " Clear statistics for all fwd engines.\n\n"
217 "show port (port_id) rx_offload capabilities\n"
218 " List all per queue and per port Rx offloading"
219 " capabilities of a port\n\n"
221 "show port (port_id) rx_offload configuration\n"
222 " List port level and all queue level"
223 " Rx offloading configuration\n\n"
225 "show port (port_id) tx_offload capabilities\n"
226 " List all per queue and per port"
227 " Tx offloading capabilities of a port\n\n"
229 "show port (port_id) tx_offload configuration\n"
230 " List port level and all queue level"
231 " Tx offloading configuration\n\n"
233 "show port (port_id) tx_metadata\n"
234 " Show Tx metadata value set"
235 " for a specific port\n\n"
237 "show port (port_id) ptypes\n"
238 " Show port supported ptypes"
239 " for a specific port\n\n"
241 "show device info (<identifier>|all)"
242 " Show general information about devices probed.\n\n"
244 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
245 " Show status of rx|tx descriptor.\n\n"
249 if (show_all || !strcmp(res->section, "config")) {
255 "Configuration changes only become active when"
256 " forwarding is started/restarted.\n\n"
259 " Reset forwarding to the default configuration.\n\n"
261 "set verbose (level)\n"
262 " Set the debug verbosity level X.\n\n"
264 "set log global|(type) (level)\n"
265 " Set the log level.\n\n"
268 " Set number of ports.\n\n"
271 " Set number of cores.\n\n"
273 "set coremask (mask)\n"
274 " Set the forwarding cores hexadecimal mask.\n\n"
276 "set portmask (mask)\n"
277 " Set the forwarding ports hexadecimal mask.\n\n"
280 " Set number of packets per burst.\n\n"
282 "set burst tx delay (microseconds) retry (num)\n"
283 " Set the transmit delay time and number of retries,"
284 " effective when retry is enabled.\n\n"
286 "set txpkts (x[,y]*)\n"
287 " Set the length of each segment of TXONLY"
288 " and optionally CSUM packets.\n\n"
290 "set txsplit (off|on|rand)\n"
291 " Set the split policy for the TX packets."
292 " Right now only applicable for CSUM and TXONLY"
295 "set corelist (x[,y]*)\n"
296 " Set the list of forwarding cores.\n\n"
298 "set portlist (x[,y]*)\n"
299 " Set the list of forwarding ports.\n\n"
301 "set port setup on (iterator|event)\n"
302 " Select how attached port is retrieved for setup.\n\n"
304 "set tx loopback (port_id) (on|off)\n"
305 " Enable or disable tx loopback.\n\n"
307 "set all queues drop (port_id) (on|off)\n"
308 " Set drop enable bit for all queues.\n\n"
310 "set vf split drop (port_id) (vf_id) (on|off)\n"
311 " Set split drop enable bit for a VF from the PF.\n\n"
313 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
314 " Set MAC antispoof for a VF from the PF.\n\n"
316 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
317 " Enable MACsec offload.\n\n"
319 "set macsec offload (port_id) off\n"
320 " Disable MACsec offload.\n\n"
322 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
323 " Configure MACsec secure connection (SC).\n\n"
325 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
326 " Configure MACsec secure association (SA).\n\n"
328 "set vf broadcast (port_id) (vf_id) (on|off)\n"
329 " Set VF broadcast for a VF from the PF.\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 (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
362 " Set the VLAN strip or filter or qinq strip or extend\n\n"
364 "vlan set (inner|outer) tpid (value) (port_id)\n"
365 " Set the VLAN TPID for Packet Filtering on"
368 "rx_vlan add (vlan_id|all) (port_id)\n"
369 " Add a vlan_id, or all identifiers, to the set"
370 " of VLAN identifiers filtered by port_id.\n\n"
372 "rx_vlan rm (vlan_id|all) (port_id)\n"
373 " Remove a vlan_id, or all identifiers, from the set"
374 " of VLAN identifiers filtered by port_id.\n\n"
376 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
377 " Add a vlan_id, to the set of VLAN identifiers"
378 "filtered for VF(s) from port_id.\n\n"
380 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
381 " Remove a vlan_id, to the set of VLAN identifiers"
382 "filtered for VF(s) from port_id.\n\n"
384 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
385 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
386 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
387 " add a tunnel filter of a port.\n\n"
389 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
390 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
391 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
392 " remove a tunnel filter of a port.\n\n"
394 "rx_vxlan_port add (udp_port) (port_id)\n"
395 " Add an UDP port for VXLAN packet filter on a port\n\n"
397 "rx_vxlan_port rm (udp_port) (port_id)\n"
398 " Remove an UDP port for VXLAN packet filter on a port\n\n"
400 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
401 " Set hardware insertion of VLAN IDs (single or double VLAN "
402 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
404 "tx_vlan set pvid port_id vlan_id (on|off)\n"
405 " Set port based TX VLAN insertion.\n\n"
407 "tx_vlan reset (port_id)\n"
408 " Disable hardware insertion of a VLAN header in"
409 " packets sent on a port.\n\n"
411 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
412 " Select hardware or software calculation of the"
413 " checksum when transmitting a packet using the"
414 " csum forward engine.\n"
415 " ip|udp|tcp|sctp always concern the inner layer.\n"
416 " outer-ip concerns the outer IP layer in"
417 " outer-udp concerns the outer UDP layer in"
418 " case the packet is recognized as a tunnel packet by"
419 " the forward engine (vxlan, gre and ipip are supported)\n"
420 " Please check the NIC datasheet for HW limits.\n\n"
422 "csum parse-tunnel (on|off) (tx_port_id)\n"
423 " If disabled, treat tunnel packets as non-tunneled"
424 " packets (treat inner headers as payload). The port\n"
425 " argument is the port used for TX in csum forward"
428 "csum show (port_id)\n"
429 " Display tx checksum offload configuration\n\n"
431 "tso set (segsize) (portid)\n"
432 " Enable TCP Segmentation Offload in csum forward"
434 " Please check the NIC datasheet for HW limits.\n\n"
437 " Display the status of TCP Segmentation Offload.\n\n"
439 "set port (port_id) gro on|off\n"
440 " Enable or disable Generic Receive Offload in"
441 " csum forwarding engine.\n\n"
443 "show port (port_id) gro\n"
444 " Display GRO configuration.\n\n"
446 "set gro flush (cycles)\n"
447 " Set the cycle to flush GROed packets from"
448 " reassembly tables.\n\n"
450 "set port (port_id) gso (on|off)"
451 " Enable or disable Generic Segmentation Offload in"
452 " csum forwarding engine.\n\n"
454 "set gso segsz (length)\n"
455 " Set max packet length for output GSO segments,"
456 " including packet header and payload.\n\n"
458 "show port (port_id) gso\n"
459 " Show GSO configuration.\n\n"
462 " Set packet forwarding mode.\n\n"
464 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
465 " Add a MAC address on port_id.\n\n"
467 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
468 " Remove a MAC address from port_id.\n\n"
470 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
471 " Set the default MAC address for port_id.\n\n"
473 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
474 " Add a MAC address for a VF on the port.\n\n"
476 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
477 " Set the MAC address for a VF from the PF.\n\n"
479 "set eth-peer (port_id) (peer_addr)\n"
480 " set the peer address for certain port.\n\n"
482 "set port (port_id) uta (mac_address|all) (on|off)\n"
483 " Add/Remove a or all unicast hash filter(s)"
486 "set promisc (port_id|all) (on|off)\n"
487 " Set the promiscuous mode on port_id, or all.\n\n"
489 "set allmulti (port_id|all) (on|off)\n"
490 " Set the allmulti mode on port_id, or all.\n\n"
492 "set vf promisc (port_id) (vf_id) (on|off)\n"
493 " Set unicast promiscuous mode for a VF from the PF.\n\n"
495 "set vf allmulti (port_id) (vf_id) (on|off)\n"
496 " Set multicast promiscuous mode for a VF from the PF.\n\n"
498 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
499 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
500 " (on|off) autoneg (on|off) (port_id)\n"
501 "set flow_ctrl rx (on|off) (portid)\n"
502 "set flow_ctrl tx (on|off) (portid)\n"
503 "set flow_ctrl high_water (high_water) (portid)\n"
504 "set flow_ctrl low_water (low_water) (portid)\n"
505 "set flow_ctrl pause_time (pause_time) (portid)\n"
506 "set flow_ctrl send_xon (send_xon) (portid)\n"
507 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
508 "set flow_ctrl autoneg (on|off) (port_id)\n"
509 " Set the link flow control parameter on a port.\n\n"
511 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
512 " (low_water) (pause_time) (priority) (port_id)\n"
513 " Set the priority flow control parameter on a"
516 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
517 " Set statistics mapping (qmapping 0..15) for RX/TX"
519 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
520 " on port 0 to mapping 5.\n\n"
522 "set xstats-hide-zero on|off\n"
523 " Set the option to hide the zero values"
524 " for xstats display.\n"
526 "set port (port_id) vf (vf_id) rx|tx on|off\n"
527 " Enable/Disable a VF receive/tranmit from a port\n\n"
529 "set port (port_id) vf (vf_id) (mac_addr)"
530 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
531 " Add/Remove unicast or multicast MAC addr filter"
534 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
536 " AUPE:accepts untagged VLAN;"
537 "ROPE:accept unicast hash\n\n"
538 " BAM:accepts broadcast packets;"
539 "MPE:accepts all multicast packets\n\n"
540 " Enable/Disable a VF receive mode of a port\n\n"
542 "set port (port_id) queue (queue_id) rate (rate_num)\n"
543 " Set rate limit for a queue of a port\n\n"
545 "set port (port_id) vf (vf_id) rate (rate_num) "
546 "queue_mask (queue_mask_value)\n"
547 " Set rate limit for queues in VF of a port\n\n"
549 "set port (port_id) mirror-rule (rule_id)"
550 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
551 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
552 " Set pool or vlan type mirror rule on a port.\n"
553 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
554 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
557 "set port (port_id) mirror-rule (rule_id)"
558 " (uplink-mirror|downlink-mirror) dst-pool"
559 " (pool_id) (on|off)\n"
560 " Set uplink or downlink type mirror rule on a port.\n"
561 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
562 " 0 on' enable mirror income traffic to pool 0.\n\n"
564 "reset port (port_id) mirror-rule (rule_id)\n"
565 " Reset a mirror rule.\n\n"
567 "set flush_rx (on|off)\n"
568 " Flush (default) or don't flush RX streams before"
569 " forwarding. Mainly used with PCAP drivers.\n\n"
571 "set bypass mode (normal|bypass|isolate) (port_id)\n"
572 " Set the bypass mode for the lowest port on bypass enabled"
575 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
576 "mode (normal|bypass|isolate) (port_id)\n"
577 " Set the event required to initiate specified bypass mode for"
578 " the lowest port on a bypass enabled NIC where:\n"
579 " timeout = enable bypass after watchdog timeout.\n"
580 " os_on = enable bypass when OS/board is powered on.\n"
581 " os_off = enable bypass when OS/board is powered off.\n"
582 " power_on = enable bypass when power supply is turned on.\n"
583 " power_off = enable bypass when power supply is turned off."
586 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
587 " Set the bypass watchdog timeout to 'n' seconds"
588 " where 0 = instant.\n\n"
590 "show bypass config (port_id)\n"
591 " Show the bypass configuration for a bypass enabled NIC"
592 " using the lowest port on the NIC.\n\n"
594 #ifdef RTE_LIBRTE_PMD_BOND
595 "create bonded device (mode) (socket)\n"
596 " Create a new bonded device with specific bonding mode and socket.\n\n"
598 "add bonding slave (slave_id) (port_id)\n"
599 " Add a slave device to a bonded device.\n\n"
601 "remove bonding slave (slave_id) (port_id)\n"
602 " Remove a slave device from a bonded device.\n\n"
604 "set bonding mode (value) (port_id)\n"
605 " Set the bonding mode on a bonded device.\n\n"
607 "set bonding primary (slave_id) (port_id)\n"
608 " Set the primary slave for a bonded device.\n\n"
610 "show bonding config (port_id)\n"
611 " Show the bonding config for port_id.\n\n"
613 "set bonding mac_addr (port_id) (address)\n"
614 " Set the MAC address of a bonded device.\n\n"
616 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
617 " Set Aggregation mode for IEEE802.3AD (mode 4)"
619 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
620 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
622 "set bonding mon_period (port_id) (value)\n"
623 " Set the bonding link status monitoring polling period in ms.\n\n"
625 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
626 " Enable/disable dedicated queues for LACP control traffic.\n\n"
629 "set link-up port (port_id)\n"
630 " Set link up for a port.\n\n"
632 "set link-down port (port_id)\n"
633 " Set link down for a port.\n\n"
635 "E-tag set insertion on port-tag-id (value)"
636 " port (port_id) vf (vf_id)\n"
637 " Enable E-tag insertion for a VF on a port\n\n"
639 "E-tag set insertion off port (port_id) vf (vf_id)\n"
640 " Disable E-tag insertion for a VF on a port\n\n"
642 "E-tag set stripping (on|off) port (port_id)\n"
643 " Enable/disable E-tag stripping on a port\n\n"
645 "E-tag set forwarding (on|off) port (port_id)\n"
646 " Enable/disable E-tag based forwarding"
649 "E-tag set filter add e-tag-id (value) dst-pool"
650 " (pool_id) port (port_id)\n"
651 " Add an E-tag forwarding filter on a port\n\n"
653 "E-tag set filter del e-tag-id (value) port (port_id)\n"
654 " Delete an E-tag forwarding filter on a port\n\n"
656 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
657 " Load a profile package on a port\n\n"
659 "ddp del (port_id) (backup_profile_path)\n"
660 " Delete a profile package from a port\n\n"
662 "ptype mapping get (port_id) (valid_only)\n"
663 " Get ptype mapping on a port\n\n"
665 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
666 " Replace target with the pkt_type in ptype mapping\n\n"
668 "ptype mapping reset (port_id)\n"
669 " Reset ptype mapping on a port\n\n"
671 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
672 " Update a ptype mapping item on a port\n\n"
674 "set port (port_id) queue-region region_id (value) "
675 "queue_start_index (value) queue_num (value)\n"
676 " Set a queue region on a port\n\n"
678 "set port (port_id) queue-region region_id (value) "
680 " Set a flowtype region index on a port\n\n"
682 "set port (port_id) queue-region UP (value) region_id (value)\n"
683 " Set the mapping of User Priority to "
684 "queue region on a port\n\n"
686 "set port (port_id) queue-region flush (on|off)\n"
687 " flush all queue region related configuration\n\n"
689 "show port meter cap (port_id)\n"
690 " Show port meter capability information\n\n"
692 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
693 " meter profile add - srtcm rfc 2697\n\n"
695 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
696 " meter profile add - trtcm rfc 2698\n\n"
698 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
699 " meter profile add - trtcm rfc 4115\n\n"
701 "del port meter profile (port_id) (profile_id)\n"
702 " meter profile delete\n\n"
704 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
705 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
706 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
707 "(dscp_tbl_entry63)]\n"
710 "enable port meter (port_id) (mtr_id)\n"
713 "disable port meter (port_id) (mtr_id)\n"
716 "del port meter (port_id) (mtr_id)\n"
719 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
720 " meter update meter profile\n\n"
722 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
723 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
724 " update meter dscp table entries\n\n"
726 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
727 "(action0) [(action1) (action2)]\n"
728 " meter update policer action\n\n"
730 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
731 " meter update stats\n\n"
733 "show port (port_id) queue-region\n"
734 " show all queue region related configuration info\n\n"
736 , list_pkt_forwarding_modes()
740 if (show_all || !strcmp(res->section, "ports")) {
746 "----------------\n\n"
748 "port start (port_id|all)\n"
749 " Start all ports or port_id.\n\n"
751 "port stop (port_id|all)\n"
752 " Stop all ports or port_id.\n\n"
754 "port close (port_id|all)\n"
755 " Close all ports or port_id.\n\n"
757 "port reset (port_id|all)\n"
758 " Reset all ports or port_id.\n\n"
760 "port attach (ident)\n"
761 " Attach physical or virtual dev by pci address or virtual device name\n\n"
763 "port detach (port_id)\n"
764 " Detach physical or virtual dev by port_id\n\n"
766 "port config (port_id|all)"
767 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
768 " duplex (half|full|auto)\n"
769 " Set speed and duplex for all ports or port_id\n\n"
771 "port config (port_id|all) loopback (mode)\n"
772 " Set loopback mode for all ports or port_id\n\n"
774 "port config all (rxq|txq|rxd|txd) (value)\n"
775 " Set number for rxq/txq/rxd/txd.\n\n"
777 "port config all max-pkt-len (value)\n"
778 " Set the max packet length.\n\n"
780 "port config all drop-en (on|off)\n"
781 " Enable or disable packet drop on all RX queues of all ports when no "
782 "receive buffers available.\n\n"
784 "port config all rss (all|default|ip|tcp|udp|sctp|"
785 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n"
786 " Set the RSS mode.\n\n"
788 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
789 " Set the RSS redirection table.\n\n"
791 "port config (port_id) dcb vt (on|off) (traffic_class)"
793 " Set the DCB mode.\n\n"
795 "port config all burst (value)\n"
796 " Set the number of packets per burst.\n\n"
798 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
800 " Set the ring prefetch/host/writeback threshold"
801 " for tx/rx queue.\n\n"
803 "port config all (txfreet|txrst|rxfreet) (value)\n"
804 " Set free threshold for rx/tx, or set"
805 " tx rs bit threshold.\n\n"
806 "port config mtu X value\n"
807 " Set the MTU of port X to a given value\n\n"
809 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
810 " Set a rx/tx queue's ring size configuration, the new"
811 " value will take effect after command that (re-)start the port"
812 " or command that setup the specific queue\n\n"
814 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
815 " Start/stop a rx/tx queue of port X. Only take effect"
816 " when port X is started\n\n"
818 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
819 " Switch on/off a deferred start of port X rx/tx queue. Only"
820 " take effect when port X is stopped.\n\n"
822 "port (port_id) (rxq|txq) (queue_id) setup\n"
823 " Setup a rx/tx queue of port X.\n\n"
825 "port config (port_id|all) l2-tunnel E-tag ether-type"
827 " Set the value of E-tag ether-type.\n\n"
829 "port config (port_id|all) l2-tunnel E-tag"
830 " (enable|disable)\n"
831 " Enable/disable the E-tag support.\n\n"
833 "port config (port_id) pctype mapping reset\n"
834 " Reset flow type to pctype mapping on a port\n\n"
836 "port config (port_id) pctype mapping update"
837 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
838 " Update a flow type to pctype mapping item on a port\n\n"
840 "port config (port_id) pctype (pctype_id) hash_inset|"
841 "fdir_inset|fdir_flx_inset get|set|clear field\n"
843 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
845 "port config (port_id) pctype (pctype_id) hash_inset|"
846 "fdir_inset|fdir_flx_inset clear all"
847 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
849 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
850 " Add/remove UDP tunnel port for tunneling offload\n\n"
852 "port config <port_id> rx_offload vlan_strip|"
853 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
854 "outer_ipv4_cksum|macsec_strip|header_split|"
855 "vlan_filter|vlan_extend|jumbo_frame|"
856 "scatter|timestamp|security|keep_crc on|off\n"
857 " Enable or disable a per port Rx offloading"
858 " on all Rx queues of a port\n\n"
860 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
861 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
862 "outer_ipv4_cksum|macsec_strip|header_split|"
863 "vlan_filter|vlan_extend|jumbo_frame|"
864 "scatter|timestamp|security|keep_crc on|off\n"
865 " Enable or disable a per queue Rx offloading"
866 " only on a specific Rx queue\n\n"
868 "port config (port_id) tx_offload vlan_insert|"
869 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
870 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
871 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
872 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
873 "security|match_metadata on|off\n"
874 " Enable or disable a per port Tx offloading"
875 " on all Tx queues of a port\n\n"
877 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
878 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
879 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
880 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
881 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
883 " Enable or disable a per queue Tx offloading"
884 " only on a specific Tx queue\n\n"
886 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
887 " Load an eBPF program as a callback"
888 " for particular RX/TX queue\n\n"
890 "bpf-unload rx|tx (port) (queue)\n"
891 " Unload previously loaded eBPF program"
892 " for particular RX/TX queue\n\n"
894 "port config (port_id) tx_metadata (value)\n"
895 " Set Tx metadata value per port. Testpmd will add this value"
896 " to any Tx packet sent from this port\n\n"
900 if (show_all || !strcmp(res->section, "registers")) {
908 "read reg (port_id) (address)\n"
909 " Display value of a port register.\n\n"
911 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
912 " Display a port register bit field.\n\n"
914 "read regbit (port_id) (address) (bit_x)\n"
915 " Display a single port register bit.\n\n"
917 "write reg (port_id) (address) (value)\n"
918 " Set value of a port register.\n\n"
920 "write regfield (port_id) (address) (bit_x) (bit_y)"
922 " Set bit field of a port register.\n\n"
924 "write regbit (port_id) (address) (bit_x) (value)\n"
925 " Set single bit value of a port register.\n\n"
928 if (show_all || !strcmp(res->section, "filters")) {
936 "ethertype_filter (port_id) (add|del)"
937 " (mac_addr|mac_ignr) (mac_address) ethertype"
938 " (ether_type) (drop|fwd) queue (queue_id)\n"
939 " Add/Del an ethertype filter.\n\n"
941 "2tuple_filter (port_id) (add|del)"
942 " dst_port (dst_port_value) protocol (protocol_value)"
943 " mask (mask_value) tcp_flags (tcp_flags_value)"
944 " priority (prio_value) queue (queue_id)\n"
945 " Add/Del a 2tuple filter.\n\n"
947 "5tuple_filter (port_id) (add|del)"
948 " dst_ip (dst_address) src_ip (src_address)"
949 " dst_port (dst_port_value) src_port (src_port_value)"
950 " protocol (protocol_value)"
951 " mask (mask_value) tcp_flags (tcp_flags_value)"
952 " priority (prio_value) queue (queue_id)\n"
953 " Add/Del a 5tuple filter.\n\n"
955 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
956 " Add/Del syn filter.\n\n"
958 "flex_filter (port_id) (add|del) len (len_value)"
959 " bytes (bytes_value) mask (mask_value)"
960 " priority (prio_value) queue (queue_id)\n"
961 " Add/Del a flex filter.\n\n"
963 "flow_director_filter (port_id) mode IP (add|del|update)"
964 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
965 " src (src_ip_address) dst (dst_ip_address)"
966 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
967 " vlan (vlan_value) flexbytes (flexbytes_value)"
968 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
969 " fd_id (fd_id_value)\n"
970 " Add/Del an IP type flow director filter.\n\n"
972 "flow_director_filter (port_id) mode IP (add|del|update)"
973 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
974 " src (src_ip_address) (src_port)"
975 " dst (dst_ip_address) (dst_port)"
976 " tos (tos_value) ttl (ttl_value)"
977 " vlan (vlan_value) flexbytes (flexbytes_value)"
978 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
979 " fd_id (fd_id_value)\n"
980 " Add/Del an UDP/TCP type flow director filter.\n\n"
982 "flow_director_filter (port_id) mode IP (add|del|update)"
983 " flow (ipv4-sctp|ipv6-sctp)"
984 " src (src_ip_address) (src_port)"
985 " dst (dst_ip_address) (dst_port)"
986 " tag (verification_tag) "
987 " tos (tos_value) ttl (ttl_value)"
989 " flexbytes (flexbytes_value) (drop|fwd)"
990 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
991 " Add/Del a SCTP type flow director filter.\n\n"
993 "flow_director_filter (port_id) mode IP (add|del|update)"
994 " flow l2_payload ether (ethertype)"
995 " flexbytes (flexbytes_value) (drop|fwd)"
996 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
997 " Add/Del a l2 payload type flow director filter.\n\n"
999 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1000 " mac (mac_address) vlan (vlan_value)"
1001 " flexbytes (flexbytes_value) (drop|fwd)"
1002 " queue (queue_id) fd_id (fd_id_value)\n"
1003 " Add/Del a MAC-VLAN flow director filter.\n\n"
1005 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1006 " mac (mac_address) vlan (vlan_value)"
1007 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1008 " flexbytes (flexbytes_value) (drop|fwd)"
1009 " queue (queue_id) fd_id (fd_id_value)\n"
1010 " Add/Del a Tunnel flow director filter.\n\n"
1012 "flow_director_filter (port_id) mode raw (add|del|update)"
1013 " flow (flow_id) (drop|fwd) queue (queue_id)"
1014 " fd_id (fd_id_value) packet (packet file name)\n"
1015 " Add/Del a raw type flow director filter.\n\n"
1017 "flush_flow_director (port_id)\n"
1018 " Flush all flow director entries of a device.\n\n"
1020 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1021 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1022 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1023 " Set flow director IP mask.\n\n"
1025 "flow_director_mask (port_id) mode MAC-VLAN"
1026 " vlan (vlan_value)\n"
1027 " Set flow director MAC-VLAN mask.\n\n"
1029 "flow_director_mask (port_id) mode Tunnel"
1030 " vlan (vlan_value) mac (mac_value)"
1031 " tunnel-type (tunnel_type_value)"
1032 " tunnel-id (tunnel_id_value)\n"
1033 " Set flow director Tunnel mask.\n\n"
1035 "flow_director_flex_mask (port_id)"
1036 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1037 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1039 " Configure mask of flex payload.\n\n"
1041 "flow_director_flex_payload (port_id)"
1042 " (raw|l2|l3|l4) (config)\n"
1043 " Configure flex payload selection.\n\n"
1045 "get_sym_hash_ena_per_port (port_id)\n"
1046 " get symmetric hash enable configuration per port.\n\n"
1048 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1049 " set symmetric hash enable configuration per port"
1050 " to enable or disable.\n\n"
1052 "get_hash_global_config (port_id)\n"
1053 " Get the global configurations of hash filters.\n\n"
1055 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1056 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1057 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1058 " (enable|disable)\n"
1059 " Set the global configurations of hash filters.\n\n"
1061 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1062 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1063 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1064 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1065 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1066 "ipv6-next-header|udp-src-port|udp-dst-port|"
1067 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1068 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1069 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1070 "fld-8th|none) (select|add)\n"
1071 " Set the input set for hash.\n\n"
1073 "set_fdir_input_set (port_id) "
1074 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1075 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1076 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1077 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1078 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1079 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1080 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1082 " Set the input set for FDir.\n\n"
1084 "flow validate {port_id}"
1085 " [group {group_id}] [priority {level}]"
1086 " [ingress] [egress]"
1087 " pattern {item} [/ {item} [...]] / end"
1088 " actions {action} [/ {action} [...]] / end\n"
1089 " Check whether a flow rule can be created.\n\n"
1091 "flow create {port_id}"
1092 " [group {group_id}] [priority {level}]"
1093 " [ingress] [egress]"
1094 " pattern {item} [/ {item} [...]] / end"
1095 " actions {action} [/ {action} [...]] / end\n"
1096 " Create a flow rule.\n\n"
1098 "flow destroy {port_id} rule {rule_id} [...]\n"
1099 " Destroy specific flow rules.\n\n"
1101 "flow flush {port_id}\n"
1102 " Destroy all flow rules.\n\n"
1104 "flow query {port_id} {rule_id} {action}\n"
1105 " Query an existing flow rule.\n\n"
1107 "flow list {port_id} [group {group_id}] [...]\n"
1108 " List existing flow rules sorted by priority,"
1109 " filtered by group identifiers.\n\n"
1111 "flow isolate {port_id} {boolean}\n"
1112 " Restrict ingress traffic to the defined"
1115 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1116 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1117 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1118 " Configure the VXLAN encapsulation for flows.\n\n"
1120 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1121 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1122 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1123 " eth-dst (eth-dst)\n"
1124 " Configure the VXLAN encapsulation for flows.\n\n"
1126 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1127 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1128 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1129 " eth-dst (eth-dst)\n"
1130 " Configure the VXLAN encapsulation for flows.\n\n"
1132 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1133 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1135 " Configure the NVGRE encapsulation for flows.\n\n"
1137 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1138 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1139 " eth-src (eth-src) eth-dst (eth-dst)\n"
1140 " Configure the NVGRE encapsulation for flows.\n\n"
1142 "set raw_encap {flow items}\n"
1143 " Configure the encapsulation with raw data.\n\n"
1145 "set raw_decap {flow items}\n"
1146 " Configure the decapsulation with raw data.\n\n"
1151 if (show_all || !strcmp(res->section, "traffic_management")) {
1155 "Traffic Management:\n"
1157 "show port tm cap (port_id)\n"
1158 " Display the port TM capability.\n\n"
1160 "show port tm level cap (port_id) (level_id)\n"
1161 " Display the port TM hierarchical level capability.\n\n"
1163 "show port tm node cap (port_id) (node_id)\n"
1164 " Display the port TM node capability.\n\n"
1166 "show port tm node type (port_id) (node_id)\n"
1167 " Display the port TM node type.\n\n"
1169 "show port tm node stats (port_id) (node_id) (clear)\n"
1170 " Display the port TM node stats.\n\n"
1172 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
1173 "set port tm hierarchy default (port_id)\n"
1174 " Set default traffic Management hierarchy on a port\n\n"
1177 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1178 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1179 " (packet_length_adjust)\n"
1180 " Add port tm node private shaper profile.\n\n"
1182 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1183 " Delete port tm node private shaper profile.\n\n"
1185 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1186 " (shaper_profile_id)\n"
1187 " Add/update port tm node shared shaper.\n\n"
1189 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1190 " Delete port tm node shared shaper.\n\n"
1192 "set port tm node shaper profile (port_id) (node_id)"
1193 " (shaper_profile_id)\n"
1194 " Set port tm node shaper profile.\n\n"
1196 "add port tm node wred profile (port_id) (wred_profile_id)"
1197 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1198 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1199 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1200 " Add port tm node wred profile.\n\n"
1202 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1203 " Delete port tm node wred profile.\n\n"
1205 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1206 " (priority) (weight) (level_id) (shaper_profile_id)"
1207 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1208 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1209 " Add port tm nonleaf node.\n\n"
1211 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1212 " (priority) (weight) (level_id) (shaper_profile_id)"
1213 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1214 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1215 " Add port tm leaf node.\n\n"
1217 "del port tm node (port_id) (node_id)\n"
1218 " Delete port tm node.\n\n"
1220 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1221 " (priority) (weight)\n"
1222 " Set port tm node parent.\n\n"
1224 "suspend port tm node (port_id) (node_id)"
1225 " Suspend tm node.\n\n"
1227 "resume port tm node (port_id) (node_id)"
1228 " Resume tm node.\n\n"
1230 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1231 " Commit tm hierarchy.\n\n"
1233 "set port tm mark ip_ecn (port) (green) (yellow)"
1235 " Enables/Disables the traffic management marking"
1236 " for IP ECN (Explicit Congestion Notification)"
1237 " packets on a given port\n\n"
1239 "set port tm mark ip_dscp (port) (green) (yellow)"
1241 " Enables/Disables the traffic management marking"
1242 " on the port for IP dscp packets\n\n"
1244 "set port tm mark vlan_dei (port) (green) (yellow)"
1246 " Enables/Disables the traffic management marking"
1247 " on the port for VLAN packets with DEI enabled\n\n"
1251 if (show_all || !strcmp(res->section, "devices")) {
1255 "Device Operations:\n"
1257 "device detach (identifier)\n"
1258 " Detach device by identifier.\n\n"
1264 cmdline_parse_token_string_t cmd_help_long_help =
1265 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1267 cmdline_parse_token_string_t cmd_help_long_section =
1268 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1269 "all#control#display#config#"
1270 "ports#registers#filters#traffic_management#devices");
1272 cmdline_parse_inst_t cmd_help_long = {
1273 .f = cmd_help_long_parsed,
1275 .help_str = "help all|control|display|config|ports|register|"
1276 "filters|traffic_management|devices: "
1279 (void *)&cmd_help_long_help,
1280 (void *)&cmd_help_long_section,
1286 /* *** start/stop/close all ports *** */
1287 struct cmd_operate_port_result {
1288 cmdline_fixed_string_t keyword;
1289 cmdline_fixed_string_t name;
1290 cmdline_fixed_string_t value;
1293 static void cmd_operate_port_parsed(void *parsed_result,
1294 __attribute__((unused)) struct cmdline *cl,
1295 __attribute__((unused)) void *data)
1297 struct cmd_operate_port_result *res = parsed_result;
1299 if (!strcmp(res->name, "start"))
1300 start_port(RTE_PORT_ALL);
1301 else if (!strcmp(res->name, "stop"))
1302 stop_port(RTE_PORT_ALL);
1303 else if (!strcmp(res->name, "close"))
1304 close_port(RTE_PORT_ALL);
1305 else if (!strcmp(res->name, "reset"))
1306 reset_port(RTE_PORT_ALL);
1308 printf("Unknown parameter\n");
1311 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1312 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1314 cmdline_parse_token_string_t cmd_operate_port_all_port =
1315 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1316 "start#stop#close#reset");
1317 cmdline_parse_token_string_t cmd_operate_port_all_all =
1318 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1320 cmdline_parse_inst_t cmd_operate_port = {
1321 .f = cmd_operate_port_parsed,
1323 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1325 (void *)&cmd_operate_port_all_cmd,
1326 (void *)&cmd_operate_port_all_port,
1327 (void *)&cmd_operate_port_all_all,
1332 /* *** start/stop/close specific port *** */
1333 struct cmd_operate_specific_port_result {
1334 cmdline_fixed_string_t keyword;
1335 cmdline_fixed_string_t name;
1339 static void cmd_operate_specific_port_parsed(void *parsed_result,
1340 __attribute__((unused)) struct cmdline *cl,
1341 __attribute__((unused)) void *data)
1343 struct cmd_operate_specific_port_result *res = parsed_result;
1345 if (!strcmp(res->name, "start"))
1346 start_port(res->value);
1347 else if (!strcmp(res->name, "stop"))
1348 stop_port(res->value);
1349 else if (!strcmp(res->name, "close"))
1350 close_port(res->value);
1351 else if (!strcmp(res->name, "reset"))
1352 reset_port(res->value);
1354 printf("Unknown parameter\n");
1357 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1358 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1360 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1361 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1362 name, "start#stop#close#reset");
1363 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1364 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1367 cmdline_parse_inst_t cmd_operate_specific_port = {
1368 .f = cmd_operate_specific_port_parsed,
1370 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1372 (void *)&cmd_operate_specific_port_cmd,
1373 (void *)&cmd_operate_specific_port_port,
1374 (void *)&cmd_operate_specific_port_id,
1379 /* *** enable port setup (after attach) via iterator or event *** */
1380 struct cmd_set_port_setup_on_result {
1381 cmdline_fixed_string_t set;
1382 cmdline_fixed_string_t port;
1383 cmdline_fixed_string_t setup;
1384 cmdline_fixed_string_t on;
1385 cmdline_fixed_string_t mode;
1388 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1389 __attribute__((unused)) struct cmdline *cl,
1390 __attribute__((unused)) void *data)
1392 struct cmd_set_port_setup_on_result *res = parsed_result;
1394 if (strcmp(res->mode, "event") == 0)
1395 setup_on_probe_event = true;
1396 else if (strcmp(res->mode, "iterator") == 0)
1397 setup_on_probe_event = false;
1399 printf("Unknown mode\n");
1402 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1403 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1405 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1406 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1408 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1409 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1411 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1412 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1414 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1415 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1416 mode, "iterator#event");
1418 cmdline_parse_inst_t cmd_set_port_setup_on = {
1419 .f = cmd_set_port_setup_on_parsed,
1421 .help_str = "set port setup on iterator|event",
1423 (void *)&cmd_set_port_setup_on_set,
1424 (void *)&cmd_set_port_setup_on_port,
1425 (void *)&cmd_set_port_setup_on_setup,
1426 (void *)&cmd_set_port_setup_on_on,
1427 (void *)&cmd_set_port_setup_on_mode,
1432 /* *** attach a specified port *** */
1433 struct cmd_operate_attach_port_result {
1434 cmdline_fixed_string_t port;
1435 cmdline_fixed_string_t keyword;
1436 cmdline_fixed_string_t identifier;
1439 static void cmd_operate_attach_port_parsed(void *parsed_result,
1440 __attribute__((unused)) struct cmdline *cl,
1441 __attribute__((unused)) void *data)
1443 struct cmd_operate_attach_port_result *res = parsed_result;
1445 if (!strcmp(res->keyword, "attach"))
1446 attach_port(res->identifier);
1448 printf("Unknown parameter\n");
1451 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1452 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1454 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1455 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1457 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1458 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1461 cmdline_parse_inst_t cmd_operate_attach_port = {
1462 .f = cmd_operate_attach_port_parsed,
1464 .help_str = "port attach <identifier>: "
1465 "(identifier: pci address or virtual dev name)",
1467 (void *)&cmd_operate_attach_port_port,
1468 (void *)&cmd_operate_attach_port_keyword,
1469 (void *)&cmd_operate_attach_port_identifier,
1474 /* *** detach a specified port *** */
1475 struct cmd_operate_detach_port_result {
1476 cmdline_fixed_string_t port;
1477 cmdline_fixed_string_t keyword;
1481 static void cmd_operate_detach_port_parsed(void *parsed_result,
1482 __attribute__((unused)) struct cmdline *cl,
1483 __attribute__((unused)) void *data)
1485 struct cmd_operate_detach_port_result *res = parsed_result;
1487 if (!strcmp(res->keyword, "detach"))
1488 detach_port_device(res->port_id);
1490 printf("Unknown parameter\n");
1493 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1494 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1496 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1497 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1499 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1500 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1503 cmdline_parse_inst_t cmd_operate_detach_port = {
1504 .f = cmd_operate_detach_port_parsed,
1506 .help_str = "port detach <port_id>",
1508 (void *)&cmd_operate_detach_port_port,
1509 (void *)&cmd_operate_detach_port_keyword,
1510 (void *)&cmd_operate_detach_port_port_id,
1515 /* *** detach device by identifier *** */
1516 struct cmd_operate_detach_device_result {
1517 cmdline_fixed_string_t device;
1518 cmdline_fixed_string_t keyword;
1519 cmdline_fixed_string_t identifier;
1522 static void cmd_operate_detach_device_parsed(void *parsed_result,
1523 __attribute__((unused)) struct cmdline *cl,
1524 __attribute__((unused)) void *data)
1526 struct cmd_operate_detach_device_result *res = parsed_result;
1528 if (!strcmp(res->keyword, "detach"))
1529 detach_device(res->identifier);
1531 printf("Unknown parameter\n");
1534 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1535 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1537 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1538 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1540 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1541 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1544 cmdline_parse_inst_t cmd_operate_detach_device = {
1545 .f = cmd_operate_detach_device_parsed,
1547 .help_str = "device detach <identifier>:"
1548 "(identifier: pci address or virtual dev name)",
1550 (void *)&cmd_operate_detach_device_device,
1551 (void *)&cmd_operate_detach_device_keyword,
1552 (void *)&cmd_operate_detach_device_identifier,
1556 /* *** configure speed for all ports *** */
1557 struct cmd_config_speed_all {
1558 cmdline_fixed_string_t port;
1559 cmdline_fixed_string_t keyword;
1560 cmdline_fixed_string_t all;
1561 cmdline_fixed_string_t item1;
1562 cmdline_fixed_string_t item2;
1563 cmdline_fixed_string_t value1;
1564 cmdline_fixed_string_t value2;
1568 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1573 if (!strcmp(duplexstr, "half")) {
1574 duplex = ETH_LINK_HALF_DUPLEX;
1575 } else if (!strcmp(duplexstr, "full")) {
1576 duplex = ETH_LINK_FULL_DUPLEX;
1577 } else if (!strcmp(duplexstr, "auto")) {
1578 duplex = ETH_LINK_FULL_DUPLEX;
1580 printf("Unknown duplex parameter\n");
1584 if (!strcmp(speedstr, "10")) {
1585 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1586 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1587 } else if (!strcmp(speedstr, "100")) {
1588 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1589 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1591 if (duplex != ETH_LINK_FULL_DUPLEX) {
1592 printf("Invalid speed/duplex parameters\n");
1595 if (!strcmp(speedstr, "1000")) {
1596 *speed = ETH_LINK_SPEED_1G;
1597 } else if (!strcmp(speedstr, "10000")) {
1598 *speed = ETH_LINK_SPEED_10G;
1599 } else if (!strcmp(speedstr, "25000")) {
1600 *speed = ETH_LINK_SPEED_25G;
1601 } else if (!strcmp(speedstr, "40000")) {
1602 *speed = ETH_LINK_SPEED_40G;
1603 } else if (!strcmp(speedstr, "50000")) {
1604 *speed = ETH_LINK_SPEED_50G;
1605 } else if (!strcmp(speedstr, "100000")) {
1606 *speed = ETH_LINK_SPEED_100G;
1607 } else if (!strcmp(speedstr, "auto")) {
1608 *speed = ETH_LINK_SPEED_AUTONEG;
1610 printf("Unknown speed parameter\n");
1619 cmd_config_speed_all_parsed(void *parsed_result,
1620 __attribute__((unused)) struct cmdline *cl,
1621 __attribute__((unused)) void *data)
1623 struct cmd_config_speed_all *res = parsed_result;
1624 uint32_t link_speed;
1627 if (!all_ports_stopped()) {
1628 printf("Please stop all ports first\n");
1632 if (parse_and_check_speed_duplex(res->value1, res->value2,
1636 RTE_ETH_FOREACH_DEV(pid) {
1637 ports[pid].dev_conf.link_speeds = link_speed;
1640 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1643 cmdline_parse_token_string_t cmd_config_speed_all_port =
1644 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1645 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1646 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1648 cmdline_parse_token_string_t cmd_config_speed_all_all =
1649 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1650 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1651 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1652 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1653 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1654 "10#100#1000#10000#25000#40000#50000#100000#auto");
1655 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1656 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1657 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1658 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1661 cmdline_parse_inst_t cmd_config_speed_all = {
1662 .f = cmd_config_speed_all_parsed,
1664 .help_str = "port config all speed "
1665 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1668 (void *)&cmd_config_speed_all_port,
1669 (void *)&cmd_config_speed_all_keyword,
1670 (void *)&cmd_config_speed_all_all,
1671 (void *)&cmd_config_speed_all_item1,
1672 (void *)&cmd_config_speed_all_value1,
1673 (void *)&cmd_config_speed_all_item2,
1674 (void *)&cmd_config_speed_all_value2,
1679 /* *** configure speed for specific port *** */
1680 struct cmd_config_speed_specific {
1681 cmdline_fixed_string_t port;
1682 cmdline_fixed_string_t keyword;
1684 cmdline_fixed_string_t item1;
1685 cmdline_fixed_string_t item2;
1686 cmdline_fixed_string_t value1;
1687 cmdline_fixed_string_t value2;
1691 cmd_config_speed_specific_parsed(void *parsed_result,
1692 __attribute__((unused)) struct cmdline *cl,
1693 __attribute__((unused)) void *data)
1695 struct cmd_config_speed_specific *res = parsed_result;
1696 uint32_t link_speed;
1698 if (!all_ports_stopped()) {
1699 printf("Please stop all ports first\n");
1703 if (port_id_is_invalid(res->id, ENABLED_WARN))
1706 if (parse_and_check_speed_duplex(res->value1, res->value2,
1710 ports[res->id].dev_conf.link_speeds = link_speed;
1712 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1716 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1717 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1719 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1720 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1722 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1723 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1724 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1725 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1727 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1728 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1729 "10#100#1000#10000#25000#40000#50000#100000#auto");
1730 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1731 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1733 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1734 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1737 cmdline_parse_inst_t cmd_config_speed_specific = {
1738 .f = cmd_config_speed_specific_parsed,
1740 .help_str = "port config <port_id> speed "
1741 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1744 (void *)&cmd_config_speed_specific_port,
1745 (void *)&cmd_config_speed_specific_keyword,
1746 (void *)&cmd_config_speed_specific_id,
1747 (void *)&cmd_config_speed_specific_item1,
1748 (void *)&cmd_config_speed_specific_value1,
1749 (void *)&cmd_config_speed_specific_item2,
1750 (void *)&cmd_config_speed_specific_value2,
1755 /* *** configure loopback for all ports *** */
1756 struct cmd_config_loopback_all {
1757 cmdline_fixed_string_t port;
1758 cmdline_fixed_string_t keyword;
1759 cmdline_fixed_string_t all;
1760 cmdline_fixed_string_t item;
1765 cmd_config_loopback_all_parsed(void *parsed_result,
1766 __attribute__((unused)) struct cmdline *cl,
1767 __attribute__((unused)) void *data)
1769 struct cmd_config_loopback_all *res = parsed_result;
1772 if (!all_ports_stopped()) {
1773 printf("Please stop all ports first\n");
1777 RTE_ETH_FOREACH_DEV(pid) {
1778 ports[pid].dev_conf.lpbk_mode = res->mode;
1781 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1784 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1785 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1786 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1787 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1789 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1790 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1791 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1792 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1794 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1795 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1797 cmdline_parse_inst_t cmd_config_loopback_all = {
1798 .f = cmd_config_loopback_all_parsed,
1800 .help_str = "port config all loopback <mode>",
1802 (void *)&cmd_config_loopback_all_port,
1803 (void *)&cmd_config_loopback_all_keyword,
1804 (void *)&cmd_config_loopback_all_all,
1805 (void *)&cmd_config_loopback_all_item,
1806 (void *)&cmd_config_loopback_all_mode,
1811 /* *** configure loopback for specific port *** */
1812 struct cmd_config_loopback_specific {
1813 cmdline_fixed_string_t port;
1814 cmdline_fixed_string_t keyword;
1816 cmdline_fixed_string_t item;
1821 cmd_config_loopback_specific_parsed(void *parsed_result,
1822 __attribute__((unused)) struct cmdline *cl,
1823 __attribute__((unused)) void *data)
1825 struct cmd_config_loopback_specific *res = parsed_result;
1827 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1830 if (!port_is_stopped(res->port_id)) {
1831 printf("Please stop port %u first\n", res->port_id);
1835 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1837 cmd_reconfig_device_queue(res->port_id, 1, 1);
1841 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1842 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1844 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1845 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1847 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1848 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1850 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1851 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1853 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1854 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1857 cmdline_parse_inst_t cmd_config_loopback_specific = {
1858 .f = cmd_config_loopback_specific_parsed,
1860 .help_str = "port config <port_id> loopback <mode>",
1862 (void *)&cmd_config_loopback_specific_port,
1863 (void *)&cmd_config_loopback_specific_keyword,
1864 (void *)&cmd_config_loopback_specific_id,
1865 (void *)&cmd_config_loopback_specific_item,
1866 (void *)&cmd_config_loopback_specific_mode,
1871 /* *** configure txq/rxq, txd/rxd *** */
1872 struct cmd_config_rx_tx {
1873 cmdline_fixed_string_t port;
1874 cmdline_fixed_string_t keyword;
1875 cmdline_fixed_string_t all;
1876 cmdline_fixed_string_t name;
1881 cmd_config_rx_tx_parsed(void *parsed_result,
1882 __attribute__((unused)) struct cmdline *cl,
1883 __attribute__((unused)) void *data)
1885 struct cmd_config_rx_tx *res = parsed_result;
1887 if (!all_ports_stopped()) {
1888 printf("Please stop all ports first\n");
1891 if (!strcmp(res->name, "rxq")) {
1892 if (!res->value && !nb_txq) {
1893 printf("Warning: Either rx or tx queues should be non zero\n");
1896 if (check_nb_rxq(res->value) != 0)
1898 nb_rxq = res->value;
1900 else if (!strcmp(res->name, "txq")) {
1901 if (!res->value && !nb_rxq) {
1902 printf("Warning: Either rx or tx queues should be non zero\n");
1905 if (check_nb_txq(res->value) != 0)
1907 nb_txq = res->value;
1909 else if (!strcmp(res->name, "rxd")) {
1910 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1911 printf("rxd %d invalid - must be > 0 && <= %d\n",
1912 res->value, RTE_TEST_RX_DESC_MAX);
1915 nb_rxd = res->value;
1916 } else if (!strcmp(res->name, "txd")) {
1917 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1918 printf("txd %d invalid - must be > 0 && <= %d\n",
1919 res->value, RTE_TEST_TX_DESC_MAX);
1922 nb_txd = res->value;
1924 printf("Unknown parameter\n");
1932 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1935 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1936 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1937 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1938 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1939 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1940 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1941 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1942 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1944 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1945 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1947 cmdline_parse_inst_t cmd_config_rx_tx = {
1948 .f = cmd_config_rx_tx_parsed,
1950 .help_str = "port config all rxq|txq|rxd|txd <value>",
1952 (void *)&cmd_config_rx_tx_port,
1953 (void *)&cmd_config_rx_tx_keyword,
1954 (void *)&cmd_config_rx_tx_all,
1955 (void *)&cmd_config_rx_tx_name,
1956 (void *)&cmd_config_rx_tx_value,
1961 /* *** config max packet length *** */
1962 struct cmd_config_max_pkt_len_result {
1963 cmdline_fixed_string_t port;
1964 cmdline_fixed_string_t keyword;
1965 cmdline_fixed_string_t all;
1966 cmdline_fixed_string_t name;
1971 cmd_config_max_pkt_len_parsed(void *parsed_result,
1972 __attribute__((unused)) struct cmdline *cl,
1973 __attribute__((unused)) void *data)
1975 struct cmd_config_max_pkt_len_result *res = parsed_result;
1978 if (!all_ports_stopped()) {
1979 printf("Please stop all ports first\n");
1983 RTE_ETH_FOREACH_DEV(pid) {
1984 struct rte_port *port = &ports[pid];
1985 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1987 if (!strcmp(res->name, "max-pkt-len")) {
1988 if (res->value < RTE_ETHER_MIN_LEN) {
1989 printf("max-pkt-len can not be less than %d\n",
1993 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1996 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1997 if (res->value > RTE_ETHER_MAX_LEN)
1998 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2000 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2001 port->dev_conf.rxmode.offloads = rx_offloads;
2003 printf("Unknown parameter\n");
2010 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2013 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2014 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2016 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2017 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2019 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2020 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2022 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2023 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2025 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2026 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2029 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2030 .f = cmd_config_max_pkt_len_parsed,
2032 .help_str = "port config all max-pkt-len <value>",
2034 (void *)&cmd_config_max_pkt_len_port,
2035 (void *)&cmd_config_max_pkt_len_keyword,
2036 (void *)&cmd_config_max_pkt_len_all,
2037 (void *)&cmd_config_max_pkt_len_name,
2038 (void *)&cmd_config_max_pkt_len_value,
2043 /* *** configure port MTU *** */
2044 struct cmd_config_mtu_result {
2045 cmdline_fixed_string_t port;
2046 cmdline_fixed_string_t keyword;
2047 cmdline_fixed_string_t mtu;
2053 cmd_config_mtu_parsed(void *parsed_result,
2054 __attribute__((unused)) struct cmdline *cl,
2055 __attribute__((unused)) void *data)
2057 struct cmd_config_mtu_result *res = parsed_result;
2059 if (res->value < RTE_ETHER_MIN_LEN) {
2060 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2063 port_mtu_set(res->port_id, res->value);
2066 cmdline_parse_token_string_t cmd_config_mtu_port =
2067 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2069 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2070 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2072 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2073 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2075 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2076 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2077 cmdline_parse_token_num_t cmd_config_mtu_value =
2078 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2080 cmdline_parse_inst_t cmd_config_mtu = {
2081 .f = cmd_config_mtu_parsed,
2083 .help_str = "port config mtu <port_id> <value>",
2085 (void *)&cmd_config_mtu_port,
2086 (void *)&cmd_config_mtu_keyword,
2087 (void *)&cmd_config_mtu_mtu,
2088 (void *)&cmd_config_mtu_port_id,
2089 (void *)&cmd_config_mtu_value,
2094 /* *** configure rx mode *** */
2095 struct cmd_config_rx_mode_flag {
2096 cmdline_fixed_string_t port;
2097 cmdline_fixed_string_t keyword;
2098 cmdline_fixed_string_t all;
2099 cmdline_fixed_string_t name;
2100 cmdline_fixed_string_t value;
2104 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2105 __attribute__((unused)) struct cmdline *cl,
2106 __attribute__((unused)) void *data)
2108 struct cmd_config_rx_mode_flag *res = parsed_result;
2110 if (!all_ports_stopped()) {
2111 printf("Please stop all ports first\n");
2115 if (!strcmp(res->name, "drop-en")) {
2116 if (!strcmp(res->value, "on"))
2118 else if (!strcmp(res->value, "off"))
2121 printf("Unknown parameter\n");
2125 printf("Unknown parameter\n");
2131 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2134 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2135 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2136 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2137 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2139 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2140 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2141 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2142 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2144 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2145 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2148 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2149 .f = cmd_config_rx_mode_flag_parsed,
2151 .help_str = "port config all drop-en on|off",
2153 (void *)&cmd_config_rx_mode_flag_port,
2154 (void *)&cmd_config_rx_mode_flag_keyword,
2155 (void *)&cmd_config_rx_mode_flag_all,
2156 (void *)&cmd_config_rx_mode_flag_name,
2157 (void *)&cmd_config_rx_mode_flag_value,
2162 /* *** configure rss *** */
2163 struct cmd_config_rss {
2164 cmdline_fixed_string_t port;
2165 cmdline_fixed_string_t keyword;
2166 cmdline_fixed_string_t all;
2167 cmdline_fixed_string_t name;
2168 cmdline_fixed_string_t value;
2172 cmd_config_rss_parsed(void *parsed_result,
2173 __attribute__((unused)) struct cmdline *cl,
2174 __attribute__((unused)) void *data)
2176 struct cmd_config_rss *res = parsed_result;
2177 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2178 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2179 int use_default = 0;
2180 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, "l3-src-only"))
2208 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2209 else if (!strcmp(res->value, "l3-dst-only"))
2210 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2211 else if (!strcmp(res->value, "l4-src-only"))
2212 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2213 else if (!strcmp(res->value, "l4-dst-only"))
2214 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2215 else if (!strcmp(res->value, "none"))
2216 rss_conf.rss_hf = 0;
2217 else if (!strcmp(res->value, "default"))
2219 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2220 atoi(res->value) < 64)
2221 rss_conf.rss_hf = 1ULL << atoi(res->value);
2223 printf("Unknown parameter\n");
2226 rss_conf.rss_key = NULL;
2227 /* Update global configuration for RSS types. */
2228 RTE_ETH_FOREACH_DEV(i) {
2229 struct rte_eth_rss_conf local_rss_conf;
2231 ret = eth_dev_info_get_print_err(i, &dev_info);
2236 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2238 local_rss_conf = rss_conf;
2239 local_rss_conf.rss_hf = rss_conf.rss_hf &
2240 dev_info.flow_type_rss_offloads;
2241 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2242 printf("Port %u modified RSS hash function based on hardware support,"
2243 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2244 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2246 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2249 printf("Configuration of RSS hash at ethernet port %d "
2250 "failed with error (%d): %s.\n",
2251 i, -diag, strerror(-diag));
2254 if (all_updated && !use_default)
2255 rss_hf = rss_conf.rss_hf;
2258 cmdline_parse_token_string_t cmd_config_rss_port =
2259 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2260 cmdline_parse_token_string_t cmd_config_rss_keyword =
2261 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2262 cmdline_parse_token_string_t cmd_config_rss_all =
2263 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2264 cmdline_parse_token_string_t cmd_config_rss_name =
2265 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2266 cmdline_parse_token_string_t cmd_config_rss_value =
2267 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2269 cmdline_parse_inst_t cmd_config_rss = {
2270 .f = cmd_config_rss_parsed,
2272 .help_str = "port config all rss "
2273 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>",
2275 (void *)&cmd_config_rss_port,
2276 (void *)&cmd_config_rss_keyword,
2277 (void *)&cmd_config_rss_all,
2278 (void *)&cmd_config_rss_name,
2279 (void *)&cmd_config_rss_value,
2284 /* *** configure rss hash key *** */
2285 struct cmd_config_rss_hash_key {
2286 cmdline_fixed_string_t port;
2287 cmdline_fixed_string_t config;
2289 cmdline_fixed_string_t rss_hash_key;
2290 cmdline_fixed_string_t rss_type;
2291 cmdline_fixed_string_t key;
2295 hexa_digit_to_value(char hexa_digit)
2297 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2298 return (uint8_t) (hexa_digit - '0');
2299 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2300 return (uint8_t) ((hexa_digit - 'a') + 10);
2301 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2302 return (uint8_t) ((hexa_digit - 'A') + 10);
2303 /* Invalid hexa digit */
2308 parse_and_check_key_hexa_digit(char *key, int idx)
2312 hexa_v = hexa_digit_to_value(key[idx]);
2314 printf("invalid key: character %c at position %d is not a "
2315 "valid hexa digit\n", key[idx], idx);
2320 cmd_config_rss_hash_key_parsed(void *parsed_result,
2321 __attribute__((unused)) struct cmdline *cl,
2322 __attribute__((unused)) void *data)
2324 struct cmd_config_rss_hash_key *res = parsed_result;
2325 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2329 struct rte_eth_dev_info dev_info;
2330 uint8_t hash_key_size;
2334 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2338 if (dev_info.hash_key_size > 0 &&
2339 dev_info.hash_key_size <= sizeof(hash_key))
2340 hash_key_size = dev_info.hash_key_size;
2342 printf("dev_info did not provide a valid hash key size\n");
2345 /* Check the length of the RSS hash key */
2346 key_len = strlen(res->key);
2347 if (key_len != (hash_key_size * 2)) {
2348 printf("key length: %d invalid - key must be a string of %d"
2349 " hexa-decimal numbers\n",
2350 (int) key_len, hash_key_size * 2);
2353 /* Translate RSS hash key into binary representation */
2354 for (i = 0; i < hash_key_size; i++) {
2355 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2358 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2361 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2363 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2367 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2368 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2369 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2370 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2372 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2373 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2374 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2375 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2376 rss_hash_key, "rss-hash-key");
2377 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2378 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2379 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2380 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2381 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2382 "ipv6-tcp-ex#ipv6-udp-ex#"
2383 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only");
2384 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2385 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2387 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2388 .f = cmd_config_rss_hash_key_parsed,
2390 .help_str = "port config <port_id> rss-hash-key "
2391 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2392 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2393 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2394 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only "
2395 "<string of hex digits (variable length, NIC dependent)>",
2397 (void *)&cmd_config_rss_hash_key_port,
2398 (void *)&cmd_config_rss_hash_key_config,
2399 (void *)&cmd_config_rss_hash_key_port_id,
2400 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2401 (void *)&cmd_config_rss_hash_key_rss_type,
2402 (void *)&cmd_config_rss_hash_key_value,
2407 /* *** configure port rxq/txq ring size *** */
2408 struct cmd_config_rxtx_ring_size {
2409 cmdline_fixed_string_t port;
2410 cmdline_fixed_string_t config;
2412 cmdline_fixed_string_t rxtxq;
2414 cmdline_fixed_string_t rsize;
2419 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2420 __attribute__((unused)) struct cmdline *cl,
2421 __attribute__((unused)) void *data)
2423 struct cmd_config_rxtx_ring_size *res = parsed_result;
2424 struct rte_port *port;
2427 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2430 if (res->portid == (portid_t)RTE_PORT_ALL) {
2431 printf("Invalid port id\n");
2435 port = &ports[res->portid];
2437 if (!strcmp(res->rxtxq, "rxq"))
2439 else if (!strcmp(res->rxtxq, "txq"))
2442 printf("Unknown parameter\n");
2446 if (isrx && rx_queue_id_is_invalid(res->qid))
2448 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2451 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2452 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2458 port->nb_rx_desc[res->qid] = res->size;
2460 port->nb_tx_desc[res->qid] = res->size;
2462 cmd_reconfig_device_queue(res->portid, 0, 1);
2465 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2466 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2468 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2469 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2471 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2472 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2474 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2475 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2477 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2478 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2480 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2481 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2482 rsize, "ring_size");
2483 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2484 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2487 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2488 .f = cmd_config_rxtx_ring_size_parsed,
2490 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2492 (void *)&cmd_config_rxtx_ring_size_port,
2493 (void *)&cmd_config_rxtx_ring_size_config,
2494 (void *)&cmd_config_rxtx_ring_size_portid,
2495 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2496 (void *)&cmd_config_rxtx_ring_size_qid,
2497 (void *)&cmd_config_rxtx_ring_size_rsize,
2498 (void *)&cmd_config_rxtx_ring_size_size,
2503 /* *** configure port rxq/txq start/stop *** */
2504 struct cmd_config_rxtx_queue {
2505 cmdline_fixed_string_t port;
2507 cmdline_fixed_string_t rxtxq;
2509 cmdline_fixed_string_t opname;
2513 cmd_config_rxtx_queue_parsed(void *parsed_result,
2514 __attribute__((unused)) struct cmdline *cl,
2515 __attribute__((unused)) void *data)
2517 struct cmd_config_rxtx_queue *res = parsed_result;
2522 if (test_done == 0) {
2523 printf("Please stop forwarding first\n");
2527 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2530 if (port_is_started(res->portid) != 1) {
2531 printf("Please start port %u first\n", res->portid);
2535 if (!strcmp(res->rxtxq, "rxq"))
2537 else if (!strcmp(res->rxtxq, "txq"))
2540 printf("Unknown parameter\n");
2544 if (isrx && rx_queue_id_is_invalid(res->qid))
2546 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2549 if (!strcmp(res->opname, "start"))
2551 else if (!strcmp(res->opname, "stop"))
2554 printf("Unknown parameter\n");
2558 if (isstart && isrx)
2559 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2560 else if (!isstart && isrx)
2561 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2562 else if (isstart && !isrx)
2563 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2565 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2567 if (ret == -ENOTSUP)
2568 printf("Function not supported in PMD driver\n");
2571 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2572 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2573 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2574 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2575 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2576 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2577 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2578 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2579 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2580 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2583 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2584 .f = cmd_config_rxtx_queue_parsed,
2586 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2588 (void *)&cmd_config_rxtx_queue_port,
2589 (void *)&cmd_config_rxtx_queue_portid,
2590 (void *)&cmd_config_rxtx_queue_rxtxq,
2591 (void *)&cmd_config_rxtx_queue_qid,
2592 (void *)&cmd_config_rxtx_queue_opname,
2597 /* *** configure port rxq/txq deferred start on/off *** */
2598 struct cmd_config_deferred_start_rxtx_queue {
2599 cmdline_fixed_string_t port;
2601 cmdline_fixed_string_t rxtxq;
2603 cmdline_fixed_string_t opname;
2604 cmdline_fixed_string_t state;
2608 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2609 __attribute__((unused)) struct cmdline *cl,
2610 __attribute__((unused)) void *data)
2612 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2613 struct rte_port *port;
2616 uint8_t needreconfig = 0;
2618 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2621 if (port_is_started(res->port_id) != 0) {
2622 printf("Please stop port %u first\n", res->port_id);
2626 port = &ports[res->port_id];
2628 isrx = !strcmp(res->rxtxq, "rxq");
2630 if (isrx && rx_queue_id_is_invalid(res->qid))
2632 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2635 ison = !strcmp(res->state, "on");
2637 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2638 port->rx_conf[res->qid].rx_deferred_start = ison;
2640 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2641 port->tx_conf[res->qid].tx_deferred_start = ison;
2646 cmd_reconfig_device_queue(res->port_id, 0, 1);
2649 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2650 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2652 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2653 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2655 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2656 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2658 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2659 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2661 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2662 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2663 opname, "deferred_start");
2664 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2665 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2668 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2669 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2671 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2673 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2674 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2675 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2676 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2677 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2678 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2683 /* *** configure port rxq/txq setup *** */
2684 struct cmd_setup_rxtx_queue {
2685 cmdline_fixed_string_t port;
2687 cmdline_fixed_string_t rxtxq;
2689 cmdline_fixed_string_t setup;
2692 /* Common CLI fields for queue setup */
2693 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2694 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2695 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2696 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2697 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2698 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2699 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2700 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2701 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2702 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2705 cmd_setup_rxtx_queue_parsed(
2706 void *parsed_result,
2707 __attribute__((unused)) struct cmdline *cl,
2708 __attribute__((unused)) void *data)
2710 struct cmd_setup_rxtx_queue *res = parsed_result;
2711 struct rte_port *port;
2712 struct rte_mempool *mp;
2713 unsigned int socket_id;
2717 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2720 if (res->portid == (portid_t)RTE_PORT_ALL) {
2721 printf("Invalid port id\n");
2725 if (!strcmp(res->rxtxq, "rxq"))
2727 else if (!strcmp(res->rxtxq, "txq"))
2730 printf("Unknown parameter\n");
2734 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2735 printf("Invalid rx queue\n");
2737 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2738 printf("Invalid tx queue\n");
2742 port = &ports[res->portid];
2744 socket_id = rxring_numa[res->portid];
2745 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2746 socket_id = port->socket_id;
2748 mp = mbuf_pool_find(socket_id);
2750 printf("Failed to setup RX queue: "
2751 "No mempool allocation"
2752 " on the socket %d\n",
2753 rxring_numa[res->portid]);
2756 ret = rte_eth_rx_queue_setup(res->portid,
2758 port->nb_rx_desc[res->qid],
2760 &port->rx_conf[res->qid],
2763 printf("Failed to setup RX queue\n");
2765 socket_id = txring_numa[res->portid];
2766 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2767 socket_id = port->socket_id;
2769 ret = rte_eth_tx_queue_setup(res->portid,
2771 port->nb_tx_desc[res->qid],
2773 &port->tx_conf[res->qid]);
2775 printf("Failed to setup TX queue\n");
2779 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2780 .f = cmd_setup_rxtx_queue_parsed,
2782 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2784 (void *)&cmd_setup_rxtx_queue_port,
2785 (void *)&cmd_setup_rxtx_queue_portid,
2786 (void *)&cmd_setup_rxtx_queue_rxtxq,
2787 (void *)&cmd_setup_rxtx_queue_qid,
2788 (void *)&cmd_setup_rxtx_queue_setup,
2794 /* *** Configure RSS RETA *** */
2795 struct cmd_config_rss_reta {
2796 cmdline_fixed_string_t port;
2797 cmdline_fixed_string_t keyword;
2799 cmdline_fixed_string_t name;
2800 cmdline_fixed_string_t list_name;
2801 cmdline_fixed_string_t list_of_items;
2805 parse_reta_config(const char *str,
2806 struct rte_eth_rss_reta_entry64 *reta_conf,
2807 uint16_t nb_entries)
2811 uint16_t hash_index, idx, shift;
2814 const char *p, *p0 = str;
2821 unsigned long int_fld[_NUM_FLD];
2822 char *str_fld[_NUM_FLD];
2824 while ((p = strchr(p0,'(')) != NULL) {
2826 if((p0 = strchr(p,')')) == NULL)
2830 if(size >= sizeof(s))
2833 snprintf(s, sizeof(s), "%.*s", size, p);
2834 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2836 for (i = 0; i < _NUM_FLD; i++) {
2838 int_fld[i] = strtoul(str_fld[i], &end, 0);
2839 if (errno != 0 || end == str_fld[i] ||
2844 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2845 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2847 if (hash_index >= nb_entries) {
2848 printf("Invalid RETA hash index=%d\n", hash_index);
2852 idx = hash_index / RTE_RETA_GROUP_SIZE;
2853 shift = hash_index % RTE_RETA_GROUP_SIZE;
2854 reta_conf[idx].mask |= (1ULL << shift);
2855 reta_conf[idx].reta[shift] = nb_queue;
2862 cmd_set_rss_reta_parsed(void *parsed_result,
2863 __attribute__((unused)) struct cmdline *cl,
2864 __attribute__((unused)) void *data)
2867 struct rte_eth_dev_info dev_info;
2868 struct rte_eth_rss_reta_entry64 reta_conf[8];
2869 struct cmd_config_rss_reta *res = parsed_result;
2871 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2875 if (dev_info.reta_size == 0) {
2876 printf("Redirection table size is 0 which is "
2877 "invalid for RSS\n");
2880 printf("The reta size of port %d is %u\n",
2881 res->port_id, dev_info.reta_size);
2882 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2883 printf("Currently do not support more than %u entries of "
2884 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2888 memset(reta_conf, 0, sizeof(reta_conf));
2889 if (!strcmp(res->list_name, "reta")) {
2890 if (parse_reta_config(res->list_of_items, reta_conf,
2891 dev_info.reta_size)) {
2892 printf("Invalid RSS Redirection Table "
2893 "config entered\n");
2896 ret = rte_eth_dev_rss_reta_update(res->port_id,
2897 reta_conf, dev_info.reta_size);
2899 printf("Bad redirection table parameter, "
2900 "return code = %d \n", ret);
2904 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2905 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2906 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2907 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2908 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2909 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2910 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2911 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2912 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2913 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2914 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2915 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2917 cmdline_parse_inst_t cmd_config_rss_reta = {
2918 .f = cmd_set_rss_reta_parsed,
2920 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2922 (void *)&cmd_config_rss_reta_port,
2923 (void *)&cmd_config_rss_reta_keyword,
2924 (void *)&cmd_config_rss_reta_port_id,
2925 (void *)&cmd_config_rss_reta_name,
2926 (void *)&cmd_config_rss_reta_list_name,
2927 (void *)&cmd_config_rss_reta_list_of_items,
2932 /* *** SHOW PORT RETA INFO *** */
2933 struct cmd_showport_reta {
2934 cmdline_fixed_string_t show;
2935 cmdline_fixed_string_t port;
2937 cmdline_fixed_string_t rss;
2938 cmdline_fixed_string_t reta;
2940 cmdline_fixed_string_t list_of_items;
2944 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2945 uint16_t nb_entries,
2949 const char *p, *p0 = str;
2954 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2955 RTE_RETA_GROUP_SIZE;
2958 p = strchr(p0, '(');
2962 p0 = strchr(p, ')');
2966 if (size >= sizeof(s)) {
2967 printf("The string size exceeds the internal buffer size\n");
2970 snprintf(s, sizeof(s), "%.*s", size, p);
2971 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2972 if (ret <= 0 || ret != num) {
2973 printf("The bits of masks do not match the number of "
2974 "reta entries: %u\n", num);
2977 for (i = 0; i < ret; i++)
2978 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2984 cmd_showport_reta_parsed(void *parsed_result,
2985 __attribute__((unused)) struct cmdline *cl,
2986 __attribute__((unused)) void *data)
2988 struct cmd_showport_reta *res = parsed_result;
2989 struct rte_eth_rss_reta_entry64 reta_conf[8];
2990 struct rte_eth_dev_info dev_info;
2991 uint16_t max_reta_size;
2994 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2998 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2999 if (res->size == 0 || res->size > max_reta_size) {
3000 printf("Invalid redirection table size: %u (1-%u)\n",
3001 res->size, max_reta_size);
3005 memset(reta_conf, 0, sizeof(reta_conf));
3006 if (showport_parse_reta_config(reta_conf, res->size,
3007 res->list_of_items) < 0) {
3008 printf("Invalid string: %s for reta masks\n",
3009 res->list_of_items);
3012 port_rss_reta_info(res->port_id, reta_conf, res->size);
3015 cmdline_parse_token_string_t cmd_showport_reta_show =
3016 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3017 cmdline_parse_token_string_t cmd_showport_reta_port =
3018 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3019 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3020 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3021 cmdline_parse_token_string_t cmd_showport_reta_rss =
3022 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3023 cmdline_parse_token_string_t cmd_showport_reta_reta =
3024 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3025 cmdline_parse_token_num_t cmd_showport_reta_size =
3026 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3027 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3028 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3029 list_of_items, NULL);
3031 cmdline_parse_inst_t cmd_showport_reta = {
3032 .f = cmd_showport_reta_parsed,
3034 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3036 (void *)&cmd_showport_reta_show,
3037 (void *)&cmd_showport_reta_port,
3038 (void *)&cmd_showport_reta_port_id,
3039 (void *)&cmd_showport_reta_rss,
3040 (void *)&cmd_showport_reta_reta,
3041 (void *)&cmd_showport_reta_size,
3042 (void *)&cmd_showport_reta_list_of_items,
3047 /* *** Show RSS hash configuration *** */
3048 struct cmd_showport_rss_hash {
3049 cmdline_fixed_string_t show;
3050 cmdline_fixed_string_t port;
3052 cmdline_fixed_string_t rss_hash;
3053 cmdline_fixed_string_t rss_type;
3054 cmdline_fixed_string_t key; /* optional argument */
3057 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3058 __attribute__((unused)) struct cmdline *cl,
3061 struct cmd_showport_rss_hash *res = parsed_result;
3063 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3066 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3067 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3068 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3069 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3070 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3071 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3072 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3073 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3075 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3076 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3078 cmdline_parse_inst_t cmd_showport_rss_hash = {
3079 .f = cmd_showport_rss_hash_parsed,
3081 .help_str = "show port <port_id> rss-hash",
3083 (void *)&cmd_showport_rss_hash_show,
3084 (void *)&cmd_showport_rss_hash_port,
3085 (void *)&cmd_showport_rss_hash_port_id,
3086 (void *)&cmd_showport_rss_hash_rss_hash,
3091 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3092 .f = cmd_showport_rss_hash_parsed,
3094 .help_str = "show port <port_id> rss-hash key",
3096 (void *)&cmd_showport_rss_hash_show,
3097 (void *)&cmd_showport_rss_hash_port,
3098 (void *)&cmd_showport_rss_hash_port_id,
3099 (void *)&cmd_showport_rss_hash_rss_hash,
3100 (void *)&cmd_showport_rss_hash_rss_key,
3105 /* *** Configure DCB *** */
3106 struct cmd_config_dcb {
3107 cmdline_fixed_string_t port;
3108 cmdline_fixed_string_t config;
3110 cmdline_fixed_string_t dcb;
3111 cmdline_fixed_string_t vt;
3112 cmdline_fixed_string_t vt_en;
3114 cmdline_fixed_string_t pfc;
3115 cmdline_fixed_string_t pfc_en;
3119 cmd_config_dcb_parsed(void *parsed_result,
3120 __attribute__((unused)) struct cmdline *cl,
3121 __attribute__((unused)) void *data)
3123 struct cmd_config_dcb *res = parsed_result;
3124 portid_t port_id = res->port_id;
3125 struct rte_port *port;
3129 port = &ports[port_id];
3130 /** Check if the port is not started **/
3131 if (port->port_status != RTE_PORT_STOPPED) {
3132 printf("Please stop port %d first\n", port_id);
3136 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3137 printf("The invalid number of traffic class,"
3138 " only 4 or 8 allowed.\n");
3142 if (nb_fwd_lcores < res->num_tcs) {
3143 printf("nb_cores shouldn't be less than number of TCs.\n");
3146 if (!strncmp(res->pfc_en, "on", 2))
3151 /* DCB in VT mode */
3152 if (!strncmp(res->vt_en, "on", 2))
3153 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3154 (enum rte_eth_nb_tcs)res->num_tcs,
3157 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3158 (enum rte_eth_nb_tcs)res->num_tcs,
3163 printf("Cannot initialize network ports.\n");
3167 cmd_reconfig_device_queue(port_id, 1, 1);
3170 cmdline_parse_token_string_t cmd_config_dcb_port =
3171 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3172 cmdline_parse_token_string_t cmd_config_dcb_config =
3173 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3174 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3175 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3176 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3177 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3178 cmdline_parse_token_string_t cmd_config_dcb_vt =
3179 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3180 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3181 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3182 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3183 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3184 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3185 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3186 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3187 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3189 cmdline_parse_inst_t cmd_config_dcb = {
3190 .f = cmd_config_dcb_parsed,
3192 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3194 (void *)&cmd_config_dcb_port,
3195 (void *)&cmd_config_dcb_config,
3196 (void *)&cmd_config_dcb_port_id,
3197 (void *)&cmd_config_dcb_dcb,
3198 (void *)&cmd_config_dcb_vt,
3199 (void *)&cmd_config_dcb_vt_en,
3200 (void *)&cmd_config_dcb_num_tcs,
3201 (void *)&cmd_config_dcb_pfc,
3202 (void *)&cmd_config_dcb_pfc_en,
3207 /* *** configure number of packets per burst *** */
3208 struct cmd_config_burst {
3209 cmdline_fixed_string_t port;
3210 cmdline_fixed_string_t keyword;
3211 cmdline_fixed_string_t all;
3212 cmdline_fixed_string_t name;
3217 cmd_config_burst_parsed(void *parsed_result,
3218 __attribute__((unused)) struct cmdline *cl,
3219 __attribute__((unused)) void *data)
3221 struct cmd_config_burst *res = parsed_result;
3222 struct rte_eth_dev_info dev_info;
3223 uint16_t rec_nb_pkts;
3226 if (!all_ports_stopped()) {
3227 printf("Please stop all ports first\n");
3231 if (!strcmp(res->name, "burst")) {
3232 if (res->value == 0) {
3233 /* If user gives a value of zero, query the PMD for
3234 * its recommended Rx burst size. Testpmd uses a single
3235 * size for all ports, so assume all ports are the same
3236 * NIC model and use the values from Port 0.
3238 ret = eth_dev_info_get_print_err(0, &dev_info);
3242 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3244 if (rec_nb_pkts == 0) {
3245 printf("PMD does not recommend a burst size.\n"
3246 "User provided value must be between"
3247 " 1 and %d\n", MAX_PKT_BURST);
3249 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3250 printf("PMD recommended burst size of %d"
3251 " exceeds maximum value of %d\n",
3252 rec_nb_pkts, MAX_PKT_BURST);
3255 printf("Using PMD-provided burst value of %d\n",
3257 nb_pkt_per_burst = rec_nb_pkts;
3258 } else if (res->value > MAX_PKT_BURST) {
3259 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3262 nb_pkt_per_burst = res->value;
3264 printf("Unknown parameter\n");
3270 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3273 cmdline_parse_token_string_t cmd_config_burst_port =
3274 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3275 cmdline_parse_token_string_t cmd_config_burst_keyword =
3276 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3277 cmdline_parse_token_string_t cmd_config_burst_all =
3278 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3279 cmdline_parse_token_string_t cmd_config_burst_name =
3280 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3281 cmdline_parse_token_num_t cmd_config_burst_value =
3282 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3284 cmdline_parse_inst_t cmd_config_burst = {
3285 .f = cmd_config_burst_parsed,
3287 .help_str = "port config all burst <value>",
3289 (void *)&cmd_config_burst_port,
3290 (void *)&cmd_config_burst_keyword,
3291 (void *)&cmd_config_burst_all,
3292 (void *)&cmd_config_burst_name,
3293 (void *)&cmd_config_burst_value,
3298 /* *** configure rx/tx queues *** */
3299 struct cmd_config_thresh {
3300 cmdline_fixed_string_t port;
3301 cmdline_fixed_string_t keyword;
3302 cmdline_fixed_string_t all;
3303 cmdline_fixed_string_t name;
3308 cmd_config_thresh_parsed(void *parsed_result,
3309 __attribute__((unused)) struct cmdline *cl,
3310 __attribute__((unused)) void *data)
3312 struct cmd_config_thresh *res = parsed_result;
3314 if (!all_ports_stopped()) {
3315 printf("Please stop all ports first\n");
3319 if (!strcmp(res->name, "txpt"))
3320 tx_pthresh = res->value;
3321 else if(!strcmp(res->name, "txht"))
3322 tx_hthresh = res->value;
3323 else if(!strcmp(res->name, "txwt"))
3324 tx_wthresh = res->value;
3325 else if(!strcmp(res->name, "rxpt"))
3326 rx_pthresh = res->value;
3327 else if(!strcmp(res->name, "rxht"))
3328 rx_hthresh = res->value;
3329 else if(!strcmp(res->name, "rxwt"))
3330 rx_wthresh = res->value;
3332 printf("Unknown parameter\n");
3338 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3341 cmdline_parse_token_string_t cmd_config_thresh_port =
3342 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3343 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3344 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3345 cmdline_parse_token_string_t cmd_config_thresh_all =
3346 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3347 cmdline_parse_token_string_t cmd_config_thresh_name =
3348 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3349 "txpt#txht#txwt#rxpt#rxht#rxwt");
3350 cmdline_parse_token_num_t cmd_config_thresh_value =
3351 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3353 cmdline_parse_inst_t cmd_config_thresh = {
3354 .f = cmd_config_thresh_parsed,
3356 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3358 (void *)&cmd_config_thresh_port,
3359 (void *)&cmd_config_thresh_keyword,
3360 (void *)&cmd_config_thresh_all,
3361 (void *)&cmd_config_thresh_name,
3362 (void *)&cmd_config_thresh_value,
3367 /* *** configure free/rs threshold *** */
3368 struct cmd_config_threshold {
3369 cmdline_fixed_string_t port;
3370 cmdline_fixed_string_t keyword;
3371 cmdline_fixed_string_t all;
3372 cmdline_fixed_string_t name;
3377 cmd_config_threshold_parsed(void *parsed_result,
3378 __attribute__((unused)) struct cmdline *cl,
3379 __attribute__((unused)) void *data)
3381 struct cmd_config_threshold *res = parsed_result;
3383 if (!all_ports_stopped()) {
3384 printf("Please stop all ports first\n");
3388 if (!strcmp(res->name, "txfreet"))
3389 tx_free_thresh = res->value;
3390 else if (!strcmp(res->name, "txrst"))
3391 tx_rs_thresh = res->value;
3392 else if (!strcmp(res->name, "rxfreet"))
3393 rx_free_thresh = res->value;
3395 printf("Unknown parameter\n");
3401 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3404 cmdline_parse_token_string_t cmd_config_threshold_port =
3405 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3406 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3407 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3409 cmdline_parse_token_string_t cmd_config_threshold_all =
3410 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3411 cmdline_parse_token_string_t cmd_config_threshold_name =
3412 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3413 "txfreet#txrst#rxfreet");
3414 cmdline_parse_token_num_t cmd_config_threshold_value =
3415 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3417 cmdline_parse_inst_t cmd_config_threshold = {
3418 .f = cmd_config_threshold_parsed,
3420 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3422 (void *)&cmd_config_threshold_port,
3423 (void *)&cmd_config_threshold_keyword,
3424 (void *)&cmd_config_threshold_all,
3425 (void *)&cmd_config_threshold_name,
3426 (void *)&cmd_config_threshold_value,
3432 struct cmd_stop_result {
3433 cmdline_fixed_string_t stop;
3436 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3437 __attribute__((unused)) struct cmdline *cl,
3438 __attribute__((unused)) void *data)
3440 stop_packet_forwarding();
3443 cmdline_parse_token_string_t cmd_stop_stop =
3444 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3446 cmdline_parse_inst_t cmd_stop = {
3447 .f = cmd_stop_parsed,
3449 .help_str = "stop: Stop packet forwarding",
3451 (void *)&cmd_stop_stop,
3456 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3459 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3460 unsigned int *parsed_items, int check_unique_values)
3462 unsigned int nb_item;
3470 * First parse all items in the list and store their value.
3475 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3477 if ((c >= '0') && (c <= '9')) {
3478 value = (unsigned int) (value * 10 + (c - '0'));
3483 printf("character %c is not a decimal digit\n", c);
3487 printf("No valid value before comma\n");
3490 if (nb_item < max_items) {
3491 parsed_items[nb_item] = value;
3497 if (nb_item >= max_items) {
3498 printf("Number of %s = %u > %u (maximum items)\n",
3499 item_name, nb_item + 1, max_items);
3502 parsed_items[nb_item++] = value;
3503 if (! check_unique_values)
3507 * Then, check that all values in the list are differents.
3508 * No optimization here...
3510 for (i = 0; i < nb_item; i++) {
3511 for (j = i + 1; j < nb_item; j++) {
3512 if (parsed_items[j] == parsed_items[i]) {
3513 printf("duplicated %s %u at index %u and %u\n",
3514 item_name, parsed_items[i], i, j);
3522 struct cmd_set_list_result {
3523 cmdline_fixed_string_t cmd_keyword;
3524 cmdline_fixed_string_t list_name;
3525 cmdline_fixed_string_t list_of_items;
3528 static void cmd_set_list_parsed(void *parsed_result,
3529 __attribute__((unused)) struct cmdline *cl,
3530 __attribute__((unused)) void *data)
3532 struct cmd_set_list_result *res;
3534 unsigned int lcorelist[RTE_MAX_LCORE];
3535 unsigned int portlist[RTE_MAX_ETHPORTS];
3537 unsigned int nb_item;
3539 if (test_done == 0) {
3540 printf("Please stop forwarding first\n");
3544 res = parsed_result;
3545 if (!strcmp(res->list_name, "corelist")) {
3546 nb_item = parse_item_list(res->list_of_items, "core",
3548 parsed_items.lcorelist, 1);
3550 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3555 if (!strcmp(res->list_name, "portlist")) {
3556 nb_item = parse_item_list(res->list_of_items, "port",
3558 parsed_items.portlist, 1);
3560 set_fwd_ports_list(parsed_items.portlist, nb_item);
3566 cmdline_parse_token_string_t cmd_set_list_keyword =
3567 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3569 cmdline_parse_token_string_t cmd_set_list_name =
3570 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3571 "corelist#portlist");
3572 cmdline_parse_token_string_t cmd_set_list_of_items =
3573 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3576 cmdline_parse_inst_t cmd_set_fwd_list = {
3577 .f = cmd_set_list_parsed,
3579 .help_str = "set corelist|portlist <list0[,list1]*>",
3581 (void *)&cmd_set_list_keyword,
3582 (void *)&cmd_set_list_name,
3583 (void *)&cmd_set_list_of_items,
3588 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3590 struct cmd_setmask_result {
3591 cmdline_fixed_string_t set;
3592 cmdline_fixed_string_t mask;
3596 static void cmd_set_mask_parsed(void *parsed_result,
3597 __attribute__((unused)) struct cmdline *cl,
3598 __attribute__((unused)) void *data)
3600 struct cmd_setmask_result *res = parsed_result;
3602 if (test_done == 0) {
3603 printf("Please stop forwarding first\n");
3606 if (!strcmp(res->mask, "coremask")) {
3607 set_fwd_lcores_mask(res->hexavalue);
3609 } else if (!strcmp(res->mask, "portmask")) {
3610 set_fwd_ports_mask(res->hexavalue);
3615 cmdline_parse_token_string_t cmd_setmask_set =
3616 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3617 cmdline_parse_token_string_t cmd_setmask_mask =
3618 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3619 "coremask#portmask");
3620 cmdline_parse_token_num_t cmd_setmask_value =
3621 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3623 cmdline_parse_inst_t cmd_set_fwd_mask = {
3624 .f = cmd_set_mask_parsed,
3626 .help_str = "set coremask|portmask <hexadecimal value>",
3628 (void *)&cmd_setmask_set,
3629 (void *)&cmd_setmask_mask,
3630 (void *)&cmd_setmask_value,
3636 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3638 struct cmd_set_result {
3639 cmdline_fixed_string_t set;
3640 cmdline_fixed_string_t what;
3644 static void cmd_set_parsed(void *parsed_result,
3645 __attribute__((unused)) struct cmdline *cl,
3646 __attribute__((unused)) void *data)
3648 struct cmd_set_result *res = parsed_result;
3649 if (!strcmp(res->what, "nbport")) {
3650 set_fwd_ports_number(res->value);
3652 } else if (!strcmp(res->what, "nbcore")) {
3653 set_fwd_lcores_number(res->value);
3655 } else if (!strcmp(res->what, "burst"))
3656 set_nb_pkt_per_burst(res->value);
3657 else if (!strcmp(res->what, "verbose"))
3658 set_verbose_level(res->value);
3661 cmdline_parse_token_string_t cmd_set_set =
3662 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3663 cmdline_parse_token_string_t cmd_set_what =
3664 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3665 "nbport#nbcore#burst#verbose");
3666 cmdline_parse_token_num_t cmd_set_value =
3667 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3669 cmdline_parse_inst_t cmd_set_numbers = {
3670 .f = cmd_set_parsed,
3672 .help_str = "set nbport|nbcore|burst|verbose <value>",
3674 (void *)&cmd_set_set,
3675 (void *)&cmd_set_what,
3676 (void *)&cmd_set_value,
3681 /* *** SET LOG LEVEL CONFIGURATION *** */
3683 struct cmd_set_log_result {
3684 cmdline_fixed_string_t set;
3685 cmdline_fixed_string_t log;
3686 cmdline_fixed_string_t type;
3691 cmd_set_log_parsed(void *parsed_result,
3692 __attribute__((unused)) struct cmdline *cl,
3693 __attribute__((unused)) void *data)
3695 struct cmd_set_log_result *res;
3698 res = parsed_result;
3699 if (!strcmp(res->type, "global"))
3700 rte_log_set_global_level(res->level);
3702 ret = rte_log_set_level_regexp(res->type, res->level);
3704 printf("Unable to set log level\n");
3708 cmdline_parse_token_string_t cmd_set_log_set =
3709 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3710 cmdline_parse_token_string_t cmd_set_log_log =
3711 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3712 cmdline_parse_token_string_t cmd_set_log_type =
3713 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3714 cmdline_parse_token_num_t cmd_set_log_level =
3715 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3717 cmdline_parse_inst_t cmd_set_log = {
3718 .f = cmd_set_log_parsed,
3720 .help_str = "set log global|<type> <level>",
3722 (void *)&cmd_set_log_set,
3723 (void *)&cmd_set_log_log,
3724 (void *)&cmd_set_log_type,
3725 (void *)&cmd_set_log_level,
3730 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3732 struct cmd_set_txpkts_result {
3733 cmdline_fixed_string_t cmd_keyword;
3734 cmdline_fixed_string_t txpkts;
3735 cmdline_fixed_string_t seg_lengths;
3739 cmd_set_txpkts_parsed(void *parsed_result,
3740 __attribute__((unused)) struct cmdline *cl,
3741 __attribute__((unused)) void *data)
3743 struct cmd_set_txpkts_result *res;
3744 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3745 unsigned int nb_segs;
3747 res = parsed_result;
3748 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3749 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3751 set_tx_pkt_segments(seg_lengths, nb_segs);
3754 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3755 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3756 cmd_keyword, "set");
3757 cmdline_parse_token_string_t cmd_set_txpkts_name =
3758 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3760 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3761 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3764 cmdline_parse_inst_t cmd_set_txpkts = {
3765 .f = cmd_set_txpkts_parsed,
3767 .help_str = "set txpkts <len0[,len1]*>",
3769 (void *)&cmd_set_txpkts_keyword,
3770 (void *)&cmd_set_txpkts_name,
3771 (void *)&cmd_set_txpkts_lengths,
3776 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3778 struct cmd_set_txsplit_result {
3779 cmdline_fixed_string_t cmd_keyword;
3780 cmdline_fixed_string_t txsplit;
3781 cmdline_fixed_string_t mode;
3785 cmd_set_txsplit_parsed(void *parsed_result,
3786 __attribute__((unused)) struct cmdline *cl,
3787 __attribute__((unused)) void *data)
3789 struct cmd_set_txsplit_result *res;
3791 res = parsed_result;
3792 set_tx_pkt_split(res->mode);
3795 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3796 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3797 cmd_keyword, "set");
3798 cmdline_parse_token_string_t cmd_set_txsplit_name =
3799 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3800 txsplit, "txsplit");
3801 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3802 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3805 cmdline_parse_inst_t cmd_set_txsplit = {
3806 .f = cmd_set_txsplit_parsed,
3808 .help_str = "set txsplit on|off|rand",
3810 (void *)&cmd_set_txsplit_keyword,
3811 (void *)&cmd_set_txsplit_name,
3812 (void *)&cmd_set_txsplit_mode,
3817 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3818 struct cmd_rx_vlan_filter_all_result {
3819 cmdline_fixed_string_t rx_vlan;
3820 cmdline_fixed_string_t what;
3821 cmdline_fixed_string_t all;
3826 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3827 __attribute__((unused)) struct cmdline *cl,
3828 __attribute__((unused)) void *data)
3830 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3832 if (!strcmp(res->what, "add"))
3833 rx_vlan_all_filter_set(res->port_id, 1);
3835 rx_vlan_all_filter_set(res->port_id, 0);
3838 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3839 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3840 rx_vlan, "rx_vlan");
3841 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3842 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3844 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3845 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3847 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3848 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3851 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3852 .f = cmd_rx_vlan_filter_all_parsed,
3854 .help_str = "rx_vlan add|rm all <port_id>: "
3855 "Add/Remove all identifiers to/from the set of VLAN "
3856 "identifiers filtered by a port",
3858 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3859 (void *)&cmd_rx_vlan_filter_all_what,
3860 (void *)&cmd_rx_vlan_filter_all_all,
3861 (void *)&cmd_rx_vlan_filter_all_portid,
3866 /* *** VLAN OFFLOAD SET ON A PORT *** */
3867 struct cmd_vlan_offload_result {
3868 cmdline_fixed_string_t vlan;
3869 cmdline_fixed_string_t set;
3870 cmdline_fixed_string_t vlan_type;
3871 cmdline_fixed_string_t what;
3872 cmdline_fixed_string_t on;
3873 cmdline_fixed_string_t port_id;
3877 cmd_vlan_offload_parsed(void *parsed_result,
3878 __attribute__((unused)) struct cmdline *cl,
3879 __attribute__((unused)) void *data)
3882 struct cmd_vlan_offload_result *res = parsed_result;
3885 portid_t port_id = 0;
3889 len = strnlen(str, STR_TOKEN_SIZE);
3891 /* Get port_id first */
3899 tmp = strtoul(str, NULL, 0);
3900 /* If port_id greater that what portid_t can represent, return */
3901 if(tmp >= RTE_MAX_ETHPORTS)
3903 port_id = (portid_t)tmp;
3905 if (!strcmp(res->on, "on"))
3910 if (!strcmp(res->what, "strip"))
3911 rx_vlan_strip_set(port_id, on);
3912 else if(!strcmp(res->what, "stripq")){
3913 uint16_t queue_id = 0;
3915 /* No queue_id, return */
3917 printf("must specify (port,queue_id)\n");
3920 tmp = strtoul(str + i + 1, NULL, 0);
3921 /* If queue_id greater that what 16-bits can represent, return */
3925 queue_id = (uint16_t)tmp;
3926 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3928 else if (!strcmp(res->what, "filter"))
3929 rx_vlan_filter_set(port_id, on);
3930 else if (!strcmp(res->what, "qinq_strip"))
3931 rx_vlan_qinq_strip_set(port_id, on);
3933 vlan_extend_set(port_id, on);
3938 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3939 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3941 cmdline_parse_token_string_t cmd_vlan_offload_set =
3942 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3944 cmdline_parse_token_string_t cmd_vlan_offload_what =
3945 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3946 what, "strip#filter#qinq_strip#extend#stripq");
3947 cmdline_parse_token_string_t cmd_vlan_offload_on =
3948 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3950 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3951 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3954 cmdline_parse_inst_t cmd_vlan_offload = {
3955 .f = cmd_vlan_offload_parsed,
3957 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
3958 "<port_id[,queue_id]>: "
3959 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
3961 (void *)&cmd_vlan_offload_vlan,
3962 (void *)&cmd_vlan_offload_set,
3963 (void *)&cmd_vlan_offload_what,
3964 (void *)&cmd_vlan_offload_on,
3965 (void *)&cmd_vlan_offload_portid,
3970 /* *** VLAN TPID SET ON A PORT *** */
3971 struct cmd_vlan_tpid_result {
3972 cmdline_fixed_string_t vlan;
3973 cmdline_fixed_string_t set;
3974 cmdline_fixed_string_t vlan_type;
3975 cmdline_fixed_string_t what;
3981 cmd_vlan_tpid_parsed(void *parsed_result,
3982 __attribute__((unused)) struct cmdline *cl,
3983 __attribute__((unused)) void *data)
3985 struct cmd_vlan_tpid_result *res = parsed_result;
3986 enum rte_vlan_type vlan_type;
3988 if (!strcmp(res->vlan_type, "inner"))
3989 vlan_type = ETH_VLAN_TYPE_INNER;
3990 else if (!strcmp(res->vlan_type, "outer"))
3991 vlan_type = ETH_VLAN_TYPE_OUTER;
3993 printf("Unknown vlan type\n");
3996 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3999 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4000 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4002 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4003 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4005 cmdline_parse_token_string_t cmd_vlan_type =
4006 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4007 vlan_type, "inner#outer");
4008 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4009 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4011 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4012 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4014 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4015 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4018 cmdline_parse_inst_t cmd_vlan_tpid = {
4019 .f = cmd_vlan_tpid_parsed,
4021 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4022 "Set the VLAN Ether type",
4024 (void *)&cmd_vlan_tpid_vlan,
4025 (void *)&cmd_vlan_tpid_set,
4026 (void *)&cmd_vlan_type,
4027 (void *)&cmd_vlan_tpid_what,
4028 (void *)&cmd_vlan_tpid_tpid,
4029 (void *)&cmd_vlan_tpid_portid,
4034 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4035 struct cmd_rx_vlan_filter_result {
4036 cmdline_fixed_string_t rx_vlan;
4037 cmdline_fixed_string_t what;
4043 cmd_rx_vlan_filter_parsed(void *parsed_result,
4044 __attribute__((unused)) struct cmdline *cl,
4045 __attribute__((unused)) void *data)
4047 struct cmd_rx_vlan_filter_result *res = parsed_result;
4049 if (!strcmp(res->what, "add"))
4050 rx_vft_set(res->port_id, res->vlan_id, 1);
4052 rx_vft_set(res->port_id, res->vlan_id, 0);
4055 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4056 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4057 rx_vlan, "rx_vlan");
4058 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4059 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4061 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4062 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4064 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4065 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4068 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4069 .f = cmd_rx_vlan_filter_parsed,
4071 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4072 "Add/Remove a VLAN identifier to/from the set of VLAN "
4073 "identifiers filtered by a port",
4075 (void *)&cmd_rx_vlan_filter_rx_vlan,
4076 (void *)&cmd_rx_vlan_filter_what,
4077 (void *)&cmd_rx_vlan_filter_vlanid,
4078 (void *)&cmd_rx_vlan_filter_portid,
4083 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4084 struct cmd_tx_vlan_set_result {
4085 cmdline_fixed_string_t tx_vlan;
4086 cmdline_fixed_string_t set;
4092 cmd_tx_vlan_set_parsed(void *parsed_result,
4093 __attribute__((unused)) struct cmdline *cl,
4094 __attribute__((unused)) void *data)
4096 struct cmd_tx_vlan_set_result *res = parsed_result;
4098 if (!port_is_stopped(res->port_id)) {
4099 printf("Please stop port %d first\n", res->port_id);
4103 tx_vlan_set(res->port_id, res->vlan_id);
4105 cmd_reconfig_device_queue(res->port_id, 1, 1);
4108 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4109 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4110 tx_vlan, "tx_vlan");
4111 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4112 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4114 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4115 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4117 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4118 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4121 cmdline_parse_inst_t cmd_tx_vlan_set = {
4122 .f = cmd_tx_vlan_set_parsed,
4124 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4125 "Enable hardware insertion of a single VLAN header "
4126 "with a given TAG Identifier in packets sent on a port",
4128 (void *)&cmd_tx_vlan_set_tx_vlan,
4129 (void *)&cmd_tx_vlan_set_set,
4130 (void *)&cmd_tx_vlan_set_portid,
4131 (void *)&cmd_tx_vlan_set_vlanid,
4136 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4137 struct cmd_tx_vlan_set_qinq_result {
4138 cmdline_fixed_string_t tx_vlan;
4139 cmdline_fixed_string_t set;
4142 uint16_t vlan_id_outer;
4146 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4147 __attribute__((unused)) struct cmdline *cl,
4148 __attribute__((unused)) void *data)
4150 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4152 if (!port_is_stopped(res->port_id)) {
4153 printf("Please stop port %d first\n", res->port_id);
4157 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4159 cmd_reconfig_device_queue(res->port_id, 1, 1);
4162 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4163 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4164 tx_vlan, "tx_vlan");
4165 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4166 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4168 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4169 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4171 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4172 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4174 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4175 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4176 vlan_id_outer, UINT16);
4178 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4179 .f = cmd_tx_vlan_set_qinq_parsed,
4181 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4182 "Enable hardware insertion of double VLAN header "
4183 "with given TAG Identifiers in packets sent on a port",
4185 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4186 (void *)&cmd_tx_vlan_set_qinq_set,
4187 (void *)&cmd_tx_vlan_set_qinq_portid,
4188 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4189 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4194 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4195 struct cmd_tx_vlan_set_pvid_result {
4196 cmdline_fixed_string_t tx_vlan;
4197 cmdline_fixed_string_t set;
4198 cmdline_fixed_string_t pvid;
4201 cmdline_fixed_string_t mode;
4205 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4206 __attribute__((unused)) struct cmdline *cl,
4207 __attribute__((unused)) void *data)
4209 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4211 if (strcmp(res->mode, "on") == 0)
4212 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4214 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4217 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4218 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4219 tx_vlan, "tx_vlan");
4220 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4221 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4223 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4224 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4226 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4227 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4229 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4230 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4232 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4233 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4236 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4237 .f = cmd_tx_vlan_set_pvid_parsed,
4239 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4241 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4242 (void *)&cmd_tx_vlan_set_pvid_set,
4243 (void *)&cmd_tx_vlan_set_pvid_pvid,
4244 (void *)&cmd_tx_vlan_set_pvid_port_id,
4245 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4246 (void *)&cmd_tx_vlan_set_pvid_mode,
4251 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4252 struct cmd_tx_vlan_reset_result {
4253 cmdline_fixed_string_t tx_vlan;
4254 cmdline_fixed_string_t reset;
4259 cmd_tx_vlan_reset_parsed(void *parsed_result,
4260 __attribute__((unused)) struct cmdline *cl,
4261 __attribute__((unused)) void *data)
4263 struct cmd_tx_vlan_reset_result *res = parsed_result;
4265 if (!port_is_stopped(res->port_id)) {
4266 printf("Please stop port %d first\n", res->port_id);
4270 tx_vlan_reset(res->port_id);
4272 cmd_reconfig_device_queue(res->port_id, 1, 1);
4275 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4276 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4277 tx_vlan, "tx_vlan");
4278 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4279 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4281 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4282 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4285 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4286 .f = cmd_tx_vlan_reset_parsed,
4288 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4289 "VLAN header in packets sent on a port",
4291 (void *)&cmd_tx_vlan_reset_tx_vlan,
4292 (void *)&cmd_tx_vlan_reset_reset,
4293 (void *)&cmd_tx_vlan_reset_portid,
4299 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4300 struct cmd_csum_result {
4301 cmdline_fixed_string_t csum;
4302 cmdline_fixed_string_t mode;
4303 cmdline_fixed_string_t proto;
4304 cmdline_fixed_string_t hwsw;
4309 csum_show(int port_id)
4311 struct rte_eth_dev_info dev_info;
4312 uint64_t tx_offloads;
4315 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4316 printf("Parse tunnel is %s\n",
4317 (ports[port_id].parse_tunnel) ? "on" : "off");
4318 printf("IP checksum offload is %s\n",
4319 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4320 printf("UDP checksum offload is %s\n",
4321 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4322 printf("TCP checksum offload is %s\n",
4323 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4324 printf("SCTP checksum offload is %s\n",
4325 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4326 printf("Outer-Ip checksum offload is %s\n",
4327 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4328 printf("Outer-Udp checksum offload is %s\n",
4329 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4331 /* display warnings if configuration is not supported by the NIC */
4332 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4336 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4337 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4338 printf("Warning: hardware IP checksum enabled but not "
4339 "supported by port %d\n", port_id);
4341 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4342 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4343 printf("Warning: hardware UDP checksum enabled but not "
4344 "supported by port %d\n", port_id);
4346 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4347 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4348 printf("Warning: hardware TCP checksum enabled but not "
4349 "supported by port %d\n", port_id);
4351 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4352 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4353 printf("Warning: hardware SCTP checksum enabled but not "
4354 "supported by port %d\n", port_id);
4356 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4357 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4358 printf("Warning: hardware outer IP checksum enabled but not "
4359 "supported by port %d\n", port_id);
4361 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4362 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4364 printf("Warning: hardware outer UDP checksum enabled but not "
4365 "supported by port %d\n", port_id);
4370 cmd_config_queue_tx_offloads(struct rte_port *port)
4374 /* Apply queue tx offloads configuration */
4375 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4376 port->tx_conf[k].offloads =
4377 port->dev_conf.txmode.offloads;
4381 cmd_csum_parsed(void *parsed_result,
4382 __attribute__((unused)) struct cmdline *cl,
4383 __attribute__((unused)) void *data)
4385 struct cmd_csum_result *res = parsed_result;
4387 uint64_t csum_offloads = 0;
4388 struct rte_eth_dev_info dev_info;
4391 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4392 printf("invalid port %d\n", res->port_id);
4395 if (!port_is_stopped(res->port_id)) {
4396 printf("Please stop port %d first\n", res->port_id);
4400 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4404 if (!strcmp(res->mode, "set")) {
4406 if (!strcmp(res->hwsw, "hw"))
4409 if (!strcmp(res->proto, "ip")) {
4410 if (hw == 0 || (dev_info.tx_offload_capa &
4411 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4412 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4414 printf("IP checksum offload is not supported "
4415 "by port %u\n", res->port_id);
4417 } else if (!strcmp(res->proto, "udp")) {
4418 if (hw == 0 || (dev_info.tx_offload_capa &
4419 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4420 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4422 printf("UDP checksum offload is not supported "
4423 "by port %u\n", res->port_id);
4425 } else if (!strcmp(res->proto, "tcp")) {
4426 if (hw == 0 || (dev_info.tx_offload_capa &
4427 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4428 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4430 printf("TCP checksum offload is not supported "
4431 "by port %u\n", res->port_id);
4433 } else if (!strcmp(res->proto, "sctp")) {
4434 if (hw == 0 || (dev_info.tx_offload_capa &
4435 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4436 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4438 printf("SCTP checksum offload is not supported "
4439 "by port %u\n", res->port_id);
4441 } else if (!strcmp(res->proto, "outer-ip")) {
4442 if (hw == 0 || (dev_info.tx_offload_capa &
4443 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4445 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4447 printf("Outer IP checksum offload is not "
4448 "supported by port %u\n", res->port_id);
4450 } else if (!strcmp(res->proto, "outer-udp")) {
4451 if (hw == 0 || (dev_info.tx_offload_capa &
4452 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4454 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4456 printf("Outer UDP checksum offload is not "
4457 "supported by port %u\n", res->port_id);
4462 ports[res->port_id].dev_conf.txmode.offloads |=
4465 ports[res->port_id].dev_conf.txmode.offloads &=
4468 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4470 csum_show(res->port_id);
4472 cmd_reconfig_device_queue(res->port_id, 1, 1);
4475 cmdline_parse_token_string_t cmd_csum_csum =
4476 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4478 cmdline_parse_token_string_t cmd_csum_mode =
4479 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4481 cmdline_parse_token_string_t cmd_csum_proto =
4482 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4483 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4484 cmdline_parse_token_string_t cmd_csum_hwsw =
4485 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4487 cmdline_parse_token_num_t cmd_csum_portid =
4488 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4491 cmdline_parse_inst_t cmd_csum_set = {
4492 .f = cmd_csum_parsed,
4494 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4495 "Enable/Disable hardware calculation of L3/L4 checksum when "
4496 "using csum forward engine",
4498 (void *)&cmd_csum_csum,
4499 (void *)&cmd_csum_mode,
4500 (void *)&cmd_csum_proto,
4501 (void *)&cmd_csum_hwsw,
4502 (void *)&cmd_csum_portid,
4507 cmdline_parse_token_string_t cmd_csum_mode_show =
4508 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4511 cmdline_parse_inst_t cmd_csum_show = {
4512 .f = cmd_csum_parsed,
4514 .help_str = "csum show <port_id>: Show checksum offload configuration",
4516 (void *)&cmd_csum_csum,
4517 (void *)&cmd_csum_mode_show,
4518 (void *)&cmd_csum_portid,
4523 /* Enable/disable tunnel parsing */
4524 struct cmd_csum_tunnel_result {
4525 cmdline_fixed_string_t csum;
4526 cmdline_fixed_string_t parse;
4527 cmdline_fixed_string_t onoff;
4532 cmd_csum_tunnel_parsed(void *parsed_result,
4533 __attribute__((unused)) struct cmdline *cl,
4534 __attribute__((unused)) void *data)
4536 struct cmd_csum_tunnel_result *res = parsed_result;
4538 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4541 if (!strcmp(res->onoff, "on"))
4542 ports[res->port_id].parse_tunnel = 1;
4544 ports[res->port_id].parse_tunnel = 0;
4546 csum_show(res->port_id);
4549 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4550 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4552 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4553 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4554 parse, "parse-tunnel");
4555 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4556 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4558 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4559 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4562 cmdline_parse_inst_t cmd_csum_tunnel = {
4563 .f = cmd_csum_tunnel_parsed,
4565 .help_str = "csum parse-tunnel on|off <port_id>: "
4566 "Enable/Disable parsing of tunnels for csum engine",
4568 (void *)&cmd_csum_tunnel_csum,
4569 (void *)&cmd_csum_tunnel_parse,
4570 (void *)&cmd_csum_tunnel_onoff,
4571 (void *)&cmd_csum_tunnel_portid,
4576 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4577 struct cmd_tso_set_result {
4578 cmdline_fixed_string_t tso;
4579 cmdline_fixed_string_t mode;
4585 cmd_tso_set_parsed(void *parsed_result,
4586 __attribute__((unused)) struct cmdline *cl,
4587 __attribute__((unused)) void *data)
4589 struct cmd_tso_set_result *res = parsed_result;
4590 struct rte_eth_dev_info dev_info;
4593 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4595 if (!port_is_stopped(res->port_id)) {
4596 printf("Please stop port %d first\n", res->port_id);
4600 if (!strcmp(res->mode, "set"))
4601 ports[res->port_id].tso_segsz = res->tso_segsz;
4603 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4607 if ((ports[res->port_id].tso_segsz != 0) &&
4608 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4609 printf("Error: TSO is not supported by port %d\n",
4614 if (ports[res->port_id].tso_segsz == 0) {
4615 ports[res->port_id].dev_conf.txmode.offloads &=
4616 ~DEV_TX_OFFLOAD_TCP_TSO;
4617 printf("TSO for non-tunneled packets is disabled\n");
4619 ports[res->port_id].dev_conf.txmode.offloads |=
4620 DEV_TX_OFFLOAD_TCP_TSO;
4621 printf("TSO segment size for non-tunneled packets is %d\n",
4622 ports[res->port_id].tso_segsz);
4624 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4626 /* display warnings if configuration is not supported by the NIC */
4627 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4631 if ((ports[res->port_id].tso_segsz != 0) &&
4632 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4633 printf("Warning: TSO enabled but not "
4634 "supported by port %d\n", res->port_id);
4637 cmd_reconfig_device_queue(res->port_id, 1, 1);
4640 cmdline_parse_token_string_t cmd_tso_set_tso =
4641 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4643 cmdline_parse_token_string_t cmd_tso_set_mode =
4644 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4646 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4647 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4649 cmdline_parse_token_num_t cmd_tso_set_portid =
4650 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4653 cmdline_parse_inst_t cmd_tso_set = {
4654 .f = cmd_tso_set_parsed,
4656 .help_str = "tso set <tso_segsz> <port_id>: "
4657 "Set TSO segment size of non-tunneled packets for csum engine "
4660 (void *)&cmd_tso_set_tso,
4661 (void *)&cmd_tso_set_mode,
4662 (void *)&cmd_tso_set_tso_segsz,
4663 (void *)&cmd_tso_set_portid,
4668 cmdline_parse_token_string_t cmd_tso_show_mode =
4669 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4673 cmdline_parse_inst_t cmd_tso_show = {
4674 .f = cmd_tso_set_parsed,
4676 .help_str = "tso show <port_id>: "
4677 "Show TSO segment size of non-tunneled packets for csum engine",
4679 (void *)&cmd_tso_set_tso,
4680 (void *)&cmd_tso_show_mode,
4681 (void *)&cmd_tso_set_portid,
4686 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4687 struct cmd_tunnel_tso_set_result {
4688 cmdline_fixed_string_t tso;
4689 cmdline_fixed_string_t mode;
4694 static struct rte_eth_dev_info
4695 check_tunnel_tso_nic_support(portid_t port_id)
4697 struct rte_eth_dev_info dev_info;
4699 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4702 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4703 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4704 "not enabled for port %d\n", port_id);
4705 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4706 printf("Warning: GRE TUNNEL TSO not supported therefore "
4707 "not enabled for port %d\n", port_id);
4708 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4709 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4710 "not enabled for port %d\n", port_id);
4711 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4712 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4713 "not enabled for port %d\n", port_id);
4714 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4715 printf("Warning: IP TUNNEL TSO not supported therefore "
4716 "not enabled for port %d\n", port_id);
4717 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4718 printf("Warning: UDP TUNNEL TSO not supported therefore "
4719 "not enabled for port %d\n", port_id);
4724 cmd_tunnel_tso_set_parsed(void *parsed_result,
4725 __attribute__((unused)) struct cmdline *cl,
4726 __attribute__((unused)) void *data)
4728 struct cmd_tunnel_tso_set_result *res = parsed_result;
4729 struct rte_eth_dev_info dev_info;
4731 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4733 if (!port_is_stopped(res->port_id)) {
4734 printf("Please stop port %d first\n", res->port_id);
4738 if (!strcmp(res->mode, "set"))
4739 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4741 dev_info = check_tunnel_tso_nic_support(res->port_id);
4742 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4743 ports[res->port_id].dev_conf.txmode.offloads &=
4744 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4745 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4746 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4747 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4748 DEV_TX_OFFLOAD_IP_TNL_TSO |
4749 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4750 printf("TSO for tunneled packets is disabled\n");
4752 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4753 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4754 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4755 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4756 DEV_TX_OFFLOAD_IP_TNL_TSO |
4757 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4759 ports[res->port_id].dev_conf.txmode.offloads |=
4760 (tso_offloads & dev_info.tx_offload_capa);
4761 printf("TSO segment size for tunneled packets is %d\n",
4762 ports[res->port_id].tunnel_tso_segsz);
4764 /* Below conditions are needed to make it work:
4765 * (1) tunnel TSO is supported by the NIC;
4766 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4768 * (3) for tunneled pkts with outer L3 of IPv4,
4769 * "csum set outer-ip" must be set to hw, because after tso,
4770 * total_len of outer IP header is changed, and the checksum
4771 * of outer IP header calculated by sw should be wrong; that
4772 * is not necessary for IPv6 tunneled pkts because there's no
4773 * checksum in IP header anymore.
4776 if (!ports[res->port_id].parse_tunnel)
4777 printf("Warning: csum parse_tunnel must be set "
4778 "so that tunneled packets are recognized\n");
4779 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4780 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4781 printf("Warning: csum set outer-ip must be set to hw "
4782 "if outer L3 is IPv4; not necessary for IPv6\n");
4785 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4786 cmd_reconfig_device_queue(res->port_id, 1, 1);
4789 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4790 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4792 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4793 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4795 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4796 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4798 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4799 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4802 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4803 .f = cmd_tunnel_tso_set_parsed,
4805 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4806 "Set TSO segment size of tunneled packets for csum engine "
4809 (void *)&cmd_tunnel_tso_set_tso,
4810 (void *)&cmd_tunnel_tso_set_mode,
4811 (void *)&cmd_tunnel_tso_set_tso_segsz,
4812 (void *)&cmd_tunnel_tso_set_portid,
4817 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4818 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4822 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4823 .f = cmd_tunnel_tso_set_parsed,
4825 .help_str = "tunnel_tso show <port_id> "
4826 "Show TSO segment size of tunneled packets for csum engine",
4828 (void *)&cmd_tunnel_tso_set_tso,
4829 (void *)&cmd_tunnel_tso_show_mode,
4830 (void *)&cmd_tunnel_tso_set_portid,
4835 /* *** SET GRO FOR A PORT *** */
4836 struct cmd_gro_enable_result {
4837 cmdline_fixed_string_t cmd_set;
4838 cmdline_fixed_string_t cmd_port;
4839 cmdline_fixed_string_t cmd_keyword;
4840 cmdline_fixed_string_t cmd_onoff;
4845 cmd_gro_enable_parsed(void *parsed_result,
4846 __attribute__((unused)) struct cmdline *cl,
4847 __attribute__((unused)) void *data)
4849 struct cmd_gro_enable_result *res;
4851 res = parsed_result;
4852 if (!strcmp(res->cmd_keyword, "gro"))
4853 setup_gro(res->cmd_onoff, res->cmd_pid);
4856 cmdline_parse_token_string_t cmd_gro_enable_set =
4857 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4859 cmdline_parse_token_string_t cmd_gro_enable_port =
4860 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4861 cmd_keyword, "port");
4862 cmdline_parse_token_num_t cmd_gro_enable_pid =
4863 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4865 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4866 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4867 cmd_keyword, "gro");
4868 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4869 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4870 cmd_onoff, "on#off");
4872 cmdline_parse_inst_t cmd_gro_enable = {
4873 .f = cmd_gro_enable_parsed,
4875 .help_str = "set port <port_id> gro on|off",
4877 (void *)&cmd_gro_enable_set,
4878 (void *)&cmd_gro_enable_port,
4879 (void *)&cmd_gro_enable_pid,
4880 (void *)&cmd_gro_enable_keyword,
4881 (void *)&cmd_gro_enable_onoff,
4886 /* *** DISPLAY GRO CONFIGURATION *** */
4887 struct cmd_gro_show_result {
4888 cmdline_fixed_string_t cmd_show;
4889 cmdline_fixed_string_t cmd_port;
4890 cmdline_fixed_string_t cmd_keyword;
4895 cmd_gro_show_parsed(void *parsed_result,
4896 __attribute__((unused)) struct cmdline *cl,
4897 __attribute__((unused)) void *data)
4899 struct cmd_gro_show_result *res;
4901 res = parsed_result;
4902 if (!strcmp(res->cmd_keyword, "gro"))
4903 show_gro(res->cmd_pid);
4906 cmdline_parse_token_string_t cmd_gro_show_show =
4907 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4909 cmdline_parse_token_string_t cmd_gro_show_port =
4910 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4912 cmdline_parse_token_num_t cmd_gro_show_pid =
4913 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4915 cmdline_parse_token_string_t cmd_gro_show_keyword =
4916 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4917 cmd_keyword, "gro");
4919 cmdline_parse_inst_t cmd_gro_show = {
4920 .f = cmd_gro_show_parsed,
4922 .help_str = "show port <port_id> gro",
4924 (void *)&cmd_gro_show_show,
4925 (void *)&cmd_gro_show_port,
4926 (void *)&cmd_gro_show_pid,
4927 (void *)&cmd_gro_show_keyword,
4932 /* *** SET FLUSH CYCLES FOR GRO *** */
4933 struct cmd_gro_flush_result {
4934 cmdline_fixed_string_t cmd_set;
4935 cmdline_fixed_string_t cmd_keyword;
4936 cmdline_fixed_string_t cmd_flush;
4941 cmd_gro_flush_parsed(void *parsed_result,
4942 __attribute__((unused)) struct cmdline *cl,
4943 __attribute__((unused)) void *data)
4945 struct cmd_gro_flush_result *res;
4947 res = parsed_result;
4948 if ((!strcmp(res->cmd_keyword, "gro")) &&
4949 (!strcmp(res->cmd_flush, "flush")))
4950 setup_gro_flush_cycles(res->cmd_cycles);
4953 cmdline_parse_token_string_t cmd_gro_flush_set =
4954 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4956 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4957 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4958 cmd_keyword, "gro");
4959 cmdline_parse_token_string_t cmd_gro_flush_flush =
4960 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4961 cmd_flush, "flush");
4962 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4963 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4966 cmdline_parse_inst_t cmd_gro_flush = {
4967 .f = cmd_gro_flush_parsed,
4969 .help_str = "set gro flush <cycles>",
4971 (void *)&cmd_gro_flush_set,
4972 (void *)&cmd_gro_flush_keyword,
4973 (void *)&cmd_gro_flush_flush,
4974 (void *)&cmd_gro_flush_cycles,
4979 /* *** ENABLE/DISABLE GSO *** */
4980 struct cmd_gso_enable_result {
4981 cmdline_fixed_string_t cmd_set;
4982 cmdline_fixed_string_t cmd_port;
4983 cmdline_fixed_string_t cmd_keyword;
4984 cmdline_fixed_string_t cmd_mode;
4989 cmd_gso_enable_parsed(void *parsed_result,
4990 __attribute__((unused)) struct cmdline *cl,
4991 __attribute__((unused)) void *data)
4993 struct cmd_gso_enable_result *res;
4995 res = parsed_result;
4996 if (!strcmp(res->cmd_keyword, "gso"))
4997 setup_gso(res->cmd_mode, res->cmd_pid);
5000 cmdline_parse_token_string_t cmd_gso_enable_set =
5001 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5003 cmdline_parse_token_string_t cmd_gso_enable_port =
5004 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5006 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5007 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5008 cmd_keyword, "gso");
5009 cmdline_parse_token_string_t cmd_gso_enable_mode =
5010 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5011 cmd_mode, "on#off");
5012 cmdline_parse_token_num_t cmd_gso_enable_pid =
5013 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5016 cmdline_parse_inst_t cmd_gso_enable = {
5017 .f = cmd_gso_enable_parsed,
5019 .help_str = "set port <port_id> gso on|off",
5021 (void *)&cmd_gso_enable_set,
5022 (void *)&cmd_gso_enable_port,
5023 (void *)&cmd_gso_enable_pid,
5024 (void *)&cmd_gso_enable_keyword,
5025 (void *)&cmd_gso_enable_mode,
5030 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5031 struct cmd_gso_size_result {
5032 cmdline_fixed_string_t cmd_set;
5033 cmdline_fixed_string_t cmd_keyword;
5034 cmdline_fixed_string_t cmd_segsz;
5039 cmd_gso_size_parsed(void *parsed_result,
5040 __attribute__((unused)) struct cmdline *cl,
5041 __attribute__((unused)) void *data)
5043 struct cmd_gso_size_result *res = parsed_result;
5045 if (test_done == 0) {
5046 printf("Before setting GSO segsz, please first"
5047 " stop fowarding\n");
5051 if (!strcmp(res->cmd_keyword, "gso") &&
5052 !strcmp(res->cmd_segsz, "segsz")) {
5053 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5054 printf("gso_size should be larger than %zu."
5055 " Please input a legal value\n",
5056 RTE_GSO_SEG_SIZE_MIN);
5058 gso_max_segment_size = res->cmd_size;
5062 cmdline_parse_token_string_t cmd_gso_size_set =
5063 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5065 cmdline_parse_token_string_t cmd_gso_size_keyword =
5066 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5067 cmd_keyword, "gso");
5068 cmdline_parse_token_string_t cmd_gso_size_segsz =
5069 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5070 cmd_segsz, "segsz");
5071 cmdline_parse_token_num_t cmd_gso_size_size =
5072 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5075 cmdline_parse_inst_t cmd_gso_size = {
5076 .f = cmd_gso_size_parsed,
5078 .help_str = "set gso segsz <length>",
5080 (void *)&cmd_gso_size_set,
5081 (void *)&cmd_gso_size_keyword,
5082 (void *)&cmd_gso_size_segsz,
5083 (void *)&cmd_gso_size_size,
5088 /* *** SHOW GSO CONFIGURATION *** */
5089 struct cmd_gso_show_result {
5090 cmdline_fixed_string_t cmd_show;
5091 cmdline_fixed_string_t cmd_port;
5092 cmdline_fixed_string_t cmd_keyword;
5097 cmd_gso_show_parsed(void *parsed_result,
5098 __attribute__((unused)) struct cmdline *cl,
5099 __attribute__((unused)) void *data)
5101 struct cmd_gso_show_result *res = parsed_result;
5103 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5104 printf("invalid port id %u\n", res->cmd_pid);
5107 if (!strcmp(res->cmd_keyword, "gso")) {
5108 if (gso_ports[res->cmd_pid].enable) {
5109 printf("Max GSO'd packet size: %uB\n"
5110 "Supported GSO types: TCP/IPv4, "
5111 "UDP/IPv4, VxLAN with inner "
5112 "TCP/IPv4 packet, GRE with inner "
5113 "TCP/IPv4 packet\n",
5114 gso_max_segment_size);
5116 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5120 cmdline_parse_token_string_t cmd_gso_show_show =
5121 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5123 cmdline_parse_token_string_t cmd_gso_show_port =
5124 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5126 cmdline_parse_token_string_t cmd_gso_show_keyword =
5127 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5128 cmd_keyword, "gso");
5129 cmdline_parse_token_num_t cmd_gso_show_pid =
5130 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5133 cmdline_parse_inst_t cmd_gso_show = {
5134 .f = cmd_gso_show_parsed,
5136 .help_str = "show port <port_id> gso",
5138 (void *)&cmd_gso_show_show,
5139 (void *)&cmd_gso_show_port,
5140 (void *)&cmd_gso_show_pid,
5141 (void *)&cmd_gso_show_keyword,
5146 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5147 struct cmd_set_flush_rx {
5148 cmdline_fixed_string_t set;
5149 cmdline_fixed_string_t flush_rx;
5150 cmdline_fixed_string_t mode;
5154 cmd_set_flush_rx_parsed(void *parsed_result,
5155 __attribute__((unused)) struct cmdline *cl,
5156 __attribute__((unused)) void *data)
5158 struct cmd_set_flush_rx *res = parsed_result;
5159 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5162 cmdline_parse_token_string_t cmd_setflushrx_set =
5163 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5165 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5166 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5167 flush_rx, "flush_rx");
5168 cmdline_parse_token_string_t cmd_setflushrx_mode =
5169 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5173 cmdline_parse_inst_t cmd_set_flush_rx = {
5174 .f = cmd_set_flush_rx_parsed,
5175 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5178 (void *)&cmd_setflushrx_set,
5179 (void *)&cmd_setflushrx_flush_rx,
5180 (void *)&cmd_setflushrx_mode,
5185 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5186 struct cmd_set_link_check {
5187 cmdline_fixed_string_t set;
5188 cmdline_fixed_string_t link_check;
5189 cmdline_fixed_string_t mode;
5193 cmd_set_link_check_parsed(void *parsed_result,
5194 __attribute__((unused)) struct cmdline *cl,
5195 __attribute__((unused)) void *data)
5197 struct cmd_set_link_check *res = parsed_result;
5198 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5201 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5202 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5204 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5205 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5206 link_check, "link_check");
5207 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5208 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5212 cmdline_parse_inst_t cmd_set_link_check = {
5213 .f = cmd_set_link_check_parsed,
5214 .help_str = "set link_check on|off: Enable/Disable link status check "
5215 "when starting/stopping a port",
5218 (void *)&cmd_setlinkcheck_set,
5219 (void *)&cmd_setlinkcheck_link_check,
5220 (void *)&cmd_setlinkcheck_mode,
5225 /* *** SET NIC BYPASS MODE *** */
5226 struct cmd_set_bypass_mode_result {
5227 cmdline_fixed_string_t set;
5228 cmdline_fixed_string_t bypass;
5229 cmdline_fixed_string_t mode;
5230 cmdline_fixed_string_t value;
5235 cmd_set_bypass_mode_parsed(void *parsed_result,
5236 __attribute__((unused)) struct cmdline *cl,
5237 __attribute__((unused)) void *data)
5239 struct cmd_set_bypass_mode_result *res = parsed_result;
5240 portid_t port_id = res->port_id;
5241 int32_t rc = -EINVAL;
5243 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5244 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5246 if (!strcmp(res->value, "bypass"))
5247 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5248 else if (!strcmp(res->value, "isolate"))
5249 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5251 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5253 /* Set the bypass mode for the relevant port. */
5254 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5257 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5260 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5261 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5263 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5264 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5266 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5267 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5269 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5270 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5271 value, "normal#bypass#isolate");
5272 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5273 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5276 cmdline_parse_inst_t cmd_set_bypass_mode = {
5277 .f = cmd_set_bypass_mode_parsed,
5278 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5279 "Set the NIC bypass mode for port_id",
5282 (void *)&cmd_setbypass_mode_set,
5283 (void *)&cmd_setbypass_mode_bypass,
5284 (void *)&cmd_setbypass_mode_mode,
5285 (void *)&cmd_setbypass_mode_value,
5286 (void *)&cmd_setbypass_mode_port,
5291 /* *** SET NIC BYPASS EVENT *** */
5292 struct cmd_set_bypass_event_result {
5293 cmdline_fixed_string_t set;
5294 cmdline_fixed_string_t bypass;
5295 cmdline_fixed_string_t event;
5296 cmdline_fixed_string_t event_value;
5297 cmdline_fixed_string_t mode;
5298 cmdline_fixed_string_t mode_value;
5303 cmd_set_bypass_event_parsed(void *parsed_result,
5304 __attribute__((unused)) struct cmdline *cl,
5305 __attribute__((unused)) void *data)
5307 int32_t rc = -EINVAL;
5308 struct cmd_set_bypass_event_result *res = parsed_result;
5309 portid_t port_id = res->port_id;
5311 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5312 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5313 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5315 if (!strcmp(res->event_value, "timeout"))
5316 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5317 else if (!strcmp(res->event_value, "os_on"))
5318 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5319 else if (!strcmp(res->event_value, "os_off"))
5320 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5321 else if (!strcmp(res->event_value, "power_on"))
5322 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5323 else if (!strcmp(res->event_value, "power_off"))
5324 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5326 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5328 if (!strcmp(res->mode_value, "bypass"))
5329 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5330 else if (!strcmp(res->mode_value, "isolate"))
5331 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5333 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5335 /* Set the watchdog timeout. */
5336 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5339 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5340 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5344 printf("Failed to set timeout value %u "
5345 "for port %d, errto code: %d.\n",
5346 bypass_timeout, port_id, rc);
5350 /* Set the bypass event to transition to bypass mode. */
5351 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5356 printf("\t Failed to set bypass event for port = %d.\n",
5360 cmdline_parse_token_string_t cmd_setbypass_event_set =
5361 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5363 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5364 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5366 cmdline_parse_token_string_t cmd_setbypass_event_event =
5367 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5369 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5370 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5371 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5372 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5373 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5375 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5376 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5377 mode_value, "normal#bypass#isolate");
5378 cmdline_parse_token_num_t cmd_setbypass_event_port =
5379 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5382 cmdline_parse_inst_t cmd_set_bypass_event = {
5383 .f = cmd_set_bypass_event_parsed,
5384 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5385 "power_off mode normal|bypass|isolate <port_id>: "
5386 "Set the NIC bypass event mode for port_id",
5389 (void *)&cmd_setbypass_event_set,
5390 (void *)&cmd_setbypass_event_bypass,
5391 (void *)&cmd_setbypass_event_event,
5392 (void *)&cmd_setbypass_event_event_value,
5393 (void *)&cmd_setbypass_event_mode,
5394 (void *)&cmd_setbypass_event_mode_value,
5395 (void *)&cmd_setbypass_event_port,
5401 /* *** SET NIC BYPASS TIMEOUT *** */
5402 struct cmd_set_bypass_timeout_result {
5403 cmdline_fixed_string_t set;
5404 cmdline_fixed_string_t bypass;
5405 cmdline_fixed_string_t timeout;
5406 cmdline_fixed_string_t value;
5410 cmd_set_bypass_timeout_parsed(void *parsed_result,
5411 __attribute__((unused)) struct cmdline *cl,
5412 __attribute__((unused)) void *data)
5414 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5416 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5417 if (!strcmp(res->value, "1.5"))
5418 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5419 else if (!strcmp(res->value, "2"))
5420 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5421 else if (!strcmp(res->value, "3"))
5422 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5423 else if (!strcmp(res->value, "4"))
5424 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5425 else if (!strcmp(res->value, "8"))
5426 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5427 else if (!strcmp(res->value, "16"))
5428 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5429 else if (!strcmp(res->value, "32"))
5430 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5432 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5436 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5437 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5439 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5440 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5442 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5443 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5444 timeout, "timeout");
5445 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5446 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5447 value, "0#1.5#2#3#4#8#16#32");
5449 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5450 .f = cmd_set_bypass_timeout_parsed,
5451 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5452 "Set the NIC bypass watchdog timeout in seconds",
5455 (void *)&cmd_setbypass_timeout_set,
5456 (void *)&cmd_setbypass_timeout_bypass,
5457 (void *)&cmd_setbypass_timeout_timeout,
5458 (void *)&cmd_setbypass_timeout_value,
5463 /* *** SHOW NIC BYPASS MODE *** */
5464 struct cmd_show_bypass_config_result {
5465 cmdline_fixed_string_t show;
5466 cmdline_fixed_string_t bypass;
5467 cmdline_fixed_string_t config;
5472 cmd_show_bypass_config_parsed(void *parsed_result,
5473 __attribute__((unused)) struct cmdline *cl,
5474 __attribute__((unused)) void *data)
5476 struct cmd_show_bypass_config_result *res = parsed_result;
5477 portid_t port_id = res->port_id;
5479 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5480 uint32_t event_mode;
5481 uint32_t bypass_mode;
5482 uint32_t timeout = bypass_timeout;
5485 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5486 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5487 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5488 {"UNKNOWN", "normal", "bypass", "isolate"};
5489 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5496 int num_events = (sizeof events) / (sizeof events[0]);
5498 /* Display the bypass mode.*/
5499 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5500 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5504 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5505 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5507 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5510 /* Display the bypass timeout.*/
5511 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5512 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5514 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5516 /* Display the bypass events and associated modes. */
5517 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5519 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5520 printf("\tFailed to get bypass mode for event = %s\n",
5523 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5524 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5526 printf("\tbypass event: %-16s = %s\n", events[i],
5532 printf("\tFailed to get bypass configuration for port = %d\n",
5536 cmdline_parse_token_string_t cmd_showbypass_config_show =
5537 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5539 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5540 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5542 cmdline_parse_token_string_t cmd_showbypass_config_config =
5543 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5545 cmdline_parse_token_num_t cmd_showbypass_config_port =
5546 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5549 cmdline_parse_inst_t cmd_show_bypass_config = {
5550 .f = cmd_show_bypass_config_parsed,
5551 .help_str = "show bypass config <port_id>: "
5552 "Show the NIC bypass config for port_id",
5555 (void *)&cmd_showbypass_config_show,
5556 (void *)&cmd_showbypass_config_bypass,
5557 (void *)&cmd_showbypass_config_config,
5558 (void *)&cmd_showbypass_config_port,
5563 #ifdef RTE_LIBRTE_PMD_BOND
5564 /* *** SET BONDING MODE *** */
5565 struct cmd_set_bonding_mode_result {
5566 cmdline_fixed_string_t set;
5567 cmdline_fixed_string_t bonding;
5568 cmdline_fixed_string_t mode;
5573 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5574 __attribute__((unused)) struct cmdline *cl,
5575 __attribute__((unused)) void *data)
5577 struct cmd_set_bonding_mode_result *res = parsed_result;
5578 portid_t port_id = res->port_id;
5580 /* Set the bonding mode for the relevant port. */
5581 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5582 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5585 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5586 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5588 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5589 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5590 bonding, "bonding");
5591 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5592 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5594 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5595 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5597 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5598 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5601 cmdline_parse_inst_t cmd_set_bonding_mode = {
5602 .f = cmd_set_bonding_mode_parsed,
5603 .help_str = "set bonding mode <mode_value> <port_id>: "
5604 "Set the bonding mode for port_id",
5607 (void *) &cmd_setbonding_mode_set,
5608 (void *) &cmd_setbonding_mode_bonding,
5609 (void *) &cmd_setbonding_mode_mode,
5610 (void *) &cmd_setbonding_mode_value,
5611 (void *) &cmd_setbonding_mode_port,
5616 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5617 struct cmd_set_bonding_lacp_dedicated_queues_result {
5618 cmdline_fixed_string_t set;
5619 cmdline_fixed_string_t bonding;
5620 cmdline_fixed_string_t lacp;
5621 cmdline_fixed_string_t dedicated_queues;
5623 cmdline_fixed_string_t mode;
5626 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5627 __attribute__((unused)) struct cmdline *cl,
5628 __attribute__((unused)) void *data)
5630 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5631 portid_t port_id = res->port_id;
5632 struct rte_port *port;
5634 port = &ports[port_id];
5636 /** Check if the port is not started **/
5637 if (port->port_status != RTE_PORT_STOPPED) {
5638 printf("Please stop port %d first\n", port_id);
5642 if (!strcmp(res->mode, "enable")) {
5643 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5644 printf("Dedicate queues for LACP control packets"
5647 printf("Enabling dedicate queues for LACP control "
5648 "packets on port %d failed\n", port_id);
5649 } else if (!strcmp(res->mode, "disable")) {
5650 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5651 printf("Dedicated queues for LACP control packets "
5654 printf("Disabling dedicated queues for LACP control "
5655 "traffic on port %d failed\n", port_id);
5659 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5660 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5662 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5663 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5664 bonding, "bonding");
5665 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5666 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5668 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5669 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5670 dedicated_queues, "dedicated_queues");
5671 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5672 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5674 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5675 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5676 mode, "enable#disable");
5678 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5679 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5680 .help_str = "set bonding lacp dedicated_queues <port_id> "
5682 "Enable/disable dedicated queues for LACP control traffic for port_id",
5685 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5686 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5687 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5688 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5689 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5690 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5695 /* *** SET BALANCE XMIT POLICY *** */
5696 struct cmd_set_bonding_balance_xmit_policy_result {
5697 cmdline_fixed_string_t set;
5698 cmdline_fixed_string_t bonding;
5699 cmdline_fixed_string_t balance_xmit_policy;
5701 cmdline_fixed_string_t policy;
5704 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5705 __attribute__((unused)) struct cmdline *cl,
5706 __attribute__((unused)) void *data)
5708 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5709 portid_t port_id = res->port_id;
5712 if (!strcmp(res->policy, "l2")) {
5713 policy = BALANCE_XMIT_POLICY_LAYER2;
5714 } else if (!strcmp(res->policy, "l23")) {
5715 policy = BALANCE_XMIT_POLICY_LAYER23;
5716 } else if (!strcmp(res->policy, "l34")) {
5717 policy = BALANCE_XMIT_POLICY_LAYER34;
5719 printf("\t Invalid xmit policy selection");
5723 /* Set the bonding mode for the relevant port. */
5724 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5725 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5730 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5731 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5733 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5734 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5735 bonding, "bonding");
5736 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5737 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5738 balance_xmit_policy, "balance_xmit_policy");
5739 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5740 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5742 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5743 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5744 policy, "l2#l23#l34");
5746 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5747 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5748 .help_str = "set bonding balance_xmit_policy <port_id> "
5750 "Set the bonding balance_xmit_policy for port_id",
5753 (void *)&cmd_setbonding_balance_xmit_policy_set,
5754 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5755 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5756 (void *)&cmd_setbonding_balance_xmit_policy_port,
5757 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5762 /* *** SHOW NIC BONDING CONFIGURATION *** */
5763 struct cmd_show_bonding_config_result {
5764 cmdline_fixed_string_t show;
5765 cmdline_fixed_string_t bonding;
5766 cmdline_fixed_string_t config;
5770 static void cmd_show_bonding_config_parsed(void *parsed_result,
5771 __attribute__((unused)) struct cmdline *cl,
5772 __attribute__((unused)) void *data)
5774 struct cmd_show_bonding_config_result *res = parsed_result;
5775 int bonding_mode, agg_mode;
5776 portid_t slaves[RTE_MAX_ETHPORTS];
5777 int num_slaves, num_active_slaves;
5780 portid_t port_id = res->port_id;
5782 /* Display the bonding mode.*/
5783 bonding_mode = rte_eth_bond_mode_get(port_id);
5784 if (bonding_mode < 0) {
5785 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5788 printf("\tBonding mode: %d\n", bonding_mode);
5790 if (bonding_mode == BONDING_MODE_BALANCE) {
5791 int balance_xmit_policy;
5793 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5794 if (balance_xmit_policy < 0) {
5795 printf("\tFailed to get balance xmit policy for port = %d\n",
5799 printf("\tBalance Xmit Policy: ");
5801 switch (balance_xmit_policy) {
5802 case BALANCE_XMIT_POLICY_LAYER2:
5803 printf("BALANCE_XMIT_POLICY_LAYER2");
5805 case BALANCE_XMIT_POLICY_LAYER23:
5806 printf("BALANCE_XMIT_POLICY_LAYER23");
5808 case BALANCE_XMIT_POLICY_LAYER34:
5809 printf("BALANCE_XMIT_POLICY_LAYER34");
5816 if (bonding_mode == BONDING_MODE_8023AD) {
5817 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5818 printf("\tIEEE802.3AD Aggregator Mode: ");
5821 printf("bandwidth");
5833 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5835 if (num_slaves < 0) {
5836 printf("\tFailed to get slave list for port = %d\n", port_id);
5839 if (num_slaves > 0) {
5840 printf("\tSlaves (%d): [", num_slaves);
5841 for (i = 0; i < num_slaves - 1; i++)
5842 printf("%d ", slaves[i]);
5844 printf("%d]\n", slaves[num_slaves - 1]);
5846 printf("\tSlaves: []\n");
5850 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5853 if (num_active_slaves < 0) {
5854 printf("\tFailed to get active slave list for port = %d\n", port_id);
5857 if (num_active_slaves > 0) {
5858 printf("\tActive Slaves (%d): [", num_active_slaves);
5859 for (i = 0; i < num_active_slaves - 1; i++)
5860 printf("%d ", slaves[i]);
5862 printf("%d]\n", slaves[num_active_slaves - 1]);
5865 printf("\tActive Slaves: []\n");
5869 primary_id = rte_eth_bond_primary_get(port_id);
5870 if (primary_id < 0) {
5871 printf("\tFailed to get primary slave for port = %d\n", port_id);
5874 printf("\tPrimary: [%d]\n", primary_id);
5878 cmdline_parse_token_string_t cmd_showbonding_config_show =
5879 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5881 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5882 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5883 bonding, "bonding");
5884 cmdline_parse_token_string_t cmd_showbonding_config_config =
5885 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5887 cmdline_parse_token_num_t cmd_showbonding_config_port =
5888 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5891 cmdline_parse_inst_t cmd_show_bonding_config = {
5892 .f = cmd_show_bonding_config_parsed,
5893 .help_str = "show bonding config <port_id>: "
5894 "Show the bonding config for port_id",
5897 (void *)&cmd_showbonding_config_show,
5898 (void *)&cmd_showbonding_config_bonding,
5899 (void *)&cmd_showbonding_config_config,
5900 (void *)&cmd_showbonding_config_port,
5905 /* *** SET BONDING PRIMARY *** */
5906 struct cmd_set_bonding_primary_result {
5907 cmdline_fixed_string_t set;
5908 cmdline_fixed_string_t bonding;
5909 cmdline_fixed_string_t primary;
5914 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5915 __attribute__((unused)) struct cmdline *cl,
5916 __attribute__((unused)) void *data)
5918 struct cmd_set_bonding_primary_result *res = parsed_result;
5919 portid_t master_port_id = res->port_id;
5920 portid_t slave_port_id = res->slave_id;
5922 /* Set the primary slave for a bonded device. */
5923 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5924 printf("\t Failed to set primary slave for port = %d.\n",
5931 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5932 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5934 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5935 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5936 bonding, "bonding");
5937 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5938 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5939 primary, "primary");
5940 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5941 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5943 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5944 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5947 cmdline_parse_inst_t cmd_set_bonding_primary = {
5948 .f = cmd_set_bonding_primary_parsed,
5949 .help_str = "set bonding primary <slave_id> <port_id>: "
5950 "Set the primary slave for port_id",
5953 (void *)&cmd_setbonding_primary_set,
5954 (void *)&cmd_setbonding_primary_bonding,
5955 (void *)&cmd_setbonding_primary_primary,
5956 (void *)&cmd_setbonding_primary_slave,
5957 (void *)&cmd_setbonding_primary_port,
5962 /* *** ADD SLAVE *** */
5963 struct cmd_add_bonding_slave_result {
5964 cmdline_fixed_string_t add;
5965 cmdline_fixed_string_t bonding;
5966 cmdline_fixed_string_t slave;
5971 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5972 __attribute__((unused)) struct cmdline *cl,
5973 __attribute__((unused)) void *data)
5975 struct cmd_add_bonding_slave_result *res = parsed_result;
5976 portid_t master_port_id = res->port_id;
5977 portid_t slave_port_id = res->slave_id;
5979 /* add the slave for a bonded device. */
5980 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5981 printf("\t Failed to add slave %d to master port = %d.\n",
5982 slave_port_id, master_port_id);
5986 set_port_slave_flag(slave_port_id);
5989 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5990 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5992 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5993 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5994 bonding, "bonding");
5995 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5996 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5998 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5999 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6001 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6002 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6005 cmdline_parse_inst_t cmd_add_bonding_slave = {
6006 .f = cmd_add_bonding_slave_parsed,
6007 .help_str = "add bonding slave <slave_id> <port_id>: "
6008 "Add a slave device to a bonded device",
6011 (void *)&cmd_addbonding_slave_add,
6012 (void *)&cmd_addbonding_slave_bonding,
6013 (void *)&cmd_addbonding_slave_slave,
6014 (void *)&cmd_addbonding_slave_slaveid,
6015 (void *)&cmd_addbonding_slave_port,
6020 /* *** REMOVE SLAVE *** */
6021 struct cmd_remove_bonding_slave_result {
6022 cmdline_fixed_string_t remove;
6023 cmdline_fixed_string_t bonding;
6024 cmdline_fixed_string_t slave;
6029 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6030 __attribute__((unused)) struct cmdline *cl,
6031 __attribute__((unused)) void *data)
6033 struct cmd_remove_bonding_slave_result *res = parsed_result;
6034 portid_t master_port_id = res->port_id;
6035 portid_t slave_port_id = res->slave_id;
6037 /* remove the slave from a bonded device. */
6038 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6039 printf("\t Failed to remove slave %d from master port = %d.\n",
6040 slave_port_id, master_port_id);
6044 clear_port_slave_flag(slave_port_id);
6047 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6048 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6050 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6051 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6052 bonding, "bonding");
6053 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6054 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6056 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6057 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6059 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6060 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6063 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6064 .f = cmd_remove_bonding_slave_parsed,
6065 .help_str = "remove bonding slave <slave_id> <port_id>: "
6066 "Remove a slave device from a bonded device",
6069 (void *)&cmd_removebonding_slave_remove,
6070 (void *)&cmd_removebonding_slave_bonding,
6071 (void *)&cmd_removebonding_slave_slave,
6072 (void *)&cmd_removebonding_slave_slaveid,
6073 (void *)&cmd_removebonding_slave_port,
6078 /* *** CREATE BONDED DEVICE *** */
6079 struct cmd_create_bonded_device_result {
6080 cmdline_fixed_string_t create;
6081 cmdline_fixed_string_t bonded;
6082 cmdline_fixed_string_t device;
6087 static int bond_dev_num = 0;
6089 static void cmd_create_bonded_device_parsed(void *parsed_result,
6090 __attribute__((unused)) struct cmdline *cl,
6091 __attribute__((unused)) void *data)
6093 struct cmd_create_bonded_device_result *res = parsed_result;
6094 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6098 if (test_done == 0) {
6099 printf("Please stop forwarding first\n");
6103 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6106 /* Create a new bonded device. */
6107 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6109 printf("\t Failed to create bonded device.\n");
6112 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6115 /* Update number of ports */
6116 nb_ports = rte_eth_dev_count_avail();
6117 reconfig(port_id, res->socket);
6118 ret = rte_eth_promiscuous_enable(port_id);
6120 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6121 port_id, rte_strerror(-ret));
6123 ports[port_id].need_setup = 0;
6124 ports[port_id].port_status = RTE_PORT_STOPPED;
6129 cmdline_parse_token_string_t cmd_createbonded_device_create =
6130 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6132 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6133 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6135 cmdline_parse_token_string_t cmd_createbonded_device_device =
6136 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6138 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6139 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6141 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6142 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6145 cmdline_parse_inst_t cmd_create_bonded_device = {
6146 .f = cmd_create_bonded_device_parsed,
6147 .help_str = "create bonded device <mode> <socket>: "
6148 "Create a new bonded device with specific bonding mode and socket",
6151 (void *)&cmd_createbonded_device_create,
6152 (void *)&cmd_createbonded_device_bonded,
6153 (void *)&cmd_createbonded_device_device,
6154 (void *)&cmd_createbonded_device_mode,
6155 (void *)&cmd_createbonded_device_socket,
6160 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6161 struct cmd_set_bond_mac_addr_result {
6162 cmdline_fixed_string_t set;
6163 cmdline_fixed_string_t bonding;
6164 cmdline_fixed_string_t mac_addr;
6166 struct rte_ether_addr address;
6169 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6170 __attribute__((unused)) struct cmdline *cl,
6171 __attribute__((unused)) void *data)
6173 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6176 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6179 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6181 /* check the return value and print it if is < 0 */
6183 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6186 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6187 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6188 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6189 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6191 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6192 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6194 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6195 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6197 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6198 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6200 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6201 .f = cmd_set_bond_mac_addr_parsed,
6203 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6205 (void *)&cmd_set_bond_mac_addr_set,
6206 (void *)&cmd_set_bond_mac_addr_bonding,
6207 (void *)&cmd_set_bond_mac_addr_mac,
6208 (void *)&cmd_set_bond_mac_addr_portnum,
6209 (void *)&cmd_set_bond_mac_addr_addr,
6215 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6216 struct cmd_set_bond_mon_period_result {
6217 cmdline_fixed_string_t set;
6218 cmdline_fixed_string_t bonding;
6219 cmdline_fixed_string_t mon_period;
6224 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6225 __attribute__((unused)) struct cmdline *cl,
6226 __attribute__((unused)) void *data)
6228 struct cmd_set_bond_mon_period_result *res = parsed_result;
6231 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6233 /* check the return value and print it if is < 0 */
6235 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6238 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6239 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6241 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6242 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6243 bonding, "bonding");
6244 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6245 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6246 mon_period, "mon_period");
6247 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6248 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6250 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6251 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6254 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6255 .f = cmd_set_bond_mon_period_parsed,
6257 .help_str = "set bonding mon_period <port_id> <period_ms>",
6259 (void *)&cmd_set_bond_mon_period_set,
6260 (void *)&cmd_set_bond_mon_period_bonding,
6261 (void *)&cmd_set_bond_mon_period_mon_period,
6262 (void *)&cmd_set_bond_mon_period_portnum,
6263 (void *)&cmd_set_bond_mon_period_period_ms,
6270 struct cmd_set_bonding_agg_mode_policy_result {
6271 cmdline_fixed_string_t set;
6272 cmdline_fixed_string_t bonding;
6273 cmdline_fixed_string_t agg_mode;
6275 cmdline_fixed_string_t policy;
6280 cmd_set_bonding_agg_mode(void *parsed_result,
6281 __attribute__((unused)) struct cmdline *cl,
6282 __attribute__((unused)) void *data)
6284 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6285 uint8_t policy = AGG_BANDWIDTH;
6287 if (!strcmp(res->policy, "bandwidth"))
6288 policy = AGG_BANDWIDTH;
6289 else if (!strcmp(res->policy, "stable"))
6290 policy = AGG_STABLE;
6291 else if (!strcmp(res->policy, "count"))
6294 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6298 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6299 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6301 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6302 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6303 bonding, "bonding");
6305 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6306 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6307 agg_mode, "agg_mode");
6309 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6310 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6313 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6314 TOKEN_STRING_INITIALIZER(
6315 struct cmd_set_bonding_balance_xmit_policy_result,
6316 policy, "stable#bandwidth#count");
6318 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6319 .f = cmd_set_bonding_agg_mode,
6321 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6323 (void *)&cmd_set_bonding_agg_mode_set,
6324 (void *)&cmd_set_bonding_agg_mode_bonding,
6325 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6326 (void *)&cmd_set_bonding_agg_mode_portnum,
6327 (void *)&cmd_set_bonding_agg_mode_policy_string,
6333 #endif /* RTE_LIBRTE_PMD_BOND */
6335 /* *** SET FORWARDING MODE *** */
6336 struct cmd_set_fwd_mode_result {
6337 cmdline_fixed_string_t set;
6338 cmdline_fixed_string_t fwd;
6339 cmdline_fixed_string_t mode;
6342 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6343 __attribute__((unused)) struct cmdline *cl,
6344 __attribute__((unused)) void *data)
6346 struct cmd_set_fwd_mode_result *res = parsed_result;
6349 set_pkt_forwarding_mode(res->mode);
6352 cmdline_parse_token_string_t cmd_setfwd_set =
6353 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6354 cmdline_parse_token_string_t cmd_setfwd_fwd =
6355 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6356 cmdline_parse_token_string_t cmd_setfwd_mode =
6357 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6358 "" /* defined at init */);
6360 cmdline_parse_inst_t cmd_set_fwd_mode = {
6361 .f = cmd_set_fwd_mode_parsed,
6363 .help_str = NULL, /* defined at init */
6365 (void *)&cmd_setfwd_set,
6366 (void *)&cmd_setfwd_fwd,
6367 (void *)&cmd_setfwd_mode,
6372 static void cmd_set_fwd_mode_init(void)
6375 static char token[128];
6376 static char help[256];
6377 cmdline_parse_token_string_t *token_struct;
6379 modes = list_pkt_forwarding_modes();
6380 snprintf(help, sizeof(help), "set fwd %s: "
6381 "Set packet forwarding mode", modes);
6382 cmd_set_fwd_mode.help_str = help;
6384 /* string token separator is # */
6385 for (c = token; *modes != '\0'; modes++)
6390 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6391 token_struct->string_data.str = token;
6394 /* *** SET RETRY FORWARDING MODE *** */
6395 struct cmd_set_fwd_retry_mode_result {
6396 cmdline_fixed_string_t set;
6397 cmdline_fixed_string_t fwd;
6398 cmdline_fixed_string_t mode;
6399 cmdline_fixed_string_t retry;
6402 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6403 __attribute__((unused)) struct cmdline *cl,
6404 __attribute__((unused)) void *data)
6406 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6409 set_pkt_forwarding_mode(res->mode);
6412 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6413 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6415 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6416 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6418 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6419 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6421 "" /* defined at init */);
6422 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6423 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6426 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6427 .f = cmd_set_fwd_retry_mode_parsed,
6429 .help_str = NULL, /* defined at init */
6431 (void *)&cmd_setfwd_retry_set,
6432 (void *)&cmd_setfwd_retry_fwd,
6433 (void *)&cmd_setfwd_retry_mode,
6434 (void *)&cmd_setfwd_retry_retry,
6439 static void cmd_set_fwd_retry_mode_init(void)
6442 static char token[128];
6443 static char help[256];
6444 cmdline_parse_token_string_t *token_struct;
6446 modes = list_pkt_forwarding_retry_modes();
6447 snprintf(help, sizeof(help), "set fwd %s retry: "
6448 "Set packet forwarding mode with retry", modes);
6449 cmd_set_fwd_retry_mode.help_str = help;
6451 /* string token separator is # */
6452 for (c = token; *modes != '\0'; modes++)
6457 token_struct = (cmdline_parse_token_string_t *)
6458 cmd_set_fwd_retry_mode.tokens[2];
6459 token_struct->string_data.str = token;
6462 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6463 struct cmd_set_burst_tx_retry_result {
6464 cmdline_fixed_string_t set;
6465 cmdline_fixed_string_t burst;
6466 cmdline_fixed_string_t tx;
6467 cmdline_fixed_string_t delay;
6469 cmdline_fixed_string_t retry;
6473 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6474 __attribute__((unused)) struct cmdline *cl,
6475 __attribute__((unused)) void *data)
6477 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6479 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6480 && !strcmp(res->tx, "tx")) {
6481 if (!strcmp(res->delay, "delay"))
6482 burst_tx_delay_time = res->time;
6483 if (!strcmp(res->retry, "retry"))
6484 burst_tx_retry_num = res->retry_num;
6489 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6490 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6491 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6492 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6494 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6495 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6496 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6497 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6498 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6499 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6500 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6501 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6502 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6503 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6505 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6506 .f = cmd_set_burst_tx_retry_parsed,
6507 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6509 (void *)&cmd_set_burst_tx_retry_set,
6510 (void *)&cmd_set_burst_tx_retry_burst,
6511 (void *)&cmd_set_burst_tx_retry_tx,
6512 (void *)&cmd_set_burst_tx_retry_delay,
6513 (void *)&cmd_set_burst_tx_retry_time,
6514 (void *)&cmd_set_burst_tx_retry_retry,
6515 (void *)&cmd_set_burst_tx_retry_retry_num,
6520 /* *** SET PROMISC MODE *** */
6521 struct cmd_set_promisc_mode_result {
6522 cmdline_fixed_string_t set;
6523 cmdline_fixed_string_t promisc;
6524 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6525 uint16_t port_num; /* valid if "allports" argument == 0 */
6526 cmdline_fixed_string_t mode;
6529 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6530 __attribute__((unused)) struct cmdline *cl,
6533 struct cmd_set_promisc_mode_result *res = parsed_result;
6537 if (!strcmp(res->mode, "on"))
6544 RTE_ETH_FOREACH_DEV(i)
6545 eth_set_promisc_mode(i, enable);
6547 eth_set_promisc_mode(res->port_num, enable);
6551 cmdline_parse_token_string_t cmd_setpromisc_set =
6552 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6553 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6554 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6556 cmdline_parse_token_string_t cmd_setpromisc_portall =
6557 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6559 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6560 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6562 cmdline_parse_token_string_t cmd_setpromisc_mode =
6563 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6566 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6567 .f = cmd_set_promisc_mode_parsed,
6569 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6571 (void *)&cmd_setpromisc_set,
6572 (void *)&cmd_setpromisc_promisc,
6573 (void *)&cmd_setpromisc_portall,
6574 (void *)&cmd_setpromisc_mode,
6579 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6580 .f = cmd_set_promisc_mode_parsed,
6582 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6584 (void *)&cmd_setpromisc_set,
6585 (void *)&cmd_setpromisc_promisc,
6586 (void *)&cmd_setpromisc_portnum,
6587 (void *)&cmd_setpromisc_mode,
6592 /* *** SET ALLMULTI MODE *** */
6593 struct cmd_set_allmulti_mode_result {
6594 cmdline_fixed_string_t set;
6595 cmdline_fixed_string_t allmulti;
6596 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6597 uint16_t port_num; /* valid if "allports" argument == 0 */
6598 cmdline_fixed_string_t mode;
6601 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6602 __attribute__((unused)) struct cmdline *cl,
6605 struct cmd_set_allmulti_mode_result *res = parsed_result;
6609 if (!strcmp(res->mode, "on"))
6616 RTE_ETH_FOREACH_DEV(i) {
6617 eth_set_allmulticast_mode(i, enable);
6621 eth_set_allmulticast_mode(res->port_num, enable);
6625 cmdline_parse_token_string_t cmd_setallmulti_set =
6626 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6627 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6628 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6630 cmdline_parse_token_string_t cmd_setallmulti_portall =
6631 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6633 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6634 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6636 cmdline_parse_token_string_t cmd_setallmulti_mode =
6637 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6640 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6641 .f = cmd_set_allmulti_mode_parsed,
6643 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6645 (void *)&cmd_setallmulti_set,
6646 (void *)&cmd_setallmulti_allmulti,
6647 (void *)&cmd_setallmulti_portall,
6648 (void *)&cmd_setallmulti_mode,
6653 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6654 .f = cmd_set_allmulti_mode_parsed,
6656 .help_str = "set allmulti <port_id> on|off: "
6657 "Set allmulti mode on port_id",
6659 (void *)&cmd_setallmulti_set,
6660 (void *)&cmd_setallmulti_allmulti,
6661 (void *)&cmd_setallmulti_portnum,
6662 (void *)&cmd_setallmulti_mode,
6667 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6668 struct cmd_link_flow_ctrl_set_result {
6669 cmdline_fixed_string_t set;
6670 cmdline_fixed_string_t flow_ctrl;
6671 cmdline_fixed_string_t rx;
6672 cmdline_fixed_string_t rx_lfc_mode;
6673 cmdline_fixed_string_t tx;
6674 cmdline_fixed_string_t tx_lfc_mode;
6675 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6676 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6677 cmdline_fixed_string_t autoneg_str;
6678 cmdline_fixed_string_t autoneg;
6679 cmdline_fixed_string_t hw_str;
6680 uint32_t high_water;
6681 cmdline_fixed_string_t lw_str;
6683 cmdline_fixed_string_t pt_str;
6684 uint16_t pause_time;
6685 cmdline_fixed_string_t xon_str;
6690 cmdline_parse_token_string_t cmd_lfc_set_set =
6691 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6693 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6694 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6695 flow_ctrl, "flow_ctrl");
6696 cmdline_parse_token_string_t cmd_lfc_set_rx =
6697 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6699 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6700 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6701 rx_lfc_mode, "on#off");
6702 cmdline_parse_token_string_t cmd_lfc_set_tx =
6703 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6705 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6706 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6707 tx_lfc_mode, "on#off");
6708 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6709 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6710 hw_str, "high_water");
6711 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6712 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6713 high_water, UINT32);
6714 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6715 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6716 lw_str, "low_water");
6717 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6718 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6720 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6721 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6722 pt_str, "pause_time");
6723 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6724 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6725 pause_time, UINT16);
6726 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6727 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6728 xon_str, "send_xon");
6729 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6730 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6732 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6733 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6734 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6735 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6736 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6737 mac_ctrl_frame_fwd_mode, "on#off");
6738 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6739 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6740 autoneg_str, "autoneg");
6741 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6742 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6744 cmdline_parse_token_num_t cmd_lfc_set_portid =
6745 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6748 /* forward declaration */
6750 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6753 cmdline_parse_inst_t cmd_link_flow_control_set = {
6754 .f = cmd_link_flow_ctrl_set_parsed,
6756 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6757 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6758 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6760 (void *)&cmd_lfc_set_set,
6761 (void *)&cmd_lfc_set_flow_ctrl,
6762 (void *)&cmd_lfc_set_rx,
6763 (void *)&cmd_lfc_set_rx_mode,
6764 (void *)&cmd_lfc_set_tx,
6765 (void *)&cmd_lfc_set_tx_mode,
6766 (void *)&cmd_lfc_set_high_water,
6767 (void *)&cmd_lfc_set_low_water,
6768 (void *)&cmd_lfc_set_pause_time,
6769 (void *)&cmd_lfc_set_send_xon,
6770 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6771 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6772 (void *)&cmd_lfc_set_autoneg_str,
6773 (void *)&cmd_lfc_set_autoneg,
6774 (void *)&cmd_lfc_set_portid,
6779 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6780 .f = cmd_link_flow_ctrl_set_parsed,
6781 .data = (void *)&cmd_link_flow_control_set_rx,
6782 .help_str = "set flow_ctrl rx on|off <port_id>: "
6783 "Change rx flow control parameter",
6785 (void *)&cmd_lfc_set_set,
6786 (void *)&cmd_lfc_set_flow_ctrl,
6787 (void *)&cmd_lfc_set_rx,
6788 (void *)&cmd_lfc_set_rx_mode,
6789 (void *)&cmd_lfc_set_portid,
6794 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6795 .f = cmd_link_flow_ctrl_set_parsed,
6796 .data = (void *)&cmd_link_flow_control_set_tx,
6797 .help_str = "set flow_ctrl tx on|off <port_id>: "
6798 "Change tx flow control parameter",
6800 (void *)&cmd_lfc_set_set,
6801 (void *)&cmd_lfc_set_flow_ctrl,
6802 (void *)&cmd_lfc_set_tx,
6803 (void *)&cmd_lfc_set_tx_mode,
6804 (void *)&cmd_lfc_set_portid,
6809 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6810 .f = cmd_link_flow_ctrl_set_parsed,
6811 .data = (void *)&cmd_link_flow_control_set_hw,
6812 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6813 "Change high water flow control parameter",
6815 (void *)&cmd_lfc_set_set,
6816 (void *)&cmd_lfc_set_flow_ctrl,
6817 (void *)&cmd_lfc_set_high_water_str,
6818 (void *)&cmd_lfc_set_high_water,
6819 (void *)&cmd_lfc_set_portid,
6824 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6825 .f = cmd_link_flow_ctrl_set_parsed,
6826 .data = (void *)&cmd_link_flow_control_set_lw,
6827 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6828 "Change low water flow control parameter",
6830 (void *)&cmd_lfc_set_set,
6831 (void *)&cmd_lfc_set_flow_ctrl,
6832 (void *)&cmd_lfc_set_low_water_str,
6833 (void *)&cmd_lfc_set_low_water,
6834 (void *)&cmd_lfc_set_portid,
6839 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6840 .f = cmd_link_flow_ctrl_set_parsed,
6841 .data = (void *)&cmd_link_flow_control_set_pt,
6842 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6843 "Change pause time flow control parameter",
6845 (void *)&cmd_lfc_set_set,
6846 (void *)&cmd_lfc_set_flow_ctrl,
6847 (void *)&cmd_lfc_set_pause_time_str,
6848 (void *)&cmd_lfc_set_pause_time,
6849 (void *)&cmd_lfc_set_portid,
6854 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6855 .f = cmd_link_flow_ctrl_set_parsed,
6856 .data = (void *)&cmd_link_flow_control_set_xon,
6857 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6858 "Change send_xon flow control parameter",
6860 (void *)&cmd_lfc_set_set,
6861 (void *)&cmd_lfc_set_flow_ctrl,
6862 (void *)&cmd_lfc_set_send_xon_str,
6863 (void *)&cmd_lfc_set_send_xon,
6864 (void *)&cmd_lfc_set_portid,
6869 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6870 .f = cmd_link_flow_ctrl_set_parsed,
6871 .data = (void *)&cmd_link_flow_control_set_macfwd,
6872 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6873 "Change mac ctrl fwd flow control parameter",
6875 (void *)&cmd_lfc_set_set,
6876 (void *)&cmd_lfc_set_flow_ctrl,
6877 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6878 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6879 (void *)&cmd_lfc_set_portid,
6884 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6885 .f = cmd_link_flow_ctrl_set_parsed,
6886 .data = (void *)&cmd_link_flow_control_set_autoneg,
6887 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6888 "Change autoneg flow control parameter",
6890 (void *)&cmd_lfc_set_set,
6891 (void *)&cmd_lfc_set_flow_ctrl,
6892 (void *)&cmd_lfc_set_autoneg_str,
6893 (void *)&cmd_lfc_set_autoneg,
6894 (void *)&cmd_lfc_set_portid,
6900 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6901 __attribute__((unused)) struct cmdline *cl,
6904 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6905 cmdline_parse_inst_t *cmd = data;
6906 struct rte_eth_fc_conf fc_conf;
6912 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6913 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6914 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6915 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6917 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6918 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6921 /* Partial command line, retrieve current configuration */
6923 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6925 printf("cannot get current flow ctrl parameters, return"
6926 "code = %d\n", ret);
6930 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6931 (fc_conf.mode == RTE_FC_FULL))
6933 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6934 (fc_conf.mode == RTE_FC_FULL))
6938 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6939 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6941 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6942 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6944 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6946 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6947 fc_conf.high_water = res->high_water;
6949 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6950 fc_conf.low_water = res->low_water;
6952 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6953 fc_conf.pause_time = res->pause_time;
6955 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6956 fc_conf.send_xon = res->send_xon;
6958 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6959 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6960 fc_conf.mac_ctrl_frame_fwd = 1;
6962 fc_conf.mac_ctrl_frame_fwd = 0;
6965 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6966 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6968 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6970 printf("bad flow contrl parameter, return code = %d \n", ret);
6973 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6974 struct cmd_priority_flow_ctrl_set_result {
6975 cmdline_fixed_string_t set;
6976 cmdline_fixed_string_t pfc_ctrl;
6977 cmdline_fixed_string_t rx;
6978 cmdline_fixed_string_t rx_pfc_mode;
6979 cmdline_fixed_string_t tx;
6980 cmdline_fixed_string_t tx_pfc_mode;
6981 uint32_t high_water;
6983 uint16_t pause_time;
6989 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6990 __attribute__((unused)) struct cmdline *cl,
6991 __attribute__((unused)) void *data)
6993 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6994 struct rte_eth_pfc_conf pfc_conf;
6995 int rx_fc_enable, tx_fc_enable;
6999 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7000 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7001 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7002 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7004 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7005 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
7008 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7009 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7010 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7011 pfc_conf.fc.high_water = res->high_water;
7012 pfc_conf.fc.low_water = res->low_water;
7013 pfc_conf.fc.pause_time = res->pause_time;
7014 pfc_conf.priority = res->priority;
7016 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7018 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7021 cmdline_parse_token_string_t cmd_pfc_set_set =
7022 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7024 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7025 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7026 pfc_ctrl, "pfc_ctrl");
7027 cmdline_parse_token_string_t cmd_pfc_set_rx =
7028 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7030 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7031 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7032 rx_pfc_mode, "on#off");
7033 cmdline_parse_token_string_t cmd_pfc_set_tx =
7034 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7036 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7037 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7038 tx_pfc_mode, "on#off");
7039 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7040 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7041 high_water, UINT32);
7042 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7043 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7045 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7046 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7047 pause_time, UINT16);
7048 cmdline_parse_token_num_t cmd_pfc_set_priority =
7049 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7051 cmdline_parse_token_num_t cmd_pfc_set_portid =
7052 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7055 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7056 .f = cmd_priority_flow_ctrl_set_parsed,
7058 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7059 "<pause_time> <priority> <port_id>: "
7060 "Configure the Ethernet priority flow control",
7062 (void *)&cmd_pfc_set_set,
7063 (void *)&cmd_pfc_set_flow_ctrl,
7064 (void *)&cmd_pfc_set_rx,
7065 (void *)&cmd_pfc_set_rx_mode,
7066 (void *)&cmd_pfc_set_tx,
7067 (void *)&cmd_pfc_set_tx_mode,
7068 (void *)&cmd_pfc_set_high_water,
7069 (void *)&cmd_pfc_set_low_water,
7070 (void *)&cmd_pfc_set_pause_time,
7071 (void *)&cmd_pfc_set_priority,
7072 (void *)&cmd_pfc_set_portid,
7077 /* *** RESET CONFIGURATION *** */
7078 struct cmd_reset_result {
7079 cmdline_fixed_string_t reset;
7080 cmdline_fixed_string_t def;
7083 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
7085 __attribute__((unused)) void *data)
7087 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7088 set_def_fwd_config();
7091 cmdline_parse_token_string_t cmd_reset_set =
7092 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7093 cmdline_parse_token_string_t cmd_reset_def =
7094 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7097 cmdline_parse_inst_t cmd_reset = {
7098 .f = cmd_reset_parsed,
7100 .help_str = "set default: Reset default forwarding configuration",
7102 (void *)&cmd_reset_set,
7103 (void *)&cmd_reset_def,
7108 /* *** START FORWARDING *** */
7109 struct cmd_start_result {
7110 cmdline_fixed_string_t start;
7113 cmdline_parse_token_string_t cmd_start_start =
7114 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7116 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
7117 __attribute__((unused)) struct cmdline *cl,
7118 __attribute__((unused)) void *data)
7120 start_packet_forwarding(0);
7123 cmdline_parse_inst_t cmd_start = {
7124 .f = cmd_start_parsed,
7126 .help_str = "start: Start packet forwarding",
7128 (void *)&cmd_start_start,
7133 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7134 struct cmd_start_tx_first_result {
7135 cmdline_fixed_string_t start;
7136 cmdline_fixed_string_t tx_first;
7140 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
7141 __attribute__((unused)) struct cmdline *cl,
7142 __attribute__((unused)) void *data)
7144 start_packet_forwarding(1);
7147 cmdline_parse_token_string_t cmd_start_tx_first_start =
7148 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7150 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7151 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7152 tx_first, "tx_first");
7154 cmdline_parse_inst_t cmd_start_tx_first = {
7155 .f = cmd_start_tx_first_parsed,
7157 .help_str = "start tx_first: Start packet forwarding, "
7158 "after sending 1 burst of packets",
7160 (void *)&cmd_start_tx_first_start,
7161 (void *)&cmd_start_tx_first_tx_first,
7166 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7167 struct cmd_start_tx_first_n_result {
7168 cmdline_fixed_string_t start;
7169 cmdline_fixed_string_t tx_first;
7174 cmd_start_tx_first_n_parsed(void *parsed_result,
7175 __attribute__((unused)) struct cmdline *cl,
7176 __attribute__((unused)) void *data)
7178 struct cmd_start_tx_first_n_result *res = parsed_result;
7180 start_packet_forwarding(res->tx_num);
7183 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7184 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7186 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7187 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7188 tx_first, "tx_first");
7189 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7190 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7193 cmdline_parse_inst_t cmd_start_tx_first_n = {
7194 .f = cmd_start_tx_first_n_parsed,
7196 .help_str = "start tx_first <num>: "
7197 "packet forwarding, after sending <num> bursts of packets",
7199 (void *)&cmd_start_tx_first_n_start,
7200 (void *)&cmd_start_tx_first_n_tx_first,
7201 (void *)&cmd_start_tx_first_n_tx_num,
7206 /* *** SET LINK UP *** */
7207 struct cmd_set_link_up_result {
7208 cmdline_fixed_string_t set;
7209 cmdline_fixed_string_t link_up;
7210 cmdline_fixed_string_t port;
7214 cmdline_parse_token_string_t cmd_set_link_up_set =
7215 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7216 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7217 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7219 cmdline_parse_token_string_t cmd_set_link_up_port =
7220 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7221 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7222 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7224 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
7225 __attribute__((unused)) struct cmdline *cl,
7226 __attribute__((unused)) void *data)
7228 struct cmd_set_link_up_result *res = parsed_result;
7229 dev_set_link_up(res->port_id);
7232 cmdline_parse_inst_t cmd_set_link_up = {
7233 .f = cmd_set_link_up_parsed,
7235 .help_str = "set link-up port <port id>",
7237 (void *)&cmd_set_link_up_set,
7238 (void *)&cmd_set_link_up_link_up,
7239 (void *)&cmd_set_link_up_port,
7240 (void *)&cmd_set_link_up_port_id,
7245 /* *** SET LINK DOWN *** */
7246 struct cmd_set_link_down_result {
7247 cmdline_fixed_string_t set;
7248 cmdline_fixed_string_t link_down;
7249 cmdline_fixed_string_t port;
7253 cmdline_parse_token_string_t cmd_set_link_down_set =
7254 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7255 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7256 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7258 cmdline_parse_token_string_t cmd_set_link_down_port =
7259 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7260 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7261 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7263 static void cmd_set_link_down_parsed(
7264 __attribute__((unused)) void *parsed_result,
7265 __attribute__((unused)) struct cmdline *cl,
7266 __attribute__((unused)) void *data)
7268 struct cmd_set_link_down_result *res = parsed_result;
7269 dev_set_link_down(res->port_id);
7272 cmdline_parse_inst_t cmd_set_link_down = {
7273 .f = cmd_set_link_down_parsed,
7275 .help_str = "set link-down port <port id>",
7277 (void *)&cmd_set_link_down_set,
7278 (void *)&cmd_set_link_down_link_down,
7279 (void *)&cmd_set_link_down_port,
7280 (void *)&cmd_set_link_down_port_id,
7285 /* *** SHOW CFG *** */
7286 struct cmd_showcfg_result {
7287 cmdline_fixed_string_t show;
7288 cmdline_fixed_string_t cfg;
7289 cmdline_fixed_string_t what;
7292 static void cmd_showcfg_parsed(void *parsed_result,
7293 __attribute__((unused)) struct cmdline *cl,
7294 __attribute__((unused)) void *data)
7296 struct cmd_showcfg_result *res = parsed_result;
7297 if (!strcmp(res->what, "rxtx"))
7298 rxtx_config_display();
7299 else if (!strcmp(res->what, "cores"))
7300 fwd_lcores_config_display();
7301 else if (!strcmp(res->what, "fwd"))
7302 pkt_fwd_config_display(&cur_fwd_config);
7303 else if (!strcmp(res->what, "txpkts"))
7304 show_tx_pkt_segments();
7307 cmdline_parse_token_string_t cmd_showcfg_show =
7308 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7309 cmdline_parse_token_string_t cmd_showcfg_port =
7310 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7311 cmdline_parse_token_string_t cmd_showcfg_what =
7312 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7313 "rxtx#cores#fwd#txpkts");
7315 cmdline_parse_inst_t cmd_showcfg = {
7316 .f = cmd_showcfg_parsed,
7318 .help_str = "show config rxtx|cores|fwd|txpkts",
7320 (void *)&cmd_showcfg_show,
7321 (void *)&cmd_showcfg_port,
7322 (void *)&cmd_showcfg_what,
7327 /* *** SHOW ALL PORT INFO *** */
7328 struct cmd_showportall_result {
7329 cmdline_fixed_string_t show;
7330 cmdline_fixed_string_t port;
7331 cmdline_fixed_string_t what;
7332 cmdline_fixed_string_t all;
7335 static void cmd_showportall_parsed(void *parsed_result,
7336 __attribute__((unused)) struct cmdline *cl,
7337 __attribute__((unused)) void *data)
7341 struct cmd_showportall_result *res = parsed_result;
7342 if (!strcmp(res->show, "clear")) {
7343 if (!strcmp(res->what, "stats"))
7344 RTE_ETH_FOREACH_DEV(i)
7346 else if (!strcmp(res->what, "xstats"))
7347 RTE_ETH_FOREACH_DEV(i)
7348 nic_xstats_clear(i);
7349 } else if (!strcmp(res->what, "info"))
7350 RTE_ETH_FOREACH_DEV(i)
7351 port_infos_display(i);
7352 else if (!strcmp(res->what, "summary")) {
7353 port_summary_header_display();
7354 RTE_ETH_FOREACH_DEV(i)
7355 port_summary_display(i);
7357 else if (!strcmp(res->what, "stats"))
7358 RTE_ETH_FOREACH_DEV(i)
7359 nic_stats_display(i);
7360 else if (!strcmp(res->what, "xstats"))
7361 RTE_ETH_FOREACH_DEV(i)
7362 nic_xstats_display(i);
7363 else if (!strcmp(res->what, "fdir"))
7364 RTE_ETH_FOREACH_DEV(i)
7366 else if (!strcmp(res->what, "stat_qmap"))
7367 RTE_ETH_FOREACH_DEV(i)
7368 nic_stats_mapping_display(i);
7369 else if (!strcmp(res->what, "dcb_tc"))
7370 RTE_ETH_FOREACH_DEV(i)
7371 port_dcb_info_display(i);
7372 else if (!strcmp(res->what, "cap"))
7373 RTE_ETH_FOREACH_DEV(i)
7374 port_offload_cap_display(i);
7377 cmdline_parse_token_string_t cmd_showportall_show =
7378 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7380 cmdline_parse_token_string_t cmd_showportall_port =
7381 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7382 cmdline_parse_token_string_t cmd_showportall_what =
7383 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7384 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7385 cmdline_parse_token_string_t cmd_showportall_all =
7386 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7387 cmdline_parse_inst_t cmd_showportall = {
7388 .f = cmd_showportall_parsed,
7390 .help_str = "show|clear port "
7391 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7393 (void *)&cmd_showportall_show,
7394 (void *)&cmd_showportall_port,
7395 (void *)&cmd_showportall_what,
7396 (void *)&cmd_showportall_all,
7401 /* *** SHOW PORT INFO *** */
7402 struct cmd_showport_result {
7403 cmdline_fixed_string_t show;
7404 cmdline_fixed_string_t port;
7405 cmdline_fixed_string_t what;
7409 static void cmd_showport_parsed(void *parsed_result,
7410 __attribute__((unused)) struct cmdline *cl,
7411 __attribute__((unused)) void *data)
7413 struct cmd_showport_result *res = parsed_result;
7414 if (!strcmp(res->show, "clear")) {
7415 if (!strcmp(res->what, "stats"))
7416 nic_stats_clear(res->portnum);
7417 else if (!strcmp(res->what, "xstats"))
7418 nic_xstats_clear(res->portnum);
7419 } else if (!strcmp(res->what, "info"))
7420 port_infos_display(res->portnum);
7421 else if (!strcmp(res->what, "summary")) {
7422 port_summary_header_display();
7423 port_summary_display(res->portnum);
7425 else if (!strcmp(res->what, "stats"))
7426 nic_stats_display(res->portnum);
7427 else if (!strcmp(res->what, "xstats"))
7428 nic_xstats_display(res->portnum);
7429 else if (!strcmp(res->what, "fdir"))
7430 fdir_get_infos(res->portnum);
7431 else if (!strcmp(res->what, "stat_qmap"))
7432 nic_stats_mapping_display(res->portnum);
7433 else if (!strcmp(res->what, "dcb_tc"))
7434 port_dcb_info_display(res->portnum);
7435 else if (!strcmp(res->what, "cap"))
7436 port_offload_cap_display(res->portnum);
7439 cmdline_parse_token_string_t cmd_showport_show =
7440 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7442 cmdline_parse_token_string_t cmd_showport_port =
7443 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7444 cmdline_parse_token_string_t cmd_showport_what =
7445 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7446 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7447 cmdline_parse_token_num_t cmd_showport_portnum =
7448 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7450 cmdline_parse_inst_t cmd_showport = {
7451 .f = cmd_showport_parsed,
7453 .help_str = "show|clear port "
7454 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7457 (void *)&cmd_showport_show,
7458 (void *)&cmd_showport_port,
7459 (void *)&cmd_showport_what,
7460 (void *)&cmd_showport_portnum,
7465 /* *** SHOW DEVICE INFO *** */
7466 struct cmd_showdevice_result {
7467 cmdline_fixed_string_t show;
7468 cmdline_fixed_string_t device;
7469 cmdline_fixed_string_t what;
7470 cmdline_fixed_string_t identifier;
7473 static void cmd_showdevice_parsed(void *parsed_result,
7474 __attribute__((unused)) struct cmdline *cl,
7475 __attribute__((unused)) void *data)
7477 struct cmd_showdevice_result *res = parsed_result;
7478 if (!strcmp(res->what, "info")) {
7479 if (!strcmp(res->identifier, "all"))
7480 device_infos_display(NULL);
7482 device_infos_display(res->identifier);
7486 cmdline_parse_token_string_t cmd_showdevice_show =
7487 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7489 cmdline_parse_token_string_t cmd_showdevice_device =
7490 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7491 cmdline_parse_token_string_t cmd_showdevice_what =
7492 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7494 cmdline_parse_token_string_t cmd_showdevice_identifier =
7495 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7498 cmdline_parse_inst_t cmd_showdevice = {
7499 .f = cmd_showdevice_parsed,
7501 .help_str = "show device info <identifier>|all",
7503 (void *)&cmd_showdevice_show,
7504 (void *)&cmd_showdevice_device,
7505 (void *)&cmd_showdevice_what,
7506 (void *)&cmd_showdevice_identifier,
7510 /* *** SHOW QUEUE INFO *** */
7511 struct cmd_showqueue_result {
7512 cmdline_fixed_string_t show;
7513 cmdline_fixed_string_t type;
7514 cmdline_fixed_string_t what;
7520 cmd_showqueue_parsed(void *parsed_result,
7521 __attribute__((unused)) struct cmdline *cl,
7522 __attribute__((unused)) void *data)
7524 struct cmd_showqueue_result *res = parsed_result;
7526 if (!strcmp(res->type, "rxq"))
7527 rx_queue_infos_display(res->portnum, res->queuenum);
7528 else if (!strcmp(res->type, "txq"))
7529 tx_queue_infos_display(res->portnum, res->queuenum);
7532 cmdline_parse_token_string_t cmd_showqueue_show =
7533 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7534 cmdline_parse_token_string_t cmd_showqueue_type =
7535 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7536 cmdline_parse_token_string_t cmd_showqueue_what =
7537 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7538 cmdline_parse_token_num_t cmd_showqueue_portnum =
7539 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7540 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7541 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7543 cmdline_parse_inst_t cmd_showqueue = {
7544 .f = cmd_showqueue_parsed,
7546 .help_str = "show rxq|txq info <port_id> <queue_id>",
7548 (void *)&cmd_showqueue_show,
7549 (void *)&cmd_showqueue_type,
7550 (void *)&cmd_showqueue_what,
7551 (void *)&cmd_showqueue_portnum,
7552 (void *)&cmd_showqueue_queuenum,
7557 /* show/clear fwd engine statistics */
7559 cmdline_fixed_string_t action;
7560 cmdline_fixed_string_t fwd;
7561 cmdline_fixed_string_t stats;
7562 cmdline_fixed_string_t all;
7565 cmdline_parse_token_string_t cmd_fwd_action =
7566 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7567 cmdline_parse_token_string_t cmd_fwd_fwd =
7568 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7569 cmdline_parse_token_string_t cmd_fwd_stats =
7570 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7571 cmdline_parse_token_string_t cmd_fwd_all =
7572 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7575 cmd_showfwdall_parsed(void *parsed_result,
7576 __rte_unused struct cmdline *cl,
7577 __rte_unused void *data)
7579 struct fwd_result *res = parsed_result;
7581 if (!strcmp(res->action, "show"))
7582 fwd_stats_display();
7587 static cmdline_parse_inst_t cmd_showfwdall = {
7588 .f = cmd_showfwdall_parsed,
7590 .help_str = "show|clear fwd stats all",
7592 (void *)&cmd_fwd_action,
7593 (void *)&cmd_fwd_fwd,
7594 (void *)&cmd_fwd_stats,
7595 (void *)&cmd_fwd_all,
7600 /* *** READ PORT REGISTER *** */
7601 struct cmd_read_reg_result {
7602 cmdline_fixed_string_t read;
7603 cmdline_fixed_string_t reg;
7609 cmd_read_reg_parsed(void *parsed_result,
7610 __attribute__((unused)) struct cmdline *cl,
7611 __attribute__((unused)) void *data)
7613 struct cmd_read_reg_result *res = parsed_result;
7614 port_reg_display(res->port_id, res->reg_off);
7617 cmdline_parse_token_string_t cmd_read_reg_read =
7618 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7619 cmdline_parse_token_string_t cmd_read_reg_reg =
7620 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7621 cmdline_parse_token_num_t cmd_read_reg_port_id =
7622 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7623 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7624 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7626 cmdline_parse_inst_t cmd_read_reg = {
7627 .f = cmd_read_reg_parsed,
7629 .help_str = "read reg <port_id> <reg_off>",
7631 (void *)&cmd_read_reg_read,
7632 (void *)&cmd_read_reg_reg,
7633 (void *)&cmd_read_reg_port_id,
7634 (void *)&cmd_read_reg_reg_off,
7639 /* *** READ PORT REGISTER BIT FIELD *** */
7640 struct cmd_read_reg_bit_field_result {
7641 cmdline_fixed_string_t read;
7642 cmdline_fixed_string_t regfield;
7650 cmd_read_reg_bit_field_parsed(void *parsed_result,
7651 __attribute__((unused)) struct cmdline *cl,
7652 __attribute__((unused)) void *data)
7654 struct cmd_read_reg_bit_field_result *res = parsed_result;
7655 port_reg_bit_field_display(res->port_id, res->reg_off,
7656 res->bit1_pos, res->bit2_pos);
7659 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7660 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7662 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7663 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7664 regfield, "regfield");
7665 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7666 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7668 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7669 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7671 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7672 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7674 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7675 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7678 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7679 .f = cmd_read_reg_bit_field_parsed,
7681 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7682 "Read register bit field between bit_x and bit_y included",
7684 (void *)&cmd_read_reg_bit_field_read,
7685 (void *)&cmd_read_reg_bit_field_regfield,
7686 (void *)&cmd_read_reg_bit_field_port_id,
7687 (void *)&cmd_read_reg_bit_field_reg_off,
7688 (void *)&cmd_read_reg_bit_field_bit1_pos,
7689 (void *)&cmd_read_reg_bit_field_bit2_pos,
7694 /* *** READ PORT REGISTER BIT *** */
7695 struct cmd_read_reg_bit_result {
7696 cmdline_fixed_string_t read;
7697 cmdline_fixed_string_t regbit;
7704 cmd_read_reg_bit_parsed(void *parsed_result,
7705 __attribute__((unused)) struct cmdline *cl,
7706 __attribute__((unused)) void *data)
7708 struct cmd_read_reg_bit_result *res = parsed_result;
7709 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7712 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7713 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7714 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7715 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7717 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7718 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7719 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7720 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7721 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7722 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7724 cmdline_parse_inst_t cmd_read_reg_bit = {
7725 .f = cmd_read_reg_bit_parsed,
7727 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7729 (void *)&cmd_read_reg_bit_read,
7730 (void *)&cmd_read_reg_bit_regbit,
7731 (void *)&cmd_read_reg_bit_port_id,
7732 (void *)&cmd_read_reg_bit_reg_off,
7733 (void *)&cmd_read_reg_bit_bit_pos,
7738 /* *** WRITE PORT REGISTER *** */
7739 struct cmd_write_reg_result {
7740 cmdline_fixed_string_t write;
7741 cmdline_fixed_string_t reg;
7748 cmd_write_reg_parsed(void *parsed_result,
7749 __attribute__((unused)) struct cmdline *cl,
7750 __attribute__((unused)) void *data)
7752 struct cmd_write_reg_result *res = parsed_result;
7753 port_reg_set(res->port_id, res->reg_off, res->value);
7756 cmdline_parse_token_string_t cmd_write_reg_write =
7757 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7758 cmdline_parse_token_string_t cmd_write_reg_reg =
7759 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7760 cmdline_parse_token_num_t cmd_write_reg_port_id =
7761 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7762 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7763 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7764 cmdline_parse_token_num_t cmd_write_reg_value =
7765 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7767 cmdline_parse_inst_t cmd_write_reg = {
7768 .f = cmd_write_reg_parsed,
7770 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7772 (void *)&cmd_write_reg_write,
7773 (void *)&cmd_write_reg_reg,
7774 (void *)&cmd_write_reg_port_id,
7775 (void *)&cmd_write_reg_reg_off,
7776 (void *)&cmd_write_reg_value,
7781 /* *** WRITE PORT REGISTER BIT FIELD *** */
7782 struct cmd_write_reg_bit_field_result {
7783 cmdline_fixed_string_t write;
7784 cmdline_fixed_string_t regfield;
7793 cmd_write_reg_bit_field_parsed(void *parsed_result,
7794 __attribute__((unused)) struct cmdline *cl,
7795 __attribute__((unused)) void *data)
7797 struct cmd_write_reg_bit_field_result *res = parsed_result;
7798 port_reg_bit_field_set(res->port_id, res->reg_off,
7799 res->bit1_pos, res->bit2_pos, res->value);
7802 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7803 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7805 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7806 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7807 regfield, "regfield");
7808 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7809 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7811 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7812 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7814 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7815 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7817 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7818 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7820 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7821 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7824 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7825 .f = cmd_write_reg_bit_field_parsed,
7827 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7829 "Set register bit field between bit_x and bit_y included",
7831 (void *)&cmd_write_reg_bit_field_write,
7832 (void *)&cmd_write_reg_bit_field_regfield,
7833 (void *)&cmd_write_reg_bit_field_port_id,
7834 (void *)&cmd_write_reg_bit_field_reg_off,
7835 (void *)&cmd_write_reg_bit_field_bit1_pos,
7836 (void *)&cmd_write_reg_bit_field_bit2_pos,
7837 (void *)&cmd_write_reg_bit_field_value,
7842 /* *** WRITE PORT REGISTER BIT *** */
7843 struct cmd_write_reg_bit_result {
7844 cmdline_fixed_string_t write;
7845 cmdline_fixed_string_t regbit;
7853 cmd_write_reg_bit_parsed(void *parsed_result,
7854 __attribute__((unused)) struct cmdline *cl,
7855 __attribute__((unused)) void *data)
7857 struct cmd_write_reg_bit_result *res = parsed_result;
7858 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7861 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7862 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7864 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7865 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7867 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7868 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7869 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7870 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7871 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7872 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7873 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7874 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7876 cmdline_parse_inst_t cmd_write_reg_bit = {
7877 .f = cmd_write_reg_bit_parsed,
7879 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7882 (void *)&cmd_write_reg_bit_write,
7883 (void *)&cmd_write_reg_bit_regbit,
7884 (void *)&cmd_write_reg_bit_port_id,
7885 (void *)&cmd_write_reg_bit_reg_off,
7886 (void *)&cmd_write_reg_bit_bit_pos,
7887 (void *)&cmd_write_reg_bit_value,
7892 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7893 struct cmd_read_rxd_txd_result {
7894 cmdline_fixed_string_t read;
7895 cmdline_fixed_string_t rxd_txd;
7902 cmd_read_rxd_txd_parsed(void *parsed_result,
7903 __attribute__((unused)) struct cmdline *cl,
7904 __attribute__((unused)) void *data)
7906 struct cmd_read_rxd_txd_result *res = parsed_result;
7908 if (!strcmp(res->rxd_txd, "rxd"))
7909 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7910 else if (!strcmp(res->rxd_txd, "txd"))
7911 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7914 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7915 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7916 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7917 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7919 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7920 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7921 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7922 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7923 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7924 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7926 cmdline_parse_inst_t cmd_read_rxd_txd = {
7927 .f = cmd_read_rxd_txd_parsed,
7929 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7931 (void *)&cmd_read_rxd_txd_read,
7932 (void *)&cmd_read_rxd_txd_rxd_txd,
7933 (void *)&cmd_read_rxd_txd_port_id,
7934 (void *)&cmd_read_rxd_txd_queue_id,
7935 (void *)&cmd_read_rxd_txd_desc_id,
7941 struct cmd_quit_result {
7942 cmdline_fixed_string_t quit;
7945 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7947 __attribute__((unused)) void *data)
7952 cmdline_parse_token_string_t cmd_quit_quit =
7953 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7955 cmdline_parse_inst_t cmd_quit = {
7956 .f = cmd_quit_parsed,
7958 .help_str = "quit: Exit application",
7960 (void *)&cmd_quit_quit,
7965 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7966 struct cmd_mac_addr_result {
7967 cmdline_fixed_string_t mac_addr_cmd;
7968 cmdline_fixed_string_t what;
7970 struct rte_ether_addr address;
7973 static void cmd_mac_addr_parsed(void *parsed_result,
7974 __attribute__((unused)) struct cmdline *cl,
7975 __attribute__((unused)) void *data)
7977 struct cmd_mac_addr_result *res = parsed_result;
7980 if (strcmp(res->what, "add") == 0)
7981 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7982 else if (strcmp(res->what, "set") == 0)
7983 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7986 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7988 /* check the return value and print it if is < 0 */
7990 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7994 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7995 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7997 cmdline_parse_token_string_t cmd_mac_addr_what =
7998 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8000 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8001 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8003 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8004 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8006 cmdline_parse_inst_t cmd_mac_addr = {
8007 .f = cmd_mac_addr_parsed,
8009 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8010 "Add/Remove/Set MAC address on port_id",
8012 (void *)&cmd_mac_addr_cmd,
8013 (void *)&cmd_mac_addr_what,
8014 (void *)&cmd_mac_addr_portnum,
8015 (void *)&cmd_mac_addr_addr,
8020 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8021 struct cmd_eth_peer_result {
8022 cmdline_fixed_string_t set;
8023 cmdline_fixed_string_t eth_peer;
8025 cmdline_fixed_string_t peer_addr;
8028 static void cmd_set_eth_peer_parsed(void *parsed_result,
8029 __attribute__((unused)) struct cmdline *cl,
8030 __attribute__((unused)) void *data)
8032 struct cmd_eth_peer_result *res = parsed_result;
8034 if (test_done == 0) {
8035 printf("Please stop forwarding first\n");
8038 if (!strcmp(res->eth_peer, "eth-peer")) {
8039 set_fwd_eth_peer(res->port_id, res->peer_addr);
8043 cmdline_parse_token_string_t cmd_eth_peer_set =
8044 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8045 cmdline_parse_token_string_t cmd_eth_peer =
8046 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8047 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8048 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8049 cmdline_parse_token_string_t cmd_eth_peer_addr =
8050 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8052 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8053 .f = cmd_set_eth_peer_parsed,
8055 .help_str = "set eth-peer <port_id> <peer_mac>",
8057 (void *)&cmd_eth_peer_set,
8058 (void *)&cmd_eth_peer,
8059 (void *)&cmd_eth_peer_port_id,
8060 (void *)&cmd_eth_peer_addr,
8065 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8066 struct cmd_set_qmap_result {
8067 cmdline_fixed_string_t set;
8068 cmdline_fixed_string_t qmap;
8069 cmdline_fixed_string_t what;
8076 cmd_set_qmap_parsed(void *parsed_result,
8077 __attribute__((unused)) struct cmdline *cl,
8078 __attribute__((unused)) void *data)
8080 struct cmd_set_qmap_result *res = parsed_result;
8081 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8083 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8086 cmdline_parse_token_string_t cmd_setqmap_set =
8087 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8089 cmdline_parse_token_string_t cmd_setqmap_qmap =
8090 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8092 cmdline_parse_token_string_t cmd_setqmap_what =
8093 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8095 cmdline_parse_token_num_t cmd_setqmap_portid =
8096 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8098 cmdline_parse_token_num_t cmd_setqmap_queueid =
8099 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8101 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8102 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8105 cmdline_parse_inst_t cmd_set_qmap = {
8106 .f = cmd_set_qmap_parsed,
8108 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8109 "Set statistics mapping value on tx|rx queue_id of port_id",
8111 (void *)&cmd_setqmap_set,
8112 (void *)&cmd_setqmap_qmap,
8113 (void *)&cmd_setqmap_what,
8114 (void *)&cmd_setqmap_portid,
8115 (void *)&cmd_setqmap_queueid,
8116 (void *)&cmd_setqmap_mapvalue,
8121 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8122 struct cmd_set_xstats_hide_zero_result {
8123 cmdline_fixed_string_t keyword;
8124 cmdline_fixed_string_t name;
8125 cmdline_fixed_string_t on_off;
8129 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8130 __attribute__((unused)) struct cmdline *cl,
8131 __attribute__((unused)) void *data)
8133 struct cmd_set_xstats_hide_zero_result *res;
8134 uint16_t on_off = 0;
8136 res = parsed_result;
8137 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8138 set_xstats_hide_zero(on_off);
8141 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8142 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8144 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8145 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8146 name, "xstats-hide-zero");
8147 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8148 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8151 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8152 .f = cmd_set_xstats_hide_zero_parsed,
8154 .help_str = "set xstats-hide-zero on|off",
8156 (void *)&cmd_set_xstats_hide_zero_keyword,
8157 (void *)&cmd_set_xstats_hide_zero_name,
8158 (void *)&cmd_set_xstats_hide_zero_on_off,
8163 /* *** CONFIGURE UNICAST HASH TABLE *** */
8164 struct cmd_set_uc_hash_table {
8165 cmdline_fixed_string_t set;
8166 cmdline_fixed_string_t port;
8168 cmdline_fixed_string_t what;
8169 struct rte_ether_addr address;
8170 cmdline_fixed_string_t mode;
8174 cmd_set_uc_hash_parsed(void *parsed_result,
8175 __attribute__((unused)) struct cmdline *cl,
8176 __attribute__((unused)) void *data)
8179 struct cmd_set_uc_hash_table *res = parsed_result;
8181 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8183 if (strcmp(res->what, "uta") == 0)
8184 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8185 &res->address,(uint8_t)is_on);
8187 printf("bad unicast hash table parameter, return code = %d \n", ret);
8191 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8192 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8194 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8195 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8197 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8198 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8200 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8201 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8203 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8204 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8206 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8207 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8210 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8211 .f = cmd_set_uc_hash_parsed,
8213 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8215 (void *)&cmd_set_uc_hash_set,
8216 (void *)&cmd_set_uc_hash_port,
8217 (void *)&cmd_set_uc_hash_portid,
8218 (void *)&cmd_set_uc_hash_what,
8219 (void *)&cmd_set_uc_hash_mac,
8220 (void *)&cmd_set_uc_hash_mode,
8225 struct cmd_set_uc_all_hash_table {
8226 cmdline_fixed_string_t set;
8227 cmdline_fixed_string_t port;
8229 cmdline_fixed_string_t what;
8230 cmdline_fixed_string_t value;
8231 cmdline_fixed_string_t mode;
8235 cmd_set_uc_all_hash_parsed(void *parsed_result,
8236 __attribute__((unused)) struct cmdline *cl,
8237 __attribute__((unused)) void *data)
8240 struct cmd_set_uc_all_hash_table *res = parsed_result;
8242 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8244 if ((strcmp(res->what, "uta") == 0) &&
8245 (strcmp(res->value, "all") == 0))
8246 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8248 printf("bad unicast hash table parameter,"
8249 "return code = %d \n", ret);
8252 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8253 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8255 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8256 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8258 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8259 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8261 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8262 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8264 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8265 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8267 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8268 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8271 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8272 .f = cmd_set_uc_all_hash_parsed,
8274 .help_str = "set port <port_id> uta all on|off",
8276 (void *)&cmd_set_uc_all_hash_set,
8277 (void *)&cmd_set_uc_all_hash_port,
8278 (void *)&cmd_set_uc_all_hash_portid,
8279 (void *)&cmd_set_uc_all_hash_what,
8280 (void *)&cmd_set_uc_all_hash_value,
8281 (void *)&cmd_set_uc_all_hash_mode,
8286 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8287 struct cmd_set_vf_macvlan_filter {
8288 cmdline_fixed_string_t set;
8289 cmdline_fixed_string_t port;
8291 cmdline_fixed_string_t vf;
8293 struct rte_ether_addr address;
8294 cmdline_fixed_string_t filter_type;
8295 cmdline_fixed_string_t mode;
8299 cmd_set_vf_macvlan_parsed(void *parsed_result,
8300 __attribute__((unused)) struct cmdline *cl,
8301 __attribute__((unused)) void *data)
8304 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8305 struct rte_eth_mac_filter filter;
8307 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8309 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8311 /* set VF MAC filter */
8315 filter.dst_id = res->vf_id;
8317 if (!strcmp(res->filter_type, "exact-mac"))
8318 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8319 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8320 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8321 else if (!strcmp(res->filter_type, "hashmac"))
8322 filter.filter_type = RTE_MAC_HASH_MATCH;
8323 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8324 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8326 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8329 ret = rte_eth_dev_filter_ctrl(res->port_id,
8330 RTE_ETH_FILTER_MACVLAN,
8334 ret = rte_eth_dev_filter_ctrl(res->port_id,
8335 RTE_ETH_FILTER_MACVLAN,
8336 RTE_ETH_FILTER_DELETE,
8340 printf("bad set MAC hash parameter, return code = %d\n", ret);
8344 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8345 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8347 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8348 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8350 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8351 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8353 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8354 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8356 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8357 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8359 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8360 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8362 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8363 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8364 filter_type, "exact-mac#exact-mac-vlan"
8365 "#hashmac#hashmac-vlan");
8366 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8367 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8370 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8371 .f = cmd_set_vf_macvlan_parsed,
8373 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8374 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8375 "Exact match rule: exact match of MAC or MAC and VLAN; "
8376 "hash match rule: hash match of MAC and exact match of VLAN",
8378 (void *)&cmd_set_vf_macvlan_set,
8379 (void *)&cmd_set_vf_macvlan_port,
8380 (void *)&cmd_set_vf_macvlan_portid,
8381 (void *)&cmd_set_vf_macvlan_vf,
8382 (void *)&cmd_set_vf_macvlan_vf_id,
8383 (void *)&cmd_set_vf_macvlan_mac,
8384 (void *)&cmd_set_vf_macvlan_filter_type,
8385 (void *)&cmd_set_vf_macvlan_mode,
8390 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8391 struct cmd_set_vf_traffic {
8392 cmdline_fixed_string_t set;
8393 cmdline_fixed_string_t port;
8395 cmdline_fixed_string_t vf;
8397 cmdline_fixed_string_t what;
8398 cmdline_fixed_string_t mode;
8402 cmd_set_vf_traffic_parsed(void *parsed_result,
8403 __attribute__((unused)) struct cmdline *cl,
8404 __attribute__((unused)) void *data)
8406 struct cmd_set_vf_traffic *res = parsed_result;
8407 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8408 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8410 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8413 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8414 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8416 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8417 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8419 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8420 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8422 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8423 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8425 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8426 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8428 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8429 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8431 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8432 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8435 cmdline_parse_inst_t cmd_set_vf_traffic = {
8436 .f = cmd_set_vf_traffic_parsed,
8438 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8440 (void *)&cmd_setvf_traffic_set,
8441 (void *)&cmd_setvf_traffic_port,
8442 (void *)&cmd_setvf_traffic_portid,
8443 (void *)&cmd_setvf_traffic_vf,
8444 (void *)&cmd_setvf_traffic_vfid,
8445 (void *)&cmd_setvf_traffic_what,
8446 (void *)&cmd_setvf_traffic_mode,
8451 /* *** CONFIGURE VF RECEIVE MODE *** */
8452 struct cmd_set_vf_rxmode {
8453 cmdline_fixed_string_t set;
8454 cmdline_fixed_string_t port;
8456 cmdline_fixed_string_t vf;
8458 cmdline_fixed_string_t what;
8459 cmdline_fixed_string_t mode;
8460 cmdline_fixed_string_t on;
8464 cmd_set_vf_rxmode_parsed(void *parsed_result,
8465 __attribute__((unused)) struct cmdline *cl,
8466 __attribute__((unused)) void *data)
8469 uint16_t vf_rxmode = 0;
8470 struct cmd_set_vf_rxmode *res = parsed_result;
8472 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8473 if (!strcmp(res->what,"rxmode")) {
8474 if (!strcmp(res->mode, "AUPE"))
8475 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8476 else if (!strcmp(res->mode, "ROPE"))
8477 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8478 else if (!strcmp(res->mode, "BAM"))
8479 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8480 else if (!strncmp(res->mode, "MPE",3))
8481 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8484 RTE_SET_USED(is_on);
8486 #ifdef RTE_LIBRTE_IXGBE_PMD
8487 if (ret == -ENOTSUP)
8488 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8489 vf_rxmode, (uint8_t)is_on);
8491 #ifdef RTE_LIBRTE_BNXT_PMD
8492 if (ret == -ENOTSUP)
8493 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8494 vf_rxmode, (uint8_t)is_on);
8497 printf("bad VF receive mode parameter, return code = %d \n",
8501 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8502 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8504 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8505 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8507 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8508 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8510 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8511 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8513 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8514 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8516 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8517 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8519 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8520 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8521 mode, "AUPE#ROPE#BAM#MPE");
8522 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8523 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8526 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8527 .f = cmd_set_vf_rxmode_parsed,
8529 .help_str = "set port <port_id> vf <vf_id> rxmode "
8530 "AUPE|ROPE|BAM|MPE on|off",
8532 (void *)&cmd_set_vf_rxmode_set,
8533 (void *)&cmd_set_vf_rxmode_port,
8534 (void *)&cmd_set_vf_rxmode_portid,
8535 (void *)&cmd_set_vf_rxmode_vf,
8536 (void *)&cmd_set_vf_rxmode_vfid,
8537 (void *)&cmd_set_vf_rxmode_what,
8538 (void *)&cmd_set_vf_rxmode_mode,
8539 (void *)&cmd_set_vf_rxmode_on,
8544 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8545 struct cmd_vf_mac_addr_result {
8546 cmdline_fixed_string_t mac_addr_cmd;
8547 cmdline_fixed_string_t what;
8548 cmdline_fixed_string_t port;
8550 cmdline_fixed_string_t vf;
8552 struct rte_ether_addr address;
8555 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8556 __attribute__((unused)) struct cmdline *cl,
8557 __attribute__((unused)) void *data)
8559 struct cmd_vf_mac_addr_result *res = parsed_result;
8562 if (strcmp(res->what, "add") != 0)
8565 #ifdef RTE_LIBRTE_I40E_PMD
8566 if (ret == -ENOTSUP)
8567 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8570 #ifdef RTE_LIBRTE_BNXT_PMD
8571 if (ret == -ENOTSUP)
8572 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8577 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8581 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8582 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8583 mac_addr_cmd,"mac_addr");
8584 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8585 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8587 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8588 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8590 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8591 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8593 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8594 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8596 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8597 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8599 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8600 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8603 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8604 .f = cmd_vf_mac_addr_parsed,
8606 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8607 "Add MAC address filtering for a VF on port_id",
8609 (void *)&cmd_vf_mac_addr_cmd,
8610 (void *)&cmd_vf_mac_addr_what,
8611 (void *)&cmd_vf_mac_addr_port,
8612 (void *)&cmd_vf_mac_addr_portnum,
8613 (void *)&cmd_vf_mac_addr_vf,
8614 (void *)&cmd_vf_mac_addr_vfnum,
8615 (void *)&cmd_vf_mac_addr_addr,
8620 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8621 struct cmd_vf_rx_vlan_filter {
8622 cmdline_fixed_string_t rx_vlan;
8623 cmdline_fixed_string_t what;
8625 cmdline_fixed_string_t port;
8627 cmdline_fixed_string_t vf;
8632 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8633 __attribute__((unused)) struct cmdline *cl,
8634 __attribute__((unused)) void *data)
8636 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8639 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8641 #ifdef RTE_LIBRTE_IXGBE_PMD
8642 if (ret == -ENOTSUP)
8643 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8644 res->vlan_id, res->vf_mask, is_add);
8646 #ifdef RTE_LIBRTE_I40E_PMD
8647 if (ret == -ENOTSUP)
8648 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8649 res->vlan_id, res->vf_mask, is_add);
8651 #ifdef RTE_LIBRTE_BNXT_PMD
8652 if (ret == -ENOTSUP)
8653 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8654 res->vlan_id, res->vf_mask, is_add);
8661 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8662 res->vlan_id, res->vf_mask);
8665 printf("invalid port_id %d\n", res->port_id);
8668 printf("function not implemented or supported\n");
8671 printf("programming error: (%s)\n", strerror(-ret));
8675 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8676 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8677 rx_vlan, "rx_vlan");
8678 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8679 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8681 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8682 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8684 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8685 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8687 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8688 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8690 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8691 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8693 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8694 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8697 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8698 .f = cmd_vf_rx_vlan_filter_parsed,
8700 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8701 "(vf_mask = hexadecimal VF mask)",
8703 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8704 (void *)&cmd_vf_rx_vlan_filter_what,
8705 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8706 (void *)&cmd_vf_rx_vlan_filter_port,
8707 (void *)&cmd_vf_rx_vlan_filter_portid,
8708 (void *)&cmd_vf_rx_vlan_filter_vf,
8709 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8714 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8715 struct cmd_queue_rate_limit_result {
8716 cmdline_fixed_string_t set;
8717 cmdline_fixed_string_t port;
8719 cmdline_fixed_string_t queue;
8721 cmdline_fixed_string_t rate;
8725 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8726 __attribute__((unused)) struct cmdline *cl,
8727 __attribute__((unused)) void *data)
8729 struct cmd_queue_rate_limit_result *res = parsed_result;
8732 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8733 && (strcmp(res->queue, "queue") == 0)
8734 && (strcmp(res->rate, "rate") == 0))
8735 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8738 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8742 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8743 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8745 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8746 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8748 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8749 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8751 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8752 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8754 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8755 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8757 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8758 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8760 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8761 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8764 cmdline_parse_inst_t cmd_queue_rate_limit = {
8765 .f = cmd_queue_rate_limit_parsed,
8767 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8768 "Set rate limit for a queue on port_id",
8770 (void *)&cmd_queue_rate_limit_set,
8771 (void *)&cmd_queue_rate_limit_port,
8772 (void *)&cmd_queue_rate_limit_portnum,
8773 (void *)&cmd_queue_rate_limit_queue,
8774 (void *)&cmd_queue_rate_limit_queuenum,
8775 (void *)&cmd_queue_rate_limit_rate,
8776 (void *)&cmd_queue_rate_limit_ratenum,
8781 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8782 struct cmd_vf_rate_limit_result {
8783 cmdline_fixed_string_t set;
8784 cmdline_fixed_string_t port;
8786 cmdline_fixed_string_t vf;
8788 cmdline_fixed_string_t rate;
8790 cmdline_fixed_string_t q_msk;
8794 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8795 __attribute__((unused)) struct cmdline *cl,
8796 __attribute__((unused)) void *data)
8798 struct cmd_vf_rate_limit_result *res = parsed_result;
8801 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8802 && (strcmp(res->vf, "vf") == 0)
8803 && (strcmp(res->rate, "rate") == 0)
8804 && (strcmp(res->q_msk, "queue_mask") == 0))
8805 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8806 res->rate_num, res->q_msk_val);
8808 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8812 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8813 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8815 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8816 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8818 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8819 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8821 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8822 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8824 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8825 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8827 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8828 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8830 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8831 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8833 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8834 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8835 q_msk, "queue_mask");
8836 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8837 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8840 cmdline_parse_inst_t cmd_vf_rate_limit = {
8841 .f = cmd_vf_rate_limit_parsed,
8843 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8844 "queue_mask <queue_mask_value>: "
8845 "Set rate limit for queues of VF on port_id",
8847 (void *)&cmd_vf_rate_limit_set,
8848 (void *)&cmd_vf_rate_limit_port,
8849 (void *)&cmd_vf_rate_limit_portnum,
8850 (void *)&cmd_vf_rate_limit_vf,
8851 (void *)&cmd_vf_rate_limit_vfnum,
8852 (void *)&cmd_vf_rate_limit_rate,
8853 (void *)&cmd_vf_rate_limit_ratenum,
8854 (void *)&cmd_vf_rate_limit_q_msk,
8855 (void *)&cmd_vf_rate_limit_q_msk_val,
8860 /* *** ADD TUNNEL FILTER OF A PORT *** */
8861 struct cmd_tunnel_filter_result {
8862 cmdline_fixed_string_t cmd;
8863 cmdline_fixed_string_t what;
8865 struct rte_ether_addr outer_mac;
8866 struct rte_ether_addr inner_mac;
8867 cmdline_ipaddr_t ip_value;
8868 uint16_t inner_vlan;
8869 cmdline_fixed_string_t tunnel_type;
8870 cmdline_fixed_string_t filter_type;
8876 cmd_tunnel_filter_parsed(void *parsed_result,
8877 __attribute__((unused)) struct cmdline *cl,
8878 __attribute__((unused)) void *data)
8880 struct cmd_tunnel_filter_result *res = parsed_result;
8881 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8884 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8886 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8887 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8888 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8890 if (res->ip_value.family == AF_INET) {
8891 tunnel_filter_conf.ip_addr.ipv4_addr =
8892 res->ip_value.addr.ipv4.s_addr;
8893 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8895 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8896 &(res->ip_value.addr.ipv6),
8897 sizeof(struct in6_addr));
8898 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8901 if (!strcmp(res->filter_type, "imac-ivlan"))
8902 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8903 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8904 tunnel_filter_conf.filter_type =
8905 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8906 else if (!strcmp(res->filter_type, "imac-tenid"))
8907 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8908 else if (!strcmp(res->filter_type, "imac"))
8909 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8910 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8911 tunnel_filter_conf.filter_type =
8912 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8913 else if (!strcmp(res->filter_type, "oip"))
8914 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8915 else if (!strcmp(res->filter_type, "iip"))
8916 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8918 printf("The filter type is not supported");
8922 if (!strcmp(res->tunnel_type, "vxlan"))
8923 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8924 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
8925 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
8926 else if (!strcmp(res->tunnel_type, "nvgre"))
8927 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8928 else if (!strcmp(res->tunnel_type, "ipingre"))
8929 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8931 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8935 tunnel_filter_conf.tenant_id = res->tenant_id;
8936 tunnel_filter_conf.queue_id = res->queue_num;
8937 if (!strcmp(res->what, "add"))
8938 ret = rte_eth_dev_filter_ctrl(res->port_id,
8939 RTE_ETH_FILTER_TUNNEL,
8941 &tunnel_filter_conf);
8943 ret = rte_eth_dev_filter_ctrl(res->port_id,
8944 RTE_ETH_FILTER_TUNNEL,
8945 RTE_ETH_FILTER_DELETE,
8946 &tunnel_filter_conf);
8948 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8952 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8953 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8954 cmd, "tunnel_filter");
8955 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8956 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8958 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8959 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8961 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8962 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8964 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8965 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8967 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8968 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8969 inner_vlan, UINT16);
8970 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8971 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8973 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8974 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8975 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
8977 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8978 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8979 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8980 "imac#omac-imac-tenid");
8981 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8982 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8984 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8985 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8988 cmdline_parse_inst_t cmd_tunnel_filter = {
8989 .f = cmd_tunnel_filter_parsed,
8991 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8992 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8993 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8994 "<queue_id>: Add/Rm tunnel filter of a port",
8996 (void *)&cmd_tunnel_filter_cmd,
8997 (void *)&cmd_tunnel_filter_what,
8998 (void *)&cmd_tunnel_filter_port_id,
8999 (void *)&cmd_tunnel_filter_outer_mac,
9000 (void *)&cmd_tunnel_filter_inner_mac,
9001 (void *)&cmd_tunnel_filter_ip_value,
9002 (void *)&cmd_tunnel_filter_innner_vlan,
9003 (void *)&cmd_tunnel_filter_tunnel_type,
9004 (void *)&cmd_tunnel_filter_filter_type,
9005 (void *)&cmd_tunnel_filter_tenant_id,
9006 (void *)&cmd_tunnel_filter_queue_num,
9011 /* *** CONFIGURE TUNNEL UDP PORT *** */
9012 struct cmd_tunnel_udp_config {
9013 cmdline_fixed_string_t cmd;
9014 cmdline_fixed_string_t what;
9020 cmd_tunnel_udp_config_parsed(void *parsed_result,
9021 __attribute__((unused)) struct cmdline *cl,
9022 __attribute__((unused)) void *data)
9024 struct cmd_tunnel_udp_config *res = parsed_result;
9025 struct rte_eth_udp_tunnel tunnel_udp;
9028 tunnel_udp.udp_port = res->udp_port;
9030 if (!strcmp(res->cmd, "rx_vxlan_port"))
9031 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9033 if (!strcmp(res->what, "add"))
9034 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9037 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9041 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9044 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9045 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9046 cmd, "rx_vxlan_port");
9047 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9048 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9050 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9051 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9053 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9054 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9057 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9058 .f = cmd_tunnel_udp_config_parsed,
9060 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9061 "Add/Remove a tunneling UDP port filter",
9063 (void *)&cmd_tunnel_udp_config_cmd,
9064 (void *)&cmd_tunnel_udp_config_what,
9065 (void *)&cmd_tunnel_udp_config_udp_port,
9066 (void *)&cmd_tunnel_udp_config_port_id,
9071 struct cmd_config_tunnel_udp_port {
9072 cmdline_fixed_string_t port;
9073 cmdline_fixed_string_t config;
9075 cmdline_fixed_string_t udp_tunnel_port;
9076 cmdline_fixed_string_t action;
9077 cmdline_fixed_string_t tunnel_type;
9082 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9083 __attribute__((unused)) struct cmdline *cl,
9084 __attribute__((unused)) void *data)
9086 struct cmd_config_tunnel_udp_port *res = parsed_result;
9087 struct rte_eth_udp_tunnel tunnel_udp;
9090 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9093 tunnel_udp.udp_port = res->udp_port;
9095 if (!strcmp(res->tunnel_type, "vxlan")) {
9096 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9097 } else if (!strcmp(res->tunnel_type, "geneve")) {
9098 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9099 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9100 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9102 printf("Invalid tunnel type\n");
9106 if (!strcmp(res->action, "add"))
9107 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9110 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9114 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9117 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9118 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9120 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9121 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9123 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9124 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9126 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9127 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9130 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9131 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9133 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9134 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9135 "vxlan#geneve#vxlan-gpe");
9136 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9137 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9140 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9141 .f = cmd_cfg_tunnel_udp_port_parsed,
9143 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9145 (void *)&cmd_config_tunnel_udp_port_port,
9146 (void *)&cmd_config_tunnel_udp_port_config,
9147 (void *)&cmd_config_tunnel_udp_port_port_id,
9148 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9149 (void *)&cmd_config_tunnel_udp_port_action,
9150 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9151 (void *)&cmd_config_tunnel_udp_port_value,
9156 /* *** GLOBAL CONFIG *** */
9157 struct cmd_global_config_result {
9158 cmdline_fixed_string_t cmd;
9160 cmdline_fixed_string_t cfg_type;
9165 cmd_global_config_parsed(void *parsed_result,
9166 __attribute__((unused)) struct cmdline *cl,
9167 __attribute__((unused)) void *data)
9169 struct cmd_global_config_result *res = parsed_result;
9170 struct rte_eth_global_cfg conf;
9173 memset(&conf, 0, sizeof(conf));
9174 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9175 conf.cfg.gre_key_len = res->len;
9176 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9177 RTE_ETH_FILTER_SET, &conf);
9179 printf("Global config error\n");
9182 cmdline_parse_token_string_t cmd_global_config_cmd =
9183 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9185 cmdline_parse_token_num_t cmd_global_config_port_id =
9186 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9188 cmdline_parse_token_string_t cmd_global_config_type =
9189 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9190 cfg_type, "gre-key-len");
9191 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9192 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9195 cmdline_parse_inst_t cmd_global_config = {
9196 .f = cmd_global_config_parsed,
9197 .data = (void *)NULL,
9198 .help_str = "global_config <port_id> gre-key-len <key_len>",
9200 (void *)&cmd_global_config_cmd,
9201 (void *)&cmd_global_config_port_id,
9202 (void *)&cmd_global_config_type,
9203 (void *)&cmd_global_config_gre_key_len,
9208 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9209 struct cmd_set_mirror_mask_result {
9210 cmdline_fixed_string_t set;
9211 cmdline_fixed_string_t port;
9213 cmdline_fixed_string_t mirror;
9215 cmdline_fixed_string_t what;
9216 cmdline_fixed_string_t value;
9217 cmdline_fixed_string_t dstpool;
9219 cmdline_fixed_string_t on;
9222 cmdline_parse_token_string_t cmd_mirror_mask_set =
9223 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9225 cmdline_parse_token_string_t cmd_mirror_mask_port =
9226 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9228 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9229 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9231 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9232 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9233 mirror, "mirror-rule");
9234 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9235 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9237 cmdline_parse_token_string_t cmd_mirror_mask_what =
9238 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9239 what, "pool-mirror-up#pool-mirror-down"
9241 cmdline_parse_token_string_t cmd_mirror_mask_value =
9242 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9244 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9245 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9246 dstpool, "dst-pool");
9247 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9248 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9250 cmdline_parse_token_string_t cmd_mirror_mask_on =
9251 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9255 cmd_set_mirror_mask_parsed(void *parsed_result,
9256 __attribute__((unused)) struct cmdline *cl,
9257 __attribute__((unused)) void *data)
9260 struct cmd_set_mirror_mask_result *res = parsed_result;
9261 struct rte_eth_mirror_conf mr_conf;
9263 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9265 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9267 mr_conf.dst_pool = res->dstpool_id;
9269 if (!strcmp(res->what, "pool-mirror-up")) {
9270 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9271 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9272 } else if (!strcmp(res->what, "pool-mirror-down")) {
9273 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9274 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9275 } else if (!strcmp(res->what, "vlan-mirror")) {
9276 mr_conf.rule_type = ETH_MIRROR_VLAN;
9277 nb_item = parse_item_list(res->value, "vlan",
9278 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9282 for (i = 0; i < nb_item; i++) {
9283 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9284 printf("Invalid vlan_id: must be < 4096\n");
9288 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9289 mr_conf.vlan.vlan_mask |= 1ULL << i;
9293 if (!strcmp(res->on, "on"))
9294 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9297 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9300 printf("mirror rule add error: (%s)\n", strerror(-ret));
9303 cmdline_parse_inst_t cmd_set_mirror_mask = {
9304 .f = cmd_set_mirror_mask_parsed,
9306 .help_str = "set port <port_id> mirror-rule <rule_id> "
9307 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9308 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9310 (void *)&cmd_mirror_mask_set,
9311 (void *)&cmd_mirror_mask_port,
9312 (void *)&cmd_mirror_mask_portid,
9313 (void *)&cmd_mirror_mask_mirror,
9314 (void *)&cmd_mirror_mask_ruleid,
9315 (void *)&cmd_mirror_mask_what,
9316 (void *)&cmd_mirror_mask_value,
9317 (void *)&cmd_mirror_mask_dstpool,
9318 (void *)&cmd_mirror_mask_poolid,
9319 (void *)&cmd_mirror_mask_on,
9324 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9325 struct cmd_set_mirror_link_result {
9326 cmdline_fixed_string_t set;
9327 cmdline_fixed_string_t port;
9329 cmdline_fixed_string_t mirror;
9331 cmdline_fixed_string_t what;
9332 cmdline_fixed_string_t dstpool;
9334 cmdline_fixed_string_t on;
9337 cmdline_parse_token_string_t cmd_mirror_link_set =
9338 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9340 cmdline_parse_token_string_t cmd_mirror_link_port =
9341 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9343 cmdline_parse_token_num_t cmd_mirror_link_portid =
9344 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9346 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9347 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9348 mirror, "mirror-rule");
9349 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9350 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9352 cmdline_parse_token_string_t cmd_mirror_link_what =
9353 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9354 what, "uplink-mirror#downlink-mirror");
9355 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9356 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9357 dstpool, "dst-pool");
9358 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9359 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9361 cmdline_parse_token_string_t cmd_mirror_link_on =
9362 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9366 cmd_set_mirror_link_parsed(void *parsed_result,
9367 __attribute__((unused)) struct cmdline *cl,
9368 __attribute__((unused)) void *data)
9371 struct cmd_set_mirror_link_result *res = parsed_result;
9372 struct rte_eth_mirror_conf mr_conf;
9374 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9375 if (!strcmp(res->what, "uplink-mirror"))
9376 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9378 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9380 mr_conf.dst_pool = res->dstpool_id;
9382 if (!strcmp(res->on, "on"))
9383 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9386 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9389 /* check the return value and print it if is < 0 */
9391 printf("mirror rule add error: (%s)\n", strerror(-ret));
9395 cmdline_parse_inst_t cmd_set_mirror_link = {
9396 .f = cmd_set_mirror_link_parsed,
9398 .help_str = "set port <port_id> mirror-rule <rule_id> "
9399 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9401 (void *)&cmd_mirror_link_set,
9402 (void *)&cmd_mirror_link_port,
9403 (void *)&cmd_mirror_link_portid,
9404 (void *)&cmd_mirror_link_mirror,
9405 (void *)&cmd_mirror_link_ruleid,
9406 (void *)&cmd_mirror_link_what,
9407 (void *)&cmd_mirror_link_dstpool,
9408 (void *)&cmd_mirror_link_poolid,
9409 (void *)&cmd_mirror_link_on,
9414 /* *** RESET VM MIRROR RULE *** */
9415 struct cmd_rm_mirror_rule_result {
9416 cmdline_fixed_string_t reset;
9417 cmdline_fixed_string_t port;
9419 cmdline_fixed_string_t mirror;
9423 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9424 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9426 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9427 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9429 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9430 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9432 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9433 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9434 mirror, "mirror-rule");
9435 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9436 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9440 cmd_reset_mirror_rule_parsed(void *parsed_result,
9441 __attribute__((unused)) struct cmdline *cl,
9442 __attribute__((unused)) void *data)
9445 struct cmd_set_mirror_link_result *res = parsed_result;
9447 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9449 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9452 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9453 .f = cmd_reset_mirror_rule_parsed,
9455 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9457 (void *)&cmd_rm_mirror_rule_reset,
9458 (void *)&cmd_rm_mirror_rule_port,
9459 (void *)&cmd_rm_mirror_rule_portid,
9460 (void *)&cmd_rm_mirror_rule_mirror,
9461 (void *)&cmd_rm_mirror_rule_ruleid,
9466 /* ******************************************************************************** */
9468 struct cmd_dump_result {
9469 cmdline_fixed_string_t dump;
9473 dump_struct_sizes(void)
9475 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9476 DUMP_SIZE(struct rte_mbuf);
9477 DUMP_SIZE(struct rte_mempool);
9478 DUMP_SIZE(struct rte_ring);
9482 static void cmd_dump_parsed(void *parsed_result,
9483 __attribute__((unused)) struct cmdline *cl,
9484 __attribute__((unused)) void *data)
9486 struct cmd_dump_result *res = parsed_result;
9488 if (!strcmp(res->dump, "dump_physmem"))
9489 rte_dump_physmem_layout(stdout);
9490 else if (!strcmp(res->dump, "dump_memzone"))
9491 rte_memzone_dump(stdout);
9492 else if (!strcmp(res->dump, "dump_struct_sizes"))
9493 dump_struct_sizes();
9494 else if (!strcmp(res->dump, "dump_ring"))
9495 rte_ring_list_dump(stdout);
9496 else if (!strcmp(res->dump, "dump_mempool"))
9497 rte_mempool_list_dump(stdout);
9498 else if (!strcmp(res->dump, "dump_devargs"))
9499 rte_devargs_dump(stdout);
9500 else if (!strcmp(res->dump, "dump_log_types"))
9501 rte_log_dump(stdout);
9504 cmdline_parse_token_string_t cmd_dump_dump =
9505 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9508 "dump_struct_sizes#"
9514 cmdline_parse_inst_t cmd_dump = {
9515 .f = cmd_dump_parsed, /* function to call */
9516 .data = NULL, /* 2nd arg of func */
9517 .help_str = "Dump status",
9518 .tokens = { /* token list, NULL terminated */
9519 (void *)&cmd_dump_dump,
9524 /* ******************************************************************************** */
9526 struct cmd_dump_one_result {
9527 cmdline_fixed_string_t dump;
9528 cmdline_fixed_string_t name;
9531 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9532 __attribute__((unused)) void *data)
9534 struct cmd_dump_one_result *res = parsed_result;
9536 if (!strcmp(res->dump, "dump_ring")) {
9538 r = rte_ring_lookup(res->name);
9540 cmdline_printf(cl, "Cannot find ring\n");
9543 rte_ring_dump(stdout, r);
9544 } else if (!strcmp(res->dump, "dump_mempool")) {
9545 struct rte_mempool *mp;
9546 mp = rte_mempool_lookup(res->name);
9548 cmdline_printf(cl, "Cannot find mempool\n");
9551 rte_mempool_dump(stdout, mp);
9555 cmdline_parse_token_string_t cmd_dump_one_dump =
9556 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9557 "dump_ring#dump_mempool");
9559 cmdline_parse_token_string_t cmd_dump_one_name =
9560 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9562 cmdline_parse_inst_t cmd_dump_one = {
9563 .f = cmd_dump_one_parsed, /* function to call */
9564 .data = NULL, /* 2nd arg of func */
9565 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9566 .tokens = { /* token list, NULL terminated */
9567 (void *)&cmd_dump_one_dump,
9568 (void *)&cmd_dump_one_name,
9573 /* *** Add/Del syn filter *** */
9574 struct cmd_syn_filter_result {
9575 cmdline_fixed_string_t filter;
9577 cmdline_fixed_string_t ops;
9578 cmdline_fixed_string_t priority;
9579 cmdline_fixed_string_t high;
9580 cmdline_fixed_string_t queue;
9585 cmd_syn_filter_parsed(void *parsed_result,
9586 __attribute__((unused)) struct cmdline *cl,
9587 __attribute__((unused)) void *data)
9589 struct cmd_syn_filter_result *res = parsed_result;
9590 struct rte_eth_syn_filter syn_filter;
9593 ret = rte_eth_dev_filter_supported(res->port_id,
9594 RTE_ETH_FILTER_SYN);
9596 printf("syn filter is not supported on port %u.\n",
9601 memset(&syn_filter, 0, sizeof(syn_filter));
9603 if (!strcmp(res->ops, "add")) {
9604 if (!strcmp(res->high, "high"))
9605 syn_filter.hig_pri = 1;
9607 syn_filter.hig_pri = 0;
9609 syn_filter.queue = res->queue_id;
9610 ret = rte_eth_dev_filter_ctrl(res->port_id,
9615 ret = rte_eth_dev_filter_ctrl(res->port_id,
9617 RTE_ETH_FILTER_DELETE,
9621 printf("syn filter programming error: (%s)\n",
9625 cmdline_parse_token_string_t cmd_syn_filter_filter =
9626 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9627 filter, "syn_filter");
9628 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9629 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9631 cmdline_parse_token_string_t cmd_syn_filter_ops =
9632 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9634 cmdline_parse_token_string_t cmd_syn_filter_priority =
9635 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9636 priority, "priority");
9637 cmdline_parse_token_string_t cmd_syn_filter_high =
9638 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9640 cmdline_parse_token_string_t cmd_syn_filter_queue =
9641 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9643 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9644 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9647 cmdline_parse_inst_t cmd_syn_filter = {
9648 .f = cmd_syn_filter_parsed,
9650 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9651 "<queue_id>: Add/Delete syn filter",
9653 (void *)&cmd_syn_filter_filter,
9654 (void *)&cmd_syn_filter_port_id,
9655 (void *)&cmd_syn_filter_ops,
9656 (void *)&cmd_syn_filter_priority,
9657 (void *)&cmd_syn_filter_high,
9658 (void *)&cmd_syn_filter_queue,
9659 (void *)&cmd_syn_filter_queue_id,
9664 /* *** queue region set *** */
9665 struct cmd_queue_region_result {
9666 cmdline_fixed_string_t set;
9667 cmdline_fixed_string_t port;
9669 cmdline_fixed_string_t cmd;
9670 cmdline_fixed_string_t region;
9672 cmdline_fixed_string_t queue_start_index;
9674 cmdline_fixed_string_t queue_num;
9675 uint8_t queue_num_value;
9679 cmd_queue_region_parsed(void *parsed_result,
9680 __attribute__((unused)) struct cmdline *cl,
9681 __attribute__((unused)) void *data)
9683 struct cmd_queue_region_result *res = parsed_result;
9685 #ifdef RTE_LIBRTE_I40E_PMD
9686 struct rte_pmd_i40e_queue_region_conf region_conf;
9687 enum rte_pmd_i40e_queue_region_op op_type;
9690 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9693 #ifdef RTE_LIBRTE_I40E_PMD
9694 memset(®ion_conf, 0, sizeof(region_conf));
9695 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9696 region_conf.region_id = res->region_id;
9697 region_conf.queue_num = res->queue_num_value;
9698 region_conf.queue_start_index = res->queue_id;
9700 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9701 op_type, ®ion_conf);
9708 printf("function not implemented or supported\n");
9711 printf("queue region config error: (%s)\n", strerror(-ret));
9715 cmdline_parse_token_string_t cmd_queue_region_set =
9716 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9718 cmdline_parse_token_string_t cmd_queue_region_port =
9719 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9720 cmdline_parse_token_num_t cmd_queue_region_port_id =
9721 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9723 cmdline_parse_token_string_t cmd_queue_region_cmd =
9724 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9725 cmd, "queue-region");
9726 cmdline_parse_token_string_t cmd_queue_region_id =
9727 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9728 region, "region_id");
9729 cmdline_parse_token_num_t cmd_queue_region_index =
9730 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9732 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9733 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9734 queue_start_index, "queue_start_index");
9735 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9736 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9738 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9739 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9740 queue_num, "queue_num");
9741 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9742 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9743 queue_num_value, UINT8);
9745 cmdline_parse_inst_t cmd_queue_region = {
9746 .f = cmd_queue_region_parsed,
9748 .help_str = "set port <port_id> queue-region region_id <value> "
9749 "queue_start_index <value> queue_num <value>: Set a queue region",
9751 (void *)&cmd_queue_region_set,
9752 (void *)&cmd_queue_region_port,
9753 (void *)&cmd_queue_region_port_id,
9754 (void *)&cmd_queue_region_cmd,
9755 (void *)&cmd_queue_region_id,
9756 (void *)&cmd_queue_region_index,
9757 (void *)&cmd_queue_region_queue_start_index,
9758 (void *)&cmd_queue_region_queue_id,
9759 (void *)&cmd_queue_region_queue_num,
9760 (void *)&cmd_queue_region_queue_num_value,
9765 /* *** queue region and flowtype set *** */
9766 struct cmd_region_flowtype_result {
9767 cmdline_fixed_string_t set;
9768 cmdline_fixed_string_t port;
9770 cmdline_fixed_string_t cmd;
9771 cmdline_fixed_string_t region;
9773 cmdline_fixed_string_t flowtype;
9774 uint8_t flowtype_id;
9778 cmd_region_flowtype_parsed(void *parsed_result,
9779 __attribute__((unused)) struct cmdline *cl,
9780 __attribute__((unused)) void *data)
9782 struct cmd_region_flowtype_result *res = parsed_result;
9784 #ifdef RTE_LIBRTE_I40E_PMD
9785 struct rte_pmd_i40e_queue_region_conf region_conf;
9786 enum rte_pmd_i40e_queue_region_op op_type;
9789 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9792 #ifdef RTE_LIBRTE_I40E_PMD
9793 memset(®ion_conf, 0, sizeof(region_conf));
9795 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9796 region_conf.region_id = res->region_id;
9797 region_conf.hw_flowtype = res->flowtype_id;
9799 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9800 op_type, ®ion_conf);
9807 printf("function not implemented or supported\n");
9810 printf("region flowtype config error: (%s)\n", strerror(-ret));
9814 cmdline_parse_token_string_t cmd_region_flowtype_set =
9815 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9817 cmdline_parse_token_string_t cmd_region_flowtype_port =
9818 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9820 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9821 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9823 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9824 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9825 cmd, "queue-region");
9826 cmdline_parse_token_string_t cmd_region_flowtype_index =
9827 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9828 region, "region_id");
9829 cmdline_parse_token_num_t cmd_region_flowtype_id =
9830 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9832 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9833 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9834 flowtype, "flowtype");
9835 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9836 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9837 flowtype_id, UINT8);
9838 cmdline_parse_inst_t cmd_region_flowtype = {
9839 .f = cmd_region_flowtype_parsed,
9841 .help_str = "set port <port_id> queue-region region_id <value> "
9842 "flowtype <value>: Set a flowtype region index",
9844 (void *)&cmd_region_flowtype_set,
9845 (void *)&cmd_region_flowtype_port,
9846 (void *)&cmd_region_flowtype_port_index,
9847 (void *)&cmd_region_flowtype_cmd,
9848 (void *)&cmd_region_flowtype_index,
9849 (void *)&cmd_region_flowtype_id,
9850 (void *)&cmd_region_flowtype_flow_index,
9851 (void *)&cmd_region_flowtype_flow_id,
9856 /* *** User Priority (UP) to queue region (region_id) set *** */
9857 struct cmd_user_priority_region_result {
9858 cmdline_fixed_string_t set;
9859 cmdline_fixed_string_t port;
9861 cmdline_fixed_string_t cmd;
9862 cmdline_fixed_string_t user_priority;
9863 uint8_t user_priority_id;
9864 cmdline_fixed_string_t region;
9869 cmd_user_priority_region_parsed(void *parsed_result,
9870 __attribute__((unused)) struct cmdline *cl,
9871 __attribute__((unused)) void *data)
9873 struct cmd_user_priority_region_result *res = parsed_result;
9875 #ifdef RTE_LIBRTE_I40E_PMD
9876 struct rte_pmd_i40e_queue_region_conf region_conf;
9877 enum rte_pmd_i40e_queue_region_op op_type;
9880 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9883 #ifdef RTE_LIBRTE_I40E_PMD
9884 memset(®ion_conf, 0, sizeof(region_conf));
9885 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9886 region_conf.user_priority = res->user_priority_id;
9887 region_conf.region_id = res->region_id;
9889 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9890 op_type, ®ion_conf);
9897 printf("function not implemented or supported\n");
9900 printf("user_priority region config error: (%s)\n",
9905 cmdline_parse_token_string_t cmd_user_priority_region_set =
9906 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9908 cmdline_parse_token_string_t cmd_user_priority_region_port =
9909 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9911 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9912 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9914 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9915 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9916 cmd, "queue-region");
9917 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9918 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9919 user_priority, "UP");
9920 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9921 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9922 user_priority_id, UINT8);
9923 cmdline_parse_token_string_t cmd_user_priority_region_region =
9924 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9925 region, "region_id");
9926 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9927 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9930 cmdline_parse_inst_t cmd_user_priority_region = {
9931 .f = cmd_user_priority_region_parsed,
9933 .help_str = "set port <port_id> queue-region UP <value> "
9934 "region_id <value>: Set the mapping of User Priority (UP) "
9935 "to queue region (region_id) ",
9937 (void *)&cmd_user_priority_region_set,
9938 (void *)&cmd_user_priority_region_port,
9939 (void *)&cmd_user_priority_region_port_index,
9940 (void *)&cmd_user_priority_region_cmd,
9941 (void *)&cmd_user_priority_region_UP,
9942 (void *)&cmd_user_priority_region_UP_id,
9943 (void *)&cmd_user_priority_region_region,
9944 (void *)&cmd_user_priority_region_region_id,
9949 /* *** flush all queue region related configuration *** */
9950 struct cmd_flush_queue_region_result {
9951 cmdline_fixed_string_t set;
9952 cmdline_fixed_string_t port;
9954 cmdline_fixed_string_t cmd;
9955 cmdline_fixed_string_t flush;
9956 cmdline_fixed_string_t what;
9960 cmd_flush_queue_region_parsed(void *parsed_result,
9961 __attribute__((unused)) struct cmdline *cl,
9962 __attribute__((unused)) void *data)
9964 struct cmd_flush_queue_region_result *res = parsed_result;
9966 #ifdef RTE_LIBRTE_I40E_PMD
9967 struct rte_pmd_i40e_queue_region_conf region_conf;
9968 enum rte_pmd_i40e_queue_region_op op_type;
9971 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9974 #ifdef RTE_LIBRTE_I40E_PMD
9975 memset(®ion_conf, 0, sizeof(region_conf));
9977 if (strcmp(res->what, "on") == 0)
9978 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9980 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9982 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9983 op_type, ®ion_conf);
9990 printf("function not implemented or supported\n");
9993 printf("queue region config flush error: (%s)\n",
9998 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9999 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10001 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10002 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10004 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10005 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10007 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10008 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10009 cmd, "queue-region");
10010 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10011 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10013 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10014 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10017 cmdline_parse_inst_t cmd_flush_queue_region = {
10018 .f = cmd_flush_queue_region_parsed,
10020 .help_str = "set port <port_id> queue-region flush on|off"
10021 ": flush all queue region related configuration",
10023 (void *)&cmd_flush_queue_region_set,
10024 (void *)&cmd_flush_queue_region_port,
10025 (void *)&cmd_flush_queue_region_port_index,
10026 (void *)&cmd_flush_queue_region_cmd,
10027 (void *)&cmd_flush_queue_region_flush,
10028 (void *)&cmd_flush_queue_region_what,
10033 /* *** get all queue region related configuration info *** */
10034 struct cmd_show_queue_region_info {
10035 cmdline_fixed_string_t show;
10036 cmdline_fixed_string_t port;
10038 cmdline_fixed_string_t cmd;
10042 cmd_show_queue_region_info_parsed(void *parsed_result,
10043 __attribute__((unused)) struct cmdline *cl,
10044 __attribute__((unused)) void *data)
10046 struct cmd_show_queue_region_info *res = parsed_result;
10047 int ret = -ENOTSUP;
10048 #ifdef RTE_LIBRTE_I40E_PMD
10049 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10050 enum rte_pmd_i40e_queue_region_op op_type;
10053 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10056 #ifdef RTE_LIBRTE_I40E_PMD
10057 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10059 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10061 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10062 op_type, &rte_pmd_regions);
10064 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10071 printf("function not implemented or supported\n");
10074 printf("queue region config info show error: (%s)\n",
10079 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10080 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10082 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10083 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10085 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10086 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10088 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10089 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10090 cmd, "queue-region");
10092 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10093 .f = cmd_show_queue_region_info_parsed,
10095 .help_str = "show port <port_id> queue-region"
10096 ": show all queue region related configuration info",
10098 (void *)&cmd_show_queue_region_info_get,
10099 (void *)&cmd_show_queue_region_info_port,
10100 (void *)&cmd_show_queue_region_info_port_index,
10101 (void *)&cmd_show_queue_region_info_cmd,
10106 /* *** ADD/REMOVE A 2tuple FILTER *** */
10107 struct cmd_2tuple_filter_result {
10108 cmdline_fixed_string_t filter;
10110 cmdline_fixed_string_t ops;
10111 cmdline_fixed_string_t dst_port;
10112 uint16_t dst_port_value;
10113 cmdline_fixed_string_t protocol;
10114 uint8_t protocol_value;
10115 cmdline_fixed_string_t mask;
10116 uint8_t mask_value;
10117 cmdline_fixed_string_t tcp_flags;
10118 uint8_t tcp_flags_value;
10119 cmdline_fixed_string_t priority;
10120 uint8_t priority_value;
10121 cmdline_fixed_string_t queue;
10126 cmd_2tuple_filter_parsed(void *parsed_result,
10127 __attribute__((unused)) struct cmdline *cl,
10128 __attribute__((unused)) void *data)
10130 struct rte_eth_ntuple_filter filter;
10131 struct cmd_2tuple_filter_result *res = parsed_result;
10134 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10136 printf("ntuple filter is not supported on port %u.\n",
10141 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10143 filter.flags = RTE_2TUPLE_FLAGS;
10144 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10145 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10146 filter.proto = res->protocol_value;
10147 filter.priority = res->priority_value;
10148 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10149 printf("nonzero tcp_flags is only meaningful"
10150 " when protocol is TCP.\n");
10153 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10154 printf("invalid TCP flags.\n");
10158 if (res->tcp_flags_value != 0) {
10159 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10160 filter.tcp_flags = res->tcp_flags_value;
10163 /* need convert to big endian. */
10164 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10165 filter.queue = res->queue_id;
10167 if (!strcmp(res->ops, "add"))
10168 ret = rte_eth_dev_filter_ctrl(res->port_id,
10169 RTE_ETH_FILTER_NTUPLE,
10170 RTE_ETH_FILTER_ADD,
10173 ret = rte_eth_dev_filter_ctrl(res->port_id,
10174 RTE_ETH_FILTER_NTUPLE,
10175 RTE_ETH_FILTER_DELETE,
10178 printf("2tuple filter programming error: (%s)\n",
10183 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10184 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10185 filter, "2tuple_filter");
10186 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10187 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10189 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10190 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10192 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10193 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10194 dst_port, "dst_port");
10195 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10196 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10197 dst_port_value, UINT16);
10198 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10199 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10200 protocol, "protocol");
10201 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10202 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10203 protocol_value, UINT8);
10204 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10205 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10207 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10208 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10210 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10211 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10212 tcp_flags, "tcp_flags");
10213 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10214 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10215 tcp_flags_value, UINT8);
10216 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10217 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10218 priority, "priority");
10219 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10220 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10221 priority_value, UINT8);
10222 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10223 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10225 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10226 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10229 cmdline_parse_inst_t cmd_2tuple_filter = {
10230 .f = cmd_2tuple_filter_parsed,
10232 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10233 "<value> mask <value> tcp_flags <value> priority <value> queue "
10234 "<queue_id>: Add a 2tuple filter",
10236 (void *)&cmd_2tuple_filter_filter,
10237 (void *)&cmd_2tuple_filter_port_id,
10238 (void *)&cmd_2tuple_filter_ops,
10239 (void *)&cmd_2tuple_filter_dst_port,
10240 (void *)&cmd_2tuple_filter_dst_port_value,
10241 (void *)&cmd_2tuple_filter_protocol,
10242 (void *)&cmd_2tuple_filter_protocol_value,
10243 (void *)&cmd_2tuple_filter_mask,
10244 (void *)&cmd_2tuple_filter_mask_value,
10245 (void *)&cmd_2tuple_filter_tcp_flags,
10246 (void *)&cmd_2tuple_filter_tcp_flags_value,
10247 (void *)&cmd_2tuple_filter_priority,
10248 (void *)&cmd_2tuple_filter_priority_value,
10249 (void *)&cmd_2tuple_filter_queue,
10250 (void *)&cmd_2tuple_filter_queue_id,
10255 /* *** ADD/REMOVE A 5tuple FILTER *** */
10256 struct cmd_5tuple_filter_result {
10257 cmdline_fixed_string_t filter;
10259 cmdline_fixed_string_t ops;
10260 cmdline_fixed_string_t dst_ip;
10261 cmdline_ipaddr_t dst_ip_value;
10262 cmdline_fixed_string_t src_ip;
10263 cmdline_ipaddr_t src_ip_value;
10264 cmdline_fixed_string_t dst_port;
10265 uint16_t dst_port_value;
10266 cmdline_fixed_string_t src_port;
10267 uint16_t src_port_value;
10268 cmdline_fixed_string_t protocol;
10269 uint8_t protocol_value;
10270 cmdline_fixed_string_t mask;
10271 uint8_t mask_value;
10272 cmdline_fixed_string_t tcp_flags;
10273 uint8_t tcp_flags_value;
10274 cmdline_fixed_string_t priority;
10275 uint8_t priority_value;
10276 cmdline_fixed_string_t queue;
10281 cmd_5tuple_filter_parsed(void *parsed_result,
10282 __attribute__((unused)) struct cmdline *cl,
10283 __attribute__((unused)) void *data)
10285 struct rte_eth_ntuple_filter filter;
10286 struct cmd_5tuple_filter_result *res = parsed_result;
10289 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10291 printf("ntuple filter is not supported on port %u.\n",
10296 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10298 filter.flags = RTE_5TUPLE_FLAGS;
10299 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10300 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10301 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10302 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10303 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10304 filter.proto = res->protocol_value;
10305 filter.priority = res->priority_value;
10306 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10307 printf("nonzero tcp_flags is only meaningful"
10308 " when protocol is TCP.\n");
10311 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10312 printf("invalid TCP flags.\n");
10316 if (res->tcp_flags_value != 0) {
10317 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10318 filter.tcp_flags = res->tcp_flags_value;
10321 if (res->dst_ip_value.family == AF_INET)
10322 /* no need to convert, already big endian. */
10323 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10325 if (filter.dst_ip_mask == 0) {
10326 printf("can not support ipv6 involved compare.\n");
10332 if (res->src_ip_value.family == AF_INET)
10333 /* no need to convert, already big endian. */
10334 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10336 if (filter.src_ip_mask == 0) {
10337 printf("can not support ipv6 involved compare.\n");
10342 /* need convert to big endian. */
10343 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10344 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10345 filter.queue = res->queue_id;
10347 if (!strcmp(res->ops, "add"))
10348 ret = rte_eth_dev_filter_ctrl(res->port_id,
10349 RTE_ETH_FILTER_NTUPLE,
10350 RTE_ETH_FILTER_ADD,
10353 ret = rte_eth_dev_filter_ctrl(res->port_id,
10354 RTE_ETH_FILTER_NTUPLE,
10355 RTE_ETH_FILTER_DELETE,
10358 printf("5tuple filter programming error: (%s)\n",
10362 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10363 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10364 filter, "5tuple_filter");
10365 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10366 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10368 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10369 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10371 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10372 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10374 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10375 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10377 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10378 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10380 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10381 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10383 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10384 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10385 dst_port, "dst_port");
10386 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10387 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10388 dst_port_value, UINT16);
10389 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10390 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10391 src_port, "src_port");
10392 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10393 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10394 src_port_value, UINT16);
10395 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10396 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10397 protocol, "protocol");
10398 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10399 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10400 protocol_value, UINT8);
10401 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10402 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10404 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10405 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10407 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10408 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10409 tcp_flags, "tcp_flags");
10410 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10411 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10412 tcp_flags_value, UINT8);
10413 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10414 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10415 priority, "priority");
10416 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10417 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10418 priority_value, UINT8);
10419 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10420 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10422 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10423 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10426 cmdline_parse_inst_t cmd_5tuple_filter = {
10427 .f = cmd_5tuple_filter_parsed,
10429 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10430 "src_ip <value> dst_port <value> src_port <value> "
10431 "protocol <value> mask <value> tcp_flags <value> "
10432 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10434 (void *)&cmd_5tuple_filter_filter,
10435 (void *)&cmd_5tuple_filter_port_id,
10436 (void *)&cmd_5tuple_filter_ops,
10437 (void *)&cmd_5tuple_filter_dst_ip,
10438 (void *)&cmd_5tuple_filter_dst_ip_value,
10439 (void *)&cmd_5tuple_filter_src_ip,
10440 (void *)&cmd_5tuple_filter_src_ip_value,
10441 (void *)&cmd_5tuple_filter_dst_port,
10442 (void *)&cmd_5tuple_filter_dst_port_value,
10443 (void *)&cmd_5tuple_filter_src_port,
10444 (void *)&cmd_5tuple_filter_src_port_value,
10445 (void *)&cmd_5tuple_filter_protocol,
10446 (void *)&cmd_5tuple_filter_protocol_value,
10447 (void *)&cmd_5tuple_filter_mask,
10448 (void *)&cmd_5tuple_filter_mask_value,
10449 (void *)&cmd_5tuple_filter_tcp_flags,
10450 (void *)&cmd_5tuple_filter_tcp_flags_value,
10451 (void *)&cmd_5tuple_filter_priority,
10452 (void *)&cmd_5tuple_filter_priority_value,
10453 (void *)&cmd_5tuple_filter_queue,
10454 (void *)&cmd_5tuple_filter_queue_id,
10459 /* *** ADD/REMOVE A flex FILTER *** */
10460 struct cmd_flex_filter_result {
10461 cmdline_fixed_string_t filter;
10462 cmdline_fixed_string_t ops;
10464 cmdline_fixed_string_t len;
10466 cmdline_fixed_string_t bytes;
10467 cmdline_fixed_string_t bytes_value;
10468 cmdline_fixed_string_t mask;
10469 cmdline_fixed_string_t mask_value;
10470 cmdline_fixed_string_t priority;
10471 uint8_t priority_value;
10472 cmdline_fixed_string_t queue;
10476 static int xdigit2val(unsigned char c)
10481 else if (isupper(c))
10482 val = c - 'A' + 10;
10484 val = c - 'a' + 10;
10489 cmd_flex_filter_parsed(void *parsed_result,
10490 __attribute__((unused)) struct cmdline *cl,
10491 __attribute__((unused)) void *data)
10494 struct rte_eth_flex_filter filter;
10495 struct cmd_flex_filter_result *res = parsed_result;
10496 char *bytes_ptr, *mask_ptr;
10497 uint16_t len, i, j = 0;
10502 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10503 printf("the len exceed the max length 128\n");
10506 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10507 filter.len = res->len_value;
10508 filter.priority = res->priority_value;
10509 filter.queue = res->queue_id;
10510 bytes_ptr = res->bytes_value;
10511 mask_ptr = res->mask_value;
10513 /* translate bytes string to array. */
10514 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10515 (bytes_ptr[1] == 'X')))
10517 len = strnlen(bytes_ptr, res->len_value * 2);
10518 if (len == 0 || (len % 8 != 0)) {
10519 printf("please check len and bytes input\n");
10522 for (i = 0; i < len; i++) {
10524 if (isxdigit(c) == 0) {
10525 /* invalid characters. */
10526 printf("invalid input\n");
10529 val = xdigit2val(c);
10532 filter.bytes[j] = byte;
10533 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10540 /* translate mask string to uint8_t array. */
10541 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10542 (mask_ptr[1] == 'X')))
10544 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10546 printf("invalid input\n");
10551 for (i = 0; i < len; i++) {
10553 if (isxdigit(c) == 0) {
10554 /* invalid characters. */
10555 printf("invalid input\n");
10558 val = xdigit2val(c);
10561 filter.mask[j] = byte;
10562 printf("mask[%d]:%02x ", j, filter.mask[j]);
10570 if (!strcmp(res->ops, "add"))
10571 ret = rte_eth_dev_filter_ctrl(res->port_id,
10572 RTE_ETH_FILTER_FLEXIBLE,
10573 RTE_ETH_FILTER_ADD,
10576 ret = rte_eth_dev_filter_ctrl(res->port_id,
10577 RTE_ETH_FILTER_FLEXIBLE,
10578 RTE_ETH_FILTER_DELETE,
10582 printf("flex filter setting error: (%s)\n", strerror(-ret));
10585 cmdline_parse_token_string_t cmd_flex_filter_filter =
10586 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10587 filter, "flex_filter");
10588 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10589 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10591 cmdline_parse_token_string_t cmd_flex_filter_ops =
10592 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10594 cmdline_parse_token_string_t cmd_flex_filter_len =
10595 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10597 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10598 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10600 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10601 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10603 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10604 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10605 bytes_value, NULL);
10606 cmdline_parse_token_string_t cmd_flex_filter_mask =
10607 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10609 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10610 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10612 cmdline_parse_token_string_t cmd_flex_filter_priority =
10613 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10614 priority, "priority");
10615 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10616 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10617 priority_value, UINT8);
10618 cmdline_parse_token_string_t cmd_flex_filter_queue =
10619 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10621 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10622 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10624 cmdline_parse_inst_t cmd_flex_filter = {
10625 .f = cmd_flex_filter_parsed,
10627 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10628 "<value> mask <value> priority <value> queue <queue_id>: "
10629 "Add/Del a flex filter",
10631 (void *)&cmd_flex_filter_filter,
10632 (void *)&cmd_flex_filter_port_id,
10633 (void *)&cmd_flex_filter_ops,
10634 (void *)&cmd_flex_filter_len,
10635 (void *)&cmd_flex_filter_len_value,
10636 (void *)&cmd_flex_filter_bytes,
10637 (void *)&cmd_flex_filter_bytes_value,
10638 (void *)&cmd_flex_filter_mask,
10639 (void *)&cmd_flex_filter_mask_value,
10640 (void *)&cmd_flex_filter_priority,
10641 (void *)&cmd_flex_filter_priority_value,
10642 (void *)&cmd_flex_filter_queue,
10643 (void *)&cmd_flex_filter_queue_id,
10648 /* *** Filters Control *** */
10650 /* *** deal with ethertype filter *** */
10651 struct cmd_ethertype_filter_result {
10652 cmdline_fixed_string_t filter;
10654 cmdline_fixed_string_t ops;
10655 cmdline_fixed_string_t mac;
10656 struct rte_ether_addr mac_addr;
10657 cmdline_fixed_string_t ethertype;
10658 uint16_t ethertype_value;
10659 cmdline_fixed_string_t drop;
10660 cmdline_fixed_string_t queue;
10664 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10665 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10666 filter, "ethertype_filter");
10667 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10668 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10670 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10671 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10673 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10674 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10675 mac, "mac_addr#mac_ignr");
10676 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10677 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10679 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10680 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10681 ethertype, "ethertype");
10682 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10683 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10684 ethertype_value, UINT16);
10685 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10686 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10688 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10689 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10691 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10692 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10696 cmd_ethertype_filter_parsed(void *parsed_result,
10697 __attribute__((unused)) struct cmdline *cl,
10698 __attribute__((unused)) void *data)
10700 struct cmd_ethertype_filter_result *res = parsed_result;
10701 struct rte_eth_ethertype_filter filter;
10704 ret = rte_eth_dev_filter_supported(res->port_id,
10705 RTE_ETH_FILTER_ETHERTYPE);
10707 printf("ethertype filter is not supported on port %u.\n",
10712 memset(&filter, 0, sizeof(filter));
10713 if (!strcmp(res->mac, "mac_addr")) {
10714 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10715 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10716 sizeof(struct rte_ether_addr));
10718 if (!strcmp(res->drop, "drop"))
10719 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10720 filter.ether_type = res->ethertype_value;
10721 filter.queue = res->queue_id;
10723 if (!strcmp(res->ops, "add"))
10724 ret = rte_eth_dev_filter_ctrl(res->port_id,
10725 RTE_ETH_FILTER_ETHERTYPE,
10726 RTE_ETH_FILTER_ADD,
10729 ret = rte_eth_dev_filter_ctrl(res->port_id,
10730 RTE_ETH_FILTER_ETHERTYPE,
10731 RTE_ETH_FILTER_DELETE,
10734 printf("ethertype filter programming error: (%s)\n",
10738 cmdline_parse_inst_t cmd_ethertype_filter = {
10739 .f = cmd_ethertype_filter_parsed,
10741 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10742 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10743 "Add or delete an ethertype filter entry",
10745 (void *)&cmd_ethertype_filter_filter,
10746 (void *)&cmd_ethertype_filter_port_id,
10747 (void *)&cmd_ethertype_filter_ops,
10748 (void *)&cmd_ethertype_filter_mac,
10749 (void *)&cmd_ethertype_filter_mac_addr,
10750 (void *)&cmd_ethertype_filter_ethertype,
10751 (void *)&cmd_ethertype_filter_ethertype_value,
10752 (void *)&cmd_ethertype_filter_drop,
10753 (void *)&cmd_ethertype_filter_queue,
10754 (void *)&cmd_ethertype_filter_queue_id,
10759 /* *** deal with flow director filter *** */
10760 struct cmd_flow_director_result {
10761 cmdline_fixed_string_t flow_director_filter;
10763 cmdline_fixed_string_t mode;
10764 cmdline_fixed_string_t mode_value;
10765 cmdline_fixed_string_t ops;
10766 cmdline_fixed_string_t flow;
10767 cmdline_fixed_string_t flow_type;
10768 cmdline_fixed_string_t ether;
10769 uint16_t ether_type;
10770 cmdline_fixed_string_t src;
10771 cmdline_ipaddr_t ip_src;
10773 cmdline_fixed_string_t dst;
10774 cmdline_ipaddr_t ip_dst;
10776 cmdline_fixed_string_t verify_tag;
10777 uint32_t verify_tag_value;
10778 cmdline_fixed_string_t tos;
10780 cmdline_fixed_string_t proto;
10781 uint8_t proto_value;
10782 cmdline_fixed_string_t ttl;
10784 cmdline_fixed_string_t vlan;
10785 uint16_t vlan_value;
10786 cmdline_fixed_string_t flexbytes;
10787 cmdline_fixed_string_t flexbytes_value;
10788 cmdline_fixed_string_t pf_vf;
10789 cmdline_fixed_string_t drop;
10790 cmdline_fixed_string_t queue;
10792 cmdline_fixed_string_t fd_id;
10793 uint32_t fd_id_value;
10794 cmdline_fixed_string_t mac;
10795 struct rte_ether_addr mac_addr;
10796 cmdline_fixed_string_t tunnel;
10797 cmdline_fixed_string_t tunnel_type;
10798 cmdline_fixed_string_t tunnel_id;
10799 uint32_t tunnel_id_value;
10800 cmdline_fixed_string_t packet;
10805 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10808 const char *p, *p0 = q_arg;
10810 unsigned long int_fld;
10811 char *str_fld[max_num];
10816 p = strchr(p0, '(');
10820 p0 = strchr(p, ')');
10825 if (size >= sizeof(s))
10828 snprintf(s, sizeof(s), "%.*s", size, p);
10829 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10830 if (ret < 0 || ret > max_num)
10832 for (i = 0; i < ret; i++) {
10834 int_fld = strtoul(str_fld[i], &end, 0);
10835 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10837 flexbytes[i] = (uint8_t)int_fld;
10843 str2flowtype(char *string)
10846 static const struct {
10849 } flowtype_str[] = {
10850 {"raw", RTE_ETH_FLOW_RAW},
10851 {"ipv4", RTE_ETH_FLOW_IPV4},
10852 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10853 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10854 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10855 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10856 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10857 {"ipv6", RTE_ETH_FLOW_IPV6},
10858 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10859 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10860 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10861 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10862 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10863 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10866 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10867 if (!strcmp(flowtype_str[i].str, string))
10868 return flowtype_str[i].type;
10871 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10872 return (uint16_t)atoi(string);
10874 return RTE_ETH_FLOW_UNKNOWN;
10877 static enum rte_eth_fdir_tunnel_type
10878 str2fdir_tunneltype(char *string)
10882 static const struct {
10884 enum rte_eth_fdir_tunnel_type type;
10885 } tunneltype_str[] = {
10886 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10887 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10890 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10891 if (!strcmp(tunneltype_str[i].str, string))
10892 return tunneltype_str[i].type;
10894 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10897 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10899 if ((ip_addr).family == AF_INET) \
10900 (ip) = (ip_addr).addr.ipv4.s_addr; \
10902 printf("invalid parameter.\n"); \
10907 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10909 if ((ip_addr).family == AF_INET6) \
10910 rte_memcpy(&(ip), \
10911 &((ip_addr).addr.ipv6), \
10912 sizeof(struct in6_addr)); \
10914 printf("invalid parameter.\n"); \
10920 cmd_flow_director_filter_parsed(void *parsed_result,
10921 __attribute__((unused)) struct cmdline *cl,
10922 __attribute__((unused)) void *data)
10924 struct cmd_flow_director_result *res = parsed_result;
10925 struct rte_eth_fdir_filter entry;
10926 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10928 unsigned long vf_id;
10931 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10933 printf("flow director is not supported on port %u.\n",
10937 memset(flexbytes, 0, sizeof(flexbytes));
10938 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10940 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10941 if (strcmp(res->mode_value, "MAC-VLAN")) {
10942 printf("Please set mode to MAC-VLAN.\n");
10945 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10946 if (strcmp(res->mode_value, "Tunnel")) {
10947 printf("Please set mode to Tunnel.\n");
10951 if (!strcmp(res->mode_value, "raw")) {
10952 #ifdef RTE_LIBRTE_I40E_PMD
10953 struct rte_pmd_i40e_flow_type_mapping
10954 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10955 struct rte_pmd_i40e_pkt_template_conf conf;
10956 uint16_t flow_type = str2flowtype(res->flow_type);
10957 uint16_t i, port = res->port_id;
10960 memset(&conf, 0, sizeof(conf));
10962 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10963 printf("Invalid flow type specified.\n");
10966 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10970 if (mapping[flow_type].pctype == 0ULL) {
10971 printf("Invalid flow type specified.\n");
10974 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10975 if (mapping[flow_type].pctype & (1ULL << i)) {
10976 conf.input.pctype = i;
10981 conf.input.packet = open_file(res->filepath,
10982 &conf.input.length);
10983 if (!conf.input.packet)
10985 if (!strcmp(res->drop, "drop"))
10986 conf.action.behavior =
10987 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10989 conf.action.behavior =
10990 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10991 conf.action.report_status =
10992 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10993 conf.action.rx_queue = res->queue_id;
10994 conf.soft_id = res->fd_id_value;
10995 add = strcmp(res->ops, "del") ? 1 : 0;
10996 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11000 printf("flow director config error: (%s)\n",
11002 close_file(conf.input.packet);
11005 } else if (strcmp(res->mode_value, "IP")) {
11006 printf("Please set mode to IP or raw.\n");
11009 entry.input.flow_type = str2flowtype(res->flow_type);
11012 ret = parse_flexbytes(res->flexbytes_value,
11014 RTE_ETH_FDIR_MAX_FLEXLEN);
11016 printf("error: Cannot parse flexbytes input.\n");
11020 switch (entry.input.flow_type) {
11021 case RTE_ETH_FLOW_FRAG_IPV4:
11022 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11023 entry.input.flow.ip4_flow.proto = res->proto_value;
11025 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11026 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11027 IPV4_ADDR_TO_UINT(res->ip_dst,
11028 entry.input.flow.ip4_flow.dst_ip);
11029 IPV4_ADDR_TO_UINT(res->ip_src,
11030 entry.input.flow.ip4_flow.src_ip);
11031 entry.input.flow.ip4_flow.tos = res->tos_value;
11032 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11033 /* need convert to big endian. */
11034 entry.input.flow.udp4_flow.dst_port =
11035 rte_cpu_to_be_16(res->port_dst);
11036 entry.input.flow.udp4_flow.src_port =
11037 rte_cpu_to_be_16(res->port_src);
11039 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11040 IPV4_ADDR_TO_UINT(res->ip_dst,
11041 entry.input.flow.sctp4_flow.ip.dst_ip);
11042 IPV4_ADDR_TO_UINT(res->ip_src,
11043 entry.input.flow.sctp4_flow.ip.src_ip);
11044 entry.input.flow.ip4_flow.tos = res->tos_value;
11045 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11046 /* need convert to big endian. */
11047 entry.input.flow.sctp4_flow.dst_port =
11048 rte_cpu_to_be_16(res->port_dst);
11049 entry.input.flow.sctp4_flow.src_port =
11050 rte_cpu_to_be_16(res->port_src);
11051 entry.input.flow.sctp4_flow.verify_tag =
11052 rte_cpu_to_be_32(res->verify_tag_value);
11054 case RTE_ETH_FLOW_FRAG_IPV6:
11055 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11056 entry.input.flow.ipv6_flow.proto = res->proto_value;
11058 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11059 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11060 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11061 entry.input.flow.ipv6_flow.dst_ip);
11062 IPV6_ADDR_TO_ARRAY(res->ip_src,
11063 entry.input.flow.ipv6_flow.src_ip);
11064 entry.input.flow.ipv6_flow.tc = res->tos_value;
11065 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11066 /* need convert to big endian. */
11067 entry.input.flow.udp6_flow.dst_port =
11068 rte_cpu_to_be_16(res->port_dst);
11069 entry.input.flow.udp6_flow.src_port =
11070 rte_cpu_to_be_16(res->port_src);
11072 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11073 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11074 entry.input.flow.sctp6_flow.ip.dst_ip);
11075 IPV6_ADDR_TO_ARRAY(res->ip_src,
11076 entry.input.flow.sctp6_flow.ip.src_ip);
11077 entry.input.flow.ipv6_flow.tc = res->tos_value;
11078 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11079 /* need convert to big endian. */
11080 entry.input.flow.sctp6_flow.dst_port =
11081 rte_cpu_to_be_16(res->port_dst);
11082 entry.input.flow.sctp6_flow.src_port =
11083 rte_cpu_to_be_16(res->port_src);
11084 entry.input.flow.sctp6_flow.verify_tag =
11085 rte_cpu_to_be_32(res->verify_tag_value);
11087 case RTE_ETH_FLOW_L2_PAYLOAD:
11088 entry.input.flow.l2_flow.ether_type =
11089 rte_cpu_to_be_16(res->ether_type);
11095 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11096 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11098 sizeof(struct rte_ether_addr));
11100 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11101 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11103 sizeof(struct rte_ether_addr));
11104 entry.input.flow.tunnel_flow.tunnel_type =
11105 str2fdir_tunneltype(res->tunnel_type);
11106 entry.input.flow.tunnel_flow.tunnel_id =
11107 rte_cpu_to_be_32(res->tunnel_id_value);
11110 rte_memcpy(entry.input.flow_ext.flexbytes,
11112 RTE_ETH_FDIR_MAX_FLEXLEN);
11114 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11116 entry.action.flex_off = 0; /*use 0 by default */
11117 if (!strcmp(res->drop, "drop"))
11118 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11120 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11122 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11123 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11124 if (!strcmp(res->pf_vf, "pf"))
11125 entry.input.flow_ext.is_vf = 0;
11126 else if (!strncmp(res->pf_vf, "vf", 2)) {
11127 struct rte_eth_dev_info dev_info;
11129 ret = eth_dev_info_get_print_err(res->port_id,
11135 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11136 if (errno != 0 || *end != '\0' ||
11137 vf_id >= dev_info.max_vfs) {
11138 printf("invalid parameter %s.\n", res->pf_vf);
11141 entry.input.flow_ext.is_vf = 1;
11142 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11144 printf("invalid parameter %s.\n", res->pf_vf);
11149 /* set to report FD ID by default */
11150 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11151 entry.action.rx_queue = res->queue_id;
11152 entry.soft_id = res->fd_id_value;
11153 if (!strcmp(res->ops, "add"))
11154 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11155 RTE_ETH_FILTER_ADD, &entry);
11156 else if (!strcmp(res->ops, "del"))
11157 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11158 RTE_ETH_FILTER_DELETE, &entry);
11160 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11161 RTE_ETH_FILTER_UPDATE, &entry);
11163 printf("flow director programming error: (%s)\n",
11167 cmdline_parse_token_string_t cmd_flow_director_filter =
11168 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11169 flow_director_filter, "flow_director_filter");
11170 cmdline_parse_token_num_t cmd_flow_director_port_id =
11171 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11173 cmdline_parse_token_string_t cmd_flow_director_ops =
11174 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11175 ops, "add#del#update");
11176 cmdline_parse_token_string_t cmd_flow_director_flow =
11177 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11179 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11180 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11182 cmdline_parse_token_string_t cmd_flow_director_ether =
11183 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11185 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11186 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11187 ether_type, UINT16);
11188 cmdline_parse_token_string_t cmd_flow_director_src =
11189 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11191 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11192 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11194 cmdline_parse_token_num_t cmd_flow_director_port_src =
11195 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11197 cmdline_parse_token_string_t cmd_flow_director_dst =
11198 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11200 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11201 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11203 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11204 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11206 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11207 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11208 verify_tag, "verify_tag");
11209 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11210 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11211 verify_tag_value, UINT32);
11212 cmdline_parse_token_string_t cmd_flow_director_tos =
11213 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11215 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11216 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11218 cmdline_parse_token_string_t cmd_flow_director_proto =
11219 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11221 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11222 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11223 proto_value, UINT8);
11224 cmdline_parse_token_string_t cmd_flow_director_ttl =
11225 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11227 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11228 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11230 cmdline_parse_token_string_t cmd_flow_director_vlan =
11231 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11233 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11234 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11235 vlan_value, UINT16);
11236 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11237 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11238 flexbytes, "flexbytes");
11239 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11240 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11241 flexbytes_value, NULL);
11242 cmdline_parse_token_string_t cmd_flow_director_drop =
11243 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11245 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11246 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11248 cmdline_parse_token_string_t cmd_flow_director_queue =
11249 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11251 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11252 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11254 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11255 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11257 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11258 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11259 fd_id_value, UINT32);
11261 cmdline_parse_token_string_t cmd_flow_director_mode =
11262 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11264 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11265 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11267 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11268 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11269 mode_value, "MAC-VLAN");
11270 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11271 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11272 mode_value, "Tunnel");
11273 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11274 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11275 mode_value, "raw");
11276 cmdline_parse_token_string_t cmd_flow_director_mac =
11277 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11279 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11280 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11282 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11283 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11285 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11286 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11287 tunnel_type, "NVGRE#VxLAN");
11288 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11289 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11290 tunnel_id, "tunnel-id");
11291 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11292 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11293 tunnel_id_value, UINT32);
11294 cmdline_parse_token_string_t cmd_flow_director_packet =
11295 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11297 cmdline_parse_token_string_t cmd_flow_director_filepath =
11298 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11301 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11302 .f = cmd_flow_director_filter_parsed,
11304 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11305 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11306 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11307 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11308 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11309 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11310 "fd_id <fd_id_value>: "
11311 "Add or delete an ip flow director entry on NIC",
11313 (void *)&cmd_flow_director_filter,
11314 (void *)&cmd_flow_director_port_id,
11315 (void *)&cmd_flow_director_mode,
11316 (void *)&cmd_flow_director_mode_ip,
11317 (void *)&cmd_flow_director_ops,
11318 (void *)&cmd_flow_director_flow,
11319 (void *)&cmd_flow_director_flow_type,
11320 (void *)&cmd_flow_director_src,
11321 (void *)&cmd_flow_director_ip_src,
11322 (void *)&cmd_flow_director_dst,
11323 (void *)&cmd_flow_director_ip_dst,
11324 (void *)&cmd_flow_director_tos,
11325 (void *)&cmd_flow_director_tos_value,
11326 (void *)&cmd_flow_director_proto,
11327 (void *)&cmd_flow_director_proto_value,
11328 (void *)&cmd_flow_director_ttl,
11329 (void *)&cmd_flow_director_ttl_value,
11330 (void *)&cmd_flow_director_vlan,
11331 (void *)&cmd_flow_director_vlan_value,
11332 (void *)&cmd_flow_director_flexbytes,
11333 (void *)&cmd_flow_director_flexbytes_value,
11334 (void *)&cmd_flow_director_drop,
11335 (void *)&cmd_flow_director_pf_vf,
11336 (void *)&cmd_flow_director_queue,
11337 (void *)&cmd_flow_director_queue_id,
11338 (void *)&cmd_flow_director_fd_id,
11339 (void *)&cmd_flow_director_fd_id_value,
11344 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11345 .f = cmd_flow_director_filter_parsed,
11347 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11348 "director entry on NIC",
11350 (void *)&cmd_flow_director_filter,
11351 (void *)&cmd_flow_director_port_id,
11352 (void *)&cmd_flow_director_mode,
11353 (void *)&cmd_flow_director_mode_ip,
11354 (void *)&cmd_flow_director_ops,
11355 (void *)&cmd_flow_director_flow,
11356 (void *)&cmd_flow_director_flow_type,
11357 (void *)&cmd_flow_director_src,
11358 (void *)&cmd_flow_director_ip_src,
11359 (void *)&cmd_flow_director_port_src,
11360 (void *)&cmd_flow_director_dst,
11361 (void *)&cmd_flow_director_ip_dst,
11362 (void *)&cmd_flow_director_port_dst,
11363 (void *)&cmd_flow_director_tos,
11364 (void *)&cmd_flow_director_tos_value,
11365 (void *)&cmd_flow_director_ttl,
11366 (void *)&cmd_flow_director_ttl_value,
11367 (void *)&cmd_flow_director_vlan,
11368 (void *)&cmd_flow_director_vlan_value,
11369 (void *)&cmd_flow_director_flexbytes,
11370 (void *)&cmd_flow_director_flexbytes_value,
11371 (void *)&cmd_flow_director_drop,
11372 (void *)&cmd_flow_director_pf_vf,
11373 (void *)&cmd_flow_director_queue,
11374 (void *)&cmd_flow_director_queue_id,
11375 (void *)&cmd_flow_director_fd_id,
11376 (void *)&cmd_flow_director_fd_id_value,
11381 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11382 .f = cmd_flow_director_filter_parsed,
11384 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11385 "director entry on NIC",
11387 (void *)&cmd_flow_director_filter,
11388 (void *)&cmd_flow_director_port_id,
11389 (void *)&cmd_flow_director_mode,
11390 (void *)&cmd_flow_director_mode_ip,
11391 (void *)&cmd_flow_director_ops,
11392 (void *)&cmd_flow_director_flow,
11393 (void *)&cmd_flow_director_flow_type,
11394 (void *)&cmd_flow_director_src,
11395 (void *)&cmd_flow_director_ip_src,
11396 (void *)&cmd_flow_director_port_src,
11397 (void *)&cmd_flow_director_dst,
11398 (void *)&cmd_flow_director_ip_dst,
11399 (void *)&cmd_flow_director_port_dst,
11400 (void *)&cmd_flow_director_verify_tag,
11401 (void *)&cmd_flow_director_verify_tag_value,
11402 (void *)&cmd_flow_director_tos,
11403 (void *)&cmd_flow_director_tos_value,
11404 (void *)&cmd_flow_director_ttl,
11405 (void *)&cmd_flow_director_ttl_value,
11406 (void *)&cmd_flow_director_vlan,
11407 (void *)&cmd_flow_director_vlan_value,
11408 (void *)&cmd_flow_director_flexbytes,
11409 (void *)&cmd_flow_director_flexbytes_value,
11410 (void *)&cmd_flow_director_drop,
11411 (void *)&cmd_flow_director_pf_vf,
11412 (void *)&cmd_flow_director_queue,
11413 (void *)&cmd_flow_director_queue_id,
11414 (void *)&cmd_flow_director_fd_id,
11415 (void *)&cmd_flow_director_fd_id_value,
11420 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11421 .f = cmd_flow_director_filter_parsed,
11423 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11424 "director entry on NIC",
11426 (void *)&cmd_flow_director_filter,
11427 (void *)&cmd_flow_director_port_id,
11428 (void *)&cmd_flow_director_mode,
11429 (void *)&cmd_flow_director_mode_ip,
11430 (void *)&cmd_flow_director_ops,
11431 (void *)&cmd_flow_director_flow,
11432 (void *)&cmd_flow_director_flow_type,
11433 (void *)&cmd_flow_director_ether,
11434 (void *)&cmd_flow_director_ether_type,
11435 (void *)&cmd_flow_director_flexbytes,
11436 (void *)&cmd_flow_director_flexbytes_value,
11437 (void *)&cmd_flow_director_drop,
11438 (void *)&cmd_flow_director_pf_vf,
11439 (void *)&cmd_flow_director_queue,
11440 (void *)&cmd_flow_director_queue_id,
11441 (void *)&cmd_flow_director_fd_id,
11442 (void *)&cmd_flow_director_fd_id_value,
11447 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11448 .f = cmd_flow_director_filter_parsed,
11450 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11451 "director entry on NIC",
11453 (void *)&cmd_flow_director_filter,
11454 (void *)&cmd_flow_director_port_id,
11455 (void *)&cmd_flow_director_mode,
11456 (void *)&cmd_flow_director_mode_mac_vlan,
11457 (void *)&cmd_flow_director_ops,
11458 (void *)&cmd_flow_director_mac,
11459 (void *)&cmd_flow_director_mac_addr,
11460 (void *)&cmd_flow_director_vlan,
11461 (void *)&cmd_flow_director_vlan_value,
11462 (void *)&cmd_flow_director_flexbytes,
11463 (void *)&cmd_flow_director_flexbytes_value,
11464 (void *)&cmd_flow_director_drop,
11465 (void *)&cmd_flow_director_queue,
11466 (void *)&cmd_flow_director_queue_id,
11467 (void *)&cmd_flow_director_fd_id,
11468 (void *)&cmd_flow_director_fd_id_value,
11473 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11474 .f = cmd_flow_director_filter_parsed,
11476 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11477 "director entry on NIC",
11479 (void *)&cmd_flow_director_filter,
11480 (void *)&cmd_flow_director_port_id,
11481 (void *)&cmd_flow_director_mode,
11482 (void *)&cmd_flow_director_mode_tunnel,
11483 (void *)&cmd_flow_director_ops,
11484 (void *)&cmd_flow_director_mac,
11485 (void *)&cmd_flow_director_mac_addr,
11486 (void *)&cmd_flow_director_vlan,
11487 (void *)&cmd_flow_director_vlan_value,
11488 (void *)&cmd_flow_director_tunnel,
11489 (void *)&cmd_flow_director_tunnel_type,
11490 (void *)&cmd_flow_director_tunnel_id,
11491 (void *)&cmd_flow_director_tunnel_id_value,
11492 (void *)&cmd_flow_director_flexbytes,
11493 (void *)&cmd_flow_director_flexbytes_value,
11494 (void *)&cmd_flow_director_drop,
11495 (void *)&cmd_flow_director_queue,
11496 (void *)&cmd_flow_director_queue_id,
11497 (void *)&cmd_flow_director_fd_id,
11498 (void *)&cmd_flow_director_fd_id_value,
11503 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11504 .f = cmd_flow_director_filter_parsed,
11506 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11507 "director entry on NIC",
11509 (void *)&cmd_flow_director_filter,
11510 (void *)&cmd_flow_director_port_id,
11511 (void *)&cmd_flow_director_mode,
11512 (void *)&cmd_flow_director_mode_raw,
11513 (void *)&cmd_flow_director_ops,
11514 (void *)&cmd_flow_director_flow,
11515 (void *)&cmd_flow_director_flow_type,
11516 (void *)&cmd_flow_director_drop,
11517 (void *)&cmd_flow_director_queue,
11518 (void *)&cmd_flow_director_queue_id,
11519 (void *)&cmd_flow_director_fd_id,
11520 (void *)&cmd_flow_director_fd_id_value,
11521 (void *)&cmd_flow_director_packet,
11522 (void *)&cmd_flow_director_filepath,
11527 struct cmd_flush_flow_director_result {
11528 cmdline_fixed_string_t flush_flow_director;
11532 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11533 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11534 flush_flow_director, "flush_flow_director");
11535 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11536 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11540 cmd_flush_flow_director_parsed(void *parsed_result,
11541 __attribute__((unused)) struct cmdline *cl,
11542 __attribute__((unused)) void *data)
11544 struct cmd_flow_director_result *res = parsed_result;
11547 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11549 printf("flow director is not supported on port %u.\n",
11554 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11555 RTE_ETH_FILTER_FLUSH, NULL);
11557 printf("flow director table flushing error: (%s)\n",
11561 cmdline_parse_inst_t cmd_flush_flow_director = {
11562 .f = cmd_flush_flow_director_parsed,
11564 .help_str = "flush_flow_director <port_id>: "
11565 "Flush all flow director entries of a device on NIC",
11567 (void *)&cmd_flush_flow_director_flush,
11568 (void *)&cmd_flush_flow_director_port_id,
11573 /* *** deal with flow director mask *** */
11574 struct cmd_flow_director_mask_result {
11575 cmdline_fixed_string_t flow_director_mask;
11577 cmdline_fixed_string_t mode;
11578 cmdline_fixed_string_t mode_value;
11579 cmdline_fixed_string_t vlan;
11580 uint16_t vlan_mask;
11581 cmdline_fixed_string_t src_mask;
11582 cmdline_ipaddr_t ipv4_src;
11583 cmdline_ipaddr_t ipv6_src;
11585 cmdline_fixed_string_t dst_mask;
11586 cmdline_ipaddr_t ipv4_dst;
11587 cmdline_ipaddr_t ipv6_dst;
11589 cmdline_fixed_string_t mac;
11590 uint8_t mac_addr_byte_mask;
11591 cmdline_fixed_string_t tunnel_id;
11592 uint32_t tunnel_id_mask;
11593 cmdline_fixed_string_t tunnel_type;
11594 uint8_t tunnel_type_mask;
11598 cmd_flow_director_mask_parsed(void *parsed_result,
11599 __attribute__((unused)) struct cmdline *cl,
11600 __attribute__((unused)) void *data)
11602 struct cmd_flow_director_mask_result *res = parsed_result;
11603 struct rte_eth_fdir_masks *mask;
11604 struct rte_port *port;
11606 port = &ports[res->port_id];
11607 /** Check if the port is not started **/
11608 if (port->port_status != RTE_PORT_STOPPED) {
11609 printf("Please stop port %d first\n", res->port_id);
11613 mask = &port->dev_conf.fdir_conf.mask;
11615 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11616 if (strcmp(res->mode_value, "MAC-VLAN")) {
11617 printf("Please set mode to MAC-VLAN.\n");
11621 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11622 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11623 if (strcmp(res->mode_value, "Tunnel")) {
11624 printf("Please set mode to Tunnel.\n");
11628 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11629 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11630 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11631 mask->tunnel_type_mask = res->tunnel_type_mask;
11633 if (strcmp(res->mode_value, "IP")) {
11634 printf("Please set mode to IP.\n");
11638 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11639 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11640 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11641 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11642 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11643 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11644 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11647 cmd_reconfig_device_queue(res->port_id, 1, 1);
11650 cmdline_parse_token_string_t cmd_flow_director_mask =
11651 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11652 flow_director_mask, "flow_director_mask");
11653 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11654 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11656 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11657 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11659 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11660 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11661 vlan_mask, UINT16);
11662 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11663 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11664 src_mask, "src_mask");
11665 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11666 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11668 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11669 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11671 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11672 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11674 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11675 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11676 dst_mask, "dst_mask");
11677 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11678 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11680 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11681 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11683 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11684 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11687 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11688 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11690 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11691 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11693 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11694 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11695 mode_value, "MAC-VLAN");
11696 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11697 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11698 mode_value, "Tunnel");
11699 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11700 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11702 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11703 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11704 mac_addr_byte_mask, UINT8);
11705 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11706 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11707 tunnel_type, "tunnel-type");
11708 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11709 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11710 tunnel_type_mask, UINT8);
11711 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11712 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11713 tunnel_id, "tunnel-id");
11714 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11715 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11716 tunnel_id_mask, UINT32);
11718 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11719 .f = cmd_flow_director_mask_parsed,
11721 .help_str = "flow_director_mask ... : "
11722 "Set IP mode flow director's mask on NIC",
11724 (void *)&cmd_flow_director_mask,
11725 (void *)&cmd_flow_director_mask_port_id,
11726 (void *)&cmd_flow_director_mask_mode,
11727 (void *)&cmd_flow_director_mask_mode_ip,
11728 (void *)&cmd_flow_director_mask_vlan,
11729 (void *)&cmd_flow_director_mask_vlan_value,
11730 (void *)&cmd_flow_director_mask_src,
11731 (void *)&cmd_flow_director_mask_ipv4_src,
11732 (void *)&cmd_flow_director_mask_ipv6_src,
11733 (void *)&cmd_flow_director_mask_port_src,
11734 (void *)&cmd_flow_director_mask_dst,
11735 (void *)&cmd_flow_director_mask_ipv4_dst,
11736 (void *)&cmd_flow_director_mask_ipv6_dst,
11737 (void *)&cmd_flow_director_mask_port_dst,
11742 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11743 .f = cmd_flow_director_mask_parsed,
11745 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11746 "flow director's mask on NIC",
11748 (void *)&cmd_flow_director_mask,
11749 (void *)&cmd_flow_director_mask_port_id,
11750 (void *)&cmd_flow_director_mask_mode,
11751 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11752 (void *)&cmd_flow_director_mask_vlan,
11753 (void *)&cmd_flow_director_mask_vlan_value,
11758 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11759 .f = cmd_flow_director_mask_parsed,
11761 .help_str = "flow_director_mask ... : Set tunnel mode "
11762 "flow director's mask on NIC",
11764 (void *)&cmd_flow_director_mask,
11765 (void *)&cmd_flow_director_mask_port_id,
11766 (void *)&cmd_flow_director_mask_mode,
11767 (void *)&cmd_flow_director_mask_mode_tunnel,
11768 (void *)&cmd_flow_director_mask_vlan,
11769 (void *)&cmd_flow_director_mask_vlan_value,
11770 (void *)&cmd_flow_director_mask_mac,
11771 (void *)&cmd_flow_director_mask_mac_value,
11772 (void *)&cmd_flow_director_mask_tunnel_type,
11773 (void *)&cmd_flow_director_mask_tunnel_type_value,
11774 (void *)&cmd_flow_director_mask_tunnel_id,
11775 (void *)&cmd_flow_director_mask_tunnel_id_value,
11780 /* *** deal with flow director mask on flexible payload *** */
11781 struct cmd_flow_director_flex_mask_result {
11782 cmdline_fixed_string_t flow_director_flexmask;
11784 cmdline_fixed_string_t flow;
11785 cmdline_fixed_string_t flow_type;
11786 cmdline_fixed_string_t mask;
11790 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11791 __attribute__((unused)) struct cmdline *cl,
11792 __attribute__((unused)) void *data)
11794 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11795 struct rte_eth_fdir_info fdir_info;
11796 struct rte_eth_fdir_flex_mask flex_mask;
11797 struct rte_port *port;
11798 uint64_t flow_type_mask;
11802 port = &ports[res->port_id];
11803 /** Check if the port is not started **/
11804 if (port->port_status != RTE_PORT_STOPPED) {
11805 printf("Please stop port %d first\n", res->port_id);
11809 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11810 ret = parse_flexbytes(res->mask,
11812 RTE_ETH_FDIR_MAX_FLEXLEN);
11814 printf("error: Cannot parse mask input.\n");
11818 memset(&fdir_info, 0, sizeof(fdir_info));
11819 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11820 RTE_ETH_FILTER_INFO, &fdir_info);
11822 printf("Cannot get FDir filter info\n");
11826 if (!strcmp(res->flow_type, "none")) {
11827 /* means don't specify the flow type */
11828 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11829 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11830 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11831 0, sizeof(struct rte_eth_fdir_flex_mask));
11832 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11833 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11835 sizeof(struct rte_eth_fdir_flex_mask));
11836 cmd_reconfig_device_queue(res->port_id, 1, 1);
11839 flow_type_mask = fdir_info.flow_types_mask[0];
11840 if (!strcmp(res->flow_type, "all")) {
11841 if (!flow_type_mask) {
11842 printf("No flow type supported\n");
11845 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11846 if (flow_type_mask & (1ULL << i)) {
11847 flex_mask.flow_type = i;
11848 fdir_set_flex_mask(res->port_id, &flex_mask);
11851 cmd_reconfig_device_queue(res->port_id, 1, 1);
11854 flex_mask.flow_type = str2flowtype(res->flow_type);
11855 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11856 printf("Flow type %s not supported on port %d\n",
11857 res->flow_type, res->port_id);
11860 fdir_set_flex_mask(res->port_id, &flex_mask);
11861 cmd_reconfig_device_queue(res->port_id, 1, 1);
11864 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11865 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11866 flow_director_flexmask,
11867 "flow_director_flex_mask");
11868 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11869 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11871 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11872 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11874 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11875 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11876 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11877 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11878 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11879 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11882 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11883 .f = cmd_flow_director_flex_mask_parsed,
11885 .help_str = "flow_director_flex_mask ... : "
11886 "Set flow director's flex mask on NIC",
11888 (void *)&cmd_flow_director_flexmask,
11889 (void *)&cmd_flow_director_flexmask_port_id,
11890 (void *)&cmd_flow_director_flexmask_flow,
11891 (void *)&cmd_flow_director_flexmask_flow_type,
11892 (void *)&cmd_flow_director_flexmask_mask,
11897 /* *** deal with flow director flexible payload configuration *** */
11898 struct cmd_flow_director_flexpayload_result {
11899 cmdline_fixed_string_t flow_director_flexpayload;
11901 cmdline_fixed_string_t payload_layer;
11902 cmdline_fixed_string_t payload_cfg;
11906 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11909 const char *p, *p0 = q_arg;
11911 unsigned long int_fld;
11912 char *str_fld[max_num];
11917 p = strchr(p0, '(');
11921 p0 = strchr(p, ')');
11926 if (size >= sizeof(s))
11929 snprintf(s, sizeof(s), "%.*s", size, p);
11930 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11931 if (ret < 0 || ret > max_num)
11933 for (i = 0; i < ret; i++) {
11935 int_fld = strtoul(str_fld[i], &end, 0);
11936 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11938 offsets[i] = (uint16_t)int_fld;
11944 cmd_flow_director_flxpld_parsed(void *parsed_result,
11945 __attribute__((unused)) struct cmdline *cl,
11946 __attribute__((unused)) void *data)
11948 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11949 struct rte_eth_flex_payload_cfg flex_cfg;
11950 struct rte_port *port;
11953 port = &ports[res->port_id];
11954 /** Check if the port is not started **/
11955 if (port->port_status != RTE_PORT_STOPPED) {
11956 printf("Please stop port %d first\n", res->port_id);
11960 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11962 if (!strcmp(res->payload_layer, "raw"))
11963 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11964 else if (!strcmp(res->payload_layer, "l2"))
11965 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11966 else if (!strcmp(res->payload_layer, "l3"))
11967 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11968 else if (!strcmp(res->payload_layer, "l4"))
11969 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11971 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11972 RTE_ETH_FDIR_MAX_FLEXLEN);
11974 printf("error: Cannot parse flex payload input.\n");
11978 fdir_set_flex_payload(res->port_id, &flex_cfg);
11979 cmd_reconfig_device_queue(res->port_id, 1, 1);
11982 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11983 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11984 flow_director_flexpayload,
11985 "flow_director_flex_payload");
11986 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11987 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11989 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11990 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11991 payload_layer, "raw#l2#l3#l4");
11992 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11993 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11994 payload_cfg, NULL);
11996 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11997 .f = cmd_flow_director_flxpld_parsed,
11999 .help_str = "flow_director_flexpayload ... : "
12000 "Set flow director's flex payload on NIC",
12002 (void *)&cmd_flow_director_flexpayload,
12003 (void *)&cmd_flow_director_flexpayload_port_id,
12004 (void *)&cmd_flow_director_flexpayload_payload_layer,
12005 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12010 /* Generic flow interface command. */
12011 extern cmdline_parse_inst_t cmd_flow;
12013 /* *** Classification Filters Control *** */
12014 /* *** Get symmetric hash enable per port *** */
12015 struct cmd_get_sym_hash_ena_per_port_result {
12016 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12021 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12022 __rte_unused struct cmdline *cl,
12023 __rte_unused void *data)
12025 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12026 struct rte_eth_hash_filter_info info;
12029 if (rte_eth_dev_filter_supported(res->port_id,
12030 RTE_ETH_FILTER_HASH) < 0) {
12031 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12036 memset(&info, 0, sizeof(info));
12037 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12038 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12039 RTE_ETH_FILTER_GET, &info);
12042 printf("Cannot get symmetric hash enable per port "
12043 "on port %u\n", res->port_id);
12047 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12048 "enabled" : "disabled", res->port_id);
12051 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12052 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12053 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12054 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12055 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12058 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12059 .f = cmd_get_sym_hash_per_port_parsed,
12061 .help_str = "get_sym_hash_ena_per_port <port_id>",
12063 (void *)&cmd_get_sym_hash_ena_per_port_all,
12064 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12069 /* *** Set symmetric hash enable per port *** */
12070 struct cmd_set_sym_hash_ena_per_port_result {
12071 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12072 cmdline_fixed_string_t enable;
12077 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12078 __rte_unused struct cmdline *cl,
12079 __rte_unused void *data)
12081 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12082 struct rte_eth_hash_filter_info info;
12085 if (rte_eth_dev_filter_supported(res->port_id,
12086 RTE_ETH_FILTER_HASH) < 0) {
12087 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12092 memset(&info, 0, sizeof(info));
12093 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12094 if (!strcmp(res->enable, "enable"))
12095 info.info.enable = 1;
12096 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12097 RTE_ETH_FILTER_SET, &info);
12099 printf("Cannot set symmetric hash enable per port on "
12100 "port %u\n", res->port_id);
12103 printf("Symmetric hash has been set to %s on port %u\n",
12104 res->enable, res->port_id);
12107 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12108 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12109 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12110 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12111 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12113 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12114 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12115 enable, "enable#disable");
12117 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12118 .f = cmd_set_sym_hash_per_port_parsed,
12120 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12122 (void *)&cmd_set_sym_hash_ena_per_port_all,
12123 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12124 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12129 /* Get global config of hash function */
12130 struct cmd_get_hash_global_config_result {
12131 cmdline_fixed_string_t get_hash_global_config;
12136 flowtype_to_str(uint16_t ftype)
12142 } ftype_table[] = {
12143 {"ipv4", RTE_ETH_FLOW_IPV4},
12144 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12145 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12146 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12147 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12148 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12149 {"ipv6", RTE_ETH_FLOW_IPV6},
12150 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12151 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12152 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12153 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12154 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12155 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12156 {"port", RTE_ETH_FLOW_PORT},
12157 {"vxlan", RTE_ETH_FLOW_VXLAN},
12158 {"geneve", RTE_ETH_FLOW_GENEVE},
12159 {"nvgre", RTE_ETH_FLOW_NVGRE},
12160 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12163 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12164 if (ftype_table[i].ftype == ftype)
12165 return ftype_table[i].str;
12172 cmd_get_hash_global_config_parsed(void *parsed_result,
12173 __rte_unused struct cmdline *cl,
12174 __rte_unused void *data)
12176 struct cmd_get_hash_global_config_result *res = parsed_result;
12177 struct rte_eth_hash_filter_info info;
12178 uint32_t idx, offset;
12183 if (rte_eth_dev_filter_supported(res->port_id,
12184 RTE_ETH_FILTER_HASH) < 0) {
12185 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12190 memset(&info, 0, sizeof(info));
12191 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12192 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12193 RTE_ETH_FILTER_GET, &info);
12195 printf("Cannot get hash global configurations by port %d\n",
12200 switch (info.info.global_conf.hash_func) {
12201 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12202 printf("Hash function is Toeplitz\n");
12204 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12205 printf("Hash function is Simple XOR\n");
12207 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12208 printf("Hash function is Symmetric Toeplitz\n");
12211 printf("Unknown hash function\n");
12215 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12216 idx = i / UINT64_BIT;
12217 offset = i % UINT64_BIT;
12218 if (!(info.info.global_conf.valid_bit_mask[idx] &
12221 str = flowtype_to_str(i);
12224 printf("Symmetric hash is %s globally for flow type %s "
12226 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12227 (1ULL << offset)) ? "enabled" : "disabled"), str,
12232 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12233 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12234 get_hash_global_config, "get_hash_global_config");
12235 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12236 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12239 cmdline_parse_inst_t cmd_get_hash_global_config = {
12240 .f = cmd_get_hash_global_config_parsed,
12242 .help_str = "get_hash_global_config <port_id>",
12244 (void *)&cmd_get_hash_global_config_all,
12245 (void *)&cmd_get_hash_global_config_port_id,
12250 /* Set global config of hash function */
12251 struct cmd_set_hash_global_config_result {
12252 cmdline_fixed_string_t set_hash_global_config;
12254 cmdline_fixed_string_t hash_func;
12255 cmdline_fixed_string_t flow_type;
12256 cmdline_fixed_string_t enable;
12260 cmd_set_hash_global_config_parsed(void *parsed_result,
12261 __rte_unused struct cmdline *cl,
12262 __rte_unused void *data)
12264 struct cmd_set_hash_global_config_result *res = parsed_result;
12265 struct rte_eth_hash_filter_info info;
12266 uint32_t ftype, idx, offset;
12269 if (rte_eth_dev_filter_supported(res->port_id,
12270 RTE_ETH_FILTER_HASH) < 0) {
12271 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12275 memset(&info, 0, sizeof(info));
12276 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12277 if (!strcmp(res->hash_func, "toeplitz"))
12278 info.info.global_conf.hash_func =
12279 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12280 else if (!strcmp(res->hash_func, "simple_xor"))
12281 info.info.global_conf.hash_func =
12282 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12283 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12284 info.info.global_conf.hash_func =
12285 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12286 else if (!strcmp(res->hash_func, "default"))
12287 info.info.global_conf.hash_func =
12288 RTE_ETH_HASH_FUNCTION_DEFAULT;
12290 ftype = str2flowtype(res->flow_type);
12291 idx = ftype / UINT64_BIT;
12292 offset = ftype % UINT64_BIT;
12293 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12294 if (!strcmp(res->enable, "enable"))
12295 info.info.global_conf.sym_hash_enable_mask[idx] |=
12297 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12298 RTE_ETH_FILTER_SET, &info);
12300 printf("Cannot set global hash configurations by port %d\n",
12303 printf("Global hash configurations have been set "
12304 "successfully by port %d\n", res->port_id);
12307 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12308 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12309 set_hash_global_config, "set_hash_global_config");
12310 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12311 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12313 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12314 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12315 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12316 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12317 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12319 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12320 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12321 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12322 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12323 enable, "enable#disable");
12325 cmdline_parse_inst_t cmd_set_hash_global_config = {
12326 .f = cmd_set_hash_global_config_parsed,
12328 .help_str = "set_hash_global_config <port_id> "
12329 "toeplitz|simple_xor|symmetric_toeplitz|default "
12330 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12331 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12332 "l2_payload enable|disable",
12334 (void *)&cmd_set_hash_global_config_all,
12335 (void *)&cmd_set_hash_global_config_port_id,
12336 (void *)&cmd_set_hash_global_config_hash_func,
12337 (void *)&cmd_set_hash_global_config_flow_type,
12338 (void *)&cmd_set_hash_global_config_enable,
12343 /* Set hash input set */
12344 struct cmd_set_hash_input_set_result {
12345 cmdline_fixed_string_t set_hash_input_set;
12347 cmdline_fixed_string_t flow_type;
12348 cmdline_fixed_string_t inset_field;
12349 cmdline_fixed_string_t select;
12352 static enum rte_eth_input_set_field
12353 str2inset(char *string)
12357 static const struct {
12359 enum rte_eth_input_set_field inset;
12360 } inset_table[] = {
12361 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12362 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12363 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12364 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12365 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12366 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12367 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12368 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12369 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12370 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12371 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12372 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12373 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12374 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12375 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12376 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12377 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12378 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12379 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12380 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12381 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12382 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12383 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12384 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12385 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12386 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12387 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12388 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12389 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12390 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12391 {"none", RTE_ETH_INPUT_SET_NONE},
12394 for (i = 0; i < RTE_DIM(inset_table); i++) {
12395 if (!strcmp(string, inset_table[i].str))
12396 return inset_table[i].inset;
12399 return RTE_ETH_INPUT_SET_UNKNOWN;
12403 cmd_set_hash_input_set_parsed(void *parsed_result,
12404 __rte_unused struct cmdline *cl,
12405 __rte_unused void *data)
12407 struct cmd_set_hash_input_set_result *res = parsed_result;
12408 struct rte_eth_hash_filter_info info;
12410 memset(&info, 0, sizeof(info));
12411 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12412 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12413 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12414 info.info.input_set_conf.inset_size = 1;
12415 if (!strcmp(res->select, "select"))
12416 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12417 else if (!strcmp(res->select, "add"))
12418 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12419 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12420 RTE_ETH_FILTER_SET, &info);
12423 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12424 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12425 set_hash_input_set, "set_hash_input_set");
12426 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12427 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12429 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12430 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12432 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12433 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12435 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12436 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12437 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12438 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12439 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12441 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12442 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12443 select, "select#add");
12445 cmdline_parse_inst_t cmd_set_hash_input_set = {
12446 .f = cmd_set_hash_input_set_parsed,
12448 .help_str = "set_hash_input_set <port_id> "
12449 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12450 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12451 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12452 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12453 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12454 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12455 "fld-7th|fld-8th|none select|add",
12457 (void *)&cmd_set_hash_input_set_cmd,
12458 (void *)&cmd_set_hash_input_set_port_id,
12459 (void *)&cmd_set_hash_input_set_flow_type,
12460 (void *)&cmd_set_hash_input_set_field,
12461 (void *)&cmd_set_hash_input_set_select,
12466 /* Set flow director input set */
12467 struct cmd_set_fdir_input_set_result {
12468 cmdline_fixed_string_t set_fdir_input_set;
12470 cmdline_fixed_string_t flow_type;
12471 cmdline_fixed_string_t inset_field;
12472 cmdline_fixed_string_t select;
12476 cmd_set_fdir_input_set_parsed(void *parsed_result,
12477 __rte_unused struct cmdline *cl,
12478 __rte_unused void *data)
12480 struct cmd_set_fdir_input_set_result *res = parsed_result;
12481 struct rte_eth_fdir_filter_info info;
12483 memset(&info, 0, sizeof(info));
12484 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12485 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12486 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12487 info.info.input_set_conf.inset_size = 1;
12488 if (!strcmp(res->select, "select"))
12489 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12490 else if (!strcmp(res->select, "add"))
12491 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12492 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12493 RTE_ETH_FILTER_SET, &info);
12496 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12497 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12498 set_fdir_input_set, "set_fdir_input_set");
12499 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12500 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12502 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12503 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12505 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12506 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12507 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12508 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12510 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12511 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12512 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12513 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12514 "sctp-veri-tag#none");
12515 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12516 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12517 select, "select#add");
12519 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12520 .f = cmd_set_fdir_input_set_parsed,
12522 .help_str = "set_fdir_input_set <port_id> "
12523 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12524 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12525 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12526 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12527 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12528 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12529 "sctp-veri-tag|none select|add",
12531 (void *)&cmd_set_fdir_input_set_cmd,
12532 (void *)&cmd_set_fdir_input_set_port_id,
12533 (void *)&cmd_set_fdir_input_set_flow_type,
12534 (void *)&cmd_set_fdir_input_set_field,
12535 (void *)&cmd_set_fdir_input_set_select,
12540 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12541 struct cmd_mcast_addr_result {
12542 cmdline_fixed_string_t mcast_addr_cmd;
12543 cmdline_fixed_string_t what;
12545 struct rte_ether_addr mc_addr;
12548 static void cmd_mcast_addr_parsed(void *parsed_result,
12549 __attribute__((unused)) struct cmdline *cl,
12550 __attribute__((unused)) void *data)
12552 struct cmd_mcast_addr_result *res = parsed_result;
12554 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12555 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12556 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12557 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12558 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12561 if (strcmp(res->what, "add") == 0)
12562 mcast_addr_add(res->port_num, &res->mc_addr);
12564 mcast_addr_remove(res->port_num, &res->mc_addr);
12567 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12568 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12569 mcast_addr_cmd, "mcast_addr");
12570 cmdline_parse_token_string_t cmd_mcast_addr_what =
12571 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12573 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12574 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12575 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12576 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12578 cmdline_parse_inst_t cmd_mcast_addr = {
12579 .f = cmd_mcast_addr_parsed,
12581 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12582 "Add/Remove multicast MAC address on port_id",
12584 (void *)&cmd_mcast_addr_cmd,
12585 (void *)&cmd_mcast_addr_what,
12586 (void *)&cmd_mcast_addr_portnum,
12587 (void *)&cmd_mcast_addr_addr,
12592 /* l2 tunnel config
12593 * only support E-tag now.
12596 /* Ether type config */
12597 struct cmd_config_l2_tunnel_eth_type_result {
12598 cmdline_fixed_string_t port;
12599 cmdline_fixed_string_t config;
12600 cmdline_fixed_string_t all;
12602 cmdline_fixed_string_t l2_tunnel;
12603 cmdline_fixed_string_t l2_tunnel_type;
12604 cmdline_fixed_string_t eth_type;
12605 uint16_t eth_type_val;
12608 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12609 TOKEN_STRING_INITIALIZER
12610 (struct cmd_config_l2_tunnel_eth_type_result,
12612 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12613 TOKEN_STRING_INITIALIZER
12614 (struct cmd_config_l2_tunnel_eth_type_result,
12616 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12617 TOKEN_STRING_INITIALIZER
12618 (struct cmd_config_l2_tunnel_eth_type_result,
12620 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12621 TOKEN_NUM_INITIALIZER
12622 (struct cmd_config_l2_tunnel_eth_type_result,
12624 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12625 TOKEN_STRING_INITIALIZER
12626 (struct cmd_config_l2_tunnel_eth_type_result,
12627 l2_tunnel, "l2-tunnel");
12628 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12629 TOKEN_STRING_INITIALIZER
12630 (struct cmd_config_l2_tunnel_eth_type_result,
12631 l2_tunnel_type, "E-tag");
12632 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12633 TOKEN_STRING_INITIALIZER
12634 (struct cmd_config_l2_tunnel_eth_type_result,
12635 eth_type, "ether-type");
12636 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12637 TOKEN_NUM_INITIALIZER
12638 (struct cmd_config_l2_tunnel_eth_type_result,
12639 eth_type_val, UINT16);
12641 static enum rte_eth_tunnel_type
12642 str2fdir_l2_tunnel_type(char *string)
12646 static const struct {
12648 enum rte_eth_tunnel_type type;
12649 } l2_tunnel_type_str[] = {
12650 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12653 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12654 if (!strcmp(l2_tunnel_type_str[i].str, string))
12655 return l2_tunnel_type_str[i].type;
12657 return RTE_TUNNEL_TYPE_NONE;
12660 /* ether type config for all ports */
12662 cmd_config_l2_tunnel_eth_type_all_parsed
12663 (void *parsed_result,
12664 __attribute__((unused)) struct cmdline *cl,
12665 __attribute__((unused)) void *data)
12667 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12668 struct rte_eth_l2_tunnel_conf entry;
12671 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12672 entry.ether_type = res->eth_type_val;
12674 RTE_ETH_FOREACH_DEV(pid) {
12675 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12679 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12680 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12682 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12684 (void *)&cmd_config_l2_tunnel_eth_type_port,
12685 (void *)&cmd_config_l2_tunnel_eth_type_config,
12686 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12687 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12688 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12689 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12690 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12695 /* ether type config for a specific port */
12697 cmd_config_l2_tunnel_eth_type_specific_parsed(
12698 void *parsed_result,
12699 __attribute__((unused)) struct cmdline *cl,
12700 __attribute__((unused)) void *data)
12702 struct cmd_config_l2_tunnel_eth_type_result *res =
12704 struct rte_eth_l2_tunnel_conf entry;
12706 if (port_id_is_invalid(res->id, ENABLED_WARN))
12709 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12710 entry.ether_type = res->eth_type_val;
12712 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12715 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12716 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12718 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12720 (void *)&cmd_config_l2_tunnel_eth_type_port,
12721 (void *)&cmd_config_l2_tunnel_eth_type_config,
12722 (void *)&cmd_config_l2_tunnel_eth_type_id,
12723 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12724 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12725 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12726 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12731 /* Enable/disable l2 tunnel */
12732 struct cmd_config_l2_tunnel_en_dis_result {
12733 cmdline_fixed_string_t port;
12734 cmdline_fixed_string_t config;
12735 cmdline_fixed_string_t all;
12737 cmdline_fixed_string_t l2_tunnel;
12738 cmdline_fixed_string_t l2_tunnel_type;
12739 cmdline_fixed_string_t en_dis;
12742 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12743 TOKEN_STRING_INITIALIZER
12744 (struct cmd_config_l2_tunnel_en_dis_result,
12746 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12747 TOKEN_STRING_INITIALIZER
12748 (struct cmd_config_l2_tunnel_en_dis_result,
12750 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12751 TOKEN_STRING_INITIALIZER
12752 (struct cmd_config_l2_tunnel_en_dis_result,
12754 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12755 TOKEN_NUM_INITIALIZER
12756 (struct cmd_config_l2_tunnel_en_dis_result,
12758 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12759 TOKEN_STRING_INITIALIZER
12760 (struct cmd_config_l2_tunnel_en_dis_result,
12761 l2_tunnel, "l2-tunnel");
12762 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12763 TOKEN_STRING_INITIALIZER
12764 (struct cmd_config_l2_tunnel_en_dis_result,
12765 l2_tunnel_type, "E-tag");
12766 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12767 TOKEN_STRING_INITIALIZER
12768 (struct cmd_config_l2_tunnel_en_dis_result,
12769 en_dis, "enable#disable");
12771 /* enable/disable l2 tunnel for all ports */
12773 cmd_config_l2_tunnel_en_dis_all_parsed(
12774 void *parsed_result,
12775 __attribute__((unused)) struct cmdline *cl,
12776 __attribute__((unused)) void *data)
12778 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12779 struct rte_eth_l2_tunnel_conf entry;
12783 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12785 if (!strcmp("enable", res->en_dis))
12790 RTE_ETH_FOREACH_DEV(pid) {
12791 rte_eth_dev_l2_tunnel_offload_set(pid,
12793 ETH_L2_TUNNEL_ENABLE_MASK,
12798 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12799 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12801 .help_str = "port config all l2-tunnel E-tag enable|disable",
12803 (void *)&cmd_config_l2_tunnel_en_dis_port,
12804 (void *)&cmd_config_l2_tunnel_en_dis_config,
12805 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12806 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12807 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12808 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12813 /* enable/disable l2 tunnel for a port */
12815 cmd_config_l2_tunnel_en_dis_specific_parsed(
12816 void *parsed_result,
12817 __attribute__((unused)) struct cmdline *cl,
12818 __attribute__((unused)) void *data)
12820 struct cmd_config_l2_tunnel_en_dis_result *res =
12822 struct rte_eth_l2_tunnel_conf entry;
12824 if (port_id_is_invalid(res->id, ENABLED_WARN))
12827 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12829 if (!strcmp("enable", res->en_dis))
12830 rte_eth_dev_l2_tunnel_offload_set(res->id,
12832 ETH_L2_TUNNEL_ENABLE_MASK,
12835 rte_eth_dev_l2_tunnel_offload_set(res->id,
12837 ETH_L2_TUNNEL_ENABLE_MASK,
12841 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12842 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12844 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12846 (void *)&cmd_config_l2_tunnel_en_dis_port,
12847 (void *)&cmd_config_l2_tunnel_en_dis_config,
12848 (void *)&cmd_config_l2_tunnel_en_dis_id,
12849 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12850 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12851 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12856 /* E-tag configuration */
12858 /* Common result structure for all E-tag configuration */
12859 struct cmd_config_e_tag_result {
12860 cmdline_fixed_string_t e_tag;
12861 cmdline_fixed_string_t set;
12862 cmdline_fixed_string_t insertion;
12863 cmdline_fixed_string_t stripping;
12864 cmdline_fixed_string_t forwarding;
12865 cmdline_fixed_string_t filter;
12866 cmdline_fixed_string_t add;
12867 cmdline_fixed_string_t del;
12868 cmdline_fixed_string_t on;
12869 cmdline_fixed_string_t off;
12870 cmdline_fixed_string_t on_off;
12871 cmdline_fixed_string_t port_tag_id;
12872 uint32_t port_tag_id_val;
12873 cmdline_fixed_string_t e_tag_id;
12874 uint16_t e_tag_id_val;
12875 cmdline_fixed_string_t dst_pool;
12876 uint8_t dst_pool_val;
12877 cmdline_fixed_string_t port;
12879 cmdline_fixed_string_t vf;
12883 /* Common CLI fields for all E-tag configuration */
12884 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12885 TOKEN_STRING_INITIALIZER
12886 (struct cmd_config_e_tag_result,
12888 cmdline_parse_token_string_t cmd_config_e_tag_set =
12889 TOKEN_STRING_INITIALIZER
12890 (struct cmd_config_e_tag_result,
12892 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12893 TOKEN_STRING_INITIALIZER
12894 (struct cmd_config_e_tag_result,
12895 insertion, "insertion");
12896 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12897 TOKEN_STRING_INITIALIZER
12898 (struct cmd_config_e_tag_result,
12899 stripping, "stripping");
12900 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12901 TOKEN_STRING_INITIALIZER
12902 (struct cmd_config_e_tag_result,
12903 forwarding, "forwarding");
12904 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12905 TOKEN_STRING_INITIALIZER
12906 (struct cmd_config_e_tag_result,
12908 cmdline_parse_token_string_t cmd_config_e_tag_add =
12909 TOKEN_STRING_INITIALIZER
12910 (struct cmd_config_e_tag_result,
12912 cmdline_parse_token_string_t cmd_config_e_tag_del =
12913 TOKEN_STRING_INITIALIZER
12914 (struct cmd_config_e_tag_result,
12916 cmdline_parse_token_string_t cmd_config_e_tag_on =
12917 TOKEN_STRING_INITIALIZER
12918 (struct cmd_config_e_tag_result,
12920 cmdline_parse_token_string_t cmd_config_e_tag_off =
12921 TOKEN_STRING_INITIALIZER
12922 (struct cmd_config_e_tag_result,
12924 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12925 TOKEN_STRING_INITIALIZER
12926 (struct cmd_config_e_tag_result,
12928 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12929 TOKEN_STRING_INITIALIZER
12930 (struct cmd_config_e_tag_result,
12931 port_tag_id, "port-tag-id");
12932 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12933 TOKEN_NUM_INITIALIZER
12934 (struct cmd_config_e_tag_result,
12935 port_tag_id_val, UINT32);
12936 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12937 TOKEN_STRING_INITIALIZER
12938 (struct cmd_config_e_tag_result,
12939 e_tag_id, "e-tag-id");
12940 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12941 TOKEN_NUM_INITIALIZER
12942 (struct cmd_config_e_tag_result,
12943 e_tag_id_val, UINT16);
12944 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12945 TOKEN_STRING_INITIALIZER
12946 (struct cmd_config_e_tag_result,
12947 dst_pool, "dst-pool");
12948 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12949 TOKEN_NUM_INITIALIZER
12950 (struct cmd_config_e_tag_result,
12951 dst_pool_val, UINT8);
12952 cmdline_parse_token_string_t cmd_config_e_tag_port =
12953 TOKEN_STRING_INITIALIZER
12954 (struct cmd_config_e_tag_result,
12956 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12957 TOKEN_NUM_INITIALIZER
12958 (struct cmd_config_e_tag_result,
12960 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12961 TOKEN_STRING_INITIALIZER
12962 (struct cmd_config_e_tag_result,
12964 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12965 TOKEN_NUM_INITIALIZER
12966 (struct cmd_config_e_tag_result,
12969 /* E-tag insertion configuration */
12971 cmd_config_e_tag_insertion_en_parsed(
12972 void *parsed_result,
12973 __attribute__((unused)) struct cmdline *cl,
12974 __attribute__((unused)) void *data)
12976 struct cmd_config_e_tag_result *res =
12978 struct rte_eth_l2_tunnel_conf entry;
12980 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12983 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12984 entry.tunnel_id = res->port_tag_id_val;
12985 entry.vf_id = res->vf_id;
12986 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12988 ETH_L2_TUNNEL_INSERTION_MASK,
12993 cmd_config_e_tag_insertion_dis_parsed(
12994 void *parsed_result,
12995 __attribute__((unused)) struct cmdline *cl,
12996 __attribute__((unused)) void *data)
12998 struct cmd_config_e_tag_result *res =
13000 struct rte_eth_l2_tunnel_conf entry;
13002 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13005 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13006 entry.vf_id = res->vf_id;
13008 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13010 ETH_L2_TUNNEL_INSERTION_MASK,
13014 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13015 .f = cmd_config_e_tag_insertion_en_parsed,
13017 .help_str = "E-tag ... : E-tag insertion enable",
13019 (void *)&cmd_config_e_tag_e_tag,
13020 (void *)&cmd_config_e_tag_set,
13021 (void *)&cmd_config_e_tag_insertion,
13022 (void *)&cmd_config_e_tag_on,
13023 (void *)&cmd_config_e_tag_port_tag_id,
13024 (void *)&cmd_config_e_tag_port_tag_id_val,
13025 (void *)&cmd_config_e_tag_port,
13026 (void *)&cmd_config_e_tag_port_id,
13027 (void *)&cmd_config_e_tag_vf,
13028 (void *)&cmd_config_e_tag_vf_id,
13033 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13034 .f = cmd_config_e_tag_insertion_dis_parsed,
13036 .help_str = "E-tag ... : E-tag insertion disable",
13038 (void *)&cmd_config_e_tag_e_tag,
13039 (void *)&cmd_config_e_tag_set,
13040 (void *)&cmd_config_e_tag_insertion,
13041 (void *)&cmd_config_e_tag_off,
13042 (void *)&cmd_config_e_tag_port,
13043 (void *)&cmd_config_e_tag_port_id,
13044 (void *)&cmd_config_e_tag_vf,
13045 (void *)&cmd_config_e_tag_vf_id,
13050 /* E-tag stripping configuration */
13052 cmd_config_e_tag_stripping_parsed(
13053 void *parsed_result,
13054 __attribute__((unused)) struct cmdline *cl,
13055 __attribute__((unused)) void *data)
13057 struct cmd_config_e_tag_result *res =
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_STRIPPING_MASK,
13073 rte_eth_dev_l2_tunnel_offload_set
13076 ETH_L2_TUNNEL_STRIPPING_MASK,
13080 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13081 .f = cmd_config_e_tag_stripping_parsed,
13083 .help_str = "E-tag ... : E-tag stripping enable/disable",
13085 (void *)&cmd_config_e_tag_e_tag,
13086 (void *)&cmd_config_e_tag_set,
13087 (void *)&cmd_config_e_tag_stripping,
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 forwarding configuration */
13097 cmd_config_e_tag_forwarding_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;
13105 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13108 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13110 if (!strcmp(res->on_off, "on"))
13111 rte_eth_dev_l2_tunnel_offload_set
13114 ETH_L2_TUNNEL_FORWARDING_MASK,
13117 rte_eth_dev_l2_tunnel_offload_set
13120 ETH_L2_TUNNEL_FORWARDING_MASK,
13124 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13125 .f = cmd_config_e_tag_forwarding_parsed,
13127 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13129 (void *)&cmd_config_e_tag_e_tag,
13130 (void *)&cmd_config_e_tag_set,
13131 (void *)&cmd_config_e_tag_forwarding,
13132 (void *)&cmd_config_e_tag_on_off,
13133 (void *)&cmd_config_e_tag_port,
13134 (void *)&cmd_config_e_tag_port_id,
13139 /* E-tag filter configuration */
13141 cmd_config_e_tag_filter_add_parsed(
13142 void *parsed_result,
13143 __attribute__((unused)) struct cmdline *cl,
13144 __attribute__((unused)) void *data)
13146 struct cmd_config_e_tag_result *res = parsed_result;
13147 struct rte_eth_l2_tunnel_conf entry;
13150 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13153 if (res->e_tag_id_val > 0x3fff) {
13154 printf("e-tag-id must be equal or less than 0x3fff.\n");
13158 ret = rte_eth_dev_filter_supported(res->port_id,
13159 RTE_ETH_FILTER_L2_TUNNEL);
13161 printf("E-tag filter is not supported on port %u.\n",
13166 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13167 entry.tunnel_id = res->e_tag_id_val;
13168 entry.pool = res->dst_pool_val;
13170 ret = rte_eth_dev_filter_ctrl(res->port_id,
13171 RTE_ETH_FILTER_L2_TUNNEL,
13172 RTE_ETH_FILTER_ADD,
13175 printf("E-tag filter programming error: (%s)\n",
13179 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13180 .f = cmd_config_e_tag_filter_add_parsed,
13182 .help_str = "E-tag ... : E-tag filter add",
13184 (void *)&cmd_config_e_tag_e_tag,
13185 (void *)&cmd_config_e_tag_set,
13186 (void *)&cmd_config_e_tag_filter,
13187 (void *)&cmd_config_e_tag_add,
13188 (void *)&cmd_config_e_tag_e_tag_id,
13189 (void *)&cmd_config_e_tag_e_tag_id_val,
13190 (void *)&cmd_config_e_tag_dst_pool,
13191 (void *)&cmd_config_e_tag_dst_pool_val,
13192 (void *)&cmd_config_e_tag_port,
13193 (void *)&cmd_config_e_tag_port_id,
13199 cmd_config_e_tag_filter_del_parsed(
13200 void *parsed_result,
13201 __attribute__((unused)) struct cmdline *cl,
13202 __attribute__((unused)) void *data)
13204 struct cmd_config_e_tag_result *res = parsed_result;
13205 struct rte_eth_l2_tunnel_conf entry;
13208 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13211 if (res->e_tag_id_val > 0x3fff) {
13212 printf("e-tag-id must be less than 0x3fff.\n");
13216 ret = rte_eth_dev_filter_supported(res->port_id,
13217 RTE_ETH_FILTER_L2_TUNNEL);
13219 printf("E-tag filter is not supported on port %u.\n",
13224 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13225 entry.tunnel_id = res->e_tag_id_val;
13227 ret = rte_eth_dev_filter_ctrl(res->port_id,
13228 RTE_ETH_FILTER_L2_TUNNEL,
13229 RTE_ETH_FILTER_DELETE,
13232 printf("E-tag filter programming error: (%s)\n",
13236 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13237 .f = cmd_config_e_tag_filter_del_parsed,
13239 .help_str = "E-tag ... : E-tag filter delete",
13241 (void *)&cmd_config_e_tag_e_tag,
13242 (void *)&cmd_config_e_tag_set,
13243 (void *)&cmd_config_e_tag_filter,
13244 (void *)&cmd_config_e_tag_del,
13245 (void *)&cmd_config_e_tag_e_tag_id,
13246 (void *)&cmd_config_e_tag_e_tag_id_val,
13247 (void *)&cmd_config_e_tag_port,
13248 (void *)&cmd_config_e_tag_port_id,
13253 /* vf vlan anti spoof configuration */
13255 /* Common result structure for vf vlan anti spoof */
13256 struct cmd_vf_vlan_anti_spoof_result {
13257 cmdline_fixed_string_t set;
13258 cmdline_fixed_string_t vf;
13259 cmdline_fixed_string_t vlan;
13260 cmdline_fixed_string_t antispoof;
13263 cmdline_fixed_string_t on_off;
13266 /* Common CLI fields for vf vlan anti spoof enable disable */
13267 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13268 TOKEN_STRING_INITIALIZER
13269 (struct cmd_vf_vlan_anti_spoof_result,
13271 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13272 TOKEN_STRING_INITIALIZER
13273 (struct cmd_vf_vlan_anti_spoof_result,
13275 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13276 TOKEN_STRING_INITIALIZER
13277 (struct cmd_vf_vlan_anti_spoof_result,
13279 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13280 TOKEN_STRING_INITIALIZER
13281 (struct cmd_vf_vlan_anti_spoof_result,
13282 antispoof, "antispoof");
13283 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13284 TOKEN_NUM_INITIALIZER
13285 (struct cmd_vf_vlan_anti_spoof_result,
13287 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13288 TOKEN_NUM_INITIALIZER
13289 (struct cmd_vf_vlan_anti_spoof_result,
13291 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13292 TOKEN_STRING_INITIALIZER
13293 (struct cmd_vf_vlan_anti_spoof_result,
13297 cmd_set_vf_vlan_anti_spoof_parsed(
13298 void *parsed_result,
13299 __attribute__((unused)) struct cmdline *cl,
13300 __attribute__((unused)) void *data)
13302 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13303 int ret = -ENOTSUP;
13305 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13307 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13310 #ifdef RTE_LIBRTE_IXGBE_PMD
13311 if (ret == -ENOTSUP)
13312 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13313 res->vf_id, is_on);
13315 #ifdef RTE_LIBRTE_I40E_PMD
13316 if (ret == -ENOTSUP)
13317 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13318 res->vf_id, is_on);
13320 #ifdef RTE_LIBRTE_BNXT_PMD
13321 if (ret == -ENOTSUP)
13322 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13323 res->vf_id, is_on);
13330 printf("invalid vf_id %d\n", res->vf_id);
13333 printf("invalid port_id %d\n", res->port_id);
13336 printf("function not implemented\n");
13339 printf("programming error: (%s)\n", strerror(-ret));
13343 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13344 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13346 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13348 (void *)&cmd_vf_vlan_anti_spoof_set,
13349 (void *)&cmd_vf_vlan_anti_spoof_vf,
13350 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13351 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13352 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13353 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13354 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13359 /* vf mac anti spoof configuration */
13361 /* Common result structure for vf mac anti spoof */
13362 struct cmd_vf_mac_anti_spoof_result {
13363 cmdline_fixed_string_t set;
13364 cmdline_fixed_string_t vf;
13365 cmdline_fixed_string_t mac;
13366 cmdline_fixed_string_t antispoof;
13369 cmdline_fixed_string_t on_off;
13372 /* Common CLI fields for vf mac anti spoof enable disable */
13373 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13374 TOKEN_STRING_INITIALIZER
13375 (struct cmd_vf_mac_anti_spoof_result,
13377 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13378 TOKEN_STRING_INITIALIZER
13379 (struct cmd_vf_mac_anti_spoof_result,
13381 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13382 TOKEN_STRING_INITIALIZER
13383 (struct cmd_vf_mac_anti_spoof_result,
13385 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13386 TOKEN_STRING_INITIALIZER
13387 (struct cmd_vf_mac_anti_spoof_result,
13388 antispoof, "antispoof");
13389 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13390 TOKEN_NUM_INITIALIZER
13391 (struct cmd_vf_mac_anti_spoof_result,
13393 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13394 TOKEN_NUM_INITIALIZER
13395 (struct cmd_vf_mac_anti_spoof_result,
13397 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13398 TOKEN_STRING_INITIALIZER
13399 (struct cmd_vf_mac_anti_spoof_result,
13403 cmd_set_vf_mac_anti_spoof_parsed(
13404 void *parsed_result,
13405 __attribute__((unused)) struct cmdline *cl,
13406 __attribute__((unused)) void *data)
13408 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13409 int ret = -ENOTSUP;
13411 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13413 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13416 #ifdef RTE_LIBRTE_IXGBE_PMD
13417 if (ret == -ENOTSUP)
13418 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13419 res->vf_id, is_on);
13421 #ifdef RTE_LIBRTE_I40E_PMD
13422 if (ret == -ENOTSUP)
13423 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13424 res->vf_id, is_on);
13426 #ifdef RTE_LIBRTE_BNXT_PMD
13427 if (ret == -ENOTSUP)
13428 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13429 res->vf_id, is_on);
13436 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13439 printf("invalid port_id %d\n", res->port_id);
13442 printf("function not implemented\n");
13445 printf("programming error: (%s)\n", strerror(-ret));
13449 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13450 .f = cmd_set_vf_mac_anti_spoof_parsed,
13452 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13454 (void *)&cmd_vf_mac_anti_spoof_set,
13455 (void *)&cmd_vf_mac_anti_spoof_vf,
13456 (void *)&cmd_vf_mac_anti_spoof_mac,
13457 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13458 (void *)&cmd_vf_mac_anti_spoof_port_id,
13459 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13460 (void *)&cmd_vf_mac_anti_spoof_on_off,
13465 /* vf vlan strip queue configuration */
13467 /* Common result structure for vf mac anti spoof */
13468 struct cmd_vf_vlan_stripq_result {
13469 cmdline_fixed_string_t set;
13470 cmdline_fixed_string_t vf;
13471 cmdline_fixed_string_t vlan;
13472 cmdline_fixed_string_t stripq;
13475 cmdline_fixed_string_t on_off;
13478 /* Common CLI fields for vf vlan strip enable disable */
13479 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13480 TOKEN_STRING_INITIALIZER
13481 (struct cmd_vf_vlan_stripq_result,
13483 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13484 TOKEN_STRING_INITIALIZER
13485 (struct cmd_vf_vlan_stripq_result,
13487 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13488 TOKEN_STRING_INITIALIZER
13489 (struct cmd_vf_vlan_stripq_result,
13491 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13492 TOKEN_STRING_INITIALIZER
13493 (struct cmd_vf_vlan_stripq_result,
13495 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13496 TOKEN_NUM_INITIALIZER
13497 (struct cmd_vf_vlan_stripq_result,
13499 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13500 TOKEN_NUM_INITIALIZER
13501 (struct cmd_vf_vlan_stripq_result,
13503 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13504 TOKEN_STRING_INITIALIZER
13505 (struct cmd_vf_vlan_stripq_result,
13509 cmd_set_vf_vlan_stripq_parsed(
13510 void *parsed_result,
13511 __attribute__((unused)) struct cmdline *cl,
13512 __attribute__((unused)) void *data)
13514 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13515 int ret = -ENOTSUP;
13517 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13519 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13522 #ifdef RTE_LIBRTE_IXGBE_PMD
13523 if (ret == -ENOTSUP)
13524 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13525 res->vf_id, is_on);
13527 #ifdef RTE_LIBRTE_I40E_PMD
13528 if (ret == -ENOTSUP)
13529 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13530 res->vf_id, is_on);
13532 #ifdef RTE_LIBRTE_BNXT_PMD
13533 if (ret == -ENOTSUP)
13534 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13535 res->vf_id, is_on);
13542 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13545 printf("invalid port_id %d\n", res->port_id);
13548 printf("function not implemented\n");
13551 printf("programming error: (%s)\n", strerror(-ret));
13555 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13556 .f = cmd_set_vf_vlan_stripq_parsed,
13558 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13560 (void *)&cmd_vf_vlan_stripq_set,
13561 (void *)&cmd_vf_vlan_stripq_vf,
13562 (void *)&cmd_vf_vlan_stripq_vlan,
13563 (void *)&cmd_vf_vlan_stripq_stripq,
13564 (void *)&cmd_vf_vlan_stripq_port_id,
13565 (void *)&cmd_vf_vlan_stripq_vf_id,
13566 (void *)&cmd_vf_vlan_stripq_on_off,
13571 /* vf vlan insert configuration */
13573 /* Common result structure for vf vlan insert */
13574 struct cmd_vf_vlan_insert_result {
13575 cmdline_fixed_string_t set;
13576 cmdline_fixed_string_t vf;
13577 cmdline_fixed_string_t vlan;
13578 cmdline_fixed_string_t insert;
13584 /* Common CLI fields for vf vlan insert enable disable */
13585 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13586 TOKEN_STRING_INITIALIZER
13587 (struct cmd_vf_vlan_insert_result,
13589 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13590 TOKEN_STRING_INITIALIZER
13591 (struct cmd_vf_vlan_insert_result,
13593 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13594 TOKEN_STRING_INITIALIZER
13595 (struct cmd_vf_vlan_insert_result,
13597 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13598 TOKEN_STRING_INITIALIZER
13599 (struct cmd_vf_vlan_insert_result,
13601 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13602 TOKEN_NUM_INITIALIZER
13603 (struct cmd_vf_vlan_insert_result,
13605 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13606 TOKEN_NUM_INITIALIZER
13607 (struct cmd_vf_vlan_insert_result,
13609 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13610 TOKEN_NUM_INITIALIZER
13611 (struct cmd_vf_vlan_insert_result,
13615 cmd_set_vf_vlan_insert_parsed(
13616 void *parsed_result,
13617 __attribute__((unused)) struct cmdline *cl,
13618 __attribute__((unused)) void *data)
13620 struct cmd_vf_vlan_insert_result *res = parsed_result;
13621 int ret = -ENOTSUP;
13623 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13626 #ifdef RTE_LIBRTE_IXGBE_PMD
13627 if (ret == -ENOTSUP)
13628 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13631 #ifdef RTE_LIBRTE_I40E_PMD
13632 if (ret == -ENOTSUP)
13633 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13636 #ifdef RTE_LIBRTE_BNXT_PMD
13637 if (ret == -ENOTSUP)
13638 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13646 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13649 printf("invalid port_id %d\n", res->port_id);
13652 printf("function not implemented\n");
13655 printf("programming error: (%s)\n", strerror(-ret));
13659 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13660 .f = cmd_set_vf_vlan_insert_parsed,
13662 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13664 (void *)&cmd_vf_vlan_insert_set,
13665 (void *)&cmd_vf_vlan_insert_vf,
13666 (void *)&cmd_vf_vlan_insert_vlan,
13667 (void *)&cmd_vf_vlan_insert_insert,
13668 (void *)&cmd_vf_vlan_insert_port_id,
13669 (void *)&cmd_vf_vlan_insert_vf_id,
13670 (void *)&cmd_vf_vlan_insert_vlan_id,
13675 /* tx loopback configuration */
13677 /* Common result structure for tx loopback */
13678 struct cmd_tx_loopback_result {
13679 cmdline_fixed_string_t set;
13680 cmdline_fixed_string_t tx;
13681 cmdline_fixed_string_t loopback;
13683 cmdline_fixed_string_t on_off;
13686 /* Common CLI fields for tx loopback enable disable */
13687 cmdline_parse_token_string_t cmd_tx_loopback_set =
13688 TOKEN_STRING_INITIALIZER
13689 (struct cmd_tx_loopback_result,
13691 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13692 TOKEN_STRING_INITIALIZER
13693 (struct cmd_tx_loopback_result,
13695 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13696 TOKEN_STRING_INITIALIZER
13697 (struct cmd_tx_loopback_result,
13698 loopback, "loopback");
13699 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13700 TOKEN_NUM_INITIALIZER
13701 (struct cmd_tx_loopback_result,
13703 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13704 TOKEN_STRING_INITIALIZER
13705 (struct cmd_tx_loopback_result,
13709 cmd_set_tx_loopback_parsed(
13710 void *parsed_result,
13711 __attribute__((unused)) struct cmdline *cl,
13712 __attribute__((unused)) void *data)
13714 struct cmd_tx_loopback_result *res = parsed_result;
13715 int ret = -ENOTSUP;
13717 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13719 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13722 #ifdef RTE_LIBRTE_IXGBE_PMD
13723 if (ret == -ENOTSUP)
13724 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13726 #ifdef RTE_LIBRTE_I40E_PMD
13727 if (ret == -ENOTSUP)
13728 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13730 #ifdef RTE_LIBRTE_BNXT_PMD
13731 if (ret == -ENOTSUP)
13732 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13734 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13735 if (ret == -ENOTSUP)
13736 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13743 printf("invalid is_on %d\n", is_on);
13746 printf("invalid port_id %d\n", res->port_id);
13749 printf("function not implemented\n");
13752 printf("programming error: (%s)\n", strerror(-ret));
13756 cmdline_parse_inst_t cmd_set_tx_loopback = {
13757 .f = cmd_set_tx_loopback_parsed,
13759 .help_str = "set tx loopback <port_id> on|off",
13761 (void *)&cmd_tx_loopback_set,
13762 (void *)&cmd_tx_loopback_tx,
13763 (void *)&cmd_tx_loopback_loopback,
13764 (void *)&cmd_tx_loopback_port_id,
13765 (void *)&cmd_tx_loopback_on_off,
13770 /* all queues drop enable configuration */
13772 /* Common result structure for all queues drop enable */
13773 struct cmd_all_queues_drop_en_result {
13774 cmdline_fixed_string_t set;
13775 cmdline_fixed_string_t all;
13776 cmdline_fixed_string_t queues;
13777 cmdline_fixed_string_t drop;
13779 cmdline_fixed_string_t on_off;
13782 /* Common CLI fields for tx loopback enable disable */
13783 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13784 TOKEN_STRING_INITIALIZER
13785 (struct cmd_all_queues_drop_en_result,
13787 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13788 TOKEN_STRING_INITIALIZER
13789 (struct cmd_all_queues_drop_en_result,
13791 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13792 TOKEN_STRING_INITIALIZER
13793 (struct cmd_all_queues_drop_en_result,
13795 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13796 TOKEN_STRING_INITIALIZER
13797 (struct cmd_all_queues_drop_en_result,
13799 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13800 TOKEN_NUM_INITIALIZER
13801 (struct cmd_all_queues_drop_en_result,
13803 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13804 TOKEN_STRING_INITIALIZER
13805 (struct cmd_all_queues_drop_en_result,
13809 cmd_set_all_queues_drop_en_parsed(
13810 void *parsed_result,
13811 __attribute__((unused)) struct cmdline *cl,
13812 __attribute__((unused)) void *data)
13814 struct cmd_all_queues_drop_en_result *res = parsed_result;
13815 int ret = -ENOTSUP;
13816 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13818 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13821 #ifdef RTE_LIBRTE_IXGBE_PMD
13822 if (ret == -ENOTSUP)
13823 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13825 #ifdef RTE_LIBRTE_BNXT_PMD
13826 if (ret == -ENOTSUP)
13827 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13833 printf("invalid is_on %d\n", is_on);
13836 printf("invalid port_id %d\n", res->port_id);
13839 printf("function not implemented\n");
13842 printf("programming error: (%s)\n", strerror(-ret));
13846 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13847 .f = cmd_set_all_queues_drop_en_parsed,
13849 .help_str = "set all queues drop <port_id> on|off",
13851 (void *)&cmd_all_queues_drop_en_set,
13852 (void *)&cmd_all_queues_drop_en_all,
13853 (void *)&cmd_all_queues_drop_en_queues,
13854 (void *)&cmd_all_queues_drop_en_drop,
13855 (void *)&cmd_all_queues_drop_en_port_id,
13856 (void *)&cmd_all_queues_drop_en_on_off,
13861 /* vf split drop enable configuration */
13863 /* Common result structure for vf split drop enable */
13864 struct cmd_vf_split_drop_en_result {
13865 cmdline_fixed_string_t set;
13866 cmdline_fixed_string_t vf;
13867 cmdline_fixed_string_t split;
13868 cmdline_fixed_string_t drop;
13871 cmdline_fixed_string_t on_off;
13874 /* Common CLI fields for vf split drop enable disable */
13875 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13876 TOKEN_STRING_INITIALIZER
13877 (struct cmd_vf_split_drop_en_result,
13879 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13880 TOKEN_STRING_INITIALIZER
13881 (struct cmd_vf_split_drop_en_result,
13883 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13884 TOKEN_STRING_INITIALIZER
13885 (struct cmd_vf_split_drop_en_result,
13887 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13888 TOKEN_STRING_INITIALIZER
13889 (struct cmd_vf_split_drop_en_result,
13891 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13892 TOKEN_NUM_INITIALIZER
13893 (struct cmd_vf_split_drop_en_result,
13895 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13896 TOKEN_NUM_INITIALIZER
13897 (struct cmd_vf_split_drop_en_result,
13899 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13900 TOKEN_STRING_INITIALIZER
13901 (struct cmd_vf_split_drop_en_result,
13905 cmd_set_vf_split_drop_en_parsed(
13906 void *parsed_result,
13907 __attribute__((unused)) struct cmdline *cl,
13908 __attribute__((unused)) void *data)
13910 struct cmd_vf_split_drop_en_result *res = parsed_result;
13911 int ret = -ENOTSUP;
13912 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13914 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13917 #ifdef RTE_LIBRTE_IXGBE_PMD
13918 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13925 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13928 printf("invalid port_id %d\n", res->port_id);
13931 printf("not supported on port %d\n", res->port_id);
13934 printf("programming error: (%s)\n", strerror(-ret));
13938 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13939 .f = cmd_set_vf_split_drop_en_parsed,
13941 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13943 (void *)&cmd_vf_split_drop_en_set,
13944 (void *)&cmd_vf_split_drop_en_vf,
13945 (void *)&cmd_vf_split_drop_en_split,
13946 (void *)&cmd_vf_split_drop_en_drop,
13947 (void *)&cmd_vf_split_drop_en_port_id,
13948 (void *)&cmd_vf_split_drop_en_vf_id,
13949 (void *)&cmd_vf_split_drop_en_on_off,
13954 /* vf mac address configuration */
13956 /* Common result structure for vf mac address */
13957 struct cmd_set_vf_mac_addr_result {
13958 cmdline_fixed_string_t set;
13959 cmdline_fixed_string_t vf;
13960 cmdline_fixed_string_t mac;
13961 cmdline_fixed_string_t addr;
13964 struct rte_ether_addr mac_addr;
13968 /* Common CLI fields for vf split drop enable disable */
13969 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13970 TOKEN_STRING_INITIALIZER
13971 (struct cmd_set_vf_mac_addr_result,
13973 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13974 TOKEN_STRING_INITIALIZER
13975 (struct cmd_set_vf_mac_addr_result,
13977 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13978 TOKEN_STRING_INITIALIZER
13979 (struct cmd_set_vf_mac_addr_result,
13981 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13982 TOKEN_STRING_INITIALIZER
13983 (struct cmd_set_vf_mac_addr_result,
13985 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13986 TOKEN_NUM_INITIALIZER
13987 (struct cmd_set_vf_mac_addr_result,
13989 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13990 TOKEN_NUM_INITIALIZER
13991 (struct cmd_set_vf_mac_addr_result,
13993 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13994 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13998 cmd_set_vf_mac_addr_parsed(
13999 void *parsed_result,
14000 __attribute__((unused)) struct cmdline *cl,
14001 __attribute__((unused)) void *data)
14003 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14004 int ret = -ENOTSUP;
14006 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14009 #ifdef RTE_LIBRTE_IXGBE_PMD
14010 if (ret == -ENOTSUP)
14011 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14014 #ifdef RTE_LIBRTE_I40E_PMD
14015 if (ret == -ENOTSUP)
14016 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14019 #ifdef RTE_LIBRTE_BNXT_PMD
14020 if (ret == -ENOTSUP)
14021 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14029 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14032 printf("invalid port_id %d\n", res->port_id);
14035 printf("function not implemented\n");
14038 printf("programming error: (%s)\n", strerror(-ret));
14042 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14043 .f = cmd_set_vf_mac_addr_parsed,
14045 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14047 (void *)&cmd_set_vf_mac_addr_set,
14048 (void *)&cmd_set_vf_mac_addr_vf,
14049 (void *)&cmd_set_vf_mac_addr_mac,
14050 (void *)&cmd_set_vf_mac_addr_addr,
14051 (void *)&cmd_set_vf_mac_addr_port_id,
14052 (void *)&cmd_set_vf_mac_addr_vf_id,
14053 (void *)&cmd_set_vf_mac_addr_mac_addr,
14058 /* MACsec configuration */
14060 /* Common result structure for MACsec offload enable */
14061 struct cmd_macsec_offload_on_result {
14062 cmdline_fixed_string_t set;
14063 cmdline_fixed_string_t macsec;
14064 cmdline_fixed_string_t offload;
14066 cmdline_fixed_string_t on;
14067 cmdline_fixed_string_t encrypt;
14068 cmdline_fixed_string_t en_on_off;
14069 cmdline_fixed_string_t replay_protect;
14070 cmdline_fixed_string_t rp_on_off;
14073 /* Common CLI fields for MACsec offload disable */
14074 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14075 TOKEN_STRING_INITIALIZER
14076 (struct cmd_macsec_offload_on_result,
14078 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14079 TOKEN_STRING_INITIALIZER
14080 (struct cmd_macsec_offload_on_result,
14082 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14083 TOKEN_STRING_INITIALIZER
14084 (struct cmd_macsec_offload_on_result,
14085 offload, "offload");
14086 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14087 TOKEN_NUM_INITIALIZER
14088 (struct cmd_macsec_offload_on_result,
14090 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14091 TOKEN_STRING_INITIALIZER
14092 (struct cmd_macsec_offload_on_result,
14094 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14095 TOKEN_STRING_INITIALIZER
14096 (struct cmd_macsec_offload_on_result,
14097 encrypt, "encrypt");
14098 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14099 TOKEN_STRING_INITIALIZER
14100 (struct cmd_macsec_offload_on_result,
14101 en_on_off, "on#off");
14102 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14103 TOKEN_STRING_INITIALIZER
14104 (struct cmd_macsec_offload_on_result,
14105 replay_protect, "replay-protect");
14106 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14107 TOKEN_STRING_INITIALIZER
14108 (struct cmd_macsec_offload_on_result,
14109 rp_on_off, "on#off");
14112 cmd_set_macsec_offload_on_parsed(
14113 void *parsed_result,
14114 __attribute__((unused)) struct cmdline *cl,
14115 __attribute__((unused)) void *data)
14117 struct cmd_macsec_offload_on_result *res = parsed_result;
14118 int ret = -ENOTSUP;
14119 portid_t port_id = res->port_id;
14120 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14121 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14122 struct rte_eth_dev_info dev_info;
14124 if (port_id_is_invalid(port_id, ENABLED_WARN))
14126 if (!port_is_stopped(port_id)) {
14127 printf("Please stop port %d first\n", port_id);
14131 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14135 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14136 #ifdef RTE_LIBRTE_IXGBE_PMD
14137 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14145 ports[port_id].dev_conf.txmode.offloads |=
14146 DEV_TX_OFFLOAD_MACSEC_INSERT;
14147 cmd_reconfig_device_queue(port_id, 1, 1);
14150 printf("invalid port_id %d\n", port_id);
14153 printf("not supported on port %d\n", port_id);
14156 printf("programming error: (%s)\n", strerror(-ret));
14160 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14161 .f = cmd_set_macsec_offload_on_parsed,
14163 .help_str = "set macsec offload <port_id> on "
14164 "encrypt on|off replay-protect on|off",
14166 (void *)&cmd_macsec_offload_on_set,
14167 (void *)&cmd_macsec_offload_on_macsec,
14168 (void *)&cmd_macsec_offload_on_offload,
14169 (void *)&cmd_macsec_offload_on_port_id,
14170 (void *)&cmd_macsec_offload_on_on,
14171 (void *)&cmd_macsec_offload_on_encrypt,
14172 (void *)&cmd_macsec_offload_on_en_on_off,
14173 (void *)&cmd_macsec_offload_on_replay_protect,
14174 (void *)&cmd_macsec_offload_on_rp_on_off,
14179 /* Common result structure for MACsec offload disable */
14180 struct cmd_macsec_offload_off_result {
14181 cmdline_fixed_string_t set;
14182 cmdline_fixed_string_t macsec;
14183 cmdline_fixed_string_t offload;
14185 cmdline_fixed_string_t off;
14188 /* Common CLI fields for MACsec offload disable */
14189 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14190 TOKEN_STRING_INITIALIZER
14191 (struct cmd_macsec_offload_off_result,
14193 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14194 TOKEN_STRING_INITIALIZER
14195 (struct cmd_macsec_offload_off_result,
14197 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14198 TOKEN_STRING_INITIALIZER
14199 (struct cmd_macsec_offload_off_result,
14200 offload, "offload");
14201 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14202 TOKEN_NUM_INITIALIZER
14203 (struct cmd_macsec_offload_off_result,
14205 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14206 TOKEN_STRING_INITIALIZER
14207 (struct cmd_macsec_offload_off_result,
14211 cmd_set_macsec_offload_off_parsed(
14212 void *parsed_result,
14213 __attribute__((unused)) struct cmdline *cl,
14214 __attribute__((unused)) void *data)
14216 struct cmd_macsec_offload_off_result *res = parsed_result;
14217 int ret = -ENOTSUP;
14218 struct rte_eth_dev_info dev_info;
14219 portid_t port_id = res->port_id;
14221 if (port_id_is_invalid(port_id, ENABLED_WARN))
14223 if (!port_is_stopped(port_id)) {
14224 printf("Please stop port %d first\n", port_id);
14228 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14232 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14233 #ifdef RTE_LIBRTE_IXGBE_PMD
14234 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14239 ports[port_id].dev_conf.txmode.offloads &=
14240 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14241 cmd_reconfig_device_queue(port_id, 1, 1);
14244 printf("invalid port_id %d\n", port_id);
14247 printf("not supported on port %d\n", port_id);
14250 printf("programming error: (%s)\n", strerror(-ret));
14254 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14255 .f = cmd_set_macsec_offload_off_parsed,
14257 .help_str = "set macsec offload <port_id> off",
14259 (void *)&cmd_macsec_offload_off_set,
14260 (void *)&cmd_macsec_offload_off_macsec,
14261 (void *)&cmd_macsec_offload_off_offload,
14262 (void *)&cmd_macsec_offload_off_port_id,
14263 (void *)&cmd_macsec_offload_off_off,
14268 /* Common result structure for MACsec secure connection configure */
14269 struct cmd_macsec_sc_result {
14270 cmdline_fixed_string_t set;
14271 cmdline_fixed_string_t macsec;
14272 cmdline_fixed_string_t sc;
14273 cmdline_fixed_string_t tx_rx;
14275 struct rte_ether_addr mac;
14279 /* Common CLI fields for MACsec secure connection configure */
14280 cmdline_parse_token_string_t cmd_macsec_sc_set =
14281 TOKEN_STRING_INITIALIZER
14282 (struct cmd_macsec_sc_result,
14284 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14285 TOKEN_STRING_INITIALIZER
14286 (struct cmd_macsec_sc_result,
14288 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14289 TOKEN_STRING_INITIALIZER
14290 (struct cmd_macsec_sc_result,
14292 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14293 TOKEN_STRING_INITIALIZER
14294 (struct cmd_macsec_sc_result,
14296 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14297 TOKEN_NUM_INITIALIZER
14298 (struct cmd_macsec_sc_result,
14300 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14301 TOKEN_ETHERADDR_INITIALIZER
14302 (struct cmd_macsec_sc_result,
14304 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14305 TOKEN_NUM_INITIALIZER
14306 (struct cmd_macsec_sc_result,
14310 cmd_set_macsec_sc_parsed(
14311 void *parsed_result,
14312 __attribute__((unused)) struct cmdline *cl,
14313 __attribute__((unused)) void *data)
14315 struct cmd_macsec_sc_result *res = parsed_result;
14316 int ret = -ENOTSUP;
14317 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14319 #ifdef RTE_LIBRTE_IXGBE_PMD
14321 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14322 res->mac.addr_bytes) :
14323 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14324 res->mac.addr_bytes, res->pi);
14326 RTE_SET_USED(is_tx);
14332 printf("invalid port_id %d\n", res->port_id);
14335 printf("not supported on port %d\n", res->port_id);
14338 printf("programming error: (%s)\n", strerror(-ret));
14342 cmdline_parse_inst_t cmd_set_macsec_sc = {
14343 .f = cmd_set_macsec_sc_parsed,
14345 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14347 (void *)&cmd_macsec_sc_set,
14348 (void *)&cmd_macsec_sc_macsec,
14349 (void *)&cmd_macsec_sc_sc,
14350 (void *)&cmd_macsec_sc_tx_rx,
14351 (void *)&cmd_macsec_sc_port_id,
14352 (void *)&cmd_macsec_sc_mac,
14353 (void *)&cmd_macsec_sc_pi,
14358 /* Common result structure for MACsec secure connection configure */
14359 struct cmd_macsec_sa_result {
14360 cmdline_fixed_string_t set;
14361 cmdline_fixed_string_t macsec;
14362 cmdline_fixed_string_t sa;
14363 cmdline_fixed_string_t tx_rx;
14368 cmdline_fixed_string_t key;
14371 /* Common CLI fields for MACsec secure connection configure */
14372 cmdline_parse_token_string_t cmd_macsec_sa_set =
14373 TOKEN_STRING_INITIALIZER
14374 (struct cmd_macsec_sa_result,
14376 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14377 TOKEN_STRING_INITIALIZER
14378 (struct cmd_macsec_sa_result,
14380 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14381 TOKEN_STRING_INITIALIZER
14382 (struct cmd_macsec_sa_result,
14384 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14385 TOKEN_STRING_INITIALIZER
14386 (struct cmd_macsec_sa_result,
14388 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14389 TOKEN_NUM_INITIALIZER
14390 (struct cmd_macsec_sa_result,
14392 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14393 TOKEN_NUM_INITIALIZER
14394 (struct cmd_macsec_sa_result,
14396 cmdline_parse_token_num_t cmd_macsec_sa_an =
14397 TOKEN_NUM_INITIALIZER
14398 (struct cmd_macsec_sa_result,
14400 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14401 TOKEN_NUM_INITIALIZER
14402 (struct cmd_macsec_sa_result,
14404 cmdline_parse_token_string_t cmd_macsec_sa_key =
14405 TOKEN_STRING_INITIALIZER
14406 (struct cmd_macsec_sa_result,
14410 cmd_set_macsec_sa_parsed(
14411 void *parsed_result,
14412 __attribute__((unused)) struct cmdline *cl,
14413 __attribute__((unused)) void *data)
14415 struct cmd_macsec_sa_result *res = parsed_result;
14416 int ret = -ENOTSUP;
14417 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14418 uint8_t key[16] = { 0 };
14424 key_len = strlen(res->key) / 2;
14428 for (i = 0; i < key_len; i++) {
14429 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14432 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14435 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14438 #ifdef RTE_LIBRTE_IXGBE_PMD
14440 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14441 res->idx, res->an, res->pn, key) :
14442 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14443 res->idx, res->an, res->pn, key);
14445 RTE_SET_USED(is_tx);
14452 printf("invalid idx %d or an %d\n", res->idx, res->an);
14455 printf("invalid port_id %d\n", res->port_id);
14458 printf("not supported on port %d\n", res->port_id);
14461 printf("programming error: (%s)\n", strerror(-ret));
14465 cmdline_parse_inst_t cmd_set_macsec_sa = {
14466 .f = cmd_set_macsec_sa_parsed,
14468 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14470 (void *)&cmd_macsec_sa_set,
14471 (void *)&cmd_macsec_sa_macsec,
14472 (void *)&cmd_macsec_sa_sa,
14473 (void *)&cmd_macsec_sa_tx_rx,
14474 (void *)&cmd_macsec_sa_port_id,
14475 (void *)&cmd_macsec_sa_idx,
14476 (void *)&cmd_macsec_sa_an,
14477 (void *)&cmd_macsec_sa_pn,
14478 (void *)&cmd_macsec_sa_key,
14483 /* VF unicast promiscuous mode configuration */
14485 /* Common result structure for VF unicast promiscuous mode */
14486 struct cmd_vf_promisc_result {
14487 cmdline_fixed_string_t set;
14488 cmdline_fixed_string_t vf;
14489 cmdline_fixed_string_t promisc;
14492 cmdline_fixed_string_t on_off;
14495 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14496 cmdline_parse_token_string_t cmd_vf_promisc_set =
14497 TOKEN_STRING_INITIALIZER
14498 (struct cmd_vf_promisc_result,
14500 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14501 TOKEN_STRING_INITIALIZER
14502 (struct cmd_vf_promisc_result,
14504 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14505 TOKEN_STRING_INITIALIZER
14506 (struct cmd_vf_promisc_result,
14507 promisc, "promisc");
14508 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14509 TOKEN_NUM_INITIALIZER
14510 (struct cmd_vf_promisc_result,
14512 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14513 TOKEN_NUM_INITIALIZER
14514 (struct cmd_vf_promisc_result,
14516 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14517 TOKEN_STRING_INITIALIZER
14518 (struct cmd_vf_promisc_result,
14522 cmd_set_vf_promisc_parsed(
14523 void *parsed_result,
14524 __attribute__((unused)) struct cmdline *cl,
14525 __attribute__((unused)) void *data)
14527 struct cmd_vf_promisc_result *res = parsed_result;
14528 int ret = -ENOTSUP;
14530 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14532 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14535 #ifdef RTE_LIBRTE_I40E_PMD
14536 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14537 res->vf_id, is_on);
14544 printf("invalid vf_id %d\n", res->vf_id);
14547 printf("invalid port_id %d\n", res->port_id);
14550 printf("function not implemented\n");
14553 printf("programming error: (%s)\n", strerror(-ret));
14557 cmdline_parse_inst_t cmd_set_vf_promisc = {
14558 .f = cmd_set_vf_promisc_parsed,
14560 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14561 "Set unicast promiscuous mode for a VF from the PF",
14563 (void *)&cmd_vf_promisc_set,
14564 (void *)&cmd_vf_promisc_vf,
14565 (void *)&cmd_vf_promisc_promisc,
14566 (void *)&cmd_vf_promisc_port_id,
14567 (void *)&cmd_vf_promisc_vf_id,
14568 (void *)&cmd_vf_promisc_on_off,
14573 /* VF multicast promiscuous mode configuration */
14575 /* Common result structure for VF multicast promiscuous mode */
14576 struct cmd_vf_allmulti_result {
14577 cmdline_fixed_string_t set;
14578 cmdline_fixed_string_t vf;
14579 cmdline_fixed_string_t allmulti;
14582 cmdline_fixed_string_t on_off;
14585 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14586 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14587 TOKEN_STRING_INITIALIZER
14588 (struct cmd_vf_allmulti_result,
14590 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14591 TOKEN_STRING_INITIALIZER
14592 (struct cmd_vf_allmulti_result,
14594 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14595 TOKEN_STRING_INITIALIZER
14596 (struct cmd_vf_allmulti_result,
14597 allmulti, "allmulti");
14598 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14599 TOKEN_NUM_INITIALIZER
14600 (struct cmd_vf_allmulti_result,
14602 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14603 TOKEN_NUM_INITIALIZER
14604 (struct cmd_vf_allmulti_result,
14606 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14607 TOKEN_STRING_INITIALIZER
14608 (struct cmd_vf_allmulti_result,
14612 cmd_set_vf_allmulti_parsed(
14613 void *parsed_result,
14614 __attribute__((unused)) struct cmdline *cl,
14615 __attribute__((unused)) void *data)
14617 struct cmd_vf_allmulti_result *res = parsed_result;
14618 int ret = -ENOTSUP;
14620 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14622 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14625 #ifdef RTE_LIBRTE_I40E_PMD
14626 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14627 res->vf_id, is_on);
14634 printf("invalid vf_id %d\n", res->vf_id);
14637 printf("invalid port_id %d\n", res->port_id);
14640 printf("function not implemented\n");
14643 printf("programming error: (%s)\n", strerror(-ret));
14647 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14648 .f = cmd_set_vf_allmulti_parsed,
14650 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14651 "Set multicast promiscuous mode for a VF from the PF",
14653 (void *)&cmd_vf_allmulti_set,
14654 (void *)&cmd_vf_allmulti_vf,
14655 (void *)&cmd_vf_allmulti_allmulti,
14656 (void *)&cmd_vf_allmulti_port_id,
14657 (void *)&cmd_vf_allmulti_vf_id,
14658 (void *)&cmd_vf_allmulti_on_off,
14663 /* vf broadcast mode configuration */
14665 /* Common result structure for vf broadcast */
14666 struct cmd_set_vf_broadcast_result {
14667 cmdline_fixed_string_t set;
14668 cmdline_fixed_string_t vf;
14669 cmdline_fixed_string_t broadcast;
14672 cmdline_fixed_string_t on_off;
14675 /* Common CLI fields for vf broadcast enable disable */
14676 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14677 TOKEN_STRING_INITIALIZER
14678 (struct cmd_set_vf_broadcast_result,
14680 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14681 TOKEN_STRING_INITIALIZER
14682 (struct cmd_set_vf_broadcast_result,
14684 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14685 TOKEN_STRING_INITIALIZER
14686 (struct cmd_set_vf_broadcast_result,
14687 broadcast, "broadcast");
14688 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14689 TOKEN_NUM_INITIALIZER
14690 (struct cmd_set_vf_broadcast_result,
14692 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14693 TOKEN_NUM_INITIALIZER
14694 (struct cmd_set_vf_broadcast_result,
14696 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14697 TOKEN_STRING_INITIALIZER
14698 (struct cmd_set_vf_broadcast_result,
14702 cmd_set_vf_broadcast_parsed(
14703 void *parsed_result,
14704 __attribute__((unused)) struct cmdline *cl,
14705 __attribute__((unused)) void *data)
14707 struct cmd_set_vf_broadcast_result *res = parsed_result;
14708 int ret = -ENOTSUP;
14710 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14712 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14715 #ifdef RTE_LIBRTE_I40E_PMD
14716 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14717 res->vf_id, is_on);
14724 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14727 printf("invalid port_id %d\n", res->port_id);
14730 printf("function not implemented\n");
14733 printf("programming error: (%s)\n", strerror(-ret));
14737 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14738 .f = cmd_set_vf_broadcast_parsed,
14740 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14742 (void *)&cmd_set_vf_broadcast_set,
14743 (void *)&cmd_set_vf_broadcast_vf,
14744 (void *)&cmd_set_vf_broadcast_broadcast,
14745 (void *)&cmd_set_vf_broadcast_port_id,
14746 (void *)&cmd_set_vf_broadcast_vf_id,
14747 (void *)&cmd_set_vf_broadcast_on_off,
14752 /* vf vlan tag configuration */
14754 /* Common result structure for vf vlan tag */
14755 struct cmd_set_vf_vlan_tag_result {
14756 cmdline_fixed_string_t set;
14757 cmdline_fixed_string_t vf;
14758 cmdline_fixed_string_t vlan;
14759 cmdline_fixed_string_t tag;
14762 cmdline_fixed_string_t on_off;
14765 /* Common CLI fields for vf vlan tag enable disable */
14766 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14767 TOKEN_STRING_INITIALIZER
14768 (struct cmd_set_vf_vlan_tag_result,
14770 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14771 TOKEN_STRING_INITIALIZER
14772 (struct cmd_set_vf_vlan_tag_result,
14774 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14775 TOKEN_STRING_INITIALIZER
14776 (struct cmd_set_vf_vlan_tag_result,
14778 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14779 TOKEN_STRING_INITIALIZER
14780 (struct cmd_set_vf_vlan_tag_result,
14782 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14783 TOKEN_NUM_INITIALIZER
14784 (struct cmd_set_vf_vlan_tag_result,
14786 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14787 TOKEN_NUM_INITIALIZER
14788 (struct cmd_set_vf_vlan_tag_result,
14790 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14791 TOKEN_STRING_INITIALIZER
14792 (struct cmd_set_vf_vlan_tag_result,
14796 cmd_set_vf_vlan_tag_parsed(
14797 void *parsed_result,
14798 __attribute__((unused)) struct cmdline *cl,
14799 __attribute__((unused)) void *data)
14801 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14802 int ret = -ENOTSUP;
14804 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14806 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14809 #ifdef RTE_LIBRTE_I40E_PMD
14810 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14811 res->vf_id, is_on);
14818 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14821 printf("invalid port_id %d\n", res->port_id);
14824 printf("function not implemented\n");
14827 printf("programming error: (%s)\n", strerror(-ret));
14831 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14832 .f = cmd_set_vf_vlan_tag_parsed,
14834 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14836 (void *)&cmd_set_vf_vlan_tag_set,
14837 (void *)&cmd_set_vf_vlan_tag_vf,
14838 (void *)&cmd_set_vf_vlan_tag_vlan,
14839 (void *)&cmd_set_vf_vlan_tag_tag,
14840 (void *)&cmd_set_vf_vlan_tag_port_id,
14841 (void *)&cmd_set_vf_vlan_tag_vf_id,
14842 (void *)&cmd_set_vf_vlan_tag_on_off,
14847 /* Common definition of VF and TC TX bandwidth configuration */
14848 struct cmd_vf_tc_bw_result {
14849 cmdline_fixed_string_t set;
14850 cmdline_fixed_string_t vf;
14851 cmdline_fixed_string_t tc;
14852 cmdline_fixed_string_t tx;
14853 cmdline_fixed_string_t min_bw;
14854 cmdline_fixed_string_t max_bw;
14855 cmdline_fixed_string_t strict_link_prio;
14860 cmdline_fixed_string_t bw_list;
14864 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14865 TOKEN_STRING_INITIALIZER
14866 (struct cmd_vf_tc_bw_result,
14868 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14869 TOKEN_STRING_INITIALIZER
14870 (struct cmd_vf_tc_bw_result,
14872 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14873 TOKEN_STRING_INITIALIZER
14874 (struct cmd_vf_tc_bw_result,
14876 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14877 TOKEN_STRING_INITIALIZER
14878 (struct cmd_vf_tc_bw_result,
14880 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14881 TOKEN_STRING_INITIALIZER
14882 (struct cmd_vf_tc_bw_result,
14883 strict_link_prio, "strict-link-priority");
14884 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14885 TOKEN_STRING_INITIALIZER
14886 (struct cmd_vf_tc_bw_result,
14887 min_bw, "min-bandwidth");
14888 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14889 TOKEN_STRING_INITIALIZER
14890 (struct cmd_vf_tc_bw_result,
14891 max_bw, "max-bandwidth");
14892 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14893 TOKEN_NUM_INITIALIZER
14894 (struct cmd_vf_tc_bw_result,
14896 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14897 TOKEN_NUM_INITIALIZER
14898 (struct cmd_vf_tc_bw_result,
14900 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14901 TOKEN_NUM_INITIALIZER
14902 (struct cmd_vf_tc_bw_result,
14904 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14905 TOKEN_NUM_INITIALIZER
14906 (struct cmd_vf_tc_bw_result,
14908 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14909 TOKEN_STRING_INITIALIZER
14910 (struct cmd_vf_tc_bw_result,
14912 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14913 TOKEN_NUM_INITIALIZER
14914 (struct cmd_vf_tc_bw_result,
14917 /* VF max bandwidth setting */
14919 cmd_vf_max_bw_parsed(
14920 void *parsed_result,
14921 __attribute__((unused)) struct cmdline *cl,
14922 __attribute__((unused)) void *data)
14924 struct cmd_vf_tc_bw_result *res = parsed_result;
14925 int ret = -ENOTSUP;
14927 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14930 #ifdef RTE_LIBRTE_I40E_PMD
14931 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14932 res->vf_id, res->bw);
14939 printf("invalid vf_id %d or bandwidth %d\n",
14940 res->vf_id, res->bw);
14943 printf("invalid port_id %d\n", res->port_id);
14946 printf("function not implemented\n");
14949 printf("programming error: (%s)\n", strerror(-ret));
14953 cmdline_parse_inst_t cmd_vf_max_bw = {
14954 .f = cmd_vf_max_bw_parsed,
14956 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14958 (void *)&cmd_vf_tc_bw_set,
14959 (void *)&cmd_vf_tc_bw_vf,
14960 (void *)&cmd_vf_tc_bw_tx,
14961 (void *)&cmd_vf_tc_bw_max_bw,
14962 (void *)&cmd_vf_tc_bw_port_id,
14963 (void *)&cmd_vf_tc_bw_vf_id,
14964 (void *)&cmd_vf_tc_bw_bw,
14970 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14975 const char *p, *p0 = str;
14982 p = strchr(p0, '(');
14984 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14988 p0 = strchr(p, ')');
14990 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14994 if (size >= sizeof(s)) {
14995 printf("The string size exceeds the internal buffer size\n");
14998 snprintf(s, sizeof(s), "%.*s", size, p);
14999 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15001 printf("Failed to get the bandwidth list. ");
15005 for (i = 0; i < ret; i++)
15006 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15011 /* TC min bandwidth setting */
15013 cmd_vf_tc_min_bw_parsed(
15014 void *parsed_result,
15015 __attribute__((unused)) struct cmdline *cl,
15016 __attribute__((unused)) void *data)
15018 struct cmd_vf_tc_bw_result *res = parsed_result;
15021 int ret = -ENOTSUP;
15023 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15026 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15030 #ifdef RTE_LIBRTE_I40E_PMD
15031 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15039 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15042 printf("invalid port_id %d\n", res->port_id);
15045 printf("function not implemented\n");
15048 printf("programming error: (%s)\n", strerror(-ret));
15052 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15053 .f = cmd_vf_tc_min_bw_parsed,
15055 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15056 " <bw1, bw2, ...>",
15058 (void *)&cmd_vf_tc_bw_set,
15059 (void *)&cmd_vf_tc_bw_vf,
15060 (void *)&cmd_vf_tc_bw_tc,
15061 (void *)&cmd_vf_tc_bw_tx,
15062 (void *)&cmd_vf_tc_bw_min_bw,
15063 (void *)&cmd_vf_tc_bw_port_id,
15064 (void *)&cmd_vf_tc_bw_vf_id,
15065 (void *)&cmd_vf_tc_bw_bw_list,
15071 cmd_tc_min_bw_parsed(
15072 void *parsed_result,
15073 __attribute__((unused)) struct cmdline *cl,
15074 __attribute__((unused)) void *data)
15076 struct cmd_vf_tc_bw_result *res = parsed_result;
15077 struct rte_port *port;
15080 int ret = -ENOTSUP;
15082 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15085 port = &ports[res->port_id];
15086 /** Check if the port is not started **/
15087 if (port->port_status != RTE_PORT_STOPPED) {
15088 printf("Please stop port %d first\n", res->port_id);
15092 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15096 #ifdef RTE_LIBRTE_IXGBE_PMD
15097 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15104 printf("invalid bandwidth\n");
15107 printf("invalid port_id %d\n", res->port_id);
15110 printf("function not implemented\n");
15113 printf("programming error: (%s)\n", strerror(-ret));
15117 cmdline_parse_inst_t cmd_tc_min_bw = {
15118 .f = cmd_tc_min_bw_parsed,
15120 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15122 (void *)&cmd_vf_tc_bw_set,
15123 (void *)&cmd_vf_tc_bw_tc,
15124 (void *)&cmd_vf_tc_bw_tx,
15125 (void *)&cmd_vf_tc_bw_min_bw,
15126 (void *)&cmd_vf_tc_bw_port_id,
15127 (void *)&cmd_vf_tc_bw_bw_list,
15132 /* TC max bandwidth setting */
15134 cmd_vf_tc_max_bw_parsed(
15135 void *parsed_result,
15136 __attribute__((unused)) struct cmdline *cl,
15137 __attribute__((unused)) void *data)
15139 struct cmd_vf_tc_bw_result *res = parsed_result;
15140 int ret = -ENOTSUP;
15142 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15145 #ifdef RTE_LIBRTE_I40E_PMD
15146 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15147 res->tc_no, res->bw);
15154 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15155 res->vf_id, res->tc_no, res->bw);
15158 printf("invalid port_id %d\n", res->port_id);
15161 printf("function not implemented\n");
15164 printf("programming error: (%s)\n", strerror(-ret));
15168 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15169 .f = cmd_vf_tc_max_bw_parsed,
15171 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15174 (void *)&cmd_vf_tc_bw_set,
15175 (void *)&cmd_vf_tc_bw_vf,
15176 (void *)&cmd_vf_tc_bw_tc,
15177 (void *)&cmd_vf_tc_bw_tx,
15178 (void *)&cmd_vf_tc_bw_max_bw,
15179 (void *)&cmd_vf_tc_bw_port_id,
15180 (void *)&cmd_vf_tc_bw_vf_id,
15181 (void *)&cmd_vf_tc_bw_tc_no,
15182 (void *)&cmd_vf_tc_bw_bw,
15188 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15190 /* *** Set Port default Traffic Management Hierarchy *** */
15191 struct cmd_set_port_tm_hierarchy_default_result {
15192 cmdline_fixed_string_t set;
15193 cmdline_fixed_string_t port;
15194 cmdline_fixed_string_t tm;
15195 cmdline_fixed_string_t hierarchy;
15196 cmdline_fixed_string_t def;
15200 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15201 TOKEN_STRING_INITIALIZER(
15202 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15203 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15204 TOKEN_STRING_INITIALIZER(
15205 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15206 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15207 TOKEN_STRING_INITIALIZER(
15208 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15209 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15210 TOKEN_STRING_INITIALIZER(
15211 struct cmd_set_port_tm_hierarchy_default_result,
15212 hierarchy, "hierarchy");
15213 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15214 TOKEN_STRING_INITIALIZER(
15215 struct cmd_set_port_tm_hierarchy_default_result,
15217 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15218 TOKEN_NUM_INITIALIZER(
15219 struct cmd_set_port_tm_hierarchy_default_result,
15222 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15223 __attribute__((unused)) struct cmdline *cl,
15224 __attribute__((unused)) void *data)
15226 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15227 struct rte_port *p;
15228 portid_t port_id = res->port_id;
15230 if (port_id_is_invalid(port_id, ENABLED_WARN))
15233 p = &ports[port_id];
15235 /* Forward mode: tm */
15236 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15237 printf(" softnicfwd mode not enabled(error)\n");
15241 /* Set the default tm hierarchy */
15242 p->softport.default_tm_hierarchy_enable = 1;
15245 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15246 .f = cmd_set_port_tm_hierarchy_default_parsed,
15248 .help_str = "set port tm hierarchy default <port_id>",
15250 (void *)&cmd_set_port_tm_hierarchy_default_set,
15251 (void *)&cmd_set_port_tm_hierarchy_default_port,
15252 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15253 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15254 (void *)&cmd_set_port_tm_hierarchy_default_default,
15255 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15261 /** Set VXLAN encapsulation details */
15262 struct cmd_set_vxlan_result {
15263 cmdline_fixed_string_t set;
15264 cmdline_fixed_string_t vxlan;
15265 cmdline_fixed_string_t pos_token;
15266 cmdline_fixed_string_t ip_version;
15267 uint32_t vlan_present:1;
15271 cmdline_ipaddr_t ip_src;
15272 cmdline_ipaddr_t ip_dst;
15276 struct rte_ether_addr eth_src;
15277 struct rte_ether_addr eth_dst;
15280 cmdline_parse_token_string_t cmd_set_vxlan_set =
15281 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15282 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15283 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15284 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15285 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15287 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15288 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15289 "vxlan-with-vlan");
15290 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15291 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15293 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15294 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15296 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15297 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15299 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15300 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15301 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15302 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15304 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15305 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15306 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15307 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15309 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15310 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15311 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15312 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15314 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15315 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15316 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15317 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15319 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15320 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15321 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15322 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15324 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15325 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15326 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15327 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15329 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15330 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15331 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15332 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15334 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15335 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15336 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15337 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15339 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15340 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15341 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15342 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15344 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15345 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15347 static void cmd_set_vxlan_parsed(void *parsed_result,
15348 __attribute__((unused)) struct cmdline *cl,
15349 __attribute__((unused)) void *data)
15351 struct cmd_set_vxlan_result *res = parsed_result;
15356 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15359 vxlan_encap_conf.select_tos_ttl = 0;
15360 if (strcmp(res->vxlan, "vxlan") == 0)
15361 vxlan_encap_conf.select_vlan = 0;
15362 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15363 vxlan_encap_conf.select_vlan = 1;
15364 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15365 vxlan_encap_conf.select_vlan = 0;
15366 vxlan_encap_conf.select_tos_ttl = 1;
15368 if (strcmp(res->ip_version, "ipv4") == 0)
15369 vxlan_encap_conf.select_ipv4 = 1;
15370 else if (strcmp(res->ip_version, "ipv6") == 0)
15371 vxlan_encap_conf.select_ipv4 = 0;
15374 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15375 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15376 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15377 vxlan_encap_conf.ip_tos = res->tos;
15378 vxlan_encap_conf.ip_ttl = res->ttl;
15379 if (vxlan_encap_conf.select_ipv4) {
15380 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15381 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15383 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15384 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15386 if (vxlan_encap_conf.select_vlan)
15387 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15388 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15389 RTE_ETHER_ADDR_LEN);
15390 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15391 RTE_ETHER_ADDR_LEN);
15394 cmdline_parse_inst_t cmd_set_vxlan = {
15395 .f = cmd_set_vxlan_parsed,
15397 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15398 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15399 " eth-src <eth-src> eth-dst <eth-dst>",
15401 (void *)&cmd_set_vxlan_set,
15402 (void *)&cmd_set_vxlan_vxlan,
15403 (void *)&cmd_set_vxlan_ip_version,
15404 (void *)&cmd_set_vxlan_ip_version_value,
15405 (void *)&cmd_set_vxlan_vni,
15406 (void *)&cmd_set_vxlan_vni_value,
15407 (void *)&cmd_set_vxlan_udp_src,
15408 (void *)&cmd_set_vxlan_udp_src_value,
15409 (void *)&cmd_set_vxlan_udp_dst,
15410 (void *)&cmd_set_vxlan_udp_dst_value,
15411 (void *)&cmd_set_vxlan_ip_src,
15412 (void *)&cmd_set_vxlan_ip_src_value,
15413 (void *)&cmd_set_vxlan_ip_dst,
15414 (void *)&cmd_set_vxlan_ip_dst_value,
15415 (void *)&cmd_set_vxlan_eth_src,
15416 (void *)&cmd_set_vxlan_eth_src_value,
15417 (void *)&cmd_set_vxlan_eth_dst,
15418 (void *)&cmd_set_vxlan_eth_dst_value,
15423 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15424 .f = cmd_set_vxlan_parsed,
15426 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15427 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15428 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15429 " eth-dst <eth-dst>",
15431 (void *)&cmd_set_vxlan_set,
15432 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15433 (void *)&cmd_set_vxlan_ip_version,
15434 (void *)&cmd_set_vxlan_ip_version_value,
15435 (void *)&cmd_set_vxlan_vni,
15436 (void *)&cmd_set_vxlan_vni_value,
15437 (void *)&cmd_set_vxlan_udp_src,
15438 (void *)&cmd_set_vxlan_udp_src_value,
15439 (void *)&cmd_set_vxlan_udp_dst,
15440 (void *)&cmd_set_vxlan_udp_dst_value,
15441 (void *)&cmd_set_vxlan_ip_tos,
15442 (void *)&cmd_set_vxlan_ip_tos_value,
15443 (void *)&cmd_set_vxlan_ip_ttl,
15444 (void *)&cmd_set_vxlan_ip_ttl_value,
15445 (void *)&cmd_set_vxlan_ip_src,
15446 (void *)&cmd_set_vxlan_ip_src_value,
15447 (void *)&cmd_set_vxlan_ip_dst,
15448 (void *)&cmd_set_vxlan_ip_dst_value,
15449 (void *)&cmd_set_vxlan_eth_src,
15450 (void *)&cmd_set_vxlan_eth_src_value,
15451 (void *)&cmd_set_vxlan_eth_dst,
15452 (void *)&cmd_set_vxlan_eth_dst_value,
15457 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15458 .f = cmd_set_vxlan_parsed,
15460 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15461 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15462 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15465 (void *)&cmd_set_vxlan_set,
15466 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15467 (void *)&cmd_set_vxlan_ip_version,
15468 (void *)&cmd_set_vxlan_ip_version_value,
15469 (void *)&cmd_set_vxlan_vni,
15470 (void *)&cmd_set_vxlan_vni_value,
15471 (void *)&cmd_set_vxlan_udp_src,
15472 (void *)&cmd_set_vxlan_udp_src_value,
15473 (void *)&cmd_set_vxlan_udp_dst,
15474 (void *)&cmd_set_vxlan_udp_dst_value,
15475 (void *)&cmd_set_vxlan_ip_src,
15476 (void *)&cmd_set_vxlan_ip_src_value,
15477 (void *)&cmd_set_vxlan_ip_dst,
15478 (void *)&cmd_set_vxlan_ip_dst_value,
15479 (void *)&cmd_set_vxlan_vlan,
15480 (void *)&cmd_set_vxlan_vlan_value,
15481 (void *)&cmd_set_vxlan_eth_src,
15482 (void *)&cmd_set_vxlan_eth_src_value,
15483 (void *)&cmd_set_vxlan_eth_dst,
15484 (void *)&cmd_set_vxlan_eth_dst_value,
15489 /** Set NVGRE encapsulation details */
15490 struct cmd_set_nvgre_result {
15491 cmdline_fixed_string_t set;
15492 cmdline_fixed_string_t nvgre;
15493 cmdline_fixed_string_t pos_token;
15494 cmdline_fixed_string_t ip_version;
15496 cmdline_ipaddr_t ip_src;
15497 cmdline_ipaddr_t ip_dst;
15499 struct rte_ether_addr eth_src;
15500 struct rte_ether_addr eth_dst;
15503 cmdline_parse_token_string_t cmd_set_nvgre_set =
15504 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15505 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15506 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15507 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15508 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15509 "nvgre-with-vlan");
15510 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15511 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15513 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15514 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15516 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15517 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15519 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15520 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15521 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15522 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15524 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15525 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15526 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15527 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15529 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15530 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15531 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15532 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15534 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15535 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15536 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15537 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15539 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15540 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15541 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15542 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15544 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15545 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15547 static void cmd_set_nvgre_parsed(void *parsed_result,
15548 __attribute__((unused)) struct cmdline *cl,
15549 __attribute__((unused)) void *data)
15551 struct cmd_set_nvgre_result *res = parsed_result;
15553 uint32_t nvgre_tni;
15556 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15559 if (strcmp(res->nvgre, "nvgre") == 0)
15560 nvgre_encap_conf.select_vlan = 0;
15561 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15562 nvgre_encap_conf.select_vlan = 1;
15563 if (strcmp(res->ip_version, "ipv4") == 0)
15564 nvgre_encap_conf.select_ipv4 = 1;
15565 else if (strcmp(res->ip_version, "ipv6") == 0)
15566 nvgre_encap_conf.select_ipv4 = 0;
15569 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15570 if (nvgre_encap_conf.select_ipv4) {
15571 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15572 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15574 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15575 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15577 if (nvgre_encap_conf.select_vlan)
15578 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15579 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15580 RTE_ETHER_ADDR_LEN);
15581 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15582 RTE_ETHER_ADDR_LEN);
15585 cmdline_parse_inst_t cmd_set_nvgre = {
15586 .f = cmd_set_nvgre_parsed,
15588 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15589 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15590 " eth-dst <eth-dst>",
15592 (void *)&cmd_set_nvgre_set,
15593 (void *)&cmd_set_nvgre_nvgre,
15594 (void *)&cmd_set_nvgre_ip_version,
15595 (void *)&cmd_set_nvgre_ip_version_value,
15596 (void *)&cmd_set_nvgre_tni,
15597 (void *)&cmd_set_nvgre_tni_value,
15598 (void *)&cmd_set_nvgre_ip_src,
15599 (void *)&cmd_set_nvgre_ip_src_value,
15600 (void *)&cmd_set_nvgre_ip_dst,
15601 (void *)&cmd_set_nvgre_ip_dst_value,
15602 (void *)&cmd_set_nvgre_eth_src,
15603 (void *)&cmd_set_nvgre_eth_src_value,
15604 (void *)&cmd_set_nvgre_eth_dst,
15605 (void *)&cmd_set_nvgre_eth_dst_value,
15610 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15611 .f = cmd_set_nvgre_parsed,
15613 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15614 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15615 " eth-src <eth-src> eth-dst <eth-dst>",
15617 (void *)&cmd_set_nvgre_set,
15618 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15619 (void *)&cmd_set_nvgre_ip_version,
15620 (void *)&cmd_set_nvgre_ip_version_value,
15621 (void *)&cmd_set_nvgre_tni,
15622 (void *)&cmd_set_nvgre_tni_value,
15623 (void *)&cmd_set_nvgre_ip_src,
15624 (void *)&cmd_set_nvgre_ip_src_value,
15625 (void *)&cmd_set_nvgre_ip_dst,
15626 (void *)&cmd_set_nvgre_ip_dst_value,
15627 (void *)&cmd_set_nvgre_vlan,
15628 (void *)&cmd_set_nvgre_vlan_value,
15629 (void *)&cmd_set_nvgre_eth_src,
15630 (void *)&cmd_set_nvgre_eth_src_value,
15631 (void *)&cmd_set_nvgre_eth_dst,
15632 (void *)&cmd_set_nvgre_eth_dst_value,
15637 /** Set L2 encapsulation details */
15638 struct cmd_set_l2_encap_result {
15639 cmdline_fixed_string_t set;
15640 cmdline_fixed_string_t l2_encap;
15641 cmdline_fixed_string_t pos_token;
15642 cmdline_fixed_string_t ip_version;
15643 uint32_t vlan_present:1;
15645 struct rte_ether_addr eth_src;
15646 struct rte_ether_addr eth_dst;
15649 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15650 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15651 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15652 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15653 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15654 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15655 "l2_encap-with-vlan");
15656 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15657 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15659 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15660 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15662 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15663 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15665 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15666 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15667 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15668 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15670 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15671 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15672 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15673 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15675 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15676 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15678 static void cmd_set_l2_encap_parsed(void *parsed_result,
15679 __attribute__((unused)) struct cmdline *cl,
15680 __attribute__((unused)) void *data)
15682 struct cmd_set_l2_encap_result *res = parsed_result;
15684 if (strcmp(res->l2_encap, "l2_encap") == 0)
15685 l2_encap_conf.select_vlan = 0;
15686 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15687 l2_encap_conf.select_vlan = 1;
15688 if (strcmp(res->ip_version, "ipv4") == 0)
15689 l2_encap_conf.select_ipv4 = 1;
15690 else if (strcmp(res->ip_version, "ipv6") == 0)
15691 l2_encap_conf.select_ipv4 = 0;
15694 if (l2_encap_conf.select_vlan)
15695 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15696 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15697 RTE_ETHER_ADDR_LEN);
15698 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15699 RTE_ETHER_ADDR_LEN);
15702 cmdline_parse_inst_t cmd_set_l2_encap = {
15703 .f = cmd_set_l2_encap_parsed,
15705 .help_str = "set l2_encap ip-version ipv4|ipv6"
15706 " eth-src <eth-src> eth-dst <eth-dst>",
15708 (void *)&cmd_set_l2_encap_set,
15709 (void *)&cmd_set_l2_encap_l2_encap,
15710 (void *)&cmd_set_l2_encap_ip_version,
15711 (void *)&cmd_set_l2_encap_ip_version_value,
15712 (void *)&cmd_set_l2_encap_eth_src,
15713 (void *)&cmd_set_l2_encap_eth_src_value,
15714 (void *)&cmd_set_l2_encap_eth_dst,
15715 (void *)&cmd_set_l2_encap_eth_dst_value,
15720 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15721 .f = cmd_set_l2_encap_parsed,
15723 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15724 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15726 (void *)&cmd_set_l2_encap_set,
15727 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15728 (void *)&cmd_set_l2_encap_ip_version,
15729 (void *)&cmd_set_l2_encap_ip_version_value,
15730 (void *)&cmd_set_l2_encap_vlan,
15731 (void *)&cmd_set_l2_encap_vlan_value,
15732 (void *)&cmd_set_l2_encap_eth_src,
15733 (void *)&cmd_set_l2_encap_eth_src_value,
15734 (void *)&cmd_set_l2_encap_eth_dst,
15735 (void *)&cmd_set_l2_encap_eth_dst_value,
15740 /** Set L2 decapsulation details */
15741 struct cmd_set_l2_decap_result {
15742 cmdline_fixed_string_t set;
15743 cmdline_fixed_string_t l2_decap;
15744 cmdline_fixed_string_t pos_token;
15745 uint32_t vlan_present:1;
15748 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15749 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15750 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15751 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15753 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15754 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15755 "l2_decap-with-vlan");
15757 static void cmd_set_l2_decap_parsed(void *parsed_result,
15758 __attribute__((unused)) struct cmdline *cl,
15759 __attribute__((unused)) void *data)
15761 struct cmd_set_l2_decap_result *res = parsed_result;
15763 if (strcmp(res->l2_decap, "l2_decap") == 0)
15764 l2_decap_conf.select_vlan = 0;
15765 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15766 l2_decap_conf.select_vlan = 1;
15769 cmdline_parse_inst_t cmd_set_l2_decap = {
15770 .f = cmd_set_l2_decap_parsed,
15772 .help_str = "set l2_decap",
15774 (void *)&cmd_set_l2_decap_set,
15775 (void *)&cmd_set_l2_decap_l2_decap,
15780 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15781 .f = cmd_set_l2_decap_parsed,
15783 .help_str = "set l2_decap-with-vlan",
15785 (void *)&cmd_set_l2_decap_set,
15786 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15791 /** Set MPLSoGRE encapsulation details */
15792 struct cmd_set_mplsogre_encap_result {
15793 cmdline_fixed_string_t set;
15794 cmdline_fixed_string_t mplsogre;
15795 cmdline_fixed_string_t pos_token;
15796 cmdline_fixed_string_t ip_version;
15797 uint32_t vlan_present:1;
15799 cmdline_ipaddr_t ip_src;
15800 cmdline_ipaddr_t ip_dst;
15802 struct rte_ether_addr eth_src;
15803 struct rte_ether_addr eth_dst;
15806 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15807 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15809 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15810 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15812 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15813 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15814 mplsogre, "mplsogre_encap-with-vlan");
15815 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15816 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15817 pos_token, "ip-version");
15818 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15819 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15820 ip_version, "ipv4#ipv6");
15821 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15822 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15823 pos_token, "label");
15824 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15825 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15827 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15828 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15829 pos_token, "ip-src");
15830 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15831 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15832 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15833 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15834 pos_token, "ip-dst");
15835 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15836 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15837 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15838 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15839 pos_token, "vlan-tci");
15840 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15841 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15843 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15844 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15845 pos_token, "eth-src");
15846 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15847 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15849 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15850 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15851 pos_token, "eth-dst");
15852 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15853 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15856 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15857 __attribute__((unused)) struct cmdline *cl,
15858 __attribute__((unused)) void *data)
15860 struct cmd_set_mplsogre_encap_result *res = parsed_result;
15862 uint32_t mplsogre_label;
15865 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15868 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15869 mplsogre_encap_conf.select_vlan = 0;
15870 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15871 mplsogre_encap_conf.select_vlan = 1;
15872 if (strcmp(res->ip_version, "ipv4") == 0)
15873 mplsogre_encap_conf.select_ipv4 = 1;
15874 else if (strcmp(res->ip_version, "ipv6") == 0)
15875 mplsogre_encap_conf.select_ipv4 = 0;
15878 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15879 if (mplsogre_encap_conf.select_ipv4) {
15880 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15881 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15883 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15884 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15886 if (mplsogre_encap_conf.select_vlan)
15887 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15888 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15889 RTE_ETHER_ADDR_LEN);
15890 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15891 RTE_ETHER_ADDR_LEN);
15894 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15895 .f = cmd_set_mplsogre_encap_parsed,
15897 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15898 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15899 " eth-dst <eth-dst>",
15901 (void *)&cmd_set_mplsogre_encap_set,
15902 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15903 (void *)&cmd_set_mplsogre_encap_ip_version,
15904 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15905 (void *)&cmd_set_mplsogre_encap_label,
15906 (void *)&cmd_set_mplsogre_encap_label_value,
15907 (void *)&cmd_set_mplsogre_encap_ip_src,
15908 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15909 (void *)&cmd_set_mplsogre_encap_ip_dst,
15910 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15911 (void *)&cmd_set_mplsogre_encap_eth_src,
15912 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15913 (void *)&cmd_set_mplsogre_encap_eth_dst,
15914 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15919 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
15920 .f = cmd_set_mplsogre_encap_parsed,
15922 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
15923 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
15924 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15926 (void *)&cmd_set_mplsogre_encap_set,
15927 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
15928 (void *)&cmd_set_mplsogre_encap_ip_version,
15929 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15930 (void *)&cmd_set_mplsogre_encap_label,
15931 (void *)&cmd_set_mplsogre_encap_label_value,
15932 (void *)&cmd_set_mplsogre_encap_ip_src,
15933 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15934 (void *)&cmd_set_mplsogre_encap_ip_dst,
15935 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15936 (void *)&cmd_set_mplsogre_encap_vlan,
15937 (void *)&cmd_set_mplsogre_encap_vlan_value,
15938 (void *)&cmd_set_mplsogre_encap_eth_src,
15939 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15940 (void *)&cmd_set_mplsogre_encap_eth_dst,
15941 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15946 /** Set MPLSoGRE decapsulation details */
15947 struct cmd_set_mplsogre_decap_result {
15948 cmdline_fixed_string_t set;
15949 cmdline_fixed_string_t mplsogre;
15950 cmdline_fixed_string_t pos_token;
15951 cmdline_fixed_string_t ip_version;
15952 uint32_t vlan_present:1;
15955 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
15956 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
15958 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
15959 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
15961 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
15962 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15963 mplsogre, "mplsogre_decap-with-vlan");
15964 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
15965 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15966 pos_token, "ip-version");
15967 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
15968 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15969 ip_version, "ipv4#ipv6");
15971 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
15972 __attribute__((unused)) struct cmdline *cl,
15973 __attribute__((unused)) void *data)
15975 struct cmd_set_mplsogre_decap_result *res = parsed_result;
15977 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
15978 mplsogre_decap_conf.select_vlan = 0;
15979 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
15980 mplsogre_decap_conf.select_vlan = 1;
15981 if (strcmp(res->ip_version, "ipv4") == 0)
15982 mplsogre_decap_conf.select_ipv4 = 1;
15983 else if (strcmp(res->ip_version, "ipv6") == 0)
15984 mplsogre_decap_conf.select_ipv4 = 0;
15987 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
15988 .f = cmd_set_mplsogre_decap_parsed,
15990 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
15992 (void *)&cmd_set_mplsogre_decap_set,
15993 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
15994 (void *)&cmd_set_mplsogre_decap_ip_version,
15995 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16000 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16001 .f = cmd_set_mplsogre_decap_parsed,
16003 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16005 (void *)&cmd_set_mplsogre_decap_set,
16006 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16007 (void *)&cmd_set_mplsogre_decap_ip_version,
16008 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16013 /** Set MPLSoUDP encapsulation details */
16014 struct cmd_set_mplsoudp_encap_result {
16015 cmdline_fixed_string_t set;
16016 cmdline_fixed_string_t mplsoudp;
16017 cmdline_fixed_string_t pos_token;
16018 cmdline_fixed_string_t ip_version;
16019 uint32_t vlan_present:1;
16023 cmdline_ipaddr_t ip_src;
16024 cmdline_ipaddr_t ip_dst;
16026 struct rte_ether_addr eth_src;
16027 struct rte_ether_addr eth_dst;
16030 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16031 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16033 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16034 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16036 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16037 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16038 mplsoudp, "mplsoudp_encap-with-vlan");
16039 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16040 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16041 pos_token, "ip-version");
16042 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16043 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16044 ip_version, "ipv4#ipv6");
16045 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16046 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16047 pos_token, "label");
16048 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16049 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16051 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16052 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16053 pos_token, "udp-src");
16054 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16055 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16057 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16058 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16059 pos_token, "udp-dst");
16060 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16061 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16063 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16064 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16065 pos_token, "ip-src");
16066 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16067 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16068 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16069 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16070 pos_token, "ip-dst");
16071 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16072 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16073 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16074 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16075 pos_token, "vlan-tci");
16076 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16077 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16079 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16080 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16081 pos_token, "eth-src");
16082 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16083 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16085 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16086 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16087 pos_token, "eth-dst");
16088 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16089 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16092 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16093 __attribute__((unused)) struct cmdline *cl,
16094 __attribute__((unused)) void *data)
16096 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16098 uint32_t mplsoudp_label;
16101 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16104 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16105 mplsoudp_encap_conf.select_vlan = 0;
16106 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16107 mplsoudp_encap_conf.select_vlan = 1;
16108 if (strcmp(res->ip_version, "ipv4") == 0)
16109 mplsoudp_encap_conf.select_ipv4 = 1;
16110 else if (strcmp(res->ip_version, "ipv6") == 0)
16111 mplsoudp_encap_conf.select_ipv4 = 0;
16114 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16115 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16116 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16117 if (mplsoudp_encap_conf.select_ipv4) {
16118 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16119 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16121 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16122 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16124 if (mplsoudp_encap_conf.select_vlan)
16125 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16126 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16127 RTE_ETHER_ADDR_LEN);
16128 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16129 RTE_ETHER_ADDR_LEN);
16132 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16133 .f = cmd_set_mplsoudp_encap_parsed,
16135 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16136 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16137 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16139 (void *)&cmd_set_mplsoudp_encap_set,
16140 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16141 (void *)&cmd_set_mplsoudp_encap_ip_version,
16142 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16143 (void *)&cmd_set_mplsoudp_encap_label,
16144 (void *)&cmd_set_mplsoudp_encap_label_value,
16145 (void *)&cmd_set_mplsoudp_encap_udp_src,
16146 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16147 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16148 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16149 (void *)&cmd_set_mplsoudp_encap_ip_src,
16150 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16151 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16152 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16153 (void *)&cmd_set_mplsoudp_encap_eth_src,
16154 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16155 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16156 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16161 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16162 .f = cmd_set_mplsoudp_encap_parsed,
16164 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16165 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16166 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16167 " eth-src <eth-src> eth-dst <eth-dst>",
16169 (void *)&cmd_set_mplsoudp_encap_set,
16170 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16171 (void *)&cmd_set_mplsoudp_encap_ip_version,
16172 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16173 (void *)&cmd_set_mplsoudp_encap_label,
16174 (void *)&cmd_set_mplsoudp_encap_label_value,
16175 (void *)&cmd_set_mplsoudp_encap_udp_src,
16176 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16177 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16178 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16179 (void *)&cmd_set_mplsoudp_encap_ip_src,
16180 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16181 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16182 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16183 (void *)&cmd_set_mplsoudp_encap_vlan,
16184 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16185 (void *)&cmd_set_mplsoudp_encap_eth_src,
16186 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16187 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16188 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16193 /** Set MPLSoUDP decapsulation details */
16194 struct cmd_set_mplsoudp_decap_result {
16195 cmdline_fixed_string_t set;
16196 cmdline_fixed_string_t mplsoudp;
16197 cmdline_fixed_string_t pos_token;
16198 cmdline_fixed_string_t ip_version;
16199 uint32_t vlan_present:1;
16202 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16203 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16205 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16206 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16208 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16209 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16210 mplsoudp, "mplsoudp_decap-with-vlan");
16211 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16212 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16213 pos_token, "ip-version");
16214 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16215 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16216 ip_version, "ipv4#ipv6");
16218 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16219 __attribute__((unused)) struct cmdline *cl,
16220 __attribute__((unused)) void *data)
16222 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16224 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16225 mplsoudp_decap_conf.select_vlan = 0;
16226 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16227 mplsoudp_decap_conf.select_vlan = 1;
16228 if (strcmp(res->ip_version, "ipv4") == 0)
16229 mplsoudp_decap_conf.select_ipv4 = 1;
16230 else if (strcmp(res->ip_version, "ipv6") == 0)
16231 mplsoudp_decap_conf.select_ipv4 = 0;
16234 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16235 .f = cmd_set_mplsoudp_decap_parsed,
16237 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16239 (void *)&cmd_set_mplsoudp_decap_set,
16240 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16241 (void *)&cmd_set_mplsoudp_decap_ip_version,
16242 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16247 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16248 .f = cmd_set_mplsoudp_decap_parsed,
16250 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16252 (void *)&cmd_set_mplsoudp_decap_set,
16253 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16254 (void *)&cmd_set_mplsoudp_decap_ip_version,
16255 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16260 /* Strict link priority scheduling mode setting */
16262 cmd_strict_link_prio_parsed(
16263 void *parsed_result,
16264 __attribute__((unused)) struct cmdline *cl,
16265 __attribute__((unused)) void *data)
16267 struct cmd_vf_tc_bw_result *res = parsed_result;
16268 int ret = -ENOTSUP;
16270 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16273 #ifdef RTE_LIBRTE_I40E_PMD
16274 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16281 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16284 printf("invalid port_id %d\n", res->port_id);
16287 printf("function not implemented\n");
16290 printf("programming error: (%s)\n", strerror(-ret));
16294 cmdline_parse_inst_t cmd_strict_link_prio = {
16295 .f = cmd_strict_link_prio_parsed,
16297 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16299 (void *)&cmd_vf_tc_bw_set,
16300 (void *)&cmd_vf_tc_bw_tx,
16301 (void *)&cmd_vf_tc_bw_strict_link_prio,
16302 (void *)&cmd_vf_tc_bw_port_id,
16303 (void *)&cmd_vf_tc_bw_tc_map,
16308 /* Load dynamic device personalization*/
16309 struct cmd_ddp_add_result {
16310 cmdline_fixed_string_t ddp;
16311 cmdline_fixed_string_t add;
16316 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16317 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16318 cmdline_parse_token_string_t cmd_ddp_add_add =
16319 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16320 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16321 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16322 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16323 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16326 cmd_ddp_add_parsed(
16327 void *parsed_result,
16328 __attribute__((unused)) struct cmdline *cl,
16329 __attribute__((unused)) void *data)
16331 struct cmd_ddp_add_result *res = parsed_result;
16337 int ret = -ENOTSUP;
16339 if (!all_ports_stopped()) {
16340 printf("Please stop all ports first\n");
16344 filepath = strdup(res->filepath);
16345 if (filepath == NULL) {
16346 printf("Failed to allocate memory\n");
16349 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16351 buff = open_file(file_fld[0], &size);
16353 free((void *)filepath);
16357 #ifdef RTE_LIBRTE_I40E_PMD
16358 if (ret == -ENOTSUP)
16359 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16361 RTE_PMD_I40E_PKG_OP_WR_ADD);
16364 if (ret == -EEXIST)
16365 printf("Profile has already existed.\n");
16367 printf("Failed to load profile.\n");
16368 else if (file_num == 2)
16369 save_file(file_fld[1], buff, size);
16372 free((void *)filepath);
16375 cmdline_parse_inst_t cmd_ddp_add = {
16376 .f = cmd_ddp_add_parsed,
16378 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16380 (void *)&cmd_ddp_add_ddp,
16381 (void *)&cmd_ddp_add_add,
16382 (void *)&cmd_ddp_add_port_id,
16383 (void *)&cmd_ddp_add_filepath,
16388 /* Delete dynamic device personalization*/
16389 struct cmd_ddp_del_result {
16390 cmdline_fixed_string_t ddp;
16391 cmdline_fixed_string_t del;
16396 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16397 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16398 cmdline_parse_token_string_t cmd_ddp_del_del =
16399 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16400 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16401 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16402 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16403 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16406 cmd_ddp_del_parsed(
16407 void *parsed_result,
16408 __attribute__((unused)) struct cmdline *cl,
16409 __attribute__((unused)) void *data)
16411 struct cmd_ddp_del_result *res = parsed_result;
16414 int ret = -ENOTSUP;
16416 if (!all_ports_stopped()) {
16417 printf("Please stop all ports first\n");
16421 buff = open_file(res->filepath, &size);
16425 #ifdef RTE_LIBRTE_I40E_PMD
16426 if (ret == -ENOTSUP)
16427 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16429 RTE_PMD_I40E_PKG_OP_WR_DEL);
16432 if (ret == -EACCES)
16433 printf("Profile does not exist.\n");
16435 printf("Failed to delete profile.\n");
16440 cmdline_parse_inst_t cmd_ddp_del = {
16441 .f = cmd_ddp_del_parsed,
16443 .help_str = "ddp del <port_id> <backup_profile_path>",
16445 (void *)&cmd_ddp_del_ddp,
16446 (void *)&cmd_ddp_del_del,
16447 (void *)&cmd_ddp_del_port_id,
16448 (void *)&cmd_ddp_del_filepath,
16453 /* Get dynamic device personalization profile info */
16454 struct cmd_ddp_info_result {
16455 cmdline_fixed_string_t ddp;
16456 cmdline_fixed_string_t get;
16457 cmdline_fixed_string_t info;
16461 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16462 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16463 cmdline_parse_token_string_t cmd_ddp_info_get =
16464 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16465 cmdline_parse_token_string_t cmd_ddp_info_info =
16466 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16467 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16468 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16471 cmd_ddp_info_parsed(
16472 void *parsed_result,
16473 __attribute__((unused)) struct cmdline *cl,
16474 __attribute__((unused)) void *data)
16476 struct cmd_ddp_info_result *res = parsed_result;
16479 int ret = -ENOTSUP;
16480 #ifdef RTE_LIBRTE_I40E_PMD
16483 uint32_t buff_size = 0;
16484 struct rte_pmd_i40e_profile_info info;
16485 uint32_t dev_num = 0;
16486 struct rte_pmd_i40e_ddp_device_id *devs;
16487 uint32_t proto_num = 0;
16488 struct rte_pmd_i40e_proto_info *proto = NULL;
16489 uint32_t pctype_num = 0;
16490 struct rte_pmd_i40e_ptype_info *pctype;
16491 uint32_t ptype_num = 0;
16492 struct rte_pmd_i40e_ptype_info *ptype;
16497 pkg = open_file(res->filepath, &pkg_size);
16501 #ifdef RTE_LIBRTE_I40E_PMD
16502 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16503 (uint8_t *)&info, sizeof(info),
16504 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16506 printf("Global Track id: 0x%x\n", info.track_id);
16507 printf("Global Version: %d.%d.%d.%d\n",
16508 info.version.major,
16509 info.version.minor,
16510 info.version.update,
16511 info.version.draft);
16512 printf("Global Package name: %s\n\n", info.name);
16515 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16516 (uint8_t *)&info, sizeof(info),
16517 RTE_PMD_I40E_PKG_INFO_HEADER);
16519 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16520 printf("i40e Profile Version: %d.%d.%d.%d\n",
16521 info.version.major,
16522 info.version.minor,
16523 info.version.update,
16524 info.version.draft);
16525 printf("i40e Profile name: %s\n\n", info.name);
16528 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16529 (uint8_t *)&buff_size, sizeof(buff_size),
16530 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16531 if (!ret && buff_size) {
16532 buff = (uint8_t *)malloc(buff_size);
16534 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16536 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16538 printf("Package Notes:\n%s\n\n", buff);
16543 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16544 (uint8_t *)&dev_num, sizeof(dev_num),
16545 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16546 if (!ret && dev_num) {
16547 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16548 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16550 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16551 (uint8_t *)devs, buff_size,
16552 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16554 printf("List of supported devices:\n");
16555 for (i = 0; i < dev_num; i++) {
16556 printf(" %04X:%04X %04X:%04X\n",
16557 devs[i].vendor_dev_id >> 16,
16558 devs[i].vendor_dev_id & 0xFFFF,
16559 devs[i].sub_vendor_dev_id >> 16,
16560 devs[i].sub_vendor_dev_id & 0xFFFF);
16568 /* get information about protocols and packet types */
16569 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16570 (uint8_t *)&proto_num, sizeof(proto_num),
16571 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16572 if (ret || !proto_num)
16573 goto no_print_return;
16575 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16576 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16578 goto no_print_return;
16580 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16582 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16584 printf("List of used protocols:\n");
16585 for (i = 0; i < proto_num; i++)
16586 printf(" %2u: %s\n", proto[i].proto_id,
16590 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16591 (uint8_t *)&pctype_num, sizeof(pctype_num),
16592 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16593 if (ret || !pctype_num)
16594 goto no_print_pctypes;
16596 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16597 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16599 goto no_print_pctypes;
16601 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16603 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16606 goto no_print_pctypes;
16609 printf("List of defined packet classification types:\n");
16610 for (i = 0; i < pctype_num; i++) {
16611 printf(" %2u:", pctype[i].ptype_id);
16612 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16613 proto_id = pctype[i].protocols[j];
16614 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16615 for (n = 0; n < proto_num; n++) {
16616 if (proto[n].proto_id == proto_id) {
16617 printf(" %s", proto[n].name);
16630 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16632 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16633 if (ret || !ptype_num)
16634 goto no_print_return;
16636 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16637 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16639 goto no_print_return;
16641 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16643 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16646 goto no_print_return;
16648 printf("List of defined packet types:\n");
16649 for (i = 0; i < ptype_num; i++) {
16650 printf(" %2u:", ptype[i].ptype_id);
16651 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16652 proto_id = ptype[i].protocols[j];
16653 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16654 for (n = 0; n < proto_num; n++) {
16655 if (proto[n].proto_id == proto_id) {
16656 printf(" %s", proto[n].name);
16672 if (ret == -ENOTSUP)
16673 printf("Function not supported in PMD driver\n");
16677 cmdline_parse_inst_t cmd_ddp_get_info = {
16678 .f = cmd_ddp_info_parsed,
16680 .help_str = "ddp get info <profile_path>",
16682 (void *)&cmd_ddp_info_ddp,
16683 (void *)&cmd_ddp_info_get,
16684 (void *)&cmd_ddp_info_info,
16685 (void *)&cmd_ddp_info_filepath,
16690 /* Get dynamic device personalization profile info list*/
16691 #define PROFILE_INFO_SIZE 48
16692 #define MAX_PROFILE_NUM 16
16694 struct cmd_ddp_get_list_result {
16695 cmdline_fixed_string_t ddp;
16696 cmdline_fixed_string_t get;
16697 cmdline_fixed_string_t list;
16701 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16702 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16703 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16704 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16705 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16706 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16707 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16708 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16711 cmd_ddp_get_list_parsed(
16712 __attribute__((unused)) void *parsed_result,
16713 __attribute__((unused)) struct cmdline *cl,
16714 __attribute__((unused)) void *data)
16716 #ifdef RTE_LIBRTE_I40E_PMD
16717 struct cmd_ddp_get_list_result *res = parsed_result;
16718 struct rte_pmd_i40e_profile_list *p_list;
16719 struct rte_pmd_i40e_profile_info *p_info;
16724 int ret = -ENOTSUP;
16726 #ifdef RTE_LIBRTE_I40E_PMD
16727 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16728 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16730 printf("%s: Failed to malloc buffer\n", __func__);
16732 if (ret == -ENOTSUP)
16733 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16734 (uint8_t *)p_list, size);
16737 p_num = p_list->p_count;
16738 printf("Profile number is: %d\n\n", p_num);
16740 for (i = 0; i < p_num; i++) {
16741 p_info = &p_list->p_info[i];
16742 printf("Profile %d:\n", i);
16743 printf("Track id: 0x%x\n", p_info->track_id);
16744 printf("Version: %d.%d.%d.%d\n",
16745 p_info->version.major,
16746 p_info->version.minor,
16747 p_info->version.update,
16748 p_info->version.draft);
16749 printf("Profile name: %s\n\n", p_info->name);
16757 printf("Failed to get ddp list\n");
16760 cmdline_parse_inst_t cmd_ddp_get_list = {
16761 .f = cmd_ddp_get_list_parsed,
16763 .help_str = "ddp get list <port_id>",
16765 (void *)&cmd_ddp_get_list_ddp,
16766 (void *)&cmd_ddp_get_list_get,
16767 (void *)&cmd_ddp_get_list_list,
16768 (void *)&cmd_ddp_get_list_port_id,
16773 /* Configure input set */
16774 struct cmd_cfg_input_set_result {
16775 cmdline_fixed_string_t port;
16776 cmdline_fixed_string_t cfg;
16778 cmdline_fixed_string_t pctype;
16780 cmdline_fixed_string_t inset_type;
16781 cmdline_fixed_string_t opt;
16782 cmdline_fixed_string_t field;
16787 cmd_cfg_input_set_parsed(
16788 __attribute__((unused)) void *parsed_result,
16789 __attribute__((unused)) struct cmdline *cl,
16790 __attribute__((unused)) void *data)
16792 #ifdef RTE_LIBRTE_I40E_PMD
16793 struct cmd_cfg_input_set_result *res = parsed_result;
16794 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16795 struct rte_pmd_i40e_inset inset;
16797 int ret = -ENOTSUP;
16799 if (!all_ports_stopped()) {
16800 printf("Please stop all ports first\n");
16804 #ifdef RTE_LIBRTE_I40E_PMD
16805 if (!strcmp(res->inset_type, "hash_inset"))
16806 inset_type = INSET_HASH;
16807 else if (!strcmp(res->inset_type, "fdir_inset"))
16808 inset_type = INSET_FDIR;
16809 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16810 inset_type = INSET_FDIR_FLX;
16811 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16812 &inset, inset_type);
16814 printf("Failed to get input set.\n");
16818 if (!strcmp(res->opt, "get")) {
16819 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16822 printf("Field index %d is enabled.\n", res->field_idx);
16824 printf("Field index %d is disabled.\n", res->field_idx);
16826 } else if (!strcmp(res->opt, "set"))
16827 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16829 else if (!strcmp(res->opt, "clear"))
16830 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16833 printf("Failed to configure input set field.\n");
16837 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16838 &inset, inset_type);
16840 printf("Failed to set input set.\n");
16845 if (ret == -ENOTSUP)
16846 printf("Function not supported\n");
16849 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16850 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16852 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16853 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16855 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16856 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16858 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16859 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16861 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16862 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16864 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16865 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16867 "hash_inset#fdir_inset#fdir_flx_inset");
16868 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16869 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16870 opt, "get#set#clear");
16871 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16872 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16874 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16875 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16878 cmdline_parse_inst_t cmd_cfg_input_set = {
16879 .f = cmd_cfg_input_set_parsed,
16881 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16882 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16884 (void *)&cmd_cfg_input_set_port,
16885 (void *)&cmd_cfg_input_set_cfg,
16886 (void *)&cmd_cfg_input_set_port_id,
16887 (void *)&cmd_cfg_input_set_pctype,
16888 (void *)&cmd_cfg_input_set_pctype_id,
16889 (void *)&cmd_cfg_input_set_inset_type,
16890 (void *)&cmd_cfg_input_set_opt,
16891 (void *)&cmd_cfg_input_set_field,
16892 (void *)&cmd_cfg_input_set_field_idx,
16897 /* Clear input set */
16898 struct cmd_clear_input_set_result {
16899 cmdline_fixed_string_t port;
16900 cmdline_fixed_string_t cfg;
16902 cmdline_fixed_string_t pctype;
16904 cmdline_fixed_string_t inset_type;
16905 cmdline_fixed_string_t clear;
16906 cmdline_fixed_string_t all;
16910 cmd_clear_input_set_parsed(
16911 __attribute__((unused)) void *parsed_result,
16912 __attribute__((unused)) struct cmdline *cl,
16913 __attribute__((unused)) void *data)
16915 #ifdef RTE_LIBRTE_I40E_PMD
16916 struct cmd_clear_input_set_result *res = parsed_result;
16917 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16918 struct rte_pmd_i40e_inset inset;
16920 int ret = -ENOTSUP;
16922 if (!all_ports_stopped()) {
16923 printf("Please stop all ports first\n");
16927 #ifdef RTE_LIBRTE_I40E_PMD
16928 if (!strcmp(res->inset_type, "hash_inset"))
16929 inset_type = INSET_HASH;
16930 else if (!strcmp(res->inset_type, "fdir_inset"))
16931 inset_type = INSET_FDIR;
16932 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16933 inset_type = INSET_FDIR_FLX;
16935 memset(&inset, 0, sizeof(inset));
16937 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16938 &inset, inset_type);
16940 printf("Failed to clear input set.\n");
16946 if (ret == -ENOTSUP)
16947 printf("Function not supported\n");
16950 cmdline_parse_token_string_t cmd_clear_input_set_port =
16951 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16953 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
16954 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16956 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
16957 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16959 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
16960 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16962 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
16963 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16965 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
16966 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16968 "hash_inset#fdir_inset#fdir_flx_inset");
16969 cmdline_parse_token_string_t cmd_clear_input_set_clear =
16970 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16972 cmdline_parse_token_string_t cmd_clear_input_set_all =
16973 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16976 cmdline_parse_inst_t cmd_clear_input_set = {
16977 .f = cmd_clear_input_set_parsed,
16979 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16980 "fdir_inset|fdir_flx_inset clear all",
16982 (void *)&cmd_clear_input_set_port,
16983 (void *)&cmd_clear_input_set_cfg,
16984 (void *)&cmd_clear_input_set_port_id,
16985 (void *)&cmd_clear_input_set_pctype,
16986 (void *)&cmd_clear_input_set_pctype_id,
16987 (void *)&cmd_clear_input_set_inset_type,
16988 (void *)&cmd_clear_input_set_clear,
16989 (void *)&cmd_clear_input_set_all,
16994 /* show vf stats */
16996 /* Common result structure for show vf stats */
16997 struct cmd_show_vf_stats_result {
16998 cmdline_fixed_string_t show;
16999 cmdline_fixed_string_t vf;
17000 cmdline_fixed_string_t stats;
17005 /* Common CLI fields show vf stats*/
17006 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17007 TOKEN_STRING_INITIALIZER
17008 (struct cmd_show_vf_stats_result,
17010 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17011 TOKEN_STRING_INITIALIZER
17012 (struct cmd_show_vf_stats_result,
17014 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17015 TOKEN_STRING_INITIALIZER
17016 (struct cmd_show_vf_stats_result,
17018 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17019 TOKEN_NUM_INITIALIZER
17020 (struct cmd_show_vf_stats_result,
17022 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17023 TOKEN_NUM_INITIALIZER
17024 (struct cmd_show_vf_stats_result,
17028 cmd_show_vf_stats_parsed(
17029 void *parsed_result,
17030 __attribute__((unused)) struct cmdline *cl,
17031 __attribute__((unused)) void *data)
17033 struct cmd_show_vf_stats_result *res = parsed_result;
17034 struct rte_eth_stats stats;
17035 int ret = -ENOTSUP;
17036 static const char *nic_stats_border = "########################";
17038 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17041 memset(&stats, 0, sizeof(stats));
17043 #ifdef RTE_LIBRTE_I40E_PMD
17044 if (ret == -ENOTSUP)
17045 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17049 #ifdef RTE_LIBRTE_BNXT_PMD
17050 if (ret == -ENOTSUP)
17051 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17060 printf("invalid vf_id %d\n", res->vf_id);
17063 printf("invalid port_id %d\n", res->port_id);
17066 printf("function not implemented\n");
17069 printf("programming error: (%s)\n", strerror(-ret));
17072 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17073 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17075 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17077 stats.ipackets, stats.imissed, stats.ibytes);
17078 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17079 printf(" RX-nombuf: %-10"PRIu64"\n",
17081 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17083 stats.opackets, stats.oerrors, stats.obytes);
17085 printf(" %s############################%s\n",
17086 nic_stats_border, nic_stats_border);
17089 cmdline_parse_inst_t cmd_show_vf_stats = {
17090 .f = cmd_show_vf_stats_parsed,
17092 .help_str = "show vf stats <port_id> <vf_id>",
17094 (void *)&cmd_show_vf_stats_show,
17095 (void *)&cmd_show_vf_stats_vf,
17096 (void *)&cmd_show_vf_stats_stats,
17097 (void *)&cmd_show_vf_stats_port_id,
17098 (void *)&cmd_show_vf_stats_vf_id,
17103 /* clear vf stats */
17105 /* Common result structure for clear vf stats */
17106 struct cmd_clear_vf_stats_result {
17107 cmdline_fixed_string_t clear;
17108 cmdline_fixed_string_t vf;
17109 cmdline_fixed_string_t stats;
17114 /* Common CLI fields clear vf stats*/
17115 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17116 TOKEN_STRING_INITIALIZER
17117 (struct cmd_clear_vf_stats_result,
17119 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17120 TOKEN_STRING_INITIALIZER
17121 (struct cmd_clear_vf_stats_result,
17123 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17124 TOKEN_STRING_INITIALIZER
17125 (struct cmd_clear_vf_stats_result,
17127 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17128 TOKEN_NUM_INITIALIZER
17129 (struct cmd_clear_vf_stats_result,
17131 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17132 TOKEN_NUM_INITIALIZER
17133 (struct cmd_clear_vf_stats_result,
17137 cmd_clear_vf_stats_parsed(
17138 void *parsed_result,
17139 __attribute__((unused)) struct cmdline *cl,
17140 __attribute__((unused)) void *data)
17142 struct cmd_clear_vf_stats_result *res = parsed_result;
17143 int ret = -ENOTSUP;
17145 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17148 #ifdef RTE_LIBRTE_I40E_PMD
17149 if (ret == -ENOTSUP)
17150 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17153 #ifdef RTE_LIBRTE_BNXT_PMD
17154 if (ret == -ENOTSUP)
17155 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17163 printf("invalid vf_id %d\n", res->vf_id);
17166 printf("invalid port_id %d\n", res->port_id);
17169 printf("function not implemented\n");
17172 printf("programming error: (%s)\n", strerror(-ret));
17176 cmdline_parse_inst_t cmd_clear_vf_stats = {
17177 .f = cmd_clear_vf_stats_parsed,
17179 .help_str = "clear vf stats <port_id> <vf_id>",
17181 (void *)&cmd_clear_vf_stats_clear,
17182 (void *)&cmd_clear_vf_stats_vf,
17183 (void *)&cmd_clear_vf_stats_stats,
17184 (void *)&cmd_clear_vf_stats_port_id,
17185 (void *)&cmd_clear_vf_stats_vf_id,
17190 /* port config pctype mapping reset */
17192 /* Common result structure for port config pctype mapping reset */
17193 struct cmd_pctype_mapping_reset_result {
17194 cmdline_fixed_string_t port;
17195 cmdline_fixed_string_t config;
17197 cmdline_fixed_string_t pctype;
17198 cmdline_fixed_string_t mapping;
17199 cmdline_fixed_string_t reset;
17202 /* Common CLI fields for port config pctype mapping reset*/
17203 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17204 TOKEN_STRING_INITIALIZER
17205 (struct cmd_pctype_mapping_reset_result,
17207 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17208 TOKEN_STRING_INITIALIZER
17209 (struct cmd_pctype_mapping_reset_result,
17211 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17212 TOKEN_NUM_INITIALIZER
17213 (struct cmd_pctype_mapping_reset_result,
17215 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17216 TOKEN_STRING_INITIALIZER
17217 (struct cmd_pctype_mapping_reset_result,
17219 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17220 TOKEN_STRING_INITIALIZER
17221 (struct cmd_pctype_mapping_reset_result,
17222 mapping, "mapping");
17223 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17224 TOKEN_STRING_INITIALIZER
17225 (struct cmd_pctype_mapping_reset_result,
17229 cmd_pctype_mapping_reset_parsed(
17230 void *parsed_result,
17231 __attribute__((unused)) struct cmdline *cl,
17232 __attribute__((unused)) void *data)
17234 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17235 int ret = -ENOTSUP;
17237 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17240 #ifdef RTE_LIBRTE_I40E_PMD
17241 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17248 printf("invalid port_id %d\n", res->port_id);
17251 printf("function not implemented\n");
17254 printf("programming error: (%s)\n", strerror(-ret));
17258 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17259 .f = cmd_pctype_mapping_reset_parsed,
17261 .help_str = "port config <port_id> pctype mapping reset",
17263 (void *)&cmd_pctype_mapping_reset_port,
17264 (void *)&cmd_pctype_mapping_reset_config,
17265 (void *)&cmd_pctype_mapping_reset_port_id,
17266 (void *)&cmd_pctype_mapping_reset_pctype,
17267 (void *)&cmd_pctype_mapping_reset_mapping,
17268 (void *)&cmd_pctype_mapping_reset_reset,
17273 /* show port pctype mapping */
17275 /* Common result structure for show port pctype mapping */
17276 struct cmd_pctype_mapping_get_result {
17277 cmdline_fixed_string_t show;
17278 cmdline_fixed_string_t port;
17280 cmdline_fixed_string_t pctype;
17281 cmdline_fixed_string_t mapping;
17284 /* Common CLI fields for pctype mapping get */
17285 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17286 TOKEN_STRING_INITIALIZER
17287 (struct cmd_pctype_mapping_get_result,
17289 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17290 TOKEN_STRING_INITIALIZER
17291 (struct cmd_pctype_mapping_get_result,
17293 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17294 TOKEN_NUM_INITIALIZER
17295 (struct cmd_pctype_mapping_get_result,
17297 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17298 TOKEN_STRING_INITIALIZER
17299 (struct cmd_pctype_mapping_get_result,
17301 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17302 TOKEN_STRING_INITIALIZER
17303 (struct cmd_pctype_mapping_get_result,
17304 mapping, "mapping");
17307 cmd_pctype_mapping_get_parsed(
17308 void *parsed_result,
17309 __attribute__((unused)) struct cmdline *cl,
17310 __attribute__((unused)) void *data)
17312 struct cmd_pctype_mapping_get_result *res = parsed_result;
17313 int ret = -ENOTSUP;
17314 #ifdef RTE_LIBRTE_I40E_PMD
17315 struct rte_pmd_i40e_flow_type_mapping
17316 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17317 int i, j, first_pctype;
17320 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17323 #ifdef RTE_LIBRTE_I40E_PMD
17324 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17331 printf("invalid port_id %d\n", res->port_id);
17334 printf("function not implemented\n");
17337 printf("programming error: (%s)\n", strerror(-ret));
17341 #ifdef RTE_LIBRTE_I40E_PMD
17342 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17343 if (mapping[i].pctype != 0ULL) {
17346 printf("pctype: ");
17347 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17348 if (mapping[i].pctype & (1ULL << j)) {
17349 printf(first_pctype ?
17350 "%02d" : ",%02d", j);
17354 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17360 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17361 .f = cmd_pctype_mapping_get_parsed,
17363 .help_str = "show port <port_id> pctype mapping",
17365 (void *)&cmd_pctype_mapping_get_show,
17366 (void *)&cmd_pctype_mapping_get_port,
17367 (void *)&cmd_pctype_mapping_get_port_id,
17368 (void *)&cmd_pctype_mapping_get_pctype,
17369 (void *)&cmd_pctype_mapping_get_mapping,
17374 /* port config pctype mapping update */
17376 /* Common result structure for port config pctype mapping update */
17377 struct cmd_pctype_mapping_update_result {
17378 cmdline_fixed_string_t port;
17379 cmdline_fixed_string_t config;
17381 cmdline_fixed_string_t pctype;
17382 cmdline_fixed_string_t mapping;
17383 cmdline_fixed_string_t update;
17384 cmdline_fixed_string_t pctype_list;
17385 uint16_t flow_type;
17388 /* Common CLI fields for pctype mapping update*/
17389 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17390 TOKEN_STRING_INITIALIZER
17391 (struct cmd_pctype_mapping_update_result,
17393 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17394 TOKEN_STRING_INITIALIZER
17395 (struct cmd_pctype_mapping_update_result,
17397 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17398 TOKEN_NUM_INITIALIZER
17399 (struct cmd_pctype_mapping_update_result,
17401 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17402 TOKEN_STRING_INITIALIZER
17403 (struct cmd_pctype_mapping_update_result,
17405 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17406 TOKEN_STRING_INITIALIZER
17407 (struct cmd_pctype_mapping_update_result,
17408 mapping, "mapping");
17409 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17410 TOKEN_STRING_INITIALIZER
17411 (struct cmd_pctype_mapping_update_result,
17413 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17414 TOKEN_STRING_INITIALIZER
17415 (struct cmd_pctype_mapping_update_result,
17416 pctype_list, NULL);
17417 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17418 TOKEN_NUM_INITIALIZER
17419 (struct cmd_pctype_mapping_update_result,
17420 flow_type, UINT16);
17423 cmd_pctype_mapping_update_parsed(
17424 void *parsed_result,
17425 __attribute__((unused)) struct cmdline *cl,
17426 __attribute__((unused)) void *data)
17428 struct cmd_pctype_mapping_update_result *res = parsed_result;
17429 int ret = -ENOTSUP;
17430 #ifdef RTE_LIBRTE_I40E_PMD
17431 struct rte_pmd_i40e_flow_type_mapping mapping;
17433 unsigned int nb_item;
17434 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17437 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17440 #ifdef RTE_LIBRTE_I40E_PMD
17441 nb_item = parse_item_list(res->pctype_list, "pctypes",
17442 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17443 mapping.flow_type = res->flow_type;
17444 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17445 mapping.pctype |= (1ULL << pctype_list[i]);
17446 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17456 printf("invalid pctype or flow type\n");
17459 printf("invalid port_id %d\n", res->port_id);
17462 printf("function not implemented\n");
17465 printf("programming error: (%s)\n", strerror(-ret));
17469 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17470 .f = cmd_pctype_mapping_update_parsed,
17472 .help_str = "port config <port_id> pctype mapping update"
17473 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17475 (void *)&cmd_pctype_mapping_update_port,
17476 (void *)&cmd_pctype_mapping_update_config,
17477 (void *)&cmd_pctype_mapping_update_port_id,
17478 (void *)&cmd_pctype_mapping_update_pctype,
17479 (void *)&cmd_pctype_mapping_update_mapping,
17480 (void *)&cmd_pctype_mapping_update_update,
17481 (void *)&cmd_pctype_mapping_update_pc_type,
17482 (void *)&cmd_pctype_mapping_update_flow_type,
17487 /* ptype mapping get */
17489 /* Common result structure for ptype mapping get */
17490 struct cmd_ptype_mapping_get_result {
17491 cmdline_fixed_string_t ptype;
17492 cmdline_fixed_string_t mapping;
17493 cmdline_fixed_string_t get;
17495 uint8_t valid_only;
17498 /* Common CLI fields for ptype mapping get */
17499 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17500 TOKEN_STRING_INITIALIZER
17501 (struct cmd_ptype_mapping_get_result,
17503 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17504 TOKEN_STRING_INITIALIZER
17505 (struct cmd_ptype_mapping_get_result,
17506 mapping, "mapping");
17507 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17508 TOKEN_STRING_INITIALIZER
17509 (struct cmd_ptype_mapping_get_result,
17511 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17512 TOKEN_NUM_INITIALIZER
17513 (struct cmd_ptype_mapping_get_result,
17515 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17516 TOKEN_NUM_INITIALIZER
17517 (struct cmd_ptype_mapping_get_result,
17518 valid_only, UINT8);
17521 cmd_ptype_mapping_get_parsed(
17522 void *parsed_result,
17523 __attribute__((unused)) struct cmdline *cl,
17524 __attribute__((unused)) void *data)
17526 struct cmd_ptype_mapping_get_result *res = parsed_result;
17527 int ret = -ENOTSUP;
17528 #ifdef RTE_LIBRTE_I40E_PMD
17529 int max_ptype_num = 256;
17530 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17535 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17538 #ifdef RTE_LIBRTE_I40E_PMD
17539 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17550 printf("invalid port_id %d\n", res->port_id);
17553 printf("function not implemented\n");
17556 printf("programming error: (%s)\n", strerror(-ret));
17559 #ifdef RTE_LIBRTE_I40E_PMD
17561 for (i = 0; i < count; i++)
17562 printf("%3d\t0x%08x\n",
17563 mapping[i].hw_ptype, mapping[i].sw_ptype);
17568 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17569 .f = cmd_ptype_mapping_get_parsed,
17571 .help_str = "ptype mapping get <port_id> <valid_only>",
17573 (void *)&cmd_ptype_mapping_get_ptype,
17574 (void *)&cmd_ptype_mapping_get_mapping,
17575 (void *)&cmd_ptype_mapping_get_get,
17576 (void *)&cmd_ptype_mapping_get_port_id,
17577 (void *)&cmd_ptype_mapping_get_valid_only,
17582 /* ptype mapping replace */
17584 /* Common result structure for ptype mapping replace */
17585 struct cmd_ptype_mapping_replace_result {
17586 cmdline_fixed_string_t ptype;
17587 cmdline_fixed_string_t mapping;
17588 cmdline_fixed_string_t replace;
17595 /* Common CLI fields for ptype mapping replace */
17596 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17597 TOKEN_STRING_INITIALIZER
17598 (struct cmd_ptype_mapping_replace_result,
17600 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17601 TOKEN_STRING_INITIALIZER
17602 (struct cmd_ptype_mapping_replace_result,
17603 mapping, "mapping");
17604 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17605 TOKEN_STRING_INITIALIZER
17606 (struct cmd_ptype_mapping_replace_result,
17607 replace, "replace");
17608 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17609 TOKEN_NUM_INITIALIZER
17610 (struct cmd_ptype_mapping_replace_result,
17612 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17613 TOKEN_NUM_INITIALIZER
17614 (struct cmd_ptype_mapping_replace_result,
17616 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17617 TOKEN_NUM_INITIALIZER
17618 (struct cmd_ptype_mapping_replace_result,
17620 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17621 TOKEN_NUM_INITIALIZER
17622 (struct cmd_ptype_mapping_replace_result,
17626 cmd_ptype_mapping_replace_parsed(
17627 void *parsed_result,
17628 __attribute__((unused)) struct cmdline *cl,
17629 __attribute__((unused)) void *data)
17631 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17632 int ret = -ENOTSUP;
17634 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17637 #ifdef RTE_LIBRTE_I40E_PMD
17638 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17648 printf("invalid ptype 0x%8x or 0x%8x\n",
17649 res->target, res->pkt_type);
17652 printf("invalid port_id %d\n", res->port_id);
17655 printf("function not implemented\n");
17658 printf("programming error: (%s)\n", strerror(-ret));
17662 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17663 .f = cmd_ptype_mapping_replace_parsed,
17666 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17668 (void *)&cmd_ptype_mapping_replace_ptype,
17669 (void *)&cmd_ptype_mapping_replace_mapping,
17670 (void *)&cmd_ptype_mapping_replace_replace,
17671 (void *)&cmd_ptype_mapping_replace_port_id,
17672 (void *)&cmd_ptype_mapping_replace_target,
17673 (void *)&cmd_ptype_mapping_replace_mask,
17674 (void *)&cmd_ptype_mapping_replace_pkt_type,
17679 /* ptype mapping reset */
17681 /* Common result structure for ptype mapping reset */
17682 struct cmd_ptype_mapping_reset_result {
17683 cmdline_fixed_string_t ptype;
17684 cmdline_fixed_string_t mapping;
17685 cmdline_fixed_string_t reset;
17689 /* Common CLI fields for ptype mapping reset*/
17690 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17691 TOKEN_STRING_INITIALIZER
17692 (struct cmd_ptype_mapping_reset_result,
17694 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17695 TOKEN_STRING_INITIALIZER
17696 (struct cmd_ptype_mapping_reset_result,
17697 mapping, "mapping");
17698 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17699 TOKEN_STRING_INITIALIZER
17700 (struct cmd_ptype_mapping_reset_result,
17702 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17703 TOKEN_NUM_INITIALIZER
17704 (struct cmd_ptype_mapping_reset_result,
17708 cmd_ptype_mapping_reset_parsed(
17709 void *parsed_result,
17710 __attribute__((unused)) struct cmdline *cl,
17711 __attribute__((unused)) void *data)
17713 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17714 int ret = -ENOTSUP;
17716 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17719 #ifdef RTE_LIBRTE_I40E_PMD
17720 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17727 printf("invalid port_id %d\n", res->port_id);
17730 printf("function not implemented\n");
17733 printf("programming error: (%s)\n", strerror(-ret));
17737 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17738 .f = cmd_ptype_mapping_reset_parsed,
17740 .help_str = "ptype mapping reset <port_id>",
17742 (void *)&cmd_ptype_mapping_reset_ptype,
17743 (void *)&cmd_ptype_mapping_reset_mapping,
17744 (void *)&cmd_ptype_mapping_reset_reset,
17745 (void *)&cmd_ptype_mapping_reset_port_id,
17750 /* ptype mapping update */
17752 /* Common result structure for ptype mapping update */
17753 struct cmd_ptype_mapping_update_result {
17754 cmdline_fixed_string_t ptype;
17755 cmdline_fixed_string_t mapping;
17756 cmdline_fixed_string_t reset;
17762 /* Common CLI fields for ptype mapping update*/
17763 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17764 TOKEN_STRING_INITIALIZER
17765 (struct cmd_ptype_mapping_update_result,
17767 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17768 TOKEN_STRING_INITIALIZER
17769 (struct cmd_ptype_mapping_update_result,
17770 mapping, "mapping");
17771 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17772 TOKEN_STRING_INITIALIZER
17773 (struct cmd_ptype_mapping_update_result,
17775 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17776 TOKEN_NUM_INITIALIZER
17777 (struct cmd_ptype_mapping_update_result,
17779 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17780 TOKEN_NUM_INITIALIZER
17781 (struct cmd_ptype_mapping_update_result,
17783 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17784 TOKEN_NUM_INITIALIZER
17785 (struct cmd_ptype_mapping_update_result,
17789 cmd_ptype_mapping_update_parsed(
17790 void *parsed_result,
17791 __attribute__((unused)) struct cmdline *cl,
17792 __attribute__((unused)) void *data)
17794 struct cmd_ptype_mapping_update_result *res = parsed_result;
17795 int ret = -ENOTSUP;
17796 #ifdef RTE_LIBRTE_I40E_PMD
17797 struct rte_pmd_i40e_ptype_mapping mapping;
17799 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17802 #ifdef RTE_LIBRTE_I40E_PMD
17803 mapping.hw_ptype = res->hw_ptype;
17804 mapping.sw_ptype = res->sw_ptype;
17805 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17815 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17818 printf("invalid port_id %d\n", res->port_id);
17821 printf("function not implemented\n");
17824 printf("programming error: (%s)\n", strerror(-ret));
17828 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17829 .f = cmd_ptype_mapping_update_parsed,
17831 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17833 (void *)&cmd_ptype_mapping_update_ptype,
17834 (void *)&cmd_ptype_mapping_update_mapping,
17835 (void *)&cmd_ptype_mapping_update_update,
17836 (void *)&cmd_ptype_mapping_update_port_id,
17837 (void *)&cmd_ptype_mapping_update_hw_ptype,
17838 (void *)&cmd_ptype_mapping_update_sw_ptype,
17843 /* Common result structure for file commands */
17844 struct cmd_cmdfile_result {
17845 cmdline_fixed_string_t load;
17846 cmdline_fixed_string_t filename;
17849 /* Common CLI fields for file commands */
17850 cmdline_parse_token_string_t cmd_load_cmdfile =
17851 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17852 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17853 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17856 cmd_load_from_file_parsed(
17857 void *parsed_result,
17858 __attribute__((unused)) struct cmdline *cl,
17859 __attribute__((unused)) void *data)
17861 struct cmd_cmdfile_result *res = parsed_result;
17863 cmdline_read_from_file(res->filename);
17866 cmdline_parse_inst_t cmd_load_from_file = {
17867 .f = cmd_load_from_file_parsed,
17869 .help_str = "load <filename>",
17871 (void *)&cmd_load_cmdfile,
17872 (void *)&cmd_load_cmdfile_filename,
17877 /* Get Rx offloads capabilities */
17878 struct cmd_rx_offload_get_capa_result {
17879 cmdline_fixed_string_t show;
17880 cmdline_fixed_string_t port;
17882 cmdline_fixed_string_t rx_offload;
17883 cmdline_fixed_string_t capabilities;
17886 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17887 TOKEN_STRING_INITIALIZER
17888 (struct cmd_rx_offload_get_capa_result,
17890 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17891 TOKEN_STRING_INITIALIZER
17892 (struct cmd_rx_offload_get_capa_result,
17894 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17895 TOKEN_NUM_INITIALIZER
17896 (struct cmd_rx_offload_get_capa_result,
17898 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17899 TOKEN_STRING_INITIALIZER
17900 (struct cmd_rx_offload_get_capa_result,
17901 rx_offload, "rx_offload");
17902 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17903 TOKEN_STRING_INITIALIZER
17904 (struct cmd_rx_offload_get_capa_result,
17905 capabilities, "capabilities");
17908 print_rx_offloads(uint64_t offloads)
17910 uint64_t single_offload;
17918 begin = __builtin_ctzll(offloads);
17919 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17921 single_offload = 1ULL << begin;
17922 for (bit = begin; bit < end; bit++) {
17923 if (offloads & single_offload)
17925 rte_eth_dev_rx_offload_name(single_offload));
17926 single_offload <<= 1;
17931 cmd_rx_offload_get_capa_parsed(
17932 void *parsed_result,
17933 __attribute__((unused)) struct cmdline *cl,
17934 __attribute__((unused)) void *data)
17936 struct cmd_rx_offload_get_capa_result *res = parsed_result;
17937 struct rte_eth_dev_info dev_info;
17938 portid_t port_id = res->port_id;
17939 uint64_t queue_offloads;
17940 uint64_t port_offloads;
17943 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17947 queue_offloads = dev_info.rx_queue_offload_capa;
17948 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
17950 printf("Rx Offloading Capabilities of port %d :\n", port_id);
17951 printf(" Per Queue :");
17952 print_rx_offloads(queue_offloads);
17955 printf(" Per Port :");
17956 print_rx_offloads(port_offloads);
17960 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
17961 .f = cmd_rx_offload_get_capa_parsed,
17963 .help_str = "show port <port_id> rx_offload capabilities",
17965 (void *)&cmd_rx_offload_get_capa_show,
17966 (void *)&cmd_rx_offload_get_capa_port,
17967 (void *)&cmd_rx_offload_get_capa_port_id,
17968 (void *)&cmd_rx_offload_get_capa_rx_offload,
17969 (void *)&cmd_rx_offload_get_capa_capabilities,
17974 /* Get Rx offloads configuration */
17975 struct cmd_rx_offload_get_configuration_result {
17976 cmdline_fixed_string_t show;
17977 cmdline_fixed_string_t port;
17979 cmdline_fixed_string_t rx_offload;
17980 cmdline_fixed_string_t configuration;
17983 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
17984 TOKEN_STRING_INITIALIZER
17985 (struct cmd_rx_offload_get_configuration_result,
17987 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
17988 TOKEN_STRING_INITIALIZER
17989 (struct cmd_rx_offload_get_configuration_result,
17991 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
17992 TOKEN_NUM_INITIALIZER
17993 (struct cmd_rx_offload_get_configuration_result,
17995 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
17996 TOKEN_STRING_INITIALIZER
17997 (struct cmd_rx_offload_get_configuration_result,
17998 rx_offload, "rx_offload");
17999 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18000 TOKEN_STRING_INITIALIZER
18001 (struct cmd_rx_offload_get_configuration_result,
18002 configuration, "configuration");
18005 cmd_rx_offload_get_configuration_parsed(
18006 void *parsed_result,
18007 __attribute__((unused)) struct cmdline *cl,
18008 __attribute__((unused)) void *data)
18010 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18011 struct rte_eth_dev_info dev_info;
18012 portid_t port_id = res->port_id;
18013 struct rte_port *port = &ports[port_id];
18014 uint64_t port_offloads;
18015 uint64_t queue_offloads;
18016 uint16_t nb_rx_queues;
18020 printf("Rx Offloading Configuration of port %d :\n", port_id);
18022 port_offloads = port->dev_conf.rxmode.offloads;
18024 print_rx_offloads(port_offloads);
18027 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18031 nb_rx_queues = dev_info.nb_rx_queues;
18032 for (q = 0; q < nb_rx_queues; q++) {
18033 queue_offloads = port->rx_conf[q].offloads;
18034 printf(" Queue[%2d] :", q);
18035 print_rx_offloads(queue_offloads);
18041 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18042 .f = cmd_rx_offload_get_configuration_parsed,
18044 .help_str = "show port <port_id> rx_offload configuration",
18046 (void *)&cmd_rx_offload_get_configuration_show,
18047 (void *)&cmd_rx_offload_get_configuration_port,
18048 (void *)&cmd_rx_offload_get_configuration_port_id,
18049 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18050 (void *)&cmd_rx_offload_get_configuration_configuration,
18055 /* Enable/Disable a per port offloading */
18056 struct cmd_config_per_port_rx_offload_result {
18057 cmdline_fixed_string_t port;
18058 cmdline_fixed_string_t config;
18060 cmdline_fixed_string_t rx_offload;
18061 cmdline_fixed_string_t offload;
18062 cmdline_fixed_string_t on_off;
18065 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18066 TOKEN_STRING_INITIALIZER
18067 (struct cmd_config_per_port_rx_offload_result,
18069 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18070 TOKEN_STRING_INITIALIZER
18071 (struct cmd_config_per_port_rx_offload_result,
18073 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18074 TOKEN_NUM_INITIALIZER
18075 (struct cmd_config_per_port_rx_offload_result,
18077 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18078 TOKEN_STRING_INITIALIZER
18079 (struct cmd_config_per_port_rx_offload_result,
18080 rx_offload, "rx_offload");
18081 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18082 TOKEN_STRING_INITIALIZER
18083 (struct cmd_config_per_port_rx_offload_result,
18084 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18085 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18086 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18087 "scatter#timestamp#security#keep_crc");
18088 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18089 TOKEN_STRING_INITIALIZER
18090 (struct cmd_config_per_port_rx_offload_result,
18094 search_rx_offload(const char *name)
18096 uint64_t single_offload;
18097 const char *single_name;
18101 single_offload = 1;
18102 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18103 single_name = rte_eth_dev_rx_offload_name(single_offload);
18104 if (!strcasecmp(single_name, name)) {
18108 single_offload <<= 1;
18112 return single_offload;
18118 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18119 __attribute__((unused)) struct cmdline *cl,
18120 __attribute__((unused)) void *data)
18122 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18123 portid_t port_id = res->port_id;
18124 struct rte_eth_dev_info dev_info;
18125 struct rte_port *port = &ports[port_id];
18126 uint64_t single_offload;
18127 uint16_t nb_rx_queues;
18131 if (port->port_status != RTE_PORT_STOPPED) {
18132 printf("Error: Can't config offload when Port %d "
18133 "is not stopped\n", port_id);
18137 single_offload = search_rx_offload(res->offload);
18138 if (single_offload == 0) {
18139 printf("Unknown offload name: %s\n", res->offload);
18143 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18147 nb_rx_queues = dev_info.nb_rx_queues;
18148 if (!strcmp(res->on_off, "on")) {
18149 port->dev_conf.rxmode.offloads |= single_offload;
18150 for (q = 0; q < nb_rx_queues; q++)
18151 port->rx_conf[q].offloads |= single_offload;
18153 port->dev_conf.rxmode.offloads &= ~single_offload;
18154 for (q = 0; q < nb_rx_queues; q++)
18155 port->rx_conf[q].offloads &= ~single_offload;
18158 cmd_reconfig_device_queue(port_id, 1, 1);
18161 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18162 .f = cmd_config_per_port_rx_offload_parsed,
18164 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18165 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18166 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18167 "jumbo_frame|scatter|timestamp|security|keep_crc "
18170 (void *)&cmd_config_per_port_rx_offload_result_port,
18171 (void *)&cmd_config_per_port_rx_offload_result_config,
18172 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18173 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18174 (void *)&cmd_config_per_port_rx_offload_result_offload,
18175 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18180 /* Enable/Disable a per queue offloading */
18181 struct cmd_config_per_queue_rx_offload_result {
18182 cmdline_fixed_string_t port;
18184 cmdline_fixed_string_t rxq;
18186 cmdline_fixed_string_t rx_offload;
18187 cmdline_fixed_string_t offload;
18188 cmdline_fixed_string_t on_off;
18191 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18192 TOKEN_STRING_INITIALIZER
18193 (struct cmd_config_per_queue_rx_offload_result,
18195 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18196 TOKEN_NUM_INITIALIZER
18197 (struct cmd_config_per_queue_rx_offload_result,
18199 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18200 TOKEN_STRING_INITIALIZER
18201 (struct cmd_config_per_queue_rx_offload_result,
18203 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18204 TOKEN_NUM_INITIALIZER
18205 (struct cmd_config_per_queue_rx_offload_result,
18207 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18208 TOKEN_STRING_INITIALIZER
18209 (struct cmd_config_per_queue_rx_offload_result,
18210 rx_offload, "rx_offload");
18211 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18212 TOKEN_STRING_INITIALIZER
18213 (struct cmd_config_per_queue_rx_offload_result,
18214 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18215 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18216 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18217 "scatter#timestamp#security#keep_crc");
18218 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18219 TOKEN_STRING_INITIALIZER
18220 (struct cmd_config_per_queue_rx_offload_result,
18224 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18225 __attribute__((unused)) struct cmdline *cl,
18226 __attribute__((unused)) void *data)
18228 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18229 struct rte_eth_dev_info dev_info;
18230 portid_t port_id = res->port_id;
18231 uint16_t queue_id = res->queue_id;
18232 struct rte_port *port = &ports[port_id];
18233 uint64_t single_offload;
18236 if (port->port_status != RTE_PORT_STOPPED) {
18237 printf("Error: Can't config offload when Port %d "
18238 "is not stopped\n", port_id);
18242 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18246 if (queue_id >= dev_info.nb_rx_queues) {
18247 printf("Error: input queue_id should be 0 ... "
18248 "%d\n", dev_info.nb_rx_queues - 1);
18252 single_offload = search_rx_offload(res->offload);
18253 if (single_offload == 0) {
18254 printf("Unknown offload name: %s\n", res->offload);
18258 if (!strcmp(res->on_off, "on"))
18259 port->rx_conf[queue_id].offloads |= single_offload;
18261 port->rx_conf[queue_id].offloads &= ~single_offload;
18263 cmd_reconfig_device_queue(port_id, 1, 1);
18266 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18267 .f = cmd_config_per_queue_rx_offload_parsed,
18269 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18270 "vlan_strip|ipv4_cksum|"
18271 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18272 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18273 "jumbo_frame|scatter|timestamp|security|keep_crc "
18276 (void *)&cmd_config_per_queue_rx_offload_result_port,
18277 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18278 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18279 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18280 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18281 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18282 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18287 /* Get Tx offloads capabilities */
18288 struct cmd_tx_offload_get_capa_result {
18289 cmdline_fixed_string_t show;
18290 cmdline_fixed_string_t port;
18292 cmdline_fixed_string_t tx_offload;
18293 cmdline_fixed_string_t capabilities;
18296 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18297 TOKEN_STRING_INITIALIZER
18298 (struct cmd_tx_offload_get_capa_result,
18300 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18301 TOKEN_STRING_INITIALIZER
18302 (struct cmd_tx_offload_get_capa_result,
18304 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18305 TOKEN_NUM_INITIALIZER
18306 (struct cmd_tx_offload_get_capa_result,
18308 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18309 TOKEN_STRING_INITIALIZER
18310 (struct cmd_tx_offload_get_capa_result,
18311 tx_offload, "tx_offload");
18312 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18313 TOKEN_STRING_INITIALIZER
18314 (struct cmd_tx_offload_get_capa_result,
18315 capabilities, "capabilities");
18318 print_tx_offloads(uint64_t offloads)
18320 uint64_t single_offload;
18328 begin = __builtin_ctzll(offloads);
18329 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18331 single_offload = 1ULL << begin;
18332 for (bit = begin; bit < end; bit++) {
18333 if (offloads & single_offload)
18335 rte_eth_dev_tx_offload_name(single_offload));
18336 single_offload <<= 1;
18341 cmd_tx_offload_get_capa_parsed(
18342 void *parsed_result,
18343 __attribute__((unused)) struct cmdline *cl,
18344 __attribute__((unused)) void *data)
18346 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18347 struct rte_eth_dev_info dev_info;
18348 portid_t port_id = res->port_id;
18349 uint64_t queue_offloads;
18350 uint64_t port_offloads;
18353 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18357 queue_offloads = dev_info.tx_queue_offload_capa;
18358 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18360 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18361 printf(" Per Queue :");
18362 print_tx_offloads(queue_offloads);
18365 printf(" Per Port :");
18366 print_tx_offloads(port_offloads);
18370 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18371 .f = cmd_tx_offload_get_capa_parsed,
18373 .help_str = "show port <port_id> tx_offload capabilities",
18375 (void *)&cmd_tx_offload_get_capa_show,
18376 (void *)&cmd_tx_offload_get_capa_port,
18377 (void *)&cmd_tx_offload_get_capa_port_id,
18378 (void *)&cmd_tx_offload_get_capa_tx_offload,
18379 (void *)&cmd_tx_offload_get_capa_capabilities,
18384 /* Get Tx offloads configuration */
18385 struct cmd_tx_offload_get_configuration_result {
18386 cmdline_fixed_string_t show;
18387 cmdline_fixed_string_t port;
18389 cmdline_fixed_string_t tx_offload;
18390 cmdline_fixed_string_t configuration;
18393 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18394 TOKEN_STRING_INITIALIZER
18395 (struct cmd_tx_offload_get_configuration_result,
18397 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18398 TOKEN_STRING_INITIALIZER
18399 (struct cmd_tx_offload_get_configuration_result,
18401 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18402 TOKEN_NUM_INITIALIZER
18403 (struct cmd_tx_offload_get_configuration_result,
18405 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18406 TOKEN_STRING_INITIALIZER
18407 (struct cmd_tx_offload_get_configuration_result,
18408 tx_offload, "tx_offload");
18409 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18410 TOKEN_STRING_INITIALIZER
18411 (struct cmd_tx_offload_get_configuration_result,
18412 configuration, "configuration");
18415 cmd_tx_offload_get_configuration_parsed(
18416 void *parsed_result,
18417 __attribute__((unused)) struct cmdline *cl,
18418 __attribute__((unused)) void *data)
18420 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18421 struct rte_eth_dev_info dev_info;
18422 portid_t port_id = res->port_id;
18423 struct rte_port *port = &ports[port_id];
18424 uint64_t port_offloads;
18425 uint64_t queue_offloads;
18426 uint16_t nb_tx_queues;
18430 printf("Tx Offloading Configuration of port %d :\n", port_id);
18432 port_offloads = port->dev_conf.txmode.offloads;
18434 print_tx_offloads(port_offloads);
18437 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18441 nb_tx_queues = dev_info.nb_tx_queues;
18442 for (q = 0; q < nb_tx_queues; q++) {
18443 queue_offloads = port->tx_conf[q].offloads;
18444 printf(" Queue[%2d] :", q);
18445 print_tx_offloads(queue_offloads);
18451 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18452 .f = cmd_tx_offload_get_configuration_parsed,
18454 .help_str = "show port <port_id> tx_offload configuration",
18456 (void *)&cmd_tx_offload_get_configuration_show,
18457 (void *)&cmd_tx_offload_get_configuration_port,
18458 (void *)&cmd_tx_offload_get_configuration_port_id,
18459 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18460 (void *)&cmd_tx_offload_get_configuration_configuration,
18465 /* Enable/Disable a per port offloading */
18466 struct cmd_config_per_port_tx_offload_result {
18467 cmdline_fixed_string_t port;
18468 cmdline_fixed_string_t config;
18470 cmdline_fixed_string_t tx_offload;
18471 cmdline_fixed_string_t offload;
18472 cmdline_fixed_string_t on_off;
18475 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18476 TOKEN_STRING_INITIALIZER
18477 (struct cmd_config_per_port_tx_offload_result,
18479 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18480 TOKEN_STRING_INITIALIZER
18481 (struct cmd_config_per_port_tx_offload_result,
18483 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18484 TOKEN_NUM_INITIALIZER
18485 (struct cmd_config_per_port_tx_offload_result,
18487 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18488 TOKEN_STRING_INITIALIZER
18489 (struct cmd_config_per_port_tx_offload_result,
18490 tx_offload, "tx_offload");
18491 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18492 TOKEN_STRING_INITIALIZER
18493 (struct cmd_config_per_port_tx_offload_result,
18494 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18495 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18496 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18497 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18498 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18500 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18501 TOKEN_STRING_INITIALIZER
18502 (struct cmd_config_per_port_tx_offload_result,
18506 search_tx_offload(const char *name)
18508 uint64_t single_offload;
18509 const char *single_name;
18513 single_offload = 1;
18514 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18515 single_name = rte_eth_dev_tx_offload_name(single_offload);
18516 if (single_name == NULL)
18518 if (!strcasecmp(single_name, name)) {
18521 } else if (!strcasecmp(single_name, "UNKNOWN"))
18523 single_offload <<= 1;
18527 return single_offload;
18533 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18534 __attribute__((unused)) struct cmdline *cl,
18535 __attribute__((unused)) void *data)
18537 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18538 portid_t port_id = res->port_id;
18539 struct rte_eth_dev_info dev_info;
18540 struct rte_port *port = &ports[port_id];
18541 uint64_t single_offload;
18542 uint16_t nb_tx_queues;
18546 if (port->port_status != RTE_PORT_STOPPED) {
18547 printf("Error: Can't config offload when Port %d "
18548 "is not stopped\n", port_id);
18552 single_offload = search_tx_offload(res->offload);
18553 if (single_offload == 0) {
18554 printf("Unknown offload name: %s\n", res->offload);
18558 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18562 nb_tx_queues = dev_info.nb_tx_queues;
18563 if (!strcmp(res->on_off, "on")) {
18564 port->dev_conf.txmode.offloads |= single_offload;
18565 for (q = 0; q < nb_tx_queues; q++)
18566 port->tx_conf[q].offloads |= single_offload;
18568 port->dev_conf.txmode.offloads &= ~single_offload;
18569 for (q = 0; q < nb_tx_queues; q++)
18570 port->tx_conf[q].offloads &= ~single_offload;
18573 cmd_reconfig_device_queue(port_id, 1, 1);
18576 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18577 .f = cmd_config_per_port_tx_offload_parsed,
18579 .help_str = "port config <port_id> tx_offload "
18580 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18581 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18582 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18583 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18584 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18585 "match_metadata on|off",
18587 (void *)&cmd_config_per_port_tx_offload_result_port,
18588 (void *)&cmd_config_per_port_tx_offload_result_config,
18589 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18590 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18591 (void *)&cmd_config_per_port_tx_offload_result_offload,
18592 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18597 /* Enable/Disable a per queue offloading */
18598 struct cmd_config_per_queue_tx_offload_result {
18599 cmdline_fixed_string_t port;
18601 cmdline_fixed_string_t txq;
18603 cmdline_fixed_string_t tx_offload;
18604 cmdline_fixed_string_t offload;
18605 cmdline_fixed_string_t on_off;
18608 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18609 TOKEN_STRING_INITIALIZER
18610 (struct cmd_config_per_queue_tx_offload_result,
18612 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18613 TOKEN_NUM_INITIALIZER
18614 (struct cmd_config_per_queue_tx_offload_result,
18616 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18617 TOKEN_STRING_INITIALIZER
18618 (struct cmd_config_per_queue_tx_offload_result,
18620 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18621 TOKEN_NUM_INITIALIZER
18622 (struct cmd_config_per_queue_tx_offload_result,
18624 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18625 TOKEN_STRING_INITIALIZER
18626 (struct cmd_config_per_queue_tx_offload_result,
18627 tx_offload, "tx_offload");
18628 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18629 TOKEN_STRING_INITIALIZER
18630 (struct cmd_config_per_queue_tx_offload_result,
18631 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18632 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18633 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18634 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18635 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18636 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18637 TOKEN_STRING_INITIALIZER
18638 (struct cmd_config_per_queue_tx_offload_result,
18642 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18643 __attribute__((unused)) struct cmdline *cl,
18644 __attribute__((unused)) void *data)
18646 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18647 struct rte_eth_dev_info dev_info;
18648 portid_t port_id = res->port_id;
18649 uint16_t queue_id = res->queue_id;
18650 struct rte_port *port = &ports[port_id];
18651 uint64_t single_offload;
18654 if (port->port_status != RTE_PORT_STOPPED) {
18655 printf("Error: Can't config offload when Port %d "
18656 "is not stopped\n", port_id);
18660 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18664 if (queue_id >= dev_info.nb_tx_queues) {
18665 printf("Error: input queue_id should be 0 ... "
18666 "%d\n", dev_info.nb_tx_queues - 1);
18670 single_offload = search_tx_offload(res->offload);
18671 if (single_offload == 0) {
18672 printf("Unknown offload name: %s\n", res->offload);
18676 if (!strcmp(res->on_off, "on"))
18677 port->tx_conf[queue_id].offloads |= single_offload;
18679 port->tx_conf[queue_id].offloads &= ~single_offload;
18681 cmd_reconfig_device_queue(port_id, 1, 1);
18684 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18685 .f = cmd_config_per_queue_tx_offload_parsed,
18687 .help_str = "port <port_id> txq <queue_id> tx_offload "
18688 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18689 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18690 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18691 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18692 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18695 (void *)&cmd_config_per_queue_tx_offload_result_port,
18696 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18697 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18698 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18699 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18700 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18701 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18706 /* *** configure tx_metadata for specific port *** */
18707 struct cmd_config_tx_metadata_specific_result {
18708 cmdline_fixed_string_t port;
18709 cmdline_fixed_string_t keyword;
18711 cmdline_fixed_string_t item;
18716 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18717 __attribute__((unused)) struct cmdline *cl,
18718 __attribute__((unused)) void *data)
18720 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18722 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18724 ports[res->port_id].tx_metadata = res->value;
18725 /* Add/remove callback to insert valid metadata in every Tx packet. */
18726 if (ports[res->port_id].tx_metadata)
18727 add_tx_md_callback(res->port_id);
18729 remove_tx_md_callback(res->port_id);
18730 rte_flow_dynf_metadata_register();
18733 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18734 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18736 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18737 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18738 keyword, "config");
18739 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18740 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18742 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18743 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18744 item, "tx_metadata");
18745 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18746 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18749 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18750 .f = cmd_config_tx_metadata_specific_parsed,
18752 .help_str = "port config <port_id> tx_metadata <value>",
18754 (void *)&cmd_config_tx_metadata_specific_port,
18755 (void *)&cmd_config_tx_metadata_specific_keyword,
18756 (void *)&cmd_config_tx_metadata_specific_id,
18757 (void *)&cmd_config_tx_metadata_specific_item,
18758 (void *)&cmd_config_tx_metadata_specific_value,
18763 /* *** display tx_metadata per port configuration *** */
18764 struct cmd_show_tx_metadata_result {
18765 cmdline_fixed_string_t cmd_show;
18766 cmdline_fixed_string_t cmd_port;
18767 cmdline_fixed_string_t cmd_keyword;
18772 cmd_show_tx_metadata_parsed(void *parsed_result,
18773 __attribute__((unused)) struct cmdline *cl,
18774 __attribute__((unused)) void *data)
18776 struct cmd_show_tx_metadata_result *res = parsed_result;
18778 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18779 printf("invalid port id %u\n", res->cmd_pid);
18782 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18783 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18784 rte_be_to_cpu_32(ports[res->cmd_pid].tx_metadata));
18788 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18789 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18791 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18792 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18794 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18795 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18797 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18798 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18799 cmd_keyword, "tx_metadata");
18801 cmdline_parse_inst_t cmd_show_tx_metadata = {
18802 .f = cmd_show_tx_metadata_parsed,
18804 .help_str = "show port <port_id> tx_metadata",
18806 (void *)&cmd_show_tx_metadata_show,
18807 (void *)&cmd_show_tx_metadata_port,
18808 (void *)&cmd_show_tx_metadata_pid,
18809 (void *)&cmd_show_tx_metadata_keyword,
18814 /* show port supported ptypes */
18816 /* Common result structure for show port ptypes */
18817 struct cmd_show_port_supported_ptypes_result {
18818 cmdline_fixed_string_t show;
18819 cmdline_fixed_string_t port;
18821 cmdline_fixed_string_t ptypes;
18824 /* Common CLI fields for show port ptypes */
18825 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
18826 TOKEN_STRING_INITIALIZER
18827 (struct cmd_show_port_supported_ptypes_result,
18829 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
18830 TOKEN_STRING_INITIALIZER
18831 (struct cmd_show_port_supported_ptypes_result,
18833 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
18834 TOKEN_NUM_INITIALIZER
18835 (struct cmd_show_port_supported_ptypes_result,
18837 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
18838 TOKEN_STRING_INITIALIZER
18839 (struct cmd_show_port_supported_ptypes_result,
18843 cmd_show_port_supported_ptypes_parsed(
18844 void *parsed_result,
18845 __attribute__((unused)) struct cmdline *cl,
18846 __attribute__((unused)) void *data)
18848 #define RSVD_PTYPE_MASK 0xf0000000
18849 #define MAX_PTYPES_PER_LAYER 16
18850 #define LTYPE_NAMESIZE 32
18851 #define PTYPE_NAMESIZE 256
18852 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
18853 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
18854 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
18855 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
18856 uint16_t port_id = res->port_id;
18859 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
18863 while (ptype_mask != RSVD_PTYPE_MASK) {
18865 switch (ptype_mask) {
18866 case RTE_PTYPE_L2_MASK:
18867 strlcpy(ltype, "L2", sizeof(ltype));
18869 case RTE_PTYPE_L3_MASK:
18870 strlcpy(ltype, "L3", sizeof(ltype));
18872 case RTE_PTYPE_L4_MASK:
18873 strlcpy(ltype, "L4", sizeof(ltype));
18875 case RTE_PTYPE_TUNNEL_MASK:
18876 strlcpy(ltype, "Tunnel", sizeof(ltype));
18878 case RTE_PTYPE_INNER_L2_MASK:
18879 strlcpy(ltype, "Inner L2", sizeof(ltype));
18881 case RTE_PTYPE_INNER_L3_MASK:
18882 strlcpy(ltype, "Inner L3", sizeof(ltype));
18884 case RTE_PTYPE_INNER_L4_MASK:
18885 strlcpy(ltype, "Inner L4", sizeof(ltype));
18891 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
18892 ptype_mask, ptypes,
18893 MAX_PTYPES_PER_LAYER);
18896 printf("Supported %s ptypes:\n", ltype);
18898 printf("%s ptypes unsupported\n", ltype);
18900 for (i = 0; i < ret; ++i) {
18901 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
18902 printf("%s\n", buf);
18909 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
18910 .f = cmd_show_port_supported_ptypes_parsed,
18912 .help_str = "show port <port_id> ptypes",
18914 (void *)&cmd_show_port_supported_ptypes_show,
18915 (void *)&cmd_show_port_supported_ptypes_port,
18916 (void *)&cmd_show_port_supported_ptypes_port_id,
18917 (void *)&cmd_show_port_supported_ptypes_ptypes,
18922 /* *** display rx/tx descriptor status *** */
18923 struct cmd_show_rx_tx_desc_status_result {
18924 cmdline_fixed_string_t cmd_show;
18925 cmdline_fixed_string_t cmd_port;
18926 cmdline_fixed_string_t cmd_keyword;
18927 cmdline_fixed_string_t cmd_desc;
18928 cmdline_fixed_string_t cmd_status;
18935 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
18936 __attribute__((unused)) struct cmdline *cl,
18937 __attribute__((unused)) void *data)
18939 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
18942 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18943 printf("invalid port id %u\n", res->cmd_pid);
18947 if (!strcmp(res->cmd_keyword, "rxq")) {
18948 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
18951 printf("Invalid queueid = %d\n", res->cmd_qid);
18954 if (rc == RTE_ETH_RX_DESC_AVAIL)
18955 printf("Desc status = AVAILABLE\n");
18956 else if (rc == RTE_ETH_RX_DESC_DONE)
18957 printf("Desc status = DONE\n");
18959 printf("Desc status = UNAVAILABLE\n");
18960 } else if (!strcmp(res->cmd_keyword, "txq")) {
18961 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
18964 printf("Invalid queueid = %d\n", res->cmd_qid);
18967 if (rc == RTE_ETH_TX_DESC_FULL)
18968 printf("Desc status = FULL\n");
18969 else if (rc == RTE_ETH_TX_DESC_DONE)
18970 printf("Desc status = DONE\n");
18972 printf("Desc status = UNAVAILABLE\n");
18976 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
18977 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18979 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
18980 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18982 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
18983 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18985 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
18986 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18987 cmd_keyword, "rxq#txq");
18988 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
18989 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18991 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
18992 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18994 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
18995 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18997 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
18998 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18999 cmd_status, "status");
19000 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19001 .f = cmd_show_rx_tx_desc_status_parsed,
19003 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19006 (void *)&cmd_show_rx_tx_desc_status_show,
19007 (void *)&cmd_show_rx_tx_desc_status_port,
19008 (void *)&cmd_show_rx_tx_desc_status_pid,
19009 (void *)&cmd_show_rx_tx_desc_status_keyword,
19010 (void *)&cmd_show_rx_tx_desc_status_qid,
19011 (void *)&cmd_show_rx_tx_desc_status_desc,
19012 (void *)&cmd_show_rx_tx_desc_status_did,
19013 (void *)&cmd_show_rx_tx_desc_status_status,
19018 /* ******************************************************************************** */
19020 /* list of instructions */
19021 cmdline_parse_ctx_t main_ctx[] = {
19022 (cmdline_parse_inst_t *)&cmd_help_brief,
19023 (cmdline_parse_inst_t *)&cmd_help_long,
19024 (cmdline_parse_inst_t *)&cmd_quit,
19025 (cmdline_parse_inst_t *)&cmd_load_from_file,
19026 (cmdline_parse_inst_t *)&cmd_showport,
19027 (cmdline_parse_inst_t *)&cmd_showqueue,
19028 (cmdline_parse_inst_t *)&cmd_showportall,
19029 (cmdline_parse_inst_t *)&cmd_showdevice,
19030 (cmdline_parse_inst_t *)&cmd_showcfg,
19031 (cmdline_parse_inst_t *)&cmd_showfwdall,
19032 (cmdline_parse_inst_t *)&cmd_start,
19033 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19034 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19035 (cmdline_parse_inst_t *)&cmd_set_link_up,
19036 (cmdline_parse_inst_t *)&cmd_set_link_down,
19037 (cmdline_parse_inst_t *)&cmd_reset,
19038 (cmdline_parse_inst_t *)&cmd_set_numbers,
19039 (cmdline_parse_inst_t *)&cmd_set_log,
19040 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19041 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19042 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19043 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19044 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19045 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19046 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19047 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19048 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19049 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19050 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19051 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19052 (cmdline_parse_inst_t *)&cmd_set_link_check,
19053 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19054 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19055 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19056 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19057 #ifdef RTE_LIBRTE_PMD_BOND
19058 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19059 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19060 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19061 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19062 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19063 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19064 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19065 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19066 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19067 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19068 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19070 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19071 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19072 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19073 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19074 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19075 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19076 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19077 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19078 (cmdline_parse_inst_t *)&cmd_csum_set,
19079 (cmdline_parse_inst_t *)&cmd_csum_show,
19080 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19081 (cmdline_parse_inst_t *)&cmd_tso_set,
19082 (cmdline_parse_inst_t *)&cmd_tso_show,
19083 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19084 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19085 (cmdline_parse_inst_t *)&cmd_gro_enable,
19086 (cmdline_parse_inst_t *)&cmd_gro_flush,
19087 (cmdline_parse_inst_t *)&cmd_gro_show,
19088 (cmdline_parse_inst_t *)&cmd_gso_enable,
19089 (cmdline_parse_inst_t *)&cmd_gso_size,
19090 (cmdline_parse_inst_t *)&cmd_gso_show,
19091 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19092 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19093 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19094 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19095 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19096 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19097 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19098 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19099 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19100 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19101 (cmdline_parse_inst_t *)&cmd_config_dcb,
19102 (cmdline_parse_inst_t *)&cmd_read_reg,
19103 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19104 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19105 (cmdline_parse_inst_t *)&cmd_write_reg,
19106 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19107 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19108 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19109 (cmdline_parse_inst_t *)&cmd_stop,
19110 (cmdline_parse_inst_t *)&cmd_mac_addr,
19111 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19112 (cmdline_parse_inst_t *)&cmd_set_qmap,
19113 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19114 (cmdline_parse_inst_t *)&cmd_operate_port,
19115 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19116 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19117 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19118 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19119 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19120 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19121 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19122 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19123 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19124 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19125 (cmdline_parse_inst_t *)&cmd_config_mtu,
19126 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19127 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19128 (cmdline_parse_inst_t *)&cmd_config_rss,
19129 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19130 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19131 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19132 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19133 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19134 (cmdline_parse_inst_t *)&cmd_showport_reta,
19135 (cmdline_parse_inst_t *)&cmd_config_burst,
19136 (cmdline_parse_inst_t *)&cmd_config_thresh,
19137 (cmdline_parse_inst_t *)&cmd_config_threshold,
19138 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19139 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19140 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19141 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19142 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19143 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19144 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19145 (cmdline_parse_inst_t *)&cmd_global_config,
19146 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19147 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19148 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19149 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19150 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19151 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19152 (cmdline_parse_inst_t *)&cmd_dump,
19153 (cmdline_parse_inst_t *)&cmd_dump_one,
19154 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
19155 (cmdline_parse_inst_t *)&cmd_syn_filter,
19156 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19157 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19158 (cmdline_parse_inst_t *)&cmd_flex_filter,
19159 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19160 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19161 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19162 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19163 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19164 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19165 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19166 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19167 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19168 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19169 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19170 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19171 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19172 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19173 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19174 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19175 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19176 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19177 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19178 (cmdline_parse_inst_t *)&cmd_flow,
19179 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19180 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19181 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19182 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19183 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19184 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19185 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19186 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19187 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19188 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19189 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19190 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19191 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19192 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19193 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19194 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19195 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19196 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19197 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19198 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19199 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19200 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19201 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19202 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19203 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19204 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19205 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19206 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19207 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19208 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19209 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19210 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19211 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19212 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19213 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19214 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19215 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19216 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19217 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19218 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19219 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19220 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19221 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19222 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19223 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19224 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19225 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19226 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19227 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19228 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
19229 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
19231 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19232 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19233 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19234 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19235 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19236 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19237 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19238 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19239 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19240 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19241 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19242 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19243 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19244 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19245 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19246 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19247 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19248 (cmdline_parse_inst_t *)&cmd_ddp_add,
19249 (cmdline_parse_inst_t *)&cmd_ddp_del,
19250 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19251 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19252 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19253 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19254 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19255 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19256 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19257 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19258 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19259 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19260 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19262 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19263 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19264 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19265 (cmdline_parse_inst_t *)&cmd_queue_region,
19266 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19267 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19268 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19269 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19270 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19271 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19272 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19273 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19274 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19275 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19276 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19277 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19278 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19279 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19280 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19281 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19282 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19283 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19284 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19285 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19286 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19287 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19288 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19289 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19290 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19291 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19292 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19293 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19294 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19295 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19296 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19297 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19298 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19299 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19300 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19301 #ifdef RTE_LIBRTE_BPF
19302 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19303 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19305 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19306 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19307 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
19308 (cmdline_parse_inst_t *)&cmd_set_raw,
19309 (cmdline_parse_inst_t *)&cmd_show_set_raw,
19310 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19314 /* read cmdline commands from file */
19316 cmdline_read_from_file(const char *filename)
19318 struct cmdline *cl;
19320 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19322 printf("Failed to create file based cmdline context: %s\n",
19327 cmdline_interact(cl);
19332 printf("Read CLI commands from %s\n", filename);
19335 /* prompt function, called from main on MASTER lcore */
19339 /* initialize non-constant commands */
19340 cmd_set_fwd_mode_init();
19341 cmd_set_fwd_retry_mode_init();
19343 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19344 if (testpmd_cl == NULL)
19346 cmdline_interact(testpmd_cl);
19347 cmdline_stdin_exit(testpmd_cl);
19353 if (testpmd_cl != NULL)
19354 cmdline_quit(testpmd_cl);
19358 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19360 if (id == (portid_t)RTE_PORT_ALL) {
19363 RTE_ETH_FOREACH_DEV(pid) {
19364 /* check if need_reconfig has been set to 1 */
19365 if (ports[pid].need_reconfig == 0)
19366 ports[pid].need_reconfig = dev;
19367 /* check if need_reconfig_queues has been set to 1 */
19368 if (ports[pid].need_reconfig_queues == 0)
19369 ports[pid].need_reconfig_queues = queue;
19371 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19372 /* check if need_reconfig has been set to 1 */
19373 if (ports[id].need_reconfig == 0)
19374 ports[id].need_reconfig = dev;
19375 /* check if need_reconfig_queues has been set to 1 */
19376 if (ports[id].need_reconfig_queues == 0)
19377 ports[id].need_reconfig_queues = queue;