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) ptype_mask (ptype_mask)\n"
675 " set packet types classification for a specific port\n\n"
677 "set port (port_id) queue-region region_id (value) "
678 "queue_start_index (value) queue_num (value)\n"
679 " Set a queue region on a port\n\n"
681 "set port (port_id) queue-region region_id (value) "
683 " Set a flowtype region index on a port\n\n"
685 "set port (port_id) queue-region UP (value) region_id (value)\n"
686 " Set the mapping of User Priority to "
687 "queue region on a port\n\n"
689 "set port (port_id) queue-region flush (on|off)\n"
690 " flush all queue region related configuration\n\n"
692 "show port meter cap (port_id)\n"
693 " Show port meter capability information\n\n"
695 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
696 " meter profile add - srtcm rfc 2697\n\n"
698 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
699 " meter profile add - trtcm rfc 2698\n\n"
701 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
702 " meter profile add - trtcm rfc 4115\n\n"
704 "del port meter profile (port_id) (profile_id)\n"
705 " meter profile delete\n\n"
707 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
708 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
709 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
710 "(dscp_tbl_entry63)]\n"
713 "enable port meter (port_id) (mtr_id)\n"
716 "disable port meter (port_id) (mtr_id)\n"
719 "del port meter (port_id) (mtr_id)\n"
722 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
723 " meter update meter profile\n\n"
725 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
726 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
727 " update meter dscp table entries\n\n"
729 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
730 "(action0) [(action1) (action2)]\n"
731 " meter update policer action\n\n"
733 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
734 " meter update stats\n\n"
736 "show port (port_id) queue-region\n"
737 " show all queue region related configuration info\n\n"
739 , list_pkt_forwarding_modes()
743 if (show_all || !strcmp(res->section, "ports")) {
749 "----------------\n\n"
751 "port start (port_id|all)\n"
752 " Start all ports or port_id.\n\n"
754 "port stop (port_id|all)\n"
755 " Stop all ports or port_id.\n\n"
757 "port close (port_id|all)\n"
758 " Close all ports or port_id.\n\n"
760 "port reset (port_id|all)\n"
761 " Reset all ports or port_id.\n\n"
763 "port attach (ident)\n"
764 " Attach physical or virtual dev by pci address or virtual device name\n\n"
766 "port detach (port_id)\n"
767 " Detach physical or virtual dev by port_id\n\n"
769 "port config (port_id|all)"
770 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
771 " duplex (half|full|auto)\n"
772 " Set speed and duplex for all ports or port_id\n\n"
774 "port config (port_id|all) loopback (mode)\n"
775 " Set loopback mode for all ports or port_id\n\n"
777 "port config all (rxq|txq|rxd|txd) (value)\n"
778 " Set number for rxq/txq/rxd/txd.\n\n"
780 "port config all max-pkt-len (value)\n"
781 " Set the max packet length.\n\n"
783 "port config all drop-en (on|off)\n"
784 " Enable or disable packet drop on all RX queues of all ports when no "
785 "receive buffers available.\n\n"
787 "port config all rss (all|default|ip|tcp|udp|sctp|"
788 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n"
789 " Set the RSS mode.\n\n"
791 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
792 " Set the RSS redirection table.\n\n"
794 "port config (port_id) dcb vt (on|off) (traffic_class)"
796 " Set the DCB mode.\n\n"
798 "port config all burst (value)\n"
799 " Set the number of packets per burst.\n\n"
801 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
803 " Set the ring prefetch/host/writeback threshold"
804 " for tx/rx queue.\n\n"
806 "port config all (txfreet|txrst|rxfreet) (value)\n"
807 " Set free threshold for rx/tx, or set"
808 " tx rs bit threshold.\n\n"
809 "port config mtu X value\n"
810 " Set the MTU of port X to a given value\n\n"
812 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
813 " Set a rx/tx queue's ring size configuration, the new"
814 " value will take effect after command that (re-)start the port"
815 " or command that setup the specific queue\n\n"
817 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
818 " Start/stop a rx/tx queue of port X. Only take effect"
819 " when port X is started\n\n"
821 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
822 " Switch on/off a deferred start of port X rx/tx queue. Only"
823 " take effect when port X is stopped.\n\n"
825 "port (port_id) (rxq|txq) (queue_id) setup\n"
826 " Setup a rx/tx queue of port X.\n\n"
828 "port config (port_id|all) l2-tunnel E-tag ether-type"
830 " Set the value of E-tag ether-type.\n\n"
832 "port config (port_id|all) l2-tunnel E-tag"
833 " (enable|disable)\n"
834 " Enable/disable the E-tag support.\n\n"
836 "port config (port_id) pctype mapping reset\n"
837 " Reset flow type to pctype mapping on a port\n\n"
839 "port config (port_id) pctype mapping update"
840 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
841 " Update a flow type to pctype mapping item on a port\n\n"
843 "port config (port_id) pctype (pctype_id) hash_inset|"
844 "fdir_inset|fdir_flx_inset get|set|clear field\n"
846 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
848 "port config (port_id) pctype (pctype_id) hash_inset|"
849 "fdir_inset|fdir_flx_inset clear all"
850 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
852 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
853 " Add/remove UDP tunnel port for tunneling offload\n\n"
855 "port config <port_id> rx_offload vlan_strip|"
856 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
857 "outer_ipv4_cksum|macsec_strip|header_split|"
858 "vlan_filter|vlan_extend|jumbo_frame|"
859 "scatter|timestamp|security|keep_crc on|off\n"
860 " Enable or disable a per port Rx offloading"
861 " on all Rx queues of a port\n\n"
863 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
864 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
865 "outer_ipv4_cksum|macsec_strip|header_split|"
866 "vlan_filter|vlan_extend|jumbo_frame|"
867 "scatter|timestamp|security|keep_crc on|off\n"
868 " Enable or disable a per queue Rx offloading"
869 " only on a specific Rx queue\n\n"
871 "port config (port_id) tx_offload vlan_insert|"
872 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
873 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
874 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
875 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
876 "security|match_metadata on|off\n"
877 " Enable or disable a per port Tx offloading"
878 " on all Tx queues of a port\n\n"
880 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
881 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
882 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
883 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
884 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
886 " Enable or disable a per queue Tx offloading"
887 " only on a specific Tx queue\n\n"
889 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
890 " Load an eBPF program as a callback"
891 " for particular RX/TX queue\n\n"
893 "bpf-unload rx|tx (port) (queue)\n"
894 " Unload previously loaded eBPF program"
895 " for particular RX/TX queue\n\n"
897 "port config (port_id) tx_metadata (value)\n"
898 " Set Tx metadata value per port. Testpmd will add this value"
899 " to any Tx packet sent from this port\n\n"
903 if (show_all || !strcmp(res->section, "registers")) {
911 "read reg (port_id) (address)\n"
912 " Display value of a port register.\n\n"
914 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
915 " Display a port register bit field.\n\n"
917 "read regbit (port_id) (address) (bit_x)\n"
918 " Display a single port register bit.\n\n"
920 "write reg (port_id) (address) (value)\n"
921 " Set value of a port register.\n\n"
923 "write regfield (port_id) (address) (bit_x) (bit_y)"
925 " Set bit field of a port register.\n\n"
927 "write regbit (port_id) (address) (bit_x) (value)\n"
928 " Set single bit value of a port register.\n\n"
931 if (show_all || !strcmp(res->section, "filters")) {
939 "ethertype_filter (port_id) (add|del)"
940 " (mac_addr|mac_ignr) (mac_address) ethertype"
941 " (ether_type) (drop|fwd) queue (queue_id)\n"
942 " Add/Del an ethertype filter.\n\n"
944 "2tuple_filter (port_id) (add|del)"
945 " dst_port (dst_port_value) protocol (protocol_value)"
946 " mask (mask_value) tcp_flags (tcp_flags_value)"
947 " priority (prio_value) queue (queue_id)\n"
948 " Add/Del a 2tuple filter.\n\n"
950 "5tuple_filter (port_id) (add|del)"
951 " dst_ip (dst_address) src_ip (src_address)"
952 " dst_port (dst_port_value) src_port (src_port_value)"
953 " protocol (protocol_value)"
954 " mask (mask_value) tcp_flags (tcp_flags_value)"
955 " priority (prio_value) queue (queue_id)\n"
956 " Add/Del a 5tuple filter.\n\n"
958 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
959 " Add/Del syn filter.\n\n"
961 "flex_filter (port_id) (add|del) len (len_value)"
962 " bytes (bytes_value) mask (mask_value)"
963 " priority (prio_value) queue (queue_id)\n"
964 " Add/Del a flex filter.\n\n"
966 "flow_director_filter (port_id) mode IP (add|del|update)"
967 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
968 " src (src_ip_address) dst (dst_ip_address)"
969 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
970 " vlan (vlan_value) flexbytes (flexbytes_value)"
971 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
972 " fd_id (fd_id_value)\n"
973 " Add/Del an IP type flow director filter.\n\n"
975 "flow_director_filter (port_id) mode IP (add|del|update)"
976 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
977 " src (src_ip_address) (src_port)"
978 " dst (dst_ip_address) (dst_port)"
979 " tos (tos_value) ttl (ttl_value)"
980 " vlan (vlan_value) flexbytes (flexbytes_value)"
981 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
982 " fd_id (fd_id_value)\n"
983 " Add/Del an UDP/TCP type flow director filter.\n\n"
985 "flow_director_filter (port_id) mode IP (add|del|update)"
986 " flow (ipv4-sctp|ipv6-sctp)"
987 " src (src_ip_address) (src_port)"
988 " dst (dst_ip_address) (dst_port)"
989 " tag (verification_tag) "
990 " tos (tos_value) ttl (ttl_value)"
992 " flexbytes (flexbytes_value) (drop|fwd)"
993 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
994 " Add/Del a SCTP type flow director filter.\n\n"
996 "flow_director_filter (port_id) mode IP (add|del|update)"
997 " flow l2_payload ether (ethertype)"
998 " flexbytes (flexbytes_value) (drop|fwd)"
999 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1000 " Add/Del a l2 payload type flow director filter.\n\n"
1002 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1003 " mac (mac_address) vlan (vlan_value)"
1004 " flexbytes (flexbytes_value) (drop|fwd)"
1005 " queue (queue_id) fd_id (fd_id_value)\n"
1006 " Add/Del a MAC-VLAN flow director filter.\n\n"
1008 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1009 " mac (mac_address) vlan (vlan_value)"
1010 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1011 " flexbytes (flexbytes_value) (drop|fwd)"
1012 " queue (queue_id) fd_id (fd_id_value)\n"
1013 " Add/Del a Tunnel flow director filter.\n\n"
1015 "flow_director_filter (port_id) mode raw (add|del|update)"
1016 " flow (flow_id) (drop|fwd) queue (queue_id)"
1017 " fd_id (fd_id_value) packet (packet file name)\n"
1018 " Add/Del a raw type flow director filter.\n\n"
1020 "flush_flow_director (port_id)\n"
1021 " Flush all flow director entries of a device.\n\n"
1023 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1024 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1025 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1026 " Set flow director IP mask.\n\n"
1028 "flow_director_mask (port_id) mode MAC-VLAN"
1029 " vlan (vlan_value)\n"
1030 " Set flow director MAC-VLAN mask.\n\n"
1032 "flow_director_mask (port_id) mode Tunnel"
1033 " vlan (vlan_value) mac (mac_value)"
1034 " tunnel-type (tunnel_type_value)"
1035 " tunnel-id (tunnel_id_value)\n"
1036 " Set flow director Tunnel mask.\n\n"
1038 "flow_director_flex_mask (port_id)"
1039 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1040 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1042 " Configure mask of flex payload.\n\n"
1044 "flow_director_flex_payload (port_id)"
1045 " (raw|l2|l3|l4) (config)\n"
1046 " Configure flex payload selection.\n\n"
1048 "get_sym_hash_ena_per_port (port_id)\n"
1049 " get symmetric hash enable configuration per port.\n\n"
1051 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1052 " set symmetric hash enable configuration per port"
1053 " to enable or disable.\n\n"
1055 "get_hash_global_config (port_id)\n"
1056 " Get the global configurations of hash filters.\n\n"
1058 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1059 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1060 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1061 " (enable|disable)\n"
1062 " Set the global configurations of hash filters.\n\n"
1064 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1065 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1066 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1067 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1068 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1069 "ipv6-next-header|udp-src-port|udp-dst-port|"
1070 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1071 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1072 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1073 "fld-8th|none) (select|add)\n"
1074 " Set the input set for hash.\n\n"
1076 "set_fdir_input_set (port_id) "
1077 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1078 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1079 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1080 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1081 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1082 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1083 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1085 " Set the input set for FDir.\n\n"
1087 "flow validate {port_id}"
1088 " [group {group_id}] [priority {level}]"
1089 " [ingress] [egress]"
1090 " pattern {item} [/ {item} [...]] / end"
1091 " actions {action} [/ {action} [...]] / end\n"
1092 " Check whether a flow rule can be created.\n\n"
1094 "flow create {port_id}"
1095 " [group {group_id}] [priority {level}]"
1096 " [ingress] [egress]"
1097 " pattern {item} [/ {item} [...]] / end"
1098 " actions {action} [/ {action} [...]] / end\n"
1099 " Create a flow rule.\n\n"
1101 "flow destroy {port_id} rule {rule_id} [...]\n"
1102 " Destroy specific flow rules.\n\n"
1104 "flow flush {port_id}\n"
1105 " Destroy all flow rules.\n\n"
1107 "flow query {port_id} {rule_id} {action}\n"
1108 " Query an existing flow rule.\n\n"
1110 "flow list {port_id} [group {group_id}] [...]\n"
1111 " List existing flow rules sorted by priority,"
1112 " filtered by group identifiers.\n\n"
1114 "flow isolate {port_id} {boolean}\n"
1115 " Restrict ingress traffic to the defined"
1118 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1119 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1120 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1121 " Configure the VXLAN encapsulation for flows.\n\n"
1123 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1124 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1125 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1126 " eth-dst (eth-dst)\n"
1127 " Configure the VXLAN encapsulation for flows.\n\n"
1129 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1130 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1131 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1132 " eth-dst (eth-dst)\n"
1133 " Configure the VXLAN encapsulation for flows.\n\n"
1135 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1136 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1138 " Configure the NVGRE encapsulation for flows.\n\n"
1140 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1141 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1142 " eth-src (eth-src) eth-dst (eth-dst)\n"
1143 " Configure the NVGRE encapsulation for flows.\n\n"
1145 "set raw_encap {flow items}\n"
1146 " Configure the encapsulation with raw data.\n\n"
1148 "set raw_decap {flow items}\n"
1149 " Configure the decapsulation with raw data.\n\n"
1154 if (show_all || !strcmp(res->section, "traffic_management")) {
1158 "Traffic Management:\n"
1160 "show port tm cap (port_id)\n"
1161 " Display the port TM capability.\n\n"
1163 "show port tm level cap (port_id) (level_id)\n"
1164 " Display the port TM hierarchical level capability.\n\n"
1166 "show port tm node cap (port_id) (node_id)\n"
1167 " Display the port TM node capability.\n\n"
1169 "show port tm node type (port_id) (node_id)\n"
1170 " Display the port TM node type.\n\n"
1172 "show port tm node stats (port_id) (node_id) (clear)\n"
1173 " Display the port TM node stats.\n\n"
1175 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
1176 "set port tm hierarchy default (port_id)\n"
1177 " Set default traffic Management hierarchy on a port\n\n"
1180 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1181 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1182 " (packet_length_adjust)\n"
1183 " Add port tm node private shaper profile.\n\n"
1185 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1186 " Delete port tm node private shaper profile.\n\n"
1188 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1189 " (shaper_profile_id)\n"
1190 " Add/update port tm node shared shaper.\n\n"
1192 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1193 " Delete port tm node shared shaper.\n\n"
1195 "set port tm node shaper profile (port_id) (node_id)"
1196 " (shaper_profile_id)\n"
1197 " Set port tm node shaper profile.\n\n"
1199 "add port tm node wred profile (port_id) (wred_profile_id)"
1200 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1201 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1202 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1203 " Add port tm node wred profile.\n\n"
1205 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1206 " Delete port tm node wred profile.\n\n"
1208 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1209 " (priority) (weight) (level_id) (shaper_profile_id)"
1210 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1211 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1212 " Add port tm nonleaf node.\n\n"
1214 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1215 " (priority) (weight) (level_id) (shaper_profile_id)"
1216 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1217 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1218 " Add port tm leaf node.\n\n"
1220 "del port tm node (port_id) (node_id)\n"
1221 " Delete port tm node.\n\n"
1223 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1224 " (priority) (weight)\n"
1225 " Set port tm node parent.\n\n"
1227 "suspend port tm node (port_id) (node_id)"
1228 " Suspend tm node.\n\n"
1230 "resume port tm node (port_id) (node_id)"
1231 " Resume tm node.\n\n"
1233 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1234 " Commit tm hierarchy.\n\n"
1236 "set port tm mark ip_ecn (port) (green) (yellow)"
1238 " Enables/Disables the traffic management marking"
1239 " for IP ECN (Explicit Congestion Notification)"
1240 " packets on a given port\n\n"
1242 "set port tm mark ip_dscp (port) (green) (yellow)"
1244 " Enables/Disables the traffic management marking"
1245 " on the port for IP dscp packets\n\n"
1247 "set port tm mark vlan_dei (port) (green) (yellow)"
1249 " Enables/Disables the traffic management marking"
1250 " on the port for VLAN packets with DEI enabled\n\n"
1254 if (show_all || !strcmp(res->section, "devices")) {
1258 "Device Operations:\n"
1260 "device detach (identifier)\n"
1261 " Detach device by identifier.\n\n"
1267 cmdline_parse_token_string_t cmd_help_long_help =
1268 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1270 cmdline_parse_token_string_t cmd_help_long_section =
1271 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1272 "all#control#display#config#"
1273 "ports#registers#filters#traffic_management#devices");
1275 cmdline_parse_inst_t cmd_help_long = {
1276 .f = cmd_help_long_parsed,
1278 .help_str = "help all|control|display|config|ports|register|"
1279 "filters|traffic_management|devices: "
1282 (void *)&cmd_help_long_help,
1283 (void *)&cmd_help_long_section,
1289 /* *** start/stop/close all ports *** */
1290 struct cmd_operate_port_result {
1291 cmdline_fixed_string_t keyword;
1292 cmdline_fixed_string_t name;
1293 cmdline_fixed_string_t value;
1296 static void cmd_operate_port_parsed(void *parsed_result,
1297 __attribute__((unused)) struct cmdline *cl,
1298 __attribute__((unused)) void *data)
1300 struct cmd_operate_port_result *res = parsed_result;
1302 if (!strcmp(res->name, "start"))
1303 start_port(RTE_PORT_ALL);
1304 else if (!strcmp(res->name, "stop"))
1305 stop_port(RTE_PORT_ALL);
1306 else if (!strcmp(res->name, "close"))
1307 close_port(RTE_PORT_ALL);
1308 else if (!strcmp(res->name, "reset"))
1309 reset_port(RTE_PORT_ALL);
1311 printf("Unknown parameter\n");
1314 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1315 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1317 cmdline_parse_token_string_t cmd_operate_port_all_port =
1318 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1319 "start#stop#close#reset");
1320 cmdline_parse_token_string_t cmd_operate_port_all_all =
1321 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1323 cmdline_parse_inst_t cmd_operate_port = {
1324 .f = cmd_operate_port_parsed,
1326 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1328 (void *)&cmd_operate_port_all_cmd,
1329 (void *)&cmd_operate_port_all_port,
1330 (void *)&cmd_operate_port_all_all,
1335 /* *** start/stop/close specific port *** */
1336 struct cmd_operate_specific_port_result {
1337 cmdline_fixed_string_t keyword;
1338 cmdline_fixed_string_t name;
1342 static void cmd_operate_specific_port_parsed(void *parsed_result,
1343 __attribute__((unused)) struct cmdline *cl,
1344 __attribute__((unused)) void *data)
1346 struct cmd_operate_specific_port_result *res = parsed_result;
1348 if (!strcmp(res->name, "start"))
1349 start_port(res->value);
1350 else if (!strcmp(res->name, "stop"))
1351 stop_port(res->value);
1352 else if (!strcmp(res->name, "close"))
1353 close_port(res->value);
1354 else if (!strcmp(res->name, "reset"))
1355 reset_port(res->value);
1357 printf("Unknown parameter\n");
1360 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1361 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1363 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1364 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1365 name, "start#stop#close#reset");
1366 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1367 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1370 cmdline_parse_inst_t cmd_operate_specific_port = {
1371 .f = cmd_operate_specific_port_parsed,
1373 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1375 (void *)&cmd_operate_specific_port_cmd,
1376 (void *)&cmd_operate_specific_port_port,
1377 (void *)&cmd_operate_specific_port_id,
1382 /* *** enable port setup (after attach) via iterator or event *** */
1383 struct cmd_set_port_setup_on_result {
1384 cmdline_fixed_string_t set;
1385 cmdline_fixed_string_t port;
1386 cmdline_fixed_string_t setup;
1387 cmdline_fixed_string_t on;
1388 cmdline_fixed_string_t mode;
1391 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1392 __attribute__((unused)) struct cmdline *cl,
1393 __attribute__((unused)) void *data)
1395 struct cmd_set_port_setup_on_result *res = parsed_result;
1397 if (strcmp(res->mode, "event") == 0)
1398 setup_on_probe_event = true;
1399 else if (strcmp(res->mode, "iterator") == 0)
1400 setup_on_probe_event = false;
1402 printf("Unknown mode\n");
1405 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1406 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1408 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1409 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1411 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1412 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1414 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1415 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1417 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1418 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1419 mode, "iterator#event");
1421 cmdline_parse_inst_t cmd_set_port_setup_on = {
1422 .f = cmd_set_port_setup_on_parsed,
1424 .help_str = "set port setup on iterator|event",
1426 (void *)&cmd_set_port_setup_on_set,
1427 (void *)&cmd_set_port_setup_on_port,
1428 (void *)&cmd_set_port_setup_on_setup,
1429 (void *)&cmd_set_port_setup_on_on,
1430 (void *)&cmd_set_port_setup_on_mode,
1435 /* *** attach a specified port *** */
1436 struct cmd_operate_attach_port_result {
1437 cmdline_fixed_string_t port;
1438 cmdline_fixed_string_t keyword;
1439 cmdline_fixed_string_t identifier;
1442 static void cmd_operate_attach_port_parsed(void *parsed_result,
1443 __attribute__((unused)) struct cmdline *cl,
1444 __attribute__((unused)) void *data)
1446 struct cmd_operate_attach_port_result *res = parsed_result;
1448 if (!strcmp(res->keyword, "attach"))
1449 attach_port(res->identifier);
1451 printf("Unknown parameter\n");
1454 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1455 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1457 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1458 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1460 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1461 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1464 cmdline_parse_inst_t cmd_operate_attach_port = {
1465 .f = cmd_operate_attach_port_parsed,
1467 .help_str = "port attach <identifier>: "
1468 "(identifier: pci address or virtual dev name)",
1470 (void *)&cmd_operate_attach_port_port,
1471 (void *)&cmd_operate_attach_port_keyword,
1472 (void *)&cmd_operate_attach_port_identifier,
1477 /* *** detach a specified port *** */
1478 struct cmd_operate_detach_port_result {
1479 cmdline_fixed_string_t port;
1480 cmdline_fixed_string_t keyword;
1484 static void cmd_operate_detach_port_parsed(void *parsed_result,
1485 __attribute__((unused)) struct cmdline *cl,
1486 __attribute__((unused)) void *data)
1488 struct cmd_operate_detach_port_result *res = parsed_result;
1490 if (!strcmp(res->keyword, "detach"))
1491 detach_port_device(res->port_id);
1493 printf("Unknown parameter\n");
1496 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1497 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1499 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1500 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1502 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1503 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1506 cmdline_parse_inst_t cmd_operate_detach_port = {
1507 .f = cmd_operate_detach_port_parsed,
1509 .help_str = "port detach <port_id>",
1511 (void *)&cmd_operate_detach_port_port,
1512 (void *)&cmd_operate_detach_port_keyword,
1513 (void *)&cmd_operate_detach_port_port_id,
1518 /* *** detach device by identifier *** */
1519 struct cmd_operate_detach_device_result {
1520 cmdline_fixed_string_t device;
1521 cmdline_fixed_string_t keyword;
1522 cmdline_fixed_string_t identifier;
1525 static void cmd_operate_detach_device_parsed(void *parsed_result,
1526 __attribute__((unused)) struct cmdline *cl,
1527 __attribute__((unused)) void *data)
1529 struct cmd_operate_detach_device_result *res = parsed_result;
1531 if (!strcmp(res->keyword, "detach"))
1532 detach_device(res->identifier);
1534 printf("Unknown parameter\n");
1537 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1538 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1540 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1541 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1543 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1544 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1547 cmdline_parse_inst_t cmd_operate_detach_device = {
1548 .f = cmd_operate_detach_device_parsed,
1550 .help_str = "device detach <identifier>:"
1551 "(identifier: pci address or virtual dev name)",
1553 (void *)&cmd_operate_detach_device_device,
1554 (void *)&cmd_operate_detach_device_keyword,
1555 (void *)&cmd_operate_detach_device_identifier,
1559 /* *** configure speed for all ports *** */
1560 struct cmd_config_speed_all {
1561 cmdline_fixed_string_t port;
1562 cmdline_fixed_string_t keyword;
1563 cmdline_fixed_string_t all;
1564 cmdline_fixed_string_t item1;
1565 cmdline_fixed_string_t item2;
1566 cmdline_fixed_string_t value1;
1567 cmdline_fixed_string_t value2;
1571 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1576 if (!strcmp(duplexstr, "half")) {
1577 duplex = ETH_LINK_HALF_DUPLEX;
1578 } else if (!strcmp(duplexstr, "full")) {
1579 duplex = ETH_LINK_FULL_DUPLEX;
1580 } else if (!strcmp(duplexstr, "auto")) {
1581 duplex = ETH_LINK_FULL_DUPLEX;
1583 printf("Unknown duplex parameter\n");
1587 if (!strcmp(speedstr, "10")) {
1588 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1589 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1590 } else if (!strcmp(speedstr, "100")) {
1591 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1592 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1594 if (duplex != ETH_LINK_FULL_DUPLEX) {
1595 printf("Invalid speed/duplex parameters\n");
1598 if (!strcmp(speedstr, "1000")) {
1599 *speed = ETH_LINK_SPEED_1G;
1600 } else if (!strcmp(speedstr, "10000")) {
1601 *speed = ETH_LINK_SPEED_10G;
1602 } else if (!strcmp(speedstr, "25000")) {
1603 *speed = ETH_LINK_SPEED_25G;
1604 } else if (!strcmp(speedstr, "40000")) {
1605 *speed = ETH_LINK_SPEED_40G;
1606 } else if (!strcmp(speedstr, "50000")) {
1607 *speed = ETH_LINK_SPEED_50G;
1608 } else if (!strcmp(speedstr, "100000")) {
1609 *speed = ETH_LINK_SPEED_100G;
1610 } else if (!strcmp(speedstr, "auto")) {
1611 *speed = ETH_LINK_SPEED_AUTONEG;
1613 printf("Unknown speed parameter\n");
1622 cmd_config_speed_all_parsed(void *parsed_result,
1623 __attribute__((unused)) struct cmdline *cl,
1624 __attribute__((unused)) void *data)
1626 struct cmd_config_speed_all *res = parsed_result;
1627 uint32_t link_speed;
1630 if (!all_ports_stopped()) {
1631 printf("Please stop all ports first\n");
1635 if (parse_and_check_speed_duplex(res->value1, res->value2,
1639 RTE_ETH_FOREACH_DEV(pid) {
1640 ports[pid].dev_conf.link_speeds = link_speed;
1643 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1646 cmdline_parse_token_string_t cmd_config_speed_all_port =
1647 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1648 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1649 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1651 cmdline_parse_token_string_t cmd_config_speed_all_all =
1652 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1653 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1654 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1655 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1656 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1657 "10#100#1000#10000#25000#40000#50000#100000#auto");
1658 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1659 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1660 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1661 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1664 cmdline_parse_inst_t cmd_config_speed_all = {
1665 .f = cmd_config_speed_all_parsed,
1667 .help_str = "port config all speed "
1668 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1671 (void *)&cmd_config_speed_all_port,
1672 (void *)&cmd_config_speed_all_keyword,
1673 (void *)&cmd_config_speed_all_all,
1674 (void *)&cmd_config_speed_all_item1,
1675 (void *)&cmd_config_speed_all_value1,
1676 (void *)&cmd_config_speed_all_item2,
1677 (void *)&cmd_config_speed_all_value2,
1682 /* *** configure speed for specific port *** */
1683 struct cmd_config_speed_specific {
1684 cmdline_fixed_string_t port;
1685 cmdline_fixed_string_t keyword;
1687 cmdline_fixed_string_t item1;
1688 cmdline_fixed_string_t item2;
1689 cmdline_fixed_string_t value1;
1690 cmdline_fixed_string_t value2;
1694 cmd_config_speed_specific_parsed(void *parsed_result,
1695 __attribute__((unused)) struct cmdline *cl,
1696 __attribute__((unused)) void *data)
1698 struct cmd_config_speed_specific *res = parsed_result;
1699 uint32_t link_speed;
1701 if (!all_ports_stopped()) {
1702 printf("Please stop all ports first\n");
1706 if (port_id_is_invalid(res->id, ENABLED_WARN))
1709 if (parse_and_check_speed_duplex(res->value1, res->value2,
1713 ports[res->id].dev_conf.link_speeds = link_speed;
1715 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1719 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1720 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1722 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1723 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1725 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1726 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1727 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1728 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1730 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1731 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1732 "10#100#1000#10000#25000#40000#50000#100000#auto");
1733 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1734 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1736 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1737 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1740 cmdline_parse_inst_t cmd_config_speed_specific = {
1741 .f = cmd_config_speed_specific_parsed,
1743 .help_str = "port config <port_id> speed "
1744 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1747 (void *)&cmd_config_speed_specific_port,
1748 (void *)&cmd_config_speed_specific_keyword,
1749 (void *)&cmd_config_speed_specific_id,
1750 (void *)&cmd_config_speed_specific_item1,
1751 (void *)&cmd_config_speed_specific_value1,
1752 (void *)&cmd_config_speed_specific_item2,
1753 (void *)&cmd_config_speed_specific_value2,
1758 /* *** configure loopback for all ports *** */
1759 struct cmd_config_loopback_all {
1760 cmdline_fixed_string_t port;
1761 cmdline_fixed_string_t keyword;
1762 cmdline_fixed_string_t all;
1763 cmdline_fixed_string_t item;
1768 cmd_config_loopback_all_parsed(void *parsed_result,
1769 __attribute__((unused)) struct cmdline *cl,
1770 __attribute__((unused)) void *data)
1772 struct cmd_config_loopback_all *res = parsed_result;
1775 if (!all_ports_stopped()) {
1776 printf("Please stop all ports first\n");
1780 RTE_ETH_FOREACH_DEV(pid) {
1781 ports[pid].dev_conf.lpbk_mode = res->mode;
1784 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1787 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1788 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1789 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1790 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1792 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1793 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1794 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1795 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1797 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1798 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1800 cmdline_parse_inst_t cmd_config_loopback_all = {
1801 .f = cmd_config_loopback_all_parsed,
1803 .help_str = "port config all loopback <mode>",
1805 (void *)&cmd_config_loopback_all_port,
1806 (void *)&cmd_config_loopback_all_keyword,
1807 (void *)&cmd_config_loopback_all_all,
1808 (void *)&cmd_config_loopback_all_item,
1809 (void *)&cmd_config_loopback_all_mode,
1814 /* *** configure loopback for specific port *** */
1815 struct cmd_config_loopback_specific {
1816 cmdline_fixed_string_t port;
1817 cmdline_fixed_string_t keyword;
1819 cmdline_fixed_string_t item;
1824 cmd_config_loopback_specific_parsed(void *parsed_result,
1825 __attribute__((unused)) struct cmdline *cl,
1826 __attribute__((unused)) void *data)
1828 struct cmd_config_loopback_specific *res = parsed_result;
1830 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1833 if (!port_is_stopped(res->port_id)) {
1834 printf("Please stop port %u first\n", res->port_id);
1838 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1840 cmd_reconfig_device_queue(res->port_id, 1, 1);
1844 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1845 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1847 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1848 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1850 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1851 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1853 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1854 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1856 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1857 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1860 cmdline_parse_inst_t cmd_config_loopback_specific = {
1861 .f = cmd_config_loopback_specific_parsed,
1863 .help_str = "port config <port_id> loopback <mode>",
1865 (void *)&cmd_config_loopback_specific_port,
1866 (void *)&cmd_config_loopback_specific_keyword,
1867 (void *)&cmd_config_loopback_specific_id,
1868 (void *)&cmd_config_loopback_specific_item,
1869 (void *)&cmd_config_loopback_specific_mode,
1874 /* *** configure txq/rxq, txd/rxd *** */
1875 struct cmd_config_rx_tx {
1876 cmdline_fixed_string_t port;
1877 cmdline_fixed_string_t keyword;
1878 cmdline_fixed_string_t all;
1879 cmdline_fixed_string_t name;
1884 cmd_config_rx_tx_parsed(void *parsed_result,
1885 __attribute__((unused)) struct cmdline *cl,
1886 __attribute__((unused)) void *data)
1888 struct cmd_config_rx_tx *res = parsed_result;
1890 if (!all_ports_stopped()) {
1891 printf("Please stop all ports first\n");
1894 if (!strcmp(res->name, "rxq")) {
1895 if (!res->value && !nb_txq) {
1896 printf("Warning: Either rx or tx queues should be non zero\n");
1899 if (check_nb_rxq(res->value) != 0)
1901 nb_rxq = res->value;
1903 else if (!strcmp(res->name, "txq")) {
1904 if (!res->value && !nb_rxq) {
1905 printf("Warning: Either rx or tx queues should be non zero\n");
1908 if (check_nb_txq(res->value) != 0)
1910 nb_txq = res->value;
1912 else if (!strcmp(res->name, "rxd")) {
1913 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1914 printf("rxd %d invalid - must be > 0 && <= %d\n",
1915 res->value, RTE_TEST_RX_DESC_MAX);
1918 nb_rxd = res->value;
1919 } else if (!strcmp(res->name, "txd")) {
1920 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1921 printf("txd %d invalid - must be > 0 && <= %d\n",
1922 res->value, RTE_TEST_TX_DESC_MAX);
1925 nb_txd = res->value;
1927 printf("Unknown parameter\n");
1935 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1938 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1939 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1940 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1941 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1942 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1943 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1944 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1945 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1947 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1948 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1950 cmdline_parse_inst_t cmd_config_rx_tx = {
1951 .f = cmd_config_rx_tx_parsed,
1953 .help_str = "port config all rxq|txq|rxd|txd <value>",
1955 (void *)&cmd_config_rx_tx_port,
1956 (void *)&cmd_config_rx_tx_keyword,
1957 (void *)&cmd_config_rx_tx_all,
1958 (void *)&cmd_config_rx_tx_name,
1959 (void *)&cmd_config_rx_tx_value,
1964 /* *** config max packet length *** */
1965 struct cmd_config_max_pkt_len_result {
1966 cmdline_fixed_string_t port;
1967 cmdline_fixed_string_t keyword;
1968 cmdline_fixed_string_t all;
1969 cmdline_fixed_string_t name;
1974 cmd_config_max_pkt_len_parsed(void *parsed_result,
1975 __attribute__((unused)) struct cmdline *cl,
1976 __attribute__((unused)) void *data)
1978 struct cmd_config_max_pkt_len_result *res = parsed_result;
1981 if (!all_ports_stopped()) {
1982 printf("Please stop all ports first\n");
1986 RTE_ETH_FOREACH_DEV(pid) {
1987 struct rte_port *port = &ports[pid];
1988 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1990 if (!strcmp(res->name, "max-pkt-len")) {
1991 if (res->value < RTE_ETHER_MIN_LEN) {
1992 printf("max-pkt-len can not be less than %d\n",
1996 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1999 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2000 if (res->value > RTE_ETHER_MAX_LEN)
2001 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2003 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2004 port->dev_conf.rxmode.offloads = rx_offloads;
2006 printf("Unknown parameter\n");
2013 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2016 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2017 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2019 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2020 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2022 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2023 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2025 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2026 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2028 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2029 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2032 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2033 .f = cmd_config_max_pkt_len_parsed,
2035 .help_str = "port config all max-pkt-len <value>",
2037 (void *)&cmd_config_max_pkt_len_port,
2038 (void *)&cmd_config_max_pkt_len_keyword,
2039 (void *)&cmd_config_max_pkt_len_all,
2040 (void *)&cmd_config_max_pkt_len_name,
2041 (void *)&cmd_config_max_pkt_len_value,
2046 /* *** configure port MTU *** */
2047 struct cmd_config_mtu_result {
2048 cmdline_fixed_string_t port;
2049 cmdline_fixed_string_t keyword;
2050 cmdline_fixed_string_t mtu;
2056 cmd_config_mtu_parsed(void *parsed_result,
2057 __attribute__((unused)) struct cmdline *cl,
2058 __attribute__((unused)) void *data)
2060 struct cmd_config_mtu_result *res = parsed_result;
2062 if (res->value < RTE_ETHER_MIN_LEN) {
2063 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2066 port_mtu_set(res->port_id, res->value);
2069 cmdline_parse_token_string_t cmd_config_mtu_port =
2070 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2072 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2073 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2075 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2076 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2078 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2079 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2080 cmdline_parse_token_num_t cmd_config_mtu_value =
2081 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2083 cmdline_parse_inst_t cmd_config_mtu = {
2084 .f = cmd_config_mtu_parsed,
2086 .help_str = "port config mtu <port_id> <value>",
2088 (void *)&cmd_config_mtu_port,
2089 (void *)&cmd_config_mtu_keyword,
2090 (void *)&cmd_config_mtu_mtu,
2091 (void *)&cmd_config_mtu_port_id,
2092 (void *)&cmd_config_mtu_value,
2097 /* *** configure rx mode *** */
2098 struct cmd_config_rx_mode_flag {
2099 cmdline_fixed_string_t port;
2100 cmdline_fixed_string_t keyword;
2101 cmdline_fixed_string_t all;
2102 cmdline_fixed_string_t name;
2103 cmdline_fixed_string_t value;
2107 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2108 __attribute__((unused)) struct cmdline *cl,
2109 __attribute__((unused)) void *data)
2111 struct cmd_config_rx_mode_flag *res = parsed_result;
2113 if (!all_ports_stopped()) {
2114 printf("Please stop all ports first\n");
2118 if (!strcmp(res->name, "drop-en")) {
2119 if (!strcmp(res->value, "on"))
2121 else if (!strcmp(res->value, "off"))
2124 printf("Unknown parameter\n");
2128 printf("Unknown parameter\n");
2134 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2137 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2138 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2139 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2140 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2142 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2143 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2144 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2145 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2147 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2148 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2151 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2152 .f = cmd_config_rx_mode_flag_parsed,
2154 .help_str = "port config all drop-en on|off",
2156 (void *)&cmd_config_rx_mode_flag_port,
2157 (void *)&cmd_config_rx_mode_flag_keyword,
2158 (void *)&cmd_config_rx_mode_flag_all,
2159 (void *)&cmd_config_rx_mode_flag_name,
2160 (void *)&cmd_config_rx_mode_flag_value,
2165 /* *** configure rss *** */
2166 struct cmd_config_rss {
2167 cmdline_fixed_string_t port;
2168 cmdline_fixed_string_t keyword;
2169 cmdline_fixed_string_t all;
2170 cmdline_fixed_string_t name;
2171 cmdline_fixed_string_t value;
2175 cmd_config_rss_parsed(void *parsed_result,
2176 __attribute__((unused)) struct cmdline *cl,
2177 __attribute__((unused)) void *data)
2179 struct cmd_config_rss *res = parsed_result;
2180 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2181 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2182 int use_default = 0;
2183 int all_updated = 1;
2188 if (!strcmp(res->value, "all"))
2189 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2190 ETH_RSS_UDP | ETH_RSS_SCTP |
2192 else if (!strcmp(res->value, "ip"))
2193 rss_conf.rss_hf = ETH_RSS_IP;
2194 else if (!strcmp(res->value, "udp"))
2195 rss_conf.rss_hf = ETH_RSS_UDP;
2196 else if (!strcmp(res->value, "tcp"))
2197 rss_conf.rss_hf = ETH_RSS_TCP;
2198 else if (!strcmp(res->value, "sctp"))
2199 rss_conf.rss_hf = ETH_RSS_SCTP;
2200 else if (!strcmp(res->value, "ether"))
2201 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2202 else if (!strcmp(res->value, "port"))
2203 rss_conf.rss_hf = ETH_RSS_PORT;
2204 else if (!strcmp(res->value, "vxlan"))
2205 rss_conf.rss_hf = ETH_RSS_VXLAN;
2206 else if (!strcmp(res->value, "geneve"))
2207 rss_conf.rss_hf = ETH_RSS_GENEVE;
2208 else if (!strcmp(res->value, "nvgre"))
2209 rss_conf.rss_hf = ETH_RSS_NVGRE;
2210 else if (!strcmp(res->value, "l3-src-only"))
2211 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2212 else if (!strcmp(res->value, "l3-dst-only"))
2213 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2214 else if (!strcmp(res->value, "l4-src-only"))
2215 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2216 else if (!strcmp(res->value, "l4-dst-only"))
2217 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2218 else if (!strcmp(res->value, "none"))
2219 rss_conf.rss_hf = 0;
2220 else if (!strcmp(res->value, "default"))
2222 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2223 atoi(res->value) < 64)
2224 rss_conf.rss_hf = 1ULL << atoi(res->value);
2226 printf("Unknown parameter\n");
2229 rss_conf.rss_key = NULL;
2230 /* Update global configuration for RSS types. */
2231 RTE_ETH_FOREACH_DEV(i) {
2232 struct rte_eth_rss_conf local_rss_conf;
2234 ret = eth_dev_info_get_print_err(i, &dev_info);
2239 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2241 local_rss_conf = rss_conf;
2242 local_rss_conf.rss_hf = rss_conf.rss_hf &
2243 dev_info.flow_type_rss_offloads;
2244 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2245 printf("Port %u modified RSS hash function based on hardware support,"
2246 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2247 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2249 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2252 printf("Configuration of RSS hash at ethernet port %d "
2253 "failed with error (%d): %s.\n",
2254 i, -diag, strerror(-diag));
2257 if (all_updated && !use_default)
2258 rss_hf = rss_conf.rss_hf;
2261 cmdline_parse_token_string_t cmd_config_rss_port =
2262 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2263 cmdline_parse_token_string_t cmd_config_rss_keyword =
2264 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2265 cmdline_parse_token_string_t cmd_config_rss_all =
2266 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2267 cmdline_parse_token_string_t cmd_config_rss_name =
2268 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2269 cmdline_parse_token_string_t cmd_config_rss_value =
2270 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2272 cmdline_parse_inst_t cmd_config_rss = {
2273 .f = cmd_config_rss_parsed,
2275 .help_str = "port config all rss "
2276 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>",
2278 (void *)&cmd_config_rss_port,
2279 (void *)&cmd_config_rss_keyword,
2280 (void *)&cmd_config_rss_all,
2281 (void *)&cmd_config_rss_name,
2282 (void *)&cmd_config_rss_value,
2287 /* *** configure rss hash key *** */
2288 struct cmd_config_rss_hash_key {
2289 cmdline_fixed_string_t port;
2290 cmdline_fixed_string_t config;
2292 cmdline_fixed_string_t rss_hash_key;
2293 cmdline_fixed_string_t rss_type;
2294 cmdline_fixed_string_t key;
2298 hexa_digit_to_value(char hexa_digit)
2300 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2301 return (uint8_t) (hexa_digit - '0');
2302 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2303 return (uint8_t) ((hexa_digit - 'a') + 10);
2304 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2305 return (uint8_t) ((hexa_digit - 'A') + 10);
2306 /* Invalid hexa digit */
2311 parse_and_check_key_hexa_digit(char *key, int idx)
2315 hexa_v = hexa_digit_to_value(key[idx]);
2317 printf("invalid key: character %c at position %d is not a "
2318 "valid hexa digit\n", key[idx], idx);
2323 cmd_config_rss_hash_key_parsed(void *parsed_result,
2324 __attribute__((unused)) struct cmdline *cl,
2325 __attribute__((unused)) void *data)
2327 struct cmd_config_rss_hash_key *res = parsed_result;
2328 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2332 struct rte_eth_dev_info dev_info;
2333 uint8_t hash_key_size;
2337 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2341 if (dev_info.hash_key_size > 0 &&
2342 dev_info.hash_key_size <= sizeof(hash_key))
2343 hash_key_size = dev_info.hash_key_size;
2345 printf("dev_info did not provide a valid hash key size\n");
2348 /* Check the length of the RSS hash key */
2349 key_len = strlen(res->key);
2350 if (key_len != (hash_key_size * 2)) {
2351 printf("key length: %d invalid - key must be a string of %d"
2352 " hexa-decimal numbers\n",
2353 (int) key_len, hash_key_size * 2);
2356 /* Translate RSS hash key into binary representation */
2357 for (i = 0; i < hash_key_size; i++) {
2358 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2361 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2364 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2366 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2370 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2371 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2372 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2373 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2375 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2376 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2377 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2378 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2379 rss_hash_key, "rss-hash-key");
2380 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2381 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2382 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2383 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2384 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2385 "ipv6-tcp-ex#ipv6-udp-ex#"
2386 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only");
2387 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2388 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2390 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2391 .f = cmd_config_rss_hash_key_parsed,
2393 .help_str = "port config <port_id> rss-hash-key "
2394 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2395 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2396 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2397 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only "
2398 "<string of hex digits (variable length, NIC dependent)>",
2400 (void *)&cmd_config_rss_hash_key_port,
2401 (void *)&cmd_config_rss_hash_key_config,
2402 (void *)&cmd_config_rss_hash_key_port_id,
2403 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2404 (void *)&cmd_config_rss_hash_key_rss_type,
2405 (void *)&cmd_config_rss_hash_key_value,
2410 /* *** configure port rxq/txq ring size *** */
2411 struct cmd_config_rxtx_ring_size {
2412 cmdline_fixed_string_t port;
2413 cmdline_fixed_string_t config;
2415 cmdline_fixed_string_t rxtxq;
2417 cmdline_fixed_string_t rsize;
2422 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2423 __attribute__((unused)) struct cmdline *cl,
2424 __attribute__((unused)) void *data)
2426 struct cmd_config_rxtx_ring_size *res = parsed_result;
2427 struct rte_port *port;
2430 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2433 if (res->portid == (portid_t)RTE_PORT_ALL) {
2434 printf("Invalid port id\n");
2438 port = &ports[res->portid];
2440 if (!strcmp(res->rxtxq, "rxq"))
2442 else if (!strcmp(res->rxtxq, "txq"))
2445 printf("Unknown parameter\n");
2449 if (isrx && rx_queue_id_is_invalid(res->qid))
2451 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2454 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2455 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2461 port->nb_rx_desc[res->qid] = res->size;
2463 port->nb_tx_desc[res->qid] = res->size;
2465 cmd_reconfig_device_queue(res->portid, 0, 1);
2468 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2469 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2471 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2472 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2474 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2475 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2477 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2478 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2480 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2481 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2483 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2484 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2485 rsize, "ring_size");
2486 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2487 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2490 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2491 .f = cmd_config_rxtx_ring_size_parsed,
2493 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2495 (void *)&cmd_config_rxtx_ring_size_port,
2496 (void *)&cmd_config_rxtx_ring_size_config,
2497 (void *)&cmd_config_rxtx_ring_size_portid,
2498 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2499 (void *)&cmd_config_rxtx_ring_size_qid,
2500 (void *)&cmd_config_rxtx_ring_size_rsize,
2501 (void *)&cmd_config_rxtx_ring_size_size,
2506 /* *** configure port rxq/txq start/stop *** */
2507 struct cmd_config_rxtx_queue {
2508 cmdline_fixed_string_t port;
2510 cmdline_fixed_string_t rxtxq;
2512 cmdline_fixed_string_t opname;
2516 cmd_config_rxtx_queue_parsed(void *parsed_result,
2517 __attribute__((unused)) struct cmdline *cl,
2518 __attribute__((unused)) void *data)
2520 struct cmd_config_rxtx_queue *res = parsed_result;
2525 if (test_done == 0) {
2526 printf("Please stop forwarding first\n");
2530 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2533 if (port_is_started(res->portid) != 1) {
2534 printf("Please start port %u first\n", res->portid);
2538 if (!strcmp(res->rxtxq, "rxq"))
2540 else if (!strcmp(res->rxtxq, "txq"))
2543 printf("Unknown parameter\n");
2547 if (isrx && rx_queue_id_is_invalid(res->qid))
2549 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2552 if (!strcmp(res->opname, "start"))
2554 else if (!strcmp(res->opname, "stop"))
2557 printf("Unknown parameter\n");
2561 if (isstart && isrx)
2562 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2563 else if (!isstart && isrx)
2564 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2565 else if (isstart && !isrx)
2566 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2568 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2570 if (ret == -ENOTSUP)
2571 printf("Function not supported in PMD driver\n");
2574 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2575 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2576 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2577 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2578 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2579 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2580 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2581 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2582 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2583 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2586 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2587 .f = cmd_config_rxtx_queue_parsed,
2589 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2591 (void *)&cmd_config_rxtx_queue_port,
2592 (void *)&cmd_config_rxtx_queue_portid,
2593 (void *)&cmd_config_rxtx_queue_rxtxq,
2594 (void *)&cmd_config_rxtx_queue_qid,
2595 (void *)&cmd_config_rxtx_queue_opname,
2600 /* *** configure port rxq/txq deferred start on/off *** */
2601 struct cmd_config_deferred_start_rxtx_queue {
2602 cmdline_fixed_string_t port;
2604 cmdline_fixed_string_t rxtxq;
2606 cmdline_fixed_string_t opname;
2607 cmdline_fixed_string_t state;
2611 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2612 __attribute__((unused)) struct cmdline *cl,
2613 __attribute__((unused)) void *data)
2615 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2616 struct rte_port *port;
2619 uint8_t needreconfig = 0;
2621 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2624 if (port_is_started(res->port_id) != 0) {
2625 printf("Please stop port %u first\n", res->port_id);
2629 port = &ports[res->port_id];
2631 isrx = !strcmp(res->rxtxq, "rxq");
2633 if (isrx && rx_queue_id_is_invalid(res->qid))
2635 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2638 ison = !strcmp(res->state, "on");
2640 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2641 port->rx_conf[res->qid].rx_deferred_start = ison;
2643 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2644 port->tx_conf[res->qid].tx_deferred_start = ison;
2649 cmd_reconfig_device_queue(res->port_id, 0, 1);
2652 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2653 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2655 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2656 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2658 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2659 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2661 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2662 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2664 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2665 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2666 opname, "deferred_start");
2667 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2668 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2671 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2672 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2674 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2676 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2677 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2678 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2679 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2680 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2681 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2686 /* *** configure port rxq/txq setup *** */
2687 struct cmd_setup_rxtx_queue {
2688 cmdline_fixed_string_t port;
2690 cmdline_fixed_string_t rxtxq;
2692 cmdline_fixed_string_t setup;
2695 /* Common CLI fields for queue setup */
2696 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2697 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2698 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2699 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2700 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2701 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2702 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2703 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2704 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2705 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2708 cmd_setup_rxtx_queue_parsed(
2709 void *parsed_result,
2710 __attribute__((unused)) struct cmdline *cl,
2711 __attribute__((unused)) void *data)
2713 struct cmd_setup_rxtx_queue *res = parsed_result;
2714 struct rte_port *port;
2715 struct rte_mempool *mp;
2716 unsigned int socket_id;
2720 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2723 if (res->portid == (portid_t)RTE_PORT_ALL) {
2724 printf("Invalid port id\n");
2728 if (!strcmp(res->rxtxq, "rxq"))
2730 else if (!strcmp(res->rxtxq, "txq"))
2733 printf("Unknown parameter\n");
2737 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2738 printf("Invalid rx queue\n");
2740 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2741 printf("Invalid tx queue\n");
2745 port = &ports[res->portid];
2747 socket_id = rxring_numa[res->portid];
2748 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2749 socket_id = port->socket_id;
2751 mp = mbuf_pool_find(socket_id);
2753 printf("Failed to setup RX queue: "
2754 "No mempool allocation"
2755 " on the socket %d\n",
2756 rxring_numa[res->portid]);
2759 ret = rte_eth_rx_queue_setup(res->portid,
2761 port->nb_rx_desc[res->qid],
2763 &port->rx_conf[res->qid],
2766 printf("Failed to setup RX queue\n");
2768 socket_id = txring_numa[res->portid];
2769 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2770 socket_id = port->socket_id;
2772 ret = rte_eth_tx_queue_setup(res->portid,
2774 port->nb_tx_desc[res->qid],
2776 &port->tx_conf[res->qid]);
2778 printf("Failed to setup TX queue\n");
2782 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2783 .f = cmd_setup_rxtx_queue_parsed,
2785 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2787 (void *)&cmd_setup_rxtx_queue_port,
2788 (void *)&cmd_setup_rxtx_queue_portid,
2789 (void *)&cmd_setup_rxtx_queue_rxtxq,
2790 (void *)&cmd_setup_rxtx_queue_qid,
2791 (void *)&cmd_setup_rxtx_queue_setup,
2797 /* *** Configure RSS RETA *** */
2798 struct cmd_config_rss_reta {
2799 cmdline_fixed_string_t port;
2800 cmdline_fixed_string_t keyword;
2802 cmdline_fixed_string_t name;
2803 cmdline_fixed_string_t list_name;
2804 cmdline_fixed_string_t list_of_items;
2808 parse_reta_config(const char *str,
2809 struct rte_eth_rss_reta_entry64 *reta_conf,
2810 uint16_t nb_entries)
2814 uint16_t hash_index, idx, shift;
2817 const char *p, *p0 = str;
2824 unsigned long int_fld[_NUM_FLD];
2825 char *str_fld[_NUM_FLD];
2827 while ((p = strchr(p0,'(')) != NULL) {
2829 if((p0 = strchr(p,')')) == NULL)
2833 if(size >= sizeof(s))
2836 snprintf(s, sizeof(s), "%.*s", size, p);
2837 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2839 for (i = 0; i < _NUM_FLD; i++) {
2841 int_fld[i] = strtoul(str_fld[i], &end, 0);
2842 if (errno != 0 || end == str_fld[i] ||
2847 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2848 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2850 if (hash_index >= nb_entries) {
2851 printf("Invalid RETA hash index=%d\n", hash_index);
2855 idx = hash_index / RTE_RETA_GROUP_SIZE;
2856 shift = hash_index % RTE_RETA_GROUP_SIZE;
2857 reta_conf[idx].mask |= (1ULL << shift);
2858 reta_conf[idx].reta[shift] = nb_queue;
2865 cmd_set_rss_reta_parsed(void *parsed_result,
2866 __attribute__((unused)) struct cmdline *cl,
2867 __attribute__((unused)) void *data)
2870 struct rte_eth_dev_info dev_info;
2871 struct rte_eth_rss_reta_entry64 reta_conf[8];
2872 struct cmd_config_rss_reta *res = parsed_result;
2874 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2878 if (dev_info.reta_size == 0) {
2879 printf("Redirection table size is 0 which is "
2880 "invalid for RSS\n");
2883 printf("The reta size of port %d is %u\n",
2884 res->port_id, dev_info.reta_size);
2885 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2886 printf("Currently do not support more than %u entries of "
2887 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2891 memset(reta_conf, 0, sizeof(reta_conf));
2892 if (!strcmp(res->list_name, "reta")) {
2893 if (parse_reta_config(res->list_of_items, reta_conf,
2894 dev_info.reta_size)) {
2895 printf("Invalid RSS Redirection Table "
2896 "config entered\n");
2899 ret = rte_eth_dev_rss_reta_update(res->port_id,
2900 reta_conf, dev_info.reta_size);
2902 printf("Bad redirection table parameter, "
2903 "return code = %d \n", ret);
2907 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2908 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2909 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2910 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2911 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2912 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2913 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2914 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2915 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2916 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2917 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2918 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2920 cmdline_parse_inst_t cmd_config_rss_reta = {
2921 .f = cmd_set_rss_reta_parsed,
2923 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2925 (void *)&cmd_config_rss_reta_port,
2926 (void *)&cmd_config_rss_reta_keyword,
2927 (void *)&cmd_config_rss_reta_port_id,
2928 (void *)&cmd_config_rss_reta_name,
2929 (void *)&cmd_config_rss_reta_list_name,
2930 (void *)&cmd_config_rss_reta_list_of_items,
2935 /* *** SHOW PORT RETA INFO *** */
2936 struct cmd_showport_reta {
2937 cmdline_fixed_string_t show;
2938 cmdline_fixed_string_t port;
2940 cmdline_fixed_string_t rss;
2941 cmdline_fixed_string_t reta;
2943 cmdline_fixed_string_t list_of_items;
2947 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2948 uint16_t nb_entries,
2952 const char *p, *p0 = str;
2957 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2958 RTE_RETA_GROUP_SIZE;
2961 p = strchr(p0, '(');
2965 p0 = strchr(p, ')');
2969 if (size >= sizeof(s)) {
2970 printf("The string size exceeds the internal buffer size\n");
2973 snprintf(s, sizeof(s), "%.*s", size, p);
2974 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2975 if (ret <= 0 || ret != num) {
2976 printf("The bits of masks do not match the number of "
2977 "reta entries: %u\n", num);
2980 for (i = 0; i < ret; i++)
2981 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2987 cmd_showport_reta_parsed(void *parsed_result,
2988 __attribute__((unused)) struct cmdline *cl,
2989 __attribute__((unused)) void *data)
2991 struct cmd_showport_reta *res = parsed_result;
2992 struct rte_eth_rss_reta_entry64 reta_conf[8];
2993 struct rte_eth_dev_info dev_info;
2994 uint16_t max_reta_size;
2997 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3001 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3002 if (res->size == 0 || res->size > max_reta_size) {
3003 printf("Invalid redirection table size: %u (1-%u)\n",
3004 res->size, max_reta_size);
3008 memset(reta_conf, 0, sizeof(reta_conf));
3009 if (showport_parse_reta_config(reta_conf, res->size,
3010 res->list_of_items) < 0) {
3011 printf("Invalid string: %s for reta masks\n",
3012 res->list_of_items);
3015 port_rss_reta_info(res->port_id, reta_conf, res->size);
3018 cmdline_parse_token_string_t cmd_showport_reta_show =
3019 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3020 cmdline_parse_token_string_t cmd_showport_reta_port =
3021 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3022 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3023 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3024 cmdline_parse_token_string_t cmd_showport_reta_rss =
3025 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3026 cmdline_parse_token_string_t cmd_showport_reta_reta =
3027 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3028 cmdline_parse_token_num_t cmd_showport_reta_size =
3029 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3030 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3031 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3032 list_of_items, NULL);
3034 cmdline_parse_inst_t cmd_showport_reta = {
3035 .f = cmd_showport_reta_parsed,
3037 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3039 (void *)&cmd_showport_reta_show,
3040 (void *)&cmd_showport_reta_port,
3041 (void *)&cmd_showport_reta_port_id,
3042 (void *)&cmd_showport_reta_rss,
3043 (void *)&cmd_showport_reta_reta,
3044 (void *)&cmd_showport_reta_size,
3045 (void *)&cmd_showport_reta_list_of_items,
3050 /* *** Show RSS hash configuration *** */
3051 struct cmd_showport_rss_hash {
3052 cmdline_fixed_string_t show;
3053 cmdline_fixed_string_t port;
3055 cmdline_fixed_string_t rss_hash;
3056 cmdline_fixed_string_t rss_type;
3057 cmdline_fixed_string_t key; /* optional argument */
3060 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3061 __attribute__((unused)) struct cmdline *cl,
3064 struct cmd_showport_rss_hash *res = parsed_result;
3066 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3069 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3070 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3071 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3072 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3073 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3074 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3075 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3076 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3078 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3079 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3081 cmdline_parse_inst_t cmd_showport_rss_hash = {
3082 .f = cmd_showport_rss_hash_parsed,
3084 .help_str = "show port <port_id> rss-hash",
3086 (void *)&cmd_showport_rss_hash_show,
3087 (void *)&cmd_showport_rss_hash_port,
3088 (void *)&cmd_showport_rss_hash_port_id,
3089 (void *)&cmd_showport_rss_hash_rss_hash,
3094 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3095 .f = cmd_showport_rss_hash_parsed,
3097 .help_str = "show port <port_id> rss-hash key",
3099 (void *)&cmd_showport_rss_hash_show,
3100 (void *)&cmd_showport_rss_hash_port,
3101 (void *)&cmd_showport_rss_hash_port_id,
3102 (void *)&cmd_showport_rss_hash_rss_hash,
3103 (void *)&cmd_showport_rss_hash_rss_key,
3108 /* *** Configure DCB *** */
3109 struct cmd_config_dcb {
3110 cmdline_fixed_string_t port;
3111 cmdline_fixed_string_t config;
3113 cmdline_fixed_string_t dcb;
3114 cmdline_fixed_string_t vt;
3115 cmdline_fixed_string_t vt_en;
3117 cmdline_fixed_string_t pfc;
3118 cmdline_fixed_string_t pfc_en;
3122 cmd_config_dcb_parsed(void *parsed_result,
3123 __attribute__((unused)) struct cmdline *cl,
3124 __attribute__((unused)) void *data)
3126 struct cmd_config_dcb *res = parsed_result;
3127 portid_t port_id = res->port_id;
3128 struct rte_port *port;
3132 port = &ports[port_id];
3133 /** Check if the port is not started **/
3134 if (port->port_status != RTE_PORT_STOPPED) {
3135 printf("Please stop port %d first\n", port_id);
3139 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3140 printf("The invalid number of traffic class,"
3141 " only 4 or 8 allowed.\n");
3145 if (nb_fwd_lcores < res->num_tcs) {
3146 printf("nb_cores shouldn't be less than number of TCs.\n");
3149 if (!strncmp(res->pfc_en, "on", 2))
3154 /* DCB in VT mode */
3155 if (!strncmp(res->vt_en, "on", 2))
3156 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3157 (enum rte_eth_nb_tcs)res->num_tcs,
3160 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3161 (enum rte_eth_nb_tcs)res->num_tcs,
3166 printf("Cannot initialize network ports.\n");
3170 cmd_reconfig_device_queue(port_id, 1, 1);
3173 cmdline_parse_token_string_t cmd_config_dcb_port =
3174 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3175 cmdline_parse_token_string_t cmd_config_dcb_config =
3176 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3177 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3178 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3179 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3180 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3181 cmdline_parse_token_string_t cmd_config_dcb_vt =
3182 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3183 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3184 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3185 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3186 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3187 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3188 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3189 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3190 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3192 cmdline_parse_inst_t cmd_config_dcb = {
3193 .f = cmd_config_dcb_parsed,
3195 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3197 (void *)&cmd_config_dcb_port,
3198 (void *)&cmd_config_dcb_config,
3199 (void *)&cmd_config_dcb_port_id,
3200 (void *)&cmd_config_dcb_dcb,
3201 (void *)&cmd_config_dcb_vt,
3202 (void *)&cmd_config_dcb_vt_en,
3203 (void *)&cmd_config_dcb_num_tcs,
3204 (void *)&cmd_config_dcb_pfc,
3205 (void *)&cmd_config_dcb_pfc_en,
3210 /* *** configure number of packets per burst *** */
3211 struct cmd_config_burst {
3212 cmdline_fixed_string_t port;
3213 cmdline_fixed_string_t keyword;
3214 cmdline_fixed_string_t all;
3215 cmdline_fixed_string_t name;
3220 cmd_config_burst_parsed(void *parsed_result,
3221 __attribute__((unused)) struct cmdline *cl,
3222 __attribute__((unused)) void *data)
3224 struct cmd_config_burst *res = parsed_result;
3225 struct rte_eth_dev_info dev_info;
3226 uint16_t rec_nb_pkts;
3229 if (!all_ports_stopped()) {
3230 printf("Please stop all ports first\n");
3234 if (!strcmp(res->name, "burst")) {
3235 if (res->value == 0) {
3236 /* If user gives a value of zero, query the PMD for
3237 * its recommended Rx burst size. Testpmd uses a single
3238 * size for all ports, so assume all ports are the same
3239 * NIC model and use the values from Port 0.
3241 ret = eth_dev_info_get_print_err(0, &dev_info);
3245 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3247 if (rec_nb_pkts == 0) {
3248 printf("PMD does not recommend a burst size.\n"
3249 "User provided value must be between"
3250 " 1 and %d\n", MAX_PKT_BURST);
3252 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3253 printf("PMD recommended burst size of %d"
3254 " exceeds maximum value of %d\n",
3255 rec_nb_pkts, MAX_PKT_BURST);
3258 printf("Using PMD-provided burst value of %d\n",
3260 nb_pkt_per_burst = rec_nb_pkts;
3261 } else if (res->value > MAX_PKT_BURST) {
3262 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3265 nb_pkt_per_burst = res->value;
3267 printf("Unknown parameter\n");
3273 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3276 cmdline_parse_token_string_t cmd_config_burst_port =
3277 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3278 cmdline_parse_token_string_t cmd_config_burst_keyword =
3279 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3280 cmdline_parse_token_string_t cmd_config_burst_all =
3281 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3282 cmdline_parse_token_string_t cmd_config_burst_name =
3283 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3284 cmdline_parse_token_num_t cmd_config_burst_value =
3285 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3287 cmdline_parse_inst_t cmd_config_burst = {
3288 .f = cmd_config_burst_parsed,
3290 .help_str = "port config all burst <value>",
3292 (void *)&cmd_config_burst_port,
3293 (void *)&cmd_config_burst_keyword,
3294 (void *)&cmd_config_burst_all,
3295 (void *)&cmd_config_burst_name,
3296 (void *)&cmd_config_burst_value,
3301 /* *** configure rx/tx queues *** */
3302 struct cmd_config_thresh {
3303 cmdline_fixed_string_t port;
3304 cmdline_fixed_string_t keyword;
3305 cmdline_fixed_string_t all;
3306 cmdline_fixed_string_t name;
3311 cmd_config_thresh_parsed(void *parsed_result,
3312 __attribute__((unused)) struct cmdline *cl,
3313 __attribute__((unused)) void *data)
3315 struct cmd_config_thresh *res = parsed_result;
3317 if (!all_ports_stopped()) {
3318 printf("Please stop all ports first\n");
3322 if (!strcmp(res->name, "txpt"))
3323 tx_pthresh = res->value;
3324 else if(!strcmp(res->name, "txht"))
3325 tx_hthresh = res->value;
3326 else if(!strcmp(res->name, "txwt"))
3327 tx_wthresh = res->value;
3328 else if(!strcmp(res->name, "rxpt"))
3329 rx_pthresh = res->value;
3330 else if(!strcmp(res->name, "rxht"))
3331 rx_hthresh = res->value;
3332 else if(!strcmp(res->name, "rxwt"))
3333 rx_wthresh = res->value;
3335 printf("Unknown parameter\n");
3341 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3344 cmdline_parse_token_string_t cmd_config_thresh_port =
3345 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3346 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3347 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3348 cmdline_parse_token_string_t cmd_config_thresh_all =
3349 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3350 cmdline_parse_token_string_t cmd_config_thresh_name =
3351 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3352 "txpt#txht#txwt#rxpt#rxht#rxwt");
3353 cmdline_parse_token_num_t cmd_config_thresh_value =
3354 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3356 cmdline_parse_inst_t cmd_config_thresh = {
3357 .f = cmd_config_thresh_parsed,
3359 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3361 (void *)&cmd_config_thresh_port,
3362 (void *)&cmd_config_thresh_keyword,
3363 (void *)&cmd_config_thresh_all,
3364 (void *)&cmd_config_thresh_name,
3365 (void *)&cmd_config_thresh_value,
3370 /* *** configure free/rs threshold *** */
3371 struct cmd_config_threshold {
3372 cmdline_fixed_string_t port;
3373 cmdline_fixed_string_t keyword;
3374 cmdline_fixed_string_t all;
3375 cmdline_fixed_string_t name;
3380 cmd_config_threshold_parsed(void *parsed_result,
3381 __attribute__((unused)) struct cmdline *cl,
3382 __attribute__((unused)) void *data)
3384 struct cmd_config_threshold *res = parsed_result;
3386 if (!all_ports_stopped()) {
3387 printf("Please stop all ports first\n");
3391 if (!strcmp(res->name, "txfreet"))
3392 tx_free_thresh = res->value;
3393 else if (!strcmp(res->name, "txrst"))
3394 tx_rs_thresh = res->value;
3395 else if (!strcmp(res->name, "rxfreet"))
3396 rx_free_thresh = res->value;
3398 printf("Unknown parameter\n");
3404 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3407 cmdline_parse_token_string_t cmd_config_threshold_port =
3408 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3409 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3410 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3412 cmdline_parse_token_string_t cmd_config_threshold_all =
3413 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3414 cmdline_parse_token_string_t cmd_config_threshold_name =
3415 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3416 "txfreet#txrst#rxfreet");
3417 cmdline_parse_token_num_t cmd_config_threshold_value =
3418 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3420 cmdline_parse_inst_t cmd_config_threshold = {
3421 .f = cmd_config_threshold_parsed,
3423 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3425 (void *)&cmd_config_threshold_port,
3426 (void *)&cmd_config_threshold_keyword,
3427 (void *)&cmd_config_threshold_all,
3428 (void *)&cmd_config_threshold_name,
3429 (void *)&cmd_config_threshold_value,
3435 struct cmd_stop_result {
3436 cmdline_fixed_string_t stop;
3439 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3440 __attribute__((unused)) struct cmdline *cl,
3441 __attribute__((unused)) void *data)
3443 stop_packet_forwarding();
3446 cmdline_parse_token_string_t cmd_stop_stop =
3447 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3449 cmdline_parse_inst_t cmd_stop = {
3450 .f = cmd_stop_parsed,
3452 .help_str = "stop: Stop packet forwarding",
3454 (void *)&cmd_stop_stop,
3459 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3462 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3463 unsigned int *parsed_items, int check_unique_values)
3465 unsigned int nb_item;
3473 * First parse all items in the list and store their value.
3478 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3480 if ((c >= '0') && (c <= '9')) {
3481 value = (unsigned int) (value * 10 + (c - '0'));
3486 printf("character %c is not a decimal digit\n", c);
3490 printf("No valid value before comma\n");
3493 if (nb_item < max_items) {
3494 parsed_items[nb_item] = value;
3500 if (nb_item >= max_items) {
3501 printf("Number of %s = %u > %u (maximum items)\n",
3502 item_name, nb_item + 1, max_items);
3505 parsed_items[nb_item++] = value;
3506 if (! check_unique_values)
3510 * Then, check that all values in the list are differents.
3511 * No optimization here...
3513 for (i = 0; i < nb_item; i++) {
3514 for (j = i + 1; j < nb_item; j++) {
3515 if (parsed_items[j] == parsed_items[i]) {
3516 printf("duplicated %s %u at index %u and %u\n",
3517 item_name, parsed_items[i], i, j);
3525 struct cmd_set_list_result {
3526 cmdline_fixed_string_t cmd_keyword;
3527 cmdline_fixed_string_t list_name;
3528 cmdline_fixed_string_t list_of_items;
3531 static void cmd_set_list_parsed(void *parsed_result,
3532 __attribute__((unused)) struct cmdline *cl,
3533 __attribute__((unused)) void *data)
3535 struct cmd_set_list_result *res;
3537 unsigned int lcorelist[RTE_MAX_LCORE];
3538 unsigned int portlist[RTE_MAX_ETHPORTS];
3540 unsigned int nb_item;
3542 if (test_done == 0) {
3543 printf("Please stop forwarding first\n");
3547 res = parsed_result;
3548 if (!strcmp(res->list_name, "corelist")) {
3549 nb_item = parse_item_list(res->list_of_items, "core",
3551 parsed_items.lcorelist, 1);
3553 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3558 if (!strcmp(res->list_name, "portlist")) {
3559 nb_item = parse_item_list(res->list_of_items, "port",
3561 parsed_items.portlist, 1);
3563 set_fwd_ports_list(parsed_items.portlist, nb_item);
3569 cmdline_parse_token_string_t cmd_set_list_keyword =
3570 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3572 cmdline_parse_token_string_t cmd_set_list_name =
3573 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3574 "corelist#portlist");
3575 cmdline_parse_token_string_t cmd_set_list_of_items =
3576 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3579 cmdline_parse_inst_t cmd_set_fwd_list = {
3580 .f = cmd_set_list_parsed,
3582 .help_str = "set corelist|portlist <list0[,list1]*>",
3584 (void *)&cmd_set_list_keyword,
3585 (void *)&cmd_set_list_name,
3586 (void *)&cmd_set_list_of_items,
3591 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3593 struct cmd_setmask_result {
3594 cmdline_fixed_string_t set;
3595 cmdline_fixed_string_t mask;
3599 static void cmd_set_mask_parsed(void *parsed_result,
3600 __attribute__((unused)) struct cmdline *cl,
3601 __attribute__((unused)) void *data)
3603 struct cmd_setmask_result *res = parsed_result;
3605 if (test_done == 0) {
3606 printf("Please stop forwarding first\n");
3609 if (!strcmp(res->mask, "coremask")) {
3610 set_fwd_lcores_mask(res->hexavalue);
3612 } else if (!strcmp(res->mask, "portmask")) {
3613 set_fwd_ports_mask(res->hexavalue);
3618 cmdline_parse_token_string_t cmd_setmask_set =
3619 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3620 cmdline_parse_token_string_t cmd_setmask_mask =
3621 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3622 "coremask#portmask");
3623 cmdline_parse_token_num_t cmd_setmask_value =
3624 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3626 cmdline_parse_inst_t cmd_set_fwd_mask = {
3627 .f = cmd_set_mask_parsed,
3629 .help_str = "set coremask|portmask <hexadecimal value>",
3631 (void *)&cmd_setmask_set,
3632 (void *)&cmd_setmask_mask,
3633 (void *)&cmd_setmask_value,
3639 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3641 struct cmd_set_result {
3642 cmdline_fixed_string_t set;
3643 cmdline_fixed_string_t what;
3647 static void cmd_set_parsed(void *parsed_result,
3648 __attribute__((unused)) struct cmdline *cl,
3649 __attribute__((unused)) void *data)
3651 struct cmd_set_result *res = parsed_result;
3652 if (!strcmp(res->what, "nbport")) {
3653 set_fwd_ports_number(res->value);
3655 } else if (!strcmp(res->what, "nbcore")) {
3656 set_fwd_lcores_number(res->value);
3658 } else if (!strcmp(res->what, "burst"))
3659 set_nb_pkt_per_burst(res->value);
3660 else if (!strcmp(res->what, "verbose"))
3661 set_verbose_level(res->value);
3664 cmdline_parse_token_string_t cmd_set_set =
3665 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3666 cmdline_parse_token_string_t cmd_set_what =
3667 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3668 "nbport#nbcore#burst#verbose");
3669 cmdline_parse_token_num_t cmd_set_value =
3670 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3672 cmdline_parse_inst_t cmd_set_numbers = {
3673 .f = cmd_set_parsed,
3675 .help_str = "set nbport|nbcore|burst|verbose <value>",
3677 (void *)&cmd_set_set,
3678 (void *)&cmd_set_what,
3679 (void *)&cmd_set_value,
3684 /* *** SET LOG LEVEL CONFIGURATION *** */
3686 struct cmd_set_log_result {
3687 cmdline_fixed_string_t set;
3688 cmdline_fixed_string_t log;
3689 cmdline_fixed_string_t type;
3694 cmd_set_log_parsed(void *parsed_result,
3695 __attribute__((unused)) struct cmdline *cl,
3696 __attribute__((unused)) void *data)
3698 struct cmd_set_log_result *res;
3701 res = parsed_result;
3702 if (!strcmp(res->type, "global"))
3703 rte_log_set_global_level(res->level);
3705 ret = rte_log_set_level_regexp(res->type, res->level);
3707 printf("Unable to set log level\n");
3711 cmdline_parse_token_string_t cmd_set_log_set =
3712 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3713 cmdline_parse_token_string_t cmd_set_log_log =
3714 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3715 cmdline_parse_token_string_t cmd_set_log_type =
3716 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3717 cmdline_parse_token_num_t cmd_set_log_level =
3718 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3720 cmdline_parse_inst_t cmd_set_log = {
3721 .f = cmd_set_log_parsed,
3723 .help_str = "set log global|<type> <level>",
3725 (void *)&cmd_set_log_set,
3726 (void *)&cmd_set_log_log,
3727 (void *)&cmd_set_log_type,
3728 (void *)&cmd_set_log_level,
3733 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3735 struct cmd_set_txpkts_result {
3736 cmdline_fixed_string_t cmd_keyword;
3737 cmdline_fixed_string_t txpkts;
3738 cmdline_fixed_string_t seg_lengths;
3742 cmd_set_txpkts_parsed(void *parsed_result,
3743 __attribute__((unused)) struct cmdline *cl,
3744 __attribute__((unused)) void *data)
3746 struct cmd_set_txpkts_result *res;
3747 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3748 unsigned int nb_segs;
3750 res = parsed_result;
3751 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3752 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3754 set_tx_pkt_segments(seg_lengths, nb_segs);
3757 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3758 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3759 cmd_keyword, "set");
3760 cmdline_parse_token_string_t cmd_set_txpkts_name =
3761 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3763 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3764 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3767 cmdline_parse_inst_t cmd_set_txpkts = {
3768 .f = cmd_set_txpkts_parsed,
3770 .help_str = "set txpkts <len0[,len1]*>",
3772 (void *)&cmd_set_txpkts_keyword,
3773 (void *)&cmd_set_txpkts_name,
3774 (void *)&cmd_set_txpkts_lengths,
3779 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3781 struct cmd_set_txsplit_result {
3782 cmdline_fixed_string_t cmd_keyword;
3783 cmdline_fixed_string_t txsplit;
3784 cmdline_fixed_string_t mode;
3788 cmd_set_txsplit_parsed(void *parsed_result,
3789 __attribute__((unused)) struct cmdline *cl,
3790 __attribute__((unused)) void *data)
3792 struct cmd_set_txsplit_result *res;
3794 res = parsed_result;
3795 set_tx_pkt_split(res->mode);
3798 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3799 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3800 cmd_keyword, "set");
3801 cmdline_parse_token_string_t cmd_set_txsplit_name =
3802 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3803 txsplit, "txsplit");
3804 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3805 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3808 cmdline_parse_inst_t cmd_set_txsplit = {
3809 .f = cmd_set_txsplit_parsed,
3811 .help_str = "set txsplit on|off|rand",
3813 (void *)&cmd_set_txsplit_keyword,
3814 (void *)&cmd_set_txsplit_name,
3815 (void *)&cmd_set_txsplit_mode,
3820 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3821 struct cmd_rx_vlan_filter_all_result {
3822 cmdline_fixed_string_t rx_vlan;
3823 cmdline_fixed_string_t what;
3824 cmdline_fixed_string_t all;
3829 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3830 __attribute__((unused)) struct cmdline *cl,
3831 __attribute__((unused)) void *data)
3833 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3835 if (!strcmp(res->what, "add"))
3836 rx_vlan_all_filter_set(res->port_id, 1);
3838 rx_vlan_all_filter_set(res->port_id, 0);
3841 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3842 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3843 rx_vlan, "rx_vlan");
3844 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3845 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3847 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3848 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3850 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3851 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3854 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3855 .f = cmd_rx_vlan_filter_all_parsed,
3857 .help_str = "rx_vlan add|rm all <port_id>: "
3858 "Add/Remove all identifiers to/from the set of VLAN "
3859 "identifiers filtered by a port",
3861 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3862 (void *)&cmd_rx_vlan_filter_all_what,
3863 (void *)&cmd_rx_vlan_filter_all_all,
3864 (void *)&cmd_rx_vlan_filter_all_portid,
3869 /* *** VLAN OFFLOAD SET ON A PORT *** */
3870 struct cmd_vlan_offload_result {
3871 cmdline_fixed_string_t vlan;
3872 cmdline_fixed_string_t set;
3873 cmdline_fixed_string_t vlan_type;
3874 cmdline_fixed_string_t what;
3875 cmdline_fixed_string_t on;
3876 cmdline_fixed_string_t port_id;
3880 cmd_vlan_offload_parsed(void *parsed_result,
3881 __attribute__((unused)) struct cmdline *cl,
3882 __attribute__((unused)) void *data)
3885 struct cmd_vlan_offload_result *res = parsed_result;
3888 portid_t port_id = 0;
3892 len = strnlen(str, STR_TOKEN_SIZE);
3894 /* Get port_id first */
3902 tmp = strtoul(str, NULL, 0);
3903 /* If port_id greater that what portid_t can represent, return */
3904 if(tmp >= RTE_MAX_ETHPORTS)
3906 port_id = (portid_t)tmp;
3908 if (!strcmp(res->on, "on"))
3913 if (!strcmp(res->what, "strip"))
3914 rx_vlan_strip_set(port_id, on);
3915 else if(!strcmp(res->what, "stripq")){
3916 uint16_t queue_id = 0;
3918 /* No queue_id, return */
3920 printf("must specify (port,queue_id)\n");
3923 tmp = strtoul(str + i + 1, NULL, 0);
3924 /* If queue_id greater that what 16-bits can represent, return */
3928 queue_id = (uint16_t)tmp;
3929 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3931 else if (!strcmp(res->what, "filter"))
3932 rx_vlan_filter_set(port_id, on);
3933 else if (!strcmp(res->what, "qinq_strip"))
3934 rx_vlan_qinq_strip_set(port_id, on);
3936 vlan_extend_set(port_id, on);
3941 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3942 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3944 cmdline_parse_token_string_t cmd_vlan_offload_set =
3945 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3947 cmdline_parse_token_string_t cmd_vlan_offload_what =
3948 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3949 what, "strip#filter#qinq_strip#extend#stripq");
3950 cmdline_parse_token_string_t cmd_vlan_offload_on =
3951 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3953 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3954 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3957 cmdline_parse_inst_t cmd_vlan_offload = {
3958 .f = cmd_vlan_offload_parsed,
3960 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
3961 "<port_id[,queue_id]>: "
3962 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
3964 (void *)&cmd_vlan_offload_vlan,
3965 (void *)&cmd_vlan_offload_set,
3966 (void *)&cmd_vlan_offload_what,
3967 (void *)&cmd_vlan_offload_on,
3968 (void *)&cmd_vlan_offload_portid,
3973 /* *** VLAN TPID SET ON A PORT *** */
3974 struct cmd_vlan_tpid_result {
3975 cmdline_fixed_string_t vlan;
3976 cmdline_fixed_string_t set;
3977 cmdline_fixed_string_t vlan_type;
3978 cmdline_fixed_string_t what;
3984 cmd_vlan_tpid_parsed(void *parsed_result,
3985 __attribute__((unused)) struct cmdline *cl,
3986 __attribute__((unused)) void *data)
3988 struct cmd_vlan_tpid_result *res = parsed_result;
3989 enum rte_vlan_type vlan_type;
3991 if (!strcmp(res->vlan_type, "inner"))
3992 vlan_type = ETH_VLAN_TYPE_INNER;
3993 else if (!strcmp(res->vlan_type, "outer"))
3994 vlan_type = ETH_VLAN_TYPE_OUTER;
3996 printf("Unknown vlan type\n");
3999 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4002 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4003 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4005 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4006 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4008 cmdline_parse_token_string_t cmd_vlan_type =
4009 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4010 vlan_type, "inner#outer");
4011 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4012 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4014 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4015 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4017 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4018 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4021 cmdline_parse_inst_t cmd_vlan_tpid = {
4022 .f = cmd_vlan_tpid_parsed,
4024 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4025 "Set the VLAN Ether type",
4027 (void *)&cmd_vlan_tpid_vlan,
4028 (void *)&cmd_vlan_tpid_set,
4029 (void *)&cmd_vlan_type,
4030 (void *)&cmd_vlan_tpid_what,
4031 (void *)&cmd_vlan_tpid_tpid,
4032 (void *)&cmd_vlan_tpid_portid,
4037 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4038 struct cmd_rx_vlan_filter_result {
4039 cmdline_fixed_string_t rx_vlan;
4040 cmdline_fixed_string_t what;
4046 cmd_rx_vlan_filter_parsed(void *parsed_result,
4047 __attribute__((unused)) struct cmdline *cl,
4048 __attribute__((unused)) void *data)
4050 struct cmd_rx_vlan_filter_result *res = parsed_result;
4052 if (!strcmp(res->what, "add"))
4053 rx_vft_set(res->port_id, res->vlan_id, 1);
4055 rx_vft_set(res->port_id, res->vlan_id, 0);
4058 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4059 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4060 rx_vlan, "rx_vlan");
4061 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4062 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4064 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4065 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4067 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4068 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4071 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4072 .f = cmd_rx_vlan_filter_parsed,
4074 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4075 "Add/Remove a VLAN identifier to/from the set of VLAN "
4076 "identifiers filtered by a port",
4078 (void *)&cmd_rx_vlan_filter_rx_vlan,
4079 (void *)&cmd_rx_vlan_filter_what,
4080 (void *)&cmd_rx_vlan_filter_vlanid,
4081 (void *)&cmd_rx_vlan_filter_portid,
4086 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4087 struct cmd_tx_vlan_set_result {
4088 cmdline_fixed_string_t tx_vlan;
4089 cmdline_fixed_string_t set;
4095 cmd_tx_vlan_set_parsed(void *parsed_result,
4096 __attribute__((unused)) struct cmdline *cl,
4097 __attribute__((unused)) void *data)
4099 struct cmd_tx_vlan_set_result *res = parsed_result;
4101 if (!port_is_stopped(res->port_id)) {
4102 printf("Please stop port %d first\n", res->port_id);
4106 tx_vlan_set(res->port_id, res->vlan_id);
4108 cmd_reconfig_device_queue(res->port_id, 1, 1);
4111 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4112 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4113 tx_vlan, "tx_vlan");
4114 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4115 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4117 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4118 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4120 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4121 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4124 cmdline_parse_inst_t cmd_tx_vlan_set = {
4125 .f = cmd_tx_vlan_set_parsed,
4127 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4128 "Enable hardware insertion of a single VLAN header "
4129 "with a given TAG Identifier in packets sent on a port",
4131 (void *)&cmd_tx_vlan_set_tx_vlan,
4132 (void *)&cmd_tx_vlan_set_set,
4133 (void *)&cmd_tx_vlan_set_portid,
4134 (void *)&cmd_tx_vlan_set_vlanid,
4139 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4140 struct cmd_tx_vlan_set_qinq_result {
4141 cmdline_fixed_string_t tx_vlan;
4142 cmdline_fixed_string_t set;
4145 uint16_t vlan_id_outer;
4149 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4150 __attribute__((unused)) struct cmdline *cl,
4151 __attribute__((unused)) void *data)
4153 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4155 if (!port_is_stopped(res->port_id)) {
4156 printf("Please stop port %d first\n", res->port_id);
4160 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4162 cmd_reconfig_device_queue(res->port_id, 1, 1);
4165 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4166 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4167 tx_vlan, "tx_vlan");
4168 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4169 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4171 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4172 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4174 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4175 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4177 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4178 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4179 vlan_id_outer, UINT16);
4181 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4182 .f = cmd_tx_vlan_set_qinq_parsed,
4184 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4185 "Enable hardware insertion of double VLAN header "
4186 "with given TAG Identifiers in packets sent on a port",
4188 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4189 (void *)&cmd_tx_vlan_set_qinq_set,
4190 (void *)&cmd_tx_vlan_set_qinq_portid,
4191 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4192 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4197 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4198 struct cmd_tx_vlan_set_pvid_result {
4199 cmdline_fixed_string_t tx_vlan;
4200 cmdline_fixed_string_t set;
4201 cmdline_fixed_string_t pvid;
4204 cmdline_fixed_string_t mode;
4208 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4209 __attribute__((unused)) struct cmdline *cl,
4210 __attribute__((unused)) void *data)
4212 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4214 if (strcmp(res->mode, "on") == 0)
4215 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4217 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4220 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4221 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4222 tx_vlan, "tx_vlan");
4223 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4224 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4226 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4227 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4229 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4230 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4232 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4233 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4235 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4236 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4239 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4240 .f = cmd_tx_vlan_set_pvid_parsed,
4242 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4244 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4245 (void *)&cmd_tx_vlan_set_pvid_set,
4246 (void *)&cmd_tx_vlan_set_pvid_pvid,
4247 (void *)&cmd_tx_vlan_set_pvid_port_id,
4248 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4249 (void *)&cmd_tx_vlan_set_pvid_mode,
4254 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4255 struct cmd_tx_vlan_reset_result {
4256 cmdline_fixed_string_t tx_vlan;
4257 cmdline_fixed_string_t reset;
4262 cmd_tx_vlan_reset_parsed(void *parsed_result,
4263 __attribute__((unused)) struct cmdline *cl,
4264 __attribute__((unused)) void *data)
4266 struct cmd_tx_vlan_reset_result *res = parsed_result;
4268 if (!port_is_stopped(res->port_id)) {
4269 printf("Please stop port %d first\n", res->port_id);
4273 tx_vlan_reset(res->port_id);
4275 cmd_reconfig_device_queue(res->port_id, 1, 1);
4278 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4279 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4280 tx_vlan, "tx_vlan");
4281 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4282 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4284 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4285 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4288 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4289 .f = cmd_tx_vlan_reset_parsed,
4291 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4292 "VLAN header in packets sent on a port",
4294 (void *)&cmd_tx_vlan_reset_tx_vlan,
4295 (void *)&cmd_tx_vlan_reset_reset,
4296 (void *)&cmd_tx_vlan_reset_portid,
4302 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4303 struct cmd_csum_result {
4304 cmdline_fixed_string_t csum;
4305 cmdline_fixed_string_t mode;
4306 cmdline_fixed_string_t proto;
4307 cmdline_fixed_string_t hwsw;
4312 csum_show(int port_id)
4314 struct rte_eth_dev_info dev_info;
4315 uint64_t tx_offloads;
4318 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4319 printf("Parse tunnel is %s\n",
4320 (ports[port_id].parse_tunnel) ? "on" : "off");
4321 printf("IP checksum offload is %s\n",
4322 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4323 printf("UDP checksum offload is %s\n",
4324 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4325 printf("TCP checksum offload is %s\n",
4326 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4327 printf("SCTP checksum offload is %s\n",
4328 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4329 printf("Outer-Ip checksum offload is %s\n",
4330 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4331 printf("Outer-Udp checksum offload is %s\n",
4332 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4334 /* display warnings if configuration is not supported by the NIC */
4335 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4339 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4340 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4341 printf("Warning: hardware IP checksum enabled but not "
4342 "supported by port %d\n", port_id);
4344 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4345 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4346 printf("Warning: hardware UDP checksum enabled but not "
4347 "supported by port %d\n", port_id);
4349 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4350 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4351 printf("Warning: hardware TCP checksum enabled but not "
4352 "supported by port %d\n", port_id);
4354 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4355 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4356 printf("Warning: hardware SCTP checksum enabled but not "
4357 "supported by port %d\n", port_id);
4359 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4360 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4361 printf("Warning: hardware outer IP checksum enabled but not "
4362 "supported by port %d\n", port_id);
4364 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4365 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4367 printf("Warning: hardware outer UDP checksum enabled but not "
4368 "supported by port %d\n", port_id);
4373 cmd_config_queue_tx_offloads(struct rte_port *port)
4377 /* Apply queue tx offloads configuration */
4378 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4379 port->tx_conf[k].offloads =
4380 port->dev_conf.txmode.offloads;
4384 cmd_csum_parsed(void *parsed_result,
4385 __attribute__((unused)) struct cmdline *cl,
4386 __attribute__((unused)) void *data)
4388 struct cmd_csum_result *res = parsed_result;
4390 uint64_t csum_offloads = 0;
4391 struct rte_eth_dev_info dev_info;
4394 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4395 printf("invalid port %d\n", res->port_id);
4398 if (!port_is_stopped(res->port_id)) {
4399 printf("Please stop port %d first\n", res->port_id);
4403 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4407 if (!strcmp(res->mode, "set")) {
4409 if (!strcmp(res->hwsw, "hw"))
4412 if (!strcmp(res->proto, "ip")) {
4413 if (hw == 0 || (dev_info.tx_offload_capa &
4414 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4415 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4417 printf("IP checksum offload is not supported "
4418 "by port %u\n", res->port_id);
4420 } else if (!strcmp(res->proto, "udp")) {
4421 if (hw == 0 || (dev_info.tx_offload_capa &
4422 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4423 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4425 printf("UDP checksum offload is not supported "
4426 "by port %u\n", res->port_id);
4428 } else if (!strcmp(res->proto, "tcp")) {
4429 if (hw == 0 || (dev_info.tx_offload_capa &
4430 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4431 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4433 printf("TCP checksum offload is not supported "
4434 "by port %u\n", res->port_id);
4436 } else if (!strcmp(res->proto, "sctp")) {
4437 if (hw == 0 || (dev_info.tx_offload_capa &
4438 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4439 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4441 printf("SCTP checksum offload is not supported "
4442 "by port %u\n", res->port_id);
4444 } else if (!strcmp(res->proto, "outer-ip")) {
4445 if (hw == 0 || (dev_info.tx_offload_capa &
4446 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4448 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4450 printf("Outer IP checksum offload is not "
4451 "supported by port %u\n", res->port_id);
4453 } else if (!strcmp(res->proto, "outer-udp")) {
4454 if (hw == 0 || (dev_info.tx_offload_capa &
4455 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4457 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4459 printf("Outer UDP checksum offload is not "
4460 "supported by port %u\n", res->port_id);
4465 ports[res->port_id].dev_conf.txmode.offloads |=
4468 ports[res->port_id].dev_conf.txmode.offloads &=
4471 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4473 csum_show(res->port_id);
4475 cmd_reconfig_device_queue(res->port_id, 1, 1);
4478 cmdline_parse_token_string_t cmd_csum_csum =
4479 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4481 cmdline_parse_token_string_t cmd_csum_mode =
4482 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4484 cmdline_parse_token_string_t cmd_csum_proto =
4485 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4486 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4487 cmdline_parse_token_string_t cmd_csum_hwsw =
4488 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4490 cmdline_parse_token_num_t cmd_csum_portid =
4491 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4494 cmdline_parse_inst_t cmd_csum_set = {
4495 .f = cmd_csum_parsed,
4497 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4498 "Enable/Disable hardware calculation of L3/L4 checksum when "
4499 "using csum forward engine",
4501 (void *)&cmd_csum_csum,
4502 (void *)&cmd_csum_mode,
4503 (void *)&cmd_csum_proto,
4504 (void *)&cmd_csum_hwsw,
4505 (void *)&cmd_csum_portid,
4510 cmdline_parse_token_string_t cmd_csum_mode_show =
4511 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4514 cmdline_parse_inst_t cmd_csum_show = {
4515 .f = cmd_csum_parsed,
4517 .help_str = "csum show <port_id>: Show checksum offload configuration",
4519 (void *)&cmd_csum_csum,
4520 (void *)&cmd_csum_mode_show,
4521 (void *)&cmd_csum_portid,
4526 /* Enable/disable tunnel parsing */
4527 struct cmd_csum_tunnel_result {
4528 cmdline_fixed_string_t csum;
4529 cmdline_fixed_string_t parse;
4530 cmdline_fixed_string_t onoff;
4535 cmd_csum_tunnel_parsed(void *parsed_result,
4536 __attribute__((unused)) struct cmdline *cl,
4537 __attribute__((unused)) void *data)
4539 struct cmd_csum_tunnel_result *res = parsed_result;
4541 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4544 if (!strcmp(res->onoff, "on"))
4545 ports[res->port_id].parse_tunnel = 1;
4547 ports[res->port_id].parse_tunnel = 0;
4549 csum_show(res->port_id);
4552 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4553 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4555 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4556 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4557 parse, "parse-tunnel");
4558 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4559 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4561 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4562 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4565 cmdline_parse_inst_t cmd_csum_tunnel = {
4566 .f = cmd_csum_tunnel_parsed,
4568 .help_str = "csum parse-tunnel on|off <port_id>: "
4569 "Enable/Disable parsing of tunnels for csum engine",
4571 (void *)&cmd_csum_tunnel_csum,
4572 (void *)&cmd_csum_tunnel_parse,
4573 (void *)&cmd_csum_tunnel_onoff,
4574 (void *)&cmd_csum_tunnel_portid,
4579 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4580 struct cmd_tso_set_result {
4581 cmdline_fixed_string_t tso;
4582 cmdline_fixed_string_t mode;
4588 cmd_tso_set_parsed(void *parsed_result,
4589 __attribute__((unused)) struct cmdline *cl,
4590 __attribute__((unused)) void *data)
4592 struct cmd_tso_set_result *res = parsed_result;
4593 struct rte_eth_dev_info dev_info;
4596 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4598 if (!port_is_stopped(res->port_id)) {
4599 printf("Please stop port %d first\n", res->port_id);
4603 if (!strcmp(res->mode, "set"))
4604 ports[res->port_id].tso_segsz = res->tso_segsz;
4606 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4610 if ((ports[res->port_id].tso_segsz != 0) &&
4611 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4612 printf("Error: TSO is not supported by port %d\n",
4617 if (ports[res->port_id].tso_segsz == 0) {
4618 ports[res->port_id].dev_conf.txmode.offloads &=
4619 ~DEV_TX_OFFLOAD_TCP_TSO;
4620 printf("TSO for non-tunneled packets is disabled\n");
4622 ports[res->port_id].dev_conf.txmode.offloads |=
4623 DEV_TX_OFFLOAD_TCP_TSO;
4624 printf("TSO segment size for non-tunneled packets is %d\n",
4625 ports[res->port_id].tso_segsz);
4627 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4629 /* display warnings if configuration is not supported by the NIC */
4630 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4634 if ((ports[res->port_id].tso_segsz != 0) &&
4635 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4636 printf("Warning: TSO enabled but not "
4637 "supported by port %d\n", res->port_id);
4640 cmd_reconfig_device_queue(res->port_id, 1, 1);
4643 cmdline_parse_token_string_t cmd_tso_set_tso =
4644 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4646 cmdline_parse_token_string_t cmd_tso_set_mode =
4647 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4649 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4650 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4652 cmdline_parse_token_num_t cmd_tso_set_portid =
4653 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4656 cmdline_parse_inst_t cmd_tso_set = {
4657 .f = cmd_tso_set_parsed,
4659 .help_str = "tso set <tso_segsz> <port_id>: "
4660 "Set TSO segment size of non-tunneled packets for csum engine "
4663 (void *)&cmd_tso_set_tso,
4664 (void *)&cmd_tso_set_mode,
4665 (void *)&cmd_tso_set_tso_segsz,
4666 (void *)&cmd_tso_set_portid,
4671 cmdline_parse_token_string_t cmd_tso_show_mode =
4672 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4676 cmdline_parse_inst_t cmd_tso_show = {
4677 .f = cmd_tso_set_parsed,
4679 .help_str = "tso show <port_id>: "
4680 "Show TSO segment size of non-tunneled packets for csum engine",
4682 (void *)&cmd_tso_set_tso,
4683 (void *)&cmd_tso_show_mode,
4684 (void *)&cmd_tso_set_portid,
4689 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4690 struct cmd_tunnel_tso_set_result {
4691 cmdline_fixed_string_t tso;
4692 cmdline_fixed_string_t mode;
4697 static struct rte_eth_dev_info
4698 check_tunnel_tso_nic_support(portid_t port_id)
4700 struct rte_eth_dev_info dev_info;
4702 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4705 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4706 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4707 "not enabled for port %d\n", port_id);
4708 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4709 printf("Warning: GRE TUNNEL TSO not supported therefore "
4710 "not enabled for port %d\n", port_id);
4711 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4712 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4713 "not enabled for port %d\n", port_id);
4714 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4715 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4716 "not enabled for port %d\n", port_id);
4717 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4718 printf("Warning: IP TUNNEL TSO not supported therefore "
4719 "not enabled for port %d\n", port_id);
4720 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4721 printf("Warning: UDP TUNNEL TSO not supported therefore "
4722 "not enabled for port %d\n", port_id);
4727 cmd_tunnel_tso_set_parsed(void *parsed_result,
4728 __attribute__((unused)) struct cmdline *cl,
4729 __attribute__((unused)) void *data)
4731 struct cmd_tunnel_tso_set_result *res = parsed_result;
4732 struct rte_eth_dev_info dev_info;
4734 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4736 if (!port_is_stopped(res->port_id)) {
4737 printf("Please stop port %d first\n", res->port_id);
4741 if (!strcmp(res->mode, "set"))
4742 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4744 dev_info = check_tunnel_tso_nic_support(res->port_id);
4745 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4746 ports[res->port_id].dev_conf.txmode.offloads &=
4747 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4748 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4749 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4750 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4751 DEV_TX_OFFLOAD_IP_TNL_TSO |
4752 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4753 printf("TSO for tunneled packets is disabled\n");
4755 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4756 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4757 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4758 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4759 DEV_TX_OFFLOAD_IP_TNL_TSO |
4760 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4762 ports[res->port_id].dev_conf.txmode.offloads |=
4763 (tso_offloads & dev_info.tx_offload_capa);
4764 printf("TSO segment size for tunneled packets is %d\n",
4765 ports[res->port_id].tunnel_tso_segsz);
4767 /* Below conditions are needed to make it work:
4768 * (1) tunnel TSO is supported by the NIC;
4769 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4771 * (3) for tunneled pkts with outer L3 of IPv4,
4772 * "csum set outer-ip" must be set to hw, because after tso,
4773 * total_len of outer IP header is changed, and the checksum
4774 * of outer IP header calculated by sw should be wrong; that
4775 * is not necessary for IPv6 tunneled pkts because there's no
4776 * checksum in IP header anymore.
4779 if (!ports[res->port_id].parse_tunnel)
4780 printf("Warning: csum parse_tunnel must be set "
4781 "so that tunneled packets are recognized\n");
4782 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4783 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4784 printf("Warning: csum set outer-ip must be set to hw "
4785 "if outer L3 is IPv4; not necessary for IPv6\n");
4788 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4789 cmd_reconfig_device_queue(res->port_id, 1, 1);
4792 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4793 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4795 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4796 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4798 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4799 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4801 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4802 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4805 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4806 .f = cmd_tunnel_tso_set_parsed,
4808 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4809 "Set TSO segment size of tunneled packets for csum engine "
4812 (void *)&cmd_tunnel_tso_set_tso,
4813 (void *)&cmd_tunnel_tso_set_mode,
4814 (void *)&cmd_tunnel_tso_set_tso_segsz,
4815 (void *)&cmd_tunnel_tso_set_portid,
4820 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4821 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4825 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4826 .f = cmd_tunnel_tso_set_parsed,
4828 .help_str = "tunnel_tso show <port_id> "
4829 "Show TSO segment size of tunneled packets for csum engine",
4831 (void *)&cmd_tunnel_tso_set_tso,
4832 (void *)&cmd_tunnel_tso_show_mode,
4833 (void *)&cmd_tunnel_tso_set_portid,
4838 /* *** SET GRO FOR A PORT *** */
4839 struct cmd_gro_enable_result {
4840 cmdline_fixed_string_t cmd_set;
4841 cmdline_fixed_string_t cmd_port;
4842 cmdline_fixed_string_t cmd_keyword;
4843 cmdline_fixed_string_t cmd_onoff;
4848 cmd_gro_enable_parsed(void *parsed_result,
4849 __attribute__((unused)) struct cmdline *cl,
4850 __attribute__((unused)) void *data)
4852 struct cmd_gro_enable_result *res;
4854 res = parsed_result;
4855 if (!strcmp(res->cmd_keyword, "gro"))
4856 setup_gro(res->cmd_onoff, res->cmd_pid);
4859 cmdline_parse_token_string_t cmd_gro_enable_set =
4860 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4862 cmdline_parse_token_string_t cmd_gro_enable_port =
4863 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4864 cmd_keyword, "port");
4865 cmdline_parse_token_num_t cmd_gro_enable_pid =
4866 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4868 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4869 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4870 cmd_keyword, "gro");
4871 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4872 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4873 cmd_onoff, "on#off");
4875 cmdline_parse_inst_t cmd_gro_enable = {
4876 .f = cmd_gro_enable_parsed,
4878 .help_str = "set port <port_id> gro on|off",
4880 (void *)&cmd_gro_enable_set,
4881 (void *)&cmd_gro_enable_port,
4882 (void *)&cmd_gro_enable_pid,
4883 (void *)&cmd_gro_enable_keyword,
4884 (void *)&cmd_gro_enable_onoff,
4889 /* *** DISPLAY GRO CONFIGURATION *** */
4890 struct cmd_gro_show_result {
4891 cmdline_fixed_string_t cmd_show;
4892 cmdline_fixed_string_t cmd_port;
4893 cmdline_fixed_string_t cmd_keyword;
4898 cmd_gro_show_parsed(void *parsed_result,
4899 __attribute__((unused)) struct cmdline *cl,
4900 __attribute__((unused)) void *data)
4902 struct cmd_gro_show_result *res;
4904 res = parsed_result;
4905 if (!strcmp(res->cmd_keyword, "gro"))
4906 show_gro(res->cmd_pid);
4909 cmdline_parse_token_string_t cmd_gro_show_show =
4910 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4912 cmdline_parse_token_string_t cmd_gro_show_port =
4913 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4915 cmdline_parse_token_num_t cmd_gro_show_pid =
4916 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4918 cmdline_parse_token_string_t cmd_gro_show_keyword =
4919 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4920 cmd_keyword, "gro");
4922 cmdline_parse_inst_t cmd_gro_show = {
4923 .f = cmd_gro_show_parsed,
4925 .help_str = "show port <port_id> gro",
4927 (void *)&cmd_gro_show_show,
4928 (void *)&cmd_gro_show_port,
4929 (void *)&cmd_gro_show_pid,
4930 (void *)&cmd_gro_show_keyword,
4935 /* *** SET FLUSH CYCLES FOR GRO *** */
4936 struct cmd_gro_flush_result {
4937 cmdline_fixed_string_t cmd_set;
4938 cmdline_fixed_string_t cmd_keyword;
4939 cmdline_fixed_string_t cmd_flush;
4944 cmd_gro_flush_parsed(void *parsed_result,
4945 __attribute__((unused)) struct cmdline *cl,
4946 __attribute__((unused)) void *data)
4948 struct cmd_gro_flush_result *res;
4950 res = parsed_result;
4951 if ((!strcmp(res->cmd_keyword, "gro")) &&
4952 (!strcmp(res->cmd_flush, "flush")))
4953 setup_gro_flush_cycles(res->cmd_cycles);
4956 cmdline_parse_token_string_t cmd_gro_flush_set =
4957 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4959 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4960 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4961 cmd_keyword, "gro");
4962 cmdline_parse_token_string_t cmd_gro_flush_flush =
4963 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4964 cmd_flush, "flush");
4965 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4966 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4969 cmdline_parse_inst_t cmd_gro_flush = {
4970 .f = cmd_gro_flush_parsed,
4972 .help_str = "set gro flush <cycles>",
4974 (void *)&cmd_gro_flush_set,
4975 (void *)&cmd_gro_flush_keyword,
4976 (void *)&cmd_gro_flush_flush,
4977 (void *)&cmd_gro_flush_cycles,
4982 /* *** ENABLE/DISABLE GSO *** */
4983 struct cmd_gso_enable_result {
4984 cmdline_fixed_string_t cmd_set;
4985 cmdline_fixed_string_t cmd_port;
4986 cmdline_fixed_string_t cmd_keyword;
4987 cmdline_fixed_string_t cmd_mode;
4992 cmd_gso_enable_parsed(void *parsed_result,
4993 __attribute__((unused)) struct cmdline *cl,
4994 __attribute__((unused)) void *data)
4996 struct cmd_gso_enable_result *res;
4998 res = parsed_result;
4999 if (!strcmp(res->cmd_keyword, "gso"))
5000 setup_gso(res->cmd_mode, res->cmd_pid);
5003 cmdline_parse_token_string_t cmd_gso_enable_set =
5004 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5006 cmdline_parse_token_string_t cmd_gso_enable_port =
5007 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5009 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5010 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5011 cmd_keyword, "gso");
5012 cmdline_parse_token_string_t cmd_gso_enable_mode =
5013 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5014 cmd_mode, "on#off");
5015 cmdline_parse_token_num_t cmd_gso_enable_pid =
5016 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5019 cmdline_parse_inst_t cmd_gso_enable = {
5020 .f = cmd_gso_enable_parsed,
5022 .help_str = "set port <port_id> gso on|off",
5024 (void *)&cmd_gso_enable_set,
5025 (void *)&cmd_gso_enable_port,
5026 (void *)&cmd_gso_enable_pid,
5027 (void *)&cmd_gso_enable_keyword,
5028 (void *)&cmd_gso_enable_mode,
5033 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5034 struct cmd_gso_size_result {
5035 cmdline_fixed_string_t cmd_set;
5036 cmdline_fixed_string_t cmd_keyword;
5037 cmdline_fixed_string_t cmd_segsz;
5042 cmd_gso_size_parsed(void *parsed_result,
5043 __attribute__((unused)) struct cmdline *cl,
5044 __attribute__((unused)) void *data)
5046 struct cmd_gso_size_result *res = parsed_result;
5048 if (test_done == 0) {
5049 printf("Before setting GSO segsz, please first"
5050 " stop fowarding\n");
5054 if (!strcmp(res->cmd_keyword, "gso") &&
5055 !strcmp(res->cmd_segsz, "segsz")) {
5056 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5057 printf("gso_size should be larger than %zu."
5058 " Please input a legal value\n",
5059 RTE_GSO_SEG_SIZE_MIN);
5061 gso_max_segment_size = res->cmd_size;
5065 cmdline_parse_token_string_t cmd_gso_size_set =
5066 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5068 cmdline_parse_token_string_t cmd_gso_size_keyword =
5069 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5070 cmd_keyword, "gso");
5071 cmdline_parse_token_string_t cmd_gso_size_segsz =
5072 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5073 cmd_segsz, "segsz");
5074 cmdline_parse_token_num_t cmd_gso_size_size =
5075 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5078 cmdline_parse_inst_t cmd_gso_size = {
5079 .f = cmd_gso_size_parsed,
5081 .help_str = "set gso segsz <length>",
5083 (void *)&cmd_gso_size_set,
5084 (void *)&cmd_gso_size_keyword,
5085 (void *)&cmd_gso_size_segsz,
5086 (void *)&cmd_gso_size_size,
5091 /* *** SHOW GSO CONFIGURATION *** */
5092 struct cmd_gso_show_result {
5093 cmdline_fixed_string_t cmd_show;
5094 cmdline_fixed_string_t cmd_port;
5095 cmdline_fixed_string_t cmd_keyword;
5100 cmd_gso_show_parsed(void *parsed_result,
5101 __attribute__((unused)) struct cmdline *cl,
5102 __attribute__((unused)) void *data)
5104 struct cmd_gso_show_result *res = parsed_result;
5106 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5107 printf("invalid port id %u\n", res->cmd_pid);
5110 if (!strcmp(res->cmd_keyword, "gso")) {
5111 if (gso_ports[res->cmd_pid].enable) {
5112 printf("Max GSO'd packet size: %uB\n"
5113 "Supported GSO types: TCP/IPv4, "
5114 "UDP/IPv4, VxLAN with inner "
5115 "TCP/IPv4 packet, GRE with inner "
5116 "TCP/IPv4 packet\n",
5117 gso_max_segment_size);
5119 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5123 cmdline_parse_token_string_t cmd_gso_show_show =
5124 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5126 cmdline_parse_token_string_t cmd_gso_show_port =
5127 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5129 cmdline_parse_token_string_t cmd_gso_show_keyword =
5130 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5131 cmd_keyword, "gso");
5132 cmdline_parse_token_num_t cmd_gso_show_pid =
5133 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5136 cmdline_parse_inst_t cmd_gso_show = {
5137 .f = cmd_gso_show_parsed,
5139 .help_str = "show port <port_id> gso",
5141 (void *)&cmd_gso_show_show,
5142 (void *)&cmd_gso_show_port,
5143 (void *)&cmd_gso_show_pid,
5144 (void *)&cmd_gso_show_keyword,
5149 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5150 struct cmd_set_flush_rx {
5151 cmdline_fixed_string_t set;
5152 cmdline_fixed_string_t flush_rx;
5153 cmdline_fixed_string_t mode;
5157 cmd_set_flush_rx_parsed(void *parsed_result,
5158 __attribute__((unused)) struct cmdline *cl,
5159 __attribute__((unused)) void *data)
5161 struct cmd_set_flush_rx *res = parsed_result;
5162 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5165 cmdline_parse_token_string_t cmd_setflushrx_set =
5166 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5168 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5169 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5170 flush_rx, "flush_rx");
5171 cmdline_parse_token_string_t cmd_setflushrx_mode =
5172 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5176 cmdline_parse_inst_t cmd_set_flush_rx = {
5177 .f = cmd_set_flush_rx_parsed,
5178 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5181 (void *)&cmd_setflushrx_set,
5182 (void *)&cmd_setflushrx_flush_rx,
5183 (void *)&cmd_setflushrx_mode,
5188 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5189 struct cmd_set_link_check {
5190 cmdline_fixed_string_t set;
5191 cmdline_fixed_string_t link_check;
5192 cmdline_fixed_string_t mode;
5196 cmd_set_link_check_parsed(void *parsed_result,
5197 __attribute__((unused)) struct cmdline *cl,
5198 __attribute__((unused)) void *data)
5200 struct cmd_set_link_check *res = parsed_result;
5201 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5204 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5205 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5207 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5208 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5209 link_check, "link_check");
5210 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5211 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5215 cmdline_parse_inst_t cmd_set_link_check = {
5216 .f = cmd_set_link_check_parsed,
5217 .help_str = "set link_check on|off: Enable/Disable link status check "
5218 "when starting/stopping a port",
5221 (void *)&cmd_setlinkcheck_set,
5222 (void *)&cmd_setlinkcheck_link_check,
5223 (void *)&cmd_setlinkcheck_mode,
5228 /* *** SET NIC BYPASS MODE *** */
5229 struct cmd_set_bypass_mode_result {
5230 cmdline_fixed_string_t set;
5231 cmdline_fixed_string_t bypass;
5232 cmdline_fixed_string_t mode;
5233 cmdline_fixed_string_t value;
5238 cmd_set_bypass_mode_parsed(void *parsed_result,
5239 __attribute__((unused)) struct cmdline *cl,
5240 __attribute__((unused)) void *data)
5242 struct cmd_set_bypass_mode_result *res = parsed_result;
5243 portid_t port_id = res->port_id;
5244 int32_t rc = -EINVAL;
5246 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5247 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5249 if (!strcmp(res->value, "bypass"))
5250 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5251 else if (!strcmp(res->value, "isolate"))
5252 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5254 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5256 /* Set the bypass mode for the relevant port. */
5257 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5260 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5263 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5264 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5266 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5267 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5269 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5270 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5272 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5273 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5274 value, "normal#bypass#isolate");
5275 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5276 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5279 cmdline_parse_inst_t cmd_set_bypass_mode = {
5280 .f = cmd_set_bypass_mode_parsed,
5281 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5282 "Set the NIC bypass mode for port_id",
5285 (void *)&cmd_setbypass_mode_set,
5286 (void *)&cmd_setbypass_mode_bypass,
5287 (void *)&cmd_setbypass_mode_mode,
5288 (void *)&cmd_setbypass_mode_value,
5289 (void *)&cmd_setbypass_mode_port,
5294 /* *** SET NIC BYPASS EVENT *** */
5295 struct cmd_set_bypass_event_result {
5296 cmdline_fixed_string_t set;
5297 cmdline_fixed_string_t bypass;
5298 cmdline_fixed_string_t event;
5299 cmdline_fixed_string_t event_value;
5300 cmdline_fixed_string_t mode;
5301 cmdline_fixed_string_t mode_value;
5306 cmd_set_bypass_event_parsed(void *parsed_result,
5307 __attribute__((unused)) struct cmdline *cl,
5308 __attribute__((unused)) void *data)
5310 int32_t rc = -EINVAL;
5311 struct cmd_set_bypass_event_result *res = parsed_result;
5312 portid_t port_id = res->port_id;
5314 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5315 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5316 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5318 if (!strcmp(res->event_value, "timeout"))
5319 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5320 else if (!strcmp(res->event_value, "os_on"))
5321 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5322 else if (!strcmp(res->event_value, "os_off"))
5323 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5324 else if (!strcmp(res->event_value, "power_on"))
5325 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5326 else if (!strcmp(res->event_value, "power_off"))
5327 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5329 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5331 if (!strcmp(res->mode_value, "bypass"))
5332 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5333 else if (!strcmp(res->mode_value, "isolate"))
5334 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5336 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5338 /* Set the watchdog timeout. */
5339 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5342 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5343 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5347 printf("Failed to set timeout value %u "
5348 "for port %d, errto code: %d.\n",
5349 bypass_timeout, port_id, rc);
5353 /* Set the bypass event to transition to bypass mode. */
5354 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5359 printf("\t Failed to set bypass event for port = %d.\n",
5363 cmdline_parse_token_string_t cmd_setbypass_event_set =
5364 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5366 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5367 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5369 cmdline_parse_token_string_t cmd_setbypass_event_event =
5370 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5372 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5373 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5374 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5375 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5376 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5378 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5379 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5380 mode_value, "normal#bypass#isolate");
5381 cmdline_parse_token_num_t cmd_setbypass_event_port =
5382 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5385 cmdline_parse_inst_t cmd_set_bypass_event = {
5386 .f = cmd_set_bypass_event_parsed,
5387 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5388 "power_off mode normal|bypass|isolate <port_id>: "
5389 "Set the NIC bypass event mode for port_id",
5392 (void *)&cmd_setbypass_event_set,
5393 (void *)&cmd_setbypass_event_bypass,
5394 (void *)&cmd_setbypass_event_event,
5395 (void *)&cmd_setbypass_event_event_value,
5396 (void *)&cmd_setbypass_event_mode,
5397 (void *)&cmd_setbypass_event_mode_value,
5398 (void *)&cmd_setbypass_event_port,
5404 /* *** SET NIC BYPASS TIMEOUT *** */
5405 struct cmd_set_bypass_timeout_result {
5406 cmdline_fixed_string_t set;
5407 cmdline_fixed_string_t bypass;
5408 cmdline_fixed_string_t timeout;
5409 cmdline_fixed_string_t value;
5413 cmd_set_bypass_timeout_parsed(void *parsed_result,
5414 __attribute__((unused)) struct cmdline *cl,
5415 __attribute__((unused)) void *data)
5417 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5419 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5420 if (!strcmp(res->value, "1.5"))
5421 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5422 else if (!strcmp(res->value, "2"))
5423 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5424 else if (!strcmp(res->value, "3"))
5425 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5426 else if (!strcmp(res->value, "4"))
5427 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5428 else if (!strcmp(res->value, "8"))
5429 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5430 else if (!strcmp(res->value, "16"))
5431 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5432 else if (!strcmp(res->value, "32"))
5433 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5435 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5439 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5440 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5442 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5443 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5445 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5446 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5447 timeout, "timeout");
5448 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5449 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5450 value, "0#1.5#2#3#4#8#16#32");
5452 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5453 .f = cmd_set_bypass_timeout_parsed,
5454 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5455 "Set the NIC bypass watchdog timeout in seconds",
5458 (void *)&cmd_setbypass_timeout_set,
5459 (void *)&cmd_setbypass_timeout_bypass,
5460 (void *)&cmd_setbypass_timeout_timeout,
5461 (void *)&cmd_setbypass_timeout_value,
5466 /* *** SHOW NIC BYPASS MODE *** */
5467 struct cmd_show_bypass_config_result {
5468 cmdline_fixed_string_t show;
5469 cmdline_fixed_string_t bypass;
5470 cmdline_fixed_string_t config;
5475 cmd_show_bypass_config_parsed(void *parsed_result,
5476 __attribute__((unused)) struct cmdline *cl,
5477 __attribute__((unused)) void *data)
5479 struct cmd_show_bypass_config_result *res = parsed_result;
5480 portid_t port_id = res->port_id;
5482 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5483 uint32_t event_mode;
5484 uint32_t bypass_mode;
5485 uint32_t timeout = bypass_timeout;
5488 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5489 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5490 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5491 {"UNKNOWN", "normal", "bypass", "isolate"};
5492 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5499 int num_events = (sizeof events) / (sizeof events[0]);
5501 /* Display the bypass mode.*/
5502 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5503 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5507 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5508 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5510 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5513 /* Display the bypass timeout.*/
5514 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5515 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5517 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5519 /* Display the bypass events and associated modes. */
5520 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5522 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5523 printf("\tFailed to get bypass mode for event = %s\n",
5526 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5527 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5529 printf("\tbypass event: %-16s = %s\n", events[i],
5535 printf("\tFailed to get bypass configuration for port = %d\n",
5539 cmdline_parse_token_string_t cmd_showbypass_config_show =
5540 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5542 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5543 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5545 cmdline_parse_token_string_t cmd_showbypass_config_config =
5546 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5548 cmdline_parse_token_num_t cmd_showbypass_config_port =
5549 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5552 cmdline_parse_inst_t cmd_show_bypass_config = {
5553 .f = cmd_show_bypass_config_parsed,
5554 .help_str = "show bypass config <port_id>: "
5555 "Show the NIC bypass config for port_id",
5558 (void *)&cmd_showbypass_config_show,
5559 (void *)&cmd_showbypass_config_bypass,
5560 (void *)&cmd_showbypass_config_config,
5561 (void *)&cmd_showbypass_config_port,
5566 #ifdef RTE_LIBRTE_PMD_BOND
5567 /* *** SET BONDING MODE *** */
5568 struct cmd_set_bonding_mode_result {
5569 cmdline_fixed_string_t set;
5570 cmdline_fixed_string_t bonding;
5571 cmdline_fixed_string_t mode;
5576 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5577 __attribute__((unused)) struct cmdline *cl,
5578 __attribute__((unused)) void *data)
5580 struct cmd_set_bonding_mode_result *res = parsed_result;
5581 portid_t port_id = res->port_id;
5583 /* Set the bonding mode for the relevant port. */
5584 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5585 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5588 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5589 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5591 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5592 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5593 bonding, "bonding");
5594 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5595 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5597 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5598 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5600 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5601 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5604 cmdline_parse_inst_t cmd_set_bonding_mode = {
5605 .f = cmd_set_bonding_mode_parsed,
5606 .help_str = "set bonding mode <mode_value> <port_id>: "
5607 "Set the bonding mode for port_id",
5610 (void *) &cmd_setbonding_mode_set,
5611 (void *) &cmd_setbonding_mode_bonding,
5612 (void *) &cmd_setbonding_mode_mode,
5613 (void *) &cmd_setbonding_mode_value,
5614 (void *) &cmd_setbonding_mode_port,
5619 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5620 struct cmd_set_bonding_lacp_dedicated_queues_result {
5621 cmdline_fixed_string_t set;
5622 cmdline_fixed_string_t bonding;
5623 cmdline_fixed_string_t lacp;
5624 cmdline_fixed_string_t dedicated_queues;
5626 cmdline_fixed_string_t mode;
5629 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5630 __attribute__((unused)) struct cmdline *cl,
5631 __attribute__((unused)) void *data)
5633 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5634 portid_t port_id = res->port_id;
5635 struct rte_port *port;
5637 port = &ports[port_id];
5639 /** Check if the port is not started **/
5640 if (port->port_status != RTE_PORT_STOPPED) {
5641 printf("Please stop port %d first\n", port_id);
5645 if (!strcmp(res->mode, "enable")) {
5646 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5647 printf("Dedicate queues for LACP control packets"
5650 printf("Enabling dedicate queues for LACP control "
5651 "packets on port %d failed\n", port_id);
5652 } else if (!strcmp(res->mode, "disable")) {
5653 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5654 printf("Dedicated queues for LACP control packets "
5657 printf("Disabling dedicated queues for LACP control "
5658 "traffic on port %d failed\n", port_id);
5662 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5663 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5665 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5666 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5667 bonding, "bonding");
5668 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5669 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5671 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5672 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5673 dedicated_queues, "dedicated_queues");
5674 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5675 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5677 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5678 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5679 mode, "enable#disable");
5681 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5682 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5683 .help_str = "set bonding lacp dedicated_queues <port_id> "
5685 "Enable/disable dedicated queues for LACP control traffic for port_id",
5688 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5689 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5690 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5691 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5692 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5693 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5698 /* *** SET BALANCE XMIT POLICY *** */
5699 struct cmd_set_bonding_balance_xmit_policy_result {
5700 cmdline_fixed_string_t set;
5701 cmdline_fixed_string_t bonding;
5702 cmdline_fixed_string_t balance_xmit_policy;
5704 cmdline_fixed_string_t policy;
5707 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5708 __attribute__((unused)) struct cmdline *cl,
5709 __attribute__((unused)) void *data)
5711 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5712 portid_t port_id = res->port_id;
5715 if (!strcmp(res->policy, "l2")) {
5716 policy = BALANCE_XMIT_POLICY_LAYER2;
5717 } else if (!strcmp(res->policy, "l23")) {
5718 policy = BALANCE_XMIT_POLICY_LAYER23;
5719 } else if (!strcmp(res->policy, "l34")) {
5720 policy = BALANCE_XMIT_POLICY_LAYER34;
5722 printf("\t Invalid xmit policy selection");
5726 /* Set the bonding mode for the relevant port. */
5727 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5728 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5733 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5734 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5736 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5737 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5738 bonding, "bonding");
5739 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5740 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5741 balance_xmit_policy, "balance_xmit_policy");
5742 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5743 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5745 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5746 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5747 policy, "l2#l23#l34");
5749 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5750 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5751 .help_str = "set bonding balance_xmit_policy <port_id> "
5753 "Set the bonding balance_xmit_policy for port_id",
5756 (void *)&cmd_setbonding_balance_xmit_policy_set,
5757 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5758 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5759 (void *)&cmd_setbonding_balance_xmit_policy_port,
5760 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5765 /* *** SHOW NIC BONDING CONFIGURATION *** */
5766 struct cmd_show_bonding_config_result {
5767 cmdline_fixed_string_t show;
5768 cmdline_fixed_string_t bonding;
5769 cmdline_fixed_string_t config;
5773 static void cmd_show_bonding_config_parsed(void *parsed_result,
5774 __attribute__((unused)) struct cmdline *cl,
5775 __attribute__((unused)) void *data)
5777 struct cmd_show_bonding_config_result *res = parsed_result;
5778 int bonding_mode, agg_mode;
5779 portid_t slaves[RTE_MAX_ETHPORTS];
5780 int num_slaves, num_active_slaves;
5783 portid_t port_id = res->port_id;
5785 /* Display the bonding mode.*/
5786 bonding_mode = rte_eth_bond_mode_get(port_id);
5787 if (bonding_mode < 0) {
5788 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5791 printf("\tBonding mode: %d\n", bonding_mode);
5793 if (bonding_mode == BONDING_MODE_BALANCE) {
5794 int balance_xmit_policy;
5796 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5797 if (balance_xmit_policy < 0) {
5798 printf("\tFailed to get balance xmit policy for port = %d\n",
5802 printf("\tBalance Xmit Policy: ");
5804 switch (balance_xmit_policy) {
5805 case BALANCE_XMIT_POLICY_LAYER2:
5806 printf("BALANCE_XMIT_POLICY_LAYER2");
5808 case BALANCE_XMIT_POLICY_LAYER23:
5809 printf("BALANCE_XMIT_POLICY_LAYER23");
5811 case BALANCE_XMIT_POLICY_LAYER34:
5812 printf("BALANCE_XMIT_POLICY_LAYER34");
5819 if (bonding_mode == BONDING_MODE_8023AD) {
5820 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5821 printf("\tIEEE802.3AD Aggregator Mode: ");
5824 printf("bandwidth");
5836 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5838 if (num_slaves < 0) {
5839 printf("\tFailed to get slave list for port = %d\n", port_id);
5842 if (num_slaves > 0) {
5843 printf("\tSlaves (%d): [", num_slaves);
5844 for (i = 0; i < num_slaves - 1; i++)
5845 printf("%d ", slaves[i]);
5847 printf("%d]\n", slaves[num_slaves - 1]);
5849 printf("\tSlaves: []\n");
5853 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5856 if (num_active_slaves < 0) {
5857 printf("\tFailed to get active slave list for port = %d\n", port_id);
5860 if (num_active_slaves > 0) {
5861 printf("\tActive Slaves (%d): [", num_active_slaves);
5862 for (i = 0; i < num_active_slaves - 1; i++)
5863 printf("%d ", slaves[i]);
5865 printf("%d]\n", slaves[num_active_slaves - 1]);
5868 printf("\tActive Slaves: []\n");
5872 primary_id = rte_eth_bond_primary_get(port_id);
5873 if (primary_id < 0) {
5874 printf("\tFailed to get primary slave for port = %d\n", port_id);
5877 printf("\tPrimary: [%d]\n", primary_id);
5881 cmdline_parse_token_string_t cmd_showbonding_config_show =
5882 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5884 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5885 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5886 bonding, "bonding");
5887 cmdline_parse_token_string_t cmd_showbonding_config_config =
5888 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5890 cmdline_parse_token_num_t cmd_showbonding_config_port =
5891 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5894 cmdline_parse_inst_t cmd_show_bonding_config = {
5895 .f = cmd_show_bonding_config_parsed,
5896 .help_str = "show bonding config <port_id>: "
5897 "Show the bonding config for port_id",
5900 (void *)&cmd_showbonding_config_show,
5901 (void *)&cmd_showbonding_config_bonding,
5902 (void *)&cmd_showbonding_config_config,
5903 (void *)&cmd_showbonding_config_port,
5908 /* *** SET BONDING PRIMARY *** */
5909 struct cmd_set_bonding_primary_result {
5910 cmdline_fixed_string_t set;
5911 cmdline_fixed_string_t bonding;
5912 cmdline_fixed_string_t primary;
5917 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5918 __attribute__((unused)) struct cmdline *cl,
5919 __attribute__((unused)) void *data)
5921 struct cmd_set_bonding_primary_result *res = parsed_result;
5922 portid_t master_port_id = res->port_id;
5923 portid_t slave_port_id = res->slave_id;
5925 /* Set the primary slave for a bonded device. */
5926 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5927 printf("\t Failed to set primary slave for port = %d.\n",
5934 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5935 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5937 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5938 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5939 bonding, "bonding");
5940 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5941 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5942 primary, "primary");
5943 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5944 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5946 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5947 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5950 cmdline_parse_inst_t cmd_set_bonding_primary = {
5951 .f = cmd_set_bonding_primary_parsed,
5952 .help_str = "set bonding primary <slave_id> <port_id>: "
5953 "Set the primary slave for port_id",
5956 (void *)&cmd_setbonding_primary_set,
5957 (void *)&cmd_setbonding_primary_bonding,
5958 (void *)&cmd_setbonding_primary_primary,
5959 (void *)&cmd_setbonding_primary_slave,
5960 (void *)&cmd_setbonding_primary_port,
5965 /* *** ADD SLAVE *** */
5966 struct cmd_add_bonding_slave_result {
5967 cmdline_fixed_string_t add;
5968 cmdline_fixed_string_t bonding;
5969 cmdline_fixed_string_t slave;
5974 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5975 __attribute__((unused)) struct cmdline *cl,
5976 __attribute__((unused)) void *data)
5978 struct cmd_add_bonding_slave_result *res = parsed_result;
5979 portid_t master_port_id = res->port_id;
5980 portid_t slave_port_id = res->slave_id;
5982 /* add the slave for a bonded device. */
5983 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5984 printf("\t Failed to add slave %d to master port = %d.\n",
5985 slave_port_id, master_port_id);
5989 set_port_slave_flag(slave_port_id);
5992 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5993 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5995 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5996 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5997 bonding, "bonding");
5998 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5999 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6001 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6002 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6004 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6005 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6008 cmdline_parse_inst_t cmd_add_bonding_slave = {
6009 .f = cmd_add_bonding_slave_parsed,
6010 .help_str = "add bonding slave <slave_id> <port_id>: "
6011 "Add a slave device to a bonded device",
6014 (void *)&cmd_addbonding_slave_add,
6015 (void *)&cmd_addbonding_slave_bonding,
6016 (void *)&cmd_addbonding_slave_slave,
6017 (void *)&cmd_addbonding_slave_slaveid,
6018 (void *)&cmd_addbonding_slave_port,
6023 /* *** REMOVE SLAVE *** */
6024 struct cmd_remove_bonding_slave_result {
6025 cmdline_fixed_string_t remove;
6026 cmdline_fixed_string_t bonding;
6027 cmdline_fixed_string_t slave;
6032 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6033 __attribute__((unused)) struct cmdline *cl,
6034 __attribute__((unused)) void *data)
6036 struct cmd_remove_bonding_slave_result *res = parsed_result;
6037 portid_t master_port_id = res->port_id;
6038 portid_t slave_port_id = res->slave_id;
6040 /* remove the slave from a bonded device. */
6041 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6042 printf("\t Failed to remove slave %d from master port = %d.\n",
6043 slave_port_id, master_port_id);
6047 clear_port_slave_flag(slave_port_id);
6050 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6051 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6053 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6054 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6055 bonding, "bonding");
6056 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6057 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6059 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6060 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6062 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6063 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6066 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6067 .f = cmd_remove_bonding_slave_parsed,
6068 .help_str = "remove bonding slave <slave_id> <port_id>: "
6069 "Remove a slave device from a bonded device",
6072 (void *)&cmd_removebonding_slave_remove,
6073 (void *)&cmd_removebonding_slave_bonding,
6074 (void *)&cmd_removebonding_slave_slave,
6075 (void *)&cmd_removebonding_slave_slaveid,
6076 (void *)&cmd_removebonding_slave_port,
6081 /* *** CREATE BONDED DEVICE *** */
6082 struct cmd_create_bonded_device_result {
6083 cmdline_fixed_string_t create;
6084 cmdline_fixed_string_t bonded;
6085 cmdline_fixed_string_t device;
6090 static int bond_dev_num = 0;
6092 static void cmd_create_bonded_device_parsed(void *parsed_result,
6093 __attribute__((unused)) struct cmdline *cl,
6094 __attribute__((unused)) void *data)
6096 struct cmd_create_bonded_device_result *res = parsed_result;
6097 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6101 if (test_done == 0) {
6102 printf("Please stop forwarding first\n");
6106 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6109 /* Create a new bonded device. */
6110 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6112 printf("\t Failed to create bonded device.\n");
6115 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6118 /* Update number of ports */
6119 nb_ports = rte_eth_dev_count_avail();
6120 reconfig(port_id, res->socket);
6121 ret = rte_eth_promiscuous_enable(port_id);
6123 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6124 port_id, rte_strerror(-ret));
6126 ports[port_id].need_setup = 0;
6127 ports[port_id].port_status = RTE_PORT_STOPPED;
6132 cmdline_parse_token_string_t cmd_createbonded_device_create =
6133 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6135 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6136 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6138 cmdline_parse_token_string_t cmd_createbonded_device_device =
6139 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6141 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6142 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6144 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6145 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6148 cmdline_parse_inst_t cmd_create_bonded_device = {
6149 .f = cmd_create_bonded_device_parsed,
6150 .help_str = "create bonded device <mode> <socket>: "
6151 "Create a new bonded device with specific bonding mode and socket",
6154 (void *)&cmd_createbonded_device_create,
6155 (void *)&cmd_createbonded_device_bonded,
6156 (void *)&cmd_createbonded_device_device,
6157 (void *)&cmd_createbonded_device_mode,
6158 (void *)&cmd_createbonded_device_socket,
6163 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6164 struct cmd_set_bond_mac_addr_result {
6165 cmdline_fixed_string_t set;
6166 cmdline_fixed_string_t bonding;
6167 cmdline_fixed_string_t mac_addr;
6169 struct rte_ether_addr address;
6172 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6173 __attribute__((unused)) struct cmdline *cl,
6174 __attribute__((unused)) void *data)
6176 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6179 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6182 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6184 /* check the return value and print it if is < 0 */
6186 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6189 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6190 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6191 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6192 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6194 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6195 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6197 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6198 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6200 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6201 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6203 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6204 .f = cmd_set_bond_mac_addr_parsed,
6206 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6208 (void *)&cmd_set_bond_mac_addr_set,
6209 (void *)&cmd_set_bond_mac_addr_bonding,
6210 (void *)&cmd_set_bond_mac_addr_mac,
6211 (void *)&cmd_set_bond_mac_addr_portnum,
6212 (void *)&cmd_set_bond_mac_addr_addr,
6218 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6219 struct cmd_set_bond_mon_period_result {
6220 cmdline_fixed_string_t set;
6221 cmdline_fixed_string_t bonding;
6222 cmdline_fixed_string_t mon_period;
6227 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6228 __attribute__((unused)) struct cmdline *cl,
6229 __attribute__((unused)) void *data)
6231 struct cmd_set_bond_mon_period_result *res = parsed_result;
6234 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6236 /* check the return value and print it if is < 0 */
6238 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6241 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6242 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6244 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6245 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6246 bonding, "bonding");
6247 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6248 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6249 mon_period, "mon_period");
6250 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6251 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6253 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6254 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6257 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6258 .f = cmd_set_bond_mon_period_parsed,
6260 .help_str = "set bonding mon_period <port_id> <period_ms>",
6262 (void *)&cmd_set_bond_mon_period_set,
6263 (void *)&cmd_set_bond_mon_period_bonding,
6264 (void *)&cmd_set_bond_mon_period_mon_period,
6265 (void *)&cmd_set_bond_mon_period_portnum,
6266 (void *)&cmd_set_bond_mon_period_period_ms,
6273 struct cmd_set_bonding_agg_mode_policy_result {
6274 cmdline_fixed_string_t set;
6275 cmdline_fixed_string_t bonding;
6276 cmdline_fixed_string_t agg_mode;
6278 cmdline_fixed_string_t policy;
6283 cmd_set_bonding_agg_mode(void *parsed_result,
6284 __attribute__((unused)) struct cmdline *cl,
6285 __attribute__((unused)) void *data)
6287 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6288 uint8_t policy = AGG_BANDWIDTH;
6290 if (!strcmp(res->policy, "bandwidth"))
6291 policy = AGG_BANDWIDTH;
6292 else if (!strcmp(res->policy, "stable"))
6293 policy = AGG_STABLE;
6294 else if (!strcmp(res->policy, "count"))
6297 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6301 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6302 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6304 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6305 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6306 bonding, "bonding");
6308 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6309 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6310 agg_mode, "agg_mode");
6312 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6313 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6316 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6317 TOKEN_STRING_INITIALIZER(
6318 struct cmd_set_bonding_balance_xmit_policy_result,
6319 policy, "stable#bandwidth#count");
6321 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6322 .f = cmd_set_bonding_agg_mode,
6324 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6326 (void *)&cmd_set_bonding_agg_mode_set,
6327 (void *)&cmd_set_bonding_agg_mode_bonding,
6328 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6329 (void *)&cmd_set_bonding_agg_mode_portnum,
6330 (void *)&cmd_set_bonding_agg_mode_policy_string,
6336 #endif /* RTE_LIBRTE_PMD_BOND */
6338 /* *** SET FORWARDING MODE *** */
6339 struct cmd_set_fwd_mode_result {
6340 cmdline_fixed_string_t set;
6341 cmdline_fixed_string_t fwd;
6342 cmdline_fixed_string_t mode;
6345 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6346 __attribute__((unused)) struct cmdline *cl,
6347 __attribute__((unused)) void *data)
6349 struct cmd_set_fwd_mode_result *res = parsed_result;
6352 set_pkt_forwarding_mode(res->mode);
6355 cmdline_parse_token_string_t cmd_setfwd_set =
6356 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6357 cmdline_parse_token_string_t cmd_setfwd_fwd =
6358 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6359 cmdline_parse_token_string_t cmd_setfwd_mode =
6360 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6361 "" /* defined at init */);
6363 cmdline_parse_inst_t cmd_set_fwd_mode = {
6364 .f = cmd_set_fwd_mode_parsed,
6366 .help_str = NULL, /* defined at init */
6368 (void *)&cmd_setfwd_set,
6369 (void *)&cmd_setfwd_fwd,
6370 (void *)&cmd_setfwd_mode,
6375 static void cmd_set_fwd_mode_init(void)
6378 static char token[128];
6379 static char help[256];
6380 cmdline_parse_token_string_t *token_struct;
6382 modes = list_pkt_forwarding_modes();
6383 snprintf(help, sizeof(help), "set fwd %s: "
6384 "Set packet forwarding mode", modes);
6385 cmd_set_fwd_mode.help_str = help;
6387 /* string token separator is # */
6388 for (c = token; *modes != '\0'; modes++)
6393 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6394 token_struct->string_data.str = token;
6397 /* *** SET RETRY FORWARDING MODE *** */
6398 struct cmd_set_fwd_retry_mode_result {
6399 cmdline_fixed_string_t set;
6400 cmdline_fixed_string_t fwd;
6401 cmdline_fixed_string_t mode;
6402 cmdline_fixed_string_t retry;
6405 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6406 __attribute__((unused)) struct cmdline *cl,
6407 __attribute__((unused)) void *data)
6409 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6412 set_pkt_forwarding_mode(res->mode);
6415 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6416 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6418 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6419 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6421 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6422 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6424 "" /* defined at init */);
6425 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6426 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6429 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6430 .f = cmd_set_fwd_retry_mode_parsed,
6432 .help_str = NULL, /* defined at init */
6434 (void *)&cmd_setfwd_retry_set,
6435 (void *)&cmd_setfwd_retry_fwd,
6436 (void *)&cmd_setfwd_retry_mode,
6437 (void *)&cmd_setfwd_retry_retry,
6442 static void cmd_set_fwd_retry_mode_init(void)
6445 static char token[128];
6446 static char help[256];
6447 cmdline_parse_token_string_t *token_struct;
6449 modes = list_pkt_forwarding_retry_modes();
6450 snprintf(help, sizeof(help), "set fwd %s retry: "
6451 "Set packet forwarding mode with retry", modes);
6452 cmd_set_fwd_retry_mode.help_str = help;
6454 /* string token separator is # */
6455 for (c = token; *modes != '\0'; modes++)
6460 token_struct = (cmdline_parse_token_string_t *)
6461 cmd_set_fwd_retry_mode.tokens[2];
6462 token_struct->string_data.str = token;
6465 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6466 struct cmd_set_burst_tx_retry_result {
6467 cmdline_fixed_string_t set;
6468 cmdline_fixed_string_t burst;
6469 cmdline_fixed_string_t tx;
6470 cmdline_fixed_string_t delay;
6472 cmdline_fixed_string_t retry;
6476 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6477 __attribute__((unused)) struct cmdline *cl,
6478 __attribute__((unused)) void *data)
6480 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6482 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6483 && !strcmp(res->tx, "tx")) {
6484 if (!strcmp(res->delay, "delay"))
6485 burst_tx_delay_time = res->time;
6486 if (!strcmp(res->retry, "retry"))
6487 burst_tx_retry_num = res->retry_num;
6492 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6493 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6494 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6495 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6497 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6498 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6499 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6500 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6501 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6502 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6503 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6504 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6505 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6506 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6508 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6509 .f = cmd_set_burst_tx_retry_parsed,
6510 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6512 (void *)&cmd_set_burst_tx_retry_set,
6513 (void *)&cmd_set_burst_tx_retry_burst,
6514 (void *)&cmd_set_burst_tx_retry_tx,
6515 (void *)&cmd_set_burst_tx_retry_delay,
6516 (void *)&cmd_set_burst_tx_retry_time,
6517 (void *)&cmd_set_burst_tx_retry_retry,
6518 (void *)&cmd_set_burst_tx_retry_retry_num,
6523 /* *** SET PROMISC MODE *** */
6524 struct cmd_set_promisc_mode_result {
6525 cmdline_fixed_string_t set;
6526 cmdline_fixed_string_t promisc;
6527 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6528 uint16_t port_num; /* valid if "allports" argument == 0 */
6529 cmdline_fixed_string_t mode;
6532 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6533 __attribute__((unused)) struct cmdline *cl,
6536 struct cmd_set_promisc_mode_result *res = parsed_result;
6540 if (!strcmp(res->mode, "on"))
6547 RTE_ETH_FOREACH_DEV(i)
6548 eth_set_promisc_mode(i, enable);
6550 eth_set_promisc_mode(res->port_num, enable);
6554 cmdline_parse_token_string_t cmd_setpromisc_set =
6555 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6556 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6557 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6559 cmdline_parse_token_string_t cmd_setpromisc_portall =
6560 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6562 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6563 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6565 cmdline_parse_token_string_t cmd_setpromisc_mode =
6566 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6569 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6570 .f = cmd_set_promisc_mode_parsed,
6572 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6574 (void *)&cmd_setpromisc_set,
6575 (void *)&cmd_setpromisc_promisc,
6576 (void *)&cmd_setpromisc_portall,
6577 (void *)&cmd_setpromisc_mode,
6582 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6583 .f = cmd_set_promisc_mode_parsed,
6585 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6587 (void *)&cmd_setpromisc_set,
6588 (void *)&cmd_setpromisc_promisc,
6589 (void *)&cmd_setpromisc_portnum,
6590 (void *)&cmd_setpromisc_mode,
6595 /* *** SET ALLMULTI MODE *** */
6596 struct cmd_set_allmulti_mode_result {
6597 cmdline_fixed_string_t set;
6598 cmdline_fixed_string_t allmulti;
6599 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6600 uint16_t port_num; /* valid if "allports" argument == 0 */
6601 cmdline_fixed_string_t mode;
6604 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6605 __attribute__((unused)) struct cmdline *cl,
6608 struct cmd_set_allmulti_mode_result *res = parsed_result;
6612 if (!strcmp(res->mode, "on"))
6619 RTE_ETH_FOREACH_DEV(i) {
6620 eth_set_allmulticast_mode(i, enable);
6624 eth_set_allmulticast_mode(res->port_num, enable);
6628 cmdline_parse_token_string_t cmd_setallmulti_set =
6629 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6630 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6631 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6633 cmdline_parse_token_string_t cmd_setallmulti_portall =
6634 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6636 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6637 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6639 cmdline_parse_token_string_t cmd_setallmulti_mode =
6640 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6643 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6644 .f = cmd_set_allmulti_mode_parsed,
6646 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6648 (void *)&cmd_setallmulti_set,
6649 (void *)&cmd_setallmulti_allmulti,
6650 (void *)&cmd_setallmulti_portall,
6651 (void *)&cmd_setallmulti_mode,
6656 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6657 .f = cmd_set_allmulti_mode_parsed,
6659 .help_str = "set allmulti <port_id> on|off: "
6660 "Set allmulti mode on port_id",
6662 (void *)&cmd_setallmulti_set,
6663 (void *)&cmd_setallmulti_allmulti,
6664 (void *)&cmd_setallmulti_portnum,
6665 (void *)&cmd_setallmulti_mode,
6670 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6671 struct cmd_link_flow_ctrl_set_result {
6672 cmdline_fixed_string_t set;
6673 cmdline_fixed_string_t flow_ctrl;
6674 cmdline_fixed_string_t rx;
6675 cmdline_fixed_string_t rx_lfc_mode;
6676 cmdline_fixed_string_t tx;
6677 cmdline_fixed_string_t tx_lfc_mode;
6678 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6679 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6680 cmdline_fixed_string_t autoneg_str;
6681 cmdline_fixed_string_t autoneg;
6682 cmdline_fixed_string_t hw_str;
6683 uint32_t high_water;
6684 cmdline_fixed_string_t lw_str;
6686 cmdline_fixed_string_t pt_str;
6687 uint16_t pause_time;
6688 cmdline_fixed_string_t xon_str;
6693 cmdline_parse_token_string_t cmd_lfc_set_set =
6694 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6696 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6697 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6698 flow_ctrl, "flow_ctrl");
6699 cmdline_parse_token_string_t cmd_lfc_set_rx =
6700 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6702 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6703 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6704 rx_lfc_mode, "on#off");
6705 cmdline_parse_token_string_t cmd_lfc_set_tx =
6706 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6708 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6709 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6710 tx_lfc_mode, "on#off");
6711 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6712 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6713 hw_str, "high_water");
6714 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6715 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6716 high_water, UINT32);
6717 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6718 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6719 lw_str, "low_water");
6720 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6721 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6723 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6724 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6725 pt_str, "pause_time");
6726 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6727 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6728 pause_time, UINT16);
6729 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6730 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6731 xon_str, "send_xon");
6732 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6733 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6735 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6736 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6737 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6738 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6739 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6740 mac_ctrl_frame_fwd_mode, "on#off");
6741 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6742 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6743 autoneg_str, "autoneg");
6744 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6745 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6747 cmdline_parse_token_num_t cmd_lfc_set_portid =
6748 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6751 /* forward declaration */
6753 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6756 cmdline_parse_inst_t cmd_link_flow_control_set = {
6757 .f = cmd_link_flow_ctrl_set_parsed,
6759 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6760 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6761 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6763 (void *)&cmd_lfc_set_set,
6764 (void *)&cmd_lfc_set_flow_ctrl,
6765 (void *)&cmd_lfc_set_rx,
6766 (void *)&cmd_lfc_set_rx_mode,
6767 (void *)&cmd_lfc_set_tx,
6768 (void *)&cmd_lfc_set_tx_mode,
6769 (void *)&cmd_lfc_set_high_water,
6770 (void *)&cmd_lfc_set_low_water,
6771 (void *)&cmd_lfc_set_pause_time,
6772 (void *)&cmd_lfc_set_send_xon,
6773 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6774 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6775 (void *)&cmd_lfc_set_autoneg_str,
6776 (void *)&cmd_lfc_set_autoneg,
6777 (void *)&cmd_lfc_set_portid,
6782 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6783 .f = cmd_link_flow_ctrl_set_parsed,
6784 .data = (void *)&cmd_link_flow_control_set_rx,
6785 .help_str = "set flow_ctrl rx on|off <port_id>: "
6786 "Change rx flow control parameter",
6788 (void *)&cmd_lfc_set_set,
6789 (void *)&cmd_lfc_set_flow_ctrl,
6790 (void *)&cmd_lfc_set_rx,
6791 (void *)&cmd_lfc_set_rx_mode,
6792 (void *)&cmd_lfc_set_portid,
6797 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6798 .f = cmd_link_flow_ctrl_set_parsed,
6799 .data = (void *)&cmd_link_flow_control_set_tx,
6800 .help_str = "set flow_ctrl tx on|off <port_id>: "
6801 "Change tx flow control parameter",
6803 (void *)&cmd_lfc_set_set,
6804 (void *)&cmd_lfc_set_flow_ctrl,
6805 (void *)&cmd_lfc_set_tx,
6806 (void *)&cmd_lfc_set_tx_mode,
6807 (void *)&cmd_lfc_set_portid,
6812 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6813 .f = cmd_link_flow_ctrl_set_parsed,
6814 .data = (void *)&cmd_link_flow_control_set_hw,
6815 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6816 "Change high water flow control parameter",
6818 (void *)&cmd_lfc_set_set,
6819 (void *)&cmd_lfc_set_flow_ctrl,
6820 (void *)&cmd_lfc_set_high_water_str,
6821 (void *)&cmd_lfc_set_high_water,
6822 (void *)&cmd_lfc_set_portid,
6827 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6828 .f = cmd_link_flow_ctrl_set_parsed,
6829 .data = (void *)&cmd_link_flow_control_set_lw,
6830 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6831 "Change low water flow control parameter",
6833 (void *)&cmd_lfc_set_set,
6834 (void *)&cmd_lfc_set_flow_ctrl,
6835 (void *)&cmd_lfc_set_low_water_str,
6836 (void *)&cmd_lfc_set_low_water,
6837 (void *)&cmd_lfc_set_portid,
6842 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6843 .f = cmd_link_flow_ctrl_set_parsed,
6844 .data = (void *)&cmd_link_flow_control_set_pt,
6845 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6846 "Change pause time flow control parameter",
6848 (void *)&cmd_lfc_set_set,
6849 (void *)&cmd_lfc_set_flow_ctrl,
6850 (void *)&cmd_lfc_set_pause_time_str,
6851 (void *)&cmd_lfc_set_pause_time,
6852 (void *)&cmd_lfc_set_portid,
6857 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6858 .f = cmd_link_flow_ctrl_set_parsed,
6859 .data = (void *)&cmd_link_flow_control_set_xon,
6860 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6861 "Change send_xon flow control parameter",
6863 (void *)&cmd_lfc_set_set,
6864 (void *)&cmd_lfc_set_flow_ctrl,
6865 (void *)&cmd_lfc_set_send_xon_str,
6866 (void *)&cmd_lfc_set_send_xon,
6867 (void *)&cmd_lfc_set_portid,
6872 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6873 .f = cmd_link_flow_ctrl_set_parsed,
6874 .data = (void *)&cmd_link_flow_control_set_macfwd,
6875 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6876 "Change mac ctrl fwd flow control parameter",
6878 (void *)&cmd_lfc_set_set,
6879 (void *)&cmd_lfc_set_flow_ctrl,
6880 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6881 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6882 (void *)&cmd_lfc_set_portid,
6887 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6888 .f = cmd_link_flow_ctrl_set_parsed,
6889 .data = (void *)&cmd_link_flow_control_set_autoneg,
6890 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6891 "Change autoneg flow control parameter",
6893 (void *)&cmd_lfc_set_set,
6894 (void *)&cmd_lfc_set_flow_ctrl,
6895 (void *)&cmd_lfc_set_autoneg_str,
6896 (void *)&cmd_lfc_set_autoneg,
6897 (void *)&cmd_lfc_set_portid,
6903 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6904 __attribute__((unused)) struct cmdline *cl,
6907 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6908 cmdline_parse_inst_t *cmd = data;
6909 struct rte_eth_fc_conf fc_conf;
6915 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6916 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6917 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6918 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6920 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6921 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6924 /* Partial command line, retrieve current configuration */
6926 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6928 printf("cannot get current flow ctrl parameters, return"
6929 "code = %d\n", ret);
6933 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6934 (fc_conf.mode == RTE_FC_FULL))
6936 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6937 (fc_conf.mode == RTE_FC_FULL))
6941 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6942 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6944 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6945 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6947 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6949 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6950 fc_conf.high_water = res->high_water;
6952 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6953 fc_conf.low_water = res->low_water;
6955 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6956 fc_conf.pause_time = res->pause_time;
6958 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6959 fc_conf.send_xon = res->send_xon;
6961 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6962 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6963 fc_conf.mac_ctrl_frame_fwd = 1;
6965 fc_conf.mac_ctrl_frame_fwd = 0;
6968 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6969 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6971 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6973 printf("bad flow contrl parameter, return code = %d \n", ret);
6976 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6977 struct cmd_priority_flow_ctrl_set_result {
6978 cmdline_fixed_string_t set;
6979 cmdline_fixed_string_t pfc_ctrl;
6980 cmdline_fixed_string_t rx;
6981 cmdline_fixed_string_t rx_pfc_mode;
6982 cmdline_fixed_string_t tx;
6983 cmdline_fixed_string_t tx_pfc_mode;
6984 uint32_t high_water;
6986 uint16_t pause_time;
6992 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6993 __attribute__((unused)) struct cmdline *cl,
6994 __attribute__((unused)) void *data)
6996 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6997 struct rte_eth_pfc_conf pfc_conf;
6998 int rx_fc_enable, tx_fc_enable;
7002 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7003 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7004 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7005 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7007 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7008 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
7011 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7012 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7013 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7014 pfc_conf.fc.high_water = res->high_water;
7015 pfc_conf.fc.low_water = res->low_water;
7016 pfc_conf.fc.pause_time = res->pause_time;
7017 pfc_conf.priority = res->priority;
7019 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7021 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7024 cmdline_parse_token_string_t cmd_pfc_set_set =
7025 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7027 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7028 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7029 pfc_ctrl, "pfc_ctrl");
7030 cmdline_parse_token_string_t cmd_pfc_set_rx =
7031 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7033 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7034 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7035 rx_pfc_mode, "on#off");
7036 cmdline_parse_token_string_t cmd_pfc_set_tx =
7037 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7039 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7040 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7041 tx_pfc_mode, "on#off");
7042 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7043 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7044 high_water, UINT32);
7045 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7046 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7048 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7049 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7050 pause_time, UINT16);
7051 cmdline_parse_token_num_t cmd_pfc_set_priority =
7052 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7054 cmdline_parse_token_num_t cmd_pfc_set_portid =
7055 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7058 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7059 .f = cmd_priority_flow_ctrl_set_parsed,
7061 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7062 "<pause_time> <priority> <port_id>: "
7063 "Configure the Ethernet priority flow control",
7065 (void *)&cmd_pfc_set_set,
7066 (void *)&cmd_pfc_set_flow_ctrl,
7067 (void *)&cmd_pfc_set_rx,
7068 (void *)&cmd_pfc_set_rx_mode,
7069 (void *)&cmd_pfc_set_tx,
7070 (void *)&cmd_pfc_set_tx_mode,
7071 (void *)&cmd_pfc_set_high_water,
7072 (void *)&cmd_pfc_set_low_water,
7073 (void *)&cmd_pfc_set_pause_time,
7074 (void *)&cmd_pfc_set_priority,
7075 (void *)&cmd_pfc_set_portid,
7080 /* *** RESET CONFIGURATION *** */
7081 struct cmd_reset_result {
7082 cmdline_fixed_string_t reset;
7083 cmdline_fixed_string_t def;
7086 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
7088 __attribute__((unused)) void *data)
7090 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7091 set_def_fwd_config();
7094 cmdline_parse_token_string_t cmd_reset_set =
7095 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7096 cmdline_parse_token_string_t cmd_reset_def =
7097 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7100 cmdline_parse_inst_t cmd_reset = {
7101 .f = cmd_reset_parsed,
7103 .help_str = "set default: Reset default forwarding configuration",
7105 (void *)&cmd_reset_set,
7106 (void *)&cmd_reset_def,
7111 /* *** START FORWARDING *** */
7112 struct cmd_start_result {
7113 cmdline_fixed_string_t start;
7116 cmdline_parse_token_string_t cmd_start_start =
7117 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7119 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
7120 __attribute__((unused)) struct cmdline *cl,
7121 __attribute__((unused)) void *data)
7123 start_packet_forwarding(0);
7126 cmdline_parse_inst_t cmd_start = {
7127 .f = cmd_start_parsed,
7129 .help_str = "start: Start packet forwarding",
7131 (void *)&cmd_start_start,
7136 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7137 struct cmd_start_tx_first_result {
7138 cmdline_fixed_string_t start;
7139 cmdline_fixed_string_t tx_first;
7143 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
7144 __attribute__((unused)) struct cmdline *cl,
7145 __attribute__((unused)) void *data)
7147 start_packet_forwarding(1);
7150 cmdline_parse_token_string_t cmd_start_tx_first_start =
7151 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7153 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7154 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7155 tx_first, "tx_first");
7157 cmdline_parse_inst_t cmd_start_tx_first = {
7158 .f = cmd_start_tx_first_parsed,
7160 .help_str = "start tx_first: Start packet forwarding, "
7161 "after sending 1 burst of packets",
7163 (void *)&cmd_start_tx_first_start,
7164 (void *)&cmd_start_tx_first_tx_first,
7169 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7170 struct cmd_start_tx_first_n_result {
7171 cmdline_fixed_string_t start;
7172 cmdline_fixed_string_t tx_first;
7177 cmd_start_tx_first_n_parsed(void *parsed_result,
7178 __attribute__((unused)) struct cmdline *cl,
7179 __attribute__((unused)) void *data)
7181 struct cmd_start_tx_first_n_result *res = parsed_result;
7183 start_packet_forwarding(res->tx_num);
7186 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7187 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7189 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7190 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7191 tx_first, "tx_first");
7192 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7193 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7196 cmdline_parse_inst_t cmd_start_tx_first_n = {
7197 .f = cmd_start_tx_first_n_parsed,
7199 .help_str = "start tx_first <num>: "
7200 "packet forwarding, after sending <num> bursts of packets",
7202 (void *)&cmd_start_tx_first_n_start,
7203 (void *)&cmd_start_tx_first_n_tx_first,
7204 (void *)&cmd_start_tx_first_n_tx_num,
7209 /* *** SET LINK UP *** */
7210 struct cmd_set_link_up_result {
7211 cmdline_fixed_string_t set;
7212 cmdline_fixed_string_t link_up;
7213 cmdline_fixed_string_t port;
7217 cmdline_parse_token_string_t cmd_set_link_up_set =
7218 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7219 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7220 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7222 cmdline_parse_token_string_t cmd_set_link_up_port =
7223 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7224 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7225 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7227 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
7228 __attribute__((unused)) struct cmdline *cl,
7229 __attribute__((unused)) void *data)
7231 struct cmd_set_link_up_result *res = parsed_result;
7232 dev_set_link_up(res->port_id);
7235 cmdline_parse_inst_t cmd_set_link_up = {
7236 .f = cmd_set_link_up_parsed,
7238 .help_str = "set link-up port <port id>",
7240 (void *)&cmd_set_link_up_set,
7241 (void *)&cmd_set_link_up_link_up,
7242 (void *)&cmd_set_link_up_port,
7243 (void *)&cmd_set_link_up_port_id,
7248 /* *** SET LINK DOWN *** */
7249 struct cmd_set_link_down_result {
7250 cmdline_fixed_string_t set;
7251 cmdline_fixed_string_t link_down;
7252 cmdline_fixed_string_t port;
7256 cmdline_parse_token_string_t cmd_set_link_down_set =
7257 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7258 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7259 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7261 cmdline_parse_token_string_t cmd_set_link_down_port =
7262 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7263 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7264 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7266 static void cmd_set_link_down_parsed(
7267 __attribute__((unused)) void *parsed_result,
7268 __attribute__((unused)) struct cmdline *cl,
7269 __attribute__((unused)) void *data)
7271 struct cmd_set_link_down_result *res = parsed_result;
7272 dev_set_link_down(res->port_id);
7275 cmdline_parse_inst_t cmd_set_link_down = {
7276 .f = cmd_set_link_down_parsed,
7278 .help_str = "set link-down port <port id>",
7280 (void *)&cmd_set_link_down_set,
7281 (void *)&cmd_set_link_down_link_down,
7282 (void *)&cmd_set_link_down_port,
7283 (void *)&cmd_set_link_down_port_id,
7288 /* *** SHOW CFG *** */
7289 struct cmd_showcfg_result {
7290 cmdline_fixed_string_t show;
7291 cmdline_fixed_string_t cfg;
7292 cmdline_fixed_string_t what;
7295 static void cmd_showcfg_parsed(void *parsed_result,
7296 __attribute__((unused)) struct cmdline *cl,
7297 __attribute__((unused)) void *data)
7299 struct cmd_showcfg_result *res = parsed_result;
7300 if (!strcmp(res->what, "rxtx"))
7301 rxtx_config_display();
7302 else if (!strcmp(res->what, "cores"))
7303 fwd_lcores_config_display();
7304 else if (!strcmp(res->what, "fwd"))
7305 pkt_fwd_config_display(&cur_fwd_config);
7306 else if (!strcmp(res->what, "txpkts"))
7307 show_tx_pkt_segments();
7310 cmdline_parse_token_string_t cmd_showcfg_show =
7311 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7312 cmdline_parse_token_string_t cmd_showcfg_port =
7313 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7314 cmdline_parse_token_string_t cmd_showcfg_what =
7315 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7316 "rxtx#cores#fwd#txpkts");
7318 cmdline_parse_inst_t cmd_showcfg = {
7319 .f = cmd_showcfg_parsed,
7321 .help_str = "show config rxtx|cores|fwd|txpkts",
7323 (void *)&cmd_showcfg_show,
7324 (void *)&cmd_showcfg_port,
7325 (void *)&cmd_showcfg_what,
7330 /* *** SHOW ALL PORT INFO *** */
7331 struct cmd_showportall_result {
7332 cmdline_fixed_string_t show;
7333 cmdline_fixed_string_t port;
7334 cmdline_fixed_string_t what;
7335 cmdline_fixed_string_t all;
7338 static void cmd_showportall_parsed(void *parsed_result,
7339 __attribute__((unused)) struct cmdline *cl,
7340 __attribute__((unused)) void *data)
7344 struct cmd_showportall_result *res = parsed_result;
7345 if (!strcmp(res->show, "clear")) {
7346 if (!strcmp(res->what, "stats"))
7347 RTE_ETH_FOREACH_DEV(i)
7349 else if (!strcmp(res->what, "xstats"))
7350 RTE_ETH_FOREACH_DEV(i)
7351 nic_xstats_clear(i);
7352 } else if (!strcmp(res->what, "info"))
7353 RTE_ETH_FOREACH_DEV(i)
7354 port_infos_display(i);
7355 else if (!strcmp(res->what, "summary")) {
7356 port_summary_header_display();
7357 RTE_ETH_FOREACH_DEV(i)
7358 port_summary_display(i);
7360 else if (!strcmp(res->what, "stats"))
7361 RTE_ETH_FOREACH_DEV(i)
7362 nic_stats_display(i);
7363 else if (!strcmp(res->what, "xstats"))
7364 RTE_ETH_FOREACH_DEV(i)
7365 nic_xstats_display(i);
7366 else if (!strcmp(res->what, "fdir"))
7367 RTE_ETH_FOREACH_DEV(i)
7369 else if (!strcmp(res->what, "stat_qmap"))
7370 RTE_ETH_FOREACH_DEV(i)
7371 nic_stats_mapping_display(i);
7372 else if (!strcmp(res->what, "dcb_tc"))
7373 RTE_ETH_FOREACH_DEV(i)
7374 port_dcb_info_display(i);
7375 else if (!strcmp(res->what, "cap"))
7376 RTE_ETH_FOREACH_DEV(i)
7377 port_offload_cap_display(i);
7380 cmdline_parse_token_string_t cmd_showportall_show =
7381 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7383 cmdline_parse_token_string_t cmd_showportall_port =
7384 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7385 cmdline_parse_token_string_t cmd_showportall_what =
7386 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7387 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7388 cmdline_parse_token_string_t cmd_showportall_all =
7389 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7390 cmdline_parse_inst_t cmd_showportall = {
7391 .f = cmd_showportall_parsed,
7393 .help_str = "show|clear port "
7394 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7396 (void *)&cmd_showportall_show,
7397 (void *)&cmd_showportall_port,
7398 (void *)&cmd_showportall_what,
7399 (void *)&cmd_showportall_all,
7404 /* *** SHOW PORT INFO *** */
7405 struct cmd_showport_result {
7406 cmdline_fixed_string_t show;
7407 cmdline_fixed_string_t port;
7408 cmdline_fixed_string_t what;
7412 static void cmd_showport_parsed(void *parsed_result,
7413 __attribute__((unused)) struct cmdline *cl,
7414 __attribute__((unused)) void *data)
7416 struct cmd_showport_result *res = parsed_result;
7417 if (!strcmp(res->show, "clear")) {
7418 if (!strcmp(res->what, "stats"))
7419 nic_stats_clear(res->portnum);
7420 else if (!strcmp(res->what, "xstats"))
7421 nic_xstats_clear(res->portnum);
7422 } else if (!strcmp(res->what, "info"))
7423 port_infos_display(res->portnum);
7424 else if (!strcmp(res->what, "summary")) {
7425 port_summary_header_display();
7426 port_summary_display(res->portnum);
7428 else if (!strcmp(res->what, "stats"))
7429 nic_stats_display(res->portnum);
7430 else if (!strcmp(res->what, "xstats"))
7431 nic_xstats_display(res->portnum);
7432 else if (!strcmp(res->what, "fdir"))
7433 fdir_get_infos(res->portnum);
7434 else if (!strcmp(res->what, "stat_qmap"))
7435 nic_stats_mapping_display(res->portnum);
7436 else if (!strcmp(res->what, "dcb_tc"))
7437 port_dcb_info_display(res->portnum);
7438 else if (!strcmp(res->what, "cap"))
7439 port_offload_cap_display(res->portnum);
7442 cmdline_parse_token_string_t cmd_showport_show =
7443 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7445 cmdline_parse_token_string_t cmd_showport_port =
7446 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7447 cmdline_parse_token_string_t cmd_showport_what =
7448 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7449 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7450 cmdline_parse_token_num_t cmd_showport_portnum =
7451 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7453 cmdline_parse_inst_t cmd_showport = {
7454 .f = cmd_showport_parsed,
7456 .help_str = "show|clear port "
7457 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7460 (void *)&cmd_showport_show,
7461 (void *)&cmd_showport_port,
7462 (void *)&cmd_showport_what,
7463 (void *)&cmd_showport_portnum,
7468 /* *** SHOW DEVICE INFO *** */
7469 struct cmd_showdevice_result {
7470 cmdline_fixed_string_t show;
7471 cmdline_fixed_string_t device;
7472 cmdline_fixed_string_t what;
7473 cmdline_fixed_string_t identifier;
7476 static void cmd_showdevice_parsed(void *parsed_result,
7477 __attribute__((unused)) struct cmdline *cl,
7478 __attribute__((unused)) void *data)
7480 struct cmd_showdevice_result *res = parsed_result;
7481 if (!strcmp(res->what, "info")) {
7482 if (!strcmp(res->identifier, "all"))
7483 device_infos_display(NULL);
7485 device_infos_display(res->identifier);
7489 cmdline_parse_token_string_t cmd_showdevice_show =
7490 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7492 cmdline_parse_token_string_t cmd_showdevice_device =
7493 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7494 cmdline_parse_token_string_t cmd_showdevice_what =
7495 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7497 cmdline_parse_token_string_t cmd_showdevice_identifier =
7498 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7501 cmdline_parse_inst_t cmd_showdevice = {
7502 .f = cmd_showdevice_parsed,
7504 .help_str = "show device info <identifier>|all",
7506 (void *)&cmd_showdevice_show,
7507 (void *)&cmd_showdevice_device,
7508 (void *)&cmd_showdevice_what,
7509 (void *)&cmd_showdevice_identifier,
7513 /* *** SHOW QUEUE INFO *** */
7514 struct cmd_showqueue_result {
7515 cmdline_fixed_string_t show;
7516 cmdline_fixed_string_t type;
7517 cmdline_fixed_string_t what;
7523 cmd_showqueue_parsed(void *parsed_result,
7524 __attribute__((unused)) struct cmdline *cl,
7525 __attribute__((unused)) void *data)
7527 struct cmd_showqueue_result *res = parsed_result;
7529 if (!strcmp(res->type, "rxq"))
7530 rx_queue_infos_display(res->portnum, res->queuenum);
7531 else if (!strcmp(res->type, "txq"))
7532 tx_queue_infos_display(res->portnum, res->queuenum);
7535 cmdline_parse_token_string_t cmd_showqueue_show =
7536 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7537 cmdline_parse_token_string_t cmd_showqueue_type =
7538 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7539 cmdline_parse_token_string_t cmd_showqueue_what =
7540 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7541 cmdline_parse_token_num_t cmd_showqueue_portnum =
7542 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7543 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7544 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7546 cmdline_parse_inst_t cmd_showqueue = {
7547 .f = cmd_showqueue_parsed,
7549 .help_str = "show rxq|txq info <port_id> <queue_id>",
7551 (void *)&cmd_showqueue_show,
7552 (void *)&cmd_showqueue_type,
7553 (void *)&cmd_showqueue_what,
7554 (void *)&cmd_showqueue_portnum,
7555 (void *)&cmd_showqueue_queuenum,
7560 /* show/clear fwd engine statistics */
7562 cmdline_fixed_string_t action;
7563 cmdline_fixed_string_t fwd;
7564 cmdline_fixed_string_t stats;
7565 cmdline_fixed_string_t all;
7568 cmdline_parse_token_string_t cmd_fwd_action =
7569 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7570 cmdline_parse_token_string_t cmd_fwd_fwd =
7571 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7572 cmdline_parse_token_string_t cmd_fwd_stats =
7573 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7574 cmdline_parse_token_string_t cmd_fwd_all =
7575 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7578 cmd_showfwdall_parsed(void *parsed_result,
7579 __rte_unused struct cmdline *cl,
7580 __rte_unused void *data)
7582 struct fwd_result *res = parsed_result;
7584 if (!strcmp(res->action, "show"))
7585 fwd_stats_display();
7590 static cmdline_parse_inst_t cmd_showfwdall = {
7591 .f = cmd_showfwdall_parsed,
7593 .help_str = "show|clear fwd stats all",
7595 (void *)&cmd_fwd_action,
7596 (void *)&cmd_fwd_fwd,
7597 (void *)&cmd_fwd_stats,
7598 (void *)&cmd_fwd_all,
7603 /* *** READ PORT REGISTER *** */
7604 struct cmd_read_reg_result {
7605 cmdline_fixed_string_t read;
7606 cmdline_fixed_string_t reg;
7612 cmd_read_reg_parsed(void *parsed_result,
7613 __attribute__((unused)) struct cmdline *cl,
7614 __attribute__((unused)) void *data)
7616 struct cmd_read_reg_result *res = parsed_result;
7617 port_reg_display(res->port_id, res->reg_off);
7620 cmdline_parse_token_string_t cmd_read_reg_read =
7621 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7622 cmdline_parse_token_string_t cmd_read_reg_reg =
7623 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7624 cmdline_parse_token_num_t cmd_read_reg_port_id =
7625 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7626 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7627 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7629 cmdline_parse_inst_t cmd_read_reg = {
7630 .f = cmd_read_reg_parsed,
7632 .help_str = "read reg <port_id> <reg_off>",
7634 (void *)&cmd_read_reg_read,
7635 (void *)&cmd_read_reg_reg,
7636 (void *)&cmd_read_reg_port_id,
7637 (void *)&cmd_read_reg_reg_off,
7642 /* *** READ PORT REGISTER BIT FIELD *** */
7643 struct cmd_read_reg_bit_field_result {
7644 cmdline_fixed_string_t read;
7645 cmdline_fixed_string_t regfield;
7653 cmd_read_reg_bit_field_parsed(void *parsed_result,
7654 __attribute__((unused)) struct cmdline *cl,
7655 __attribute__((unused)) void *data)
7657 struct cmd_read_reg_bit_field_result *res = parsed_result;
7658 port_reg_bit_field_display(res->port_id, res->reg_off,
7659 res->bit1_pos, res->bit2_pos);
7662 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7663 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7665 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7666 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7667 regfield, "regfield");
7668 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7669 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7671 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7672 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7674 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7675 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7677 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7678 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7681 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7682 .f = cmd_read_reg_bit_field_parsed,
7684 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7685 "Read register bit field between bit_x and bit_y included",
7687 (void *)&cmd_read_reg_bit_field_read,
7688 (void *)&cmd_read_reg_bit_field_regfield,
7689 (void *)&cmd_read_reg_bit_field_port_id,
7690 (void *)&cmd_read_reg_bit_field_reg_off,
7691 (void *)&cmd_read_reg_bit_field_bit1_pos,
7692 (void *)&cmd_read_reg_bit_field_bit2_pos,
7697 /* *** READ PORT REGISTER BIT *** */
7698 struct cmd_read_reg_bit_result {
7699 cmdline_fixed_string_t read;
7700 cmdline_fixed_string_t regbit;
7707 cmd_read_reg_bit_parsed(void *parsed_result,
7708 __attribute__((unused)) struct cmdline *cl,
7709 __attribute__((unused)) void *data)
7711 struct cmd_read_reg_bit_result *res = parsed_result;
7712 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7715 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7716 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7717 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7718 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7720 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7721 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7722 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7723 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7724 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7725 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7727 cmdline_parse_inst_t cmd_read_reg_bit = {
7728 .f = cmd_read_reg_bit_parsed,
7730 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7732 (void *)&cmd_read_reg_bit_read,
7733 (void *)&cmd_read_reg_bit_regbit,
7734 (void *)&cmd_read_reg_bit_port_id,
7735 (void *)&cmd_read_reg_bit_reg_off,
7736 (void *)&cmd_read_reg_bit_bit_pos,
7741 /* *** WRITE PORT REGISTER *** */
7742 struct cmd_write_reg_result {
7743 cmdline_fixed_string_t write;
7744 cmdline_fixed_string_t reg;
7751 cmd_write_reg_parsed(void *parsed_result,
7752 __attribute__((unused)) struct cmdline *cl,
7753 __attribute__((unused)) void *data)
7755 struct cmd_write_reg_result *res = parsed_result;
7756 port_reg_set(res->port_id, res->reg_off, res->value);
7759 cmdline_parse_token_string_t cmd_write_reg_write =
7760 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7761 cmdline_parse_token_string_t cmd_write_reg_reg =
7762 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7763 cmdline_parse_token_num_t cmd_write_reg_port_id =
7764 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7765 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7766 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7767 cmdline_parse_token_num_t cmd_write_reg_value =
7768 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7770 cmdline_parse_inst_t cmd_write_reg = {
7771 .f = cmd_write_reg_parsed,
7773 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7775 (void *)&cmd_write_reg_write,
7776 (void *)&cmd_write_reg_reg,
7777 (void *)&cmd_write_reg_port_id,
7778 (void *)&cmd_write_reg_reg_off,
7779 (void *)&cmd_write_reg_value,
7784 /* *** WRITE PORT REGISTER BIT FIELD *** */
7785 struct cmd_write_reg_bit_field_result {
7786 cmdline_fixed_string_t write;
7787 cmdline_fixed_string_t regfield;
7796 cmd_write_reg_bit_field_parsed(void *parsed_result,
7797 __attribute__((unused)) struct cmdline *cl,
7798 __attribute__((unused)) void *data)
7800 struct cmd_write_reg_bit_field_result *res = parsed_result;
7801 port_reg_bit_field_set(res->port_id, res->reg_off,
7802 res->bit1_pos, res->bit2_pos, res->value);
7805 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7806 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7808 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7809 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7810 regfield, "regfield");
7811 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7812 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7814 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7815 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7817 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7818 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7820 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7821 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7823 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7824 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7827 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7828 .f = cmd_write_reg_bit_field_parsed,
7830 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7832 "Set register bit field between bit_x and bit_y included",
7834 (void *)&cmd_write_reg_bit_field_write,
7835 (void *)&cmd_write_reg_bit_field_regfield,
7836 (void *)&cmd_write_reg_bit_field_port_id,
7837 (void *)&cmd_write_reg_bit_field_reg_off,
7838 (void *)&cmd_write_reg_bit_field_bit1_pos,
7839 (void *)&cmd_write_reg_bit_field_bit2_pos,
7840 (void *)&cmd_write_reg_bit_field_value,
7845 /* *** WRITE PORT REGISTER BIT *** */
7846 struct cmd_write_reg_bit_result {
7847 cmdline_fixed_string_t write;
7848 cmdline_fixed_string_t regbit;
7856 cmd_write_reg_bit_parsed(void *parsed_result,
7857 __attribute__((unused)) struct cmdline *cl,
7858 __attribute__((unused)) void *data)
7860 struct cmd_write_reg_bit_result *res = parsed_result;
7861 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7864 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7865 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7867 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7868 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7870 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7871 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7872 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7873 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7874 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7875 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7876 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7877 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7879 cmdline_parse_inst_t cmd_write_reg_bit = {
7880 .f = cmd_write_reg_bit_parsed,
7882 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7885 (void *)&cmd_write_reg_bit_write,
7886 (void *)&cmd_write_reg_bit_regbit,
7887 (void *)&cmd_write_reg_bit_port_id,
7888 (void *)&cmd_write_reg_bit_reg_off,
7889 (void *)&cmd_write_reg_bit_bit_pos,
7890 (void *)&cmd_write_reg_bit_value,
7895 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7896 struct cmd_read_rxd_txd_result {
7897 cmdline_fixed_string_t read;
7898 cmdline_fixed_string_t rxd_txd;
7905 cmd_read_rxd_txd_parsed(void *parsed_result,
7906 __attribute__((unused)) struct cmdline *cl,
7907 __attribute__((unused)) void *data)
7909 struct cmd_read_rxd_txd_result *res = parsed_result;
7911 if (!strcmp(res->rxd_txd, "rxd"))
7912 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7913 else if (!strcmp(res->rxd_txd, "txd"))
7914 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7917 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7918 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7919 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7920 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7922 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7923 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7924 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7925 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7926 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7927 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7929 cmdline_parse_inst_t cmd_read_rxd_txd = {
7930 .f = cmd_read_rxd_txd_parsed,
7932 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7934 (void *)&cmd_read_rxd_txd_read,
7935 (void *)&cmd_read_rxd_txd_rxd_txd,
7936 (void *)&cmd_read_rxd_txd_port_id,
7937 (void *)&cmd_read_rxd_txd_queue_id,
7938 (void *)&cmd_read_rxd_txd_desc_id,
7944 struct cmd_quit_result {
7945 cmdline_fixed_string_t quit;
7948 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7950 __attribute__((unused)) void *data)
7955 cmdline_parse_token_string_t cmd_quit_quit =
7956 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7958 cmdline_parse_inst_t cmd_quit = {
7959 .f = cmd_quit_parsed,
7961 .help_str = "quit: Exit application",
7963 (void *)&cmd_quit_quit,
7968 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7969 struct cmd_mac_addr_result {
7970 cmdline_fixed_string_t mac_addr_cmd;
7971 cmdline_fixed_string_t what;
7973 struct rte_ether_addr address;
7976 static void cmd_mac_addr_parsed(void *parsed_result,
7977 __attribute__((unused)) struct cmdline *cl,
7978 __attribute__((unused)) void *data)
7980 struct cmd_mac_addr_result *res = parsed_result;
7983 if (strcmp(res->what, "add") == 0)
7984 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7985 else if (strcmp(res->what, "set") == 0)
7986 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7989 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7991 /* check the return value and print it if is < 0 */
7993 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7997 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7998 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8000 cmdline_parse_token_string_t cmd_mac_addr_what =
8001 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8003 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8004 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8006 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8007 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8009 cmdline_parse_inst_t cmd_mac_addr = {
8010 .f = cmd_mac_addr_parsed,
8012 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8013 "Add/Remove/Set MAC address on port_id",
8015 (void *)&cmd_mac_addr_cmd,
8016 (void *)&cmd_mac_addr_what,
8017 (void *)&cmd_mac_addr_portnum,
8018 (void *)&cmd_mac_addr_addr,
8023 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8024 struct cmd_eth_peer_result {
8025 cmdline_fixed_string_t set;
8026 cmdline_fixed_string_t eth_peer;
8028 cmdline_fixed_string_t peer_addr;
8031 static void cmd_set_eth_peer_parsed(void *parsed_result,
8032 __attribute__((unused)) struct cmdline *cl,
8033 __attribute__((unused)) void *data)
8035 struct cmd_eth_peer_result *res = parsed_result;
8037 if (test_done == 0) {
8038 printf("Please stop forwarding first\n");
8041 if (!strcmp(res->eth_peer, "eth-peer")) {
8042 set_fwd_eth_peer(res->port_id, res->peer_addr);
8046 cmdline_parse_token_string_t cmd_eth_peer_set =
8047 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8048 cmdline_parse_token_string_t cmd_eth_peer =
8049 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8050 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8051 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8052 cmdline_parse_token_string_t cmd_eth_peer_addr =
8053 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8055 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8056 .f = cmd_set_eth_peer_parsed,
8058 .help_str = "set eth-peer <port_id> <peer_mac>",
8060 (void *)&cmd_eth_peer_set,
8061 (void *)&cmd_eth_peer,
8062 (void *)&cmd_eth_peer_port_id,
8063 (void *)&cmd_eth_peer_addr,
8068 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8069 struct cmd_set_qmap_result {
8070 cmdline_fixed_string_t set;
8071 cmdline_fixed_string_t qmap;
8072 cmdline_fixed_string_t what;
8079 cmd_set_qmap_parsed(void *parsed_result,
8080 __attribute__((unused)) struct cmdline *cl,
8081 __attribute__((unused)) void *data)
8083 struct cmd_set_qmap_result *res = parsed_result;
8084 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8086 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8089 cmdline_parse_token_string_t cmd_setqmap_set =
8090 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8092 cmdline_parse_token_string_t cmd_setqmap_qmap =
8093 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8095 cmdline_parse_token_string_t cmd_setqmap_what =
8096 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8098 cmdline_parse_token_num_t cmd_setqmap_portid =
8099 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8101 cmdline_parse_token_num_t cmd_setqmap_queueid =
8102 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8104 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8105 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8108 cmdline_parse_inst_t cmd_set_qmap = {
8109 .f = cmd_set_qmap_parsed,
8111 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8112 "Set statistics mapping value on tx|rx queue_id of port_id",
8114 (void *)&cmd_setqmap_set,
8115 (void *)&cmd_setqmap_qmap,
8116 (void *)&cmd_setqmap_what,
8117 (void *)&cmd_setqmap_portid,
8118 (void *)&cmd_setqmap_queueid,
8119 (void *)&cmd_setqmap_mapvalue,
8124 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8125 struct cmd_set_xstats_hide_zero_result {
8126 cmdline_fixed_string_t keyword;
8127 cmdline_fixed_string_t name;
8128 cmdline_fixed_string_t on_off;
8132 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8133 __attribute__((unused)) struct cmdline *cl,
8134 __attribute__((unused)) void *data)
8136 struct cmd_set_xstats_hide_zero_result *res;
8137 uint16_t on_off = 0;
8139 res = parsed_result;
8140 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8141 set_xstats_hide_zero(on_off);
8144 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8145 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8147 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8148 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8149 name, "xstats-hide-zero");
8150 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8151 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8154 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8155 .f = cmd_set_xstats_hide_zero_parsed,
8157 .help_str = "set xstats-hide-zero on|off",
8159 (void *)&cmd_set_xstats_hide_zero_keyword,
8160 (void *)&cmd_set_xstats_hide_zero_name,
8161 (void *)&cmd_set_xstats_hide_zero_on_off,
8166 /* *** CONFIGURE UNICAST HASH TABLE *** */
8167 struct cmd_set_uc_hash_table {
8168 cmdline_fixed_string_t set;
8169 cmdline_fixed_string_t port;
8171 cmdline_fixed_string_t what;
8172 struct rte_ether_addr address;
8173 cmdline_fixed_string_t mode;
8177 cmd_set_uc_hash_parsed(void *parsed_result,
8178 __attribute__((unused)) struct cmdline *cl,
8179 __attribute__((unused)) void *data)
8182 struct cmd_set_uc_hash_table *res = parsed_result;
8184 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8186 if (strcmp(res->what, "uta") == 0)
8187 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8188 &res->address,(uint8_t)is_on);
8190 printf("bad unicast hash table parameter, return code = %d \n", ret);
8194 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8195 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8197 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8198 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8200 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8201 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8203 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8204 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8206 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8207 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8209 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8210 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8213 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8214 .f = cmd_set_uc_hash_parsed,
8216 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8218 (void *)&cmd_set_uc_hash_set,
8219 (void *)&cmd_set_uc_hash_port,
8220 (void *)&cmd_set_uc_hash_portid,
8221 (void *)&cmd_set_uc_hash_what,
8222 (void *)&cmd_set_uc_hash_mac,
8223 (void *)&cmd_set_uc_hash_mode,
8228 struct cmd_set_uc_all_hash_table {
8229 cmdline_fixed_string_t set;
8230 cmdline_fixed_string_t port;
8232 cmdline_fixed_string_t what;
8233 cmdline_fixed_string_t value;
8234 cmdline_fixed_string_t mode;
8238 cmd_set_uc_all_hash_parsed(void *parsed_result,
8239 __attribute__((unused)) struct cmdline *cl,
8240 __attribute__((unused)) void *data)
8243 struct cmd_set_uc_all_hash_table *res = parsed_result;
8245 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8247 if ((strcmp(res->what, "uta") == 0) &&
8248 (strcmp(res->value, "all") == 0))
8249 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8251 printf("bad unicast hash table parameter,"
8252 "return code = %d \n", ret);
8255 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8256 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8258 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8259 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8261 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8262 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8264 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8265 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8267 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8268 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8270 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8271 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8274 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8275 .f = cmd_set_uc_all_hash_parsed,
8277 .help_str = "set port <port_id> uta all on|off",
8279 (void *)&cmd_set_uc_all_hash_set,
8280 (void *)&cmd_set_uc_all_hash_port,
8281 (void *)&cmd_set_uc_all_hash_portid,
8282 (void *)&cmd_set_uc_all_hash_what,
8283 (void *)&cmd_set_uc_all_hash_value,
8284 (void *)&cmd_set_uc_all_hash_mode,
8289 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8290 struct cmd_set_vf_macvlan_filter {
8291 cmdline_fixed_string_t set;
8292 cmdline_fixed_string_t port;
8294 cmdline_fixed_string_t vf;
8296 struct rte_ether_addr address;
8297 cmdline_fixed_string_t filter_type;
8298 cmdline_fixed_string_t mode;
8302 cmd_set_vf_macvlan_parsed(void *parsed_result,
8303 __attribute__((unused)) struct cmdline *cl,
8304 __attribute__((unused)) void *data)
8307 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8308 struct rte_eth_mac_filter filter;
8310 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8312 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8314 /* set VF MAC filter */
8318 filter.dst_id = res->vf_id;
8320 if (!strcmp(res->filter_type, "exact-mac"))
8321 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8322 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8323 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8324 else if (!strcmp(res->filter_type, "hashmac"))
8325 filter.filter_type = RTE_MAC_HASH_MATCH;
8326 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8327 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8329 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8332 ret = rte_eth_dev_filter_ctrl(res->port_id,
8333 RTE_ETH_FILTER_MACVLAN,
8337 ret = rte_eth_dev_filter_ctrl(res->port_id,
8338 RTE_ETH_FILTER_MACVLAN,
8339 RTE_ETH_FILTER_DELETE,
8343 printf("bad set MAC hash parameter, return code = %d\n", ret);
8347 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8348 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8350 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8351 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8353 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8354 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8356 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8357 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8359 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8360 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8362 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8363 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8365 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8366 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8367 filter_type, "exact-mac#exact-mac-vlan"
8368 "#hashmac#hashmac-vlan");
8369 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8370 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8373 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8374 .f = cmd_set_vf_macvlan_parsed,
8376 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8377 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8378 "Exact match rule: exact match of MAC or MAC and VLAN; "
8379 "hash match rule: hash match of MAC and exact match of VLAN",
8381 (void *)&cmd_set_vf_macvlan_set,
8382 (void *)&cmd_set_vf_macvlan_port,
8383 (void *)&cmd_set_vf_macvlan_portid,
8384 (void *)&cmd_set_vf_macvlan_vf,
8385 (void *)&cmd_set_vf_macvlan_vf_id,
8386 (void *)&cmd_set_vf_macvlan_mac,
8387 (void *)&cmd_set_vf_macvlan_filter_type,
8388 (void *)&cmd_set_vf_macvlan_mode,
8393 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8394 struct cmd_set_vf_traffic {
8395 cmdline_fixed_string_t set;
8396 cmdline_fixed_string_t port;
8398 cmdline_fixed_string_t vf;
8400 cmdline_fixed_string_t what;
8401 cmdline_fixed_string_t mode;
8405 cmd_set_vf_traffic_parsed(void *parsed_result,
8406 __attribute__((unused)) struct cmdline *cl,
8407 __attribute__((unused)) void *data)
8409 struct cmd_set_vf_traffic *res = parsed_result;
8410 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8411 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8413 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8416 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8417 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8419 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8420 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8422 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8423 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8425 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8426 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8428 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8429 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8431 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8432 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8434 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8435 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8438 cmdline_parse_inst_t cmd_set_vf_traffic = {
8439 .f = cmd_set_vf_traffic_parsed,
8441 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8443 (void *)&cmd_setvf_traffic_set,
8444 (void *)&cmd_setvf_traffic_port,
8445 (void *)&cmd_setvf_traffic_portid,
8446 (void *)&cmd_setvf_traffic_vf,
8447 (void *)&cmd_setvf_traffic_vfid,
8448 (void *)&cmd_setvf_traffic_what,
8449 (void *)&cmd_setvf_traffic_mode,
8454 /* *** CONFIGURE VF RECEIVE MODE *** */
8455 struct cmd_set_vf_rxmode {
8456 cmdline_fixed_string_t set;
8457 cmdline_fixed_string_t port;
8459 cmdline_fixed_string_t vf;
8461 cmdline_fixed_string_t what;
8462 cmdline_fixed_string_t mode;
8463 cmdline_fixed_string_t on;
8467 cmd_set_vf_rxmode_parsed(void *parsed_result,
8468 __attribute__((unused)) struct cmdline *cl,
8469 __attribute__((unused)) void *data)
8472 uint16_t vf_rxmode = 0;
8473 struct cmd_set_vf_rxmode *res = parsed_result;
8475 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8476 if (!strcmp(res->what,"rxmode")) {
8477 if (!strcmp(res->mode, "AUPE"))
8478 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8479 else if (!strcmp(res->mode, "ROPE"))
8480 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8481 else if (!strcmp(res->mode, "BAM"))
8482 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8483 else if (!strncmp(res->mode, "MPE",3))
8484 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8487 RTE_SET_USED(is_on);
8489 #ifdef RTE_LIBRTE_IXGBE_PMD
8490 if (ret == -ENOTSUP)
8491 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8492 vf_rxmode, (uint8_t)is_on);
8494 #ifdef RTE_LIBRTE_BNXT_PMD
8495 if (ret == -ENOTSUP)
8496 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8497 vf_rxmode, (uint8_t)is_on);
8500 printf("bad VF receive mode parameter, return code = %d \n",
8504 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8505 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8507 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8508 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8510 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8511 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8513 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8514 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8516 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8517 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8519 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8520 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8522 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8523 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8524 mode, "AUPE#ROPE#BAM#MPE");
8525 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8526 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8529 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8530 .f = cmd_set_vf_rxmode_parsed,
8532 .help_str = "set port <port_id> vf <vf_id> rxmode "
8533 "AUPE|ROPE|BAM|MPE on|off",
8535 (void *)&cmd_set_vf_rxmode_set,
8536 (void *)&cmd_set_vf_rxmode_port,
8537 (void *)&cmd_set_vf_rxmode_portid,
8538 (void *)&cmd_set_vf_rxmode_vf,
8539 (void *)&cmd_set_vf_rxmode_vfid,
8540 (void *)&cmd_set_vf_rxmode_what,
8541 (void *)&cmd_set_vf_rxmode_mode,
8542 (void *)&cmd_set_vf_rxmode_on,
8547 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8548 struct cmd_vf_mac_addr_result {
8549 cmdline_fixed_string_t mac_addr_cmd;
8550 cmdline_fixed_string_t what;
8551 cmdline_fixed_string_t port;
8553 cmdline_fixed_string_t vf;
8555 struct rte_ether_addr address;
8558 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8559 __attribute__((unused)) struct cmdline *cl,
8560 __attribute__((unused)) void *data)
8562 struct cmd_vf_mac_addr_result *res = parsed_result;
8565 if (strcmp(res->what, "add") != 0)
8568 #ifdef RTE_LIBRTE_I40E_PMD
8569 if (ret == -ENOTSUP)
8570 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8573 #ifdef RTE_LIBRTE_BNXT_PMD
8574 if (ret == -ENOTSUP)
8575 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8580 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8584 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8585 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8586 mac_addr_cmd,"mac_addr");
8587 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8588 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8590 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8591 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8593 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8594 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8596 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8597 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8599 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8600 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8602 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8603 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8606 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8607 .f = cmd_vf_mac_addr_parsed,
8609 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8610 "Add MAC address filtering for a VF on port_id",
8612 (void *)&cmd_vf_mac_addr_cmd,
8613 (void *)&cmd_vf_mac_addr_what,
8614 (void *)&cmd_vf_mac_addr_port,
8615 (void *)&cmd_vf_mac_addr_portnum,
8616 (void *)&cmd_vf_mac_addr_vf,
8617 (void *)&cmd_vf_mac_addr_vfnum,
8618 (void *)&cmd_vf_mac_addr_addr,
8623 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8624 struct cmd_vf_rx_vlan_filter {
8625 cmdline_fixed_string_t rx_vlan;
8626 cmdline_fixed_string_t what;
8628 cmdline_fixed_string_t port;
8630 cmdline_fixed_string_t vf;
8635 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8636 __attribute__((unused)) struct cmdline *cl,
8637 __attribute__((unused)) void *data)
8639 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8642 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8644 #ifdef RTE_LIBRTE_IXGBE_PMD
8645 if (ret == -ENOTSUP)
8646 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8647 res->vlan_id, res->vf_mask, is_add);
8649 #ifdef RTE_LIBRTE_I40E_PMD
8650 if (ret == -ENOTSUP)
8651 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8652 res->vlan_id, res->vf_mask, is_add);
8654 #ifdef RTE_LIBRTE_BNXT_PMD
8655 if (ret == -ENOTSUP)
8656 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8657 res->vlan_id, res->vf_mask, is_add);
8664 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8665 res->vlan_id, res->vf_mask);
8668 printf("invalid port_id %d\n", res->port_id);
8671 printf("function not implemented or supported\n");
8674 printf("programming error: (%s)\n", strerror(-ret));
8678 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8679 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8680 rx_vlan, "rx_vlan");
8681 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8682 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8684 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8685 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8687 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8688 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8690 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8691 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8693 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8694 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8696 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8697 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8700 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8701 .f = cmd_vf_rx_vlan_filter_parsed,
8703 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8704 "(vf_mask = hexadecimal VF mask)",
8706 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8707 (void *)&cmd_vf_rx_vlan_filter_what,
8708 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8709 (void *)&cmd_vf_rx_vlan_filter_port,
8710 (void *)&cmd_vf_rx_vlan_filter_portid,
8711 (void *)&cmd_vf_rx_vlan_filter_vf,
8712 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8717 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8718 struct cmd_queue_rate_limit_result {
8719 cmdline_fixed_string_t set;
8720 cmdline_fixed_string_t port;
8722 cmdline_fixed_string_t queue;
8724 cmdline_fixed_string_t rate;
8728 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8729 __attribute__((unused)) struct cmdline *cl,
8730 __attribute__((unused)) void *data)
8732 struct cmd_queue_rate_limit_result *res = parsed_result;
8735 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8736 && (strcmp(res->queue, "queue") == 0)
8737 && (strcmp(res->rate, "rate") == 0))
8738 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8741 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8745 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8746 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8748 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8749 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8751 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8752 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8754 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8755 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8757 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8758 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8760 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8761 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8763 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8764 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8767 cmdline_parse_inst_t cmd_queue_rate_limit = {
8768 .f = cmd_queue_rate_limit_parsed,
8770 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8771 "Set rate limit for a queue on port_id",
8773 (void *)&cmd_queue_rate_limit_set,
8774 (void *)&cmd_queue_rate_limit_port,
8775 (void *)&cmd_queue_rate_limit_portnum,
8776 (void *)&cmd_queue_rate_limit_queue,
8777 (void *)&cmd_queue_rate_limit_queuenum,
8778 (void *)&cmd_queue_rate_limit_rate,
8779 (void *)&cmd_queue_rate_limit_ratenum,
8784 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8785 struct cmd_vf_rate_limit_result {
8786 cmdline_fixed_string_t set;
8787 cmdline_fixed_string_t port;
8789 cmdline_fixed_string_t vf;
8791 cmdline_fixed_string_t rate;
8793 cmdline_fixed_string_t q_msk;
8797 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8798 __attribute__((unused)) struct cmdline *cl,
8799 __attribute__((unused)) void *data)
8801 struct cmd_vf_rate_limit_result *res = parsed_result;
8804 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8805 && (strcmp(res->vf, "vf") == 0)
8806 && (strcmp(res->rate, "rate") == 0)
8807 && (strcmp(res->q_msk, "queue_mask") == 0))
8808 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8809 res->rate_num, res->q_msk_val);
8811 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8815 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8816 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8818 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8819 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8821 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8822 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8824 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8825 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8827 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8828 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8830 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8831 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8833 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8834 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8836 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8837 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8838 q_msk, "queue_mask");
8839 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8840 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8843 cmdline_parse_inst_t cmd_vf_rate_limit = {
8844 .f = cmd_vf_rate_limit_parsed,
8846 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8847 "queue_mask <queue_mask_value>: "
8848 "Set rate limit for queues of VF on port_id",
8850 (void *)&cmd_vf_rate_limit_set,
8851 (void *)&cmd_vf_rate_limit_port,
8852 (void *)&cmd_vf_rate_limit_portnum,
8853 (void *)&cmd_vf_rate_limit_vf,
8854 (void *)&cmd_vf_rate_limit_vfnum,
8855 (void *)&cmd_vf_rate_limit_rate,
8856 (void *)&cmd_vf_rate_limit_ratenum,
8857 (void *)&cmd_vf_rate_limit_q_msk,
8858 (void *)&cmd_vf_rate_limit_q_msk_val,
8863 /* *** ADD TUNNEL FILTER OF A PORT *** */
8864 struct cmd_tunnel_filter_result {
8865 cmdline_fixed_string_t cmd;
8866 cmdline_fixed_string_t what;
8868 struct rte_ether_addr outer_mac;
8869 struct rte_ether_addr inner_mac;
8870 cmdline_ipaddr_t ip_value;
8871 uint16_t inner_vlan;
8872 cmdline_fixed_string_t tunnel_type;
8873 cmdline_fixed_string_t filter_type;
8879 cmd_tunnel_filter_parsed(void *parsed_result,
8880 __attribute__((unused)) struct cmdline *cl,
8881 __attribute__((unused)) void *data)
8883 struct cmd_tunnel_filter_result *res = parsed_result;
8884 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8887 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8889 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8890 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8891 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8893 if (res->ip_value.family == AF_INET) {
8894 tunnel_filter_conf.ip_addr.ipv4_addr =
8895 res->ip_value.addr.ipv4.s_addr;
8896 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8898 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8899 &(res->ip_value.addr.ipv6),
8900 sizeof(struct in6_addr));
8901 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8904 if (!strcmp(res->filter_type, "imac-ivlan"))
8905 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8906 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8907 tunnel_filter_conf.filter_type =
8908 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8909 else if (!strcmp(res->filter_type, "imac-tenid"))
8910 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8911 else if (!strcmp(res->filter_type, "imac"))
8912 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8913 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8914 tunnel_filter_conf.filter_type =
8915 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8916 else if (!strcmp(res->filter_type, "oip"))
8917 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8918 else if (!strcmp(res->filter_type, "iip"))
8919 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8921 printf("The filter type is not supported");
8925 if (!strcmp(res->tunnel_type, "vxlan"))
8926 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8927 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
8928 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
8929 else if (!strcmp(res->tunnel_type, "nvgre"))
8930 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8931 else if (!strcmp(res->tunnel_type, "ipingre"))
8932 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8934 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8938 tunnel_filter_conf.tenant_id = res->tenant_id;
8939 tunnel_filter_conf.queue_id = res->queue_num;
8940 if (!strcmp(res->what, "add"))
8941 ret = rte_eth_dev_filter_ctrl(res->port_id,
8942 RTE_ETH_FILTER_TUNNEL,
8944 &tunnel_filter_conf);
8946 ret = rte_eth_dev_filter_ctrl(res->port_id,
8947 RTE_ETH_FILTER_TUNNEL,
8948 RTE_ETH_FILTER_DELETE,
8949 &tunnel_filter_conf);
8951 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8955 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8956 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8957 cmd, "tunnel_filter");
8958 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8959 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8961 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8962 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8964 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8965 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8967 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8968 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8970 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8971 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8972 inner_vlan, UINT16);
8973 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8974 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8976 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8977 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8978 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
8980 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8981 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8982 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8983 "imac#omac-imac-tenid");
8984 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8985 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8987 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8988 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8991 cmdline_parse_inst_t cmd_tunnel_filter = {
8992 .f = cmd_tunnel_filter_parsed,
8994 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8995 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8996 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8997 "<queue_id>: Add/Rm tunnel filter of a port",
8999 (void *)&cmd_tunnel_filter_cmd,
9000 (void *)&cmd_tunnel_filter_what,
9001 (void *)&cmd_tunnel_filter_port_id,
9002 (void *)&cmd_tunnel_filter_outer_mac,
9003 (void *)&cmd_tunnel_filter_inner_mac,
9004 (void *)&cmd_tunnel_filter_ip_value,
9005 (void *)&cmd_tunnel_filter_innner_vlan,
9006 (void *)&cmd_tunnel_filter_tunnel_type,
9007 (void *)&cmd_tunnel_filter_filter_type,
9008 (void *)&cmd_tunnel_filter_tenant_id,
9009 (void *)&cmd_tunnel_filter_queue_num,
9014 /* *** CONFIGURE TUNNEL UDP PORT *** */
9015 struct cmd_tunnel_udp_config {
9016 cmdline_fixed_string_t cmd;
9017 cmdline_fixed_string_t what;
9023 cmd_tunnel_udp_config_parsed(void *parsed_result,
9024 __attribute__((unused)) struct cmdline *cl,
9025 __attribute__((unused)) void *data)
9027 struct cmd_tunnel_udp_config *res = parsed_result;
9028 struct rte_eth_udp_tunnel tunnel_udp;
9031 tunnel_udp.udp_port = res->udp_port;
9033 if (!strcmp(res->cmd, "rx_vxlan_port"))
9034 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9036 if (!strcmp(res->what, "add"))
9037 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9040 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9044 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9047 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9048 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9049 cmd, "rx_vxlan_port");
9050 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9051 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9053 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9054 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9056 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9057 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9060 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9061 .f = cmd_tunnel_udp_config_parsed,
9063 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9064 "Add/Remove a tunneling UDP port filter",
9066 (void *)&cmd_tunnel_udp_config_cmd,
9067 (void *)&cmd_tunnel_udp_config_what,
9068 (void *)&cmd_tunnel_udp_config_udp_port,
9069 (void *)&cmd_tunnel_udp_config_port_id,
9074 struct cmd_config_tunnel_udp_port {
9075 cmdline_fixed_string_t port;
9076 cmdline_fixed_string_t config;
9078 cmdline_fixed_string_t udp_tunnel_port;
9079 cmdline_fixed_string_t action;
9080 cmdline_fixed_string_t tunnel_type;
9085 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9086 __attribute__((unused)) struct cmdline *cl,
9087 __attribute__((unused)) void *data)
9089 struct cmd_config_tunnel_udp_port *res = parsed_result;
9090 struct rte_eth_udp_tunnel tunnel_udp;
9093 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9096 tunnel_udp.udp_port = res->udp_port;
9098 if (!strcmp(res->tunnel_type, "vxlan")) {
9099 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9100 } else if (!strcmp(res->tunnel_type, "geneve")) {
9101 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9102 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9103 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9105 printf("Invalid tunnel type\n");
9109 if (!strcmp(res->action, "add"))
9110 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9113 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9117 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9120 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9121 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9123 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9124 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9126 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9127 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9129 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9130 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9133 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9134 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9136 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9137 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9138 "vxlan#geneve#vxlan-gpe");
9139 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9140 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9143 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9144 .f = cmd_cfg_tunnel_udp_port_parsed,
9146 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9148 (void *)&cmd_config_tunnel_udp_port_port,
9149 (void *)&cmd_config_tunnel_udp_port_config,
9150 (void *)&cmd_config_tunnel_udp_port_port_id,
9151 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9152 (void *)&cmd_config_tunnel_udp_port_action,
9153 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9154 (void *)&cmd_config_tunnel_udp_port_value,
9159 /* *** GLOBAL CONFIG *** */
9160 struct cmd_global_config_result {
9161 cmdline_fixed_string_t cmd;
9163 cmdline_fixed_string_t cfg_type;
9168 cmd_global_config_parsed(void *parsed_result,
9169 __attribute__((unused)) struct cmdline *cl,
9170 __attribute__((unused)) void *data)
9172 struct cmd_global_config_result *res = parsed_result;
9173 struct rte_eth_global_cfg conf;
9176 memset(&conf, 0, sizeof(conf));
9177 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9178 conf.cfg.gre_key_len = res->len;
9179 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9180 RTE_ETH_FILTER_SET, &conf);
9182 printf("Global config error\n");
9185 cmdline_parse_token_string_t cmd_global_config_cmd =
9186 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9188 cmdline_parse_token_num_t cmd_global_config_port_id =
9189 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9191 cmdline_parse_token_string_t cmd_global_config_type =
9192 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9193 cfg_type, "gre-key-len");
9194 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9195 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9198 cmdline_parse_inst_t cmd_global_config = {
9199 .f = cmd_global_config_parsed,
9200 .data = (void *)NULL,
9201 .help_str = "global_config <port_id> gre-key-len <key_len>",
9203 (void *)&cmd_global_config_cmd,
9204 (void *)&cmd_global_config_port_id,
9205 (void *)&cmd_global_config_type,
9206 (void *)&cmd_global_config_gre_key_len,
9211 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9212 struct cmd_set_mirror_mask_result {
9213 cmdline_fixed_string_t set;
9214 cmdline_fixed_string_t port;
9216 cmdline_fixed_string_t mirror;
9218 cmdline_fixed_string_t what;
9219 cmdline_fixed_string_t value;
9220 cmdline_fixed_string_t dstpool;
9222 cmdline_fixed_string_t on;
9225 cmdline_parse_token_string_t cmd_mirror_mask_set =
9226 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9228 cmdline_parse_token_string_t cmd_mirror_mask_port =
9229 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9231 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9232 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9234 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9235 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9236 mirror, "mirror-rule");
9237 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9238 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9240 cmdline_parse_token_string_t cmd_mirror_mask_what =
9241 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9242 what, "pool-mirror-up#pool-mirror-down"
9244 cmdline_parse_token_string_t cmd_mirror_mask_value =
9245 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9247 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9248 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9249 dstpool, "dst-pool");
9250 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9251 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9253 cmdline_parse_token_string_t cmd_mirror_mask_on =
9254 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9258 cmd_set_mirror_mask_parsed(void *parsed_result,
9259 __attribute__((unused)) struct cmdline *cl,
9260 __attribute__((unused)) void *data)
9263 struct cmd_set_mirror_mask_result *res = parsed_result;
9264 struct rte_eth_mirror_conf mr_conf;
9266 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9268 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9270 mr_conf.dst_pool = res->dstpool_id;
9272 if (!strcmp(res->what, "pool-mirror-up")) {
9273 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9274 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9275 } else if (!strcmp(res->what, "pool-mirror-down")) {
9276 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9277 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9278 } else if (!strcmp(res->what, "vlan-mirror")) {
9279 mr_conf.rule_type = ETH_MIRROR_VLAN;
9280 nb_item = parse_item_list(res->value, "vlan",
9281 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9285 for (i = 0; i < nb_item; i++) {
9286 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9287 printf("Invalid vlan_id: must be < 4096\n");
9291 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9292 mr_conf.vlan.vlan_mask |= 1ULL << i;
9296 if (!strcmp(res->on, "on"))
9297 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9300 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9303 printf("mirror rule add error: (%s)\n", strerror(-ret));
9306 cmdline_parse_inst_t cmd_set_mirror_mask = {
9307 .f = cmd_set_mirror_mask_parsed,
9309 .help_str = "set port <port_id> mirror-rule <rule_id> "
9310 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9311 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9313 (void *)&cmd_mirror_mask_set,
9314 (void *)&cmd_mirror_mask_port,
9315 (void *)&cmd_mirror_mask_portid,
9316 (void *)&cmd_mirror_mask_mirror,
9317 (void *)&cmd_mirror_mask_ruleid,
9318 (void *)&cmd_mirror_mask_what,
9319 (void *)&cmd_mirror_mask_value,
9320 (void *)&cmd_mirror_mask_dstpool,
9321 (void *)&cmd_mirror_mask_poolid,
9322 (void *)&cmd_mirror_mask_on,
9327 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9328 struct cmd_set_mirror_link_result {
9329 cmdline_fixed_string_t set;
9330 cmdline_fixed_string_t port;
9332 cmdline_fixed_string_t mirror;
9334 cmdline_fixed_string_t what;
9335 cmdline_fixed_string_t dstpool;
9337 cmdline_fixed_string_t on;
9340 cmdline_parse_token_string_t cmd_mirror_link_set =
9341 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9343 cmdline_parse_token_string_t cmd_mirror_link_port =
9344 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9346 cmdline_parse_token_num_t cmd_mirror_link_portid =
9347 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9349 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9350 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9351 mirror, "mirror-rule");
9352 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9353 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9355 cmdline_parse_token_string_t cmd_mirror_link_what =
9356 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9357 what, "uplink-mirror#downlink-mirror");
9358 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9359 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9360 dstpool, "dst-pool");
9361 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9362 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9364 cmdline_parse_token_string_t cmd_mirror_link_on =
9365 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9369 cmd_set_mirror_link_parsed(void *parsed_result,
9370 __attribute__((unused)) struct cmdline *cl,
9371 __attribute__((unused)) void *data)
9374 struct cmd_set_mirror_link_result *res = parsed_result;
9375 struct rte_eth_mirror_conf mr_conf;
9377 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9378 if (!strcmp(res->what, "uplink-mirror"))
9379 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9381 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9383 mr_conf.dst_pool = res->dstpool_id;
9385 if (!strcmp(res->on, "on"))
9386 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9389 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9392 /* check the return value and print it if is < 0 */
9394 printf("mirror rule add error: (%s)\n", strerror(-ret));
9398 cmdline_parse_inst_t cmd_set_mirror_link = {
9399 .f = cmd_set_mirror_link_parsed,
9401 .help_str = "set port <port_id> mirror-rule <rule_id> "
9402 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9404 (void *)&cmd_mirror_link_set,
9405 (void *)&cmd_mirror_link_port,
9406 (void *)&cmd_mirror_link_portid,
9407 (void *)&cmd_mirror_link_mirror,
9408 (void *)&cmd_mirror_link_ruleid,
9409 (void *)&cmd_mirror_link_what,
9410 (void *)&cmd_mirror_link_dstpool,
9411 (void *)&cmd_mirror_link_poolid,
9412 (void *)&cmd_mirror_link_on,
9417 /* *** RESET VM MIRROR RULE *** */
9418 struct cmd_rm_mirror_rule_result {
9419 cmdline_fixed_string_t reset;
9420 cmdline_fixed_string_t port;
9422 cmdline_fixed_string_t mirror;
9426 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9427 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9429 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9430 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9432 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9433 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9435 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9436 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9437 mirror, "mirror-rule");
9438 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9439 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9443 cmd_reset_mirror_rule_parsed(void *parsed_result,
9444 __attribute__((unused)) struct cmdline *cl,
9445 __attribute__((unused)) void *data)
9448 struct cmd_set_mirror_link_result *res = parsed_result;
9450 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9452 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9455 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9456 .f = cmd_reset_mirror_rule_parsed,
9458 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9460 (void *)&cmd_rm_mirror_rule_reset,
9461 (void *)&cmd_rm_mirror_rule_port,
9462 (void *)&cmd_rm_mirror_rule_portid,
9463 (void *)&cmd_rm_mirror_rule_mirror,
9464 (void *)&cmd_rm_mirror_rule_ruleid,
9469 /* ******************************************************************************** */
9471 struct cmd_dump_result {
9472 cmdline_fixed_string_t dump;
9476 dump_struct_sizes(void)
9478 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9479 DUMP_SIZE(struct rte_mbuf);
9480 DUMP_SIZE(struct rte_mempool);
9481 DUMP_SIZE(struct rte_ring);
9485 static void cmd_dump_parsed(void *parsed_result,
9486 __attribute__((unused)) struct cmdline *cl,
9487 __attribute__((unused)) void *data)
9489 struct cmd_dump_result *res = parsed_result;
9491 if (!strcmp(res->dump, "dump_physmem"))
9492 rte_dump_physmem_layout(stdout);
9493 else if (!strcmp(res->dump, "dump_memzone"))
9494 rte_memzone_dump(stdout);
9495 else if (!strcmp(res->dump, "dump_struct_sizes"))
9496 dump_struct_sizes();
9497 else if (!strcmp(res->dump, "dump_ring"))
9498 rte_ring_list_dump(stdout);
9499 else if (!strcmp(res->dump, "dump_mempool"))
9500 rte_mempool_list_dump(stdout);
9501 else if (!strcmp(res->dump, "dump_devargs"))
9502 rte_devargs_dump(stdout);
9503 else if (!strcmp(res->dump, "dump_log_types"))
9504 rte_log_dump(stdout);
9507 cmdline_parse_token_string_t cmd_dump_dump =
9508 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9511 "dump_struct_sizes#"
9517 cmdline_parse_inst_t cmd_dump = {
9518 .f = cmd_dump_parsed, /* function to call */
9519 .data = NULL, /* 2nd arg of func */
9520 .help_str = "Dump status",
9521 .tokens = { /* token list, NULL terminated */
9522 (void *)&cmd_dump_dump,
9527 /* ******************************************************************************** */
9529 struct cmd_dump_one_result {
9530 cmdline_fixed_string_t dump;
9531 cmdline_fixed_string_t name;
9534 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9535 __attribute__((unused)) void *data)
9537 struct cmd_dump_one_result *res = parsed_result;
9539 if (!strcmp(res->dump, "dump_ring")) {
9541 r = rte_ring_lookup(res->name);
9543 cmdline_printf(cl, "Cannot find ring\n");
9546 rte_ring_dump(stdout, r);
9547 } else if (!strcmp(res->dump, "dump_mempool")) {
9548 struct rte_mempool *mp;
9549 mp = rte_mempool_lookup(res->name);
9551 cmdline_printf(cl, "Cannot find mempool\n");
9554 rte_mempool_dump(stdout, mp);
9558 cmdline_parse_token_string_t cmd_dump_one_dump =
9559 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9560 "dump_ring#dump_mempool");
9562 cmdline_parse_token_string_t cmd_dump_one_name =
9563 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9565 cmdline_parse_inst_t cmd_dump_one = {
9566 .f = cmd_dump_one_parsed, /* function to call */
9567 .data = NULL, /* 2nd arg of func */
9568 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9569 .tokens = { /* token list, NULL terminated */
9570 (void *)&cmd_dump_one_dump,
9571 (void *)&cmd_dump_one_name,
9576 /* *** Add/Del syn filter *** */
9577 struct cmd_syn_filter_result {
9578 cmdline_fixed_string_t filter;
9580 cmdline_fixed_string_t ops;
9581 cmdline_fixed_string_t priority;
9582 cmdline_fixed_string_t high;
9583 cmdline_fixed_string_t queue;
9588 cmd_syn_filter_parsed(void *parsed_result,
9589 __attribute__((unused)) struct cmdline *cl,
9590 __attribute__((unused)) void *data)
9592 struct cmd_syn_filter_result *res = parsed_result;
9593 struct rte_eth_syn_filter syn_filter;
9596 ret = rte_eth_dev_filter_supported(res->port_id,
9597 RTE_ETH_FILTER_SYN);
9599 printf("syn filter is not supported on port %u.\n",
9604 memset(&syn_filter, 0, sizeof(syn_filter));
9606 if (!strcmp(res->ops, "add")) {
9607 if (!strcmp(res->high, "high"))
9608 syn_filter.hig_pri = 1;
9610 syn_filter.hig_pri = 0;
9612 syn_filter.queue = res->queue_id;
9613 ret = rte_eth_dev_filter_ctrl(res->port_id,
9618 ret = rte_eth_dev_filter_ctrl(res->port_id,
9620 RTE_ETH_FILTER_DELETE,
9624 printf("syn filter programming error: (%s)\n",
9628 cmdline_parse_token_string_t cmd_syn_filter_filter =
9629 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9630 filter, "syn_filter");
9631 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9632 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9634 cmdline_parse_token_string_t cmd_syn_filter_ops =
9635 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9637 cmdline_parse_token_string_t cmd_syn_filter_priority =
9638 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9639 priority, "priority");
9640 cmdline_parse_token_string_t cmd_syn_filter_high =
9641 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9643 cmdline_parse_token_string_t cmd_syn_filter_queue =
9644 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9646 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9647 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9650 cmdline_parse_inst_t cmd_syn_filter = {
9651 .f = cmd_syn_filter_parsed,
9653 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9654 "<queue_id>: Add/Delete syn filter",
9656 (void *)&cmd_syn_filter_filter,
9657 (void *)&cmd_syn_filter_port_id,
9658 (void *)&cmd_syn_filter_ops,
9659 (void *)&cmd_syn_filter_priority,
9660 (void *)&cmd_syn_filter_high,
9661 (void *)&cmd_syn_filter_queue,
9662 (void *)&cmd_syn_filter_queue_id,
9667 /* *** queue region set *** */
9668 struct cmd_queue_region_result {
9669 cmdline_fixed_string_t set;
9670 cmdline_fixed_string_t port;
9672 cmdline_fixed_string_t cmd;
9673 cmdline_fixed_string_t region;
9675 cmdline_fixed_string_t queue_start_index;
9677 cmdline_fixed_string_t queue_num;
9678 uint8_t queue_num_value;
9682 cmd_queue_region_parsed(void *parsed_result,
9683 __attribute__((unused)) struct cmdline *cl,
9684 __attribute__((unused)) void *data)
9686 struct cmd_queue_region_result *res = parsed_result;
9688 #ifdef RTE_LIBRTE_I40E_PMD
9689 struct rte_pmd_i40e_queue_region_conf region_conf;
9690 enum rte_pmd_i40e_queue_region_op op_type;
9693 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9696 #ifdef RTE_LIBRTE_I40E_PMD
9697 memset(®ion_conf, 0, sizeof(region_conf));
9698 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9699 region_conf.region_id = res->region_id;
9700 region_conf.queue_num = res->queue_num_value;
9701 region_conf.queue_start_index = res->queue_id;
9703 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9704 op_type, ®ion_conf);
9711 printf("function not implemented or supported\n");
9714 printf("queue region config error: (%s)\n", strerror(-ret));
9718 cmdline_parse_token_string_t cmd_queue_region_set =
9719 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9721 cmdline_parse_token_string_t cmd_queue_region_port =
9722 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9723 cmdline_parse_token_num_t cmd_queue_region_port_id =
9724 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9726 cmdline_parse_token_string_t cmd_queue_region_cmd =
9727 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9728 cmd, "queue-region");
9729 cmdline_parse_token_string_t cmd_queue_region_id =
9730 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9731 region, "region_id");
9732 cmdline_parse_token_num_t cmd_queue_region_index =
9733 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9735 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9736 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9737 queue_start_index, "queue_start_index");
9738 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9739 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9741 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9742 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9743 queue_num, "queue_num");
9744 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9745 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9746 queue_num_value, UINT8);
9748 cmdline_parse_inst_t cmd_queue_region = {
9749 .f = cmd_queue_region_parsed,
9751 .help_str = "set port <port_id> queue-region region_id <value> "
9752 "queue_start_index <value> queue_num <value>: Set a queue region",
9754 (void *)&cmd_queue_region_set,
9755 (void *)&cmd_queue_region_port,
9756 (void *)&cmd_queue_region_port_id,
9757 (void *)&cmd_queue_region_cmd,
9758 (void *)&cmd_queue_region_id,
9759 (void *)&cmd_queue_region_index,
9760 (void *)&cmd_queue_region_queue_start_index,
9761 (void *)&cmd_queue_region_queue_id,
9762 (void *)&cmd_queue_region_queue_num,
9763 (void *)&cmd_queue_region_queue_num_value,
9768 /* *** queue region and flowtype set *** */
9769 struct cmd_region_flowtype_result {
9770 cmdline_fixed_string_t set;
9771 cmdline_fixed_string_t port;
9773 cmdline_fixed_string_t cmd;
9774 cmdline_fixed_string_t region;
9776 cmdline_fixed_string_t flowtype;
9777 uint8_t flowtype_id;
9781 cmd_region_flowtype_parsed(void *parsed_result,
9782 __attribute__((unused)) struct cmdline *cl,
9783 __attribute__((unused)) void *data)
9785 struct cmd_region_flowtype_result *res = parsed_result;
9787 #ifdef RTE_LIBRTE_I40E_PMD
9788 struct rte_pmd_i40e_queue_region_conf region_conf;
9789 enum rte_pmd_i40e_queue_region_op op_type;
9792 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9795 #ifdef RTE_LIBRTE_I40E_PMD
9796 memset(®ion_conf, 0, sizeof(region_conf));
9798 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9799 region_conf.region_id = res->region_id;
9800 region_conf.hw_flowtype = res->flowtype_id;
9802 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9803 op_type, ®ion_conf);
9810 printf("function not implemented or supported\n");
9813 printf("region flowtype config error: (%s)\n", strerror(-ret));
9817 cmdline_parse_token_string_t cmd_region_flowtype_set =
9818 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9820 cmdline_parse_token_string_t cmd_region_flowtype_port =
9821 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9823 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9824 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9826 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9827 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9828 cmd, "queue-region");
9829 cmdline_parse_token_string_t cmd_region_flowtype_index =
9830 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9831 region, "region_id");
9832 cmdline_parse_token_num_t cmd_region_flowtype_id =
9833 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9835 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9836 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9837 flowtype, "flowtype");
9838 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9839 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9840 flowtype_id, UINT8);
9841 cmdline_parse_inst_t cmd_region_flowtype = {
9842 .f = cmd_region_flowtype_parsed,
9844 .help_str = "set port <port_id> queue-region region_id <value> "
9845 "flowtype <value>: Set a flowtype region index",
9847 (void *)&cmd_region_flowtype_set,
9848 (void *)&cmd_region_flowtype_port,
9849 (void *)&cmd_region_flowtype_port_index,
9850 (void *)&cmd_region_flowtype_cmd,
9851 (void *)&cmd_region_flowtype_index,
9852 (void *)&cmd_region_flowtype_id,
9853 (void *)&cmd_region_flowtype_flow_index,
9854 (void *)&cmd_region_flowtype_flow_id,
9859 /* *** User Priority (UP) to queue region (region_id) set *** */
9860 struct cmd_user_priority_region_result {
9861 cmdline_fixed_string_t set;
9862 cmdline_fixed_string_t port;
9864 cmdline_fixed_string_t cmd;
9865 cmdline_fixed_string_t user_priority;
9866 uint8_t user_priority_id;
9867 cmdline_fixed_string_t region;
9872 cmd_user_priority_region_parsed(void *parsed_result,
9873 __attribute__((unused)) struct cmdline *cl,
9874 __attribute__((unused)) void *data)
9876 struct cmd_user_priority_region_result *res = parsed_result;
9878 #ifdef RTE_LIBRTE_I40E_PMD
9879 struct rte_pmd_i40e_queue_region_conf region_conf;
9880 enum rte_pmd_i40e_queue_region_op op_type;
9883 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9886 #ifdef RTE_LIBRTE_I40E_PMD
9887 memset(®ion_conf, 0, sizeof(region_conf));
9888 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9889 region_conf.user_priority = res->user_priority_id;
9890 region_conf.region_id = res->region_id;
9892 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9893 op_type, ®ion_conf);
9900 printf("function not implemented or supported\n");
9903 printf("user_priority region config error: (%s)\n",
9908 cmdline_parse_token_string_t cmd_user_priority_region_set =
9909 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9911 cmdline_parse_token_string_t cmd_user_priority_region_port =
9912 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9914 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9915 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9917 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9918 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9919 cmd, "queue-region");
9920 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9921 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9922 user_priority, "UP");
9923 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9924 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9925 user_priority_id, UINT8);
9926 cmdline_parse_token_string_t cmd_user_priority_region_region =
9927 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9928 region, "region_id");
9929 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9930 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9933 cmdline_parse_inst_t cmd_user_priority_region = {
9934 .f = cmd_user_priority_region_parsed,
9936 .help_str = "set port <port_id> queue-region UP <value> "
9937 "region_id <value>: Set the mapping of User Priority (UP) "
9938 "to queue region (region_id) ",
9940 (void *)&cmd_user_priority_region_set,
9941 (void *)&cmd_user_priority_region_port,
9942 (void *)&cmd_user_priority_region_port_index,
9943 (void *)&cmd_user_priority_region_cmd,
9944 (void *)&cmd_user_priority_region_UP,
9945 (void *)&cmd_user_priority_region_UP_id,
9946 (void *)&cmd_user_priority_region_region,
9947 (void *)&cmd_user_priority_region_region_id,
9952 /* *** flush all queue region related configuration *** */
9953 struct cmd_flush_queue_region_result {
9954 cmdline_fixed_string_t set;
9955 cmdline_fixed_string_t port;
9957 cmdline_fixed_string_t cmd;
9958 cmdline_fixed_string_t flush;
9959 cmdline_fixed_string_t what;
9963 cmd_flush_queue_region_parsed(void *parsed_result,
9964 __attribute__((unused)) struct cmdline *cl,
9965 __attribute__((unused)) void *data)
9967 struct cmd_flush_queue_region_result *res = parsed_result;
9969 #ifdef RTE_LIBRTE_I40E_PMD
9970 struct rte_pmd_i40e_queue_region_conf region_conf;
9971 enum rte_pmd_i40e_queue_region_op op_type;
9974 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9977 #ifdef RTE_LIBRTE_I40E_PMD
9978 memset(®ion_conf, 0, sizeof(region_conf));
9980 if (strcmp(res->what, "on") == 0)
9981 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9983 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9985 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9986 op_type, ®ion_conf);
9993 printf("function not implemented or supported\n");
9996 printf("queue region config flush error: (%s)\n",
10001 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10002 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10004 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10005 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10007 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10008 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10010 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10011 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10012 cmd, "queue-region");
10013 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10014 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10016 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10017 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10020 cmdline_parse_inst_t cmd_flush_queue_region = {
10021 .f = cmd_flush_queue_region_parsed,
10023 .help_str = "set port <port_id> queue-region flush on|off"
10024 ": flush all queue region related configuration",
10026 (void *)&cmd_flush_queue_region_set,
10027 (void *)&cmd_flush_queue_region_port,
10028 (void *)&cmd_flush_queue_region_port_index,
10029 (void *)&cmd_flush_queue_region_cmd,
10030 (void *)&cmd_flush_queue_region_flush,
10031 (void *)&cmd_flush_queue_region_what,
10036 /* *** get all queue region related configuration info *** */
10037 struct cmd_show_queue_region_info {
10038 cmdline_fixed_string_t show;
10039 cmdline_fixed_string_t port;
10041 cmdline_fixed_string_t cmd;
10045 cmd_show_queue_region_info_parsed(void *parsed_result,
10046 __attribute__((unused)) struct cmdline *cl,
10047 __attribute__((unused)) void *data)
10049 struct cmd_show_queue_region_info *res = parsed_result;
10050 int ret = -ENOTSUP;
10051 #ifdef RTE_LIBRTE_I40E_PMD
10052 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10053 enum rte_pmd_i40e_queue_region_op op_type;
10056 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10059 #ifdef RTE_LIBRTE_I40E_PMD
10060 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10062 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10064 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10065 op_type, &rte_pmd_regions);
10067 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10074 printf("function not implemented or supported\n");
10077 printf("queue region config info show error: (%s)\n",
10082 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10083 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10085 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10086 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10088 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10089 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10091 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10092 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10093 cmd, "queue-region");
10095 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10096 .f = cmd_show_queue_region_info_parsed,
10098 .help_str = "show port <port_id> queue-region"
10099 ": show all queue region related configuration info",
10101 (void *)&cmd_show_queue_region_info_get,
10102 (void *)&cmd_show_queue_region_info_port,
10103 (void *)&cmd_show_queue_region_info_port_index,
10104 (void *)&cmd_show_queue_region_info_cmd,
10109 /* *** ADD/REMOVE A 2tuple FILTER *** */
10110 struct cmd_2tuple_filter_result {
10111 cmdline_fixed_string_t filter;
10113 cmdline_fixed_string_t ops;
10114 cmdline_fixed_string_t dst_port;
10115 uint16_t dst_port_value;
10116 cmdline_fixed_string_t protocol;
10117 uint8_t protocol_value;
10118 cmdline_fixed_string_t mask;
10119 uint8_t mask_value;
10120 cmdline_fixed_string_t tcp_flags;
10121 uint8_t tcp_flags_value;
10122 cmdline_fixed_string_t priority;
10123 uint8_t priority_value;
10124 cmdline_fixed_string_t queue;
10129 cmd_2tuple_filter_parsed(void *parsed_result,
10130 __attribute__((unused)) struct cmdline *cl,
10131 __attribute__((unused)) void *data)
10133 struct rte_eth_ntuple_filter filter;
10134 struct cmd_2tuple_filter_result *res = parsed_result;
10137 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10139 printf("ntuple filter is not supported on port %u.\n",
10144 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10146 filter.flags = RTE_2TUPLE_FLAGS;
10147 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10148 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10149 filter.proto = res->protocol_value;
10150 filter.priority = res->priority_value;
10151 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10152 printf("nonzero tcp_flags is only meaningful"
10153 " when protocol is TCP.\n");
10156 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10157 printf("invalid TCP flags.\n");
10161 if (res->tcp_flags_value != 0) {
10162 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10163 filter.tcp_flags = res->tcp_flags_value;
10166 /* need convert to big endian. */
10167 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10168 filter.queue = res->queue_id;
10170 if (!strcmp(res->ops, "add"))
10171 ret = rte_eth_dev_filter_ctrl(res->port_id,
10172 RTE_ETH_FILTER_NTUPLE,
10173 RTE_ETH_FILTER_ADD,
10176 ret = rte_eth_dev_filter_ctrl(res->port_id,
10177 RTE_ETH_FILTER_NTUPLE,
10178 RTE_ETH_FILTER_DELETE,
10181 printf("2tuple filter programming error: (%s)\n",
10186 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10187 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10188 filter, "2tuple_filter");
10189 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10190 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10192 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10193 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10195 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10196 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10197 dst_port, "dst_port");
10198 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10199 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10200 dst_port_value, UINT16);
10201 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10202 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10203 protocol, "protocol");
10204 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10205 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10206 protocol_value, UINT8);
10207 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10208 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10210 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10211 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10213 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10214 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10215 tcp_flags, "tcp_flags");
10216 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10217 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10218 tcp_flags_value, UINT8);
10219 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10220 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10221 priority, "priority");
10222 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10223 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10224 priority_value, UINT8);
10225 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10226 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10228 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10229 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10232 cmdline_parse_inst_t cmd_2tuple_filter = {
10233 .f = cmd_2tuple_filter_parsed,
10235 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10236 "<value> mask <value> tcp_flags <value> priority <value> queue "
10237 "<queue_id>: Add a 2tuple filter",
10239 (void *)&cmd_2tuple_filter_filter,
10240 (void *)&cmd_2tuple_filter_port_id,
10241 (void *)&cmd_2tuple_filter_ops,
10242 (void *)&cmd_2tuple_filter_dst_port,
10243 (void *)&cmd_2tuple_filter_dst_port_value,
10244 (void *)&cmd_2tuple_filter_protocol,
10245 (void *)&cmd_2tuple_filter_protocol_value,
10246 (void *)&cmd_2tuple_filter_mask,
10247 (void *)&cmd_2tuple_filter_mask_value,
10248 (void *)&cmd_2tuple_filter_tcp_flags,
10249 (void *)&cmd_2tuple_filter_tcp_flags_value,
10250 (void *)&cmd_2tuple_filter_priority,
10251 (void *)&cmd_2tuple_filter_priority_value,
10252 (void *)&cmd_2tuple_filter_queue,
10253 (void *)&cmd_2tuple_filter_queue_id,
10258 /* *** ADD/REMOVE A 5tuple FILTER *** */
10259 struct cmd_5tuple_filter_result {
10260 cmdline_fixed_string_t filter;
10262 cmdline_fixed_string_t ops;
10263 cmdline_fixed_string_t dst_ip;
10264 cmdline_ipaddr_t dst_ip_value;
10265 cmdline_fixed_string_t src_ip;
10266 cmdline_ipaddr_t src_ip_value;
10267 cmdline_fixed_string_t dst_port;
10268 uint16_t dst_port_value;
10269 cmdline_fixed_string_t src_port;
10270 uint16_t src_port_value;
10271 cmdline_fixed_string_t protocol;
10272 uint8_t protocol_value;
10273 cmdline_fixed_string_t mask;
10274 uint8_t mask_value;
10275 cmdline_fixed_string_t tcp_flags;
10276 uint8_t tcp_flags_value;
10277 cmdline_fixed_string_t priority;
10278 uint8_t priority_value;
10279 cmdline_fixed_string_t queue;
10284 cmd_5tuple_filter_parsed(void *parsed_result,
10285 __attribute__((unused)) struct cmdline *cl,
10286 __attribute__((unused)) void *data)
10288 struct rte_eth_ntuple_filter filter;
10289 struct cmd_5tuple_filter_result *res = parsed_result;
10292 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10294 printf("ntuple filter is not supported on port %u.\n",
10299 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10301 filter.flags = RTE_5TUPLE_FLAGS;
10302 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10303 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10304 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10305 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10306 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10307 filter.proto = res->protocol_value;
10308 filter.priority = res->priority_value;
10309 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10310 printf("nonzero tcp_flags is only meaningful"
10311 " when protocol is TCP.\n");
10314 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10315 printf("invalid TCP flags.\n");
10319 if (res->tcp_flags_value != 0) {
10320 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10321 filter.tcp_flags = res->tcp_flags_value;
10324 if (res->dst_ip_value.family == AF_INET)
10325 /* no need to convert, already big endian. */
10326 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10328 if (filter.dst_ip_mask == 0) {
10329 printf("can not support ipv6 involved compare.\n");
10335 if (res->src_ip_value.family == AF_INET)
10336 /* no need to convert, already big endian. */
10337 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10339 if (filter.src_ip_mask == 0) {
10340 printf("can not support ipv6 involved compare.\n");
10345 /* need convert to big endian. */
10346 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10347 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10348 filter.queue = res->queue_id;
10350 if (!strcmp(res->ops, "add"))
10351 ret = rte_eth_dev_filter_ctrl(res->port_id,
10352 RTE_ETH_FILTER_NTUPLE,
10353 RTE_ETH_FILTER_ADD,
10356 ret = rte_eth_dev_filter_ctrl(res->port_id,
10357 RTE_ETH_FILTER_NTUPLE,
10358 RTE_ETH_FILTER_DELETE,
10361 printf("5tuple filter programming error: (%s)\n",
10365 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10366 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10367 filter, "5tuple_filter");
10368 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10369 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10371 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10372 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10374 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10375 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10377 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10378 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10380 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10381 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10383 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10384 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10386 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10387 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10388 dst_port, "dst_port");
10389 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10390 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10391 dst_port_value, UINT16);
10392 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10393 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10394 src_port, "src_port");
10395 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10396 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10397 src_port_value, UINT16);
10398 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10399 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10400 protocol, "protocol");
10401 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10402 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10403 protocol_value, UINT8);
10404 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10405 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10407 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10408 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10410 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10411 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10412 tcp_flags, "tcp_flags");
10413 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10414 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10415 tcp_flags_value, UINT8);
10416 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10417 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10418 priority, "priority");
10419 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10420 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10421 priority_value, UINT8);
10422 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10423 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10425 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10426 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10429 cmdline_parse_inst_t cmd_5tuple_filter = {
10430 .f = cmd_5tuple_filter_parsed,
10432 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10433 "src_ip <value> dst_port <value> src_port <value> "
10434 "protocol <value> mask <value> tcp_flags <value> "
10435 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10437 (void *)&cmd_5tuple_filter_filter,
10438 (void *)&cmd_5tuple_filter_port_id,
10439 (void *)&cmd_5tuple_filter_ops,
10440 (void *)&cmd_5tuple_filter_dst_ip,
10441 (void *)&cmd_5tuple_filter_dst_ip_value,
10442 (void *)&cmd_5tuple_filter_src_ip,
10443 (void *)&cmd_5tuple_filter_src_ip_value,
10444 (void *)&cmd_5tuple_filter_dst_port,
10445 (void *)&cmd_5tuple_filter_dst_port_value,
10446 (void *)&cmd_5tuple_filter_src_port,
10447 (void *)&cmd_5tuple_filter_src_port_value,
10448 (void *)&cmd_5tuple_filter_protocol,
10449 (void *)&cmd_5tuple_filter_protocol_value,
10450 (void *)&cmd_5tuple_filter_mask,
10451 (void *)&cmd_5tuple_filter_mask_value,
10452 (void *)&cmd_5tuple_filter_tcp_flags,
10453 (void *)&cmd_5tuple_filter_tcp_flags_value,
10454 (void *)&cmd_5tuple_filter_priority,
10455 (void *)&cmd_5tuple_filter_priority_value,
10456 (void *)&cmd_5tuple_filter_queue,
10457 (void *)&cmd_5tuple_filter_queue_id,
10462 /* *** ADD/REMOVE A flex FILTER *** */
10463 struct cmd_flex_filter_result {
10464 cmdline_fixed_string_t filter;
10465 cmdline_fixed_string_t ops;
10467 cmdline_fixed_string_t len;
10469 cmdline_fixed_string_t bytes;
10470 cmdline_fixed_string_t bytes_value;
10471 cmdline_fixed_string_t mask;
10472 cmdline_fixed_string_t mask_value;
10473 cmdline_fixed_string_t priority;
10474 uint8_t priority_value;
10475 cmdline_fixed_string_t queue;
10479 static int xdigit2val(unsigned char c)
10484 else if (isupper(c))
10485 val = c - 'A' + 10;
10487 val = c - 'a' + 10;
10492 cmd_flex_filter_parsed(void *parsed_result,
10493 __attribute__((unused)) struct cmdline *cl,
10494 __attribute__((unused)) void *data)
10497 struct rte_eth_flex_filter filter;
10498 struct cmd_flex_filter_result *res = parsed_result;
10499 char *bytes_ptr, *mask_ptr;
10500 uint16_t len, i, j = 0;
10505 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10506 printf("the len exceed the max length 128\n");
10509 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10510 filter.len = res->len_value;
10511 filter.priority = res->priority_value;
10512 filter.queue = res->queue_id;
10513 bytes_ptr = res->bytes_value;
10514 mask_ptr = res->mask_value;
10516 /* translate bytes string to array. */
10517 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10518 (bytes_ptr[1] == 'X')))
10520 len = strnlen(bytes_ptr, res->len_value * 2);
10521 if (len == 0 || (len % 8 != 0)) {
10522 printf("please check len and bytes input\n");
10525 for (i = 0; i < len; i++) {
10527 if (isxdigit(c) == 0) {
10528 /* invalid characters. */
10529 printf("invalid input\n");
10532 val = xdigit2val(c);
10535 filter.bytes[j] = byte;
10536 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10543 /* translate mask string to uint8_t array. */
10544 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10545 (mask_ptr[1] == 'X')))
10547 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10549 printf("invalid input\n");
10554 for (i = 0; i < len; i++) {
10556 if (isxdigit(c) == 0) {
10557 /* invalid characters. */
10558 printf("invalid input\n");
10561 val = xdigit2val(c);
10564 filter.mask[j] = byte;
10565 printf("mask[%d]:%02x ", j, filter.mask[j]);
10573 if (!strcmp(res->ops, "add"))
10574 ret = rte_eth_dev_filter_ctrl(res->port_id,
10575 RTE_ETH_FILTER_FLEXIBLE,
10576 RTE_ETH_FILTER_ADD,
10579 ret = rte_eth_dev_filter_ctrl(res->port_id,
10580 RTE_ETH_FILTER_FLEXIBLE,
10581 RTE_ETH_FILTER_DELETE,
10585 printf("flex filter setting error: (%s)\n", strerror(-ret));
10588 cmdline_parse_token_string_t cmd_flex_filter_filter =
10589 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10590 filter, "flex_filter");
10591 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10592 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10594 cmdline_parse_token_string_t cmd_flex_filter_ops =
10595 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10597 cmdline_parse_token_string_t cmd_flex_filter_len =
10598 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10600 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10601 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10603 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10604 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10606 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10607 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10608 bytes_value, NULL);
10609 cmdline_parse_token_string_t cmd_flex_filter_mask =
10610 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10612 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10613 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10615 cmdline_parse_token_string_t cmd_flex_filter_priority =
10616 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10617 priority, "priority");
10618 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10619 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10620 priority_value, UINT8);
10621 cmdline_parse_token_string_t cmd_flex_filter_queue =
10622 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10624 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10625 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10627 cmdline_parse_inst_t cmd_flex_filter = {
10628 .f = cmd_flex_filter_parsed,
10630 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10631 "<value> mask <value> priority <value> queue <queue_id>: "
10632 "Add/Del a flex filter",
10634 (void *)&cmd_flex_filter_filter,
10635 (void *)&cmd_flex_filter_port_id,
10636 (void *)&cmd_flex_filter_ops,
10637 (void *)&cmd_flex_filter_len,
10638 (void *)&cmd_flex_filter_len_value,
10639 (void *)&cmd_flex_filter_bytes,
10640 (void *)&cmd_flex_filter_bytes_value,
10641 (void *)&cmd_flex_filter_mask,
10642 (void *)&cmd_flex_filter_mask_value,
10643 (void *)&cmd_flex_filter_priority,
10644 (void *)&cmd_flex_filter_priority_value,
10645 (void *)&cmd_flex_filter_queue,
10646 (void *)&cmd_flex_filter_queue_id,
10651 /* *** Filters Control *** */
10653 /* *** deal with ethertype filter *** */
10654 struct cmd_ethertype_filter_result {
10655 cmdline_fixed_string_t filter;
10657 cmdline_fixed_string_t ops;
10658 cmdline_fixed_string_t mac;
10659 struct rte_ether_addr mac_addr;
10660 cmdline_fixed_string_t ethertype;
10661 uint16_t ethertype_value;
10662 cmdline_fixed_string_t drop;
10663 cmdline_fixed_string_t queue;
10667 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10668 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10669 filter, "ethertype_filter");
10670 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10671 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10673 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10674 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10676 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10677 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10678 mac, "mac_addr#mac_ignr");
10679 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10680 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10682 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10683 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10684 ethertype, "ethertype");
10685 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10686 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10687 ethertype_value, UINT16);
10688 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10689 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10691 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10692 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10694 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10695 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10699 cmd_ethertype_filter_parsed(void *parsed_result,
10700 __attribute__((unused)) struct cmdline *cl,
10701 __attribute__((unused)) void *data)
10703 struct cmd_ethertype_filter_result *res = parsed_result;
10704 struct rte_eth_ethertype_filter filter;
10707 ret = rte_eth_dev_filter_supported(res->port_id,
10708 RTE_ETH_FILTER_ETHERTYPE);
10710 printf("ethertype filter is not supported on port %u.\n",
10715 memset(&filter, 0, sizeof(filter));
10716 if (!strcmp(res->mac, "mac_addr")) {
10717 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10718 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10719 sizeof(struct rte_ether_addr));
10721 if (!strcmp(res->drop, "drop"))
10722 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10723 filter.ether_type = res->ethertype_value;
10724 filter.queue = res->queue_id;
10726 if (!strcmp(res->ops, "add"))
10727 ret = rte_eth_dev_filter_ctrl(res->port_id,
10728 RTE_ETH_FILTER_ETHERTYPE,
10729 RTE_ETH_FILTER_ADD,
10732 ret = rte_eth_dev_filter_ctrl(res->port_id,
10733 RTE_ETH_FILTER_ETHERTYPE,
10734 RTE_ETH_FILTER_DELETE,
10737 printf("ethertype filter programming error: (%s)\n",
10741 cmdline_parse_inst_t cmd_ethertype_filter = {
10742 .f = cmd_ethertype_filter_parsed,
10744 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10745 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10746 "Add or delete an ethertype filter entry",
10748 (void *)&cmd_ethertype_filter_filter,
10749 (void *)&cmd_ethertype_filter_port_id,
10750 (void *)&cmd_ethertype_filter_ops,
10751 (void *)&cmd_ethertype_filter_mac,
10752 (void *)&cmd_ethertype_filter_mac_addr,
10753 (void *)&cmd_ethertype_filter_ethertype,
10754 (void *)&cmd_ethertype_filter_ethertype_value,
10755 (void *)&cmd_ethertype_filter_drop,
10756 (void *)&cmd_ethertype_filter_queue,
10757 (void *)&cmd_ethertype_filter_queue_id,
10762 /* *** deal with flow director filter *** */
10763 struct cmd_flow_director_result {
10764 cmdline_fixed_string_t flow_director_filter;
10766 cmdline_fixed_string_t mode;
10767 cmdline_fixed_string_t mode_value;
10768 cmdline_fixed_string_t ops;
10769 cmdline_fixed_string_t flow;
10770 cmdline_fixed_string_t flow_type;
10771 cmdline_fixed_string_t ether;
10772 uint16_t ether_type;
10773 cmdline_fixed_string_t src;
10774 cmdline_ipaddr_t ip_src;
10776 cmdline_fixed_string_t dst;
10777 cmdline_ipaddr_t ip_dst;
10779 cmdline_fixed_string_t verify_tag;
10780 uint32_t verify_tag_value;
10781 cmdline_fixed_string_t tos;
10783 cmdline_fixed_string_t proto;
10784 uint8_t proto_value;
10785 cmdline_fixed_string_t ttl;
10787 cmdline_fixed_string_t vlan;
10788 uint16_t vlan_value;
10789 cmdline_fixed_string_t flexbytes;
10790 cmdline_fixed_string_t flexbytes_value;
10791 cmdline_fixed_string_t pf_vf;
10792 cmdline_fixed_string_t drop;
10793 cmdline_fixed_string_t queue;
10795 cmdline_fixed_string_t fd_id;
10796 uint32_t fd_id_value;
10797 cmdline_fixed_string_t mac;
10798 struct rte_ether_addr mac_addr;
10799 cmdline_fixed_string_t tunnel;
10800 cmdline_fixed_string_t tunnel_type;
10801 cmdline_fixed_string_t tunnel_id;
10802 uint32_t tunnel_id_value;
10803 cmdline_fixed_string_t packet;
10808 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10811 const char *p, *p0 = q_arg;
10813 unsigned long int_fld;
10814 char *str_fld[max_num];
10819 p = strchr(p0, '(');
10823 p0 = strchr(p, ')');
10828 if (size >= sizeof(s))
10831 snprintf(s, sizeof(s), "%.*s", size, p);
10832 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10833 if (ret < 0 || ret > max_num)
10835 for (i = 0; i < ret; i++) {
10837 int_fld = strtoul(str_fld[i], &end, 0);
10838 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10840 flexbytes[i] = (uint8_t)int_fld;
10846 str2flowtype(char *string)
10849 static const struct {
10852 } flowtype_str[] = {
10853 {"raw", RTE_ETH_FLOW_RAW},
10854 {"ipv4", RTE_ETH_FLOW_IPV4},
10855 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10856 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10857 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10858 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10859 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10860 {"ipv6", RTE_ETH_FLOW_IPV6},
10861 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10862 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10863 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10864 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10865 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10866 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10869 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10870 if (!strcmp(flowtype_str[i].str, string))
10871 return flowtype_str[i].type;
10874 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10875 return (uint16_t)atoi(string);
10877 return RTE_ETH_FLOW_UNKNOWN;
10880 static enum rte_eth_fdir_tunnel_type
10881 str2fdir_tunneltype(char *string)
10885 static const struct {
10887 enum rte_eth_fdir_tunnel_type type;
10888 } tunneltype_str[] = {
10889 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10890 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10893 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10894 if (!strcmp(tunneltype_str[i].str, string))
10895 return tunneltype_str[i].type;
10897 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10900 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10902 if ((ip_addr).family == AF_INET) \
10903 (ip) = (ip_addr).addr.ipv4.s_addr; \
10905 printf("invalid parameter.\n"); \
10910 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10912 if ((ip_addr).family == AF_INET6) \
10913 rte_memcpy(&(ip), \
10914 &((ip_addr).addr.ipv6), \
10915 sizeof(struct in6_addr)); \
10917 printf("invalid parameter.\n"); \
10923 cmd_flow_director_filter_parsed(void *parsed_result,
10924 __attribute__((unused)) struct cmdline *cl,
10925 __attribute__((unused)) void *data)
10927 struct cmd_flow_director_result *res = parsed_result;
10928 struct rte_eth_fdir_filter entry;
10929 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10931 unsigned long vf_id;
10934 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10936 printf("flow director is not supported on port %u.\n",
10940 memset(flexbytes, 0, sizeof(flexbytes));
10941 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10943 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10944 if (strcmp(res->mode_value, "MAC-VLAN")) {
10945 printf("Please set mode to MAC-VLAN.\n");
10948 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10949 if (strcmp(res->mode_value, "Tunnel")) {
10950 printf("Please set mode to Tunnel.\n");
10954 if (!strcmp(res->mode_value, "raw")) {
10955 #ifdef RTE_LIBRTE_I40E_PMD
10956 struct rte_pmd_i40e_flow_type_mapping
10957 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10958 struct rte_pmd_i40e_pkt_template_conf conf;
10959 uint16_t flow_type = str2flowtype(res->flow_type);
10960 uint16_t i, port = res->port_id;
10963 memset(&conf, 0, sizeof(conf));
10965 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10966 printf("Invalid flow type specified.\n");
10969 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10973 if (mapping[flow_type].pctype == 0ULL) {
10974 printf("Invalid flow type specified.\n");
10977 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10978 if (mapping[flow_type].pctype & (1ULL << i)) {
10979 conf.input.pctype = i;
10984 conf.input.packet = open_file(res->filepath,
10985 &conf.input.length);
10986 if (!conf.input.packet)
10988 if (!strcmp(res->drop, "drop"))
10989 conf.action.behavior =
10990 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10992 conf.action.behavior =
10993 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10994 conf.action.report_status =
10995 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10996 conf.action.rx_queue = res->queue_id;
10997 conf.soft_id = res->fd_id_value;
10998 add = strcmp(res->ops, "del") ? 1 : 0;
10999 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11003 printf("flow director config error: (%s)\n",
11005 close_file(conf.input.packet);
11008 } else if (strcmp(res->mode_value, "IP")) {
11009 printf("Please set mode to IP or raw.\n");
11012 entry.input.flow_type = str2flowtype(res->flow_type);
11015 ret = parse_flexbytes(res->flexbytes_value,
11017 RTE_ETH_FDIR_MAX_FLEXLEN);
11019 printf("error: Cannot parse flexbytes input.\n");
11023 switch (entry.input.flow_type) {
11024 case RTE_ETH_FLOW_FRAG_IPV4:
11025 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11026 entry.input.flow.ip4_flow.proto = res->proto_value;
11028 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11029 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11030 IPV4_ADDR_TO_UINT(res->ip_dst,
11031 entry.input.flow.ip4_flow.dst_ip);
11032 IPV4_ADDR_TO_UINT(res->ip_src,
11033 entry.input.flow.ip4_flow.src_ip);
11034 entry.input.flow.ip4_flow.tos = res->tos_value;
11035 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11036 /* need convert to big endian. */
11037 entry.input.flow.udp4_flow.dst_port =
11038 rte_cpu_to_be_16(res->port_dst);
11039 entry.input.flow.udp4_flow.src_port =
11040 rte_cpu_to_be_16(res->port_src);
11042 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11043 IPV4_ADDR_TO_UINT(res->ip_dst,
11044 entry.input.flow.sctp4_flow.ip.dst_ip);
11045 IPV4_ADDR_TO_UINT(res->ip_src,
11046 entry.input.flow.sctp4_flow.ip.src_ip);
11047 entry.input.flow.ip4_flow.tos = res->tos_value;
11048 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11049 /* need convert to big endian. */
11050 entry.input.flow.sctp4_flow.dst_port =
11051 rte_cpu_to_be_16(res->port_dst);
11052 entry.input.flow.sctp4_flow.src_port =
11053 rte_cpu_to_be_16(res->port_src);
11054 entry.input.flow.sctp4_flow.verify_tag =
11055 rte_cpu_to_be_32(res->verify_tag_value);
11057 case RTE_ETH_FLOW_FRAG_IPV6:
11058 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11059 entry.input.flow.ipv6_flow.proto = res->proto_value;
11061 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11062 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11063 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11064 entry.input.flow.ipv6_flow.dst_ip);
11065 IPV6_ADDR_TO_ARRAY(res->ip_src,
11066 entry.input.flow.ipv6_flow.src_ip);
11067 entry.input.flow.ipv6_flow.tc = res->tos_value;
11068 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11069 /* need convert to big endian. */
11070 entry.input.flow.udp6_flow.dst_port =
11071 rte_cpu_to_be_16(res->port_dst);
11072 entry.input.flow.udp6_flow.src_port =
11073 rte_cpu_to_be_16(res->port_src);
11075 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11076 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11077 entry.input.flow.sctp6_flow.ip.dst_ip);
11078 IPV6_ADDR_TO_ARRAY(res->ip_src,
11079 entry.input.flow.sctp6_flow.ip.src_ip);
11080 entry.input.flow.ipv6_flow.tc = res->tos_value;
11081 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11082 /* need convert to big endian. */
11083 entry.input.flow.sctp6_flow.dst_port =
11084 rte_cpu_to_be_16(res->port_dst);
11085 entry.input.flow.sctp6_flow.src_port =
11086 rte_cpu_to_be_16(res->port_src);
11087 entry.input.flow.sctp6_flow.verify_tag =
11088 rte_cpu_to_be_32(res->verify_tag_value);
11090 case RTE_ETH_FLOW_L2_PAYLOAD:
11091 entry.input.flow.l2_flow.ether_type =
11092 rte_cpu_to_be_16(res->ether_type);
11098 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11099 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11101 sizeof(struct rte_ether_addr));
11103 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11104 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11106 sizeof(struct rte_ether_addr));
11107 entry.input.flow.tunnel_flow.tunnel_type =
11108 str2fdir_tunneltype(res->tunnel_type);
11109 entry.input.flow.tunnel_flow.tunnel_id =
11110 rte_cpu_to_be_32(res->tunnel_id_value);
11113 rte_memcpy(entry.input.flow_ext.flexbytes,
11115 RTE_ETH_FDIR_MAX_FLEXLEN);
11117 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11119 entry.action.flex_off = 0; /*use 0 by default */
11120 if (!strcmp(res->drop, "drop"))
11121 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11123 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11125 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11126 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11127 if (!strcmp(res->pf_vf, "pf"))
11128 entry.input.flow_ext.is_vf = 0;
11129 else if (!strncmp(res->pf_vf, "vf", 2)) {
11130 struct rte_eth_dev_info dev_info;
11132 ret = eth_dev_info_get_print_err(res->port_id,
11138 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11139 if (errno != 0 || *end != '\0' ||
11140 vf_id >= dev_info.max_vfs) {
11141 printf("invalid parameter %s.\n", res->pf_vf);
11144 entry.input.flow_ext.is_vf = 1;
11145 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11147 printf("invalid parameter %s.\n", res->pf_vf);
11152 /* set to report FD ID by default */
11153 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11154 entry.action.rx_queue = res->queue_id;
11155 entry.soft_id = res->fd_id_value;
11156 if (!strcmp(res->ops, "add"))
11157 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11158 RTE_ETH_FILTER_ADD, &entry);
11159 else if (!strcmp(res->ops, "del"))
11160 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11161 RTE_ETH_FILTER_DELETE, &entry);
11163 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11164 RTE_ETH_FILTER_UPDATE, &entry);
11166 printf("flow director programming error: (%s)\n",
11170 cmdline_parse_token_string_t cmd_flow_director_filter =
11171 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11172 flow_director_filter, "flow_director_filter");
11173 cmdline_parse_token_num_t cmd_flow_director_port_id =
11174 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11176 cmdline_parse_token_string_t cmd_flow_director_ops =
11177 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11178 ops, "add#del#update");
11179 cmdline_parse_token_string_t cmd_flow_director_flow =
11180 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11182 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11183 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11185 cmdline_parse_token_string_t cmd_flow_director_ether =
11186 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11188 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11189 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11190 ether_type, UINT16);
11191 cmdline_parse_token_string_t cmd_flow_director_src =
11192 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11194 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11195 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11197 cmdline_parse_token_num_t cmd_flow_director_port_src =
11198 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11200 cmdline_parse_token_string_t cmd_flow_director_dst =
11201 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11203 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11204 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11206 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11207 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11209 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11210 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11211 verify_tag, "verify_tag");
11212 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11213 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11214 verify_tag_value, UINT32);
11215 cmdline_parse_token_string_t cmd_flow_director_tos =
11216 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11218 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11219 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11221 cmdline_parse_token_string_t cmd_flow_director_proto =
11222 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11224 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11225 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11226 proto_value, UINT8);
11227 cmdline_parse_token_string_t cmd_flow_director_ttl =
11228 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11230 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11231 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11233 cmdline_parse_token_string_t cmd_flow_director_vlan =
11234 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11236 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11237 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11238 vlan_value, UINT16);
11239 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11240 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11241 flexbytes, "flexbytes");
11242 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11243 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11244 flexbytes_value, NULL);
11245 cmdline_parse_token_string_t cmd_flow_director_drop =
11246 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11248 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11249 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11251 cmdline_parse_token_string_t cmd_flow_director_queue =
11252 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11254 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11255 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11257 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11258 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11260 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11261 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11262 fd_id_value, UINT32);
11264 cmdline_parse_token_string_t cmd_flow_director_mode =
11265 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11267 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11268 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11270 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11271 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11272 mode_value, "MAC-VLAN");
11273 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11274 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11275 mode_value, "Tunnel");
11276 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11277 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11278 mode_value, "raw");
11279 cmdline_parse_token_string_t cmd_flow_director_mac =
11280 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11282 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11283 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11285 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11286 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11288 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11289 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11290 tunnel_type, "NVGRE#VxLAN");
11291 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11292 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11293 tunnel_id, "tunnel-id");
11294 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11295 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11296 tunnel_id_value, UINT32);
11297 cmdline_parse_token_string_t cmd_flow_director_packet =
11298 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11300 cmdline_parse_token_string_t cmd_flow_director_filepath =
11301 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11304 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11305 .f = cmd_flow_director_filter_parsed,
11307 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11308 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11309 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11310 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11311 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11312 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11313 "fd_id <fd_id_value>: "
11314 "Add or delete an ip flow director entry on NIC",
11316 (void *)&cmd_flow_director_filter,
11317 (void *)&cmd_flow_director_port_id,
11318 (void *)&cmd_flow_director_mode,
11319 (void *)&cmd_flow_director_mode_ip,
11320 (void *)&cmd_flow_director_ops,
11321 (void *)&cmd_flow_director_flow,
11322 (void *)&cmd_flow_director_flow_type,
11323 (void *)&cmd_flow_director_src,
11324 (void *)&cmd_flow_director_ip_src,
11325 (void *)&cmd_flow_director_dst,
11326 (void *)&cmd_flow_director_ip_dst,
11327 (void *)&cmd_flow_director_tos,
11328 (void *)&cmd_flow_director_tos_value,
11329 (void *)&cmd_flow_director_proto,
11330 (void *)&cmd_flow_director_proto_value,
11331 (void *)&cmd_flow_director_ttl,
11332 (void *)&cmd_flow_director_ttl_value,
11333 (void *)&cmd_flow_director_vlan,
11334 (void *)&cmd_flow_director_vlan_value,
11335 (void *)&cmd_flow_director_flexbytes,
11336 (void *)&cmd_flow_director_flexbytes_value,
11337 (void *)&cmd_flow_director_drop,
11338 (void *)&cmd_flow_director_pf_vf,
11339 (void *)&cmd_flow_director_queue,
11340 (void *)&cmd_flow_director_queue_id,
11341 (void *)&cmd_flow_director_fd_id,
11342 (void *)&cmd_flow_director_fd_id_value,
11347 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11348 .f = cmd_flow_director_filter_parsed,
11350 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11351 "director entry on NIC",
11353 (void *)&cmd_flow_director_filter,
11354 (void *)&cmd_flow_director_port_id,
11355 (void *)&cmd_flow_director_mode,
11356 (void *)&cmd_flow_director_mode_ip,
11357 (void *)&cmd_flow_director_ops,
11358 (void *)&cmd_flow_director_flow,
11359 (void *)&cmd_flow_director_flow_type,
11360 (void *)&cmd_flow_director_src,
11361 (void *)&cmd_flow_director_ip_src,
11362 (void *)&cmd_flow_director_port_src,
11363 (void *)&cmd_flow_director_dst,
11364 (void *)&cmd_flow_director_ip_dst,
11365 (void *)&cmd_flow_director_port_dst,
11366 (void *)&cmd_flow_director_tos,
11367 (void *)&cmd_flow_director_tos_value,
11368 (void *)&cmd_flow_director_ttl,
11369 (void *)&cmd_flow_director_ttl_value,
11370 (void *)&cmd_flow_director_vlan,
11371 (void *)&cmd_flow_director_vlan_value,
11372 (void *)&cmd_flow_director_flexbytes,
11373 (void *)&cmd_flow_director_flexbytes_value,
11374 (void *)&cmd_flow_director_drop,
11375 (void *)&cmd_flow_director_pf_vf,
11376 (void *)&cmd_flow_director_queue,
11377 (void *)&cmd_flow_director_queue_id,
11378 (void *)&cmd_flow_director_fd_id,
11379 (void *)&cmd_flow_director_fd_id_value,
11384 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11385 .f = cmd_flow_director_filter_parsed,
11387 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11388 "director entry on NIC",
11390 (void *)&cmd_flow_director_filter,
11391 (void *)&cmd_flow_director_port_id,
11392 (void *)&cmd_flow_director_mode,
11393 (void *)&cmd_flow_director_mode_ip,
11394 (void *)&cmd_flow_director_ops,
11395 (void *)&cmd_flow_director_flow,
11396 (void *)&cmd_flow_director_flow_type,
11397 (void *)&cmd_flow_director_src,
11398 (void *)&cmd_flow_director_ip_src,
11399 (void *)&cmd_flow_director_port_src,
11400 (void *)&cmd_flow_director_dst,
11401 (void *)&cmd_flow_director_ip_dst,
11402 (void *)&cmd_flow_director_port_dst,
11403 (void *)&cmd_flow_director_verify_tag,
11404 (void *)&cmd_flow_director_verify_tag_value,
11405 (void *)&cmd_flow_director_tos,
11406 (void *)&cmd_flow_director_tos_value,
11407 (void *)&cmd_flow_director_ttl,
11408 (void *)&cmd_flow_director_ttl_value,
11409 (void *)&cmd_flow_director_vlan,
11410 (void *)&cmd_flow_director_vlan_value,
11411 (void *)&cmd_flow_director_flexbytes,
11412 (void *)&cmd_flow_director_flexbytes_value,
11413 (void *)&cmd_flow_director_drop,
11414 (void *)&cmd_flow_director_pf_vf,
11415 (void *)&cmd_flow_director_queue,
11416 (void *)&cmd_flow_director_queue_id,
11417 (void *)&cmd_flow_director_fd_id,
11418 (void *)&cmd_flow_director_fd_id_value,
11423 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11424 .f = cmd_flow_director_filter_parsed,
11426 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11427 "director entry on NIC",
11429 (void *)&cmd_flow_director_filter,
11430 (void *)&cmd_flow_director_port_id,
11431 (void *)&cmd_flow_director_mode,
11432 (void *)&cmd_flow_director_mode_ip,
11433 (void *)&cmd_flow_director_ops,
11434 (void *)&cmd_flow_director_flow,
11435 (void *)&cmd_flow_director_flow_type,
11436 (void *)&cmd_flow_director_ether,
11437 (void *)&cmd_flow_director_ether_type,
11438 (void *)&cmd_flow_director_flexbytes,
11439 (void *)&cmd_flow_director_flexbytes_value,
11440 (void *)&cmd_flow_director_drop,
11441 (void *)&cmd_flow_director_pf_vf,
11442 (void *)&cmd_flow_director_queue,
11443 (void *)&cmd_flow_director_queue_id,
11444 (void *)&cmd_flow_director_fd_id,
11445 (void *)&cmd_flow_director_fd_id_value,
11450 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11451 .f = cmd_flow_director_filter_parsed,
11453 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11454 "director entry on NIC",
11456 (void *)&cmd_flow_director_filter,
11457 (void *)&cmd_flow_director_port_id,
11458 (void *)&cmd_flow_director_mode,
11459 (void *)&cmd_flow_director_mode_mac_vlan,
11460 (void *)&cmd_flow_director_ops,
11461 (void *)&cmd_flow_director_mac,
11462 (void *)&cmd_flow_director_mac_addr,
11463 (void *)&cmd_flow_director_vlan,
11464 (void *)&cmd_flow_director_vlan_value,
11465 (void *)&cmd_flow_director_flexbytes,
11466 (void *)&cmd_flow_director_flexbytes_value,
11467 (void *)&cmd_flow_director_drop,
11468 (void *)&cmd_flow_director_queue,
11469 (void *)&cmd_flow_director_queue_id,
11470 (void *)&cmd_flow_director_fd_id,
11471 (void *)&cmd_flow_director_fd_id_value,
11476 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11477 .f = cmd_flow_director_filter_parsed,
11479 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11480 "director entry on NIC",
11482 (void *)&cmd_flow_director_filter,
11483 (void *)&cmd_flow_director_port_id,
11484 (void *)&cmd_flow_director_mode,
11485 (void *)&cmd_flow_director_mode_tunnel,
11486 (void *)&cmd_flow_director_ops,
11487 (void *)&cmd_flow_director_mac,
11488 (void *)&cmd_flow_director_mac_addr,
11489 (void *)&cmd_flow_director_vlan,
11490 (void *)&cmd_flow_director_vlan_value,
11491 (void *)&cmd_flow_director_tunnel,
11492 (void *)&cmd_flow_director_tunnel_type,
11493 (void *)&cmd_flow_director_tunnel_id,
11494 (void *)&cmd_flow_director_tunnel_id_value,
11495 (void *)&cmd_flow_director_flexbytes,
11496 (void *)&cmd_flow_director_flexbytes_value,
11497 (void *)&cmd_flow_director_drop,
11498 (void *)&cmd_flow_director_queue,
11499 (void *)&cmd_flow_director_queue_id,
11500 (void *)&cmd_flow_director_fd_id,
11501 (void *)&cmd_flow_director_fd_id_value,
11506 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11507 .f = cmd_flow_director_filter_parsed,
11509 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11510 "director entry on NIC",
11512 (void *)&cmd_flow_director_filter,
11513 (void *)&cmd_flow_director_port_id,
11514 (void *)&cmd_flow_director_mode,
11515 (void *)&cmd_flow_director_mode_raw,
11516 (void *)&cmd_flow_director_ops,
11517 (void *)&cmd_flow_director_flow,
11518 (void *)&cmd_flow_director_flow_type,
11519 (void *)&cmd_flow_director_drop,
11520 (void *)&cmd_flow_director_queue,
11521 (void *)&cmd_flow_director_queue_id,
11522 (void *)&cmd_flow_director_fd_id,
11523 (void *)&cmd_flow_director_fd_id_value,
11524 (void *)&cmd_flow_director_packet,
11525 (void *)&cmd_flow_director_filepath,
11530 struct cmd_flush_flow_director_result {
11531 cmdline_fixed_string_t flush_flow_director;
11535 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11536 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11537 flush_flow_director, "flush_flow_director");
11538 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11539 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11543 cmd_flush_flow_director_parsed(void *parsed_result,
11544 __attribute__((unused)) struct cmdline *cl,
11545 __attribute__((unused)) void *data)
11547 struct cmd_flow_director_result *res = parsed_result;
11550 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11552 printf("flow director is not supported on port %u.\n",
11557 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11558 RTE_ETH_FILTER_FLUSH, NULL);
11560 printf("flow director table flushing error: (%s)\n",
11564 cmdline_parse_inst_t cmd_flush_flow_director = {
11565 .f = cmd_flush_flow_director_parsed,
11567 .help_str = "flush_flow_director <port_id>: "
11568 "Flush all flow director entries of a device on NIC",
11570 (void *)&cmd_flush_flow_director_flush,
11571 (void *)&cmd_flush_flow_director_port_id,
11576 /* *** deal with flow director mask *** */
11577 struct cmd_flow_director_mask_result {
11578 cmdline_fixed_string_t flow_director_mask;
11580 cmdline_fixed_string_t mode;
11581 cmdline_fixed_string_t mode_value;
11582 cmdline_fixed_string_t vlan;
11583 uint16_t vlan_mask;
11584 cmdline_fixed_string_t src_mask;
11585 cmdline_ipaddr_t ipv4_src;
11586 cmdline_ipaddr_t ipv6_src;
11588 cmdline_fixed_string_t dst_mask;
11589 cmdline_ipaddr_t ipv4_dst;
11590 cmdline_ipaddr_t ipv6_dst;
11592 cmdline_fixed_string_t mac;
11593 uint8_t mac_addr_byte_mask;
11594 cmdline_fixed_string_t tunnel_id;
11595 uint32_t tunnel_id_mask;
11596 cmdline_fixed_string_t tunnel_type;
11597 uint8_t tunnel_type_mask;
11601 cmd_flow_director_mask_parsed(void *parsed_result,
11602 __attribute__((unused)) struct cmdline *cl,
11603 __attribute__((unused)) void *data)
11605 struct cmd_flow_director_mask_result *res = parsed_result;
11606 struct rte_eth_fdir_masks *mask;
11607 struct rte_port *port;
11609 port = &ports[res->port_id];
11610 /** Check if the port is not started **/
11611 if (port->port_status != RTE_PORT_STOPPED) {
11612 printf("Please stop port %d first\n", res->port_id);
11616 mask = &port->dev_conf.fdir_conf.mask;
11618 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11619 if (strcmp(res->mode_value, "MAC-VLAN")) {
11620 printf("Please set mode to MAC-VLAN.\n");
11624 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11625 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11626 if (strcmp(res->mode_value, "Tunnel")) {
11627 printf("Please set mode to Tunnel.\n");
11631 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11632 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11633 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11634 mask->tunnel_type_mask = res->tunnel_type_mask;
11636 if (strcmp(res->mode_value, "IP")) {
11637 printf("Please set mode to IP.\n");
11641 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11642 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11643 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11644 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11645 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11646 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11647 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11650 cmd_reconfig_device_queue(res->port_id, 1, 1);
11653 cmdline_parse_token_string_t cmd_flow_director_mask =
11654 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11655 flow_director_mask, "flow_director_mask");
11656 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11657 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11659 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11660 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11662 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11663 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11664 vlan_mask, UINT16);
11665 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11666 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11667 src_mask, "src_mask");
11668 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11669 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11671 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11672 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11674 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11675 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11677 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11678 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11679 dst_mask, "dst_mask");
11680 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11681 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11683 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11684 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11686 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11687 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11690 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11691 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11693 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11694 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11696 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11697 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11698 mode_value, "MAC-VLAN");
11699 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11700 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11701 mode_value, "Tunnel");
11702 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11703 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11705 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11706 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11707 mac_addr_byte_mask, UINT8);
11708 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11709 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11710 tunnel_type, "tunnel-type");
11711 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11712 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11713 tunnel_type_mask, UINT8);
11714 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11715 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11716 tunnel_id, "tunnel-id");
11717 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11718 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11719 tunnel_id_mask, UINT32);
11721 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11722 .f = cmd_flow_director_mask_parsed,
11724 .help_str = "flow_director_mask ... : "
11725 "Set IP mode flow director's mask on NIC",
11727 (void *)&cmd_flow_director_mask,
11728 (void *)&cmd_flow_director_mask_port_id,
11729 (void *)&cmd_flow_director_mask_mode,
11730 (void *)&cmd_flow_director_mask_mode_ip,
11731 (void *)&cmd_flow_director_mask_vlan,
11732 (void *)&cmd_flow_director_mask_vlan_value,
11733 (void *)&cmd_flow_director_mask_src,
11734 (void *)&cmd_flow_director_mask_ipv4_src,
11735 (void *)&cmd_flow_director_mask_ipv6_src,
11736 (void *)&cmd_flow_director_mask_port_src,
11737 (void *)&cmd_flow_director_mask_dst,
11738 (void *)&cmd_flow_director_mask_ipv4_dst,
11739 (void *)&cmd_flow_director_mask_ipv6_dst,
11740 (void *)&cmd_flow_director_mask_port_dst,
11745 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11746 .f = cmd_flow_director_mask_parsed,
11748 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11749 "flow director's mask on NIC",
11751 (void *)&cmd_flow_director_mask,
11752 (void *)&cmd_flow_director_mask_port_id,
11753 (void *)&cmd_flow_director_mask_mode,
11754 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11755 (void *)&cmd_flow_director_mask_vlan,
11756 (void *)&cmd_flow_director_mask_vlan_value,
11761 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11762 .f = cmd_flow_director_mask_parsed,
11764 .help_str = "flow_director_mask ... : Set tunnel mode "
11765 "flow director's mask on NIC",
11767 (void *)&cmd_flow_director_mask,
11768 (void *)&cmd_flow_director_mask_port_id,
11769 (void *)&cmd_flow_director_mask_mode,
11770 (void *)&cmd_flow_director_mask_mode_tunnel,
11771 (void *)&cmd_flow_director_mask_vlan,
11772 (void *)&cmd_flow_director_mask_vlan_value,
11773 (void *)&cmd_flow_director_mask_mac,
11774 (void *)&cmd_flow_director_mask_mac_value,
11775 (void *)&cmd_flow_director_mask_tunnel_type,
11776 (void *)&cmd_flow_director_mask_tunnel_type_value,
11777 (void *)&cmd_flow_director_mask_tunnel_id,
11778 (void *)&cmd_flow_director_mask_tunnel_id_value,
11783 /* *** deal with flow director mask on flexible payload *** */
11784 struct cmd_flow_director_flex_mask_result {
11785 cmdline_fixed_string_t flow_director_flexmask;
11787 cmdline_fixed_string_t flow;
11788 cmdline_fixed_string_t flow_type;
11789 cmdline_fixed_string_t mask;
11793 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11794 __attribute__((unused)) struct cmdline *cl,
11795 __attribute__((unused)) void *data)
11797 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11798 struct rte_eth_fdir_info fdir_info;
11799 struct rte_eth_fdir_flex_mask flex_mask;
11800 struct rte_port *port;
11801 uint64_t flow_type_mask;
11805 port = &ports[res->port_id];
11806 /** Check if the port is not started **/
11807 if (port->port_status != RTE_PORT_STOPPED) {
11808 printf("Please stop port %d first\n", res->port_id);
11812 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11813 ret = parse_flexbytes(res->mask,
11815 RTE_ETH_FDIR_MAX_FLEXLEN);
11817 printf("error: Cannot parse mask input.\n");
11821 memset(&fdir_info, 0, sizeof(fdir_info));
11822 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11823 RTE_ETH_FILTER_INFO, &fdir_info);
11825 printf("Cannot get FDir filter info\n");
11829 if (!strcmp(res->flow_type, "none")) {
11830 /* means don't specify the flow type */
11831 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11832 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11833 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11834 0, sizeof(struct rte_eth_fdir_flex_mask));
11835 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11836 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11838 sizeof(struct rte_eth_fdir_flex_mask));
11839 cmd_reconfig_device_queue(res->port_id, 1, 1);
11842 flow_type_mask = fdir_info.flow_types_mask[0];
11843 if (!strcmp(res->flow_type, "all")) {
11844 if (!flow_type_mask) {
11845 printf("No flow type supported\n");
11848 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11849 if (flow_type_mask & (1ULL << i)) {
11850 flex_mask.flow_type = i;
11851 fdir_set_flex_mask(res->port_id, &flex_mask);
11854 cmd_reconfig_device_queue(res->port_id, 1, 1);
11857 flex_mask.flow_type = str2flowtype(res->flow_type);
11858 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11859 printf("Flow type %s not supported on port %d\n",
11860 res->flow_type, res->port_id);
11863 fdir_set_flex_mask(res->port_id, &flex_mask);
11864 cmd_reconfig_device_queue(res->port_id, 1, 1);
11867 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11868 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11869 flow_director_flexmask,
11870 "flow_director_flex_mask");
11871 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11872 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11874 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11875 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11877 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11878 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11879 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11880 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11881 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11882 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11885 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11886 .f = cmd_flow_director_flex_mask_parsed,
11888 .help_str = "flow_director_flex_mask ... : "
11889 "Set flow director's flex mask on NIC",
11891 (void *)&cmd_flow_director_flexmask,
11892 (void *)&cmd_flow_director_flexmask_port_id,
11893 (void *)&cmd_flow_director_flexmask_flow,
11894 (void *)&cmd_flow_director_flexmask_flow_type,
11895 (void *)&cmd_flow_director_flexmask_mask,
11900 /* *** deal with flow director flexible payload configuration *** */
11901 struct cmd_flow_director_flexpayload_result {
11902 cmdline_fixed_string_t flow_director_flexpayload;
11904 cmdline_fixed_string_t payload_layer;
11905 cmdline_fixed_string_t payload_cfg;
11909 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11912 const char *p, *p0 = q_arg;
11914 unsigned long int_fld;
11915 char *str_fld[max_num];
11920 p = strchr(p0, '(');
11924 p0 = strchr(p, ')');
11929 if (size >= sizeof(s))
11932 snprintf(s, sizeof(s), "%.*s", size, p);
11933 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11934 if (ret < 0 || ret > max_num)
11936 for (i = 0; i < ret; i++) {
11938 int_fld = strtoul(str_fld[i], &end, 0);
11939 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11941 offsets[i] = (uint16_t)int_fld;
11947 cmd_flow_director_flxpld_parsed(void *parsed_result,
11948 __attribute__((unused)) struct cmdline *cl,
11949 __attribute__((unused)) void *data)
11951 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11952 struct rte_eth_flex_payload_cfg flex_cfg;
11953 struct rte_port *port;
11956 port = &ports[res->port_id];
11957 /** Check if the port is not started **/
11958 if (port->port_status != RTE_PORT_STOPPED) {
11959 printf("Please stop port %d first\n", res->port_id);
11963 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11965 if (!strcmp(res->payload_layer, "raw"))
11966 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11967 else if (!strcmp(res->payload_layer, "l2"))
11968 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11969 else if (!strcmp(res->payload_layer, "l3"))
11970 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11971 else if (!strcmp(res->payload_layer, "l4"))
11972 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11974 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11975 RTE_ETH_FDIR_MAX_FLEXLEN);
11977 printf("error: Cannot parse flex payload input.\n");
11981 fdir_set_flex_payload(res->port_id, &flex_cfg);
11982 cmd_reconfig_device_queue(res->port_id, 1, 1);
11985 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11986 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11987 flow_director_flexpayload,
11988 "flow_director_flex_payload");
11989 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11990 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11992 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11993 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11994 payload_layer, "raw#l2#l3#l4");
11995 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11996 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11997 payload_cfg, NULL);
11999 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12000 .f = cmd_flow_director_flxpld_parsed,
12002 .help_str = "flow_director_flexpayload ... : "
12003 "Set flow director's flex payload on NIC",
12005 (void *)&cmd_flow_director_flexpayload,
12006 (void *)&cmd_flow_director_flexpayload_port_id,
12007 (void *)&cmd_flow_director_flexpayload_payload_layer,
12008 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12013 /* Generic flow interface command. */
12014 extern cmdline_parse_inst_t cmd_flow;
12016 /* *** Classification Filters Control *** */
12017 /* *** Get symmetric hash enable per port *** */
12018 struct cmd_get_sym_hash_ena_per_port_result {
12019 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12024 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12025 __rte_unused struct cmdline *cl,
12026 __rte_unused void *data)
12028 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12029 struct rte_eth_hash_filter_info info;
12032 if (rte_eth_dev_filter_supported(res->port_id,
12033 RTE_ETH_FILTER_HASH) < 0) {
12034 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12039 memset(&info, 0, sizeof(info));
12040 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12041 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12042 RTE_ETH_FILTER_GET, &info);
12045 printf("Cannot get symmetric hash enable per port "
12046 "on port %u\n", res->port_id);
12050 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12051 "enabled" : "disabled", res->port_id);
12054 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12055 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12056 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12057 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12058 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12061 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12062 .f = cmd_get_sym_hash_per_port_parsed,
12064 .help_str = "get_sym_hash_ena_per_port <port_id>",
12066 (void *)&cmd_get_sym_hash_ena_per_port_all,
12067 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12072 /* *** Set symmetric hash enable per port *** */
12073 struct cmd_set_sym_hash_ena_per_port_result {
12074 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12075 cmdline_fixed_string_t enable;
12080 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12081 __rte_unused struct cmdline *cl,
12082 __rte_unused void *data)
12084 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12085 struct rte_eth_hash_filter_info info;
12088 if (rte_eth_dev_filter_supported(res->port_id,
12089 RTE_ETH_FILTER_HASH) < 0) {
12090 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12095 memset(&info, 0, sizeof(info));
12096 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12097 if (!strcmp(res->enable, "enable"))
12098 info.info.enable = 1;
12099 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12100 RTE_ETH_FILTER_SET, &info);
12102 printf("Cannot set symmetric hash enable per port on "
12103 "port %u\n", res->port_id);
12106 printf("Symmetric hash has been set to %s on port %u\n",
12107 res->enable, res->port_id);
12110 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12111 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12112 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12113 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12114 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12116 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12117 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12118 enable, "enable#disable");
12120 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12121 .f = cmd_set_sym_hash_per_port_parsed,
12123 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12125 (void *)&cmd_set_sym_hash_ena_per_port_all,
12126 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12127 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12132 /* Get global config of hash function */
12133 struct cmd_get_hash_global_config_result {
12134 cmdline_fixed_string_t get_hash_global_config;
12139 flowtype_to_str(uint16_t ftype)
12145 } ftype_table[] = {
12146 {"ipv4", RTE_ETH_FLOW_IPV4},
12147 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12148 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12149 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12150 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12151 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12152 {"ipv6", RTE_ETH_FLOW_IPV6},
12153 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12154 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12155 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12156 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12157 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12158 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12159 {"port", RTE_ETH_FLOW_PORT},
12160 {"vxlan", RTE_ETH_FLOW_VXLAN},
12161 {"geneve", RTE_ETH_FLOW_GENEVE},
12162 {"nvgre", RTE_ETH_FLOW_NVGRE},
12163 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12166 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12167 if (ftype_table[i].ftype == ftype)
12168 return ftype_table[i].str;
12175 cmd_get_hash_global_config_parsed(void *parsed_result,
12176 __rte_unused struct cmdline *cl,
12177 __rte_unused void *data)
12179 struct cmd_get_hash_global_config_result *res = parsed_result;
12180 struct rte_eth_hash_filter_info info;
12181 uint32_t idx, offset;
12186 if (rte_eth_dev_filter_supported(res->port_id,
12187 RTE_ETH_FILTER_HASH) < 0) {
12188 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12193 memset(&info, 0, sizeof(info));
12194 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12195 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12196 RTE_ETH_FILTER_GET, &info);
12198 printf("Cannot get hash global configurations by port %d\n",
12203 switch (info.info.global_conf.hash_func) {
12204 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12205 printf("Hash function is Toeplitz\n");
12207 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12208 printf("Hash function is Simple XOR\n");
12210 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12211 printf("Hash function is Symmetric Toeplitz\n");
12214 printf("Unknown hash function\n");
12218 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12219 idx = i / UINT64_BIT;
12220 offset = i % UINT64_BIT;
12221 if (!(info.info.global_conf.valid_bit_mask[idx] &
12224 str = flowtype_to_str(i);
12227 printf("Symmetric hash is %s globally for flow type %s "
12229 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12230 (1ULL << offset)) ? "enabled" : "disabled"), str,
12235 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12236 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12237 get_hash_global_config, "get_hash_global_config");
12238 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12239 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12242 cmdline_parse_inst_t cmd_get_hash_global_config = {
12243 .f = cmd_get_hash_global_config_parsed,
12245 .help_str = "get_hash_global_config <port_id>",
12247 (void *)&cmd_get_hash_global_config_all,
12248 (void *)&cmd_get_hash_global_config_port_id,
12253 /* Set global config of hash function */
12254 struct cmd_set_hash_global_config_result {
12255 cmdline_fixed_string_t set_hash_global_config;
12257 cmdline_fixed_string_t hash_func;
12258 cmdline_fixed_string_t flow_type;
12259 cmdline_fixed_string_t enable;
12263 cmd_set_hash_global_config_parsed(void *parsed_result,
12264 __rte_unused struct cmdline *cl,
12265 __rte_unused void *data)
12267 struct cmd_set_hash_global_config_result *res = parsed_result;
12268 struct rte_eth_hash_filter_info info;
12269 uint32_t ftype, idx, offset;
12272 if (rte_eth_dev_filter_supported(res->port_id,
12273 RTE_ETH_FILTER_HASH) < 0) {
12274 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12278 memset(&info, 0, sizeof(info));
12279 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12280 if (!strcmp(res->hash_func, "toeplitz"))
12281 info.info.global_conf.hash_func =
12282 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12283 else if (!strcmp(res->hash_func, "simple_xor"))
12284 info.info.global_conf.hash_func =
12285 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12286 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12287 info.info.global_conf.hash_func =
12288 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12289 else if (!strcmp(res->hash_func, "default"))
12290 info.info.global_conf.hash_func =
12291 RTE_ETH_HASH_FUNCTION_DEFAULT;
12293 ftype = str2flowtype(res->flow_type);
12294 idx = ftype / UINT64_BIT;
12295 offset = ftype % UINT64_BIT;
12296 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12297 if (!strcmp(res->enable, "enable"))
12298 info.info.global_conf.sym_hash_enable_mask[idx] |=
12300 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12301 RTE_ETH_FILTER_SET, &info);
12303 printf("Cannot set global hash configurations by port %d\n",
12306 printf("Global hash configurations have been set "
12307 "successfully by port %d\n", res->port_id);
12310 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12311 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12312 set_hash_global_config, "set_hash_global_config");
12313 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12314 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12316 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12317 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12318 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12319 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12320 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12322 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12323 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12324 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12325 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12326 enable, "enable#disable");
12328 cmdline_parse_inst_t cmd_set_hash_global_config = {
12329 .f = cmd_set_hash_global_config_parsed,
12331 .help_str = "set_hash_global_config <port_id> "
12332 "toeplitz|simple_xor|symmetric_toeplitz|default "
12333 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12334 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12335 "l2_payload enable|disable",
12337 (void *)&cmd_set_hash_global_config_all,
12338 (void *)&cmd_set_hash_global_config_port_id,
12339 (void *)&cmd_set_hash_global_config_hash_func,
12340 (void *)&cmd_set_hash_global_config_flow_type,
12341 (void *)&cmd_set_hash_global_config_enable,
12346 /* Set hash input set */
12347 struct cmd_set_hash_input_set_result {
12348 cmdline_fixed_string_t set_hash_input_set;
12350 cmdline_fixed_string_t flow_type;
12351 cmdline_fixed_string_t inset_field;
12352 cmdline_fixed_string_t select;
12355 static enum rte_eth_input_set_field
12356 str2inset(char *string)
12360 static const struct {
12362 enum rte_eth_input_set_field inset;
12363 } inset_table[] = {
12364 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12365 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12366 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12367 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12368 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12369 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12370 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12371 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12372 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12373 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12374 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12375 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12376 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12377 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12378 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12379 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12380 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12381 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12382 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12383 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12384 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12385 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12386 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12387 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12388 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12389 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12390 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12391 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12392 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12393 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12394 {"none", RTE_ETH_INPUT_SET_NONE},
12397 for (i = 0; i < RTE_DIM(inset_table); i++) {
12398 if (!strcmp(string, inset_table[i].str))
12399 return inset_table[i].inset;
12402 return RTE_ETH_INPUT_SET_UNKNOWN;
12406 cmd_set_hash_input_set_parsed(void *parsed_result,
12407 __rte_unused struct cmdline *cl,
12408 __rte_unused void *data)
12410 struct cmd_set_hash_input_set_result *res = parsed_result;
12411 struct rte_eth_hash_filter_info info;
12413 memset(&info, 0, sizeof(info));
12414 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12415 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12416 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12417 info.info.input_set_conf.inset_size = 1;
12418 if (!strcmp(res->select, "select"))
12419 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12420 else if (!strcmp(res->select, "add"))
12421 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12422 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12423 RTE_ETH_FILTER_SET, &info);
12426 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12427 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12428 set_hash_input_set, "set_hash_input_set");
12429 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12430 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12432 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12433 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12435 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12436 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12438 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12439 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12440 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12441 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12442 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12444 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12445 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12446 select, "select#add");
12448 cmdline_parse_inst_t cmd_set_hash_input_set = {
12449 .f = cmd_set_hash_input_set_parsed,
12451 .help_str = "set_hash_input_set <port_id> "
12452 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12453 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12454 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12455 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12456 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12457 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12458 "fld-7th|fld-8th|none select|add",
12460 (void *)&cmd_set_hash_input_set_cmd,
12461 (void *)&cmd_set_hash_input_set_port_id,
12462 (void *)&cmd_set_hash_input_set_flow_type,
12463 (void *)&cmd_set_hash_input_set_field,
12464 (void *)&cmd_set_hash_input_set_select,
12469 /* Set flow director input set */
12470 struct cmd_set_fdir_input_set_result {
12471 cmdline_fixed_string_t set_fdir_input_set;
12473 cmdline_fixed_string_t flow_type;
12474 cmdline_fixed_string_t inset_field;
12475 cmdline_fixed_string_t select;
12479 cmd_set_fdir_input_set_parsed(void *parsed_result,
12480 __rte_unused struct cmdline *cl,
12481 __rte_unused void *data)
12483 struct cmd_set_fdir_input_set_result *res = parsed_result;
12484 struct rte_eth_fdir_filter_info info;
12486 memset(&info, 0, sizeof(info));
12487 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12488 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12489 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12490 info.info.input_set_conf.inset_size = 1;
12491 if (!strcmp(res->select, "select"))
12492 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12493 else if (!strcmp(res->select, "add"))
12494 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12495 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12496 RTE_ETH_FILTER_SET, &info);
12499 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12500 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12501 set_fdir_input_set, "set_fdir_input_set");
12502 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12503 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12505 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12506 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12508 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12509 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12510 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12511 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12513 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12514 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12515 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12516 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12517 "sctp-veri-tag#none");
12518 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12519 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12520 select, "select#add");
12522 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12523 .f = cmd_set_fdir_input_set_parsed,
12525 .help_str = "set_fdir_input_set <port_id> "
12526 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12527 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12528 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12529 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12530 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12531 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12532 "sctp-veri-tag|none select|add",
12534 (void *)&cmd_set_fdir_input_set_cmd,
12535 (void *)&cmd_set_fdir_input_set_port_id,
12536 (void *)&cmd_set_fdir_input_set_flow_type,
12537 (void *)&cmd_set_fdir_input_set_field,
12538 (void *)&cmd_set_fdir_input_set_select,
12543 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12544 struct cmd_mcast_addr_result {
12545 cmdline_fixed_string_t mcast_addr_cmd;
12546 cmdline_fixed_string_t what;
12548 struct rte_ether_addr mc_addr;
12551 static void cmd_mcast_addr_parsed(void *parsed_result,
12552 __attribute__((unused)) struct cmdline *cl,
12553 __attribute__((unused)) void *data)
12555 struct cmd_mcast_addr_result *res = parsed_result;
12557 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12558 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12559 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12560 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12561 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12564 if (strcmp(res->what, "add") == 0)
12565 mcast_addr_add(res->port_num, &res->mc_addr);
12567 mcast_addr_remove(res->port_num, &res->mc_addr);
12570 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12571 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12572 mcast_addr_cmd, "mcast_addr");
12573 cmdline_parse_token_string_t cmd_mcast_addr_what =
12574 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12576 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12577 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12578 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12579 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12581 cmdline_parse_inst_t cmd_mcast_addr = {
12582 .f = cmd_mcast_addr_parsed,
12584 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12585 "Add/Remove multicast MAC address on port_id",
12587 (void *)&cmd_mcast_addr_cmd,
12588 (void *)&cmd_mcast_addr_what,
12589 (void *)&cmd_mcast_addr_portnum,
12590 (void *)&cmd_mcast_addr_addr,
12595 /* l2 tunnel config
12596 * only support E-tag now.
12599 /* Ether type config */
12600 struct cmd_config_l2_tunnel_eth_type_result {
12601 cmdline_fixed_string_t port;
12602 cmdline_fixed_string_t config;
12603 cmdline_fixed_string_t all;
12605 cmdline_fixed_string_t l2_tunnel;
12606 cmdline_fixed_string_t l2_tunnel_type;
12607 cmdline_fixed_string_t eth_type;
12608 uint16_t eth_type_val;
12611 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12612 TOKEN_STRING_INITIALIZER
12613 (struct cmd_config_l2_tunnel_eth_type_result,
12615 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12616 TOKEN_STRING_INITIALIZER
12617 (struct cmd_config_l2_tunnel_eth_type_result,
12619 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12620 TOKEN_STRING_INITIALIZER
12621 (struct cmd_config_l2_tunnel_eth_type_result,
12623 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12624 TOKEN_NUM_INITIALIZER
12625 (struct cmd_config_l2_tunnel_eth_type_result,
12627 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12628 TOKEN_STRING_INITIALIZER
12629 (struct cmd_config_l2_tunnel_eth_type_result,
12630 l2_tunnel, "l2-tunnel");
12631 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12632 TOKEN_STRING_INITIALIZER
12633 (struct cmd_config_l2_tunnel_eth_type_result,
12634 l2_tunnel_type, "E-tag");
12635 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12636 TOKEN_STRING_INITIALIZER
12637 (struct cmd_config_l2_tunnel_eth_type_result,
12638 eth_type, "ether-type");
12639 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12640 TOKEN_NUM_INITIALIZER
12641 (struct cmd_config_l2_tunnel_eth_type_result,
12642 eth_type_val, UINT16);
12644 static enum rte_eth_tunnel_type
12645 str2fdir_l2_tunnel_type(char *string)
12649 static const struct {
12651 enum rte_eth_tunnel_type type;
12652 } l2_tunnel_type_str[] = {
12653 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12656 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12657 if (!strcmp(l2_tunnel_type_str[i].str, string))
12658 return l2_tunnel_type_str[i].type;
12660 return RTE_TUNNEL_TYPE_NONE;
12663 /* ether type config for all ports */
12665 cmd_config_l2_tunnel_eth_type_all_parsed
12666 (void *parsed_result,
12667 __attribute__((unused)) struct cmdline *cl,
12668 __attribute__((unused)) void *data)
12670 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12671 struct rte_eth_l2_tunnel_conf entry;
12674 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12675 entry.ether_type = res->eth_type_val;
12677 RTE_ETH_FOREACH_DEV(pid) {
12678 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12682 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12683 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12685 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12687 (void *)&cmd_config_l2_tunnel_eth_type_port,
12688 (void *)&cmd_config_l2_tunnel_eth_type_config,
12689 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12690 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12691 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12692 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12693 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12698 /* ether type config for a specific port */
12700 cmd_config_l2_tunnel_eth_type_specific_parsed(
12701 void *parsed_result,
12702 __attribute__((unused)) struct cmdline *cl,
12703 __attribute__((unused)) void *data)
12705 struct cmd_config_l2_tunnel_eth_type_result *res =
12707 struct rte_eth_l2_tunnel_conf entry;
12709 if (port_id_is_invalid(res->id, ENABLED_WARN))
12712 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12713 entry.ether_type = res->eth_type_val;
12715 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12718 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12719 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12721 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12723 (void *)&cmd_config_l2_tunnel_eth_type_port,
12724 (void *)&cmd_config_l2_tunnel_eth_type_config,
12725 (void *)&cmd_config_l2_tunnel_eth_type_id,
12726 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12727 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12728 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12729 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12734 /* Enable/disable l2 tunnel */
12735 struct cmd_config_l2_tunnel_en_dis_result {
12736 cmdline_fixed_string_t port;
12737 cmdline_fixed_string_t config;
12738 cmdline_fixed_string_t all;
12740 cmdline_fixed_string_t l2_tunnel;
12741 cmdline_fixed_string_t l2_tunnel_type;
12742 cmdline_fixed_string_t en_dis;
12745 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12746 TOKEN_STRING_INITIALIZER
12747 (struct cmd_config_l2_tunnel_en_dis_result,
12749 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12750 TOKEN_STRING_INITIALIZER
12751 (struct cmd_config_l2_tunnel_en_dis_result,
12753 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12754 TOKEN_STRING_INITIALIZER
12755 (struct cmd_config_l2_tunnel_en_dis_result,
12757 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12758 TOKEN_NUM_INITIALIZER
12759 (struct cmd_config_l2_tunnel_en_dis_result,
12761 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12762 TOKEN_STRING_INITIALIZER
12763 (struct cmd_config_l2_tunnel_en_dis_result,
12764 l2_tunnel, "l2-tunnel");
12765 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12766 TOKEN_STRING_INITIALIZER
12767 (struct cmd_config_l2_tunnel_en_dis_result,
12768 l2_tunnel_type, "E-tag");
12769 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12770 TOKEN_STRING_INITIALIZER
12771 (struct cmd_config_l2_tunnel_en_dis_result,
12772 en_dis, "enable#disable");
12774 /* enable/disable l2 tunnel for all ports */
12776 cmd_config_l2_tunnel_en_dis_all_parsed(
12777 void *parsed_result,
12778 __attribute__((unused)) struct cmdline *cl,
12779 __attribute__((unused)) void *data)
12781 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12782 struct rte_eth_l2_tunnel_conf entry;
12786 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12788 if (!strcmp("enable", res->en_dis))
12793 RTE_ETH_FOREACH_DEV(pid) {
12794 rte_eth_dev_l2_tunnel_offload_set(pid,
12796 ETH_L2_TUNNEL_ENABLE_MASK,
12801 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12802 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12804 .help_str = "port config all l2-tunnel E-tag enable|disable",
12806 (void *)&cmd_config_l2_tunnel_en_dis_port,
12807 (void *)&cmd_config_l2_tunnel_en_dis_config,
12808 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12809 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12810 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12811 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12816 /* enable/disable l2 tunnel for a port */
12818 cmd_config_l2_tunnel_en_dis_specific_parsed(
12819 void *parsed_result,
12820 __attribute__((unused)) struct cmdline *cl,
12821 __attribute__((unused)) void *data)
12823 struct cmd_config_l2_tunnel_en_dis_result *res =
12825 struct rte_eth_l2_tunnel_conf entry;
12827 if (port_id_is_invalid(res->id, ENABLED_WARN))
12830 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12832 if (!strcmp("enable", res->en_dis))
12833 rte_eth_dev_l2_tunnel_offload_set(res->id,
12835 ETH_L2_TUNNEL_ENABLE_MASK,
12838 rte_eth_dev_l2_tunnel_offload_set(res->id,
12840 ETH_L2_TUNNEL_ENABLE_MASK,
12844 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12845 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12847 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12849 (void *)&cmd_config_l2_tunnel_en_dis_port,
12850 (void *)&cmd_config_l2_tunnel_en_dis_config,
12851 (void *)&cmd_config_l2_tunnel_en_dis_id,
12852 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12853 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12854 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12859 /* E-tag configuration */
12861 /* Common result structure for all E-tag configuration */
12862 struct cmd_config_e_tag_result {
12863 cmdline_fixed_string_t e_tag;
12864 cmdline_fixed_string_t set;
12865 cmdline_fixed_string_t insertion;
12866 cmdline_fixed_string_t stripping;
12867 cmdline_fixed_string_t forwarding;
12868 cmdline_fixed_string_t filter;
12869 cmdline_fixed_string_t add;
12870 cmdline_fixed_string_t del;
12871 cmdline_fixed_string_t on;
12872 cmdline_fixed_string_t off;
12873 cmdline_fixed_string_t on_off;
12874 cmdline_fixed_string_t port_tag_id;
12875 uint32_t port_tag_id_val;
12876 cmdline_fixed_string_t e_tag_id;
12877 uint16_t e_tag_id_val;
12878 cmdline_fixed_string_t dst_pool;
12879 uint8_t dst_pool_val;
12880 cmdline_fixed_string_t port;
12882 cmdline_fixed_string_t vf;
12886 /* Common CLI fields for all E-tag configuration */
12887 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12888 TOKEN_STRING_INITIALIZER
12889 (struct cmd_config_e_tag_result,
12891 cmdline_parse_token_string_t cmd_config_e_tag_set =
12892 TOKEN_STRING_INITIALIZER
12893 (struct cmd_config_e_tag_result,
12895 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12896 TOKEN_STRING_INITIALIZER
12897 (struct cmd_config_e_tag_result,
12898 insertion, "insertion");
12899 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12900 TOKEN_STRING_INITIALIZER
12901 (struct cmd_config_e_tag_result,
12902 stripping, "stripping");
12903 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12904 TOKEN_STRING_INITIALIZER
12905 (struct cmd_config_e_tag_result,
12906 forwarding, "forwarding");
12907 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12908 TOKEN_STRING_INITIALIZER
12909 (struct cmd_config_e_tag_result,
12911 cmdline_parse_token_string_t cmd_config_e_tag_add =
12912 TOKEN_STRING_INITIALIZER
12913 (struct cmd_config_e_tag_result,
12915 cmdline_parse_token_string_t cmd_config_e_tag_del =
12916 TOKEN_STRING_INITIALIZER
12917 (struct cmd_config_e_tag_result,
12919 cmdline_parse_token_string_t cmd_config_e_tag_on =
12920 TOKEN_STRING_INITIALIZER
12921 (struct cmd_config_e_tag_result,
12923 cmdline_parse_token_string_t cmd_config_e_tag_off =
12924 TOKEN_STRING_INITIALIZER
12925 (struct cmd_config_e_tag_result,
12927 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12928 TOKEN_STRING_INITIALIZER
12929 (struct cmd_config_e_tag_result,
12931 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12932 TOKEN_STRING_INITIALIZER
12933 (struct cmd_config_e_tag_result,
12934 port_tag_id, "port-tag-id");
12935 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12936 TOKEN_NUM_INITIALIZER
12937 (struct cmd_config_e_tag_result,
12938 port_tag_id_val, UINT32);
12939 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12940 TOKEN_STRING_INITIALIZER
12941 (struct cmd_config_e_tag_result,
12942 e_tag_id, "e-tag-id");
12943 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12944 TOKEN_NUM_INITIALIZER
12945 (struct cmd_config_e_tag_result,
12946 e_tag_id_val, UINT16);
12947 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12948 TOKEN_STRING_INITIALIZER
12949 (struct cmd_config_e_tag_result,
12950 dst_pool, "dst-pool");
12951 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12952 TOKEN_NUM_INITIALIZER
12953 (struct cmd_config_e_tag_result,
12954 dst_pool_val, UINT8);
12955 cmdline_parse_token_string_t cmd_config_e_tag_port =
12956 TOKEN_STRING_INITIALIZER
12957 (struct cmd_config_e_tag_result,
12959 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12960 TOKEN_NUM_INITIALIZER
12961 (struct cmd_config_e_tag_result,
12963 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12964 TOKEN_STRING_INITIALIZER
12965 (struct cmd_config_e_tag_result,
12967 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12968 TOKEN_NUM_INITIALIZER
12969 (struct cmd_config_e_tag_result,
12972 /* E-tag insertion configuration */
12974 cmd_config_e_tag_insertion_en_parsed(
12975 void *parsed_result,
12976 __attribute__((unused)) struct cmdline *cl,
12977 __attribute__((unused)) void *data)
12979 struct cmd_config_e_tag_result *res =
12981 struct rte_eth_l2_tunnel_conf entry;
12983 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12986 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12987 entry.tunnel_id = res->port_tag_id_val;
12988 entry.vf_id = res->vf_id;
12989 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12991 ETH_L2_TUNNEL_INSERTION_MASK,
12996 cmd_config_e_tag_insertion_dis_parsed(
12997 void *parsed_result,
12998 __attribute__((unused)) struct cmdline *cl,
12999 __attribute__((unused)) void *data)
13001 struct cmd_config_e_tag_result *res =
13003 struct rte_eth_l2_tunnel_conf entry;
13005 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13008 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13009 entry.vf_id = res->vf_id;
13011 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13013 ETH_L2_TUNNEL_INSERTION_MASK,
13017 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13018 .f = cmd_config_e_tag_insertion_en_parsed,
13020 .help_str = "E-tag ... : E-tag insertion enable",
13022 (void *)&cmd_config_e_tag_e_tag,
13023 (void *)&cmd_config_e_tag_set,
13024 (void *)&cmd_config_e_tag_insertion,
13025 (void *)&cmd_config_e_tag_on,
13026 (void *)&cmd_config_e_tag_port_tag_id,
13027 (void *)&cmd_config_e_tag_port_tag_id_val,
13028 (void *)&cmd_config_e_tag_port,
13029 (void *)&cmd_config_e_tag_port_id,
13030 (void *)&cmd_config_e_tag_vf,
13031 (void *)&cmd_config_e_tag_vf_id,
13036 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13037 .f = cmd_config_e_tag_insertion_dis_parsed,
13039 .help_str = "E-tag ... : E-tag insertion disable",
13041 (void *)&cmd_config_e_tag_e_tag,
13042 (void *)&cmd_config_e_tag_set,
13043 (void *)&cmd_config_e_tag_insertion,
13044 (void *)&cmd_config_e_tag_off,
13045 (void *)&cmd_config_e_tag_port,
13046 (void *)&cmd_config_e_tag_port_id,
13047 (void *)&cmd_config_e_tag_vf,
13048 (void *)&cmd_config_e_tag_vf_id,
13053 /* E-tag stripping configuration */
13055 cmd_config_e_tag_stripping_parsed(
13056 void *parsed_result,
13057 __attribute__((unused)) struct cmdline *cl,
13058 __attribute__((unused)) void *data)
13060 struct cmd_config_e_tag_result *res =
13062 struct rte_eth_l2_tunnel_conf entry;
13064 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13067 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13069 if (!strcmp(res->on_off, "on"))
13070 rte_eth_dev_l2_tunnel_offload_set
13073 ETH_L2_TUNNEL_STRIPPING_MASK,
13076 rte_eth_dev_l2_tunnel_offload_set
13079 ETH_L2_TUNNEL_STRIPPING_MASK,
13083 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13084 .f = cmd_config_e_tag_stripping_parsed,
13086 .help_str = "E-tag ... : E-tag stripping enable/disable",
13088 (void *)&cmd_config_e_tag_e_tag,
13089 (void *)&cmd_config_e_tag_set,
13090 (void *)&cmd_config_e_tag_stripping,
13091 (void *)&cmd_config_e_tag_on_off,
13092 (void *)&cmd_config_e_tag_port,
13093 (void *)&cmd_config_e_tag_port_id,
13098 /* E-tag forwarding configuration */
13100 cmd_config_e_tag_forwarding_parsed(
13101 void *parsed_result,
13102 __attribute__((unused)) struct cmdline *cl,
13103 __attribute__((unused)) void *data)
13105 struct cmd_config_e_tag_result *res = parsed_result;
13106 struct rte_eth_l2_tunnel_conf entry;
13108 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13111 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13113 if (!strcmp(res->on_off, "on"))
13114 rte_eth_dev_l2_tunnel_offload_set
13117 ETH_L2_TUNNEL_FORWARDING_MASK,
13120 rte_eth_dev_l2_tunnel_offload_set
13123 ETH_L2_TUNNEL_FORWARDING_MASK,
13127 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13128 .f = cmd_config_e_tag_forwarding_parsed,
13130 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13132 (void *)&cmd_config_e_tag_e_tag,
13133 (void *)&cmd_config_e_tag_set,
13134 (void *)&cmd_config_e_tag_forwarding,
13135 (void *)&cmd_config_e_tag_on_off,
13136 (void *)&cmd_config_e_tag_port,
13137 (void *)&cmd_config_e_tag_port_id,
13142 /* E-tag filter configuration */
13144 cmd_config_e_tag_filter_add_parsed(
13145 void *parsed_result,
13146 __attribute__((unused)) struct cmdline *cl,
13147 __attribute__((unused)) void *data)
13149 struct cmd_config_e_tag_result *res = parsed_result;
13150 struct rte_eth_l2_tunnel_conf entry;
13153 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13156 if (res->e_tag_id_val > 0x3fff) {
13157 printf("e-tag-id must be equal or less than 0x3fff.\n");
13161 ret = rte_eth_dev_filter_supported(res->port_id,
13162 RTE_ETH_FILTER_L2_TUNNEL);
13164 printf("E-tag filter is not supported on port %u.\n",
13169 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13170 entry.tunnel_id = res->e_tag_id_val;
13171 entry.pool = res->dst_pool_val;
13173 ret = rte_eth_dev_filter_ctrl(res->port_id,
13174 RTE_ETH_FILTER_L2_TUNNEL,
13175 RTE_ETH_FILTER_ADD,
13178 printf("E-tag filter programming error: (%s)\n",
13182 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13183 .f = cmd_config_e_tag_filter_add_parsed,
13185 .help_str = "E-tag ... : E-tag filter add",
13187 (void *)&cmd_config_e_tag_e_tag,
13188 (void *)&cmd_config_e_tag_set,
13189 (void *)&cmd_config_e_tag_filter,
13190 (void *)&cmd_config_e_tag_add,
13191 (void *)&cmd_config_e_tag_e_tag_id,
13192 (void *)&cmd_config_e_tag_e_tag_id_val,
13193 (void *)&cmd_config_e_tag_dst_pool,
13194 (void *)&cmd_config_e_tag_dst_pool_val,
13195 (void *)&cmd_config_e_tag_port,
13196 (void *)&cmd_config_e_tag_port_id,
13202 cmd_config_e_tag_filter_del_parsed(
13203 void *parsed_result,
13204 __attribute__((unused)) struct cmdline *cl,
13205 __attribute__((unused)) void *data)
13207 struct cmd_config_e_tag_result *res = parsed_result;
13208 struct rte_eth_l2_tunnel_conf entry;
13211 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13214 if (res->e_tag_id_val > 0x3fff) {
13215 printf("e-tag-id must be less than 0x3fff.\n");
13219 ret = rte_eth_dev_filter_supported(res->port_id,
13220 RTE_ETH_FILTER_L2_TUNNEL);
13222 printf("E-tag filter is not supported on port %u.\n",
13227 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13228 entry.tunnel_id = res->e_tag_id_val;
13230 ret = rte_eth_dev_filter_ctrl(res->port_id,
13231 RTE_ETH_FILTER_L2_TUNNEL,
13232 RTE_ETH_FILTER_DELETE,
13235 printf("E-tag filter programming error: (%s)\n",
13239 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13240 .f = cmd_config_e_tag_filter_del_parsed,
13242 .help_str = "E-tag ... : E-tag filter delete",
13244 (void *)&cmd_config_e_tag_e_tag,
13245 (void *)&cmd_config_e_tag_set,
13246 (void *)&cmd_config_e_tag_filter,
13247 (void *)&cmd_config_e_tag_del,
13248 (void *)&cmd_config_e_tag_e_tag_id,
13249 (void *)&cmd_config_e_tag_e_tag_id_val,
13250 (void *)&cmd_config_e_tag_port,
13251 (void *)&cmd_config_e_tag_port_id,
13256 /* vf vlan anti spoof configuration */
13258 /* Common result structure for vf vlan anti spoof */
13259 struct cmd_vf_vlan_anti_spoof_result {
13260 cmdline_fixed_string_t set;
13261 cmdline_fixed_string_t vf;
13262 cmdline_fixed_string_t vlan;
13263 cmdline_fixed_string_t antispoof;
13266 cmdline_fixed_string_t on_off;
13269 /* Common CLI fields for vf vlan anti spoof enable disable */
13270 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13271 TOKEN_STRING_INITIALIZER
13272 (struct cmd_vf_vlan_anti_spoof_result,
13274 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13275 TOKEN_STRING_INITIALIZER
13276 (struct cmd_vf_vlan_anti_spoof_result,
13278 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13279 TOKEN_STRING_INITIALIZER
13280 (struct cmd_vf_vlan_anti_spoof_result,
13282 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13283 TOKEN_STRING_INITIALIZER
13284 (struct cmd_vf_vlan_anti_spoof_result,
13285 antispoof, "antispoof");
13286 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13287 TOKEN_NUM_INITIALIZER
13288 (struct cmd_vf_vlan_anti_spoof_result,
13290 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13291 TOKEN_NUM_INITIALIZER
13292 (struct cmd_vf_vlan_anti_spoof_result,
13294 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13295 TOKEN_STRING_INITIALIZER
13296 (struct cmd_vf_vlan_anti_spoof_result,
13300 cmd_set_vf_vlan_anti_spoof_parsed(
13301 void *parsed_result,
13302 __attribute__((unused)) struct cmdline *cl,
13303 __attribute__((unused)) void *data)
13305 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13306 int ret = -ENOTSUP;
13308 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13310 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13313 #ifdef RTE_LIBRTE_IXGBE_PMD
13314 if (ret == -ENOTSUP)
13315 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13316 res->vf_id, is_on);
13318 #ifdef RTE_LIBRTE_I40E_PMD
13319 if (ret == -ENOTSUP)
13320 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13321 res->vf_id, is_on);
13323 #ifdef RTE_LIBRTE_BNXT_PMD
13324 if (ret == -ENOTSUP)
13325 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13326 res->vf_id, is_on);
13333 printf("invalid vf_id %d\n", res->vf_id);
13336 printf("invalid port_id %d\n", res->port_id);
13339 printf("function not implemented\n");
13342 printf("programming error: (%s)\n", strerror(-ret));
13346 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13347 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13349 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13351 (void *)&cmd_vf_vlan_anti_spoof_set,
13352 (void *)&cmd_vf_vlan_anti_spoof_vf,
13353 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13354 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13355 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13356 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13357 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13362 /* vf mac anti spoof configuration */
13364 /* Common result structure for vf mac anti spoof */
13365 struct cmd_vf_mac_anti_spoof_result {
13366 cmdline_fixed_string_t set;
13367 cmdline_fixed_string_t vf;
13368 cmdline_fixed_string_t mac;
13369 cmdline_fixed_string_t antispoof;
13372 cmdline_fixed_string_t on_off;
13375 /* Common CLI fields for vf mac anti spoof enable disable */
13376 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13377 TOKEN_STRING_INITIALIZER
13378 (struct cmd_vf_mac_anti_spoof_result,
13380 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13381 TOKEN_STRING_INITIALIZER
13382 (struct cmd_vf_mac_anti_spoof_result,
13384 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13385 TOKEN_STRING_INITIALIZER
13386 (struct cmd_vf_mac_anti_spoof_result,
13388 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13389 TOKEN_STRING_INITIALIZER
13390 (struct cmd_vf_mac_anti_spoof_result,
13391 antispoof, "antispoof");
13392 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13393 TOKEN_NUM_INITIALIZER
13394 (struct cmd_vf_mac_anti_spoof_result,
13396 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13397 TOKEN_NUM_INITIALIZER
13398 (struct cmd_vf_mac_anti_spoof_result,
13400 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13401 TOKEN_STRING_INITIALIZER
13402 (struct cmd_vf_mac_anti_spoof_result,
13406 cmd_set_vf_mac_anti_spoof_parsed(
13407 void *parsed_result,
13408 __attribute__((unused)) struct cmdline *cl,
13409 __attribute__((unused)) void *data)
13411 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13412 int ret = -ENOTSUP;
13414 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13416 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13419 #ifdef RTE_LIBRTE_IXGBE_PMD
13420 if (ret == -ENOTSUP)
13421 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13422 res->vf_id, is_on);
13424 #ifdef RTE_LIBRTE_I40E_PMD
13425 if (ret == -ENOTSUP)
13426 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13427 res->vf_id, is_on);
13429 #ifdef RTE_LIBRTE_BNXT_PMD
13430 if (ret == -ENOTSUP)
13431 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13432 res->vf_id, is_on);
13439 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13442 printf("invalid port_id %d\n", res->port_id);
13445 printf("function not implemented\n");
13448 printf("programming error: (%s)\n", strerror(-ret));
13452 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13453 .f = cmd_set_vf_mac_anti_spoof_parsed,
13455 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13457 (void *)&cmd_vf_mac_anti_spoof_set,
13458 (void *)&cmd_vf_mac_anti_spoof_vf,
13459 (void *)&cmd_vf_mac_anti_spoof_mac,
13460 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13461 (void *)&cmd_vf_mac_anti_spoof_port_id,
13462 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13463 (void *)&cmd_vf_mac_anti_spoof_on_off,
13468 /* vf vlan strip queue configuration */
13470 /* Common result structure for vf mac anti spoof */
13471 struct cmd_vf_vlan_stripq_result {
13472 cmdline_fixed_string_t set;
13473 cmdline_fixed_string_t vf;
13474 cmdline_fixed_string_t vlan;
13475 cmdline_fixed_string_t stripq;
13478 cmdline_fixed_string_t on_off;
13481 /* Common CLI fields for vf vlan strip enable disable */
13482 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13483 TOKEN_STRING_INITIALIZER
13484 (struct cmd_vf_vlan_stripq_result,
13486 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13487 TOKEN_STRING_INITIALIZER
13488 (struct cmd_vf_vlan_stripq_result,
13490 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13491 TOKEN_STRING_INITIALIZER
13492 (struct cmd_vf_vlan_stripq_result,
13494 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13495 TOKEN_STRING_INITIALIZER
13496 (struct cmd_vf_vlan_stripq_result,
13498 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13499 TOKEN_NUM_INITIALIZER
13500 (struct cmd_vf_vlan_stripq_result,
13502 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13503 TOKEN_NUM_INITIALIZER
13504 (struct cmd_vf_vlan_stripq_result,
13506 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13507 TOKEN_STRING_INITIALIZER
13508 (struct cmd_vf_vlan_stripq_result,
13512 cmd_set_vf_vlan_stripq_parsed(
13513 void *parsed_result,
13514 __attribute__((unused)) struct cmdline *cl,
13515 __attribute__((unused)) void *data)
13517 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13518 int ret = -ENOTSUP;
13520 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13522 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13525 #ifdef RTE_LIBRTE_IXGBE_PMD
13526 if (ret == -ENOTSUP)
13527 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13528 res->vf_id, is_on);
13530 #ifdef RTE_LIBRTE_I40E_PMD
13531 if (ret == -ENOTSUP)
13532 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13533 res->vf_id, is_on);
13535 #ifdef RTE_LIBRTE_BNXT_PMD
13536 if (ret == -ENOTSUP)
13537 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13538 res->vf_id, is_on);
13545 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13548 printf("invalid port_id %d\n", res->port_id);
13551 printf("function not implemented\n");
13554 printf("programming error: (%s)\n", strerror(-ret));
13558 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13559 .f = cmd_set_vf_vlan_stripq_parsed,
13561 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13563 (void *)&cmd_vf_vlan_stripq_set,
13564 (void *)&cmd_vf_vlan_stripq_vf,
13565 (void *)&cmd_vf_vlan_stripq_vlan,
13566 (void *)&cmd_vf_vlan_stripq_stripq,
13567 (void *)&cmd_vf_vlan_stripq_port_id,
13568 (void *)&cmd_vf_vlan_stripq_vf_id,
13569 (void *)&cmd_vf_vlan_stripq_on_off,
13574 /* vf vlan insert configuration */
13576 /* Common result structure for vf vlan insert */
13577 struct cmd_vf_vlan_insert_result {
13578 cmdline_fixed_string_t set;
13579 cmdline_fixed_string_t vf;
13580 cmdline_fixed_string_t vlan;
13581 cmdline_fixed_string_t insert;
13587 /* Common CLI fields for vf vlan insert enable disable */
13588 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13589 TOKEN_STRING_INITIALIZER
13590 (struct cmd_vf_vlan_insert_result,
13592 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13593 TOKEN_STRING_INITIALIZER
13594 (struct cmd_vf_vlan_insert_result,
13596 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13597 TOKEN_STRING_INITIALIZER
13598 (struct cmd_vf_vlan_insert_result,
13600 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13601 TOKEN_STRING_INITIALIZER
13602 (struct cmd_vf_vlan_insert_result,
13604 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13605 TOKEN_NUM_INITIALIZER
13606 (struct cmd_vf_vlan_insert_result,
13608 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13609 TOKEN_NUM_INITIALIZER
13610 (struct cmd_vf_vlan_insert_result,
13612 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13613 TOKEN_NUM_INITIALIZER
13614 (struct cmd_vf_vlan_insert_result,
13618 cmd_set_vf_vlan_insert_parsed(
13619 void *parsed_result,
13620 __attribute__((unused)) struct cmdline *cl,
13621 __attribute__((unused)) void *data)
13623 struct cmd_vf_vlan_insert_result *res = parsed_result;
13624 int ret = -ENOTSUP;
13626 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13629 #ifdef RTE_LIBRTE_IXGBE_PMD
13630 if (ret == -ENOTSUP)
13631 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13634 #ifdef RTE_LIBRTE_I40E_PMD
13635 if (ret == -ENOTSUP)
13636 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13639 #ifdef RTE_LIBRTE_BNXT_PMD
13640 if (ret == -ENOTSUP)
13641 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13649 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13652 printf("invalid port_id %d\n", res->port_id);
13655 printf("function not implemented\n");
13658 printf("programming error: (%s)\n", strerror(-ret));
13662 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13663 .f = cmd_set_vf_vlan_insert_parsed,
13665 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13667 (void *)&cmd_vf_vlan_insert_set,
13668 (void *)&cmd_vf_vlan_insert_vf,
13669 (void *)&cmd_vf_vlan_insert_vlan,
13670 (void *)&cmd_vf_vlan_insert_insert,
13671 (void *)&cmd_vf_vlan_insert_port_id,
13672 (void *)&cmd_vf_vlan_insert_vf_id,
13673 (void *)&cmd_vf_vlan_insert_vlan_id,
13678 /* tx loopback configuration */
13680 /* Common result structure for tx loopback */
13681 struct cmd_tx_loopback_result {
13682 cmdline_fixed_string_t set;
13683 cmdline_fixed_string_t tx;
13684 cmdline_fixed_string_t loopback;
13686 cmdline_fixed_string_t on_off;
13689 /* Common CLI fields for tx loopback enable disable */
13690 cmdline_parse_token_string_t cmd_tx_loopback_set =
13691 TOKEN_STRING_INITIALIZER
13692 (struct cmd_tx_loopback_result,
13694 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13695 TOKEN_STRING_INITIALIZER
13696 (struct cmd_tx_loopback_result,
13698 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13699 TOKEN_STRING_INITIALIZER
13700 (struct cmd_tx_loopback_result,
13701 loopback, "loopback");
13702 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13703 TOKEN_NUM_INITIALIZER
13704 (struct cmd_tx_loopback_result,
13706 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13707 TOKEN_STRING_INITIALIZER
13708 (struct cmd_tx_loopback_result,
13712 cmd_set_tx_loopback_parsed(
13713 void *parsed_result,
13714 __attribute__((unused)) struct cmdline *cl,
13715 __attribute__((unused)) void *data)
13717 struct cmd_tx_loopback_result *res = parsed_result;
13718 int ret = -ENOTSUP;
13720 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13722 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13725 #ifdef RTE_LIBRTE_IXGBE_PMD
13726 if (ret == -ENOTSUP)
13727 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13729 #ifdef RTE_LIBRTE_I40E_PMD
13730 if (ret == -ENOTSUP)
13731 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13733 #ifdef RTE_LIBRTE_BNXT_PMD
13734 if (ret == -ENOTSUP)
13735 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13737 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13738 if (ret == -ENOTSUP)
13739 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13746 printf("invalid is_on %d\n", is_on);
13749 printf("invalid port_id %d\n", res->port_id);
13752 printf("function not implemented\n");
13755 printf("programming error: (%s)\n", strerror(-ret));
13759 cmdline_parse_inst_t cmd_set_tx_loopback = {
13760 .f = cmd_set_tx_loopback_parsed,
13762 .help_str = "set tx loopback <port_id> on|off",
13764 (void *)&cmd_tx_loopback_set,
13765 (void *)&cmd_tx_loopback_tx,
13766 (void *)&cmd_tx_loopback_loopback,
13767 (void *)&cmd_tx_loopback_port_id,
13768 (void *)&cmd_tx_loopback_on_off,
13773 /* all queues drop enable configuration */
13775 /* Common result structure for all queues drop enable */
13776 struct cmd_all_queues_drop_en_result {
13777 cmdline_fixed_string_t set;
13778 cmdline_fixed_string_t all;
13779 cmdline_fixed_string_t queues;
13780 cmdline_fixed_string_t drop;
13782 cmdline_fixed_string_t on_off;
13785 /* Common CLI fields for tx loopback enable disable */
13786 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13787 TOKEN_STRING_INITIALIZER
13788 (struct cmd_all_queues_drop_en_result,
13790 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13791 TOKEN_STRING_INITIALIZER
13792 (struct cmd_all_queues_drop_en_result,
13794 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13795 TOKEN_STRING_INITIALIZER
13796 (struct cmd_all_queues_drop_en_result,
13798 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13799 TOKEN_STRING_INITIALIZER
13800 (struct cmd_all_queues_drop_en_result,
13802 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13803 TOKEN_NUM_INITIALIZER
13804 (struct cmd_all_queues_drop_en_result,
13806 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13807 TOKEN_STRING_INITIALIZER
13808 (struct cmd_all_queues_drop_en_result,
13812 cmd_set_all_queues_drop_en_parsed(
13813 void *parsed_result,
13814 __attribute__((unused)) struct cmdline *cl,
13815 __attribute__((unused)) void *data)
13817 struct cmd_all_queues_drop_en_result *res = parsed_result;
13818 int ret = -ENOTSUP;
13819 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13821 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13824 #ifdef RTE_LIBRTE_IXGBE_PMD
13825 if (ret == -ENOTSUP)
13826 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13828 #ifdef RTE_LIBRTE_BNXT_PMD
13829 if (ret == -ENOTSUP)
13830 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13836 printf("invalid is_on %d\n", is_on);
13839 printf("invalid port_id %d\n", res->port_id);
13842 printf("function not implemented\n");
13845 printf("programming error: (%s)\n", strerror(-ret));
13849 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13850 .f = cmd_set_all_queues_drop_en_parsed,
13852 .help_str = "set all queues drop <port_id> on|off",
13854 (void *)&cmd_all_queues_drop_en_set,
13855 (void *)&cmd_all_queues_drop_en_all,
13856 (void *)&cmd_all_queues_drop_en_queues,
13857 (void *)&cmd_all_queues_drop_en_drop,
13858 (void *)&cmd_all_queues_drop_en_port_id,
13859 (void *)&cmd_all_queues_drop_en_on_off,
13864 /* vf split drop enable configuration */
13866 /* Common result structure for vf split drop enable */
13867 struct cmd_vf_split_drop_en_result {
13868 cmdline_fixed_string_t set;
13869 cmdline_fixed_string_t vf;
13870 cmdline_fixed_string_t split;
13871 cmdline_fixed_string_t drop;
13874 cmdline_fixed_string_t on_off;
13877 /* Common CLI fields for vf split drop enable disable */
13878 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13879 TOKEN_STRING_INITIALIZER
13880 (struct cmd_vf_split_drop_en_result,
13882 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13883 TOKEN_STRING_INITIALIZER
13884 (struct cmd_vf_split_drop_en_result,
13886 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13887 TOKEN_STRING_INITIALIZER
13888 (struct cmd_vf_split_drop_en_result,
13890 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13891 TOKEN_STRING_INITIALIZER
13892 (struct cmd_vf_split_drop_en_result,
13894 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13895 TOKEN_NUM_INITIALIZER
13896 (struct cmd_vf_split_drop_en_result,
13898 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13899 TOKEN_NUM_INITIALIZER
13900 (struct cmd_vf_split_drop_en_result,
13902 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13903 TOKEN_STRING_INITIALIZER
13904 (struct cmd_vf_split_drop_en_result,
13908 cmd_set_vf_split_drop_en_parsed(
13909 void *parsed_result,
13910 __attribute__((unused)) struct cmdline *cl,
13911 __attribute__((unused)) void *data)
13913 struct cmd_vf_split_drop_en_result *res = parsed_result;
13914 int ret = -ENOTSUP;
13915 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13917 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13920 #ifdef RTE_LIBRTE_IXGBE_PMD
13921 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13928 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13931 printf("invalid port_id %d\n", res->port_id);
13934 printf("not supported on port %d\n", res->port_id);
13937 printf("programming error: (%s)\n", strerror(-ret));
13941 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13942 .f = cmd_set_vf_split_drop_en_parsed,
13944 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13946 (void *)&cmd_vf_split_drop_en_set,
13947 (void *)&cmd_vf_split_drop_en_vf,
13948 (void *)&cmd_vf_split_drop_en_split,
13949 (void *)&cmd_vf_split_drop_en_drop,
13950 (void *)&cmd_vf_split_drop_en_port_id,
13951 (void *)&cmd_vf_split_drop_en_vf_id,
13952 (void *)&cmd_vf_split_drop_en_on_off,
13957 /* vf mac address configuration */
13959 /* Common result structure for vf mac address */
13960 struct cmd_set_vf_mac_addr_result {
13961 cmdline_fixed_string_t set;
13962 cmdline_fixed_string_t vf;
13963 cmdline_fixed_string_t mac;
13964 cmdline_fixed_string_t addr;
13967 struct rte_ether_addr mac_addr;
13971 /* Common CLI fields for vf split drop enable disable */
13972 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13973 TOKEN_STRING_INITIALIZER
13974 (struct cmd_set_vf_mac_addr_result,
13976 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13977 TOKEN_STRING_INITIALIZER
13978 (struct cmd_set_vf_mac_addr_result,
13980 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13981 TOKEN_STRING_INITIALIZER
13982 (struct cmd_set_vf_mac_addr_result,
13984 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13985 TOKEN_STRING_INITIALIZER
13986 (struct cmd_set_vf_mac_addr_result,
13988 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13989 TOKEN_NUM_INITIALIZER
13990 (struct cmd_set_vf_mac_addr_result,
13992 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13993 TOKEN_NUM_INITIALIZER
13994 (struct cmd_set_vf_mac_addr_result,
13996 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13997 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14001 cmd_set_vf_mac_addr_parsed(
14002 void *parsed_result,
14003 __attribute__((unused)) struct cmdline *cl,
14004 __attribute__((unused)) void *data)
14006 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14007 int ret = -ENOTSUP;
14009 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14012 #ifdef RTE_LIBRTE_IXGBE_PMD
14013 if (ret == -ENOTSUP)
14014 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14017 #ifdef RTE_LIBRTE_I40E_PMD
14018 if (ret == -ENOTSUP)
14019 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14022 #ifdef RTE_LIBRTE_BNXT_PMD
14023 if (ret == -ENOTSUP)
14024 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14032 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14035 printf("invalid port_id %d\n", res->port_id);
14038 printf("function not implemented\n");
14041 printf("programming error: (%s)\n", strerror(-ret));
14045 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14046 .f = cmd_set_vf_mac_addr_parsed,
14048 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14050 (void *)&cmd_set_vf_mac_addr_set,
14051 (void *)&cmd_set_vf_mac_addr_vf,
14052 (void *)&cmd_set_vf_mac_addr_mac,
14053 (void *)&cmd_set_vf_mac_addr_addr,
14054 (void *)&cmd_set_vf_mac_addr_port_id,
14055 (void *)&cmd_set_vf_mac_addr_vf_id,
14056 (void *)&cmd_set_vf_mac_addr_mac_addr,
14061 /* MACsec configuration */
14063 /* Common result structure for MACsec offload enable */
14064 struct cmd_macsec_offload_on_result {
14065 cmdline_fixed_string_t set;
14066 cmdline_fixed_string_t macsec;
14067 cmdline_fixed_string_t offload;
14069 cmdline_fixed_string_t on;
14070 cmdline_fixed_string_t encrypt;
14071 cmdline_fixed_string_t en_on_off;
14072 cmdline_fixed_string_t replay_protect;
14073 cmdline_fixed_string_t rp_on_off;
14076 /* Common CLI fields for MACsec offload disable */
14077 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14078 TOKEN_STRING_INITIALIZER
14079 (struct cmd_macsec_offload_on_result,
14081 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14082 TOKEN_STRING_INITIALIZER
14083 (struct cmd_macsec_offload_on_result,
14085 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14086 TOKEN_STRING_INITIALIZER
14087 (struct cmd_macsec_offload_on_result,
14088 offload, "offload");
14089 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14090 TOKEN_NUM_INITIALIZER
14091 (struct cmd_macsec_offload_on_result,
14093 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14094 TOKEN_STRING_INITIALIZER
14095 (struct cmd_macsec_offload_on_result,
14097 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14098 TOKEN_STRING_INITIALIZER
14099 (struct cmd_macsec_offload_on_result,
14100 encrypt, "encrypt");
14101 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14102 TOKEN_STRING_INITIALIZER
14103 (struct cmd_macsec_offload_on_result,
14104 en_on_off, "on#off");
14105 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14106 TOKEN_STRING_INITIALIZER
14107 (struct cmd_macsec_offload_on_result,
14108 replay_protect, "replay-protect");
14109 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14110 TOKEN_STRING_INITIALIZER
14111 (struct cmd_macsec_offload_on_result,
14112 rp_on_off, "on#off");
14115 cmd_set_macsec_offload_on_parsed(
14116 void *parsed_result,
14117 __attribute__((unused)) struct cmdline *cl,
14118 __attribute__((unused)) void *data)
14120 struct cmd_macsec_offload_on_result *res = parsed_result;
14121 int ret = -ENOTSUP;
14122 portid_t port_id = res->port_id;
14123 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14124 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14125 struct rte_eth_dev_info dev_info;
14127 if (port_id_is_invalid(port_id, ENABLED_WARN))
14129 if (!port_is_stopped(port_id)) {
14130 printf("Please stop port %d first\n", port_id);
14134 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14138 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14139 #ifdef RTE_LIBRTE_IXGBE_PMD
14140 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14148 ports[port_id].dev_conf.txmode.offloads |=
14149 DEV_TX_OFFLOAD_MACSEC_INSERT;
14150 cmd_reconfig_device_queue(port_id, 1, 1);
14153 printf("invalid port_id %d\n", port_id);
14156 printf("not supported on port %d\n", port_id);
14159 printf("programming error: (%s)\n", strerror(-ret));
14163 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14164 .f = cmd_set_macsec_offload_on_parsed,
14166 .help_str = "set macsec offload <port_id> on "
14167 "encrypt on|off replay-protect on|off",
14169 (void *)&cmd_macsec_offload_on_set,
14170 (void *)&cmd_macsec_offload_on_macsec,
14171 (void *)&cmd_macsec_offload_on_offload,
14172 (void *)&cmd_macsec_offload_on_port_id,
14173 (void *)&cmd_macsec_offload_on_on,
14174 (void *)&cmd_macsec_offload_on_encrypt,
14175 (void *)&cmd_macsec_offload_on_en_on_off,
14176 (void *)&cmd_macsec_offload_on_replay_protect,
14177 (void *)&cmd_macsec_offload_on_rp_on_off,
14182 /* Common result structure for MACsec offload disable */
14183 struct cmd_macsec_offload_off_result {
14184 cmdline_fixed_string_t set;
14185 cmdline_fixed_string_t macsec;
14186 cmdline_fixed_string_t offload;
14188 cmdline_fixed_string_t off;
14191 /* Common CLI fields for MACsec offload disable */
14192 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14193 TOKEN_STRING_INITIALIZER
14194 (struct cmd_macsec_offload_off_result,
14196 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14197 TOKEN_STRING_INITIALIZER
14198 (struct cmd_macsec_offload_off_result,
14200 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14201 TOKEN_STRING_INITIALIZER
14202 (struct cmd_macsec_offload_off_result,
14203 offload, "offload");
14204 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14205 TOKEN_NUM_INITIALIZER
14206 (struct cmd_macsec_offload_off_result,
14208 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14209 TOKEN_STRING_INITIALIZER
14210 (struct cmd_macsec_offload_off_result,
14214 cmd_set_macsec_offload_off_parsed(
14215 void *parsed_result,
14216 __attribute__((unused)) struct cmdline *cl,
14217 __attribute__((unused)) void *data)
14219 struct cmd_macsec_offload_off_result *res = parsed_result;
14220 int ret = -ENOTSUP;
14221 struct rte_eth_dev_info dev_info;
14222 portid_t port_id = res->port_id;
14224 if (port_id_is_invalid(port_id, ENABLED_WARN))
14226 if (!port_is_stopped(port_id)) {
14227 printf("Please stop port %d first\n", port_id);
14231 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14235 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14236 #ifdef RTE_LIBRTE_IXGBE_PMD
14237 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14242 ports[port_id].dev_conf.txmode.offloads &=
14243 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14244 cmd_reconfig_device_queue(port_id, 1, 1);
14247 printf("invalid port_id %d\n", port_id);
14250 printf("not supported on port %d\n", port_id);
14253 printf("programming error: (%s)\n", strerror(-ret));
14257 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14258 .f = cmd_set_macsec_offload_off_parsed,
14260 .help_str = "set macsec offload <port_id> off",
14262 (void *)&cmd_macsec_offload_off_set,
14263 (void *)&cmd_macsec_offload_off_macsec,
14264 (void *)&cmd_macsec_offload_off_offload,
14265 (void *)&cmd_macsec_offload_off_port_id,
14266 (void *)&cmd_macsec_offload_off_off,
14271 /* Common result structure for MACsec secure connection configure */
14272 struct cmd_macsec_sc_result {
14273 cmdline_fixed_string_t set;
14274 cmdline_fixed_string_t macsec;
14275 cmdline_fixed_string_t sc;
14276 cmdline_fixed_string_t tx_rx;
14278 struct rte_ether_addr mac;
14282 /* Common CLI fields for MACsec secure connection configure */
14283 cmdline_parse_token_string_t cmd_macsec_sc_set =
14284 TOKEN_STRING_INITIALIZER
14285 (struct cmd_macsec_sc_result,
14287 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14288 TOKEN_STRING_INITIALIZER
14289 (struct cmd_macsec_sc_result,
14291 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14292 TOKEN_STRING_INITIALIZER
14293 (struct cmd_macsec_sc_result,
14295 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14296 TOKEN_STRING_INITIALIZER
14297 (struct cmd_macsec_sc_result,
14299 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14300 TOKEN_NUM_INITIALIZER
14301 (struct cmd_macsec_sc_result,
14303 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14304 TOKEN_ETHERADDR_INITIALIZER
14305 (struct cmd_macsec_sc_result,
14307 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14308 TOKEN_NUM_INITIALIZER
14309 (struct cmd_macsec_sc_result,
14313 cmd_set_macsec_sc_parsed(
14314 void *parsed_result,
14315 __attribute__((unused)) struct cmdline *cl,
14316 __attribute__((unused)) void *data)
14318 struct cmd_macsec_sc_result *res = parsed_result;
14319 int ret = -ENOTSUP;
14320 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14322 #ifdef RTE_LIBRTE_IXGBE_PMD
14324 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14325 res->mac.addr_bytes) :
14326 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14327 res->mac.addr_bytes, res->pi);
14329 RTE_SET_USED(is_tx);
14335 printf("invalid port_id %d\n", res->port_id);
14338 printf("not supported on port %d\n", res->port_id);
14341 printf("programming error: (%s)\n", strerror(-ret));
14345 cmdline_parse_inst_t cmd_set_macsec_sc = {
14346 .f = cmd_set_macsec_sc_parsed,
14348 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14350 (void *)&cmd_macsec_sc_set,
14351 (void *)&cmd_macsec_sc_macsec,
14352 (void *)&cmd_macsec_sc_sc,
14353 (void *)&cmd_macsec_sc_tx_rx,
14354 (void *)&cmd_macsec_sc_port_id,
14355 (void *)&cmd_macsec_sc_mac,
14356 (void *)&cmd_macsec_sc_pi,
14361 /* Common result structure for MACsec secure connection configure */
14362 struct cmd_macsec_sa_result {
14363 cmdline_fixed_string_t set;
14364 cmdline_fixed_string_t macsec;
14365 cmdline_fixed_string_t sa;
14366 cmdline_fixed_string_t tx_rx;
14371 cmdline_fixed_string_t key;
14374 /* Common CLI fields for MACsec secure connection configure */
14375 cmdline_parse_token_string_t cmd_macsec_sa_set =
14376 TOKEN_STRING_INITIALIZER
14377 (struct cmd_macsec_sa_result,
14379 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14380 TOKEN_STRING_INITIALIZER
14381 (struct cmd_macsec_sa_result,
14383 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14384 TOKEN_STRING_INITIALIZER
14385 (struct cmd_macsec_sa_result,
14387 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14388 TOKEN_STRING_INITIALIZER
14389 (struct cmd_macsec_sa_result,
14391 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14392 TOKEN_NUM_INITIALIZER
14393 (struct cmd_macsec_sa_result,
14395 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14396 TOKEN_NUM_INITIALIZER
14397 (struct cmd_macsec_sa_result,
14399 cmdline_parse_token_num_t cmd_macsec_sa_an =
14400 TOKEN_NUM_INITIALIZER
14401 (struct cmd_macsec_sa_result,
14403 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14404 TOKEN_NUM_INITIALIZER
14405 (struct cmd_macsec_sa_result,
14407 cmdline_parse_token_string_t cmd_macsec_sa_key =
14408 TOKEN_STRING_INITIALIZER
14409 (struct cmd_macsec_sa_result,
14413 cmd_set_macsec_sa_parsed(
14414 void *parsed_result,
14415 __attribute__((unused)) struct cmdline *cl,
14416 __attribute__((unused)) void *data)
14418 struct cmd_macsec_sa_result *res = parsed_result;
14419 int ret = -ENOTSUP;
14420 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14421 uint8_t key[16] = { 0 };
14427 key_len = strlen(res->key) / 2;
14431 for (i = 0; i < key_len; i++) {
14432 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14435 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14438 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14441 #ifdef RTE_LIBRTE_IXGBE_PMD
14443 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14444 res->idx, res->an, res->pn, key) :
14445 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14446 res->idx, res->an, res->pn, key);
14448 RTE_SET_USED(is_tx);
14455 printf("invalid idx %d or an %d\n", res->idx, res->an);
14458 printf("invalid port_id %d\n", res->port_id);
14461 printf("not supported on port %d\n", res->port_id);
14464 printf("programming error: (%s)\n", strerror(-ret));
14468 cmdline_parse_inst_t cmd_set_macsec_sa = {
14469 .f = cmd_set_macsec_sa_parsed,
14471 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14473 (void *)&cmd_macsec_sa_set,
14474 (void *)&cmd_macsec_sa_macsec,
14475 (void *)&cmd_macsec_sa_sa,
14476 (void *)&cmd_macsec_sa_tx_rx,
14477 (void *)&cmd_macsec_sa_port_id,
14478 (void *)&cmd_macsec_sa_idx,
14479 (void *)&cmd_macsec_sa_an,
14480 (void *)&cmd_macsec_sa_pn,
14481 (void *)&cmd_macsec_sa_key,
14486 /* VF unicast promiscuous mode configuration */
14488 /* Common result structure for VF unicast promiscuous mode */
14489 struct cmd_vf_promisc_result {
14490 cmdline_fixed_string_t set;
14491 cmdline_fixed_string_t vf;
14492 cmdline_fixed_string_t promisc;
14495 cmdline_fixed_string_t on_off;
14498 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14499 cmdline_parse_token_string_t cmd_vf_promisc_set =
14500 TOKEN_STRING_INITIALIZER
14501 (struct cmd_vf_promisc_result,
14503 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14504 TOKEN_STRING_INITIALIZER
14505 (struct cmd_vf_promisc_result,
14507 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14508 TOKEN_STRING_INITIALIZER
14509 (struct cmd_vf_promisc_result,
14510 promisc, "promisc");
14511 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14512 TOKEN_NUM_INITIALIZER
14513 (struct cmd_vf_promisc_result,
14515 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14516 TOKEN_NUM_INITIALIZER
14517 (struct cmd_vf_promisc_result,
14519 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14520 TOKEN_STRING_INITIALIZER
14521 (struct cmd_vf_promisc_result,
14525 cmd_set_vf_promisc_parsed(
14526 void *parsed_result,
14527 __attribute__((unused)) struct cmdline *cl,
14528 __attribute__((unused)) void *data)
14530 struct cmd_vf_promisc_result *res = parsed_result;
14531 int ret = -ENOTSUP;
14533 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14535 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14538 #ifdef RTE_LIBRTE_I40E_PMD
14539 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14540 res->vf_id, is_on);
14547 printf("invalid vf_id %d\n", res->vf_id);
14550 printf("invalid port_id %d\n", res->port_id);
14553 printf("function not implemented\n");
14556 printf("programming error: (%s)\n", strerror(-ret));
14560 cmdline_parse_inst_t cmd_set_vf_promisc = {
14561 .f = cmd_set_vf_promisc_parsed,
14563 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14564 "Set unicast promiscuous mode for a VF from the PF",
14566 (void *)&cmd_vf_promisc_set,
14567 (void *)&cmd_vf_promisc_vf,
14568 (void *)&cmd_vf_promisc_promisc,
14569 (void *)&cmd_vf_promisc_port_id,
14570 (void *)&cmd_vf_promisc_vf_id,
14571 (void *)&cmd_vf_promisc_on_off,
14576 /* VF multicast promiscuous mode configuration */
14578 /* Common result structure for VF multicast promiscuous mode */
14579 struct cmd_vf_allmulti_result {
14580 cmdline_fixed_string_t set;
14581 cmdline_fixed_string_t vf;
14582 cmdline_fixed_string_t allmulti;
14585 cmdline_fixed_string_t on_off;
14588 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14589 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14590 TOKEN_STRING_INITIALIZER
14591 (struct cmd_vf_allmulti_result,
14593 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14594 TOKEN_STRING_INITIALIZER
14595 (struct cmd_vf_allmulti_result,
14597 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14598 TOKEN_STRING_INITIALIZER
14599 (struct cmd_vf_allmulti_result,
14600 allmulti, "allmulti");
14601 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14602 TOKEN_NUM_INITIALIZER
14603 (struct cmd_vf_allmulti_result,
14605 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14606 TOKEN_NUM_INITIALIZER
14607 (struct cmd_vf_allmulti_result,
14609 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14610 TOKEN_STRING_INITIALIZER
14611 (struct cmd_vf_allmulti_result,
14615 cmd_set_vf_allmulti_parsed(
14616 void *parsed_result,
14617 __attribute__((unused)) struct cmdline *cl,
14618 __attribute__((unused)) void *data)
14620 struct cmd_vf_allmulti_result *res = parsed_result;
14621 int ret = -ENOTSUP;
14623 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14625 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14628 #ifdef RTE_LIBRTE_I40E_PMD
14629 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14630 res->vf_id, is_on);
14637 printf("invalid vf_id %d\n", res->vf_id);
14640 printf("invalid port_id %d\n", res->port_id);
14643 printf("function not implemented\n");
14646 printf("programming error: (%s)\n", strerror(-ret));
14650 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14651 .f = cmd_set_vf_allmulti_parsed,
14653 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14654 "Set multicast promiscuous mode for a VF from the PF",
14656 (void *)&cmd_vf_allmulti_set,
14657 (void *)&cmd_vf_allmulti_vf,
14658 (void *)&cmd_vf_allmulti_allmulti,
14659 (void *)&cmd_vf_allmulti_port_id,
14660 (void *)&cmd_vf_allmulti_vf_id,
14661 (void *)&cmd_vf_allmulti_on_off,
14666 /* vf broadcast mode configuration */
14668 /* Common result structure for vf broadcast */
14669 struct cmd_set_vf_broadcast_result {
14670 cmdline_fixed_string_t set;
14671 cmdline_fixed_string_t vf;
14672 cmdline_fixed_string_t broadcast;
14675 cmdline_fixed_string_t on_off;
14678 /* Common CLI fields for vf broadcast enable disable */
14679 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14680 TOKEN_STRING_INITIALIZER
14681 (struct cmd_set_vf_broadcast_result,
14683 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14684 TOKEN_STRING_INITIALIZER
14685 (struct cmd_set_vf_broadcast_result,
14687 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14688 TOKEN_STRING_INITIALIZER
14689 (struct cmd_set_vf_broadcast_result,
14690 broadcast, "broadcast");
14691 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14692 TOKEN_NUM_INITIALIZER
14693 (struct cmd_set_vf_broadcast_result,
14695 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14696 TOKEN_NUM_INITIALIZER
14697 (struct cmd_set_vf_broadcast_result,
14699 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14700 TOKEN_STRING_INITIALIZER
14701 (struct cmd_set_vf_broadcast_result,
14705 cmd_set_vf_broadcast_parsed(
14706 void *parsed_result,
14707 __attribute__((unused)) struct cmdline *cl,
14708 __attribute__((unused)) void *data)
14710 struct cmd_set_vf_broadcast_result *res = parsed_result;
14711 int ret = -ENOTSUP;
14713 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14715 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14718 #ifdef RTE_LIBRTE_I40E_PMD
14719 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14720 res->vf_id, is_on);
14727 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14730 printf("invalid port_id %d\n", res->port_id);
14733 printf("function not implemented\n");
14736 printf("programming error: (%s)\n", strerror(-ret));
14740 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14741 .f = cmd_set_vf_broadcast_parsed,
14743 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14745 (void *)&cmd_set_vf_broadcast_set,
14746 (void *)&cmd_set_vf_broadcast_vf,
14747 (void *)&cmd_set_vf_broadcast_broadcast,
14748 (void *)&cmd_set_vf_broadcast_port_id,
14749 (void *)&cmd_set_vf_broadcast_vf_id,
14750 (void *)&cmd_set_vf_broadcast_on_off,
14755 /* vf vlan tag configuration */
14757 /* Common result structure for vf vlan tag */
14758 struct cmd_set_vf_vlan_tag_result {
14759 cmdline_fixed_string_t set;
14760 cmdline_fixed_string_t vf;
14761 cmdline_fixed_string_t vlan;
14762 cmdline_fixed_string_t tag;
14765 cmdline_fixed_string_t on_off;
14768 /* Common CLI fields for vf vlan tag enable disable */
14769 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14770 TOKEN_STRING_INITIALIZER
14771 (struct cmd_set_vf_vlan_tag_result,
14773 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14774 TOKEN_STRING_INITIALIZER
14775 (struct cmd_set_vf_vlan_tag_result,
14777 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14778 TOKEN_STRING_INITIALIZER
14779 (struct cmd_set_vf_vlan_tag_result,
14781 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14782 TOKEN_STRING_INITIALIZER
14783 (struct cmd_set_vf_vlan_tag_result,
14785 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14786 TOKEN_NUM_INITIALIZER
14787 (struct cmd_set_vf_vlan_tag_result,
14789 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14790 TOKEN_NUM_INITIALIZER
14791 (struct cmd_set_vf_vlan_tag_result,
14793 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14794 TOKEN_STRING_INITIALIZER
14795 (struct cmd_set_vf_vlan_tag_result,
14799 cmd_set_vf_vlan_tag_parsed(
14800 void *parsed_result,
14801 __attribute__((unused)) struct cmdline *cl,
14802 __attribute__((unused)) void *data)
14804 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14805 int ret = -ENOTSUP;
14807 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14809 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14812 #ifdef RTE_LIBRTE_I40E_PMD
14813 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14814 res->vf_id, is_on);
14821 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14824 printf("invalid port_id %d\n", res->port_id);
14827 printf("function not implemented\n");
14830 printf("programming error: (%s)\n", strerror(-ret));
14834 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14835 .f = cmd_set_vf_vlan_tag_parsed,
14837 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14839 (void *)&cmd_set_vf_vlan_tag_set,
14840 (void *)&cmd_set_vf_vlan_tag_vf,
14841 (void *)&cmd_set_vf_vlan_tag_vlan,
14842 (void *)&cmd_set_vf_vlan_tag_tag,
14843 (void *)&cmd_set_vf_vlan_tag_port_id,
14844 (void *)&cmd_set_vf_vlan_tag_vf_id,
14845 (void *)&cmd_set_vf_vlan_tag_on_off,
14850 /* Common definition of VF and TC TX bandwidth configuration */
14851 struct cmd_vf_tc_bw_result {
14852 cmdline_fixed_string_t set;
14853 cmdline_fixed_string_t vf;
14854 cmdline_fixed_string_t tc;
14855 cmdline_fixed_string_t tx;
14856 cmdline_fixed_string_t min_bw;
14857 cmdline_fixed_string_t max_bw;
14858 cmdline_fixed_string_t strict_link_prio;
14863 cmdline_fixed_string_t bw_list;
14867 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14868 TOKEN_STRING_INITIALIZER
14869 (struct cmd_vf_tc_bw_result,
14871 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14872 TOKEN_STRING_INITIALIZER
14873 (struct cmd_vf_tc_bw_result,
14875 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14876 TOKEN_STRING_INITIALIZER
14877 (struct cmd_vf_tc_bw_result,
14879 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14880 TOKEN_STRING_INITIALIZER
14881 (struct cmd_vf_tc_bw_result,
14883 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14884 TOKEN_STRING_INITIALIZER
14885 (struct cmd_vf_tc_bw_result,
14886 strict_link_prio, "strict-link-priority");
14887 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14888 TOKEN_STRING_INITIALIZER
14889 (struct cmd_vf_tc_bw_result,
14890 min_bw, "min-bandwidth");
14891 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14892 TOKEN_STRING_INITIALIZER
14893 (struct cmd_vf_tc_bw_result,
14894 max_bw, "max-bandwidth");
14895 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14896 TOKEN_NUM_INITIALIZER
14897 (struct cmd_vf_tc_bw_result,
14899 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14900 TOKEN_NUM_INITIALIZER
14901 (struct cmd_vf_tc_bw_result,
14903 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14904 TOKEN_NUM_INITIALIZER
14905 (struct cmd_vf_tc_bw_result,
14907 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14908 TOKEN_NUM_INITIALIZER
14909 (struct cmd_vf_tc_bw_result,
14911 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14912 TOKEN_STRING_INITIALIZER
14913 (struct cmd_vf_tc_bw_result,
14915 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14916 TOKEN_NUM_INITIALIZER
14917 (struct cmd_vf_tc_bw_result,
14920 /* VF max bandwidth setting */
14922 cmd_vf_max_bw_parsed(
14923 void *parsed_result,
14924 __attribute__((unused)) struct cmdline *cl,
14925 __attribute__((unused)) void *data)
14927 struct cmd_vf_tc_bw_result *res = parsed_result;
14928 int ret = -ENOTSUP;
14930 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14933 #ifdef RTE_LIBRTE_I40E_PMD
14934 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14935 res->vf_id, res->bw);
14942 printf("invalid vf_id %d or bandwidth %d\n",
14943 res->vf_id, res->bw);
14946 printf("invalid port_id %d\n", res->port_id);
14949 printf("function not implemented\n");
14952 printf("programming error: (%s)\n", strerror(-ret));
14956 cmdline_parse_inst_t cmd_vf_max_bw = {
14957 .f = cmd_vf_max_bw_parsed,
14959 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14961 (void *)&cmd_vf_tc_bw_set,
14962 (void *)&cmd_vf_tc_bw_vf,
14963 (void *)&cmd_vf_tc_bw_tx,
14964 (void *)&cmd_vf_tc_bw_max_bw,
14965 (void *)&cmd_vf_tc_bw_port_id,
14966 (void *)&cmd_vf_tc_bw_vf_id,
14967 (void *)&cmd_vf_tc_bw_bw,
14973 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14978 const char *p, *p0 = str;
14985 p = strchr(p0, '(');
14987 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14991 p0 = strchr(p, ')');
14993 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14997 if (size >= sizeof(s)) {
14998 printf("The string size exceeds the internal buffer size\n");
15001 snprintf(s, sizeof(s), "%.*s", size, p);
15002 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15004 printf("Failed to get the bandwidth list. ");
15008 for (i = 0; i < ret; i++)
15009 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15014 /* TC min bandwidth setting */
15016 cmd_vf_tc_min_bw_parsed(
15017 void *parsed_result,
15018 __attribute__((unused)) struct cmdline *cl,
15019 __attribute__((unused)) void *data)
15021 struct cmd_vf_tc_bw_result *res = parsed_result;
15024 int ret = -ENOTSUP;
15026 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15029 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15033 #ifdef RTE_LIBRTE_I40E_PMD
15034 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15042 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15045 printf("invalid port_id %d\n", res->port_id);
15048 printf("function not implemented\n");
15051 printf("programming error: (%s)\n", strerror(-ret));
15055 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15056 .f = cmd_vf_tc_min_bw_parsed,
15058 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15059 " <bw1, bw2, ...>",
15061 (void *)&cmd_vf_tc_bw_set,
15062 (void *)&cmd_vf_tc_bw_vf,
15063 (void *)&cmd_vf_tc_bw_tc,
15064 (void *)&cmd_vf_tc_bw_tx,
15065 (void *)&cmd_vf_tc_bw_min_bw,
15066 (void *)&cmd_vf_tc_bw_port_id,
15067 (void *)&cmd_vf_tc_bw_vf_id,
15068 (void *)&cmd_vf_tc_bw_bw_list,
15074 cmd_tc_min_bw_parsed(
15075 void *parsed_result,
15076 __attribute__((unused)) struct cmdline *cl,
15077 __attribute__((unused)) void *data)
15079 struct cmd_vf_tc_bw_result *res = parsed_result;
15080 struct rte_port *port;
15083 int ret = -ENOTSUP;
15085 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15088 port = &ports[res->port_id];
15089 /** Check if the port is not started **/
15090 if (port->port_status != RTE_PORT_STOPPED) {
15091 printf("Please stop port %d first\n", res->port_id);
15095 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15099 #ifdef RTE_LIBRTE_IXGBE_PMD
15100 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15107 printf("invalid bandwidth\n");
15110 printf("invalid port_id %d\n", res->port_id);
15113 printf("function not implemented\n");
15116 printf("programming error: (%s)\n", strerror(-ret));
15120 cmdline_parse_inst_t cmd_tc_min_bw = {
15121 .f = cmd_tc_min_bw_parsed,
15123 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15125 (void *)&cmd_vf_tc_bw_set,
15126 (void *)&cmd_vf_tc_bw_tc,
15127 (void *)&cmd_vf_tc_bw_tx,
15128 (void *)&cmd_vf_tc_bw_min_bw,
15129 (void *)&cmd_vf_tc_bw_port_id,
15130 (void *)&cmd_vf_tc_bw_bw_list,
15135 /* TC max bandwidth setting */
15137 cmd_vf_tc_max_bw_parsed(
15138 void *parsed_result,
15139 __attribute__((unused)) struct cmdline *cl,
15140 __attribute__((unused)) void *data)
15142 struct cmd_vf_tc_bw_result *res = parsed_result;
15143 int ret = -ENOTSUP;
15145 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15148 #ifdef RTE_LIBRTE_I40E_PMD
15149 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15150 res->tc_no, res->bw);
15157 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15158 res->vf_id, res->tc_no, res->bw);
15161 printf("invalid port_id %d\n", res->port_id);
15164 printf("function not implemented\n");
15167 printf("programming error: (%s)\n", strerror(-ret));
15171 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15172 .f = cmd_vf_tc_max_bw_parsed,
15174 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15177 (void *)&cmd_vf_tc_bw_set,
15178 (void *)&cmd_vf_tc_bw_vf,
15179 (void *)&cmd_vf_tc_bw_tc,
15180 (void *)&cmd_vf_tc_bw_tx,
15181 (void *)&cmd_vf_tc_bw_max_bw,
15182 (void *)&cmd_vf_tc_bw_port_id,
15183 (void *)&cmd_vf_tc_bw_vf_id,
15184 (void *)&cmd_vf_tc_bw_tc_no,
15185 (void *)&cmd_vf_tc_bw_bw,
15191 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15193 /* *** Set Port default Traffic Management Hierarchy *** */
15194 struct cmd_set_port_tm_hierarchy_default_result {
15195 cmdline_fixed_string_t set;
15196 cmdline_fixed_string_t port;
15197 cmdline_fixed_string_t tm;
15198 cmdline_fixed_string_t hierarchy;
15199 cmdline_fixed_string_t def;
15203 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15204 TOKEN_STRING_INITIALIZER(
15205 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15206 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15207 TOKEN_STRING_INITIALIZER(
15208 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15209 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15210 TOKEN_STRING_INITIALIZER(
15211 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15212 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15213 TOKEN_STRING_INITIALIZER(
15214 struct cmd_set_port_tm_hierarchy_default_result,
15215 hierarchy, "hierarchy");
15216 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15217 TOKEN_STRING_INITIALIZER(
15218 struct cmd_set_port_tm_hierarchy_default_result,
15220 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15221 TOKEN_NUM_INITIALIZER(
15222 struct cmd_set_port_tm_hierarchy_default_result,
15225 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15226 __attribute__((unused)) struct cmdline *cl,
15227 __attribute__((unused)) void *data)
15229 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15230 struct rte_port *p;
15231 portid_t port_id = res->port_id;
15233 if (port_id_is_invalid(port_id, ENABLED_WARN))
15236 p = &ports[port_id];
15238 /* Forward mode: tm */
15239 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15240 printf(" softnicfwd mode not enabled(error)\n");
15244 /* Set the default tm hierarchy */
15245 p->softport.default_tm_hierarchy_enable = 1;
15248 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15249 .f = cmd_set_port_tm_hierarchy_default_parsed,
15251 .help_str = "set port tm hierarchy default <port_id>",
15253 (void *)&cmd_set_port_tm_hierarchy_default_set,
15254 (void *)&cmd_set_port_tm_hierarchy_default_port,
15255 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15256 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15257 (void *)&cmd_set_port_tm_hierarchy_default_default,
15258 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15264 /** Set VXLAN encapsulation details */
15265 struct cmd_set_vxlan_result {
15266 cmdline_fixed_string_t set;
15267 cmdline_fixed_string_t vxlan;
15268 cmdline_fixed_string_t pos_token;
15269 cmdline_fixed_string_t ip_version;
15270 uint32_t vlan_present:1;
15274 cmdline_ipaddr_t ip_src;
15275 cmdline_ipaddr_t ip_dst;
15279 struct rte_ether_addr eth_src;
15280 struct rte_ether_addr eth_dst;
15283 cmdline_parse_token_string_t cmd_set_vxlan_set =
15284 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15285 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15286 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15287 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15288 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15290 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15291 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15292 "vxlan-with-vlan");
15293 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15294 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15296 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15297 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15299 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15300 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15302 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15303 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15304 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15305 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15307 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15308 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15309 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15310 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15312 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15313 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15314 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15315 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15317 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15318 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15319 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15320 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15322 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15323 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15324 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15325 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15327 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15328 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15329 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15330 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15332 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15333 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15334 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15335 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15337 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15338 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15339 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15340 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15342 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15343 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15344 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15345 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15347 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15348 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15350 static void cmd_set_vxlan_parsed(void *parsed_result,
15351 __attribute__((unused)) struct cmdline *cl,
15352 __attribute__((unused)) void *data)
15354 struct cmd_set_vxlan_result *res = parsed_result;
15359 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15362 vxlan_encap_conf.select_tos_ttl = 0;
15363 if (strcmp(res->vxlan, "vxlan") == 0)
15364 vxlan_encap_conf.select_vlan = 0;
15365 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15366 vxlan_encap_conf.select_vlan = 1;
15367 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15368 vxlan_encap_conf.select_vlan = 0;
15369 vxlan_encap_conf.select_tos_ttl = 1;
15371 if (strcmp(res->ip_version, "ipv4") == 0)
15372 vxlan_encap_conf.select_ipv4 = 1;
15373 else if (strcmp(res->ip_version, "ipv6") == 0)
15374 vxlan_encap_conf.select_ipv4 = 0;
15377 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15378 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15379 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15380 vxlan_encap_conf.ip_tos = res->tos;
15381 vxlan_encap_conf.ip_ttl = res->ttl;
15382 if (vxlan_encap_conf.select_ipv4) {
15383 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15384 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15386 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15387 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15389 if (vxlan_encap_conf.select_vlan)
15390 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15391 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15392 RTE_ETHER_ADDR_LEN);
15393 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15394 RTE_ETHER_ADDR_LEN);
15397 cmdline_parse_inst_t cmd_set_vxlan = {
15398 .f = cmd_set_vxlan_parsed,
15400 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15401 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15402 " eth-src <eth-src> eth-dst <eth-dst>",
15404 (void *)&cmd_set_vxlan_set,
15405 (void *)&cmd_set_vxlan_vxlan,
15406 (void *)&cmd_set_vxlan_ip_version,
15407 (void *)&cmd_set_vxlan_ip_version_value,
15408 (void *)&cmd_set_vxlan_vni,
15409 (void *)&cmd_set_vxlan_vni_value,
15410 (void *)&cmd_set_vxlan_udp_src,
15411 (void *)&cmd_set_vxlan_udp_src_value,
15412 (void *)&cmd_set_vxlan_udp_dst,
15413 (void *)&cmd_set_vxlan_udp_dst_value,
15414 (void *)&cmd_set_vxlan_ip_src,
15415 (void *)&cmd_set_vxlan_ip_src_value,
15416 (void *)&cmd_set_vxlan_ip_dst,
15417 (void *)&cmd_set_vxlan_ip_dst_value,
15418 (void *)&cmd_set_vxlan_eth_src,
15419 (void *)&cmd_set_vxlan_eth_src_value,
15420 (void *)&cmd_set_vxlan_eth_dst,
15421 (void *)&cmd_set_vxlan_eth_dst_value,
15426 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15427 .f = cmd_set_vxlan_parsed,
15429 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15430 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15431 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15432 " eth-dst <eth-dst>",
15434 (void *)&cmd_set_vxlan_set,
15435 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15436 (void *)&cmd_set_vxlan_ip_version,
15437 (void *)&cmd_set_vxlan_ip_version_value,
15438 (void *)&cmd_set_vxlan_vni,
15439 (void *)&cmd_set_vxlan_vni_value,
15440 (void *)&cmd_set_vxlan_udp_src,
15441 (void *)&cmd_set_vxlan_udp_src_value,
15442 (void *)&cmd_set_vxlan_udp_dst,
15443 (void *)&cmd_set_vxlan_udp_dst_value,
15444 (void *)&cmd_set_vxlan_ip_tos,
15445 (void *)&cmd_set_vxlan_ip_tos_value,
15446 (void *)&cmd_set_vxlan_ip_ttl,
15447 (void *)&cmd_set_vxlan_ip_ttl_value,
15448 (void *)&cmd_set_vxlan_ip_src,
15449 (void *)&cmd_set_vxlan_ip_src_value,
15450 (void *)&cmd_set_vxlan_ip_dst,
15451 (void *)&cmd_set_vxlan_ip_dst_value,
15452 (void *)&cmd_set_vxlan_eth_src,
15453 (void *)&cmd_set_vxlan_eth_src_value,
15454 (void *)&cmd_set_vxlan_eth_dst,
15455 (void *)&cmd_set_vxlan_eth_dst_value,
15460 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15461 .f = cmd_set_vxlan_parsed,
15463 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15464 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15465 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15468 (void *)&cmd_set_vxlan_set,
15469 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15470 (void *)&cmd_set_vxlan_ip_version,
15471 (void *)&cmd_set_vxlan_ip_version_value,
15472 (void *)&cmd_set_vxlan_vni,
15473 (void *)&cmd_set_vxlan_vni_value,
15474 (void *)&cmd_set_vxlan_udp_src,
15475 (void *)&cmd_set_vxlan_udp_src_value,
15476 (void *)&cmd_set_vxlan_udp_dst,
15477 (void *)&cmd_set_vxlan_udp_dst_value,
15478 (void *)&cmd_set_vxlan_ip_src,
15479 (void *)&cmd_set_vxlan_ip_src_value,
15480 (void *)&cmd_set_vxlan_ip_dst,
15481 (void *)&cmd_set_vxlan_ip_dst_value,
15482 (void *)&cmd_set_vxlan_vlan,
15483 (void *)&cmd_set_vxlan_vlan_value,
15484 (void *)&cmd_set_vxlan_eth_src,
15485 (void *)&cmd_set_vxlan_eth_src_value,
15486 (void *)&cmd_set_vxlan_eth_dst,
15487 (void *)&cmd_set_vxlan_eth_dst_value,
15492 /** Set NVGRE encapsulation details */
15493 struct cmd_set_nvgre_result {
15494 cmdline_fixed_string_t set;
15495 cmdline_fixed_string_t nvgre;
15496 cmdline_fixed_string_t pos_token;
15497 cmdline_fixed_string_t ip_version;
15499 cmdline_ipaddr_t ip_src;
15500 cmdline_ipaddr_t ip_dst;
15502 struct rte_ether_addr eth_src;
15503 struct rte_ether_addr eth_dst;
15506 cmdline_parse_token_string_t cmd_set_nvgre_set =
15507 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15508 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15509 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15510 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15511 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15512 "nvgre-with-vlan");
15513 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15514 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15516 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15517 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15519 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15520 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15522 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15523 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15524 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15525 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15527 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15528 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15529 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15530 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15532 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15533 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15534 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15535 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15537 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15538 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15539 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15540 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15542 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15543 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15544 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15545 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15547 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15548 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15550 static void cmd_set_nvgre_parsed(void *parsed_result,
15551 __attribute__((unused)) struct cmdline *cl,
15552 __attribute__((unused)) void *data)
15554 struct cmd_set_nvgre_result *res = parsed_result;
15556 uint32_t nvgre_tni;
15559 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15562 if (strcmp(res->nvgre, "nvgre") == 0)
15563 nvgre_encap_conf.select_vlan = 0;
15564 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15565 nvgre_encap_conf.select_vlan = 1;
15566 if (strcmp(res->ip_version, "ipv4") == 0)
15567 nvgre_encap_conf.select_ipv4 = 1;
15568 else if (strcmp(res->ip_version, "ipv6") == 0)
15569 nvgre_encap_conf.select_ipv4 = 0;
15572 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15573 if (nvgre_encap_conf.select_ipv4) {
15574 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15575 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15577 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15578 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15580 if (nvgre_encap_conf.select_vlan)
15581 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15582 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15583 RTE_ETHER_ADDR_LEN);
15584 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15585 RTE_ETHER_ADDR_LEN);
15588 cmdline_parse_inst_t cmd_set_nvgre = {
15589 .f = cmd_set_nvgre_parsed,
15591 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15592 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15593 " eth-dst <eth-dst>",
15595 (void *)&cmd_set_nvgre_set,
15596 (void *)&cmd_set_nvgre_nvgre,
15597 (void *)&cmd_set_nvgre_ip_version,
15598 (void *)&cmd_set_nvgre_ip_version_value,
15599 (void *)&cmd_set_nvgre_tni,
15600 (void *)&cmd_set_nvgre_tni_value,
15601 (void *)&cmd_set_nvgre_ip_src,
15602 (void *)&cmd_set_nvgre_ip_src_value,
15603 (void *)&cmd_set_nvgre_ip_dst,
15604 (void *)&cmd_set_nvgre_ip_dst_value,
15605 (void *)&cmd_set_nvgre_eth_src,
15606 (void *)&cmd_set_nvgre_eth_src_value,
15607 (void *)&cmd_set_nvgre_eth_dst,
15608 (void *)&cmd_set_nvgre_eth_dst_value,
15613 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15614 .f = cmd_set_nvgre_parsed,
15616 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15617 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15618 " eth-src <eth-src> eth-dst <eth-dst>",
15620 (void *)&cmd_set_nvgre_set,
15621 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15622 (void *)&cmd_set_nvgre_ip_version,
15623 (void *)&cmd_set_nvgre_ip_version_value,
15624 (void *)&cmd_set_nvgre_tni,
15625 (void *)&cmd_set_nvgre_tni_value,
15626 (void *)&cmd_set_nvgre_ip_src,
15627 (void *)&cmd_set_nvgre_ip_src_value,
15628 (void *)&cmd_set_nvgre_ip_dst,
15629 (void *)&cmd_set_nvgre_ip_dst_value,
15630 (void *)&cmd_set_nvgre_vlan,
15631 (void *)&cmd_set_nvgre_vlan_value,
15632 (void *)&cmd_set_nvgre_eth_src,
15633 (void *)&cmd_set_nvgre_eth_src_value,
15634 (void *)&cmd_set_nvgre_eth_dst,
15635 (void *)&cmd_set_nvgre_eth_dst_value,
15640 /** Set L2 encapsulation details */
15641 struct cmd_set_l2_encap_result {
15642 cmdline_fixed_string_t set;
15643 cmdline_fixed_string_t l2_encap;
15644 cmdline_fixed_string_t pos_token;
15645 cmdline_fixed_string_t ip_version;
15646 uint32_t vlan_present:1;
15648 struct rte_ether_addr eth_src;
15649 struct rte_ether_addr eth_dst;
15652 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15653 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15654 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15655 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15656 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15657 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15658 "l2_encap-with-vlan");
15659 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15660 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15662 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15663 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15665 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15666 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15668 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15669 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15670 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15671 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15673 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15674 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15675 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15676 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15678 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15679 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15681 static void cmd_set_l2_encap_parsed(void *parsed_result,
15682 __attribute__((unused)) struct cmdline *cl,
15683 __attribute__((unused)) void *data)
15685 struct cmd_set_l2_encap_result *res = parsed_result;
15687 if (strcmp(res->l2_encap, "l2_encap") == 0)
15688 l2_encap_conf.select_vlan = 0;
15689 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15690 l2_encap_conf.select_vlan = 1;
15691 if (strcmp(res->ip_version, "ipv4") == 0)
15692 l2_encap_conf.select_ipv4 = 1;
15693 else if (strcmp(res->ip_version, "ipv6") == 0)
15694 l2_encap_conf.select_ipv4 = 0;
15697 if (l2_encap_conf.select_vlan)
15698 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15699 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15700 RTE_ETHER_ADDR_LEN);
15701 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15702 RTE_ETHER_ADDR_LEN);
15705 cmdline_parse_inst_t cmd_set_l2_encap = {
15706 .f = cmd_set_l2_encap_parsed,
15708 .help_str = "set l2_encap ip-version ipv4|ipv6"
15709 " eth-src <eth-src> eth-dst <eth-dst>",
15711 (void *)&cmd_set_l2_encap_set,
15712 (void *)&cmd_set_l2_encap_l2_encap,
15713 (void *)&cmd_set_l2_encap_ip_version,
15714 (void *)&cmd_set_l2_encap_ip_version_value,
15715 (void *)&cmd_set_l2_encap_eth_src,
15716 (void *)&cmd_set_l2_encap_eth_src_value,
15717 (void *)&cmd_set_l2_encap_eth_dst,
15718 (void *)&cmd_set_l2_encap_eth_dst_value,
15723 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15724 .f = cmd_set_l2_encap_parsed,
15726 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15727 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15729 (void *)&cmd_set_l2_encap_set,
15730 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15731 (void *)&cmd_set_l2_encap_ip_version,
15732 (void *)&cmd_set_l2_encap_ip_version_value,
15733 (void *)&cmd_set_l2_encap_vlan,
15734 (void *)&cmd_set_l2_encap_vlan_value,
15735 (void *)&cmd_set_l2_encap_eth_src,
15736 (void *)&cmd_set_l2_encap_eth_src_value,
15737 (void *)&cmd_set_l2_encap_eth_dst,
15738 (void *)&cmd_set_l2_encap_eth_dst_value,
15743 /** Set L2 decapsulation details */
15744 struct cmd_set_l2_decap_result {
15745 cmdline_fixed_string_t set;
15746 cmdline_fixed_string_t l2_decap;
15747 cmdline_fixed_string_t pos_token;
15748 uint32_t vlan_present:1;
15751 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15752 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15753 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15754 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15756 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15757 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15758 "l2_decap-with-vlan");
15760 static void cmd_set_l2_decap_parsed(void *parsed_result,
15761 __attribute__((unused)) struct cmdline *cl,
15762 __attribute__((unused)) void *data)
15764 struct cmd_set_l2_decap_result *res = parsed_result;
15766 if (strcmp(res->l2_decap, "l2_decap") == 0)
15767 l2_decap_conf.select_vlan = 0;
15768 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15769 l2_decap_conf.select_vlan = 1;
15772 cmdline_parse_inst_t cmd_set_l2_decap = {
15773 .f = cmd_set_l2_decap_parsed,
15775 .help_str = "set l2_decap",
15777 (void *)&cmd_set_l2_decap_set,
15778 (void *)&cmd_set_l2_decap_l2_decap,
15783 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15784 .f = cmd_set_l2_decap_parsed,
15786 .help_str = "set l2_decap-with-vlan",
15788 (void *)&cmd_set_l2_decap_set,
15789 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15794 /** Set MPLSoGRE encapsulation details */
15795 struct cmd_set_mplsogre_encap_result {
15796 cmdline_fixed_string_t set;
15797 cmdline_fixed_string_t mplsogre;
15798 cmdline_fixed_string_t pos_token;
15799 cmdline_fixed_string_t ip_version;
15800 uint32_t vlan_present:1;
15802 cmdline_ipaddr_t ip_src;
15803 cmdline_ipaddr_t ip_dst;
15805 struct rte_ether_addr eth_src;
15806 struct rte_ether_addr eth_dst;
15809 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15810 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15812 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15813 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15815 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15816 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15817 mplsogre, "mplsogre_encap-with-vlan");
15818 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15819 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15820 pos_token, "ip-version");
15821 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15822 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15823 ip_version, "ipv4#ipv6");
15824 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15825 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15826 pos_token, "label");
15827 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15828 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15830 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15831 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15832 pos_token, "ip-src");
15833 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15834 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15835 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15836 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15837 pos_token, "ip-dst");
15838 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15839 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15840 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15841 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15842 pos_token, "vlan-tci");
15843 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15844 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15846 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15847 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15848 pos_token, "eth-src");
15849 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15850 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15852 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15853 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15854 pos_token, "eth-dst");
15855 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15856 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15859 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15860 __attribute__((unused)) struct cmdline *cl,
15861 __attribute__((unused)) void *data)
15863 struct cmd_set_mplsogre_encap_result *res = parsed_result;
15865 uint32_t mplsogre_label;
15868 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15871 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15872 mplsogre_encap_conf.select_vlan = 0;
15873 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15874 mplsogre_encap_conf.select_vlan = 1;
15875 if (strcmp(res->ip_version, "ipv4") == 0)
15876 mplsogre_encap_conf.select_ipv4 = 1;
15877 else if (strcmp(res->ip_version, "ipv6") == 0)
15878 mplsogre_encap_conf.select_ipv4 = 0;
15881 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15882 if (mplsogre_encap_conf.select_ipv4) {
15883 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15884 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15886 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15887 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15889 if (mplsogre_encap_conf.select_vlan)
15890 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15891 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15892 RTE_ETHER_ADDR_LEN);
15893 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15894 RTE_ETHER_ADDR_LEN);
15897 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15898 .f = cmd_set_mplsogre_encap_parsed,
15900 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15901 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15902 " eth-dst <eth-dst>",
15904 (void *)&cmd_set_mplsogre_encap_set,
15905 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15906 (void *)&cmd_set_mplsogre_encap_ip_version,
15907 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15908 (void *)&cmd_set_mplsogre_encap_label,
15909 (void *)&cmd_set_mplsogre_encap_label_value,
15910 (void *)&cmd_set_mplsogre_encap_ip_src,
15911 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15912 (void *)&cmd_set_mplsogre_encap_ip_dst,
15913 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15914 (void *)&cmd_set_mplsogre_encap_eth_src,
15915 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15916 (void *)&cmd_set_mplsogre_encap_eth_dst,
15917 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15922 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
15923 .f = cmd_set_mplsogre_encap_parsed,
15925 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
15926 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
15927 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15929 (void *)&cmd_set_mplsogre_encap_set,
15930 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
15931 (void *)&cmd_set_mplsogre_encap_ip_version,
15932 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15933 (void *)&cmd_set_mplsogre_encap_label,
15934 (void *)&cmd_set_mplsogre_encap_label_value,
15935 (void *)&cmd_set_mplsogre_encap_ip_src,
15936 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15937 (void *)&cmd_set_mplsogre_encap_ip_dst,
15938 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15939 (void *)&cmd_set_mplsogre_encap_vlan,
15940 (void *)&cmd_set_mplsogre_encap_vlan_value,
15941 (void *)&cmd_set_mplsogre_encap_eth_src,
15942 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15943 (void *)&cmd_set_mplsogre_encap_eth_dst,
15944 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15949 /** Set MPLSoGRE decapsulation details */
15950 struct cmd_set_mplsogre_decap_result {
15951 cmdline_fixed_string_t set;
15952 cmdline_fixed_string_t mplsogre;
15953 cmdline_fixed_string_t pos_token;
15954 cmdline_fixed_string_t ip_version;
15955 uint32_t vlan_present:1;
15958 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
15959 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
15961 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
15962 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
15964 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
15965 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15966 mplsogre, "mplsogre_decap-with-vlan");
15967 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
15968 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15969 pos_token, "ip-version");
15970 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
15971 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15972 ip_version, "ipv4#ipv6");
15974 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
15975 __attribute__((unused)) struct cmdline *cl,
15976 __attribute__((unused)) void *data)
15978 struct cmd_set_mplsogre_decap_result *res = parsed_result;
15980 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
15981 mplsogre_decap_conf.select_vlan = 0;
15982 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
15983 mplsogre_decap_conf.select_vlan = 1;
15984 if (strcmp(res->ip_version, "ipv4") == 0)
15985 mplsogre_decap_conf.select_ipv4 = 1;
15986 else if (strcmp(res->ip_version, "ipv6") == 0)
15987 mplsogre_decap_conf.select_ipv4 = 0;
15990 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
15991 .f = cmd_set_mplsogre_decap_parsed,
15993 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
15995 (void *)&cmd_set_mplsogre_decap_set,
15996 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
15997 (void *)&cmd_set_mplsogre_decap_ip_version,
15998 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16003 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16004 .f = cmd_set_mplsogre_decap_parsed,
16006 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16008 (void *)&cmd_set_mplsogre_decap_set,
16009 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16010 (void *)&cmd_set_mplsogre_decap_ip_version,
16011 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16016 /** Set MPLSoUDP encapsulation details */
16017 struct cmd_set_mplsoudp_encap_result {
16018 cmdline_fixed_string_t set;
16019 cmdline_fixed_string_t mplsoudp;
16020 cmdline_fixed_string_t pos_token;
16021 cmdline_fixed_string_t ip_version;
16022 uint32_t vlan_present:1;
16026 cmdline_ipaddr_t ip_src;
16027 cmdline_ipaddr_t ip_dst;
16029 struct rte_ether_addr eth_src;
16030 struct rte_ether_addr eth_dst;
16033 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16034 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16036 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16037 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16039 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16040 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16041 mplsoudp, "mplsoudp_encap-with-vlan");
16042 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16043 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16044 pos_token, "ip-version");
16045 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16046 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16047 ip_version, "ipv4#ipv6");
16048 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16049 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16050 pos_token, "label");
16051 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16052 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16054 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16055 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16056 pos_token, "udp-src");
16057 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16058 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16060 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16061 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16062 pos_token, "udp-dst");
16063 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16064 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16066 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16067 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16068 pos_token, "ip-src");
16069 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16070 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16071 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16072 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16073 pos_token, "ip-dst");
16074 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16075 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16076 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16077 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16078 pos_token, "vlan-tci");
16079 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16080 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16082 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16083 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16084 pos_token, "eth-src");
16085 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16086 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16088 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16089 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16090 pos_token, "eth-dst");
16091 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16092 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16095 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16096 __attribute__((unused)) struct cmdline *cl,
16097 __attribute__((unused)) void *data)
16099 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16101 uint32_t mplsoudp_label;
16104 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16107 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16108 mplsoudp_encap_conf.select_vlan = 0;
16109 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16110 mplsoudp_encap_conf.select_vlan = 1;
16111 if (strcmp(res->ip_version, "ipv4") == 0)
16112 mplsoudp_encap_conf.select_ipv4 = 1;
16113 else if (strcmp(res->ip_version, "ipv6") == 0)
16114 mplsoudp_encap_conf.select_ipv4 = 0;
16117 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16118 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16119 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16120 if (mplsoudp_encap_conf.select_ipv4) {
16121 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16122 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16124 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16125 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16127 if (mplsoudp_encap_conf.select_vlan)
16128 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16129 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16130 RTE_ETHER_ADDR_LEN);
16131 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16132 RTE_ETHER_ADDR_LEN);
16135 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16136 .f = cmd_set_mplsoudp_encap_parsed,
16138 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16139 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16140 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16142 (void *)&cmd_set_mplsoudp_encap_set,
16143 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16144 (void *)&cmd_set_mplsoudp_encap_ip_version,
16145 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16146 (void *)&cmd_set_mplsoudp_encap_label,
16147 (void *)&cmd_set_mplsoudp_encap_label_value,
16148 (void *)&cmd_set_mplsoudp_encap_udp_src,
16149 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16150 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16151 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16152 (void *)&cmd_set_mplsoudp_encap_ip_src,
16153 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16154 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16155 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16156 (void *)&cmd_set_mplsoudp_encap_eth_src,
16157 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16158 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16159 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16164 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16165 .f = cmd_set_mplsoudp_encap_parsed,
16167 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16168 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16169 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16170 " eth-src <eth-src> eth-dst <eth-dst>",
16172 (void *)&cmd_set_mplsoudp_encap_set,
16173 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16174 (void *)&cmd_set_mplsoudp_encap_ip_version,
16175 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16176 (void *)&cmd_set_mplsoudp_encap_label,
16177 (void *)&cmd_set_mplsoudp_encap_label_value,
16178 (void *)&cmd_set_mplsoudp_encap_udp_src,
16179 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16180 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16181 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16182 (void *)&cmd_set_mplsoudp_encap_ip_src,
16183 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16184 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16185 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16186 (void *)&cmd_set_mplsoudp_encap_vlan,
16187 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16188 (void *)&cmd_set_mplsoudp_encap_eth_src,
16189 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16190 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16191 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16196 /** Set MPLSoUDP decapsulation details */
16197 struct cmd_set_mplsoudp_decap_result {
16198 cmdline_fixed_string_t set;
16199 cmdline_fixed_string_t mplsoudp;
16200 cmdline_fixed_string_t pos_token;
16201 cmdline_fixed_string_t ip_version;
16202 uint32_t vlan_present:1;
16205 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16206 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16208 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16209 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16211 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16212 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16213 mplsoudp, "mplsoudp_decap-with-vlan");
16214 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16215 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16216 pos_token, "ip-version");
16217 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16218 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16219 ip_version, "ipv4#ipv6");
16221 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16222 __attribute__((unused)) struct cmdline *cl,
16223 __attribute__((unused)) void *data)
16225 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16227 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16228 mplsoudp_decap_conf.select_vlan = 0;
16229 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16230 mplsoudp_decap_conf.select_vlan = 1;
16231 if (strcmp(res->ip_version, "ipv4") == 0)
16232 mplsoudp_decap_conf.select_ipv4 = 1;
16233 else if (strcmp(res->ip_version, "ipv6") == 0)
16234 mplsoudp_decap_conf.select_ipv4 = 0;
16237 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16238 .f = cmd_set_mplsoudp_decap_parsed,
16240 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16242 (void *)&cmd_set_mplsoudp_decap_set,
16243 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16244 (void *)&cmd_set_mplsoudp_decap_ip_version,
16245 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16250 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16251 .f = cmd_set_mplsoudp_decap_parsed,
16253 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16255 (void *)&cmd_set_mplsoudp_decap_set,
16256 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16257 (void *)&cmd_set_mplsoudp_decap_ip_version,
16258 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16263 /* Strict link priority scheduling mode setting */
16265 cmd_strict_link_prio_parsed(
16266 void *parsed_result,
16267 __attribute__((unused)) struct cmdline *cl,
16268 __attribute__((unused)) void *data)
16270 struct cmd_vf_tc_bw_result *res = parsed_result;
16271 int ret = -ENOTSUP;
16273 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16276 #ifdef RTE_LIBRTE_I40E_PMD
16277 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16284 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16287 printf("invalid port_id %d\n", res->port_id);
16290 printf("function not implemented\n");
16293 printf("programming error: (%s)\n", strerror(-ret));
16297 cmdline_parse_inst_t cmd_strict_link_prio = {
16298 .f = cmd_strict_link_prio_parsed,
16300 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16302 (void *)&cmd_vf_tc_bw_set,
16303 (void *)&cmd_vf_tc_bw_tx,
16304 (void *)&cmd_vf_tc_bw_strict_link_prio,
16305 (void *)&cmd_vf_tc_bw_port_id,
16306 (void *)&cmd_vf_tc_bw_tc_map,
16311 /* Load dynamic device personalization*/
16312 struct cmd_ddp_add_result {
16313 cmdline_fixed_string_t ddp;
16314 cmdline_fixed_string_t add;
16319 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16320 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16321 cmdline_parse_token_string_t cmd_ddp_add_add =
16322 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16323 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16324 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16325 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16326 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16329 cmd_ddp_add_parsed(
16330 void *parsed_result,
16331 __attribute__((unused)) struct cmdline *cl,
16332 __attribute__((unused)) void *data)
16334 struct cmd_ddp_add_result *res = parsed_result;
16340 int ret = -ENOTSUP;
16342 if (!all_ports_stopped()) {
16343 printf("Please stop all ports first\n");
16347 filepath = strdup(res->filepath);
16348 if (filepath == NULL) {
16349 printf("Failed to allocate memory\n");
16352 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16354 buff = open_file(file_fld[0], &size);
16356 free((void *)filepath);
16360 #ifdef RTE_LIBRTE_I40E_PMD
16361 if (ret == -ENOTSUP)
16362 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16364 RTE_PMD_I40E_PKG_OP_WR_ADD);
16367 if (ret == -EEXIST)
16368 printf("Profile has already existed.\n");
16370 printf("Failed to load profile.\n");
16371 else if (file_num == 2)
16372 save_file(file_fld[1], buff, size);
16375 free((void *)filepath);
16378 cmdline_parse_inst_t cmd_ddp_add = {
16379 .f = cmd_ddp_add_parsed,
16381 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16383 (void *)&cmd_ddp_add_ddp,
16384 (void *)&cmd_ddp_add_add,
16385 (void *)&cmd_ddp_add_port_id,
16386 (void *)&cmd_ddp_add_filepath,
16391 /* Delete dynamic device personalization*/
16392 struct cmd_ddp_del_result {
16393 cmdline_fixed_string_t ddp;
16394 cmdline_fixed_string_t del;
16399 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16400 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16401 cmdline_parse_token_string_t cmd_ddp_del_del =
16402 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16403 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16404 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16405 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16406 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16409 cmd_ddp_del_parsed(
16410 void *parsed_result,
16411 __attribute__((unused)) struct cmdline *cl,
16412 __attribute__((unused)) void *data)
16414 struct cmd_ddp_del_result *res = parsed_result;
16417 int ret = -ENOTSUP;
16419 if (!all_ports_stopped()) {
16420 printf("Please stop all ports first\n");
16424 buff = open_file(res->filepath, &size);
16428 #ifdef RTE_LIBRTE_I40E_PMD
16429 if (ret == -ENOTSUP)
16430 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16432 RTE_PMD_I40E_PKG_OP_WR_DEL);
16435 if (ret == -EACCES)
16436 printf("Profile does not exist.\n");
16438 printf("Failed to delete profile.\n");
16443 cmdline_parse_inst_t cmd_ddp_del = {
16444 .f = cmd_ddp_del_parsed,
16446 .help_str = "ddp del <port_id> <backup_profile_path>",
16448 (void *)&cmd_ddp_del_ddp,
16449 (void *)&cmd_ddp_del_del,
16450 (void *)&cmd_ddp_del_port_id,
16451 (void *)&cmd_ddp_del_filepath,
16456 /* Get dynamic device personalization profile info */
16457 struct cmd_ddp_info_result {
16458 cmdline_fixed_string_t ddp;
16459 cmdline_fixed_string_t get;
16460 cmdline_fixed_string_t info;
16464 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16465 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16466 cmdline_parse_token_string_t cmd_ddp_info_get =
16467 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16468 cmdline_parse_token_string_t cmd_ddp_info_info =
16469 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16470 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16471 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16474 cmd_ddp_info_parsed(
16475 void *parsed_result,
16476 __attribute__((unused)) struct cmdline *cl,
16477 __attribute__((unused)) void *data)
16479 struct cmd_ddp_info_result *res = parsed_result;
16482 int ret = -ENOTSUP;
16483 #ifdef RTE_LIBRTE_I40E_PMD
16486 uint32_t buff_size = 0;
16487 struct rte_pmd_i40e_profile_info info;
16488 uint32_t dev_num = 0;
16489 struct rte_pmd_i40e_ddp_device_id *devs;
16490 uint32_t proto_num = 0;
16491 struct rte_pmd_i40e_proto_info *proto = NULL;
16492 uint32_t pctype_num = 0;
16493 struct rte_pmd_i40e_ptype_info *pctype;
16494 uint32_t ptype_num = 0;
16495 struct rte_pmd_i40e_ptype_info *ptype;
16500 pkg = open_file(res->filepath, &pkg_size);
16504 #ifdef RTE_LIBRTE_I40E_PMD
16505 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16506 (uint8_t *)&info, sizeof(info),
16507 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16509 printf("Global Track id: 0x%x\n", info.track_id);
16510 printf("Global Version: %d.%d.%d.%d\n",
16511 info.version.major,
16512 info.version.minor,
16513 info.version.update,
16514 info.version.draft);
16515 printf("Global Package name: %s\n\n", info.name);
16518 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16519 (uint8_t *)&info, sizeof(info),
16520 RTE_PMD_I40E_PKG_INFO_HEADER);
16522 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16523 printf("i40e Profile Version: %d.%d.%d.%d\n",
16524 info.version.major,
16525 info.version.minor,
16526 info.version.update,
16527 info.version.draft);
16528 printf("i40e Profile name: %s\n\n", info.name);
16531 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16532 (uint8_t *)&buff_size, sizeof(buff_size),
16533 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16534 if (!ret && buff_size) {
16535 buff = (uint8_t *)malloc(buff_size);
16537 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16539 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16541 printf("Package Notes:\n%s\n\n", buff);
16546 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16547 (uint8_t *)&dev_num, sizeof(dev_num),
16548 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16549 if (!ret && dev_num) {
16550 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16551 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16553 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16554 (uint8_t *)devs, buff_size,
16555 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16557 printf("List of supported devices:\n");
16558 for (i = 0; i < dev_num; i++) {
16559 printf(" %04X:%04X %04X:%04X\n",
16560 devs[i].vendor_dev_id >> 16,
16561 devs[i].vendor_dev_id & 0xFFFF,
16562 devs[i].sub_vendor_dev_id >> 16,
16563 devs[i].sub_vendor_dev_id & 0xFFFF);
16571 /* get information about protocols and packet types */
16572 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16573 (uint8_t *)&proto_num, sizeof(proto_num),
16574 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16575 if (ret || !proto_num)
16576 goto no_print_return;
16578 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16579 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16581 goto no_print_return;
16583 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16585 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16587 printf("List of used protocols:\n");
16588 for (i = 0; i < proto_num; i++)
16589 printf(" %2u: %s\n", proto[i].proto_id,
16593 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16594 (uint8_t *)&pctype_num, sizeof(pctype_num),
16595 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16596 if (ret || !pctype_num)
16597 goto no_print_pctypes;
16599 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16600 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16602 goto no_print_pctypes;
16604 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16606 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16609 goto no_print_pctypes;
16612 printf("List of defined packet classification types:\n");
16613 for (i = 0; i < pctype_num; i++) {
16614 printf(" %2u:", pctype[i].ptype_id);
16615 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16616 proto_id = pctype[i].protocols[j];
16617 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16618 for (n = 0; n < proto_num; n++) {
16619 if (proto[n].proto_id == proto_id) {
16620 printf(" %s", proto[n].name);
16633 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16635 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16636 if (ret || !ptype_num)
16637 goto no_print_return;
16639 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16640 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16642 goto no_print_return;
16644 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16646 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16649 goto no_print_return;
16651 printf("List of defined packet types:\n");
16652 for (i = 0; i < ptype_num; i++) {
16653 printf(" %2u:", ptype[i].ptype_id);
16654 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16655 proto_id = ptype[i].protocols[j];
16656 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16657 for (n = 0; n < proto_num; n++) {
16658 if (proto[n].proto_id == proto_id) {
16659 printf(" %s", proto[n].name);
16675 if (ret == -ENOTSUP)
16676 printf("Function not supported in PMD driver\n");
16680 cmdline_parse_inst_t cmd_ddp_get_info = {
16681 .f = cmd_ddp_info_parsed,
16683 .help_str = "ddp get info <profile_path>",
16685 (void *)&cmd_ddp_info_ddp,
16686 (void *)&cmd_ddp_info_get,
16687 (void *)&cmd_ddp_info_info,
16688 (void *)&cmd_ddp_info_filepath,
16693 /* Get dynamic device personalization profile info list*/
16694 #define PROFILE_INFO_SIZE 48
16695 #define MAX_PROFILE_NUM 16
16697 struct cmd_ddp_get_list_result {
16698 cmdline_fixed_string_t ddp;
16699 cmdline_fixed_string_t get;
16700 cmdline_fixed_string_t list;
16704 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16705 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16706 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16707 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16708 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16709 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16710 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16711 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16714 cmd_ddp_get_list_parsed(
16715 __attribute__((unused)) void *parsed_result,
16716 __attribute__((unused)) struct cmdline *cl,
16717 __attribute__((unused)) void *data)
16719 #ifdef RTE_LIBRTE_I40E_PMD
16720 struct cmd_ddp_get_list_result *res = parsed_result;
16721 struct rte_pmd_i40e_profile_list *p_list;
16722 struct rte_pmd_i40e_profile_info *p_info;
16727 int ret = -ENOTSUP;
16729 #ifdef RTE_LIBRTE_I40E_PMD
16730 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16731 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16733 printf("%s: Failed to malloc buffer\n", __func__);
16735 if (ret == -ENOTSUP)
16736 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16737 (uint8_t *)p_list, size);
16740 p_num = p_list->p_count;
16741 printf("Profile number is: %d\n\n", p_num);
16743 for (i = 0; i < p_num; i++) {
16744 p_info = &p_list->p_info[i];
16745 printf("Profile %d:\n", i);
16746 printf("Track id: 0x%x\n", p_info->track_id);
16747 printf("Version: %d.%d.%d.%d\n",
16748 p_info->version.major,
16749 p_info->version.minor,
16750 p_info->version.update,
16751 p_info->version.draft);
16752 printf("Profile name: %s\n\n", p_info->name);
16760 printf("Failed to get ddp list\n");
16763 cmdline_parse_inst_t cmd_ddp_get_list = {
16764 .f = cmd_ddp_get_list_parsed,
16766 .help_str = "ddp get list <port_id>",
16768 (void *)&cmd_ddp_get_list_ddp,
16769 (void *)&cmd_ddp_get_list_get,
16770 (void *)&cmd_ddp_get_list_list,
16771 (void *)&cmd_ddp_get_list_port_id,
16776 /* Configure input set */
16777 struct cmd_cfg_input_set_result {
16778 cmdline_fixed_string_t port;
16779 cmdline_fixed_string_t cfg;
16781 cmdline_fixed_string_t pctype;
16783 cmdline_fixed_string_t inset_type;
16784 cmdline_fixed_string_t opt;
16785 cmdline_fixed_string_t field;
16790 cmd_cfg_input_set_parsed(
16791 __attribute__((unused)) void *parsed_result,
16792 __attribute__((unused)) struct cmdline *cl,
16793 __attribute__((unused)) void *data)
16795 #ifdef RTE_LIBRTE_I40E_PMD
16796 struct cmd_cfg_input_set_result *res = parsed_result;
16797 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16798 struct rte_pmd_i40e_inset inset;
16800 int ret = -ENOTSUP;
16802 if (!all_ports_stopped()) {
16803 printf("Please stop all ports first\n");
16807 #ifdef RTE_LIBRTE_I40E_PMD
16808 if (!strcmp(res->inset_type, "hash_inset"))
16809 inset_type = INSET_HASH;
16810 else if (!strcmp(res->inset_type, "fdir_inset"))
16811 inset_type = INSET_FDIR;
16812 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16813 inset_type = INSET_FDIR_FLX;
16814 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16815 &inset, inset_type);
16817 printf("Failed to get input set.\n");
16821 if (!strcmp(res->opt, "get")) {
16822 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16825 printf("Field index %d is enabled.\n", res->field_idx);
16827 printf("Field index %d is disabled.\n", res->field_idx);
16829 } else if (!strcmp(res->opt, "set"))
16830 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16832 else if (!strcmp(res->opt, "clear"))
16833 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16836 printf("Failed to configure input set field.\n");
16840 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16841 &inset, inset_type);
16843 printf("Failed to set input set.\n");
16848 if (ret == -ENOTSUP)
16849 printf("Function not supported\n");
16852 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16853 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16855 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16856 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16858 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16859 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16861 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16862 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16864 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16865 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16867 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16868 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16870 "hash_inset#fdir_inset#fdir_flx_inset");
16871 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16872 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16873 opt, "get#set#clear");
16874 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16875 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16877 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16878 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16881 cmdline_parse_inst_t cmd_cfg_input_set = {
16882 .f = cmd_cfg_input_set_parsed,
16884 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16885 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16887 (void *)&cmd_cfg_input_set_port,
16888 (void *)&cmd_cfg_input_set_cfg,
16889 (void *)&cmd_cfg_input_set_port_id,
16890 (void *)&cmd_cfg_input_set_pctype,
16891 (void *)&cmd_cfg_input_set_pctype_id,
16892 (void *)&cmd_cfg_input_set_inset_type,
16893 (void *)&cmd_cfg_input_set_opt,
16894 (void *)&cmd_cfg_input_set_field,
16895 (void *)&cmd_cfg_input_set_field_idx,
16900 /* Clear input set */
16901 struct cmd_clear_input_set_result {
16902 cmdline_fixed_string_t port;
16903 cmdline_fixed_string_t cfg;
16905 cmdline_fixed_string_t pctype;
16907 cmdline_fixed_string_t inset_type;
16908 cmdline_fixed_string_t clear;
16909 cmdline_fixed_string_t all;
16913 cmd_clear_input_set_parsed(
16914 __attribute__((unused)) void *parsed_result,
16915 __attribute__((unused)) struct cmdline *cl,
16916 __attribute__((unused)) void *data)
16918 #ifdef RTE_LIBRTE_I40E_PMD
16919 struct cmd_clear_input_set_result *res = parsed_result;
16920 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16921 struct rte_pmd_i40e_inset inset;
16923 int ret = -ENOTSUP;
16925 if (!all_ports_stopped()) {
16926 printf("Please stop all ports first\n");
16930 #ifdef RTE_LIBRTE_I40E_PMD
16931 if (!strcmp(res->inset_type, "hash_inset"))
16932 inset_type = INSET_HASH;
16933 else if (!strcmp(res->inset_type, "fdir_inset"))
16934 inset_type = INSET_FDIR;
16935 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16936 inset_type = INSET_FDIR_FLX;
16938 memset(&inset, 0, sizeof(inset));
16940 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16941 &inset, inset_type);
16943 printf("Failed to clear input set.\n");
16949 if (ret == -ENOTSUP)
16950 printf("Function not supported\n");
16953 cmdline_parse_token_string_t cmd_clear_input_set_port =
16954 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16956 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
16957 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16959 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
16960 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16962 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
16963 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16965 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
16966 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16968 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
16969 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16971 "hash_inset#fdir_inset#fdir_flx_inset");
16972 cmdline_parse_token_string_t cmd_clear_input_set_clear =
16973 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16975 cmdline_parse_token_string_t cmd_clear_input_set_all =
16976 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16979 cmdline_parse_inst_t cmd_clear_input_set = {
16980 .f = cmd_clear_input_set_parsed,
16982 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16983 "fdir_inset|fdir_flx_inset clear all",
16985 (void *)&cmd_clear_input_set_port,
16986 (void *)&cmd_clear_input_set_cfg,
16987 (void *)&cmd_clear_input_set_port_id,
16988 (void *)&cmd_clear_input_set_pctype,
16989 (void *)&cmd_clear_input_set_pctype_id,
16990 (void *)&cmd_clear_input_set_inset_type,
16991 (void *)&cmd_clear_input_set_clear,
16992 (void *)&cmd_clear_input_set_all,
16997 /* show vf stats */
16999 /* Common result structure for show vf stats */
17000 struct cmd_show_vf_stats_result {
17001 cmdline_fixed_string_t show;
17002 cmdline_fixed_string_t vf;
17003 cmdline_fixed_string_t stats;
17008 /* Common CLI fields show vf stats*/
17009 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17010 TOKEN_STRING_INITIALIZER
17011 (struct cmd_show_vf_stats_result,
17013 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17014 TOKEN_STRING_INITIALIZER
17015 (struct cmd_show_vf_stats_result,
17017 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17018 TOKEN_STRING_INITIALIZER
17019 (struct cmd_show_vf_stats_result,
17021 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17022 TOKEN_NUM_INITIALIZER
17023 (struct cmd_show_vf_stats_result,
17025 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17026 TOKEN_NUM_INITIALIZER
17027 (struct cmd_show_vf_stats_result,
17031 cmd_show_vf_stats_parsed(
17032 void *parsed_result,
17033 __attribute__((unused)) struct cmdline *cl,
17034 __attribute__((unused)) void *data)
17036 struct cmd_show_vf_stats_result *res = parsed_result;
17037 struct rte_eth_stats stats;
17038 int ret = -ENOTSUP;
17039 static const char *nic_stats_border = "########################";
17041 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17044 memset(&stats, 0, sizeof(stats));
17046 #ifdef RTE_LIBRTE_I40E_PMD
17047 if (ret == -ENOTSUP)
17048 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17052 #ifdef RTE_LIBRTE_BNXT_PMD
17053 if (ret == -ENOTSUP)
17054 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17063 printf("invalid vf_id %d\n", res->vf_id);
17066 printf("invalid port_id %d\n", res->port_id);
17069 printf("function not implemented\n");
17072 printf("programming error: (%s)\n", strerror(-ret));
17075 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17076 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17078 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17080 stats.ipackets, stats.imissed, stats.ibytes);
17081 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17082 printf(" RX-nombuf: %-10"PRIu64"\n",
17084 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17086 stats.opackets, stats.oerrors, stats.obytes);
17088 printf(" %s############################%s\n",
17089 nic_stats_border, nic_stats_border);
17092 cmdline_parse_inst_t cmd_show_vf_stats = {
17093 .f = cmd_show_vf_stats_parsed,
17095 .help_str = "show vf stats <port_id> <vf_id>",
17097 (void *)&cmd_show_vf_stats_show,
17098 (void *)&cmd_show_vf_stats_vf,
17099 (void *)&cmd_show_vf_stats_stats,
17100 (void *)&cmd_show_vf_stats_port_id,
17101 (void *)&cmd_show_vf_stats_vf_id,
17106 /* clear vf stats */
17108 /* Common result structure for clear vf stats */
17109 struct cmd_clear_vf_stats_result {
17110 cmdline_fixed_string_t clear;
17111 cmdline_fixed_string_t vf;
17112 cmdline_fixed_string_t stats;
17117 /* Common CLI fields clear vf stats*/
17118 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17119 TOKEN_STRING_INITIALIZER
17120 (struct cmd_clear_vf_stats_result,
17122 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17123 TOKEN_STRING_INITIALIZER
17124 (struct cmd_clear_vf_stats_result,
17126 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17127 TOKEN_STRING_INITIALIZER
17128 (struct cmd_clear_vf_stats_result,
17130 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17131 TOKEN_NUM_INITIALIZER
17132 (struct cmd_clear_vf_stats_result,
17134 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17135 TOKEN_NUM_INITIALIZER
17136 (struct cmd_clear_vf_stats_result,
17140 cmd_clear_vf_stats_parsed(
17141 void *parsed_result,
17142 __attribute__((unused)) struct cmdline *cl,
17143 __attribute__((unused)) void *data)
17145 struct cmd_clear_vf_stats_result *res = parsed_result;
17146 int ret = -ENOTSUP;
17148 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17151 #ifdef RTE_LIBRTE_I40E_PMD
17152 if (ret == -ENOTSUP)
17153 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17156 #ifdef RTE_LIBRTE_BNXT_PMD
17157 if (ret == -ENOTSUP)
17158 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17166 printf("invalid vf_id %d\n", res->vf_id);
17169 printf("invalid port_id %d\n", res->port_id);
17172 printf("function not implemented\n");
17175 printf("programming error: (%s)\n", strerror(-ret));
17179 cmdline_parse_inst_t cmd_clear_vf_stats = {
17180 .f = cmd_clear_vf_stats_parsed,
17182 .help_str = "clear vf stats <port_id> <vf_id>",
17184 (void *)&cmd_clear_vf_stats_clear,
17185 (void *)&cmd_clear_vf_stats_vf,
17186 (void *)&cmd_clear_vf_stats_stats,
17187 (void *)&cmd_clear_vf_stats_port_id,
17188 (void *)&cmd_clear_vf_stats_vf_id,
17193 /* port config pctype mapping reset */
17195 /* Common result structure for port config pctype mapping reset */
17196 struct cmd_pctype_mapping_reset_result {
17197 cmdline_fixed_string_t port;
17198 cmdline_fixed_string_t config;
17200 cmdline_fixed_string_t pctype;
17201 cmdline_fixed_string_t mapping;
17202 cmdline_fixed_string_t reset;
17205 /* Common CLI fields for port config pctype mapping reset*/
17206 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17207 TOKEN_STRING_INITIALIZER
17208 (struct cmd_pctype_mapping_reset_result,
17210 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17211 TOKEN_STRING_INITIALIZER
17212 (struct cmd_pctype_mapping_reset_result,
17214 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17215 TOKEN_NUM_INITIALIZER
17216 (struct cmd_pctype_mapping_reset_result,
17218 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17219 TOKEN_STRING_INITIALIZER
17220 (struct cmd_pctype_mapping_reset_result,
17222 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17223 TOKEN_STRING_INITIALIZER
17224 (struct cmd_pctype_mapping_reset_result,
17225 mapping, "mapping");
17226 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17227 TOKEN_STRING_INITIALIZER
17228 (struct cmd_pctype_mapping_reset_result,
17232 cmd_pctype_mapping_reset_parsed(
17233 void *parsed_result,
17234 __attribute__((unused)) struct cmdline *cl,
17235 __attribute__((unused)) void *data)
17237 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17238 int ret = -ENOTSUP;
17240 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17243 #ifdef RTE_LIBRTE_I40E_PMD
17244 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17251 printf("invalid port_id %d\n", res->port_id);
17254 printf("function not implemented\n");
17257 printf("programming error: (%s)\n", strerror(-ret));
17261 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17262 .f = cmd_pctype_mapping_reset_parsed,
17264 .help_str = "port config <port_id> pctype mapping reset",
17266 (void *)&cmd_pctype_mapping_reset_port,
17267 (void *)&cmd_pctype_mapping_reset_config,
17268 (void *)&cmd_pctype_mapping_reset_port_id,
17269 (void *)&cmd_pctype_mapping_reset_pctype,
17270 (void *)&cmd_pctype_mapping_reset_mapping,
17271 (void *)&cmd_pctype_mapping_reset_reset,
17276 /* show port pctype mapping */
17278 /* Common result structure for show port pctype mapping */
17279 struct cmd_pctype_mapping_get_result {
17280 cmdline_fixed_string_t show;
17281 cmdline_fixed_string_t port;
17283 cmdline_fixed_string_t pctype;
17284 cmdline_fixed_string_t mapping;
17287 /* Common CLI fields for pctype mapping get */
17288 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17289 TOKEN_STRING_INITIALIZER
17290 (struct cmd_pctype_mapping_get_result,
17292 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17293 TOKEN_STRING_INITIALIZER
17294 (struct cmd_pctype_mapping_get_result,
17296 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17297 TOKEN_NUM_INITIALIZER
17298 (struct cmd_pctype_mapping_get_result,
17300 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17301 TOKEN_STRING_INITIALIZER
17302 (struct cmd_pctype_mapping_get_result,
17304 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17305 TOKEN_STRING_INITIALIZER
17306 (struct cmd_pctype_mapping_get_result,
17307 mapping, "mapping");
17310 cmd_pctype_mapping_get_parsed(
17311 void *parsed_result,
17312 __attribute__((unused)) struct cmdline *cl,
17313 __attribute__((unused)) void *data)
17315 struct cmd_pctype_mapping_get_result *res = parsed_result;
17316 int ret = -ENOTSUP;
17317 #ifdef RTE_LIBRTE_I40E_PMD
17318 struct rte_pmd_i40e_flow_type_mapping
17319 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17320 int i, j, first_pctype;
17323 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17326 #ifdef RTE_LIBRTE_I40E_PMD
17327 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17334 printf("invalid port_id %d\n", res->port_id);
17337 printf("function not implemented\n");
17340 printf("programming error: (%s)\n", strerror(-ret));
17344 #ifdef RTE_LIBRTE_I40E_PMD
17345 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17346 if (mapping[i].pctype != 0ULL) {
17349 printf("pctype: ");
17350 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17351 if (mapping[i].pctype & (1ULL << j)) {
17352 printf(first_pctype ?
17353 "%02d" : ",%02d", j);
17357 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17363 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17364 .f = cmd_pctype_mapping_get_parsed,
17366 .help_str = "show port <port_id> pctype mapping",
17368 (void *)&cmd_pctype_mapping_get_show,
17369 (void *)&cmd_pctype_mapping_get_port,
17370 (void *)&cmd_pctype_mapping_get_port_id,
17371 (void *)&cmd_pctype_mapping_get_pctype,
17372 (void *)&cmd_pctype_mapping_get_mapping,
17377 /* port config pctype mapping update */
17379 /* Common result structure for port config pctype mapping update */
17380 struct cmd_pctype_mapping_update_result {
17381 cmdline_fixed_string_t port;
17382 cmdline_fixed_string_t config;
17384 cmdline_fixed_string_t pctype;
17385 cmdline_fixed_string_t mapping;
17386 cmdline_fixed_string_t update;
17387 cmdline_fixed_string_t pctype_list;
17388 uint16_t flow_type;
17391 /* Common CLI fields for pctype mapping update*/
17392 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17393 TOKEN_STRING_INITIALIZER
17394 (struct cmd_pctype_mapping_update_result,
17396 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17397 TOKEN_STRING_INITIALIZER
17398 (struct cmd_pctype_mapping_update_result,
17400 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17401 TOKEN_NUM_INITIALIZER
17402 (struct cmd_pctype_mapping_update_result,
17404 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17405 TOKEN_STRING_INITIALIZER
17406 (struct cmd_pctype_mapping_update_result,
17408 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17409 TOKEN_STRING_INITIALIZER
17410 (struct cmd_pctype_mapping_update_result,
17411 mapping, "mapping");
17412 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17413 TOKEN_STRING_INITIALIZER
17414 (struct cmd_pctype_mapping_update_result,
17416 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17417 TOKEN_STRING_INITIALIZER
17418 (struct cmd_pctype_mapping_update_result,
17419 pctype_list, NULL);
17420 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17421 TOKEN_NUM_INITIALIZER
17422 (struct cmd_pctype_mapping_update_result,
17423 flow_type, UINT16);
17426 cmd_pctype_mapping_update_parsed(
17427 void *parsed_result,
17428 __attribute__((unused)) struct cmdline *cl,
17429 __attribute__((unused)) void *data)
17431 struct cmd_pctype_mapping_update_result *res = parsed_result;
17432 int ret = -ENOTSUP;
17433 #ifdef RTE_LIBRTE_I40E_PMD
17434 struct rte_pmd_i40e_flow_type_mapping mapping;
17436 unsigned int nb_item;
17437 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17440 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17443 #ifdef RTE_LIBRTE_I40E_PMD
17444 nb_item = parse_item_list(res->pctype_list, "pctypes",
17445 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17446 mapping.flow_type = res->flow_type;
17447 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17448 mapping.pctype |= (1ULL << pctype_list[i]);
17449 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17459 printf("invalid pctype or flow type\n");
17462 printf("invalid port_id %d\n", res->port_id);
17465 printf("function not implemented\n");
17468 printf("programming error: (%s)\n", strerror(-ret));
17472 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17473 .f = cmd_pctype_mapping_update_parsed,
17475 .help_str = "port config <port_id> pctype mapping update"
17476 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17478 (void *)&cmd_pctype_mapping_update_port,
17479 (void *)&cmd_pctype_mapping_update_config,
17480 (void *)&cmd_pctype_mapping_update_port_id,
17481 (void *)&cmd_pctype_mapping_update_pctype,
17482 (void *)&cmd_pctype_mapping_update_mapping,
17483 (void *)&cmd_pctype_mapping_update_update,
17484 (void *)&cmd_pctype_mapping_update_pc_type,
17485 (void *)&cmd_pctype_mapping_update_flow_type,
17490 /* ptype mapping get */
17492 /* Common result structure for ptype mapping get */
17493 struct cmd_ptype_mapping_get_result {
17494 cmdline_fixed_string_t ptype;
17495 cmdline_fixed_string_t mapping;
17496 cmdline_fixed_string_t get;
17498 uint8_t valid_only;
17501 /* Common CLI fields for ptype mapping get */
17502 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17503 TOKEN_STRING_INITIALIZER
17504 (struct cmd_ptype_mapping_get_result,
17506 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17507 TOKEN_STRING_INITIALIZER
17508 (struct cmd_ptype_mapping_get_result,
17509 mapping, "mapping");
17510 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17511 TOKEN_STRING_INITIALIZER
17512 (struct cmd_ptype_mapping_get_result,
17514 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17515 TOKEN_NUM_INITIALIZER
17516 (struct cmd_ptype_mapping_get_result,
17518 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17519 TOKEN_NUM_INITIALIZER
17520 (struct cmd_ptype_mapping_get_result,
17521 valid_only, UINT8);
17524 cmd_ptype_mapping_get_parsed(
17525 void *parsed_result,
17526 __attribute__((unused)) struct cmdline *cl,
17527 __attribute__((unused)) void *data)
17529 struct cmd_ptype_mapping_get_result *res = parsed_result;
17530 int ret = -ENOTSUP;
17531 #ifdef RTE_LIBRTE_I40E_PMD
17532 int max_ptype_num = 256;
17533 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17538 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17541 #ifdef RTE_LIBRTE_I40E_PMD
17542 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17553 printf("invalid port_id %d\n", res->port_id);
17556 printf("function not implemented\n");
17559 printf("programming error: (%s)\n", strerror(-ret));
17562 #ifdef RTE_LIBRTE_I40E_PMD
17564 for (i = 0; i < count; i++)
17565 printf("%3d\t0x%08x\n",
17566 mapping[i].hw_ptype, mapping[i].sw_ptype);
17571 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17572 .f = cmd_ptype_mapping_get_parsed,
17574 .help_str = "ptype mapping get <port_id> <valid_only>",
17576 (void *)&cmd_ptype_mapping_get_ptype,
17577 (void *)&cmd_ptype_mapping_get_mapping,
17578 (void *)&cmd_ptype_mapping_get_get,
17579 (void *)&cmd_ptype_mapping_get_port_id,
17580 (void *)&cmd_ptype_mapping_get_valid_only,
17585 /* ptype mapping replace */
17587 /* Common result structure for ptype mapping replace */
17588 struct cmd_ptype_mapping_replace_result {
17589 cmdline_fixed_string_t ptype;
17590 cmdline_fixed_string_t mapping;
17591 cmdline_fixed_string_t replace;
17598 /* Common CLI fields for ptype mapping replace */
17599 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17600 TOKEN_STRING_INITIALIZER
17601 (struct cmd_ptype_mapping_replace_result,
17603 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17604 TOKEN_STRING_INITIALIZER
17605 (struct cmd_ptype_mapping_replace_result,
17606 mapping, "mapping");
17607 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17608 TOKEN_STRING_INITIALIZER
17609 (struct cmd_ptype_mapping_replace_result,
17610 replace, "replace");
17611 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17612 TOKEN_NUM_INITIALIZER
17613 (struct cmd_ptype_mapping_replace_result,
17615 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17616 TOKEN_NUM_INITIALIZER
17617 (struct cmd_ptype_mapping_replace_result,
17619 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17620 TOKEN_NUM_INITIALIZER
17621 (struct cmd_ptype_mapping_replace_result,
17623 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17624 TOKEN_NUM_INITIALIZER
17625 (struct cmd_ptype_mapping_replace_result,
17629 cmd_ptype_mapping_replace_parsed(
17630 void *parsed_result,
17631 __attribute__((unused)) struct cmdline *cl,
17632 __attribute__((unused)) void *data)
17634 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17635 int ret = -ENOTSUP;
17637 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17640 #ifdef RTE_LIBRTE_I40E_PMD
17641 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17651 printf("invalid ptype 0x%8x or 0x%8x\n",
17652 res->target, res->pkt_type);
17655 printf("invalid port_id %d\n", res->port_id);
17658 printf("function not implemented\n");
17661 printf("programming error: (%s)\n", strerror(-ret));
17665 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17666 .f = cmd_ptype_mapping_replace_parsed,
17669 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17671 (void *)&cmd_ptype_mapping_replace_ptype,
17672 (void *)&cmd_ptype_mapping_replace_mapping,
17673 (void *)&cmd_ptype_mapping_replace_replace,
17674 (void *)&cmd_ptype_mapping_replace_port_id,
17675 (void *)&cmd_ptype_mapping_replace_target,
17676 (void *)&cmd_ptype_mapping_replace_mask,
17677 (void *)&cmd_ptype_mapping_replace_pkt_type,
17682 /* ptype mapping reset */
17684 /* Common result structure for ptype mapping reset */
17685 struct cmd_ptype_mapping_reset_result {
17686 cmdline_fixed_string_t ptype;
17687 cmdline_fixed_string_t mapping;
17688 cmdline_fixed_string_t reset;
17692 /* Common CLI fields for ptype mapping reset*/
17693 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17694 TOKEN_STRING_INITIALIZER
17695 (struct cmd_ptype_mapping_reset_result,
17697 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17698 TOKEN_STRING_INITIALIZER
17699 (struct cmd_ptype_mapping_reset_result,
17700 mapping, "mapping");
17701 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17702 TOKEN_STRING_INITIALIZER
17703 (struct cmd_ptype_mapping_reset_result,
17705 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17706 TOKEN_NUM_INITIALIZER
17707 (struct cmd_ptype_mapping_reset_result,
17711 cmd_ptype_mapping_reset_parsed(
17712 void *parsed_result,
17713 __attribute__((unused)) struct cmdline *cl,
17714 __attribute__((unused)) void *data)
17716 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17717 int ret = -ENOTSUP;
17719 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17722 #ifdef RTE_LIBRTE_I40E_PMD
17723 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17730 printf("invalid port_id %d\n", res->port_id);
17733 printf("function not implemented\n");
17736 printf("programming error: (%s)\n", strerror(-ret));
17740 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17741 .f = cmd_ptype_mapping_reset_parsed,
17743 .help_str = "ptype mapping reset <port_id>",
17745 (void *)&cmd_ptype_mapping_reset_ptype,
17746 (void *)&cmd_ptype_mapping_reset_mapping,
17747 (void *)&cmd_ptype_mapping_reset_reset,
17748 (void *)&cmd_ptype_mapping_reset_port_id,
17753 /* ptype mapping update */
17755 /* Common result structure for ptype mapping update */
17756 struct cmd_ptype_mapping_update_result {
17757 cmdline_fixed_string_t ptype;
17758 cmdline_fixed_string_t mapping;
17759 cmdline_fixed_string_t reset;
17765 /* Common CLI fields for ptype mapping update*/
17766 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17767 TOKEN_STRING_INITIALIZER
17768 (struct cmd_ptype_mapping_update_result,
17770 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17771 TOKEN_STRING_INITIALIZER
17772 (struct cmd_ptype_mapping_update_result,
17773 mapping, "mapping");
17774 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17775 TOKEN_STRING_INITIALIZER
17776 (struct cmd_ptype_mapping_update_result,
17778 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17779 TOKEN_NUM_INITIALIZER
17780 (struct cmd_ptype_mapping_update_result,
17782 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17783 TOKEN_NUM_INITIALIZER
17784 (struct cmd_ptype_mapping_update_result,
17786 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17787 TOKEN_NUM_INITIALIZER
17788 (struct cmd_ptype_mapping_update_result,
17792 cmd_ptype_mapping_update_parsed(
17793 void *parsed_result,
17794 __attribute__((unused)) struct cmdline *cl,
17795 __attribute__((unused)) void *data)
17797 struct cmd_ptype_mapping_update_result *res = parsed_result;
17798 int ret = -ENOTSUP;
17799 #ifdef RTE_LIBRTE_I40E_PMD
17800 struct rte_pmd_i40e_ptype_mapping mapping;
17802 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17805 #ifdef RTE_LIBRTE_I40E_PMD
17806 mapping.hw_ptype = res->hw_ptype;
17807 mapping.sw_ptype = res->sw_ptype;
17808 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17818 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17821 printf("invalid port_id %d\n", res->port_id);
17824 printf("function not implemented\n");
17827 printf("programming error: (%s)\n", strerror(-ret));
17831 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17832 .f = cmd_ptype_mapping_update_parsed,
17834 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17836 (void *)&cmd_ptype_mapping_update_ptype,
17837 (void *)&cmd_ptype_mapping_update_mapping,
17838 (void *)&cmd_ptype_mapping_update_update,
17839 (void *)&cmd_ptype_mapping_update_port_id,
17840 (void *)&cmd_ptype_mapping_update_hw_ptype,
17841 (void *)&cmd_ptype_mapping_update_sw_ptype,
17846 /* Common result structure for file commands */
17847 struct cmd_cmdfile_result {
17848 cmdline_fixed_string_t load;
17849 cmdline_fixed_string_t filename;
17852 /* Common CLI fields for file commands */
17853 cmdline_parse_token_string_t cmd_load_cmdfile =
17854 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17855 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17856 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17859 cmd_load_from_file_parsed(
17860 void *parsed_result,
17861 __attribute__((unused)) struct cmdline *cl,
17862 __attribute__((unused)) void *data)
17864 struct cmd_cmdfile_result *res = parsed_result;
17866 cmdline_read_from_file(res->filename);
17869 cmdline_parse_inst_t cmd_load_from_file = {
17870 .f = cmd_load_from_file_parsed,
17872 .help_str = "load <filename>",
17874 (void *)&cmd_load_cmdfile,
17875 (void *)&cmd_load_cmdfile_filename,
17880 /* Get Rx offloads capabilities */
17881 struct cmd_rx_offload_get_capa_result {
17882 cmdline_fixed_string_t show;
17883 cmdline_fixed_string_t port;
17885 cmdline_fixed_string_t rx_offload;
17886 cmdline_fixed_string_t capabilities;
17889 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17890 TOKEN_STRING_INITIALIZER
17891 (struct cmd_rx_offload_get_capa_result,
17893 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17894 TOKEN_STRING_INITIALIZER
17895 (struct cmd_rx_offload_get_capa_result,
17897 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17898 TOKEN_NUM_INITIALIZER
17899 (struct cmd_rx_offload_get_capa_result,
17901 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17902 TOKEN_STRING_INITIALIZER
17903 (struct cmd_rx_offload_get_capa_result,
17904 rx_offload, "rx_offload");
17905 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17906 TOKEN_STRING_INITIALIZER
17907 (struct cmd_rx_offload_get_capa_result,
17908 capabilities, "capabilities");
17911 print_rx_offloads(uint64_t offloads)
17913 uint64_t single_offload;
17921 begin = __builtin_ctzll(offloads);
17922 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17924 single_offload = 1ULL << begin;
17925 for (bit = begin; bit < end; bit++) {
17926 if (offloads & single_offload)
17928 rte_eth_dev_rx_offload_name(single_offload));
17929 single_offload <<= 1;
17934 cmd_rx_offload_get_capa_parsed(
17935 void *parsed_result,
17936 __attribute__((unused)) struct cmdline *cl,
17937 __attribute__((unused)) void *data)
17939 struct cmd_rx_offload_get_capa_result *res = parsed_result;
17940 struct rte_eth_dev_info dev_info;
17941 portid_t port_id = res->port_id;
17942 uint64_t queue_offloads;
17943 uint64_t port_offloads;
17946 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17950 queue_offloads = dev_info.rx_queue_offload_capa;
17951 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
17953 printf("Rx Offloading Capabilities of port %d :\n", port_id);
17954 printf(" Per Queue :");
17955 print_rx_offloads(queue_offloads);
17958 printf(" Per Port :");
17959 print_rx_offloads(port_offloads);
17963 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
17964 .f = cmd_rx_offload_get_capa_parsed,
17966 .help_str = "show port <port_id> rx_offload capabilities",
17968 (void *)&cmd_rx_offload_get_capa_show,
17969 (void *)&cmd_rx_offload_get_capa_port,
17970 (void *)&cmd_rx_offload_get_capa_port_id,
17971 (void *)&cmd_rx_offload_get_capa_rx_offload,
17972 (void *)&cmd_rx_offload_get_capa_capabilities,
17977 /* Get Rx offloads configuration */
17978 struct cmd_rx_offload_get_configuration_result {
17979 cmdline_fixed_string_t show;
17980 cmdline_fixed_string_t port;
17982 cmdline_fixed_string_t rx_offload;
17983 cmdline_fixed_string_t configuration;
17986 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
17987 TOKEN_STRING_INITIALIZER
17988 (struct cmd_rx_offload_get_configuration_result,
17990 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
17991 TOKEN_STRING_INITIALIZER
17992 (struct cmd_rx_offload_get_configuration_result,
17994 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
17995 TOKEN_NUM_INITIALIZER
17996 (struct cmd_rx_offload_get_configuration_result,
17998 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
17999 TOKEN_STRING_INITIALIZER
18000 (struct cmd_rx_offload_get_configuration_result,
18001 rx_offload, "rx_offload");
18002 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18003 TOKEN_STRING_INITIALIZER
18004 (struct cmd_rx_offload_get_configuration_result,
18005 configuration, "configuration");
18008 cmd_rx_offload_get_configuration_parsed(
18009 void *parsed_result,
18010 __attribute__((unused)) struct cmdline *cl,
18011 __attribute__((unused)) void *data)
18013 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18014 struct rte_eth_dev_info dev_info;
18015 portid_t port_id = res->port_id;
18016 struct rte_port *port = &ports[port_id];
18017 uint64_t port_offloads;
18018 uint64_t queue_offloads;
18019 uint16_t nb_rx_queues;
18023 printf("Rx Offloading Configuration of port %d :\n", port_id);
18025 port_offloads = port->dev_conf.rxmode.offloads;
18027 print_rx_offloads(port_offloads);
18030 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18034 nb_rx_queues = dev_info.nb_rx_queues;
18035 for (q = 0; q < nb_rx_queues; q++) {
18036 queue_offloads = port->rx_conf[q].offloads;
18037 printf(" Queue[%2d] :", q);
18038 print_rx_offloads(queue_offloads);
18044 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18045 .f = cmd_rx_offload_get_configuration_parsed,
18047 .help_str = "show port <port_id> rx_offload configuration",
18049 (void *)&cmd_rx_offload_get_configuration_show,
18050 (void *)&cmd_rx_offload_get_configuration_port,
18051 (void *)&cmd_rx_offload_get_configuration_port_id,
18052 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18053 (void *)&cmd_rx_offload_get_configuration_configuration,
18058 /* Enable/Disable a per port offloading */
18059 struct cmd_config_per_port_rx_offload_result {
18060 cmdline_fixed_string_t port;
18061 cmdline_fixed_string_t config;
18063 cmdline_fixed_string_t rx_offload;
18064 cmdline_fixed_string_t offload;
18065 cmdline_fixed_string_t on_off;
18068 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18069 TOKEN_STRING_INITIALIZER
18070 (struct cmd_config_per_port_rx_offload_result,
18072 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18073 TOKEN_STRING_INITIALIZER
18074 (struct cmd_config_per_port_rx_offload_result,
18076 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18077 TOKEN_NUM_INITIALIZER
18078 (struct cmd_config_per_port_rx_offload_result,
18080 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18081 TOKEN_STRING_INITIALIZER
18082 (struct cmd_config_per_port_rx_offload_result,
18083 rx_offload, "rx_offload");
18084 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18085 TOKEN_STRING_INITIALIZER
18086 (struct cmd_config_per_port_rx_offload_result,
18087 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18088 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18089 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18090 "scatter#timestamp#security#keep_crc#rss_hash");
18091 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18092 TOKEN_STRING_INITIALIZER
18093 (struct cmd_config_per_port_rx_offload_result,
18097 search_rx_offload(const char *name)
18099 uint64_t single_offload;
18100 const char *single_name;
18104 single_offload = 1;
18105 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18106 single_name = rte_eth_dev_rx_offload_name(single_offload);
18107 if (!strcasecmp(single_name, name)) {
18111 single_offload <<= 1;
18115 return single_offload;
18121 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18122 __attribute__((unused)) struct cmdline *cl,
18123 __attribute__((unused)) void *data)
18125 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18126 portid_t port_id = res->port_id;
18127 struct rte_eth_dev_info dev_info;
18128 struct rte_port *port = &ports[port_id];
18129 uint64_t single_offload;
18130 uint16_t nb_rx_queues;
18134 if (port->port_status != RTE_PORT_STOPPED) {
18135 printf("Error: Can't config offload when Port %d "
18136 "is not stopped\n", port_id);
18140 single_offload = search_rx_offload(res->offload);
18141 if (single_offload == 0) {
18142 printf("Unknown offload name: %s\n", res->offload);
18146 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18150 nb_rx_queues = dev_info.nb_rx_queues;
18151 if (!strcmp(res->on_off, "on")) {
18152 port->dev_conf.rxmode.offloads |= single_offload;
18153 for (q = 0; q < nb_rx_queues; q++)
18154 port->rx_conf[q].offloads |= single_offload;
18156 port->dev_conf.rxmode.offloads &= ~single_offload;
18157 for (q = 0; q < nb_rx_queues; q++)
18158 port->rx_conf[q].offloads &= ~single_offload;
18161 cmd_reconfig_device_queue(port_id, 1, 1);
18164 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18165 .f = cmd_config_per_port_rx_offload_parsed,
18167 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18168 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18169 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18170 "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
18173 (void *)&cmd_config_per_port_rx_offload_result_port,
18174 (void *)&cmd_config_per_port_rx_offload_result_config,
18175 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18176 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18177 (void *)&cmd_config_per_port_rx_offload_result_offload,
18178 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18183 /* Enable/Disable a per queue offloading */
18184 struct cmd_config_per_queue_rx_offload_result {
18185 cmdline_fixed_string_t port;
18187 cmdline_fixed_string_t rxq;
18189 cmdline_fixed_string_t rx_offload;
18190 cmdline_fixed_string_t offload;
18191 cmdline_fixed_string_t on_off;
18194 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18195 TOKEN_STRING_INITIALIZER
18196 (struct cmd_config_per_queue_rx_offload_result,
18198 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18199 TOKEN_NUM_INITIALIZER
18200 (struct cmd_config_per_queue_rx_offload_result,
18202 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18203 TOKEN_STRING_INITIALIZER
18204 (struct cmd_config_per_queue_rx_offload_result,
18206 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18207 TOKEN_NUM_INITIALIZER
18208 (struct cmd_config_per_queue_rx_offload_result,
18210 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18211 TOKEN_STRING_INITIALIZER
18212 (struct cmd_config_per_queue_rx_offload_result,
18213 rx_offload, "rx_offload");
18214 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18215 TOKEN_STRING_INITIALIZER
18216 (struct cmd_config_per_queue_rx_offload_result,
18217 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18218 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18219 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18220 "scatter#timestamp#security#keep_crc");
18221 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18222 TOKEN_STRING_INITIALIZER
18223 (struct cmd_config_per_queue_rx_offload_result,
18227 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18228 __attribute__((unused)) struct cmdline *cl,
18229 __attribute__((unused)) void *data)
18231 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18232 struct rte_eth_dev_info dev_info;
18233 portid_t port_id = res->port_id;
18234 uint16_t queue_id = res->queue_id;
18235 struct rte_port *port = &ports[port_id];
18236 uint64_t single_offload;
18239 if (port->port_status != RTE_PORT_STOPPED) {
18240 printf("Error: Can't config offload when Port %d "
18241 "is not stopped\n", port_id);
18245 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18249 if (queue_id >= dev_info.nb_rx_queues) {
18250 printf("Error: input queue_id should be 0 ... "
18251 "%d\n", dev_info.nb_rx_queues - 1);
18255 single_offload = search_rx_offload(res->offload);
18256 if (single_offload == 0) {
18257 printf("Unknown offload name: %s\n", res->offload);
18261 if (!strcmp(res->on_off, "on"))
18262 port->rx_conf[queue_id].offloads |= single_offload;
18264 port->rx_conf[queue_id].offloads &= ~single_offload;
18266 cmd_reconfig_device_queue(port_id, 1, 1);
18269 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18270 .f = cmd_config_per_queue_rx_offload_parsed,
18272 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18273 "vlan_strip|ipv4_cksum|"
18274 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18275 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18276 "jumbo_frame|scatter|timestamp|security|keep_crc "
18279 (void *)&cmd_config_per_queue_rx_offload_result_port,
18280 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18281 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18282 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18283 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18284 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18285 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18290 /* Get Tx offloads capabilities */
18291 struct cmd_tx_offload_get_capa_result {
18292 cmdline_fixed_string_t show;
18293 cmdline_fixed_string_t port;
18295 cmdline_fixed_string_t tx_offload;
18296 cmdline_fixed_string_t capabilities;
18299 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18300 TOKEN_STRING_INITIALIZER
18301 (struct cmd_tx_offload_get_capa_result,
18303 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18304 TOKEN_STRING_INITIALIZER
18305 (struct cmd_tx_offload_get_capa_result,
18307 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18308 TOKEN_NUM_INITIALIZER
18309 (struct cmd_tx_offload_get_capa_result,
18311 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18312 TOKEN_STRING_INITIALIZER
18313 (struct cmd_tx_offload_get_capa_result,
18314 tx_offload, "tx_offload");
18315 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18316 TOKEN_STRING_INITIALIZER
18317 (struct cmd_tx_offload_get_capa_result,
18318 capabilities, "capabilities");
18321 print_tx_offloads(uint64_t offloads)
18323 uint64_t single_offload;
18331 begin = __builtin_ctzll(offloads);
18332 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18334 single_offload = 1ULL << begin;
18335 for (bit = begin; bit < end; bit++) {
18336 if (offloads & single_offload)
18338 rte_eth_dev_tx_offload_name(single_offload));
18339 single_offload <<= 1;
18344 cmd_tx_offload_get_capa_parsed(
18345 void *parsed_result,
18346 __attribute__((unused)) struct cmdline *cl,
18347 __attribute__((unused)) void *data)
18349 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18350 struct rte_eth_dev_info dev_info;
18351 portid_t port_id = res->port_id;
18352 uint64_t queue_offloads;
18353 uint64_t port_offloads;
18356 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18360 queue_offloads = dev_info.tx_queue_offload_capa;
18361 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18363 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18364 printf(" Per Queue :");
18365 print_tx_offloads(queue_offloads);
18368 printf(" Per Port :");
18369 print_tx_offloads(port_offloads);
18373 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18374 .f = cmd_tx_offload_get_capa_parsed,
18376 .help_str = "show port <port_id> tx_offload capabilities",
18378 (void *)&cmd_tx_offload_get_capa_show,
18379 (void *)&cmd_tx_offload_get_capa_port,
18380 (void *)&cmd_tx_offload_get_capa_port_id,
18381 (void *)&cmd_tx_offload_get_capa_tx_offload,
18382 (void *)&cmd_tx_offload_get_capa_capabilities,
18387 /* Get Tx offloads configuration */
18388 struct cmd_tx_offload_get_configuration_result {
18389 cmdline_fixed_string_t show;
18390 cmdline_fixed_string_t port;
18392 cmdline_fixed_string_t tx_offload;
18393 cmdline_fixed_string_t configuration;
18396 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18397 TOKEN_STRING_INITIALIZER
18398 (struct cmd_tx_offload_get_configuration_result,
18400 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18401 TOKEN_STRING_INITIALIZER
18402 (struct cmd_tx_offload_get_configuration_result,
18404 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18405 TOKEN_NUM_INITIALIZER
18406 (struct cmd_tx_offload_get_configuration_result,
18408 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18409 TOKEN_STRING_INITIALIZER
18410 (struct cmd_tx_offload_get_configuration_result,
18411 tx_offload, "tx_offload");
18412 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18413 TOKEN_STRING_INITIALIZER
18414 (struct cmd_tx_offload_get_configuration_result,
18415 configuration, "configuration");
18418 cmd_tx_offload_get_configuration_parsed(
18419 void *parsed_result,
18420 __attribute__((unused)) struct cmdline *cl,
18421 __attribute__((unused)) void *data)
18423 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18424 struct rte_eth_dev_info dev_info;
18425 portid_t port_id = res->port_id;
18426 struct rte_port *port = &ports[port_id];
18427 uint64_t port_offloads;
18428 uint64_t queue_offloads;
18429 uint16_t nb_tx_queues;
18433 printf("Tx Offloading Configuration of port %d :\n", port_id);
18435 port_offloads = port->dev_conf.txmode.offloads;
18437 print_tx_offloads(port_offloads);
18440 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18444 nb_tx_queues = dev_info.nb_tx_queues;
18445 for (q = 0; q < nb_tx_queues; q++) {
18446 queue_offloads = port->tx_conf[q].offloads;
18447 printf(" Queue[%2d] :", q);
18448 print_tx_offloads(queue_offloads);
18454 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18455 .f = cmd_tx_offload_get_configuration_parsed,
18457 .help_str = "show port <port_id> tx_offload configuration",
18459 (void *)&cmd_tx_offload_get_configuration_show,
18460 (void *)&cmd_tx_offload_get_configuration_port,
18461 (void *)&cmd_tx_offload_get_configuration_port_id,
18462 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18463 (void *)&cmd_tx_offload_get_configuration_configuration,
18468 /* Enable/Disable a per port offloading */
18469 struct cmd_config_per_port_tx_offload_result {
18470 cmdline_fixed_string_t port;
18471 cmdline_fixed_string_t config;
18473 cmdline_fixed_string_t tx_offload;
18474 cmdline_fixed_string_t offload;
18475 cmdline_fixed_string_t on_off;
18478 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18479 TOKEN_STRING_INITIALIZER
18480 (struct cmd_config_per_port_tx_offload_result,
18482 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18483 TOKEN_STRING_INITIALIZER
18484 (struct cmd_config_per_port_tx_offload_result,
18486 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18487 TOKEN_NUM_INITIALIZER
18488 (struct cmd_config_per_port_tx_offload_result,
18490 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18491 TOKEN_STRING_INITIALIZER
18492 (struct cmd_config_per_port_tx_offload_result,
18493 tx_offload, "tx_offload");
18494 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18495 TOKEN_STRING_INITIALIZER
18496 (struct cmd_config_per_port_tx_offload_result,
18497 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18498 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18499 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18500 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18501 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18503 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18504 TOKEN_STRING_INITIALIZER
18505 (struct cmd_config_per_port_tx_offload_result,
18509 search_tx_offload(const char *name)
18511 uint64_t single_offload;
18512 const char *single_name;
18516 single_offload = 1;
18517 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18518 single_name = rte_eth_dev_tx_offload_name(single_offload);
18519 if (single_name == NULL)
18521 if (!strcasecmp(single_name, name)) {
18524 } else if (!strcasecmp(single_name, "UNKNOWN"))
18526 single_offload <<= 1;
18530 return single_offload;
18536 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18537 __attribute__((unused)) struct cmdline *cl,
18538 __attribute__((unused)) void *data)
18540 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18541 portid_t port_id = res->port_id;
18542 struct rte_eth_dev_info dev_info;
18543 struct rte_port *port = &ports[port_id];
18544 uint64_t single_offload;
18545 uint16_t nb_tx_queues;
18549 if (port->port_status != RTE_PORT_STOPPED) {
18550 printf("Error: Can't config offload when Port %d "
18551 "is not stopped\n", port_id);
18555 single_offload = search_tx_offload(res->offload);
18556 if (single_offload == 0) {
18557 printf("Unknown offload name: %s\n", res->offload);
18561 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18565 nb_tx_queues = dev_info.nb_tx_queues;
18566 if (!strcmp(res->on_off, "on")) {
18567 port->dev_conf.txmode.offloads |= single_offload;
18568 for (q = 0; q < nb_tx_queues; q++)
18569 port->tx_conf[q].offloads |= single_offload;
18571 port->dev_conf.txmode.offloads &= ~single_offload;
18572 for (q = 0; q < nb_tx_queues; q++)
18573 port->tx_conf[q].offloads &= ~single_offload;
18576 cmd_reconfig_device_queue(port_id, 1, 1);
18579 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18580 .f = cmd_config_per_port_tx_offload_parsed,
18582 .help_str = "port config <port_id> tx_offload "
18583 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18584 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18585 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18586 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18587 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18588 "match_metadata on|off",
18590 (void *)&cmd_config_per_port_tx_offload_result_port,
18591 (void *)&cmd_config_per_port_tx_offload_result_config,
18592 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18593 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18594 (void *)&cmd_config_per_port_tx_offload_result_offload,
18595 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18600 /* Enable/Disable a per queue offloading */
18601 struct cmd_config_per_queue_tx_offload_result {
18602 cmdline_fixed_string_t port;
18604 cmdline_fixed_string_t txq;
18606 cmdline_fixed_string_t tx_offload;
18607 cmdline_fixed_string_t offload;
18608 cmdline_fixed_string_t on_off;
18611 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18612 TOKEN_STRING_INITIALIZER
18613 (struct cmd_config_per_queue_tx_offload_result,
18615 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18616 TOKEN_NUM_INITIALIZER
18617 (struct cmd_config_per_queue_tx_offload_result,
18619 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18620 TOKEN_STRING_INITIALIZER
18621 (struct cmd_config_per_queue_tx_offload_result,
18623 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18624 TOKEN_NUM_INITIALIZER
18625 (struct cmd_config_per_queue_tx_offload_result,
18627 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18628 TOKEN_STRING_INITIALIZER
18629 (struct cmd_config_per_queue_tx_offload_result,
18630 tx_offload, "tx_offload");
18631 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18632 TOKEN_STRING_INITIALIZER
18633 (struct cmd_config_per_queue_tx_offload_result,
18634 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18635 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18636 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18637 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18638 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18639 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18640 TOKEN_STRING_INITIALIZER
18641 (struct cmd_config_per_queue_tx_offload_result,
18645 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18646 __attribute__((unused)) struct cmdline *cl,
18647 __attribute__((unused)) void *data)
18649 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18650 struct rte_eth_dev_info dev_info;
18651 portid_t port_id = res->port_id;
18652 uint16_t queue_id = res->queue_id;
18653 struct rte_port *port = &ports[port_id];
18654 uint64_t single_offload;
18657 if (port->port_status != RTE_PORT_STOPPED) {
18658 printf("Error: Can't config offload when Port %d "
18659 "is not stopped\n", port_id);
18663 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18667 if (queue_id >= dev_info.nb_tx_queues) {
18668 printf("Error: input queue_id should be 0 ... "
18669 "%d\n", dev_info.nb_tx_queues - 1);
18673 single_offload = search_tx_offload(res->offload);
18674 if (single_offload == 0) {
18675 printf("Unknown offload name: %s\n", res->offload);
18679 if (!strcmp(res->on_off, "on"))
18680 port->tx_conf[queue_id].offloads |= single_offload;
18682 port->tx_conf[queue_id].offloads &= ~single_offload;
18684 cmd_reconfig_device_queue(port_id, 1, 1);
18687 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18688 .f = cmd_config_per_queue_tx_offload_parsed,
18690 .help_str = "port <port_id> txq <queue_id> tx_offload "
18691 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18692 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18693 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18694 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18695 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18698 (void *)&cmd_config_per_queue_tx_offload_result_port,
18699 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18700 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18701 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18702 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18703 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18704 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18709 /* *** configure tx_metadata for specific port *** */
18710 struct cmd_config_tx_metadata_specific_result {
18711 cmdline_fixed_string_t port;
18712 cmdline_fixed_string_t keyword;
18714 cmdline_fixed_string_t item;
18719 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18720 __attribute__((unused)) struct cmdline *cl,
18721 __attribute__((unused)) void *data)
18723 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18725 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18727 ports[res->port_id].tx_metadata = res->value;
18728 /* Add/remove callback to insert valid metadata in every Tx packet. */
18729 if (ports[res->port_id].tx_metadata)
18730 add_tx_md_callback(res->port_id);
18732 remove_tx_md_callback(res->port_id);
18733 rte_flow_dynf_metadata_register();
18736 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18737 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18739 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18740 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18741 keyword, "config");
18742 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18743 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18745 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18746 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18747 item, "tx_metadata");
18748 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18749 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18752 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18753 .f = cmd_config_tx_metadata_specific_parsed,
18755 .help_str = "port config <port_id> tx_metadata <value>",
18757 (void *)&cmd_config_tx_metadata_specific_port,
18758 (void *)&cmd_config_tx_metadata_specific_keyword,
18759 (void *)&cmd_config_tx_metadata_specific_id,
18760 (void *)&cmd_config_tx_metadata_specific_item,
18761 (void *)&cmd_config_tx_metadata_specific_value,
18766 /* *** display tx_metadata per port configuration *** */
18767 struct cmd_show_tx_metadata_result {
18768 cmdline_fixed_string_t cmd_show;
18769 cmdline_fixed_string_t cmd_port;
18770 cmdline_fixed_string_t cmd_keyword;
18775 cmd_show_tx_metadata_parsed(void *parsed_result,
18776 __attribute__((unused)) struct cmdline *cl,
18777 __attribute__((unused)) void *data)
18779 struct cmd_show_tx_metadata_result *res = parsed_result;
18781 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18782 printf("invalid port id %u\n", res->cmd_pid);
18785 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18786 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18787 rte_be_to_cpu_32(ports[res->cmd_pid].tx_metadata));
18791 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18792 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18794 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18795 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18797 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18798 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18800 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18801 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18802 cmd_keyword, "tx_metadata");
18804 cmdline_parse_inst_t cmd_show_tx_metadata = {
18805 .f = cmd_show_tx_metadata_parsed,
18807 .help_str = "show port <port_id> tx_metadata",
18809 (void *)&cmd_show_tx_metadata_show,
18810 (void *)&cmd_show_tx_metadata_port,
18811 (void *)&cmd_show_tx_metadata_pid,
18812 (void *)&cmd_show_tx_metadata_keyword,
18817 /* show port supported ptypes */
18819 /* Common result structure for show port ptypes */
18820 struct cmd_show_port_supported_ptypes_result {
18821 cmdline_fixed_string_t show;
18822 cmdline_fixed_string_t port;
18824 cmdline_fixed_string_t ptypes;
18827 /* Common CLI fields for show port ptypes */
18828 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
18829 TOKEN_STRING_INITIALIZER
18830 (struct cmd_show_port_supported_ptypes_result,
18832 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
18833 TOKEN_STRING_INITIALIZER
18834 (struct cmd_show_port_supported_ptypes_result,
18836 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
18837 TOKEN_NUM_INITIALIZER
18838 (struct cmd_show_port_supported_ptypes_result,
18840 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
18841 TOKEN_STRING_INITIALIZER
18842 (struct cmd_show_port_supported_ptypes_result,
18846 cmd_show_port_supported_ptypes_parsed(
18847 void *parsed_result,
18848 __attribute__((unused)) struct cmdline *cl,
18849 __attribute__((unused)) void *data)
18851 #define RSVD_PTYPE_MASK 0xf0000000
18852 #define MAX_PTYPES_PER_LAYER 16
18853 #define LTYPE_NAMESIZE 32
18854 #define PTYPE_NAMESIZE 256
18855 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
18856 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
18857 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
18858 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
18859 uint16_t port_id = res->port_id;
18862 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
18866 while (ptype_mask != RSVD_PTYPE_MASK) {
18868 switch (ptype_mask) {
18869 case RTE_PTYPE_L2_MASK:
18870 strlcpy(ltype, "L2", sizeof(ltype));
18872 case RTE_PTYPE_L3_MASK:
18873 strlcpy(ltype, "L3", sizeof(ltype));
18875 case RTE_PTYPE_L4_MASK:
18876 strlcpy(ltype, "L4", sizeof(ltype));
18878 case RTE_PTYPE_TUNNEL_MASK:
18879 strlcpy(ltype, "Tunnel", sizeof(ltype));
18881 case RTE_PTYPE_INNER_L2_MASK:
18882 strlcpy(ltype, "Inner L2", sizeof(ltype));
18884 case RTE_PTYPE_INNER_L3_MASK:
18885 strlcpy(ltype, "Inner L3", sizeof(ltype));
18887 case RTE_PTYPE_INNER_L4_MASK:
18888 strlcpy(ltype, "Inner L4", sizeof(ltype));
18894 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
18895 ptype_mask, ptypes,
18896 MAX_PTYPES_PER_LAYER);
18899 printf("Supported %s ptypes:\n", ltype);
18901 printf("%s ptypes unsupported\n", ltype);
18903 for (i = 0; i < ret; ++i) {
18904 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
18905 printf("%s\n", buf);
18912 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
18913 .f = cmd_show_port_supported_ptypes_parsed,
18915 .help_str = "show port <port_id> ptypes",
18917 (void *)&cmd_show_port_supported_ptypes_show,
18918 (void *)&cmd_show_port_supported_ptypes_port,
18919 (void *)&cmd_show_port_supported_ptypes_port_id,
18920 (void *)&cmd_show_port_supported_ptypes_ptypes,
18925 /* *** display rx/tx descriptor status *** */
18926 struct cmd_show_rx_tx_desc_status_result {
18927 cmdline_fixed_string_t cmd_show;
18928 cmdline_fixed_string_t cmd_port;
18929 cmdline_fixed_string_t cmd_keyword;
18930 cmdline_fixed_string_t cmd_desc;
18931 cmdline_fixed_string_t cmd_status;
18938 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
18939 __attribute__((unused)) struct cmdline *cl,
18940 __attribute__((unused)) void *data)
18942 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
18945 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18946 printf("invalid port id %u\n", res->cmd_pid);
18950 if (!strcmp(res->cmd_keyword, "rxq")) {
18951 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
18954 printf("Invalid queueid = %d\n", res->cmd_qid);
18957 if (rc == RTE_ETH_RX_DESC_AVAIL)
18958 printf("Desc status = AVAILABLE\n");
18959 else if (rc == RTE_ETH_RX_DESC_DONE)
18960 printf("Desc status = DONE\n");
18962 printf("Desc status = UNAVAILABLE\n");
18963 } else if (!strcmp(res->cmd_keyword, "txq")) {
18964 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
18967 printf("Invalid queueid = %d\n", res->cmd_qid);
18970 if (rc == RTE_ETH_TX_DESC_FULL)
18971 printf("Desc status = FULL\n");
18972 else if (rc == RTE_ETH_TX_DESC_DONE)
18973 printf("Desc status = DONE\n");
18975 printf("Desc status = UNAVAILABLE\n");
18979 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
18980 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18982 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
18983 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18985 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
18986 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18988 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
18989 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18990 cmd_keyword, "rxq#txq");
18991 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
18992 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18994 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
18995 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
18997 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
18998 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19000 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19001 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19002 cmd_status, "status");
19003 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19004 .f = cmd_show_rx_tx_desc_status_parsed,
19006 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19009 (void *)&cmd_show_rx_tx_desc_status_show,
19010 (void *)&cmd_show_rx_tx_desc_status_port,
19011 (void *)&cmd_show_rx_tx_desc_status_pid,
19012 (void *)&cmd_show_rx_tx_desc_status_keyword,
19013 (void *)&cmd_show_rx_tx_desc_status_qid,
19014 (void *)&cmd_show_rx_tx_desc_status_desc,
19015 (void *)&cmd_show_rx_tx_desc_status_did,
19016 (void *)&cmd_show_rx_tx_desc_status_status,
19021 /* Common result structure for set port ptypes */
19022 struct cmd_set_port_ptypes_result {
19023 cmdline_fixed_string_t set;
19024 cmdline_fixed_string_t port;
19026 cmdline_fixed_string_t ptype_mask;
19030 /* Common CLI fields for set port ptypes */
19031 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19032 TOKEN_STRING_INITIALIZER
19033 (struct cmd_set_port_ptypes_result,
19035 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19036 TOKEN_STRING_INITIALIZER
19037 (struct cmd_set_port_ptypes_result,
19039 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19040 TOKEN_NUM_INITIALIZER
19041 (struct cmd_set_port_ptypes_result,
19043 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19044 TOKEN_STRING_INITIALIZER
19045 (struct cmd_set_port_ptypes_result,
19046 ptype_mask, "ptype_mask");
19047 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19048 TOKEN_NUM_INITIALIZER
19049 (struct cmd_set_port_ptypes_result,
19053 cmd_set_port_ptypes_parsed(
19054 void *parsed_result,
19055 __attribute__((unused)) struct cmdline *cl,
19056 __attribute__((unused)) void *data)
19058 struct cmd_set_port_ptypes_result *res = parsed_result;
19059 #define PTYPE_NAMESIZE 256
19060 char ptype_name[PTYPE_NAMESIZE];
19061 uint16_t port_id = res->port_id;
19062 uint32_t ptype_mask = res->mask;
19065 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19068 printf("Port %d doesn't support any ptypes.\n", port_id);
19072 uint32_t ptypes[ret];
19074 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19076 printf("Unable to set requested ptypes for Port %d\n", port_id);
19080 printf("Successfully set following ptypes for Port %d\n", port_id);
19081 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19082 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19083 printf("%s\n", ptype_name);
19087 cmdline_parse_inst_t cmd_set_port_ptypes = {
19088 .f = cmd_set_port_ptypes_parsed,
19090 .help_str = "set port <port_id> ptype_mask <mask>",
19092 (void *)&cmd_set_port_ptypes_set,
19093 (void *)&cmd_set_port_ptypes_port,
19094 (void *)&cmd_set_port_ptypes_port_id,
19095 (void *)&cmd_set_port_ptypes_mask_str,
19096 (void *)&cmd_set_port_ptypes_mask_u32,
19101 /* ******************************************************************************** */
19103 /* list of instructions */
19104 cmdline_parse_ctx_t main_ctx[] = {
19105 (cmdline_parse_inst_t *)&cmd_help_brief,
19106 (cmdline_parse_inst_t *)&cmd_help_long,
19107 (cmdline_parse_inst_t *)&cmd_quit,
19108 (cmdline_parse_inst_t *)&cmd_load_from_file,
19109 (cmdline_parse_inst_t *)&cmd_showport,
19110 (cmdline_parse_inst_t *)&cmd_showqueue,
19111 (cmdline_parse_inst_t *)&cmd_showportall,
19112 (cmdline_parse_inst_t *)&cmd_showdevice,
19113 (cmdline_parse_inst_t *)&cmd_showcfg,
19114 (cmdline_parse_inst_t *)&cmd_showfwdall,
19115 (cmdline_parse_inst_t *)&cmd_start,
19116 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19117 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19118 (cmdline_parse_inst_t *)&cmd_set_link_up,
19119 (cmdline_parse_inst_t *)&cmd_set_link_down,
19120 (cmdline_parse_inst_t *)&cmd_reset,
19121 (cmdline_parse_inst_t *)&cmd_set_numbers,
19122 (cmdline_parse_inst_t *)&cmd_set_log,
19123 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19124 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19125 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19126 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19127 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19128 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19129 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19130 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19131 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19132 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19133 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19134 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19135 (cmdline_parse_inst_t *)&cmd_set_link_check,
19136 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19137 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19138 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19139 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19140 #ifdef RTE_LIBRTE_PMD_BOND
19141 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19142 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19143 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19144 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19145 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19146 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19147 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19148 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19149 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19150 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19151 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19153 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19154 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19155 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19156 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19157 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19158 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19159 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19160 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19161 (cmdline_parse_inst_t *)&cmd_csum_set,
19162 (cmdline_parse_inst_t *)&cmd_csum_show,
19163 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19164 (cmdline_parse_inst_t *)&cmd_tso_set,
19165 (cmdline_parse_inst_t *)&cmd_tso_show,
19166 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19167 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19168 (cmdline_parse_inst_t *)&cmd_gro_enable,
19169 (cmdline_parse_inst_t *)&cmd_gro_flush,
19170 (cmdline_parse_inst_t *)&cmd_gro_show,
19171 (cmdline_parse_inst_t *)&cmd_gso_enable,
19172 (cmdline_parse_inst_t *)&cmd_gso_size,
19173 (cmdline_parse_inst_t *)&cmd_gso_show,
19174 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19175 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19176 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19177 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19178 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19179 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19180 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19181 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19182 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19183 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19184 (cmdline_parse_inst_t *)&cmd_config_dcb,
19185 (cmdline_parse_inst_t *)&cmd_read_reg,
19186 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19187 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19188 (cmdline_parse_inst_t *)&cmd_write_reg,
19189 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19190 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19191 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19192 (cmdline_parse_inst_t *)&cmd_stop,
19193 (cmdline_parse_inst_t *)&cmd_mac_addr,
19194 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19195 (cmdline_parse_inst_t *)&cmd_set_qmap,
19196 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19197 (cmdline_parse_inst_t *)&cmd_operate_port,
19198 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19199 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19200 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19201 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19202 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19203 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19204 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19205 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19206 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19207 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19208 (cmdline_parse_inst_t *)&cmd_config_mtu,
19209 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19210 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19211 (cmdline_parse_inst_t *)&cmd_config_rss,
19212 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19213 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19214 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19215 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19216 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19217 (cmdline_parse_inst_t *)&cmd_showport_reta,
19218 (cmdline_parse_inst_t *)&cmd_config_burst,
19219 (cmdline_parse_inst_t *)&cmd_config_thresh,
19220 (cmdline_parse_inst_t *)&cmd_config_threshold,
19221 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19222 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19223 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19224 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19225 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19226 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19227 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19228 (cmdline_parse_inst_t *)&cmd_global_config,
19229 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19230 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19231 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19232 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19233 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19234 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19235 (cmdline_parse_inst_t *)&cmd_dump,
19236 (cmdline_parse_inst_t *)&cmd_dump_one,
19237 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
19238 (cmdline_parse_inst_t *)&cmd_syn_filter,
19239 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19240 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19241 (cmdline_parse_inst_t *)&cmd_flex_filter,
19242 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19243 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19244 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19245 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19246 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19247 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19248 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19249 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19250 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19251 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19252 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19253 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19254 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19255 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19256 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19257 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19258 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19259 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19260 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19261 (cmdline_parse_inst_t *)&cmd_flow,
19262 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19263 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19264 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19265 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19266 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19267 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19268 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19269 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19270 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19271 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19272 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19273 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19274 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19275 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19276 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19277 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19278 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19279 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19280 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19281 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19282 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19283 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19284 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19285 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19286 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19287 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19288 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19289 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19290 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19291 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19292 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19293 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19294 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19295 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19296 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19297 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19298 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19299 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19300 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19301 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19302 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19303 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19304 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19305 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19306 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19307 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19308 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19309 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19310 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19311 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
19312 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
19314 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19315 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19316 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19317 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19318 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19319 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19320 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19321 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19322 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19323 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19324 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19325 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19326 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19327 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19328 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19329 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19330 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19331 (cmdline_parse_inst_t *)&cmd_ddp_add,
19332 (cmdline_parse_inst_t *)&cmd_ddp_del,
19333 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19334 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19335 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19336 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19337 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19338 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19339 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19340 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
19341 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19342 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19343 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19344 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19346 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19347 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19348 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19349 (cmdline_parse_inst_t *)&cmd_queue_region,
19350 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19351 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19352 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19353 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19354 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19355 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19356 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19357 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19358 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19359 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19360 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19361 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19362 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19363 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19364 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19365 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19366 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19367 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19368 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19369 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19370 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19371 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19372 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19373 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19374 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19375 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19376 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19377 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19378 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19379 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19380 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19381 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19382 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19383 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19384 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19385 #ifdef RTE_LIBRTE_BPF
19386 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19387 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19389 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19390 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19391 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
19392 (cmdline_parse_inst_t *)&cmd_set_raw,
19393 (cmdline_parse_inst_t *)&cmd_show_set_raw,
19394 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19398 /* read cmdline commands from file */
19400 cmdline_read_from_file(const char *filename)
19402 struct cmdline *cl;
19404 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19406 printf("Failed to create file based cmdline context: %s\n",
19411 cmdline_interact(cl);
19416 printf("Read CLI commands from %s\n", filename);
19419 /* prompt function, called from main on MASTER lcore */
19423 /* initialize non-constant commands */
19424 cmd_set_fwd_mode_init();
19425 cmd_set_fwd_retry_mode_init();
19427 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19428 if (testpmd_cl == NULL)
19430 cmdline_interact(testpmd_cl);
19431 cmdline_stdin_exit(testpmd_cl);
19437 if (testpmd_cl != NULL)
19438 cmdline_quit(testpmd_cl);
19442 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19444 if (id == (portid_t)RTE_PORT_ALL) {
19447 RTE_ETH_FOREACH_DEV(pid) {
19448 /* check if need_reconfig has been set to 1 */
19449 if (ports[pid].need_reconfig == 0)
19450 ports[pid].need_reconfig = dev;
19451 /* check if need_reconfig_queues has been set to 1 */
19452 if (ports[pid].need_reconfig_queues == 0)
19453 ports[pid].need_reconfig_queues = queue;
19455 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19456 /* check if need_reconfig has been set to 1 */
19457 if (ports[id].need_reconfig == 0)
19458 ports[id].need_reconfig = dev;
19459 /* check if need_reconfig_queues has been set to 1 */
19460 if (ports[id].need_reconfig_queues == 0)
19461 ports[id].need_reconfig_queues = queue;