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 max-lro-pkt-size (value)\n"
784 " Set the max LRO aggregated packet size.\n\n"
786 "port config all drop-en (on|off)\n"
787 " Enable or disable packet drop on all RX queues of all ports when no "
788 "receive buffers available.\n\n"
790 "port config all rss (all|default|ip|tcp|udp|sctp|"
791 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n"
792 " Set the RSS mode.\n\n"
794 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
795 " Set the RSS redirection table.\n\n"
797 "port config (port_id) dcb vt (on|off) (traffic_class)"
799 " Set the DCB mode.\n\n"
801 "port config all burst (value)\n"
802 " Set the number of packets per burst.\n\n"
804 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
806 " Set the ring prefetch/host/writeback threshold"
807 " for tx/rx queue.\n\n"
809 "port config all (txfreet|txrst|rxfreet) (value)\n"
810 " Set free threshold for rx/tx, or set"
811 " tx rs bit threshold.\n\n"
812 "port config mtu X value\n"
813 " Set the MTU of port X to a given value\n\n"
815 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
816 " Set a rx/tx queue's ring size configuration, the new"
817 " value will take effect after command that (re-)start the port"
818 " or command that setup the specific queue\n\n"
820 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
821 " Start/stop a rx/tx queue of port X. Only take effect"
822 " when port X is started\n\n"
824 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
825 " Switch on/off a deferred start of port X rx/tx queue. Only"
826 " take effect when port X is stopped.\n\n"
828 "port (port_id) (rxq|txq) (queue_id) setup\n"
829 " Setup a rx/tx queue of port X.\n\n"
831 "port config (port_id|all) l2-tunnel E-tag ether-type"
833 " Set the value of E-tag ether-type.\n\n"
835 "port config (port_id|all) l2-tunnel E-tag"
836 " (enable|disable)\n"
837 " Enable/disable the E-tag support.\n\n"
839 "port config (port_id) pctype mapping reset\n"
840 " Reset flow type to pctype mapping on a port\n\n"
842 "port config (port_id) pctype mapping update"
843 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
844 " Update a flow type to pctype mapping item on a port\n\n"
846 "port config (port_id) pctype (pctype_id) hash_inset|"
847 "fdir_inset|fdir_flx_inset get|set|clear field\n"
849 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
851 "port config (port_id) pctype (pctype_id) hash_inset|"
852 "fdir_inset|fdir_flx_inset clear all"
853 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
855 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
856 " Add/remove UDP tunnel port for tunneling offload\n\n"
858 "port config <port_id> rx_offload vlan_strip|"
859 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
860 "outer_ipv4_cksum|macsec_strip|header_split|"
861 "vlan_filter|vlan_extend|jumbo_frame|"
862 "scatter|timestamp|security|keep_crc on|off\n"
863 " Enable or disable a per port Rx offloading"
864 " on all Rx queues of a port\n\n"
866 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
867 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
868 "outer_ipv4_cksum|macsec_strip|header_split|"
869 "vlan_filter|vlan_extend|jumbo_frame|"
870 "scatter|timestamp|security|keep_crc on|off\n"
871 " Enable or disable a per queue Rx offloading"
872 " only on a specific Rx queue\n\n"
874 "port config (port_id) tx_offload vlan_insert|"
875 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
876 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
877 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
878 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
879 "security|match_metadata on|off\n"
880 " Enable or disable a per port Tx offloading"
881 " on all Tx queues of a port\n\n"
883 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
884 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
885 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
886 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
887 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
889 " Enable or disable a per queue Tx offloading"
890 " only on a specific Tx queue\n\n"
892 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
893 " Load an eBPF program as a callback"
894 " for particular RX/TX queue\n\n"
896 "bpf-unload rx|tx (port) (queue)\n"
897 " Unload previously loaded eBPF program"
898 " for particular RX/TX queue\n\n"
900 "port config (port_id) tx_metadata (value)\n"
901 " Set Tx metadata value per port. Testpmd will add this value"
902 " to any Tx packet sent from this port\n\n"
906 if (show_all || !strcmp(res->section, "registers")) {
914 "read reg (port_id) (address)\n"
915 " Display value of a port register.\n\n"
917 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
918 " Display a port register bit field.\n\n"
920 "read regbit (port_id) (address) (bit_x)\n"
921 " Display a single port register bit.\n\n"
923 "write reg (port_id) (address) (value)\n"
924 " Set value of a port register.\n\n"
926 "write regfield (port_id) (address) (bit_x) (bit_y)"
928 " Set bit field of a port register.\n\n"
930 "write regbit (port_id) (address) (bit_x) (value)\n"
931 " Set single bit value of a port register.\n\n"
934 if (show_all || !strcmp(res->section, "filters")) {
942 "ethertype_filter (port_id) (add|del)"
943 " (mac_addr|mac_ignr) (mac_address) ethertype"
944 " (ether_type) (drop|fwd) queue (queue_id)\n"
945 " Add/Del an ethertype filter.\n\n"
947 "2tuple_filter (port_id) (add|del)"
948 " dst_port (dst_port_value) protocol (protocol_value)"
949 " mask (mask_value) tcp_flags (tcp_flags_value)"
950 " priority (prio_value) queue (queue_id)\n"
951 " Add/Del a 2tuple filter.\n\n"
953 "5tuple_filter (port_id) (add|del)"
954 " dst_ip (dst_address) src_ip (src_address)"
955 " dst_port (dst_port_value) src_port (src_port_value)"
956 " protocol (protocol_value)"
957 " mask (mask_value) tcp_flags (tcp_flags_value)"
958 " priority (prio_value) queue (queue_id)\n"
959 " Add/Del a 5tuple filter.\n\n"
961 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
962 " Add/Del syn filter.\n\n"
964 "flex_filter (port_id) (add|del) len (len_value)"
965 " bytes (bytes_value) mask (mask_value)"
966 " priority (prio_value) queue (queue_id)\n"
967 " Add/Del a flex filter.\n\n"
969 "flow_director_filter (port_id) mode IP (add|del|update)"
970 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
971 " src (src_ip_address) dst (dst_ip_address)"
972 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
973 " vlan (vlan_value) flexbytes (flexbytes_value)"
974 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
975 " fd_id (fd_id_value)\n"
976 " Add/Del an IP type flow director filter.\n\n"
978 "flow_director_filter (port_id) mode IP (add|del|update)"
979 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
980 " src (src_ip_address) (src_port)"
981 " dst (dst_ip_address) (dst_port)"
982 " tos (tos_value) ttl (ttl_value)"
983 " vlan (vlan_value) flexbytes (flexbytes_value)"
984 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
985 " fd_id (fd_id_value)\n"
986 " Add/Del an UDP/TCP type flow director filter.\n\n"
988 "flow_director_filter (port_id) mode IP (add|del|update)"
989 " flow (ipv4-sctp|ipv6-sctp)"
990 " src (src_ip_address) (src_port)"
991 " dst (dst_ip_address) (dst_port)"
992 " tag (verification_tag) "
993 " tos (tos_value) ttl (ttl_value)"
995 " flexbytes (flexbytes_value) (drop|fwd)"
996 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
997 " Add/Del a SCTP type flow director filter.\n\n"
999 "flow_director_filter (port_id) mode IP (add|del|update)"
1000 " flow l2_payload ether (ethertype)"
1001 " flexbytes (flexbytes_value) (drop|fwd)"
1002 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1003 " Add/Del a l2 payload type flow director filter.\n\n"
1005 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1006 " mac (mac_address) vlan (vlan_value)"
1007 " flexbytes (flexbytes_value) (drop|fwd)"
1008 " queue (queue_id) fd_id (fd_id_value)\n"
1009 " Add/Del a MAC-VLAN flow director filter.\n\n"
1011 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1012 " mac (mac_address) vlan (vlan_value)"
1013 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1014 " flexbytes (flexbytes_value) (drop|fwd)"
1015 " queue (queue_id) fd_id (fd_id_value)\n"
1016 " Add/Del a Tunnel flow director filter.\n\n"
1018 "flow_director_filter (port_id) mode raw (add|del|update)"
1019 " flow (flow_id) (drop|fwd) queue (queue_id)"
1020 " fd_id (fd_id_value) packet (packet file name)\n"
1021 " Add/Del a raw type flow director filter.\n\n"
1023 "flush_flow_director (port_id)\n"
1024 " Flush all flow director entries of a device.\n\n"
1026 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1027 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1028 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1029 " Set flow director IP mask.\n\n"
1031 "flow_director_mask (port_id) mode MAC-VLAN"
1032 " vlan (vlan_value)\n"
1033 " Set flow director MAC-VLAN mask.\n\n"
1035 "flow_director_mask (port_id) mode Tunnel"
1036 " vlan (vlan_value) mac (mac_value)"
1037 " tunnel-type (tunnel_type_value)"
1038 " tunnel-id (tunnel_id_value)\n"
1039 " Set flow director Tunnel mask.\n\n"
1041 "flow_director_flex_mask (port_id)"
1042 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1043 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1045 " Configure mask of flex payload.\n\n"
1047 "flow_director_flex_payload (port_id)"
1048 " (raw|l2|l3|l4) (config)\n"
1049 " Configure flex payload selection.\n\n"
1051 "get_sym_hash_ena_per_port (port_id)\n"
1052 " get symmetric hash enable configuration per port.\n\n"
1054 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1055 " set symmetric hash enable configuration per port"
1056 " to enable or disable.\n\n"
1058 "get_hash_global_config (port_id)\n"
1059 " Get the global configurations of hash filters.\n\n"
1061 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1062 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1063 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1064 " (enable|disable)\n"
1065 " Set the global configurations of hash filters.\n\n"
1067 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1068 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1069 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1070 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1071 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1072 "ipv6-next-header|udp-src-port|udp-dst-port|"
1073 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1074 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1075 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1076 "fld-8th|none) (select|add)\n"
1077 " Set the input set for hash.\n\n"
1079 "set_fdir_input_set (port_id) "
1080 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1081 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1082 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1083 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1084 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1085 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1086 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1088 " Set the input set for FDir.\n\n"
1090 "flow validate {port_id}"
1091 " [group {group_id}] [priority {level}]"
1092 " [ingress] [egress]"
1093 " pattern {item} [/ {item} [...]] / end"
1094 " actions {action} [/ {action} [...]] / end\n"
1095 " Check whether a flow rule can be created.\n\n"
1097 "flow create {port_id}"
1098 " [group {group_id}] [priority {level}]"
1099 " [ingress] [egress]"
1100 " pattern {item} [/ {item} [...]] / end"
1101 " actions {action} [/ {action} [...]] / end\n"
1102 " Create a flow rule.\n\n"
1104 "flow destroy {port_id} rule {rule_id} [...]\n"
1105 " Destroy specific flow rules.\n\n"
1107 "flow flush {port_id}\n"
1108 " Destroy all flow rules.\n\n"
1110 "flow query {port_id} {rule_id} {action}\n"
1111 " Query an existing flow rule.\n\n"
1113 "flow list {port_id} [group {group_id}] [...]\n"
1114 " List existing flow rules sorted by priority,"
1115 " filtered by group identifiers.\n\n"
1117 "flow isolate {port_id} {boolean}\n"
1118 " Restrict ingress traffic to the defined"
1121 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1122 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1123 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1124 " Configure the VXLAN encapsulation for flows.\n\n"
1126 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1127 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1128 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1129 " eth-dst (eth-dst)\n"
1130 " Configure the VXLAN encapsulation for flows.\n\n"
1132 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1133 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1134 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1135 " eth-dst (eth-dst)\n"
1136 " Configure the VXLAN encapsulation for flows.\n\n"
1138 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1139 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1141 " Configure the NVGRE encapsulation for flows.\n\n"
1143 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1144 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1145 " eth-src (eth-src) eth-dst (eth-dst)\n"
1146 " Configure the NVGRE encapsulation for flows.\n\n"
1148 "set raw_encap {flow items}\n"
1149 " Configure the encapsulation with raw data.\n\n"
1151 "set raw_decap {flow items}\n"
1152 " Configure the decapsulation with raw data.\n\n"
1157 if (show_all || !strcmp(res->section, "traffic_management")) {
1161 "Traffic Management:\n"
1163 "show port tm cap (port_id)\n"
1164 " Display the port TM capability.\n\n"
1166 "show port tm level cap (port_id) (level_id)\n"
1167 " Display the port TM hierarchical level capability.\n\n"
1169 "show port tm node cap (port_id) (node_id)\n"
1170 " Display the port TM node capability.\n\n"
1172 "show port tm node type (port_id) (node_id)\n"
1173 " Display the port TM node type.\n\n"
1175 "show port tm node stats (port_id) (node_id) (clear)\n"
1176 " Display the port TM node stats.\n\n"
1178 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
1179 "set port tm hierarchy default (port_id)\n"
1180 " Set default traffic Management hierarchy on a port\n\n"
1183 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1184 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1185 " (packet_length_adjust)\n"
1186 " Add port tm node private shaper profile.\n\n"
1188 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1189 " Delete port tm node private shaper profile.\n\n"
1191 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1192 " (shaper_profile_id)\n"
1193 " Add/update port tm node shared shaper.\n\n"
1195 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1196 " Delete port tm node shared shaper.\n\n"
1198 "set port tm node shaper profile (port_id) (node_id)"
1199 " (shaper_profile_id)\n"
1200 " Set port tm node shaper profile.\n\n"
1202 "add port tm node wred profile (port_id) (wred_profile_id)"
1203 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1204 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1205 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1206 " Add port tm node wred profile.\n\n"
1208 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1209 " Delete port tm node wred profile.\n\n"
1211 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1212 " (priority) (weight) (level_id) (shaper_profile_id)"
1213 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1214 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1215 " Add port tm nonleaf node.\n\n"
1217 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1218 " (priority) (weight) (level_id) (shaper_profile_id)"
1219 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1220 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1221 " Add port tm leaf node.\n\n"
1223 "del port tm node (port_id) (node_id)\n"
1224 " Delete port tm node.\n\n"
1226 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1227 " (priority) (weight)\n"
1228 " Set port tm node parent.\n\n"
1230 "suspend port tm node (port_id) (node_id)"
1231 " Suspend tm node.\n\n"
1233 "resume port tm node (port_id) (node_id)"
1234 " Resume tm node.\n\n"
1236 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1237 " Commit tm hierarchy.\n\n"
1239 "set port tm mark ip_ecn (port) (green) (yellow)"
1241 " Enables/Disables the traffic management marking"
1242 " for IP ECN (Explicit Congestion Notification)"
1243 " packets on a given port\n\n"
1245 "set port tm mark ip_dscp (port) (green) (yellow)"
1247 " Enables/Disables the traffic management marking"
1248 " on the port for IP dscp packets\n\n"
1250 "set port tm mark vlan_dei (port) (green) (yellow)"
1252 " Enables/Disables the traffic management marking"
1253 " on the port for VLAN packets with DEI enabled\n\n"
1257 if (show_all || !strcmp(res->section, "devices")) {
1261 "Device Operations:\n"
1263 "device detach (identifier)\n"
1264 " Detach device by identifier.\n\n"
1270 cmdline_parse_token_string_t cmd_help_long_help =
1271 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1273 cmdline_parse_token_string_t cmd_help_long_section =
1274 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1275 "all#control#display#config#"
1276 "ports#registers#filters#traffic_management#devices");
1278 cmdline_parse_inst_t cmd_help_long = {
1279 .f = cmd_help_long_parsed,
1281 .help_str = "help all|control|display|config|ports|register|"
1282 "filters|traffic_management|devices: "
1285 (void *)&cmd_help_long_help,
1286 (void *)&cmd_help_long_section,
1292 /* *** start/stop/close all ports *** */
1293 struct cmd_operate_port_result {
1294 cmdline_fixed_string_t keyword;
1295 cmdline_fixed_string_t name;
1296 cmdline_fixed_string_t value;
1299 static void cmd_operate_port_parsed(void *parsed_result,
1300 __attribute__((unused)) struct cmdline *cl,
1301 __attribute__((unused)) void *data)
1303 struct cmd_operate_port_result *res = parsed_result;
1305 if (!strcmp(res->name, "start"))
1306 start_port(RTE_PORT_ALL);
1307 else if (!strcmp(res->name, "stop"))
1308 stop_port(RTE_PORT_ALL);
1309 else if (!strcmp(res->name, "close"))
1310 close_port(RTE_PORT_ALL);
1311 else if (!strcmp(res->name, "reset"))
1312 reset_port(RTE_PORT_ALL);
1314 printf("Unknown parameter\n");
1317 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1318 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1320 cmdline_parse_token_string_t cmd_operate_port_all_port =
1321 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1322 "start#stop#close#reset");
1323 cmdline_parse_token_string_t cmd_operate_port_all_all =
1324 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1326 cmdline_parse_inst_t cmd_operate_port = {
1327 .f = cmd_operate_port_parsed,
1329 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1331 (void *)&cmd_operate_port_all_cmd,
1332 (void *)&cmd_operate_port_all_port,
1333 (void *)&cmd_operate_port_all_all,
1338 /* *** start/stop/close specific port *** */
1339 struct cmd_operate_specific_port_result {
1340 cmdline_fixed_string_t keyword;
1341 cmdline_fixed_string_t name;
1345 static void cmd_operate_specific_port_parsed(void *parsed_result,
1346 __attribute__((unused)) struct cmdline *cl,
1347 __attribute__((unused)) void *data)
1349 struct cmd_operate_specific_port_result *res = parsed_result;
1351 if (!strcmp(res->name, "start"))
1352 start_port(res->value);
1353 else if (!strcmp(res->name, "stop"))
1354 stop_port(res->value);
1355 else if (!strcmp(res->name, "close"))
1356 close_port(res->value);
1357 else if (!strcmp(res->name, "reset"))
1358 reset_port(res->value);
1360 printf("Unknown parameter\n");
1363 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1364 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1366 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1367 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1368 name, "start#stop#close#reset");
1369 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1370 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1373 cmdline_parse_inst_t cmd_operate_specific_port = {
1374 .f = cmd_operate_specific_port_parsed,
1376 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1378 (void *)&cmd_operate_specific_port_cmd,
1379 (void *)&cmd_operate_specific_port_port,
1380 (void *)&cmd_operate_specific_port_id,
1385 /* *** enable port setup (after attach) via iterator or event *** */
1386 struct cmd_set_port_setup_on_result {
1387 cmdline_fixed_string_t set;
1388 cmdline_fixed_string_t port;
1389 cmdline_fixed_string_t setup;
1390 cmdline_fixed_string_t on;
1391 cmdline_fixed_string_t mode;
1394 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1395 __attribute__((unused)) struct cmdline *cl,
1396 __attribute__((unused)) void *data)
1398 struct cmd_set_port_setup_on_result *res = parsed_result;
1400 if (strcmp(res->mode, "event") == 0)
1401 setup_on_probe_event = true;
1402 else if (strcmp(res->mode, "iterator") == 0)
1403 setup_on_probe_event = false;
1405 printf("Unknown mode\n");
1408 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1409 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1411 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1412 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1414 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1415 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1417 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1418 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1420 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1421 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1422 mode, "iterator#event");
1424 cmdline_parse_inst_t cmd_set_port_setup_on = {
1425 .f = cmd_set_port_setup_on_parsed,
1427 .help_str = "set port setup on iterator|event",
1429 (void *)&cmd_set_port_setup_on_set,
1430 (void *)&cmd_set_port_setup_on_port,
1431 (void *)&cmd_set_port_setup_on_setup,
1432 (void *)&cmd_set_port_setup_on_on,
1433 (void *)&cmd_set_port_setup_on_mode,
1438 /* *** attach a specified port *** */
1439 struct cmd_operate_attach_port_result {
1440 cmdline_fixed_string_t port;
1441 cmdline_fixed_string_t keyword;
1442 cmdline_fixed_string_t identifier;
1445 static void cmd_operate_attach_port_parsed(void *parsed_result,
1446 __attribute__((unused)) struct cmdline *cl,
1447 __attribute__((unused)) void *data)
1449 struct cmd_operate_attach_port_result *res = parsed_result;
1451 if (!strcmp(res->keyword, "attach"))
1452 attach_port(res->identifier);
1454 printf("Unknown parameter\n");
1457 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1458 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1460 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1461 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1463 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1464 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1467 cmdline_parse_inst_t cmd_operate_attach_port = {
1468 .f = cmd_operate_attach_port_parsed,
1470 .help_str = "port attach <identifier>: "
1471 "(identifier: pci address or virtual dev name)",
1473 (void *)&cmd_operate_attach_port_port,
1474 (void *)&cmd_operate_attach_port_keyword,
1475 (void *)&cmd_operate_attach_port_identifier,
1480 /* *** detach a specified port *** */
1481 struct cmd_operate_detach_port_result {
1482 cmdline_fixed_string_t port;
1483 cmdline_fixed_string_t keyword;
1487 static void cmd_operate_detach_port_parsed(void *parsed_result,
1488 __attribute__((unused)) struct cmdline *cl,
1489 __attribute__((unused)) void *data)
1491 struct cmd_operate_detach_port_result *res = parsed_result;
1493 if (!strcmp(res->keyword, "detach"))
1494 detach_port_device(res->port_id);
1496 printf("Unknown parameter\n");
1499 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1500 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1502 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1503 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1505 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1506 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1509 cmdline_parse_inst_t cmd_operate_detach_port = {
1510 .f = cmd_operate_detach_port_parsed,
1512 .help_str = "port detach <port_id>",
1514 (void *)&cmd_operate_detach_port_port,
1515 (void *)&cmd_operate_detach_port_keyword,
1516 (void *)&cmd_operate_detach_port_port_id,
1521 /* *** detach device by identifier *** */
1522 struct cmd_operate_detach_device_result {
1523 cmdline_fixed_string_t device;
1524 cmdline_fixed_string_t keyword;
1525 cmdline_fixed_string_t identifier;
1528 static void cmd_operate_detach_device_parsed(void *parsed_result,
1529 __attribute__((unused)) struct cmdline *cl,
1530 __attribute__((unused)) void *data)
1532 struct cmd_operate_detach_device_result *res = parsed_result;
1534 if (!strcmp(res->keyword, "detach"))
1535 detach_device(res->identifier);
1537 printf("Unknown parameter\n");
1540 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1541 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1543 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1544 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1546 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1547 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1550 cmdline_parse_inst_t cmd_operate_detach_device = {
1551 .f = cmd_operate_detach_device_parsed,
1553 .help_str = "device detach <identifier>:"
1554 "(identifier: pci address or virtual dev name)",
1556 (void *)&cmd_operate_detach_device_device,
1557 (void *)&cmd_operate_detach_device_keyword,
1558 (void *)&cmd_operate_detach_device_identifier,
1562 /* *** configure speed for all ports *** */
1563 struct cmd_config_speed_all {
1564 cmdline_fixed_string_t port;
1565 cmdline_fixed_string_t keyword;
1566 cmdline_fixed_string_t all;
1567 cmdline_fixed_string_t item1;
1568 cmdline_fixed_string_t item2;
1569 cmdline_fixed_string_t value1;
1570 cmdline_fixed_string_t value2;
1574 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1579 if (!strcmp(duplexstr, "half")) {
1580 duplex = ETH_LINK_HALF_DUPLEX;
1581 } else if (!strcmp(duplexstr, "full")) {
1582 duplex = ETH_LINK_FULL_DUPLEX;
1583 } else if (!strcmp(duplexstr, "auto")) {
1584 duplex = ETH_LINK_FULL_DUPLEX;
1586 printf("Unknown duplex parameter\n");
1590 if (!strcmp(speedstr, "10")) {
1591 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1592 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1593 } else if (!strcmp(speedstr, "100")) {
1594 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1595 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1597 if (duplex != ETH_LINK_FULL_DUPLEX) {
1598 printf("Invalid speed/duplex parameters\n");
1601 if (!strcmp(speedstr, "1000")) {
1602 *speed = ETH_LINK_SPEED_1G;
1603 } else if (!strcmp(speedstr, "10000")) {
1604 *speed = ETH_LINK_SPEED_10G;
1605 } else if (!strcmp(speedstr, "25000")) {
1606 *speed = ETH_LINK_SPEED_25G;
1607 } else if (!strcmp(speedstr, "40000")) {
1608 *speed = ETH_LINK_SPEED_40G;
1609 } else if (!strcmp(speedstr, "50000")) {
1610 *speed = ETH_LINK_SPEED_50G;
1611 } else if (!strcmp(speedstr, "100000")) {
1612 *speed = ETH_LINK_SPEED_100G;
1613 } else if (!strcmp(speedstr, "auto")) {
1614 *speed = ETH_LINK_SPEED_AUTONEG;
1616 printf("Unknown speed parameter\n");
1625 cmd_config_speed_all_parsed(void *parsed_result,
1626 __attribute__((unused)) struct cmdline *cl,
1627 __attribute__((unused)) void *data)
1629 struct cmd_config_speed_all *res = parsed_result;
1630 uint32_t link_speed;
1633 if (!all_ports_stopped()) {
1634 printf("Please stop all ports first\n");
1638 if (parse_and_check_speed_duplex(res->value1, res->value2,
1642 RTE_ETH_FOREACH_DEV(pid) {
1643 ports[pid].dev_conf.link_speeds = link_speed;
1646 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1649 cmdline_parse_token_string_t cmd_config_speed_all_port =
1650 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1651 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1652 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1654 cmdline_parse_token_string_t cmd_config_speed_all_all =
1655 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1656 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1657 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1658 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1659 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1660 "10#100#1000#10000#25000#40000#50000#100000#auto");
1661 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1662 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1663 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1664 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1667 cmdline_parse_inst_t cmd_config_speed_all = {
1668 .f = cmd_config_speed_all_parsed,
1670 .help_str = "port config all speed "
1671 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1674 (void *)&cmd_config_speed_all_port,
1675 (void *)&cmd_config_speed_all_keyword,
1676 (void *)&cmd_config_speed_all_all,
1677 (void *)&cmd_config_speed_all_item1,
1678 (void *)&cmd_config_speed_all_value1,
1679 (void *)&cmd_config_speed_all_item2,
1680 (void *)&cmd_config_speed_all_value2,
1685 /* *** configure speed for specific port *** */
1686 struct cmd_config_speed_specific {
1687 cmdline_fixed_string_t port;
1688 cmdline_fixed_string_t keyword;
1690 cmdline_fixed_string_t item1;
1691 cmdline_fixed_string_t item2;
1692 cmdline_fixed_string_t value1;
1693 cmdline_fixed_string_t value2;
1697 cmd_config_speed_specific_parsed(void *parsed_result,
1698 __attribute__((unused)) struct cmdline *cl,
1699 __attribute__((unused)) void *data)
1701 struct cmd_config_speed_specific *res = parsed_result;
1702 uint32_t link_speed;
1704 if (!all_ports_stopped()) {
1705 printf("Please stop all ports first\n");
1709 if (port_id_is_invalid(res->id, ENABLED_WARN))
1712 if (parse_and_check_speed_duplex(res->value1, res->value2,
1716 ports[res->id].dev_conf.link_speeds = link_speed;
1718 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1722 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1723 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1725 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1726 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1728 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1729 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1730 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1731 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1733 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1734 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1735 "10#100#1000#10000#25000#40000#50000#100000#auto");
1736 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1737 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1739 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1740 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1743 cmdline_parse_inst_t cmd_config_speed_specific = {
1744 .f = cmd_config_speed_specific_parsed,
1746 .help_str = "port config <port_id> speed "
1747 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1750 (void *)&cmd_config_speed_specific_port,
1751 (void *)&cmd_config_speed_specific_keyword,
1752 (void *)&cmd_config_speed_specific_id,
1753 (void *)&cmd_config_speed_specific_item1,
1754 (void *)&cmd_config_speed_specific_value1,
1755 (void *)&cmd_config_speed_specific_item2,
1756 (void *)&cmd_config_speed_specific_value2,
1761 /* *** configure loopback for all ports *** */
1762 struct cmd_config_loopback_all {
1763 cmdline_fixed_string_t port;
1764 cmdline_fixed_string_t keyword;
1765 cmdline_fixed_string_t all;
1766 cmdline_fixed_string_t item;
1771 cmd_config_loopback_all_parsed(void *parsed_result,
1772 __attribute__((unused)) struct cmdline *cl,
1773 __attribute__((unused)) void *data)
1775 struct cmd_config_loopback_all *res = parsed_result;
1778 if (!all_ports_stopped()) {
1779 printf("Please stop all ports first\n");
1783 RTE_ETH_FOREACH_DEV(pid) {
1784 ports[pid].dev_conf.lpbk_mode = res->mode;
1787 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1790 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1791 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1792 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1793 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1795 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1796 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1797 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1798 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1800 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1801 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1803 cmdline_parse_inst_t cmd_config_loopback_all = {
1804 .f = cmd_config_loopback_all_parsed,
1806 .help_str = "port config all loopback <mode>",
1808 (void *)&cmd_config_loopback_all_port,
1809 (void *)&cmd_config_loopback_all_keyword,
1810 (void *)&cmd_config_loopback_all_all,
1811 (void *)&cmd_config_loopback_all_item,
1812 (void *)&cmd_config_loopback_all_mode,
1817 /* *** configure loopback for specific port *** */
1818 struct cmd_config_loopback_specific {
1819 cmdline_fixed_string_t port;
1820 cmdline_fixed_string_t keyword;
1822 cmdline_fixed_string_t item;
1827 cmd_config_loopback_specific_parsed(void *parsed_result,
1828 __attribute__((unused)) struct cmdline *cl,
1829 __attribute__((unused)) void *data)
1831 struct cmd_config_loopback_specific *res = parsed_result;
1833 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1836 if (!port_is_stopped(res->port_id)) {
1837 printf("Please stop port %u first\n", res->port_id);
1841 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1843 cmd_reconfig_device_queue(res->port_id, 1, 1);
1847 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1848 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1850 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1851 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1853 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1854 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1856 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1857 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1859 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1860 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1863 cmdline_parse_inst_t cmd_config_loopback_specific = {
1864 .f = cmd_config_loopback_specific_parsed,
1866 .help_str = "port config <port_id> loopback <mode>",
1868 (void *)&cmd_config_loopback_specific_port,
1869 (void *)&cmd_config_loopback_specific_keyword,
1870 (void *)&cmd_config_loopback_specific_id,
1871 (void *)&cmd_config_loopback_specific_item,
1872 (void *)&cmd_config_loopback_specific_mode,
1877 /* *** configure txq/rxq, txd/rxd *** */
1878 struct cmd_config_rx_tx {
1879 cmdline_fixed_string_t port;
1880 cmdline_fixed_string_t keyword;
1881 cmdline_fixed_string_t all;
1882 cmdline_fixed_string_t name;
1887 cmd_config_rx_tx_parsed(void *parsed_result,
1888 __attribute__((unused)) struct cmdline *cl,
1889 __attribute__((unused)) void *data)
1891 struct cmd_config_rx_tx *res = parsed_result;
1893 if (!all_ports_stopped()) {
1894 printf("Please stop all ports first\n");
1897 if (!strcmp(res->name, "rxq")) {
1898 if (!res->value && !nb_txq) {
1899 printf("Warning: Either rx or tx queues should be non zero\n");
1902 if (check_nb_rxq(res->value) != 0)
1904 nb_rxq = res->value;
1906 else if (!strcmp(res->name, "txq")) {
1907 if (!res->value && !nb_rxq) {
1908 printf("Warning: Either rx or tx queues should be non zero\n");
1911 if (check_nb_txq(res->value) != 0)
1913 nb_txq = res->value;
1915 else if (!strcmp(res->name, "rxd")) {
1916 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1917 printf("rxd %d invalid - must be > 0 && <= %d\n",
1918 res->value, RTE_TEST_RX_DESC_MAX);
1921 nb_rxd = res->value;
1922 } else if (!strcmp(res->name, "txd")) {
1923 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1924 printf("txd %d invalid - must be > 0 && <= %d\n",
1925 res->value, RTE_TEST_TX_DESC_MAX);
1928 nb_txd = res->value;
1930 printf("Unknown parameter\n");
1938 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1941 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1942 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1943 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1944 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1945 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1946 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1947 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1948 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1950 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1951 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1953 cmdline_parse_inst_t cmd_config_rx_tx = {
1954 .f = cmd_config_rx_tx_parsed,
1956 .help_str = "port config all rxq|txq|rxd|txd <value>",
1958 (void *)&cmd_config_rx_tx_port,
1959 (void *)&cmd_config_rx_tx_keyword,
1960 (void *)&cmd_config_rx_tx_all,
1961 (void *)&cmd_config_rx_tx_name,
1962 (void *)&cmd_config_rx_tx_value,
1967 /* *** config max packet length *** */
1968 struct cmd_config_max_pkt_len_result {
1969 cmdline_fixed_string_t port;
1970 cmdline_fixed_string_t keyword;
1971 cmdline_fixed_string_t all;
1972 cmdline_fixed_string_t name;
1977 cmd_config_max_pkt_len_parsed(void *parsed_result,
1978 __attribute__((unused)) struct cmdline *cl,
1979 __attribute__((unused)) void *data)
1981 struct cmd_config_max_pkt_len_result *res = parsed_result;
1984 if (!all_ports_stopped()) {
1985 printf("Please stop all ports first\n");
1989 RTE_ETH_FOREACH_DEV(pid) {
1990 struct rte_port *port = &ports[pid];
1991 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1993 if (!strcmp(res->name, "max-pkt-len")) {
1994 if (res->value < RTE_ETHER_MIN_LEN) {
1995 printf("max-pkt-len can not be less than %d\n",
1999 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
2002 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
2003 if (res->value > RTE_ETHER_MAX_LEN)
2004 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2006 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2007 port->dev_conf.rxmode.offloads = rx_offloads;
2009 printf("Unknown parameter\n");
2016 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2019 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2020 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2022 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2023 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2025 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2026 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2028 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2029 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2031 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2032 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2035 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2036 .f = cmd_config_max_pkt_len_parsed,
2038 .help_str = "port config all max-pkt-len <value>",
2040 (void *)&cmd_config_max_pkt_len_port,
2041 (void *)&cmd_config_max_pkt_len_keyword,
2042 (void *)&cmd_config_max_pkt_len_all,
2043 (void *)&cmd_config_max_pkt_len_name,
2044 (void *)&cmd_config_max_pkt_len_value,
2049 /* *** config max LRO aggregated packet size *** */
2050 struct cmd_config_max_lro_pkt_size_result {
2051 cmdline_fixed_string_t port;
2052 cmdline_fixed_string_t keyword;
2053 cmdline_fixed_string_t all;
2054 cmdline_fixed_string_t name;
2059 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2060 __attribute__((unused)) struct cmdline *cl,
2061 __attribute__((unused)) void *data)
2063 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2066 if (!all_ports_stopped()) {
2067 printf("Please stop all ports first\n");
2071 RTE_ETH_FOREACH_DEV(pid) {
2072 struct rte_port *port = &ports[pid];
2074 if (!strcmp(res->name, "max-lro-pkt-size")) {
2076 port->dev_conf.rxmode.max_lro_pkt_size)
2079 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2081 printf("Unknown parameter\n");
2088 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2091 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2092 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2094 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2095 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2097 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2098 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2100 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2101 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2102 name, "max-lro-pkt-size");
2103 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2104 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2107 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2108 .f = cmd_config_max_lro_pkt_size_parsed,
2110 .help_str = "port config all max-lro-pkt-size <value>",
2112 (void *)&cmd_config_max_lro_pkt_size_port,
2113 (void *)&cmd_config_max_lro_pkt_size_keyword,
2114 (void *)&cmd_config_max_lro_pkt_size_all,
2115 (void *)&cmd_config_max_lro_pkt_size_name,
2116 (void *)&cmd_config_max_lro_pkt_size_value,
2121 /* *** configure port MTU *** */
2122 struct cmd_config_mtu_result {
2123 cmdline_fixed_string_t port;
2124 cmdline_fixed_string_t keyword;
2125 cmdline_fixed_string_t mtu;
2131 cmd_config_mtu_parsed(void *parsed_result,
2132 __attribute__((unused)) struct cmdline *cl,
2133 __attribute__((unused)) void *data)
2135 struct cmd_config_mtu_result *res = parsed_result;
2137 if (res->value < RTE_ETHER_MIN_LEN) {
2138 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2141 port_mtu_set(res->port_id, res->value);
2144 cmdline_parse_token_string_t cmd_config_mtu_port =
2145 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2147 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2148 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2150 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2151 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2153 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2154 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2155 cmdline_parse_token_num_t cmd_config_mtu_value =
2156 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2158 cmdline_parse_inst_t cmd_config_mtu = {
2159 .f = cmd_config_mtu_parsed,
2161 .help_str = "port config mtu <port_id> <value>",
2163 (void *)&cmd_config_mtu_port,
2164 (void *)&cmd_config_mtu_keyword,
2165 (void *)&cmd_config_mtu_mtu,
2166 (void *)&cmd_config_mtu_port_id,
2167 (void *)&cmd_config_mtu_value,
2172 /* *** configure rx mode *** */
2173 struct cmd_config_rx_mode_flag {
2174 cmdline_fixed_string_t port;
2175 cmdline_fixed_string_t keyword;
2176 cmdline_fixed_string_t all;
2177 cmdline_fixed_string_t name;
2178 cmdline_fixed_string_t value;
2182 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2183 __attribute__((unused)) struct cmdline *cl,
2184 __attribute__((unused)) void *data)
2186 struct cmd_config_rx_mode_flag *res = parsed_result;
2188 if (!all_ports_stopped()) {
2189 printf("Please stop all ports first\n");
2193 if (!strcmp(res->name, "drop-en")) {
2194 if (!strcmp(res->value, "on"))
2196 else if (!strcmp(res->value, "off"))
2199 printf("Unknown parameter\n");
2203 printf("Unknown parameter\n");
2209 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2212 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2213 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2214 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2215 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2217 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2218 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2219 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2220 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2222 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2223 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2226 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2227 .f = cmd_config_rx_mode_flag_parsed,
2229 .help_str = "port config all drop-en on|off",
2231 (void *)&cmd_config_rx_mode_flag_port,
2232 (void *)&cmd_config_rx_mode_flag_keyword,
2233 (void *)&cmd_config_rx_mode_flag_all,
2234 (void *)&cmd_config_rx_mode_flag_name,
2235 (void *)&cmd_config_rx_mode_flag_value,
2240 /* *** configure rss *** */
2241 struct cmd_config_rss {
2242 cmdline_fixed_string_t port;
2243 cmdline_fixed_string_t keyword;
2244 cmdline_fixed_string_t all;
2245 cmdline_fixed_string_t name;
2246 cmdline_fixed_string_t value;
2250 cmd_config_rss_parsed(void *parsed_result,
2251 __attribute__((unused)) struct cmdline *cl,
2252 __attribute__((unused)) void *data)
2254 struct cmd_config_rss *res = parsed_result;
2255 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2256 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2257 int use_default = 0;
2258 int all_updated = 1;
2263 if (!strcmp(res->value, "all"))
2264 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2265 ETH_RSS_UDP | ETH_RSS_SCTP |
2267 else if (!strcmp(res->value, "ip"))
2268 rss_conf.rss_hf = ETH_RSS_IP;
2269 else if (!strcmp(res->value, "udp"))
2270 rss_conf.rss_hf = ETH_RSS_UDP;
2271 else if (!strcmp(res->value, "tcp"))
2272 rss_conf.rss_hf = ETH_RSS_TCP;
2273 else if (!strcmp(res->value, "sctp"))
2274 rss_conf.rss_hf = ETH_RSS_SCTP;
2275 else if (!strcmp(res->value, "ether"))
2276 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2277 else if (!strcmp(res->value, "port"))
2278 rss_conf.rss_hf = ETH_RSS_PORT;
2279 else if (!strcmp(res->value, "vxlan"))
2280 rss_conf.rss_hf = ETH_RSS_VXLAN;
2281 else if (!strcmp(res->value, "geneve"))
2282 rss_conf.rss_hf = ETH_RSS_GENEVE;
2283 else if (!strcmp(res->value, "nvgre"))
2284 rss_conf.rss_hf = ETH_RSS_NVGRE;
2285 else if (!strcmp(res->value, "l3-src-only"))
2286 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2287 else if (!strcmp(res->value, "l3-dst-only"))
2288 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2289 else if (!strcmp(res->value, "l4-src-only"))
2290 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2291 else if (!strcmp(res->value, "l4-dst-only"))
2292 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2293 else if (!strcmp(res->value, "none"))
2294 rss_conf.rss_hf = 0;
2295 else if (!strcmp(res->value, "default"))
2297 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2298 atoi(res->value) < 64)
2299 rss_conf.rss_hf = 1ULL << atoi(res->value);
2301 printf("Unknown parameter\n");
2304 rss_conf.rss_key = NULL;
2305 /* Update global configuration for RSS types. */
2306 RTE_ETH_FOREACH_DEV(i) {
2307 struct rte_eth_rss_conf local_rss_conf;
2309 ret = eth_dev_info_get_print_err(i, &dev_info);
2314 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2316 local_rss_conf = rss_conf;
2317 local_rss_conf.rss_hf = rss_conf.rss_hf &
2318 dev_info.flow_type_rss_offloads;
2319 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2320 printf("Port %u modified RSS hash function based on hardware support,"
2321 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2322 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2324 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2327 printf("Configuration of RSS hash at ethernet port %d "
2328 "failed with error (%d): %s.\n",
2329 i, -diag, strerror(-diag));
2332 if (all_updated && !use_default)
2333 rss_hf = rss_conf.rss_hf;
2336 cmdline_parse_token_string_t cmd_config_rss_port =
2337 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2338 cmdline_parse_token_string_t cmd_config_rss_keyword =
2339 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2340 cmdline_parse_token_string_t cmd_config_rss_all =
2341 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2342 cmdline_parse_token_string_t cmd_config_rss_name =
2343 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2344 cmdline_parse_token_string_t cmd_config_rss_value =
2345 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2347 cmdline_parse_inst_t cmd_config_rss = {
2348 .f = cmd_config_rss_parsed,
2350 .help_str = "port config all rss "
2351 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>",
2353 (void *)&cmd_config_rss_port,
2354 (void *)&cmd_config_rss_keyword,
2355 (void *)&cmd_config_rss_all,
2356 (void *)&cmd_config_rss_name,
2357 (void *)&cmd_config_rss_value,
2362 /* *** configure rss hash key *** */
2363 struct cmd_config_rss_hash_key {
2364 cmdline_fixed_string_t port;
2365 cmdline_fixed_string_t config;
2367 cmdline_fixed_string_t rss_hash_key;
2368 cmdline_fixed_string_t rss_type;
2369 cmdline_fixed_string_t key;
2373 hexa_digit_to_value(char hexa_digit)
2375 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2376 return (uint8_t) (hexa_digit - '0');
2377 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2378 return (uint8_t) ((hexa_digit - 'a') + 10);
2379 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2380 return (uint8_t) ((hexa_digit - 'A') + 10);
2381 /* Invalid hexa digit */
2386 parse_and_check_key_hexa_digit(char *key, int idx)
2390 hexa_v = hexa_digit_to_value(key[idx]);
2392 printf("invalid key: character %c at position %d is not a "
2393 "valid hexa digit\n", key[idx], idx);
2398 cmd_config_rss_hash_key_parsed(void *parsed_result,
2399 __attribute__((unused)) struct cmdline *cl,
2400 __attribute__((unused)) void *data)
2402 struct cmd_config_rss_hash_key *res = parsed_result;
2403 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2407 struct rte_eth_dev_info dev_info;
2408 uint8_t hash_key_size;
2412 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2416 if (dev_info.hash_key_size > 0 &&
2417 dev_info.hash_key_size <= sizeof(hash_key))
2418 hash_key_size = dev_info.hash_key_size;
2420 printf("dev_info did not provide a valid hash key size\n");
2423 /* Check the length of the RSS hash key */
2424 key_len = strlen(res->key);
2425 if (key_len != (hash_key_size * 2)) {
2426 printf("key length: %d invalid - key must be a string of %d"
2427 " hexa-decimal numbers\n",
2428 (int) key_len, hash_key_size * 2);
2431 /* Translate RSS hash key into binary representation */
2432 for (i = 0; i < hash_key_size; i++) {
2433 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2436 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2439 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2441 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2445 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2446 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2447 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2448 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2450 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2451 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2452 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2453 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2454 rss_hash_key, "rss-hash-key");
2455 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2456 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2457 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2458 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2459 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2460 "ipv6-tcp-ex#ipv6-udp-ex#"
2461 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only");
2462 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2463 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2465 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2466 .f = cmd_config_rss_hash_key_parsed,
2468 .help_str = "port config <port_id> rss-hash-key "
2469 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2470 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2471 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2472 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only "
2473 "<string of hex digits (variable length, NIC dependent)>",
2475 (void *)&cmd_config_rss_hash_key_port,
2476 (void *)&cmd_config_rss_hash_key_config,
2477 (void *)&cmd_config_rss_hash_key_port_id,
2478 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2479 (void *)&cmd_config_rss_hash_key_rss_type,
2480 (void *)&cmd_config_rss_hash_key_value,
2485 /* *** configure port rxq/txq ring size *** */
2486 struct cmd_config_rxtx_ring_size {
2487 cmdline_fixed_string_t port;
2488 cmdline_fixed_string_t config;
2490 cmdline_fixed_string_t rxtxq;
2492 cmdline_fixed_string_t rsize;
2497 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2498 __attribute__((unused)) struct cmdline *cl,
2499 __attribute__((unused)) void *data)
2501 struct cmd_config_rxtx_ring_size *res = parsed_result;
2502 struct rte_port *port;
2505 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2508 if (res->portid == (portid_t)RTE_PORT_ALL) {
2509 printf("Invalid port id\n");
2513 port = &ports[res->portid];
2515 if (!strcmp(res->rxtxq, "rxq"))
2517 else if (!strcmp(res->rxtxq, "txq"))
2520 printf("Unknown parameter\n");
2524 if (isrx && rx_queue_id_is_invalid(res->qid))
2526 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2529 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2530 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2536 port->nb_rx_desc[res->qid] = res->size;
2538 port->nb_tx_desc[res->qid] = res->size;
2540 cmd_reconfig_device_queue(res->portid, 0, 1);
2543 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2544 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2546 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2547 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2549 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2550 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2552 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2553 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2555 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2556 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2558 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2559 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2560 rsize, "ring_size");
2561 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2562 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2565 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2566 .f = cmd_config_rxtx_ring_size_parsed,
2568 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2570 (void *)&cmd_config_rxtx_ring_size_port,
2571 (void *)&cmd_config_rxtx_ring_size_config,
2572 (void *)&cmd_config_rxtx_ring_size_portid,
2573 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2574 (void *)&cmd_config_rxtx_ring_size_qid,
2575 (void *)&cmd_config_rxtx_ring_size_rsize,
2576 (void *)&cmd_config_rxtx_ring_size_size,
2581 /* *** configure port rxq/txq start/stop *** */
2582 struct cmd_config_rxtx_queue {
2583 cmdline_fixed_string_t port;
2585 cmdline_fixed_string_t rxtxq;
2587 cmdline_fixed_string_t opname;
2591 cmd_config_rxtx_queue_parsed(void *parsed_result,
2592 __attribute__((unused)) struct cmdline *cl,
2593 __attribute__((unused)) void *data)
2595 struct cmd_config_rxtx_queue *res = parsed_result;
2600 if (test_done == 0) {
2601 printf("Please stop forwarding first\n");
2605 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2608 if (port_is_started(res->portid) != 1) {
2609 printf("Please start port %u first\n", res->portid);
2613 if (!strcmp(res->rxtxq, "rxq"))
2615 else if (!strcmp(res->rxtxq, "txq"))
2618 printf("Unknown parameter\n");
2622 if (isrx && rx_queue_id_is_invalid(res->qid))
2624 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2627 if (!strcmp(res->opname, "start"))
2629 else if (!strcmp(res->opname, "stop"))
2632 printf("Unknown parameter\n");
2636 if (isstart && isrx)
2637 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2638 else if (!isstart && isrx)
2639 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2640 else if (isstart && !isrx)
2641 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2643 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2645 if (ret == -ENOTSUP)
2646 printf("Function not supported in PMD driver\n");
2649 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2650 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2651 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2652 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2653 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2654 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2655 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2656 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2657 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2658 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2661 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2662 .f = cmd_config_rxtx_queue_parsed,
2664 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2666 (void *)&cmd_config_rxtx_queue_port,
2667 (void *)&cmd_config_rxtx_queue_portid,
2668 (void *)&cmd_config_rxtx_queue_rxtxq,
2669 (void *)&cmd_config_rxtx_queue_qid,
2670 (void *)&cmd_config_rxtx_queue_opname,
2675 /* *** configure port rxq/txq deferred start on/off *** */
2676 struct cmd_config_deferred_start_rxtx_queue {
2677 cmdline_fixed_string_t port;
2679 cmdline_fixed_string_t rxtxq;
2681 cmdline_fixed_string_t opname;
2682 cmdline_fixed_string_t state;
2686 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2687 __attribute__((unused)) struct cmdline *cl,
2688 __attribute__((unused)) void *data)
2690 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2691 struct rte_port *port;
2694 uint8_t needreconfig = 0;
2696 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2699 if (port_is_started(res->port_id) != 0) {
2700 printf("Please stop port %u first\n", res->port_id);
2704 port = &ports[res->port_id];
2706 isrx = !strcmp(res->rxtxq, "rxq");
2708 if (isrx && rx_queue_id_is_invalid(res->qid))
2710 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2713 ison = !strcmp(res->state, "on");
2715 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2716 port->rx_conf[res->qid].rx_deferred_start = ison;
2718 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2719 port->tx_conf[res->qid].tx_deferred_start = ison;
2724 cmd_reconfig_device_queue(res->port_id, 0, 1);
2727 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2728 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2730 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2731 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2733 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2734 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2736 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2737 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2739 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2740 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2741 opname, "deferred_start");
2742 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2743 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2746 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2747 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2749 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2751 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2752 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2753 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2754 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2755 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2756 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2761 /* *** configure port rxq/txq setup *** */
2762 struct cmd_setup_rxtx_queue {
2763 cmdline_fixed_string_t port;
2765 cmdline_fixed_string_t rxtxq;
2767 cmdline_fixed_string_t setup;
2770 /* Common CLI fields for queue setup */
2771 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2772 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2773 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2774 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2775 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2776 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2777 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2778 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2779 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2780 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2783 cmd_setup_rxtx_queue_parsed(
2784 void *parsed_result,
2785 __attribute__((unused)) struct cmdline *cl,
2786 __attribute__((unused)) void *data)
2788 struct cmd_setup_rxtx_queue *res = parsed_result;
2789 struct rte_port *port;
2790 struct rte_mempool *mp;
2791 unsigned int socket_id;
2795 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2798 if (res->portid == (portid_t)RTE_PORT_ALL) {
2799 printf("Invalid port id\n");
2803 if (!strcmp(res->rxtxq, "rxq"))
2805 else if (!strcmp(res->rxtxq, "txq"))
2808 printf("Unknown parameter\n");
2812 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2813 printf("Invalid rx queue\n");
2815 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2816 printf("Invalid tx queue\n");
2820 port = &ports[res->portid];
2822 socket_id = rxring_numa[res->portid];
2823 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2824 socket_id = port->socket_id;
2826 mp = mbuf_pool_find(socket_id);
2828 printf("Failed to setup RX queue: "
2829 "No mempool allocation"
2830 " on the socket %d\n",
2831 rxring_numa[res->portid]);
2834 ret = rte_eth_rx_queue_setup(res->portid,
2836 port->nb_rx_desc[res->qid],
2838 &port->rx_conf[res->qid],
2841 printf("Failed to setup RX queue\n");
2843 socket_id = txring_numa[res->portid];
2844 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2845 socket_id = port->socket_id;
2847 ret = rte_eth_tx_queue_setup(res->portid,
2849 port->nb_tx_desc[res->qid],
2851 &port->tx_conf[res->qid]);
2853 printf("Failed to setup TX queue\n");
2857 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2858 .f = cmd_setup_rxtx_queue_parsed,
2860 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2862 (void *)&cmd_setup_rxtx_queue_port,
2863 (void *)&cmd_setup_rxtx_queue_portid,
2864 (void *)&cmd_setup_rxtx_queue_rxtxq,
2865 (void *)&cmd_setup_rxtx_queue_qid,
2866 (void *)&cmd_setup_rxtx_queue_setup,
2872 /* *** Configure RSS RETA *** */
2873 struct cmd_config_rss_reta {
2874 cmdline_fixed_string_t port;
2875 cmdline_fixed_string_t keyword;
2877 cmdline_fixed_string_t name;
2878 cmdline_fixed_string_t list_name;
2879 cmdline_fixed_string_t list_of_items;
2883 parse_reta_config(const char *str,
2884 struct rte_eth_rss_reta_entry64 *reta_conf,
2885 uint16_t nb_entries)
2889 uint16_t hash_index, idx, shift;
2892 const char *p, *p0 = str;
2899 unsigned long int_fld[_NUM_FLD];
2900 char *str_fld[_NUM_FLD];
2902 while ((p = strchr(p0,'(')) != NULL) {
2904 if((p0 = strchr(p,')')) == NULL)
2908 if(size >= sizeof(s))
2911 snprintf(s, sizeof(s), "%.*s", size, p);
2912 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2914 for (i = 0; i < _NUM_FLD; i++) {
2916 int_fld[i] = strtoul(str_fld[i], &end, 0);
2917 if (errno != 0 || end == str_fld[i] ||
2922 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2923 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2925 if (hash_index >= nb_entries) {
2926 printf("Invalid RETA hash index=%d\n", hash_index);
2930 idx = hash_index / RTE_RETA_GROUP_SIZE;
2931 shift = hash_index % RTE_RETA_GROUP_SIZE;
2932 reta_conf[idx].mask |= (1ULL << shift);
2933 reta_conf[idx].reta[shift] = nb_queue;
2940 cmd_set_rss_reta_parsed(void *parsed_result,
2941 __attribute__((unused)) struct cmdline *cl,
2942 __attribute__((unused)) void *data)
2945 struct rte_eth_dev_info dev_info;
2946 struct rte_eth_rss_reta_entry64 reta_conf[8];
2947 struct cmd_config_rss_reta *res = parsed_result;
2949 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2953 if (dev_info.reta_size == 0) {
2954 printf("Redirection table size is 0 which is "
2955 "invalid for RSS\n");
2958 printf("The reta size of port %d is %u\n",
2959 res->port_id, dev_info.reta_size);
2960 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2961 printf("Currently do not support more than %u entries of "
2962 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2966 memset(reta_conf, 0, sizeof(reta_conf));
2967 if (!strcmp(res->list_name, "reta")) {
2968 if (parse_reta_config(res->list_of_items, reta_conf,
2969 dev_info.reta_size)) {
2970 printf("Invalid RSS Redirection Table "
2971 "config entered\n");
2974 ret = rte_eth_dev_rss_reta_update(res->port_id,
2975 reta_conf, dev_info.reta_size);
2977 printf("Bad redirection table parameter, "
2978 "return code = %d \n", ret);
2982 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2983 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2984 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2985 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2986 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2987 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2988 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2989 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2990 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2991 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2992 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2993 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2995 cmdline_parse_inst_t cmd_config_rss_reta = {
2996 .f = cmd_set_rss_reta_parsed,
2998 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3000 (void *)&cmd_config_rss_reta_port,
3001 (void *)&cmd_config_rss_reta_keyword,
3002 (void *)&cmd_config_rss_reta_port_id,
3003 (void *)&cmd_config_rss_reta_name,
3004 (void *)&cmd_config_rss_reta_list_name,
3005 (void *)&cmd_config_rss_reta_list_of_items,
3010 /* *** SHOW PORT RETA INFO *** */
3011 struct cmd_showport_reta {
3012 cmdline_fixed_string_t show;
3013 cmdline_fixed_string_t port;
3015 cmdline_fixed_string_t rss;
3016 cmdline_fixed_string_t reta;
3018 cmdline_fixed_string_t list_of_items;
3022 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3023 uint16_t nb_entries,
3027 const char *p, *p0 = str;
3032 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3033 RTE_RETA_GROUP_SIZE;
3036 p = strchr(p0, '(');
3040 p0 = strchr(p, ')');
3044 if (size >= sizeof(s)) {
3045 printf("The string size exceeds the internal buffer size\n");
3048 snprintf(s, sizeof(s), "%.*s", size, p);
3049 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3050 if (ret <= 0 || ret != num) {
3051 printf("The bits of masks do not match the number of "
3052 "reta entries: %u\n", num);
3055 for (i = 0; i < ret; i++)
3056 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3062 cmd_showport_reta_parsed(void *parsed_result,
3063 __attribute__((unused)) struct cmdline *cl,
3064 __attribute__((unused)) void *data)
3066 struct cmd_showport_reta *res = parsed_result;
3067 struct rte_eth_rss_reta_entry64 reta_conf[8];
3068 struct rte_eth_dev_info dev_info;
3069 uint16_t max_reta_size;
3072 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3076 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3077 if (res->size == 0 || res->size > max_reta_size) {
3078 printf("Invalid redirection table size: %u (1-%u)\n",
3079 res->size, max_reta_size);
3083 memset(reta_conf, 0, sizeof(reta_conf));
3084 if (showport_parse_reta_config(reta_conf, res->size,
3085 res->list_of_items) < 0) {
3086 printf("Invalid string: %s for reta masks\n",
3087 res->list_of_items);
3090 port_rss_reta_info(res->port_id, reta_conf, res->size);
3093 cmdline_parse_token_string_t cmd_showport_reta_show =
3094 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3095 cmdline_parse_token_string_t cmd_showport_reta_port =
3096 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3097 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3098 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3099 cmdline_parse_token_string_t cmd_showport_reta_rss =
3100 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3101 cmdline_parse_token_string_t cmd_showport_reta_reta =
3102 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3103 cmdline_parse_token_num_t cmd_showport_reta_size =
3104 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3105 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3106 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3107 list_of_items, NULL);
3109 cmdline_parse_inst_t cmd_showport_reta = {
3110 .f = cmd_showport_reta_parsed,
3112 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3114 (void *)&cmd_showport_reta_show,
3115 (void *)&cmd_showport_reta_port,
3116 (void *)&cmd_showport_reta_port_id,
3117 (void *)&cmd_showport_reta_rss,
3118 (void *)&cmd_showport_reta_reta,
3119 (void *)&cmd_showport_reta_size,
3120 (void *)&cmd_showport_reta_list_of_items,
3125 /* *** Show RSS hash configuration *** */
3126 struct cmd_showport_rss_hash {
3127 cmdline_fixed_string_t show;
3128 cmdline_fixed_string_t port;
3130 cmdline_fixed_string_t rss_hash;
3131 cmdline_fixed_string_t rss_type;
3132 cmdline_fixed_string_t key; /* optional argument */
3135 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3136 __attribute__((unused)) struct cmdline *cl,
3139 struct cmd_showport_rss_hash *res = parsed_result;
3141 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3144 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3145 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3146 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3147 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3148 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3149 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3150 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3151 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3153 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3154 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3156 cmdline_parse_inst_t cmd_showport_rss_hash = {
3157 .f = cmd_showport_rss_hash_parsed,
3159 .help_str = "show port <port_id> rss-hash",
3161 (void *)&cmd_showport_rss_hash_show,
3162 (void *)&cmd_showport_rss_hash_port,
3163 (void *)&cmd_showport_rss_hash_port_id,
3164 (void *)&cmd_showport_rss_hash_rss_hash,
3169 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3170 .f = cmd_showport_rss_hash_parsed,
3172 .help_str = "show port <port_id> rss-hash key",
3174 (void *)&cmd_showport_rss_hash_show,
3175 (void *)&cmd_showport_rss_hash_port,
3176 (void *)&cmd_showport_rss_hash_port_id,
3177 (void *)&cmd_showport_rss_hash_rss_hash,
3178 (void *)&cmd_showport_rss_hash_rss_key,
3183 /* *** Configure DCB *** */
3184 struct cmd_config_dcb {
3185 cmdline_fixed_string_t port;
3186 cmdline_fixed_string_t config;
3188 cmdline_fixed_string_t dcb;
3189 cmdline_fixed_string_t vt;
3190 cmdline_fixed_string_t vt_en;
3192 cmdline_fixed_string_t pfc;
3193 cmdline_fixed_string_t pfc_en;
3197 cmd_config_dcb_parsed(void *parsed_result,
3198 __attribute__((unused)) struct cmdline *cl,
3199 __attribute__((unused)) void *data)
3201 struct cmd_config_dcb *res = parsed_result;
3202 portid_t port_id = res->port_id;
3203 struct rte_port *port;
3207 port = &ports[port_id];
3208 /** Check if the port is not started **/
3209 if (port->port_status != RTE_PORT_STOPPED) {
3210 printf("Please stop port %d first\n", port_id);
3214 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3215 printf("The invalid number of traffic class,"
3216 " only 4 or 8 allowed.\n");
3220 if (nb_fwd_lcores < res->num_tcs) {
3221 printf("nb_cores shouldn't be less than number of TCs.\n");
3224 if (!strncmp(res->pfc_en, "on", 2))
3229 /* DCB in VT mode */
3230 if (!strncmp(res->vt_en, "on", 2))
3231 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3232 (enum rte_eth_nb_tcs)res->num_tcs,
3235 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3236 (enum rte_eth_nb_tcs)res->num_tcs,
3241 printf("Cannot initialize network ports.\n");
3245 cmd_reconfig_device_queue(port_id, 1, 1);
3248 cmdline_parse_token_string_t cmd_config_dcb_port =
3249 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3250 cmdline_parse_token_string_t cmd_config_dcb_config =
3251 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3252 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3253 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3254 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3255 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3256 cmdline_parse_token_string_t cmd_config_dcb_vt =
3257 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3258 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3259 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3260 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3261 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3262 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3263 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3264 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3265 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3267 cmdline_parse_inst_t cmd_config_dcb = {
3268 .f = cmd_config_dcb_parsed,
3270 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3272 (void *)&cmd_config_dcb_port,
3273 (void *)&cmd_config_dcb_config,
3274 (void *)&cmd_config_dcb_port_id,
3275 (void *)&cmd_config_dcb_dcb,
3276 (void *)&cmd_config_dcb_vt,
3277 (void *)&cmd_config_dcb_vt_en,
3278 (void *)&cmd_config_dcb_num_tcs,
3279 (void *)&cmd_config_dcb_pfc,
3280 (void *)&cmd_config_dcb_pfc_en,
3285 /* *** configure number of packets per burst *** */
3286 struct cmd_config_burst {
3287 cmdline_fixed_string_t port;
3288 cmdline_fixed_string_t keyword;
3289 cmdline_fixed_string_t all;
3290 cmdline_fixed_string_t name;
3295 cmd_config_burst_parsed(void *parsed_result,
3296 __attribute__((unused)) struct cmdline *cl,
3297 __attribute__((unused)) void *data)
3299 struct cmd_config_burst *res = parsed_result;
3300 struct rte_eth_dev_info dev_info;
3301 uint16_t rec_nb_pkts;
3304 if (!all_ports_stopped()) {
3305 printf("Please stop all ports first\n");
3309 if (!strcmp(res->name, "burst")) {
3310 if (res->value == 0) {
3311 /* If user gives a value of zero, query the PMD for
3312 * its recommended Rx burst size. Testpmd uses a single
3313 * size for all ports, so assume all ports are the same
3314 * NIC model and use the values from Port 0.
3316 ret = eth_dev_info_get_print_err(0, &dev_info);
3320 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3322 if (rec_nb_pkts == 0) {
3323 printf("PMD does not recommend a burst size.\n"
3324 "User provided value must be between"
3325 " 1 and %d\n", MAX_PKT_BURST);
3327 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3328 printf("PMD recommended burst size of %d"
3329 " exceeds maximum value of %d\n",
3330 rec_nb_pkts, MAX_PKT_BURST);
3333 printf("Using PMD-provided burst value of %d\n",
3335 nb_pkt_per_burst = rec_nb_pkts;
3336 } else if (res->value > MAX_PKT_BURST) {
3337 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3340 nb_pkt_per_burst = res->value;
3342 printf("Unknown parameter\n");
3348 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3351 cmdline_parse_token_string_t cmd_config_burst_port =
3352 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3353 cmdline_parse_token_string_t cmd_config_burst_keyword =
3354 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3355 cmdline_parse_token_string_t cmd_config_burst_all =
3356 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3357 cmdline_parse_token_string_t cmd_config_burst_name =
3358 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3359 cmdline_parse_token_num_t cmd_config_burst_value =
3360 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3362 cmdline_parse_inst_t cmd_config_burst = {
3363 .f = cmd_config_burst_parsed,
3365 .help_str = "port config all burst <value>",
3367 (void *)&cmd_config_burst_port,
3368 (void *)&cmd_config_burst_keyword,
3369 (void *)&cmd_config_burst_all,
3370 (void *)&cmd_config_burst_name,
3371 (void *)&cmd_config_burst_value,
3376 /* *** configure rx/tx queues *** */
3377 struct cmd_config_thresh {
3378 cmdline_fixed_string_t port;
3379 cmdline_fixed_string_t keyword;
3380 cmdline_fixed_string_t all;
3381 cmdline_fixed_string_t name;
3386 cmd_config_thresh_parsed(void *parsed_result,
3387 __attribute__((unused)) struct cmdline *cl,
3388 __attribute__((unused)) void *data)
3390 struct cmd_config_thresh *res = parsed_result;
3392 if (!all_ports_stopped()) {
3393 printf("Please stop all ports first\n");
3397 if (!strcmp(res->name, "txpt"))
3398 tx_pthresh = res->value;
3399 else if(!strcmp(res->name, "txht"))
3400 tx_hthresh = res->value;
3401 else if(!strcmp(res->name, "txwt"))
3402 tx_wthresh = res->value;
3403 else if(!strcmp(res->name, "rxpt"))
3404 rx_pthresh = res->value;
3405 else if(!strcmp(res->name, "rxht"))
3406 rx_hthresh = res->value;
3407 else if(!strcmp(res->name, "rxwt"))
3408 rx_wthresh = res->value;
3410 printf("Unknown parameter\n");
3416 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3419 cmdline_parse_token_string_t cmd_config_thresh_port =
3420 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3421 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3422 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3423 cmdline_parse_token_string_t cmd_config_thresh_all =
3424 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3425 cmdline_parse_token_string_t cmd_config_thresh_name =
3426 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3427 "txpt#txht#txwt#rxpt#rxht#rxwt");
3428 cmdline_parse_token_num_t cmd_config_thresh_value =
3429 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3431 cmdline_parse_inst_t cmd_config_thresh = {
3432 .f = cmd_config_thresh_parsed,
3434 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3436 (void *)&cmd_config_thresh_port,
3437 (void *)&cmd_config_thresh_keyword,
3438 (void *)&cmd_config_thresh_all,
3439 (void *)&cmd_config_thresh_name,
3440 (void *)&cmd_config_thresh_value,
3445 /* *** configure free/rs threshold *** */
3446 struct cmd_config_threshold {
3447 cmdline_fixed_string_t port;
3448 cmdline_fixed_string_t keyword;
3449 cmdline_fixed_string_t all;
3450 cmdline_fixed_string_t name;
3455 cmd_config_threshold_parsed(void *parsed_result,
3456 __attribute__((unused)) struct cmdline *cl,
3457 __attribute__((unused)) void *data)
3459 struct cmd_config_threshold *res = parsed_result;
3461 if (!all_ports_stopped()) {
3462 printf("Please stop all ports first\n");
3466 if (!strcmp(res->name, "txfreet"))
3467 tx_free_thresh = res->value;
3468 else if (!strcmp(res->name, "txrst"))
3469 tx_rs_thresh = res->value;
3470 else if (!strcmp(res->name, "rxfreet"))
3471 rx_free_thresh = res->value;
3473 printf("Unknown parameter\n");
3479 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3482 cmdline_parse_token_string_t cmd_config_threshold_port =
3483 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3484 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3485 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3487 cmdline_parse_token_string_t cmd_config_threshold_all =
3488 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3489 cmdline_parse_token_string_t cmd_config_threshold_name =
3490 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3491 "txfreet#txrst#rxfreet");
3492 cmdline_parse_token_num_t cmd_config_threshold_value =
3493 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3495 cmdline_parse_inst_t cmd_config_threshold = {
3496 .f = cmd_config_threshold_parsed,
3498 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3500 (void *)&cmd_config_threshold_port,
3501 (void *)&cmd_config_threshold_keyword,
3502 (void *)&cmd_config_threshold_all,
3503 (void *)&cmd_config_threshold_name,
3504 (void *)&cmd_config_threshold_value,
3510 struct cmd_stop_result {
3511 cmdline_fixed_string_t stop;
3514 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3515 __attribute__((unused)) struct cmdline *cl,
3516 __attribute__((unused)) void *data)
3518 stop_packet_forwarding();
3521 cmdline_parse_token_string_t cmd_stop_stop =
3522 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3524 cmdline_parse_inst_t cmd_stop = {
3525 .f = cmd_stop_parsed,
3527 .help_str = "stop: Stop packet forwarding",
3529 (void *)&cmd_stop_stop,
3534 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3537 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3538 unsigned int *parsed_items, int check_unique_values)
3540 unsigned int nb_item;
3548 * First parse all items in the list and store their value.
3553 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3555 if ((c >= '0') && (c <= '9')) {
3556 value = (unsigned int) (value * 10 + (c - '0'));
3561 printf("character %c is not a decimal digit\n", c);
3565 printf("No valid value before comma\n");
3568 if (nb_item < max_items) {
3569 parsed_items[nb_item] = value;
3575 if (nb_item >= max_items) {
3576 printf("Number of %s = %u > %u (maximum items)\n",
3577 item_name, nb_item + 1, max_items);
3580 parsed_items[nb_item++] = value;
3581 if (! check_unique_values)
3585 * Then, check that all values in the list are differents.
3586 * No optimization here...
3588 for (i = 0; i < nb_item; i++) {
3589 for (j = i + 1; j < nb_item; j++) {
3590 if (parsed_items[j] == parsed_items[i]) {
3591 printf("duplicated %s %u at index %u and %u\n",
3592 item_name, parsed_items[i], i, j);
3600 struct cmd_set_list_result {
3601 cmdline_fixed_string_t cmd_keyword;
3602 cmdline_fixed_string_t list_name;
3603 cmdline_fixed_string_t list_of_items;
3606 static void cmd_set_list_parsed(void *parsed_result,
3607 __attribute__((unused)) struct cmdline *cl,
3608 __attribute__((unused)) void *data)
3610 struct cmd_set_list_result *res;
3612 unsigned int lcorelist[RTE_MAX_LCORE];
3613 unsigned int portlist[RTE_MAX_ETHPORTS];
3615 unsigned int nb_item;
3617 if (test_done == 0) {
3618 printf("Please stop forwarding first\n");
3622 res = parsed_result;
3623 if (!strcmp(res->list_name, "corelist")) {
3624 nb_item = parse_item_list(res->list_of_items, "core",
3626 parsed_items.lcorelist, 1);
3628 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3633 if (!strcmp(res->list_name, "portlist")) {
3634 nb_item = parse_item_list(res->list_of_items, "port",
3636 parsed_items.portlist, 1);
3638 set_fwd_ports_list(parsed_items.portlist, nb_item);
3644 cmdline_parse_token_string_t cmd_set_list_keyword =
3645 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3647 cmdline_parse_token_string_t cmd_set_list_name =
3648 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3649 "corelist#portlist");
3650 cmdline_parse_token_string_t cmd_set_list_of_items =
3651 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3654 cmdline_parse_inst_t cmd_set_fwd_list = {
3655 .f = cmd_set_list_parsed,
3657 .help_str = "set corelist|portlist <list0[,list1]*>",
3659 (void *)&cmd_set_list_keyword,
3660 (void *)&cmd_set_list_name,
3661 (void *)&cmd_set_list_of_items,
3666 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3668 struct cmd_setmask_result {
3669 cmdline_fixed_string_t set;
3670 cmdline_fixed_string_t mask;
3674 static void cmd_set_mask_parsed(void *parsed_result,
3675 __attribute__((unused)) struct cmdline *cl,
3676 __attribute__((unused)) void *data)
3678 struct cmd_setmask_result *res = parsed_result;
3680 if (test_done == 0) {
3681 printf("Please stop forwarding first\n");
3684 if (!strcmp(res->mask, "coremask")) {
3685 set_fwd_lcores_mask(res->hexavalue);
3687 } else if (!strcmp(res->mask, "portmask")) {
3688 set_fwd_ports_mask(res->hexavalue);
3693 cmdline_parse_token_string_t cmd_setmask_set =
3694 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3695 cmdline_parse_token_string_t cmd_setmask_mask =
3696 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3697 "coremask#portmask");
3698 cmdline_parse_token_num_t cmd_setmask_value =
3699 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3701 cmdline_parse_inst_t cmd_set_fwd_mask = {
3702 .f = cmd_set_mask_parsed,
3704 .help_str = "set coremask|portmask <hexadecimal value>",
3706 (void *)&cmd_setmask_set,
3707 (void *)&cmd_setmask_mask,
3708 (void *)&cmd_setmask_value,
3714 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3716 struct cmd_set_result {
3717 cmdline_fixed_string_t set;
3718 cmdline_fixed_string_t what;
3722 static void cmd_set_parsed(void *parsed_result,
3723 __attribute__((unused)) struct cmdline *cl,
3724 __attribute__((unused)) void *data)
3726 struct cmd_set_result *res = parsed_result;
3727 if (!strcmp(res->what, "nbport")) {
3728 set_fwd_ports_number(res->value);
3730 } else if (!strcmp(res->what, "nbcore")) {
3731 set_fwd_lcores_number(res->value);
3733 } else if (!strcmp(res->what, "burst"))
3734 set_nb_pkt_per_burst(res->value);
3735 else if (!strcmp(res->what, "verbose"))
3736 set_verbose_level(res->value);
3739 cmdline_parse_token_string_t cmd_set_set =
3740 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3741 cmdline_parse_token_string_t cmd_set_what =
3742 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3743 "nbport#nbcore#burst#verbose");
3744 cmdline_parse_token_num_t cmd_set_value =
3745 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3747 cmdline_parse_inst_t cmd_set_numbers = {
3748 .f = cmd_set_parsed,
3750 .help_str = "set nbport|nbcore|burst|verbose <value>",
3752 (void *)&cmd_set_set,
3753 (void *)&cmd_set_what,
3754 (void *)&cmd_set_value,
3759 /* *** SET LOG LEVEL CONFIGURATION *** */
3761 struct cmd_set_log_result {
3762 cmdline_fixed_string_t set;
3763 cmdline_fixed_string_t log;
3764 cmdline_fixed_string_t type;
3769 cmd_set_log_parsed(void *parsed_result,
3770 __attribute__((unused)) struct cmdline *cl,
3771 __attribute__((unused)) void *data)
3773 struct cmd_set_log_result *res;
3776 res = parsed_result;
3777 if (!strcmp(res->type, "global"))
3778 rte_log_set_global_level(res->level);
3780 ret = rte_log_set_level_regexp(res->type, res->level);
3782 printf("Unable to set log level\n");
3786 cmdline_parse_token_string_t cmd_set_log_set =
3787 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3788 cmdline_parse_token_string_t cmd_set_log_log =
3789 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3790 cmdline_parse_token_string_t cmd_set_log_type =
3791 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3792 cmdline_parse_token_num_t cmd_set_log_level =
3793 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3795 cmdline_parse_inst_t cmd_set_log = {
3796 .f = cmd_set_log_parsed,
3798 .help_str = "set log global|<type> <level>",
3800 (void *)&cmd_set_log_set,
3801 (void *)&cmd_set_log_log,
3802 (void *)&cmd_set_log_type,
3803 (void *)&cmd_set_log_level,
3808 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3810 struct cmd_set_txpkts_result {
3811 cmdline_fixed_string_t cmd_keyword;
3812 cmdline_fixed_string_t txpkts;
3813 cmdline_fixed_string_t seg_lengths;
3817 cmd_set_txpkts_parsed(void *parsed_result,
3818 __attribute__((unused)) struct cmdline *cl,
3819 __attribute__((unused)) void *data)
3821 struct cmd_set_txpkts_result *res;
3822 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3823 unsigned int nb_segs;
3825 res = parsed_result;
3826 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3827 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3829 set_tx_pkt_segments(seg_lengths, nb_segs);
3832 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3833 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3834 cmd_keyword, "set");
3835 cmdline_parse_token_string_t cmd_set_txpkts_name =
3836 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3838 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3839 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3842 cmdline_parse_inst_t cmd_set_txpkts = {
3843 .f = cmd_set_txpkts_parsed,
3845 .help_str = "set txpkts <len0[,len1]*>",
3847 (void *)&cmd_set_txpkts_keyword,
3848 (void *)&cmd_set_txpkts_name,
3849 (void *)&cmd_set_txpkts_lengths,
3854 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3856 struct cmd_set_txsplit_result {
3857 cmdline_fixed_string_t cmd_keyword;
3858 cmdline_fixed_string_t txsplit;
3859 cmdline_fixed_string_t mode;
3863 cmd_set_txsplit_parsed(void *parsed_result,
3864 __attribute__((unused)) struct cmdline *cl,
3865 __attribute__((unused)) void *data)
3867 struct cmd_set_txsplit_result *res;
3869 res = parsed_result;
3870 set_tx_pkt_split(res->mode);
3873 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3874 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3875 cmd_keyword, "set");
3876 cmdline_parse_token_string_t cmd_set_txsplit_name =
3877 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3878 txsplit, "txsplit");
3879 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3880 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3883 cmdline_parse_inst_t cmd_set_txsplit = {
3884 .f = cmd_set_txsplit_parsed,
3886 .help_str = "set txsplit on|off|rand",
3888 (void *)&cmd_set_txsplit_keyword,
3889 (void *)&cmd_set_txsplit_name,
3890 (void *)&cmd_set_txsplit_mode,
3895 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3896 struct cmd_rx_vlan_filter_all_result {
3897 cmdline_fixed_string_t rx_vlan;
3898 cmdline_fixed_string_t what;
3899 cmdline_fixed_string_t all;
3904 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3905 __attribute__((unused)) struct cmdline *cl,
3906 __attribute__((unused)) void *data)
3908 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3910 if (!strcmp(res->what, "add"))
3911 rx_vlan_all_filter_set(res->port_id, 1);
3913 rx_vlan_all_filter_set(res->port_id, 0);
3916 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3917 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3918 rx_vlan, "rx_vlan");
3919 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3920 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3922 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3923 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3925 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3926 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3929 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3930 .f = cmd_rx_vlan_filter_all_parsed,
3932 .help_str = "rx_vlan add|rm all <port_id>: "
3933 "Add/Remove all identifiers to/from the set of VLAN "
3934 "identifiers filtered by a port",
3936 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3937 (void *)&cmd_rx_vlan_filter_all_what,
3938 (void *)&cmd_rx_vlan_filter_all_all,
3939 (void *)&cmd_rx_vlan_filter_all_portid,
3944 /* *** VLAN OFFLOAD SET ON A PORT *** */
3945 struct cmd_vlan_offload_result {
3946 cmdline_fixed_string_t vlan;
3947 cmdline_fixed_string_t set;
3948 cmdline_fixed_string_t vlan_type;
3949 cmdline_fixed_string_t what;
3950 cmdline_fixed_string_t on;
3951 cmdline_fixed_string_t port_id;
3955 cmd_vlan_offload_parsed(void *parsed_result,
3956 __attribute__((unused)) struct cmdline *cl,
3957 __attribute__((unused)) void *data)
3960 struct cmd_vlan_offload_result *res = parsed_result;
3963 portid_t port_id = 0;
3967 len = strnlen(str, STR_TOKEN_SIZE);
3969 /* Get port_id first */
3977 tmp = strtoul(str, NULL, 0);
3978 /* If port_id greater that what portid_t can represent, return */
3979 if(tmp >= RTE_MAX_ETHPORTS)
3981 port_id = (portid_t)tmp;
3983 if (!strcmp(res->on, "on"))
3988 if (!strcmp(res->what, "strip"))
3989 rx_vlan_strip_set(port_id, on);
3990 else if(!strcmp(res->what, "stripq")){
3991 uint16_t queue_id = 0;
3993 /* No queue_id, return */
3995 printf("must specify (port,queue_id)\n");
3998 tmp = strtoul(str + i + 1, NULL, 0);
3999 /* If queue_id greater that what 16-bits can represent, return */
4003 queue_id = (uint16_t)tmp;
4004 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4006 else if (!strcmp(res->what, "filter"))
4007 rx_vlan_filter_set(port_id, on);
4008 else if (!strcmp(res->what, "qinq_strip"))
4009 rx_vlan_qinq_strip_set(port_id, on);
4011 vlan_extend_set(port_id, on);
4016 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4017 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4019 cmdline_parse_token_string_t cmd_vlan_offload_set =
4020 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4022 cmdline_parse_token_string_t cmd_vlan_offload_what =
4023 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4024 what, "strip#filter#qinq_strip#extend#stripq");
4025 cmdline_parse_token_string_t cmd_vlan_offload_on =
4026 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4028 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4029 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4032 cmdline_parse_inst_t cmd_vlan_offload = {
4033 .f = cmd_vlan_offload_parsed,
4035 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4036 "<port_id[,queue_id]>: "
4037 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4039 (void *)&cmd_vlan_offload_vlan,
4040 (void *)&cmd_vlan_offload_set,
4041 (void *)&cmd_vlan_offload_what,
4042 (void *)&cmd_vlan_offload_on,
4043 (void *)&cmd_vlan_offload_portid,
4048 /* *** VLAN TPID SET ON A PORT *** */
4049 struct cmd_vlan_tpid_result {
4050 cmdline_fixed_string_t vlan;
4051 cmdline_fixed_string_t set;
4052 cmdline_fixed_string_t vlan_type;
4053 cmdline_fixed_string_t what;
4059 cmd_vlan_tpid_parsed(void *parsed_result,
4060 __attribute__((unused)) struct cmdline *cl,
4061 __attribute__((unused)) void *data)
4063 struct cmd_vlan_tpid_result *res = parsed_result;
4064 enum rte_vlan_type vlan_type;
4066 if (!strcmp(res->vlan_type, "inner"))
4067 vlan_type = ETH_VLAN_TYPE_INNER;
4068 else if (!strcmp(res->vlan_type, "outer"))
4069 vlan_type = ETH_VLAN_TYPE_OUTER;
4071 printf("Unknown vlan type\n");
4074 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4077 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4078 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4080 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4081 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4083 cmdline_parse_token_string_t cmd_vlan_type =
4084 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4085 vlan_type, "inner#outer");
4086 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4087 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4089 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4090 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4092 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4093 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4096 cmdline_parse_inst_t cmd_vlan_tpid = {
4097 .f = cmd_vlan_tpid_parsed,
4099 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4100 "Set the VLAN Ether type",
4102 (void *)&cmd_vlan_tpid_vlan,
4103 (void *)&cmd_vlan_tpid_set,
4104 (void *)&cmd_vlan_type,
4105 (void *)&cmd_vlan_tpid_what,
4106 (void *)&cmd_vlan_tpid_tpid,
4107 (void *)&cmd_vlan_tpid_portid,
4112 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4113 struct cmd_rx_vlan_filter_result {
4114 cmdline_fixed_string_t rx_vlan;
4115 cmdline_fixed_string_t what;
4121 cmd_rx_vlan_filter_parsed(void *parsed_result,
4122 __attribute__((unused)) struct cmdline *cl,
4123 __attribute__((unused)) void *data)
4125 struct cmd_rx_vlan_filter_result *res = parsed_result;
4127 if (!strcmp(res->what, "add"))
4128 rx_vft_set(res->port_id, res->vlan_id, 1);
4130 rx_vft_set(res->port_id, res->vlan_id, 0);
4133 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4134 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4135 rx_vlan, "rx_vlan");
4136 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4137 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4139 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4140 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4142 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4143 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4146 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4147 .f = cmd_rx_vlan_filter_parsed,
4149 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4150 "Add/Remove a VLAN identifier to/from the set of VLAN "
4151 "identifiers filtered by a port",
4153 (void *)&cmd_rx_vlan_filter_rx_vlan,
4154 (void *)&cmd_rx_vlan_filter_what,
4155 (void *)&cmd_rx_vlan_filter_vlanid,
4156 (void *)&cmd_rx_vlan_filter_portid,
4161 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4162 struct cmd_tx_vlan_set_result {
4163 cmdline_fixed_string_t tx_vlan;
4164 cmdline_fixed_string_t set;
4170 cmd_tx_vlan_set_parsed(void *parsed_result,
4171 __attribute__((unused)) struct cmdline *cl,
4172 __attribute__((unused)) void *data)
4174 struct cmd_tx_vlan_set_result *res = parsed_result;
4176 if (!port_is_stopped(res->port_id)) {
4177 printf("Please stop port %d first\n", res->port_id);
4181 tx_vlan_set(res->port_id, res->vlan_id);
4183 cmd_reconfig_device_queue(res->port_id, 1, 1);
4186 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4187 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4188 tx_vlan, "tx_vlan");
4189 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4190 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4192 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4193 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4195 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4196 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4199 cmdline_parse_inst_t cmd_tx_vlan_set = {
4200 .f = cmd_tx_vlan_set_parsed,
4202 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4203 "Enable hardware insertion of a single VLAN header "
4204 "with a given TAG Identifier in packets sent on a port",
4206 (void *)&cmd_tx_vlan_set_tx_vlan,
4207 (void *)&cmd_tx_vlan_set_set,
4208 (void *)&cmd_tx_vlan_set_portid,
4209 (void *)&cmd_tx_vlan_set_vlanid,
4214 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4215 struct cmd_tx_vlan_set_qinq_result {
4216 cmdline_fixed_string_t tx_vlan;
4217 cmdline_fixed_string_t set;
4220 uint16_t vlan_id_outer;
4224 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4225 __attribute__((unused)) struct cmdline *cl,
4226 __attribute__((unused)) void *data)
4228 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4230 if (!port_is_stopped(res->port_id)) {
4231 printf("Please stop port %d first\n", res->port_id);
4235 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4237 cmd_reconfig_device_queue(res->port_id, 1, 1);
4240 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4241 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4242 tx_vlan, "tx_vlan");
4243 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4244 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4246 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4247 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4249 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4250 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4252 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4253 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4254 vlan_id_outer, UINT16);
4256 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4257 .f = cmd_tx_vlan_set_qinq_parsed,
4259 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4260 "Enable hardware insertion of double VLAN header "
4261 "with given TAG Identifiers in packets sent on a port",
4263 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4264 (void *)&cmd_tx_vlan_set_qinq_set,
4265 (void *)&cmd_tx_vlan_set_qinq_portid,
4266 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4267 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4272 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4273 struct cmd_tx_vlan_set_pvid_result {
4274 cmdline_fixed_string_t tx_vlan;
4275 cmdline_fixed_string_t set;
4276 cmdline_fixed_string_t pvid;
4279 cmdline_fixed_string_t mode;
4283 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4284 __attribute__((unused)) struct cmdline *cl,
4285 __attribute__((unused)) void *data)
4287 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4289 if (strcmp(res->mode, "on") == 0)
4290 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4292 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4295 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4296 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4297 tx_vlan, "tx_vlan");
4298 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4299 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4301 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4302 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4304 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4305 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4307 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4308 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4310 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4311 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4314 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4315 .f = cmd_tx_vlan_set_pvid_parsed,
4317 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4319 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4320 (void *)&cmd_tx_vlan_set_pvid_set,
4321 (void *)&cmd_tx_vlan_set_pvid_pvid,
4322 (void *)&cmd_tx_vlan_set_pvid_port_id,
4323 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4324 (void *)&cmd_tx_vlan_set_pvid_mode,
4329 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4330 struct cmd_tx_vlan_reset_result {
4331 cmdline_fixed_string_t tx_vlan;
4332 cmdline_fixed_string_t reset;
4337 cmd_tx_vlan_reset_parsed(void *parsed_result,
4338 __attribute__((unused)) struct cmdline *cl,
4339 __attribute__((unused)) void *data)
4341 struct cmd_tx_vlan_reset_result *res = parsed_result;
4343 if (!port_is_stopped(res->port_id)) {
4344 printf("Please stop port %d first\n", res->port_id);
4348 tx_vlan_reset(res->port_id);
4350 cmd_reconfig_device_queue(res->port_id, 1, 1);
4353 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4354 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4355 tx_vlan, "tx_vlan");
4356 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4357 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4359 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4360 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4363 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4364 .f = cmd_tx_vlan_reset_parsed,
4366 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4367 "VLAN header in packets sent on a port",
4369 (void *)&cmd_tx_vlan_reset_tx_vlan,
4370 (void *)&cmd_tx_vlan_reset_reset,
4371 (void *)&cmd_tx_vlan_reset_portid,
4377 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4378 struct cmd_csum_result {
4379 cmdline_fixed_string_t csum;
4380 cmdline_fixed_string_t mode;
4381 cmdline_fixed_string_t proto;
4382 cmdline_fixed_string_t hwsw;
4387 csum_show(int port_id)
4389 struct rte_eth_dev_info dev_info;
4390 uint64_t tx_offloads;
4393 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4394 printf("Parse tunnel is %s\n",
4395 (ports[port_id].parse_tunnel) ? "on" : "off");
4396 printf("IP checksum offload is %s\n",
4397 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4398 printf("UDP checksum offload is %s\n",
4399 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4400 printf("TCP checksum offload is %s\n",
4401 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4402 printf("SCTP checksum offload is %s\n",
4403 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4404 printf("Outer-Ip checksum offload is %s\n",
4405 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4406 printf("Outer-Udp checksum offload is %s\n",
4407 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4409 /* display warnings if configuration is not supported by the NIC */
4410 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4414 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4415 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4416 printf("Warning: hardware IP checksum enabled but not "
4417 "supported by port %d\n", port_id);
4419 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4420 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4421 printf("Warning: hardware UDP checksum enabled but not "
4422 "supported by port %d\n", port_id);
4424 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4425 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4426 printf("Warning: hardware TCP checksum enabled but not "
4427 "supported by port %d\n", port_id);
4429 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4430 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4431 printf("Warning: hardware SCTP checksum enabled but not "
4432 "supported by port %d\n", port_id);
4434 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4435 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4436 printf("Warning: hardware outer IP checksum enabled but not "
4437 "supported by port %d\n", port_id);
4439 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4440 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4442 printf("Warning: hardware outer UDP checksum enabled but not "
4443 "supported by port %d\n", port_id);
4448 cmd_config_queue_tx_offloads(struct rte_port *port)
4452 /* Apply queue tx offloads configuration */
4453 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4454 port->tx_conf[k].offloads =
4455 port->dev_conf.txmode.offloads;
4459 cmd_csum_parsed(void *parsed_result,
4460 __attribute__((unused)) struct cmdline *cl,
4461 __attribute__((unused)) void *data)
4463 struct cmd_csum_result *res = parsed_result;
4465 uint64_t csum_offloads = 0;
4466 struct rte_eth_dev_info dev_info;
4469 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4470 printf("invalid port %d\n", res->port_id);
4473 if (!port_is_stopped(res->port_id)) {
4474 printf("Please stop port %d first\n", res->port_id);
4478 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4482 if (!strcmp(res->mode, "set")) {
4484 if (!strcmp(res->hwsw, "hw"))
4487 if (!strcmp(res->proto, "ip")) {
4488 if (hw == 0 || (dev_info.tx_offload_capa &
4489 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4490 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4492 printf("IP checksum offload is not supported "
4493 "by port %u\n", res->port_id);
4495 } else if (!strcmp(res->proto, "udp")) {
4496 if (hw == 0 || (dev_info.tx_offload_capa &
4497 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4498 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4500 printf("UDP checksum offload is not supported "
4501 "by port %u\n", res->port_id);
4503 } else if (!strcmp(res->proto, "tcp")) {
4504 if (hw == 0 || (dev_info.tx_offload_capa &
4505 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4506 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4508 printf("TCP checksum offload is not supported "
4509 "by port %u\n", res->port_id);
4511 } else if (!strcmp(res->proto, "sctp")) {
4512 if (hw == 0 || (dev_info.tx_offload_capa &
4513 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4514 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4516 printf("SCTP checksum offload is not supported "
4517 "by port %u\n", res->port_id);
4519 } else if (!strcmp(res->proto, "outer-ip")) {
4520 if (hw == 0 || (dev_info.tx_offload_capa &
4521 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4523 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4525 printf("Outer IP checksum offload is not "
4526 "supported by port %u\n", res->port_id);
4528 } else if (!strcmp(res->proto, "outer-udp")) {
4529 if (hw == 0 || (dev_info.tx_offload_capa &
4530 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4532 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4534 printf("Outer UDP checksum offload is not "
4535 "supported by port %u\n", res->port_id);
4540 ports[res->port_id].dev_conf.txmode.offloads |=
4543 ports[res->port_id].dev_conf.txmode.offloads &=
4546 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4548 csum_show(res->port_id);
4550 cmd_reconfig_device_queue(res->port_id, 1, 1);
4553 cmdline_parse_token_string_t cmd_csum_csum =
4554 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4556 cmdline_parse_token_string_t cmd_csum_mode =
4557 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4559 cmdline_parse_token_string_t cmd_csum_proto =
4560 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4561 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4562 cmdline_parse_token_string_t cmd_csum_hwsw =
4563 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4565 cmdline_parse_token_num_t cmd_csum_portid =
4566 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4569 cmdline_parse_inst_t cmd_csum_set = {
4570 .f = cmd_csum_parsed,
4572 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4573 "Enable/Disable hardware calculation of L3/L4 checksum when "
4574 "using csum forward engine",
4576 (void *)&cmd_csum_csum,
4577 (void *)&cmd_csum_mode,
4578 (void *)&cmd_csum_proto,
4579 (void *)&cmd_csum_hwsw,
4580 (void *)&cmd_csum_portid,
4585 cmdline_parse_token_string_t cmd_csum_mode_show =
4586 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4589 cmdline_parse_inst_t cmd_csum_show = {
4590 .f = cmd_csum_parsed,
4592 .help_str = "csum show <port_id>: Show checksum offload configuration",
4594 (void *)&cmd_csum_csum,
4595 (void *)&cmd_csum_mode_show,
4596 (void *)&cmd_csum_portid,
4601 /* Enable/disable tunnel parsing */
4602 struct cmd_csum_tunnel_result {
4603 cmdline_fixed_string_t csum;
4604 cmdline_fixed_string_t parse;
4605 cmdline_fixed_string_t onoff;
4610 cmd_csum_tunnel_parsed(void *parsed_result,
4611 __attribute__((unused)) struct cmdline *cl,
4612 __attribute__((unused)) void *data)
4614 struct cmd_csum_tunnel_result *res = parsed_result;
4616 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4619 if (!strcmp(res->onoff, "on"))
4620 ports[res->port_id].parse_tunnel = 1;
4622 ports[res->port_id].parse_tunnel = 0;
4624 csum_show(res->port_id);
4627 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4628 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4630 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4631 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4632 parse, "parse-tunnel");
4633 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4634 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4636 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4637 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4640 cmdline_parse_inst_t cmd_csum_tunnel = {
4641 .f = cmd_csum_tunnel_parsed,
4643 .help_str = "csum parse-tunnel on|off <port_id>: "
4644 "Enable/Disable parsing of tunnels for csum engine",
4646 (void *)&cmd_csum_tunnel_csum,
4647 (void *)&cmd_csum_tunnel_parse,
4648 (void *)&cmd_csum_tunnel_onoff,
4649 (void *)&cmd_csum_tunnel_portid,
4654 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4655 struct cmd_tso_set_result {
4656 cmdline_fixed_string_t tso;
4657 cmdline_fixed_string_t mode;
4663 cmd_tso_set_parsed(void *parsed_result,
4664 __attribute__((unused)) struct cmdline *cl,
4665 __attribute__((unused)) void *data)
4667 struct cmd_tso_set_result *res = parsed_result;
4668 struct rte_eth_dev_info dev_info;
4671 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4673 if (!port_is_stopped(res->port_id)) {
4674 printf("Please stop port %d first\n", res->port_id);
4678 if (!strcmp(res->mode, "set"))
4679 ports[res->port_id].tso_segsz = res->tso_segsz;
4681 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4685 if ((ports[res->port_id].tso_segsz != 0) &&
4686 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4687 printf("Error: TSO is not supported by port %d\n",
4692 if (ports[res->port_id].tso_segsz == 0) {
4693 ports[res->port_id].dev_conf.txmode.offloads &=
4694 ~DEV_TX_OFFLOAD_TCP_TSO;
4695 printf("TSO for non-tunneled packets is disabled\n");
4697 ports[res->port_id].dev_conf.txmode.offloads |=
4698 DEV_TX_OFFLOAD_TCP_TSO;
4699 printf("TSO segment size for non-tunneled packets is %d\n",
4700 ports[res->port_id].tso_segsz);
4702 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4704 /* display warnings if configuration is not supported by the NIC */
4705 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4709 if ((ports[res->port_id].tso_segsz != 0) &&
4710 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4711 printf("Warning: TSO enabled but not "
4712 "supported by port %d\n", res->port_id);
4715 cmd_reconfig_device_queue(res->port_id, 1, 1);
4718 cmdline_parse_token_string_t cmd_tso_set_tso =
4719 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4721 cmdline_parse_token_string_t cmd_tso_set_mode =
4722 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4724 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4725 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4727 cmdline_parse_token_num_t cmd_tso_set_portid =
4728 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4731 cmdline_parse_inst_t cmd_tso_set = {
4732 .f = cmd_tso_set_parsed,
4734 .help_str = "tso set <tso_segsz> <port_id>: "
4735 "Set TSO segment size of non-tunneled packets for csum engine "
4738 (void *)&cmd_tso_set_tso,
4739 (void *)&cmd_tso_set_mode,
4740 (void *)&cmd_tso_set_tso_segsz,
4741 (void *)&cmd_tso_set_portid,
4746 cmdline_parse_token_string_t cmd_tso_show_mode =
4747 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4751 cmdline_parse_inst_t cmd_tso_show = {
4752 .f = cmd_tso_set_parsed,
4754 .help_str = "tso show <port_id>: "
4755 "Show TSO segment size of non-tunneled packets for csum engine",
4757 (void *)&cmd_tso_set_tso,
4758 (void *)&cmd_tso_show_mode,
4759 (void *)&cmd_tso_set_portid,
4764 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4765 struct cmd_tunnel_tso_set_result {
4766 cmdline_fixed_string_t tso;
4767 cmdline_fixed_string_t mode;
4772 static struct rte_eth_dev_info
4773 check_tunnel_tso_nic_support(portid_t port_id)
4775 struct rte_eth_dev_info dev_info;
4777 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4780 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4781 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4782 "not enabled for port %d\n", port_id);
4783 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4784 printf("Warning: GRE TUNNEL TSO not supported therefore "
4785 "not enabled for port %d\n", port_id);
4786 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4787 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4788 "not enabled for port %d\n", port_id);
4789 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4790 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4791 "not enabled for port %d\n", port_id);
4792 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4793 printf("Warning: IP TUNNEL TSO not supported therefore "
4794 "not enabled for port %d\n", port_id);
4795 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4796 printf("Warning: UDP TUNNEL TSO not supported therefore "
4797 "not enabled for port %d\n", port_id);
4802 cmd_tunnel_tso_set_parsed(void *parsed_result,
4803 __attribute__((unused)) struct cmdline *cl,
4804 __attribute__((unused)) void *data)
4806 struct cmd_tunnel_tso_set_result *res = parsed_result;
4807 struct rte_eth_dev_info dev_info;
4809 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4811 if (!port_is_stopped(res->port_id)) {
4812 printf("Please stop port %d first\n", res->port_id);
4816 if (!strcmp(res->mode, "set"))
4817 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4819 dev_info = check_tunnel_tso_nic_support(res->port_id);
4820 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4821 ports[res->port_id].dev_conf.txmode.offloads &=
4822 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4823 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4824 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4825 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4826 DEV_TX_OFFLOAD_IP_TNL_TSO |
4827 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4828 printf("TSO for tunneled packets is disabled\n");
4830 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4831 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4832 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4833 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4834 DEV_TX_OFFLOAD_IP_TNL_TSO |
4835 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4837 ports[res->port_id].dev_conf.txmode.offloads |=
4838 (tso_offloads & dev_info.tx_offload_capa);
4839 printf("TSO segment size for tunneled packets is %d\n",
4840 ports[res->port_id].tunnel_tso_segsz);
4842 /* Below conditions are needed to make it work:
4843 * (1) tunnel TSO is supported by the NIC;
4844 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4846 * (3) for tunneled pkts with outer L3 of IPv4,
4847 * "csum set outer-ip" must be set to hw, because after tso,
4848 * total_len of outer IP header is changed, and the checksum
4849 * of outer IP header calculated by sw should be wrong; that
4850 * is not necessary for IPv6 tunneled pkts because there's no
4851 * checksum in IP header anymore.
4854 if (!ports[res->port_id].parse_tunnel)
4855 printf("Warning: csum parse_tunnel must be set "
4856 "so that tunneled packets are recognized\n");
4857 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4858 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4859 printf("Warning: csum set outer-ip must be set to hw "
4860 "if outer L3 is IPv4; not necessary for IPv6\n");
4863 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4864 cmd_reconfig_device_queue(res->port_id, 1, 1);
4867 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4868 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4870 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4871 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4873 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4874 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4876 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4877 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4880 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4881 .f = cmd_tunnel_tso_set_parsed,
4883 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4884 "Set TSO segment size of tunneled packets for csum engine "
4887 (void *)&cmd_tunnel_tso_set_tso,
4888 (void *)&cmd_tunnel_tso_set_mode,
4889 (void *)&cmd_tunnel_tso_set_tso_segsz,
4890 (void *)&cmd_tunnel_tso_set_portid,
4895 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4896 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4900 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4901 .f = cmd_tunnel_tso_set_parsed,
4903 .help_str = "tunnel_tso show <port_id> "
4904 "Show TSO segment size of tunneled packets for csum engine",
4906 (void *)&cmd_tunnel_tso_set_tso,
4907 (void *)&cmd_tunnel_tso_show_mode,
4908 (void *)&cmd_tunnel_tso_set_portid,
4913 /* *** SET GRO FOR A PORT *** */
4914 struct cmd_gro_enable_result {
4915 cmdline_fixed_string_t cmd_set;
4916 cmdline_fixed_string_t cmd_port;
4917 cmdline_fixed_string_t cmd_keyword;
4918 cmdline_fixed_string_t cmd_onoff;
4923 cmd_gro_enable_parsed(void *parsed_result,
4924 __attribute__((unused)) struct cmdline *cl,
4925 __attribute__((unused)) void *data)
4927 struct cmd_gro_enable_result *res;
4929 res = parsed_result;
4930 if (!strcmp(res->cmd_keyword, "gro"))
4931 setup_gro(res->cmd_onoff, res->cmd_pid);
4934 cmdline_parse_token_string_t cmd_gro_enable_set =
4935 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4937 cmdline_parse_token_string_t cmd_gro_enable_port =
4938 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4939 cmd_keyword, "port");
4940 cmdline_parse_token_num_t cmd_gro_enable_pid =
4941 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4943 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4944 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4945 cmd_keyword, "gro");
4946 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4947 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4948 cmd_onoff, "on#off");
4950 cmdline_parse_inst_t cmd_gro_enable = {
4951 .f = cmd_gro_enable_parsed,
4953 .help_str = "set port <port_id> gro on|off",
4955 (void *)&cmd_gro_enable_set,
4956 (void *)&cmd_gro_enable_port,
4957 (void *)&cmd_gro_enable_pid,
4958 (void *)&cmd_gro_enable_keyword,
4959 (void *)&cmd_gro_enable_onoff,
4964 /* *** DISPLAY GRO CONFIGURATION *** */
4965 struct cmd_gro_show_result {
4966 cmdline_fixed_string_t cmd_show;
4967 cmdline_fixed_string_t cmd_port;
4968 cmdline_fixed_string_t cmd_keyword;
4973 cmd_gro_show_parsed(void *parsed_result,
4974 __attribute__((unused)) struct cmdline *cl,
4975 __attribute__((unused)) void *data)
4977 struct cmd_gro_show_result *res;
4979 res = parsed_result;
4980 if (!strcmp(res->cmd_keyword, "gro"))
4981 show_gro(res->cmd_pid);
4984 cmdline_parse_token_string_t cmd_gro_show_show =
4985 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4987 cmdline_parse_token_string_t cmd_gro_show_port =
4988 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4990 cmdline_parse_token_num_t cmd_gro_show_pid =
4991 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4993 cmdline_parse_token_string_t cmd_gro_show_keyword =
4994 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4995 cmd_keyword, "gro");
4997 cmdline_parse_inst_t cmd_gro_show = {
4998 .f = cmd_gro_show_parsed,
5000 .help_str = "show port <port_id> gro",
5002 (void *)&cmd_gro_show_show,
5003 (void *)&cmd_gro_show_port,
5004 (void *)&cmd_gro_show_pid,
5005 (void *)&cmd_gro_show_keyword,
5010 /* *** SET FLUSH CYCLES FOR GRO *** */
5011 struct cmd_gro_flush_result {
5012 cmdline_fixed_string_t cmd_set;
5013 cmdline_fixed_string_t cmd_keyword;
5014 cmdline_fixed_string_t cmd_flush;
5019 cmd_gro_flush_parsed(void *parsed_result,
5020 __attribute__((unused)) struct cmdline *cl,
5021 __attribute__((unused)) void *data)
5023 struct cmd_gro_flush_result *res;
5025 res = parsed_result;
5026 if ((!strcmp(res->cmd_keyword, "gro")) &&
5027 (!strcmp(res->cmd_flush, "flush")))
5028 setup_gro_flush_cycles(res->cmd_cycles);
5031 cmdline_parse_token_string_t cmd_gro_flush_set =
5032 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5034 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5035 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5036 cmd_keyword, "gro");
5037 cmdline_parse_token_string_t cmd_gro_flush_flush =
5038 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5039 cmd_flush, "flush");
5040 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5041 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5044 cmdline_parse_inst_t cmd_gro_flush = {
5045 .f = cmd_gro_flush_parsed,
5047 .help_str = "set gro flush <cycles>",
5049 (void *)&cmd_gro_flush_set,
5050 (void *)&cmd_gro_flush_keyword,
5051 (void *)&cmd_gro_flush_flush,
5052 (void *)&cmd_gro_flush_cycles,
5057 /* *** ENABLE/DISABLE GSO *** */
5058 struct cmd_gso_enable_result {
5059 cmdline_fixed_string_t cmd_set;
5060 cmdline_fixed_string_t cmd_port;
5061 cmdline_fixed_string_t cmd_keyword;
5062 cmdline_fixed_string_t cmd_mode;
5067 cmd_gso_enable_parsed(void *parsed_result,
5068 __attribute__((unused)) struct cmdline *cl,
5069 __attribute__((unused)) void *data)
5071 struct cmd_gso_enable_result *res;
5073 res = parsed_result;
5074 if (!strcmp(res->cmd_keyword, "gso"))
5075 setup_gso(res->cmd_mode, res->cmd_pid);
5078 cmdline_parse_token_string_t cmd_gso_enable_set =
5079 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5081 cmdline_parse_token_string_t cmd_gso_enable_port =
5082 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5084 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5085 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5086 cmd_keyword, "gso");
5087 cmdline_parse_token_string_t cmd_gso_enable_mode =
5088 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5089 cmd_mode, "on#off");
5090 cmdline_parse_token_num_t cmd_gso_enable_pid =
5091 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5094 cmdline_parse_inst_t cmd_gso_enable = {
5095 .f = cmd_gso_enable_parsed,
5097 .help_str = "set port <port_id> gso on|off",
5099 (void *)&cmd_gso_enable_set,
5100 (void *)&cmd_gso_enable_port,
5101 (void *)&cmd_gso_enable_pid,
5102 (void *)&cmd_gso_enable_keyword,
5103 (void *)&cmd_gso_enable_mode,
5108 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5109 struct cmd_gso_size_result {
5110 cmdline_fixed_string_t cmd_set;
5111 cmdline_fixed_string_t cmd_keyword;
5112 cmdline_fixed_string_t cmd_segsz;
5117 cmd_gso_size_parsed(void *parsed_result,
5118 __attribute__((unused)) struct cmdline *cl,
5119 __attribute__((unused)) void *data)
5121 struct cmd_gso_size_result *res = parsed_result;
5123 if (test_done == 0) {
5124 printf("Before setting GSO segsz, please first"
5125 " stop fowarding\n");
5129 if (!strcmp(res->cmd_keyword, "gso") &&
5130 !strcmp(res->cmd_segsz, "segsz")) {
5131 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5132 printf("gso_size should be larger than %zu."
5133 " Please input a legal value\n",
5134 RTE_GSO_SEG_SIZE_MIN);
5136 gso_max_segment_size = res->cmd_size;
5140 cmdline_parse_token_string_t cmd_gso_size_set =
5141 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5143 cmdline_parse_token_string_t cmd_gso_size_keyword =
5144 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5145 cmd_keyword, "gso");
5146 cmdline_parse_token_string_t cmd_gso_size_segsz =
5147 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5148 cmd_segsz, "segsz");
5149 cmdline_parse_token_num_t cmd_gso_size_size =
5150 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5153 cmdline_parse_inst_t cmd_gso_size = {
5154 .f = cmd_gso_size_parsed,
5156 .help_str = "set gso segsz <length>",
5158 (void *)&cmd_gso_size_set,
5159 (void *)&cmd_gso_size_keyword,
5160 (void *)&cmd_gso_size_segsz,
5161 (void *)&cmd_gso_size_size,
5166 /* *** SHOW GSO CONFIGURATION *** */
5167 struct cmd_gso_show_result {
5168 cmdline_fixed_string_t cmd_show;
5169 cmdline_fixed_string_t cmd_port;
5170 cmdline_fixed_string_t cmd_keyword;
5175 cmd_gso_show_parsed(void *parsed_result,
5176 __attribute__((unused)) struct cmdline *cl,
5177 __attribute__((unused)) void *data)
5179 struct cmd_gso_show_result *res = parsed_result;
5181 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5182 printf("invalid port id %u\n", res->cmd_pid);
5185 if (!strcmp(res->cmd_keyword, "gso")) {
5186 if (gso_ports[res->cmd_pid].enable) {
5187 printf("Max GSO'd packet size: %uB\n"
5188 "Supported GSO types: TCP/IPv4, "
5189 "UDP/IPv4, VxLAN with inner "
5190 "TCP/IPv4 packet, GRE with inner "
5191 "TCP/IPv4 packet\n",
5192 gso_max_segment_size);
5194 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5198 cmdline_parse_token_string_t cmd_gso_show_show =
5199 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5201 cmdline_parse_token_string_t cmd_gso_show_port =
5202 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5204 cmdline_parse_token_string_t cmd_gso_show_keyword =
5205 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5206 cmd_keyword, "gso");
5207 cmdline_parse_token_num_t cmd_gso_show_pid =
5208 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5211 cmdline_parse_inst_t cmd_gso_show = {
5212 .f = cmd_gso_show_parsed,
5214 .help_str = "show port <port_id> gso",
5216 (void *)&cmd_gso_show_show,
5217 (void *)&cmd_gso_show_port,
5218 (void *)&cmd_gso_show_pid,
5219 (void *)&cmd_gso_show_keyword,
5224 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5225 struct cmd_set_flush_rx {
5226 cmdline_fixed_string_t set;
5227 cmdline_fixed_string_t flush_rx;
5228 cmdline_fixed_string_t mode;
5232 cmd_set_flush_rx_parsed(void *parsed_result,
5233 __attribute__((unused)) struct cmdline *cl,
5234 __attribute__((unused)) void *data)
5236 struct cmd_set_flush_rx *res = parsed_result;
5237 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5240 cmdline_parse_token_string_t cmd_setflushrx_set =
5241 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5243 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5244 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5245 flush_rx, "flush_rx");
5246 cmdline_parse_token_string_t cmd_setflushrx_mode =
5247 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5251 cmdline_parse_inst_t cmd_set_flush_rx = {
5252 .f = cmd_set_flush_rx_parsed,
5253 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5256 (void *)&cmd_setflushrx_set,
5257 (void *)&cmd_setflushrx_flush_rx,
5258 (void *)&cmd_setflushrx_mode,
5263 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5264 struct cmd_set_link_check {
5265 cmdline_fixed_string_t set;
5266 cmdline_fixed_string_t link_check;
5267 cmdline_fixed_string_t mode;
5271 cmd_set_link_check_parsed(void *parsed_result,
5272 __attribute__((unused)) struct cmdline *cl,
5273 __attribute__((unused)) void *data)
5275 struct cmd_set_link_check *res = parsed_result;
5276 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5279 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5280 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5282 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5283 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5284 link_check, "link_check");
5285 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5286 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5290 cmdline_parse_inst_t cmd_set_link_check = {
5291 .f = cmd_set_link_check_parsed,
5292 .help_str = "set link_check on|off: Enable/Disable link status check "
5293 "when starting/stopping a port",
5296 (void *)&cmd_setlinkcheck_set,
5297 (void *)&cmd_setlinkcheck_link_check,
5298 (void *)&cmd_setlinkcheck_mode,
5303 /* *** SET NIC BYPASS MODE *** */
5304 struct cmd_set_bypass_mode_result {
5305 cmdline_fixed_string_t set;
5306 cmdline_fixed_string_t bypass;
5307 cmdline_fixed_string_t mode;
5308 cmdline_fixed_string_t value;
5313 cmd_set_bypass_mode_parsed(void *parsed_result,
5314 __attribute__((unused)) struct cmdline *cl,
5315 __attribute__((unused)) void *data)
5317 struct cmd_set_bypass_mode_result *res = parsed_result;
5318 portid_t port_id = res->port_id;
5319 int32_t rc = -EINVAL;
5321 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5322 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5324 if (!strcmp(res->value, "bypass"))
5325 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5326 else if (!strcmp(res->value, "isolate"))
5327 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5329 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5331 /* Set the bypass mode for the relevant port. */
5332 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5335 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5338 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5339 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5341 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5342 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5344 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5345 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5347 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5348 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5349 value, "normal#bypass#isolate");
5350 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5351 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5354 cmdline_parse_inst_t cmd_set_bypass_mode = {
5355 .f = cmd_set_bypass_mode_parsed,
5356 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5357 "Set the NIC bypass mode for port_id",
5360 (void *)&cmd_setbypass_mode_set,
5361 (void *)&cmd_setbypass_mode_bypass,
5362 (void *)&cmd_setbypass_mode_mode,
5363 (void *)&cmd_setbypass_mode_value,
5364 (void *)&cmd_setbypass_mode_port,
5369 /* *** SET NIC BYPASS EVENT *** */
5370 struct cmd_set_bypass_event_result {
5371 cmdline_fixed_string_t set;
5372 cmdline_fixed_string_t bypass;
5373 cmdline_fixed_string_t event;
5374 cmdline_fixed_string_t event_value;
5375 cmdline_fixed_string_t mode;
5376 cmdline_fixed_string_t mode_value;
5381 cmd_set_bypass_event_parsed(void *parsed_result,
5382 __attribute__((unused)) struct cmdline *cl,
5383 __attribute__((unused)) void *data)
5385 int32_t rc = -EINVAL;
5386 struct cmd_set_bypass_event_result *res = parsed_result;
5387 portid_t port_id = res->port_id;
5389 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5390 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5391 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5393 if (!strcmp(res->event_value, "timeout"))
5394 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5395 else if (!strcmp(res->event_value, "os_on"))
5396 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5397 else if (!strcmp(res->event_value, "os_off"))
5398 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5399 else if (!strcmp(res->event_value, "power_on"))
5400 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5401 else if (!strcmp(res->event_value, "power_off"))
5402 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5404 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5406 if (!strcmp(res->mode_value, "bypass"))
5407 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5408 else if (!strcmp(res->mode_value, "isolate"))
5409 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5411 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5413 /* Set the watchdog timeout. */
5414 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5417 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5418 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5422 printf("Failed to set timeout value %u "
5423 "for port %d, errto code: %d.\n",
5424 bypass_timeout, port_id, rc);
5428 /* Set the bypass event to transition to bypass mode. */
5429 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5434 printf("\t Failed to set bypass event for port = %d.\n",
5438 cmdline_parse_token_string_t cmd_setbypass_event_set =
5439 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5441 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5442 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5444 cmdline_parse_token_string_t cmd_setbypass_event_event =
5445 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5447 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5448 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5449 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5450 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5451 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5453 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5454 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5455 mode_value, "normal#bypass#isolate");
5456 cmdline_parse_token_num_t cmd_setbypass_event_port =
5457 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5460 cmdline_parse_inst_t cmd_set_bypass_event = {
5461 .f = cmd_set_bypass_event_parsed,
5462 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5463 "power_off mode normal|bypass|isolate <port_id>: "
5464 "Set the NIC bypass event mode for port_id",
5467 (void *)&cmd_setbypass_event_set,
5468 (void *)&cmd_setbypass_event_bypass,
5469 (void *)&cmd_setbypass_event_event,
5470 (void *)&cmd_setbypass_event_event_value,
5471 (void *)&cmd_setbypass_event_mode,
5472 (void *)&cmd_setbypass_event_mode_value,
5473 (void *)&cmd_setbypass_event_port,
5479 /* *** SET NIC BYPASS TIMEOUT *** */
5480 struct cmd_set_bypass_timeout_result {
5481 cmdline_fixed_string_t set;
5482 cmdline_fixed_string_t bypass;
5483 cmdline_fixed_string_t timeout;
5484 cmdline_fixed_string_t value;
5488 cmd_set_bypass_timeout_parsed(void *parsed_result,
5489 __attribute__((unused)) struct cmdline *cl,
5490 __attribute__((unused)) void *data)
5492 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5494 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5495 if (!strcmp(res->value, "1.5"))
5496 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5497 else if (!strcmp(res->value, "2"))
5498 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5499 else if (!strcmp(res->value, "3"))
5500 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5501 else if (!strcmp(res->value, "4"))
5502 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5503 else if (!strcmp(res->value, "8"))
5504 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5505 else if (!strcmp(res->value, "16"))
5506 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5507 else if (!strcmp(res->value, "32"))
5508 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5510 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5514 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5515 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5517 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5518 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5520 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5521 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5522 timeout, "timeout");
5523 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5524 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5525 value, "0#1.5#2#3#4#8#16#32");
5527 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5528 .f = cmd_set_bypass_timeout_parsed,
5529 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5530 "Set the NIC bypass watchdog timeout in seconds",
5533 (void *)&cmd_setbypass_timeout_set,
5534 (void *)&cmd_setbypass_timeout_bypass,
5535 (void *)&cmd_setbypass_timeout_timeout,
5536 (void *)&cmd_setbypass_timeout_value,
5541 /* *** SHOW NIC BYPASS MODE *** */
5542 struct cmd_show_bypass_config_result {
5543 cmdline_fixed_string_t show;
5544 cmdline_fixed_string_t bypass;
5545 cmdline_fixed_string_t config;
5550 cmd_show_bypass_config_parsed(void *parsed_result,
5551 __attribute__((unused)) struct cmdline *cl,
5552 __attribute__((unused)) void *data)
5554 struct cmd_show_bypass_config_result *res = parsed_result;
5555 portid_t port_id = res->port_id;
5557 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5558 uint32_t event_mode;
5559 uint32_t bypass_mode;
5560 uint32_t timeout = bypass_timeout;
5563 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5564 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5565 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5566 {"UNKNOWN", "normal", "bypass", "isolate"};
5567 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5574 int num_events = (sizeof events) / (sizeof events[0]);
5576 /* Display the bypass mode.*/
5577 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5578 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5582 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5583 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5585 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5588 /* Display the bypass timeout.*/
5589 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5590 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5592 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5594 /* Display the bypass events and associated modes. */
5595 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5597 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5598 printf("\tFailed to get bypass mode for event = %s\n",
5601 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5602 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5604 printf("\tbypass event: %-16s = %s\n", events[i],
5610 printf("\tFailed to get bypass configuration for port = %d\n",
5614 cmdline_parse_token_string_t cmd_showbypass_config_show =
5615 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5617 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5618 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5620 cmdline_parse_token_string_t cmd_showbypass_config_config =
5621 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5623 cmdline_parse_token_num_t cmd_showbypass_config_port =
5624 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5627 cmdline_parse_inst_t cmd_show_bypass_config = {
5628 .f = cmd_show_bypass_config_parsed,
5629 .help_str = "show bypass config <port_id>: "
5630 "Show the NIC bypass config for port_id",
5633 (void *)&cmd_showbypass_config_show,
5634 (void *)&cmd_showbypass_config_bypass,
5635 (void *)&cmd_showbypass_config_config,
5636 (void *)&cmd_showbypass_config_port,
5641 #ifdef RTE_LIBRTE_PMD_BOND
5642 /* *** SET BONDING MODE *** */
5643 struct cmd_set_bonding_mode_result {
5644 cmdline_fixed_string_t set;
5645 cmdline_fixed_string_t bonding;
5646 cmdline_fixed_string_t mode;
5651 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5652 __attribute__((unused)) struct cmdline *cl,
5653 __attribute__((unused)) void *data)
5655 struct cmd_set_bonding_mode_result *res = parsed_result;
5656 portid_t port_id = res->port_id;
5658 /* Set the bonding mode for the relevant port. */
5659 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5660 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5663 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5664 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5666 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5667 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5668 bonding, "bonding");
5669 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5670 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5672 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5673 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5675 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5676 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5679 cmdline_parse_inst_t cmd_set_bonding_mode = {
5680 .f = cmd_set_bonding_mode_parsed,
5681 .help_str = "set bonding mode <mode_value> <port_id>: "
5682 "Set the bonding mode for port_id",
5685 (void *) &cmd_setbonding_mode_set,
5686 (void *) &cmd_setbonding_mode_bonding,
5687 (void *) &cmd_setbonding_mode_mode,
5688 (void *) &cmd_setbonding_mode_value,
5689 (void *) &cmd_setbonding_mode_port,
5694 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5695 struct cmd_set_bonding_lacp_dedicated_queues_result {
5696 cmdline_fixed_string_t set;
5697 cmdline_fixed_string_t bonding;
5698 cmdline_fixed_string_t lacp;
5699 cmdline_fixed_string_t dedicated_queues;
5701 cmdline_fixed_string_t mode;
5704 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5705 __attribute__((unused)) struct cmdline *cl,
5706 __attribute__((unused)) void *data)
5708 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5709 portid_t port_id = res->port_id;
5710 struct rte_port *port;
5712 port = &ports[port_id];
5714 /** Check if the port is not started **/
5715 if (port->port_status != RTE_PORT_STOPPED) {
5716 printf("Please stop port %d first\n", port_id);
5720 if (!strcmp(res->mode, "enable")) {
5721 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5722 printf("Dedicate queues for LACP control packets"
5725 printf("Enabling dedicate queues for LACP control "
5726 "packets on port %d failed\n", port_id);
5727 } else if (!strcmp(res->mode, "disable")) {
5728 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5729 printf("Dedicated queues for LACP control packets "
5732 printf("Disabling dedicated queues for LACP control "
5733 "traffic on port %d failed\n", port_id);
5737 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5738 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5740 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5741 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5742 bonding, "bonding");
5743 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5744 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5746 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5747 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5748 dedicated_queues, "dedicated_queues");
5749 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5750 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5752 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5753 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5754 mode, "enable#disable");
5756 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5757 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5758 .help_str = "set bonding lacp dedicated_queues <port_id> "
5760 "Enable/disable dedicated queues for LACP control traffic for port_id",
5763 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5764 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5765 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5766 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5767 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5768 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5773 /* *** SET BALANCE XMIT POLICY *** */
5774 struct cmd_set_bonding_balance_xmit_policy_result {
5775 cmdline_fixed_string_t set;
5776 cmdline_fixed_string_t bonding;
5777 cmdline_fixed_string_t balance_xmit_policy;
5779 cmdline_fixed_string_t policy;
5782 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5783 __attribute__((unused)) struct cmdline *cl,
5784 __attribute__((unused)) void *data)
5786 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5787 portid_t port_id = res->port_id;
5790 if (!strcmp(res->policy, "l2")) {
5791 policy = BALANCE_XMIT_POLICY_LAYER2;
5792 } else if (!strcmp(res->policy, "l23")) {
5793 policy = BALANCE_XMIT_POLICY_LAYER23;
5794 } else if (!strcmp(res->policy, "l34")) {
5795 policy = BALANCE_XMIT_POLICY_LAYER34;
5797 printf("\t Invalid xmit policy selection");
5801 /* Set the bonding mode for the relevant port. */
5802 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5803 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5808 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5809 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5811 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5812 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5813 bonding, "bonding");
5814 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5815 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5816 balance_xmit_policy, "balance_xmit_policy");
5817 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5818 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5820 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5821 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5822 policy, "l2#l23#l34");
5824 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5825 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5826 .help_str = "set bonding balance_xmit_policy <port_id> "
5828 "Set the bonding balance_xmit_policy for port_id",
5831 (void *)&cmd_setbonding_balance_xmit_policy_set,
5832 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5833 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5834 (void *)&cmd_setbonding_balance_xmit_policy_port,
5835 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5840 /* *** SHOW NIC BONDING CONFIGURATION *** */
5841 struct cmd_show_bonding_config_result {
5842 cmdline_fixed_string_t show;
5843 cmdline_fixed_string_t bonding;
5844 cmdline_fixed_string_t config;
5848 static void cmd_show_bonding_config_parsed(void *parsed_result,
5849 __attribute__((unused)) struct cmdline *cl,
5850 __attribute__((unused)) void *data)
5852 struct cmd_show_bonding_config_result *res = parsed_result;
5853 int bonding_mode, agg_mode;
5854 portid_t slaves[RTE_MAX_ETHPORTS];
5855 int num_slaves, num_active_slaves;
5858 portid_t port_id = res->port_id;
5860 /* Display the bonding mode.*/
5861 bonding_mode = rte_eth_bond_mode_get(port_id);
5862 if (bonding_mode < 0) {
5863 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5866 printf("\tBonding mode: %d\n", bonding_mode);
5868 if (bonding_mode == BONDING_MODE_BALANCE) {
5869 int balance_xmit_policy;
5871 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5872 if (balance_xmit_policy < 0) {
5873 printf("\tFailed to get balance xmit policy for port = %d\n",
5877 printf("\tBalance Xmit Policy: ");
5879 switch (balance_xmit_policy) {
5880 case BALANCE_XMIT_POLICY_LAYER2:
5881 printf("BALANCE_XMIT_POLICY_LAYER2");
5883 case BALANCE_XMIT_POLICY_LAYER23:
5884 printf("BALANCE_XMIT_POLICY_LAYER23");
5886 case BALANCE_XMIT_POLICY_LAYER34:
5887 printf("BALANCE_XMIT_POLICY_LAYER34");
5894 if (bonding_mode == BONDING_MODE_8023AD) {
5895 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5896 printf("\tIEEE802.3AD Aggregator Mode: ");
5899 printf("bandwidth");
5911 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5913 if (num_slaves < 0) {
5914 printf("\tFailed to get slave list for port = %d\n", port_id);
5917 if (num_slaves > 0) {
5918 printf("\tSlaves (%d): [", num_slaves);
5919 for (i = 0; i < num_slaves - 1; i++)
5920 printf("%d ", slaves[i]);
5922 printf("%d]\n", slaves[num_slaves - 1]);
5924 printf("\tSlaves: []\n");
5928 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5931 if (num_active_slaves < 0) {
5932 printf("\tFailed to get active slave list for port = %d\n", port_id);
5935 if (num_active_slaves > 0) {
5936 printf("\tActive Slaves (%d): [", num_active_slaves);
5937 for (i = 0; i < num_active_slaves - 1; i++)
5938 printf("%d ", slaves[i]);
5940 printf("%d]\n", slaves[num_active_slaves - 1]);
5943 printf("\tActive Slaves: []\n");
5947 primary_id = rte_eth_bond_primary_get(port_id);
5948 if (primary_id < 0) {
5949 printf("\tFailed to get primary slave for port = %d\n", port_id);
5952 printf("\tPrimary: [%d]\n", primary_id);
5956 cmdline_parse_token_string_t cmd_showbonding_config_show =
5957 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5959 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5960 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5961 bonding, "bonding");
5962 cmdline_parse_token_string_t cmd_showbonding_config_config =
5963 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5965 cmdline_parse_token_num_t cmd_showbonding_config_port =
5966 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5969 cmdline_parse_inst_t cmd_show_bonding_config = {
5970 .f = cmd_show_bonding_config_parsed,
5971 .help_str = "show bonding config <port_id>: "
5972 "Show the bonding config for port_id",
5975 (void *)&cmd_showbonding_config_show,
5976 (void *)&cmd_showbonding_config_bonding,
5977 (void *)&cmd_showbonding_config_config,
5978 (void *)&cmd_showbonding_config_port,
5983 /* *** SET BONDING PRIMARY *** */
5984 struct cmd_set_bonding_primary_result {
5985 cmdline_fixed_string_t set;
5986 cmdline_fixed_string_t bonding;
5987 cmdline_fixed_string_t primary;
5992 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5993 __attribute__((unused)) struct cmdline *cl,
5994 __attribute__((unused)) void *data)
5996 struct cmd_set_bonding_primary_result *res = parsed_result;
5997 portid_t master_port_id = res->port_id;
5998 portid_t slave_port_id = res->slave_id;
6000 /* Set the primary slave for a bonded device. */
6001 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6002 printf("\t Failed to set primary slave for port = %d.\n",
6009 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6010 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6012 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6013 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6014 bonding, "bonding");
6015 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6016 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6017 primary, "primary");
6018 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6019 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6021 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6022 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6025 cmdline_parse_inst_t cmd_set_bonding_primary = {
6026 .f = cmd_set_bonding_primary_parsed,
6027 .help_str = "set bonding primary <slave_id> <port_id>: "
6028 "Set the primary slave for port_id",
6031 (void *)&cmd_setbonding_primary_set,
6032 (void *)&cmd_setbonding_primary_bonding,
6033 (void *)&cmd_setbonding_primary_primary,
6034 (void *)&cmd_setbonding_primary_slave,
6035 (void *)&cmd_setbonding_primary_port,
6040 /* *** ADD SLAVE *** */
6041 struct cmd_add_bonding_slave_result {
6042 cmdline_fixed_string_t add;
6043 cmdline_fixed_string_t bonding;
6044 cmdline_fixed_string_t slave;
6049 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6050 __attribute__((unused)) struct cmdline *cl,
6051 __attribute__((unused)) void *data)
6053 struct cmd_add_bonding_slave_result *res = parsed_result;
6054 portid_t master_port_id = res->port_id;
6055 portid_t slave_port_id = res->slave_id;
6057 /* add the slave for a bonded device. */
6058 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6059 printf("\t Failed to add slave %d to master port = %d.\n",
6060 slave_port_id, master_port_id);
6064 set_port_slave_flag(slave_port_id);
6067 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6068 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6070 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6071 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6072 bonding, "bonding");
6073 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6074 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6076 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6077 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6079 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6080 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6083 cmdline_parse_inst_t cmd_add_bonding_slave = {
6084 .f = cmd_add_bonding_slave_parsed,
6085 .help_str = "add bonding slave <slave_id> <port_id>: "
6086 "Add a slave device to a bonded device",
6089 (void *)&cmd_addbonding_slave_add,
6090 (void *)&cmd_addbonding_slave_bonding,
6091 (void *)&cmd_addbonding_slave_slave,
6092 (void *)&cmd_addbonding_slave_slaveid,
6093 (void *)&cmd_addbonding_slave_port,
6098 /* *** REMOVE SLAVE *** */
6099 struct cmd_remove_bonding_slave_result {
6100 cmdline_fixed_string_t remove;
6101 cmdline_fixed_string_t bonding;
6102 cmdline_fixed_string_t slave;
6107 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6108 __attribute__((unused)) struct cmdline *cl,
6109 __attribute__((unused)) void *data)
6111 struct cmd_remove_bonding_slave_result *res = parsed_result;
6112 portid_t master_port_id = res->port_id;
6113 portid_t slave_port_id = res->slave_id;
6115 /* remove the slave from a bonded device. */
6116 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6117 printf("\t Failed to remove slave %d from master port = %d.\n",
6118 slave_port_id, master_port_id);
6122 clear_port_slave_flag(slave_port_id);
6125 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6126 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6128 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6129 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6130 bonding, "bonding");
6131 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6132 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6134 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6135 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6137 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6138 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6141 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6142 .f = cmd_remove_bonding_slave_parsed,
6143 .help_str = "remove bonding slave <slave_id> <port_id>: "
6144 "Remove a slave device from a bonded device",
6147 (void *)&cmd_removebonding_slave_remove,
6148 (void *)&cmd_removebonding_slave_bonding,
6149 (void *)&cmd_removebonding_slave_slave,
6150 (void *)&cmd_removebonding_slave_slaveid,
6151 (void *)&cmd_removebonding_slave_port,
6156 /* *** CREATE BONDED DEVICE *** */
6157 struct cmd_create_bonded_device_result {
6158 cmdline_fixed_string_t create;
6159 cmdline_fixed_string_t bonded;
6160 cmdline_fixed_string_t device;
6165 static int bond_dev_num = 0;
6167 static void cmd_create_bonded_device_parsed(void *parsed_result,
6168 __attribute__((unused)) struct cmdline *cl,
6169 __attribute__((unused)) void *data)
6171 struct cmd_create_bonded_device_result *res = parsed_result;
6172 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6176 if (test_done == 0) {
6177 printf("Please stop forwarding first\n");
6181 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6184 /* Create a new bonded device. */
6185 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6187 printf("\t Failed to create bonded device.\n");
6190 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6193 /* Update number of ports */
6194 nb_ports = rte_eth_dev_count_avail();
6195 reconfig(port_id, res->socket);
6196 ret = rte_eth_promiscuous_enable(port_id);
6198 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6199 port_id, rte_strerror(-ret));
6201 ports[port_id].need_setup = 0;
6202 ports[port_id].port_status = RTE_PORT_STOPPED;
6207 cmdline_parse_token_string_t cmd_createbonded_device_create =
6208 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6210 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6211 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6213 cmdline_parse_token_string_t cmd_createbonded_device_device =
6214 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6216 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6217 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6219 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6220 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6223 cmdline_parse_inst_t cmd_create_bonded_device = {
6224 .f = cmd_create_bonded_device_parsed,
6225 .help_str = "create bonded device <mode> <socket>: "
6226 "Create a new bonded device with specific bonding mode and socket",
6229 (void *)&cmd_createbonded_device_create,
6230 (void *)&cmd_createbonded_device_bonded,
6231 (void *)&cmd_createbonded_device_device,
6232 (void *)&cmd_createbonded_device_mode,
6233 (void *)&cmd_createbonded_device_socket,
6238 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6239 struct cmd_set_bond_mac_addr_result {
6240 cmdline_fixed_string_t set;
6241 cmdline_fixed_string_t bonding;
6242 cmdline_fixed_string_t mac_addr;
6244 struct rte_ether_addr address;
6247 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6248 __attribute__((unused)) struct cmdline *cl,
6249 __attribute__((unused)) void *data)
6251 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6254 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6257 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6259 /* check the return value and print it if is < 0 */
6261 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6264 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6265 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6266 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6267 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6269 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6270 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6272 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6273 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6275 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6276 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6278 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6279 .f = cmd_set_bond_mac_addr_parsed,
6281 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6283 (void *)&cmd_set_bond_mac_addr_set,
6284 (void *)&cmd_set_bond_mac_addr_bonding,
6285 (void *)&cmd_set_bond_mac_addr_mac,
6286 (void *)&cmd_set_bond_mac_addr_portnum,
6287 (void *)&cmd_set_bond_mac_addr_addr,
6293 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6294 struct cmd_set_bond_mon_period_result {
6295 cmdline_fixed_string_t set;
6296 cmdline_fixed_string_t bonding;
6297 cmdline_fixed_string_t mon_period;
6302 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6303 __attribute__((unused)) struct cmdline *cl,
6304 __attribute__((unused)) void *data)
6306 struct cmd_set_bond_mon_period_result *res = parsed_result;
6309 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6311 /* check the return value and print it if is < 0 */
6313 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6316 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6317 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6319 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6320 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6321 bonding, "bonding");
6322 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6323 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6324 mon_period, "mon_period");
6325 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6326 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6328 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6329 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6332 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6333 .f = cmd_set_bond_mon_period_parsed,
6335 .help_str = "set bonding mon_period <port_id> <period_ms>",
6337 (void *)&cmd_set_bond_mon_period_set,
6338 (void *)&cmd_set_bond_mon_period_bonding,
6339 (void *)&cmd_set_bond_mon_period_mon_period,
6340 (void *)&cmd_set_bond_mon_period_portnum,
6341 (void *)&cmd_set_bond_mon_period_period_ms,
6348 struct cmd_set_bonding_agg_mode_policy_result {
6349 cmdline_fixed_string_t set;
6350 cmdline_fixed_string_t bonding;
6351 cmdline_fixed_string_t agg_mode;
6353 cmdline_fixed_string_t policy;
6358 cmd_set_bonding_agg_mode(void *parsed_result,
6359 __attribute__((unused)) struct cmdline *cl,
6360 __attribute__((unused)) void *data)
6362 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6363 uint8_t policy = AGG_BANDWIDTH;
6365 if (!strcmp(res->policy, "bandwidth"))
6366 policy = AGG_BANDWIDTH;
6367 else if (!strcmp(res->policy, "stable"))
6368 policy = AGG_STABLE;
6369 else if (!strcmp(res->policy, "count"))
6372 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6376 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6377 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6379 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6380 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6381 bonding, "bonding");
6383 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6384 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6385 agg_mode, "agg_mode");
6387 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6388 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6391 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6392 TOKEN_STRING_INITIALIZER(
6393 struct cmd_set_bonding_balance_xmit_policy_result,
6394 policy, "stable#bandwidth#count");
6396 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6397 .f = cmd_set_bonding_agg_mode,
6399 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6401 (void *)&cmd_set_bonding_agg_mode_set,
6402 (void *)&cmd_set_bonding_agg_mode_bonding,
6403 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6404 (void *)&cmd_set_bonding_agg_mode_portnum,
6405 (void *)&cmd_set_bonding_agg_mode_policy_string,
6411 #endif /* RTE_LIBRTE_PMD_BOND */
6413 /* *** SET FORWARDING MODE *** */
6414 struct cmd_set_fwd_mode_result {
6415 cmdline_fixed_string_t set;
6416 cmdline_fixed_string_t fwd;
6417 cmdline_fixed_string_t mode;
6420 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6421 __attribute__((unused)) struct cmdline *cl,
6422 __attribute__((unused)) void *data)
6424 struct cmd_set_fwd_mode_result *res = parsed_result;
6427 set_pkt_forwarding_mode(res->mode);
6430 cmdline_parse_token_string_t cmd_setfwd_set =
6431 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6432 cmdline_parse_token_string_t cmd_setfwd_fwd =
6433 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6434 cmdline_parse_token_string_t cmd_setfwd_mode =
6435 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6436 "" /* defined at init */);
6438 cmdline_parse_inst_t cmd_set_fwd_mode = {
6439 .f = cmd_set_fwd_mode_parsed,
6441 .help_str = NULL, /* defined at init */
6443 (void *)&cmd_setfwd_set,
6444 (void *)&cmd_setfwd_fwd,
6445 (void *)&cmd_setfwd_mode,
6450 static void cmd_set_fwd_mode_init(void)
6453 static char token[128];
6454 static char help[256];
6455 cmdline_parse_token_string_t *token_struct;
6457 modes = list_pkt_forwarding_modes();
6458 snprintf(help, sizeof(help), "set fwd %s: "
6459 "Set packet forwarding mode", modes);
6460 cmd_set_fwd_mode.help_str = help;
6462 /* string token separator is # */
6463 for (c = token; *modes != '\0'; modes++)
6468 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6469 token_struct->string_data.str = token;
6472 /* *** SET RETRY FORWARDING MODE *** */
6473 struct cmd_set_fwd_retry_mode_result {
6474 cmdline_fixed_string_t set;
6475 cmdline_fixed_string_t fwd;
6476 cmdline_fixed_string_t mode;
6477 cmdline_fixed_string_t retry;
6480 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6481 __attribute__((unused)) struct cmdline *cl,
6482 __attribute__((unused)) void *data)
6484 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6487 set_pkt_forwarding_mode(res->mode);
6490 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6491 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6493 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6494 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6496 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6497 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6499 "" /* defined at init */);
6500 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6501 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6504 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6505 .f = cmd_set_fwd_retry_mode_parsed,
6507 .help_str = NULL, /* defined at init */
6509 (void *)&cmd_setfwd_retry_set,
6510 (void *)&cmd_setfwd_retry_fwd,
6511 (void *)&cmd_setfwd_retry_mode,
6512 (void *)&cmd_setfwd_retry_retry,
6517 static void cmd_set_fwd_retry_mode_init(void)
6520 static char token[128];
6521 static char help[256];
6522 cmdline_parse_token_string_t *token_struct;
6524 modes = list_pkt_forwarding_retry_modes();
6525 snprintf(help, sizeof(help), "set fwd %s retry: "
6526 "Set packet forwarding mode with retry", modes);
6527 cmd_set_fwd_retry_mode.help_str = help;
6529 /* string token separator is # */
6530 for (c = token; *modes != '\0'; modes++)
6535 token_struct = (cmdline_parse_token_string_t *)
6536 cmd_set_fwd_retry_mode.tokens[2];
6537 token_struct->string_data.str = token;
6540 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6541 struct cmd_set_burst_tx_retry_result {
6542 cmdline_fixed_string_t set;
6543 cmdline_fixed_string_t burst;
6544 cmdline_fixed_string_t tx;
6545 cmdline_fixed_string_t delay;
6547 cmdline_fixed_string_t retry;
6551 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6552 __attribute__((unused)) struct cmdline *cl,
6553 __attribute__((unused)) void *data)
6555 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6557 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6558 && !strcmp(res->tx, "tx")) {
6559 if (!strcmp(res->delay, "delay"))
6560 burst_tx_delay_time = res->time;
6561 if (!strcmp(res->retry, "retry"))
6562 burst_tx_retry_num = res->retry_num;
6567 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6568 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6569 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6570 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6572 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6573 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6574 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6575 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6576 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6577 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6578 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6579 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6580 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6581 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6583 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6584 .f = cmd_set_burst_tx_retry_parsed,
6585 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6587 (void *)&cmd_set_burst_tx_retry_set,
6588 (void *)&cmd_set_burst_tx_retry_burst,
6589 (void *)&cmd_set_burst_tx_retry_tx,
6590 (void *)&cmd_set_burst_tx_retry_delay,
6591 (void *)&cmd_set_burst_tx_retry_time,
6592 (void *)&cmd_set_burst_tx_retry_retry,
6593 (void *)&cmd_set_burst_tx_retry_retry_num,
6598 /* *** SET PROMISC MODE *** */
6599 struct cmd_set_promisc_mode_result {
6600 cmdline_fixed_string_t set;
6601 cmdline_fixed_string_t promisc;
6602 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6603 uint16_t port_num; /* valid if "allports" argument == 0 */
6604 cmdline_fixed_string_t mode;
6607 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6608 __attribute__((unused)) struct cmdline *cl,
6611 struct cmd_set_promisc_mode_result *res = parsed_result;
6615 if (!strcmp(res->mode, "on"))
6622 RTE_ETH_FOREACH_DEV(i)
6623 eth_set_promisc_mode(i, enable);
6625 eth_set_promisc_mode(res->port_num, enable);
6629 cmdline_parse_token_string_t cmd_setpromisc_set =
6630 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6631 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6632 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6634 cmdline_parse_token_string_t cmd_setpromisc_portall =
6635 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6637 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6638 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6640 cmdline_parse_token_string_t cmd_setpromisc_mode =
6641 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6644 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6645 .f = cmd_set_promisc_mode_parsed,
6647 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6649 (void *)&cmd_setpromisc_set,
6650 (void *)&cmd_setpromisc_promisc,
6651 (void *)&cmd_setpromisc_portall,
6652 (void *)&cmd_setpromisc_mode,
6657 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6658 .f = cmd_set_promisc_mode_parsed,
6660 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6662 (void *)&cmd_setpromisc_set,
6663 (void *)&cmd_setpromisc_promisc,
6664 (void *)&cmd_setpromisc_portnum,
6665 (void *)&cmd_setpromisc_mode,
6670 /* *** SET ALLMULTI MODE *** */
6671 struct cmd_set_allmulti_mode_result {
6672 cmdline_fixed_string_t set;
6673 cmdline_fixed_string_t allmulti;
6674 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6675 uint16_t port_num; /* valid if "allports" argument == 0 */
6676 cmdline_fixed_string_t mode;
6679 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6680 __attribute__((unused)) struct cmdline *cl,
6683 struct cmd_set_allmulti_mode_result *res = parsed_result;
6687 if (!strcmp(res->mode, "on"))
6694 RTE_ETH_FOREACH_DEV(i) {
6695 eth_set_allmulticast_mode(i, enable);
6699 eth_set_allmulticast_mode(res->port_num, enable);
6703 cmdline_parse_token_string_t cmd_setallmulti_set =
6704 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6705 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6706 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6708 cmdline_parse_token_string_t cmd_setallmulti_portall =
6709 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6711 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6712 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6714 cmdline_parse_token_string_t cmd_setallmulti_mode =
6715 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6718 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6719 .f = cmd_set_allmulti_mode_parsed,
6721 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6723 (void *)&cmd_setallmulti_set,
6724 (void *)&cmd_setallmulti_allmulti,
6725 (void *)&cmd_setallmulti_portall,
6726 (void *)&cmd_setallmulti_mode,
6731 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6732 .f = cmd_set_allmulti_mode_parsed,
6734 .help_str = "set allmulti <port_id> on|off: "
6735 "Set allmulti mode on port_id",
6737 (void *)&cmd_setallmulti_set,
6738 (void *)&cmd_setallmulti_allmulti,
6739 (void *)&cmd_setallmulti_portnum,
6740 (void *)&cmd_setallmulti_mode,
6745 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6746 struct cmd_link_flow_ctrl_set_result {
6747 cmdline_fixed_string_t set;
6748 cmdline_fixed_string_t flow_ctrl;
6749 cmdline_fixed_string_t rx;
6750 cmdline_fixed_string_t rx_lfc_mode;
6751 cmdline_fixed_string_t tx;
6752 cmdline_fixed_string_t tx_lfc_mode;
6753 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6754 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6755 cmdline_fixed_string_t autoneg_str;
6756 cmdline_fixed_string_t autoneg;
6757 cmdline_fixed_string_t hw_str;
6758 uint32_t high_water;
6759 cmdline_fixed_string_t lw_str;
6761 cmdline_fixed_string_t pt_str;
6762 uint16_t pause_time;
6763 cmdline_fixed_string_t xon_str;
6768 cmdline_parse_token_string_t cmd_lfc_set_set =
6769 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6771 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6772 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6773 flow_ctrl, "flow_ctrl");
6774 cmdline_parse_token_string_t cmd_lfc_set_rx =
6775 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6777 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6778 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6779 rx_lfc_mode, "on#off");
6780 cmdline_parse_token_string_t cmd_lfc_set_tx =
6781 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6783 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6784 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6785 tx_lfc_mode, "on#off");
6786 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6787 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6788 hw_str, "high_water");
6789 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6790 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6791 high_water, UINT32);
6792 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6793 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6794 lw_str, "low_water");
6795 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6796 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6798 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6799 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6800 pt_str, "pause_time");
6801 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6802 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6803 pause_time, UINT16);
6804 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6805 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6806 xon_str, "send_xon");
6807 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6808 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6810 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6811 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6812 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6813 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6814 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6815 mac_ctrl_frame_fwd_mode, "on#off");
6816 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6817 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6818 autoneg_str, "autoneg");
6819 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6820 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6822 cmdline_parse_token_num_t cmd_lfc_set_portid =
6823 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6826 /* forward declaration */
6828 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6831 cmdline_parse_inst_t cmd_link_flow_control_set = {
6832 .f = cmd_link_flow_ctrl_set_parsed,
6834 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6835 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6836 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6838 (void *)&cmd_lfc_set_set,
6839 (void *)&cmd_lfc_set_flow_ctrl,
6840 (void *)&cmd_lfc_set_rx,
6841 (void *)&cmd_lfc_set_rx_mode,
6842 (void *)&cmd_lfc_set_tx,
6843 (void *)&cmd_lfc_set_tx_mode,
6844 (void *)&cmd_lfc_set_high_water,
6845 (void *)&cmd_lfc_set_low_water,
6846 (void *)&cmd_lfc_set_pause_time,
6847 (void *)&cmd_lfc_set_send_xon,
6848 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6849 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6850 (void *)&cmd_lfc_set_autoneg_str,
6851 (void *)&cmd_lfc_set_autoneg,
6852 (void *)&cmd_lfc_set_portid,
6857 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6858 .f = cmd_link_flow_ctrl_set_parsed,
6859 .data = (void *)&cmd_link_flow_control_set_rx,
6860 .help_str = "set flow_ctrl rx on|off <port_id>: "
6861 "Change rx flow control parameter",
6863 (void *)&cmd_lfc_set_set,
6864 (void *)&cmd_lfc_set_flow_ctrl,
6865 (void *)&cmd_lfc_set_rx,
6866 (void *)&cmd_lfc_set_rx_mode,
6867 (void *)&cmd_lfc_set_portid,
6872 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6873 .f = cmd_link_flow_ctrl_set_parsed,
6874 .data = (void *)&cmd_link_flow_control_set_tx,
6875 .help_str = "set flow_ctrl tx on|off <port_id>: "
6876 "Change tx flow control parameter",
6878 (void *)&cmd_lfc_set_set,
6879 (void *)&cmd_lfc_set_flow_ctrl,
6880 (void *)&cmd_lfc_set_tx,
6881 (void *)&cmd_lfc_set_tx_mode,
6882 (void *)&cmd_lfc_set_portid,
6887 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6888 .f = cmd_link_flow_ctrl_set_parsed,
6889 .data = (void *)&cmd_link_flow_control_set_hw,
6890 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6891 "Change high water flow control parameter",
6893 (void *)&cmd_lfc_set_set,
6894 (void *)&cmd_lfc_set_flow_ctrl,
6895 (void *)&cmd_lfc_set_high_water_str,
6896 (void *)&cmd_lfc_set_high_water,
6897 (void *)&cmd_lfc_set_portid,
6902 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6903 .f = cmd_link_flow_ctrl_set_parsed,
6904 .data = (void *)&cmd_link_flow_control_set_lw,
6905 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6906 "Change low water flow control parameter",
6908 (void *)&cmd_lfc_set_set,
6909 (void *)&cmd_lfc_set_flow_ctrl,
6910 (void *)&cmd_lfc_set_low_water_str,
6911 (void *)&cmd_lfc_set_low_water,
6912 (void *)&cmd_lfc_set_portid,
6917 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6918 .f = cmd_link_flow_ctrl_set_parsed,
6919 .data = (void *)&cmd_link_flow_control_set_pt,
6920 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6921 "Change pause time flow control parameter",
6923 (void *)&cmd_lfc_set_set,
6924 (void *)&cmd_lfc_set_flow_ctrl,
6925 (void *)&cmd_lfc_set_pause_time_str,
6926 (void *)&cmd_lfc_set_pause_time,
6927 (void *)&cmd_lfc_set_portid,
6932 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6933 .f = cmd_link_flow_ctrl_set_parsed,
6934 .data = (void *)&cmd_link_flow_control_set_xon,
6935 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6936 "Change send_xon flow control parameter",
6938 (void *)&cmd_lfc_set_set,
6939 (void *)&cmd_lfc_set_flow_ctrl,
6940 (void *)&cmd_lfc_set_send_xon_str,
6941 (void *)&cmd_lfc_set_send_xon,
6942 (void *)&cmd_lfc_set_portid,
6947 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6948 .f = cmd_link_flow_ctrl_set_parsed,
6949 .data = (void *)&cmd_link_flow_control_set_macfwd,
6950 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6951 "Change mac ctrl fwd flow control parameter",
6953 (void *)&cmd_lfc_set_set,
6954 (void *)&cmd_lfc_set_flow_ctrl,
6955 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6956 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6957 (void *)&cmd_lfc_set_portid,
6962 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6963 .f = cmd_link_flow_ctrl_set_parsed,
6964 .data = (void *)&cmd_link_flow_control_set_autoneg,
6965 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6966 "Change autoneg flow control parameter",
6968 (void *)&cmd_lfc_set_set,
6969 (void *)&cmd_lfc_set_flow_ctrl,
6970 (void *)&cmd_lfc_set_autoneg_str,
6971 (void *)&cmd_lfc_set_autoneg,
6972 (void *)&cmd_lfc_set_portid,
6978 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6979 __attribute__((unused)) struct cmdline *cl,
6982 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6983 cmdline_parse_inst_t *cmd = data;
6984 struct rte_eth_fc_conf fc_conf;
6990 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6991 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6992 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6993 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6995 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6996 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6999 /* Partial command line, retrieve current configuration */
7001 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7003 printf("cannot get current flow ctrl parameters, return"
7004 "code = %d\n", ret);
7008 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7009 (fc_conf.mode == RTE_FC_FULL))
7011 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7012 (fc_conf.mode == RTE_FC_FULL))
7016 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7017 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7019 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7020 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7022 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7024 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7025 fc_conf.high_water = res->high_water;
7027 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7028 fc_conf.low_water = res->low_water;
7030 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7031 fc_conf.pause_time = res->pause_time;
7033 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7034 fc_conf.send_xon = res->send_xon;
7036 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7037 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7038 fc_conf.mac_ctrl_frame_fwd = 1;
7040 fc_conf.mac_ctrl_frame_fwd = 0;
7043 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7044 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7046 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7048 printf("bad flow contrl parameter, return code = %d \n", ret);
7051 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7052 struct cmd_priority_flow_ctrl_set_result {
7053 cmdline_fixed_string_t set;
7054 cmdline_fixed_string_t pfc_ctrl;
7055 cmdline_fixed_string_t rx;
7056 cmdline_fixed_string_t rx_pfc_mode;
7057 cmdline_fixed_string_t tx;
7058 cmdline_fixed_string_t tx_pfc_mode;
7059 uint32_t high_water;
7061 uint16_t pause_time;
7067 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7068 __attribute__((unused)) struct cmdline *cl,
7069 __attribute__((unused)) void *data)
7071 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7072 struct rte_eth_pfc_conf pfc_conf;
7073 int rx_fc_enable, tx_fc_enable;
7077 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7078 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7079 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7080 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7082 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7083 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
7086 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7087 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7088 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7089 pfc_conf.fc.high_water = res->high_water;
7090 pfc_conf.fc.low_water = res->low_water;
7091 pfc_conf.fc.pause_time = res->pause_time;
7092 pfc_conf.priority = res->priority;
7094 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7096 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7099 cmdline_parse_token_string_t cmd_pfc_set_set =
7100 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7102 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7103 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7104 pfc_ctrl, "pfc_ctrl");
7105 cmdline_parse_token_string_t cmd_pfc_set_rx =
7106 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7108 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7109 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7110 rx_pfc_mode, "on#off");
7111 cmdline_parse_token_string_t cmd_pfc_set_tx =
7112 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7114 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7115 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7116 tx_pfc_mode, "on#off");
7117 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7118 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7119 high_water, UINT32);
7120 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7121 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7123 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7124 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7125 pause_time, UINT16);
7126 cmdline_parse_token_num_t cmd_pfc_set_priority =
7127 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7129 cmdline_parse_token_num_t cmd_pfc_set_portid =
7130 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7133 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7134 .f = cmd_priority_flow_ctrl_set_parsed,
7136 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7137 "<pause_time> <priority> <port_id>: "
7138 "Configure the Ethernet priority flow control",
7140 (void *)&cmd_pfc_set_set,
7141 (void *)&cmd_pfc_set_flow_ctrl,
7142 (void *)&cmd_pfc_set_rx,
7143 (void *)&cmd_pfc_set_rx_mode,
7144 (void *)&cmd_pfc_set_tx,
7145 (void *)&cmd_pfc_set_tx_mode,
7146 (void *)&cmd_pfc_set_high_water,
7147 (void *)&cmd_pfc_set_low_water,
7148 (void *)&cmd_pfc_set_pause_time,
7149 (void *)&cmd_pfc_set_priority,
7150 (void *)&cmd_pfc_set_portid,
7155 /* *** RESET CONFIGURATION *** */
7156 struct cmd_reset_result {
7157 cmdline_fixed_string_t reset;
7158 cmdline_fixed_string_t def;
7161 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
7163 __attribute__((unused)) void *data)
7165 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7166 set_def_fwd_config();
7169 cmdline_parse_token_string_t cmd_reset_set =
7170 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7171 cmdline_parse_token_string_t cmd_reset_def =
7172 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7175 cmdline_parse_inst_t cmd_reset = {
7176 .f = cmd_reset_parsed,
7178 .help_str = "set default: Reset default forwarding configuration",
7180 (void *)&cmd_reset_set,
7181 (void *)&cmd_reset_def,
7186 /* *** START FORWARDING *** */
7187 struct cmd_start_result {
7188 cmdline_fixed_string_t start;
7191 cmdline_parse_token_string_t cmd_start_start =
7192 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7194 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
7195 __attribute__((unused)) struct cmdline *cl,
7196 __attribute__((unused)) void *data)
7198 start_packet_forwarding(0);
7201 cmdline_parse_inst_t cmd_start = {
7202 .f = cmd_start_parsed,
7204 .help_str = "start: Start packet forwarding",
7206 (void *)&cmd_start_start,
7211 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7212 struct cmd_start_tx_first_result {
7213 cmdline_fixed_string_t start;
7214 cmdline_fixed_string_t tx_first;
7218 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
7219 __attribute__((unused)) struct cmdline *cl,
7220 __attribute__((unused)) void *data)
7222 start_packet_forwarding(1);
7225 cmdline_parse_token_string_t cmd_start_tx_first_start =
7226 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7228 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7229 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7230 tx_first, "tx_first");
7232 cmdline_parse_inst_t cmd_start_tx_first = {
7233 .f = cmd_start_tx_first_parsed,
7235 .help_str = "start tx_first: Start packet forwarding, "
7236 "after sending 1 burst of packets",
7238 (void *)&cmd_start_tx_first_start,
7239 (void *)&cmd_start_tx_first_tx_first,
7244 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7245 struct cmd_start_tx_first_n_result {
7246 cmdline_fixed_string_t start;
7247 cmdline_fixed_string_t tx_first;
7252 cmd_start_tx_first_n_parsed(void *parsed_result,
7253 __attribute__((unused)) struct cmdline *cl,
7254 __attribute__((unused)) void *data)
7256 struct cmd_start_tx_first_n_result *res = parsed_result;
7258 start_packet_forwarding(res->tx_num);
7261 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7262 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7264 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7265 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7266 tx_first, "tx_first");
7267 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7268 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7271 cmdline_parse_inst_t cmd_start_tx_first_n = {
7272 .f = cmd_start_tx_first_n_parsed,
7274 .help_str = "start tx_first <num>: "
7275 "packet forwarding, after sending <num> bursts of packets",
7277 (void *)&cmd_start_tx_first_n_start,
7278 (void *)&cmd_start_tx_first_n_tx_first,
7279 (void *)&cmd_start_tx_first_n_tx_num,
7284 /* *** SET LINK UP *** */
7285 struct cmd_set_link_up_result {
7286 cmdline_fixed_string_t set;
7287 cmdline_fixed_string_t link_up;
7288 cmdline_fixed_string_t port;
7292 cmdline_parse_token_string_t cmd_set_link_up_set =
7293 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7294 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7295 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7297 cmdline_parse_token_string_t cmd_set_link_up_port =
7298 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7299 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7300 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7302 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
7303 __attribute__((unused)) struct cmdline *cl,
7304 __attribute__((unused)) void *data)
7306 struct cmd_set_link_up_result *res = parsed_result;
7307 dev_set_link_up(res->port_id);
7310 cmdline_parse_inst_t cmd_set_link_up = {
7311 .f = cmd_set_link_up_parsed,
7313 .help_str = "set link-up port <port id>",
7315 (void *)&cmd_set_link_up_set,
7316 (void *)&cmd_set_link_up_link_up,
7317 (void *)&cmd_set_link_up_port,
7318 (void *)&cmd_set_link_up_port_id,
7323 /* *** SET LINK DOWN *** */
7324 struct cmd_set_link_down_result {
7325 cmdline_fixed_string_t set;
7326 cmdline_fixed_string_t link_down;
7327 cmdline_fixed_string_t port;
7331 cmdline_parse_token_string_t cmd_set_link_down_set =
7332 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7333 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7334 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7336 cmdline_parse_token_string_t cmd_set_link_down_port =
7337 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7338 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7339 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7341 static void cmd_set_link_down_parsed(
7342 __attribute__((unused)) void *parsed_result,
7343 __attribute__((unused)) struct cmdline *cl,
7344 __attribute__((unused)) void *data)
7346 struct cmd_set_link_down_result *res = parsed_result;
7347 dev_set_link_down(res->port_id);
7350 cmdline_parse_inst_t cmd_set_link_down = {
7351 .f = cmd_set_link_down_parsed,
7353 .help_str = "set link-down port <port id>",
7355 (void *)&cmd_set_link_down_set,
7356 (void *)&cmd_set_link_down_link_down,
7357 (void *)&cmd_set_link_down_port,
7358 (void *)&cmd_set_link_down_port_id,
7363 /* *** SHOW CFG *** */
7364 struct cmd_showcfg_result {
7365 cmdline_fixed_string_t show;
7366 cmdline_fixed_string_t cfg;
7367 cmdline_fixed_string_t what;
7370 static void cmd_showcfg_parsed(void *parsed_result,
7371 __attribute__((unused)) struct cmdline *cl,
7372 __attribute__((unused)) void *data)
7374 struct cmd_showcfg_result *res = parsed_result;
7375 if (!strcmp(res->what, "rxtx"))
7376 rxtx_config_display();
7377 else if (!strcmp(res->what, "cores"))
7378 fwd_lcores_config_display();
7379 else if (!strcmp(res->what, "fwd"))
7380 pkt_fwd_config_display(&cur_fwd_config);
7381 else if (!strcmp(res->what, "txpkts"))
7382 show_tx_pkt_segments();
7385 cmdline_parse_token_string_t cmd_showcfg_show =
7386 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7387 cmdline_parse_token_string_t cmd_showcfg_port =
7388 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7389 cmdline_parse_token_string_t cmd_showcfg_what =
7390 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7391 "rxtx#cores#fwd#txpkts");
7393 cmdline_parse_inst_t cmd_showcfg = {
7394 .f = cmd_showcfg_parsed,
7396 .help_str = "show config rxtx|cores|fwd|txpkts",
7398 (void *)&cmd_showcfg_show,
7399 (void *)&cmd_showcfg_port,
7400 (void *)&cmd_showcfg_what,
7405 /* *** SHOW ALL PORT INFO *** */
7406 struct cmd_showportall_result {
7407 cmdline_fixed_string_t show;
7408 cmdline_fixed_string_t port;
7409 cmdline_fixed_string_t what;
7410 cmdline_fixed_string_t all;
7413 static void cmd_showportall_parsed(void *parsed_result,
7414 __attribute__((unused)) struct cmdline *cl,
7415 __attribute__((unused)) void *data)
7419 struct cmd_showportall_result *res = parsed_result;
7420 if (!strcmp(res->show, "clear")) {
7421 if (!strcmp(res->what, "stats"))
7422 RTE_ETH_FOREACH_DEV(i)
7424 else if (!strcmp(res->what, "xstats"))
7425 RTE_ETH_FOREACH_DEV(i)
7426 nic_xstats_clear(i);
7427 } else if (!strcmp(res->what, "info"))
7428 RTE_ETH_FOREACH_DEV(i)
7429 port_infos_display(i);
7430 else if (!strcmp(res->what, "summary")) {
7431 port_summary_header_display();
7432 RTE_ETH_FOREACH_DEV(i)
7433 port_summary_display(i);
7435 else if (!strcmp(res->what, "stats"))
7436 RTE_ETH_FOREACH_DEV(i)
7437 nic_stats_display(i);
7438 else if (!strcmp(res->what, "xstats"))
7439 RTE_ETH_FOREACH_DEV(i)
7440 nic_xstats_display(i);
7441 else if (!strcmp(res->what, "fdir"))
7442 RTE_ETH_FOREACH_DEV(i)
7444 else if (!strcmp(res->what, "stat_qmap"))
7445 RTE_ETH_FOREACH_DEV(i)
7446 nic_stats_mapping_display(i);
7447 else if (!strcmp(res->what, "dcb_tc"))
7448 RTE_ETH_FOREACH_DEV(i)
7449 port_dcb_info_display(i);
7450 else if (!strcmp(res->what, "cap"))
7451 RTE_ETH_FOREACH_DEV(i)
7452 port_offload_cap_display(i);
7455 cmdline_parse_token_string_t cmd_showportall_show =
7456 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7458 cmdline_parse_token_string_t cmd_showportall_port =
7459 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7460 cmdline_parse_token_string_t cmd_showportall_what =
7461 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7462 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7463 cmdline_parse_token_string_t cmd_showportall_all =
7464 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7465 cmdline_parse_inst_t cmd_showportall = {
7466 .f = cmd_showportall_parsed,
7468 .help_str = "show|clear port "
7469 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7471 (void *)&cmd_showportall_show,
7472 (void *)&cmd_showportall_port,
7473 (void *)&cmd_showportall_what,
7474 (void *)&cmd_showportall_all,
7479 /* *** SHOW PORT INFO *** */
7480 struct cmd_showport_result {
7481 cmdline_fixed_string_t show;
7482 cmdline_fixed_string_t port;
7483 cmdline_fixed_string_t what;
7487 static void cmd_showport_parsed(void *parsed_result,
7488 __attribute__((unused)) struct cmdline *cl,
7489 __attribute__((unused)) void *data)
7491 struct cmd_showport_result *res = parsed_result;
7492 if (!strcmp(res->show, "clear")) {
7493 if (!strcmp(res->what, "stats"))
7494 nic_stats_clear(res->portnum);
7495 else if (!strcmp(res->what, "xstats"))
7496 nic_xstats_clear(res->portnum);
7497 } else if (!strcmp(res->what, "info"))
7498 port_infos_display(res->portnum);
7499 else if (!strcmp(res->what, "summary")) {
7500 port_summary_header_display();
7501 port_summary_display(res->portnum);
7503 else if (!strcmp(res->what, "stats"))
7504 nic_stats_display(res->portnum);
7505 else if (!strcmp(res->what, "xstats"))
7506 nic_xstats_display(res->portnum);
7507 else if (!strcmp(res->what, "fdir"))
7508 fdir_get_infos(res->portnum);
7509 else if (!strcmp(res->what, "stat_qmap"))
7510 nic_stats_mapping_display(res->portnum);
7511 else if (!strcmp(res->what, "dcb_tc"))
7512 port_dcb_info_display(res->portnum);
7513 else if (!strcmp(res->what, "cap"))
7514 port_offload_cap_display(res->portnum);
7517 cmdline_parse_token_string_t cmd_showport_show =
7518 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7520 cmdline_parse_token_string_t cmd_showport_port =
7521 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7522 cmdline_parse_token_string_t cmd_showport_what =
7523 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7524 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7525 cmdline_parse_token_num_t cmd_showport_portnum =
7526 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7528 cmdline_parse_inst_t cmd_showport = {
7529 .f = cmd_showport_parsed,
7531 .help_str = "show|clear port "
7532 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7535 (void *)&cmd_showport_show,
7536 (void *)&cmd_showport_port,
7537 (void *)&cmd_showport_what,
7538 (void *)&cmd_showport_portnum,
7543 /* *** SHOW DEVICE INFO *** */
7544 struct cmd_showdevice_result {
7545 cmdline_fixed_string_t show;
7546 cmdline_fixed_string_t device;
7547 cmdline_fixed_string_t what;
7548 cmdline_fixed_string_t identifier;
7551 static void cmd_showdevice_parsed(void *parsed_result,
7552 __attribute__((unused)) struct cmdline *cl,
7553 __attribute__((unused)) void *data)
7555 struct cmd_showdevice_result *res = parsed_result;
7556 if (!strcmp(res->what, "info")) {
7557 if (!strcmp(res->identifier, "all"))
7558 device_infos_display(NULL);
7560 device_infos_display(res->identifier);
7564 cmdline_parse_token_string_t cmd_showdevice_show =
7565 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7567 cmdline_parse_token_string_t cmd_showdevice_device =
7568 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7569 cmdline_parse_token_string_t cmd_showdevice_what =
7570 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7572 cmdline_parse_token_string_t cmd_showdevice_identifier =
7573 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7576 cmdline_parse_inst_t cmd_showdevice = {
7577 .f = cmd_showdevice_parsed,
7579 .help_str = "show device info <identifier>|all",
7581 (void *)&cmd_showdevice_show,
7582 (void *)&cmd_showdevice_device,
7583 (void *)&cmd_showdevice_what,
7584 (void *)&cmd_showdevice_identifier,
7588 /* *** SHOW QUEUE INFO *** */
7589 struct cmd_showqueue_result {
7590 cmdline_fixed_string_t show;
7591 cmdline_fixed_string_t type;
7592 cmdline_fixed_string_t what;
7598 cmd_showqueue_parsed(void *parsed_result,
7599 __attribute__((unused)) struct cmdline *cl,
7600 __attribute__((unused)) void *data)
7602 struct cmd_showqueue_result *res = parsed_result;
7604 if (!strcmp(res->type, "rxq"))
7605 rx_queue_infos_display(res->portnum, res->queuenum);
7606 else if (!strcmp(res->type, "txq"))
7607 tx_queue_infos_display(res->portnum, res->queuenum);
7610 cmdline_parse_token_string_t cmd_showqueue_show =
7611 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7612 cmdline_parse_token_string_t cmd_showqueue_type =
7613 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7614 cmdline_parse_token_string_t cmd_showqueue_what =
7615 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7616 cmdline_parse_token_num_t cmd_showqueue_portnum =
7617 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7618 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7619 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7621 cmdline_parse_inst_t cmd_showqueue = {
7622 .f = cmd_showqueue_parsed,
7624 .help_str = "show rxq|txq info <port_id> <queue_id>",
7626 (void *)&cmd_showqueue_show,
7627 (void *)&cmd_showqueue_type,
7628 (void *)&cmd_showqueue_what,
7629 (void *)&cmd_showqueue_portnum,
7630 (void *)&cmd_showqueue_queuenum,
7635 /* show/clear fwd engine statistics */
7637 cmdline_fixed_string_t action;
7638 cmdline_fixed_string_t fwd;
7639 cmdline_fixed_string_t stats;
7640 cmdline_fixed_string_t all;
7643 cmdline_parse_token_string_t cmd_fwd_action =
7644 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7645 cmdline_parse_token_string_t cmd_fwd_fwd =
7646 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7647 cmdline_parse_token_string_t cmd_fwd_stats =
7648 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7649 cmdline_parse_token_string_t cmd_fwd_all =
7650 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7653 cmd_showfwdall_parsed(void *parsed_result,
7654 __rte_unused struct cmdline *cl,
7655 __rte_unused void *data)
7657 struct fwd_result *res = parsed_result;
7659 if (!strcmp(res->action, "show"))
7660 fwd_stats_display();
7665 static cmdline_parse_inst_t cmd_showfwdall = {
7666 .f = cmd_showfwdall_parsed,
7668 .help_str = "show|clear fwd stats all",
7670 (void *)&cmd_fwd_action,
7671 (void *)&cmd_fwd_fwd,
7672 (void *)&cmd_fwd_stats,
7673 (void *)&cmd_fwd_all,
7678 /* *** READ PORT REGISTER *** */
7679 struct cmd_read_reg_result {
7680 cmdline_fixed_string_t read;
7681 cmdline_fixed_string_t reg;
7687 cmd_read_reg_parsed(void *parsed_result,
7688 __attribute__((unused)) struct cmdline *cl,
7689 __attribute__((unused)) void *data)
7691 struct cmd_read_reg_result *res = parsed_result;
7692 port_reg_display(res->port_id, res->reg_off);
7695 cmdline_parse_token_string_t cmd_read_reg_read =
7696 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7697 cmdline_parse_token_string_t cmd_read_reg_reg =
7698 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7699 cmdline_parse_token_num_t cmd_read_reg_port_id =
7700 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7701 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7702 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7704 cmdline_parse_inst_t cmd_read_reg = {
7705 .f = cmd_read_reg_parsed,
7707 .help_str = "read reg <port_id> <reg_off>",
7709 (void *)&cmd_read_reg_read,
7710 (void *)&cmd_read_reg_reg,
7711 (void *)&cmd_read_reg_port_id,
7712 (void *)&cmd_read_reg_reg_off,
7717 /* *** READ PORT REGISTER BIT FIELD *** */
7718 struct cmd_read_reg_bit_field_result {
7719 cmdline_fixed_string_t read;
7720 cmdline_fixed_string_t regfield;
7728 cmd_read_reg_bit_field_parsed(void *parsed_result,
7729 __attribute__((unused)) struct cmdline *cl,
7730 __attribute__((unused)) void *data)
7732 struct cmd_read_reg_bit_field_result *res = parsed_result;
7733 port_reg_bit_field_display(res->port_id, res->reg_off,
7734 res->bit1_pos, res->bit2_pos);
7737 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7738 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7740 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7741 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7742 regfield, "regfield");
7743 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7744 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7746 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7747 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7749 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7750 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7752 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7753 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7756 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7757 .f = cmd_read_reg_bit_field_parsed,
7759 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7760 "Read register bit field between bit_x and bit_y included",
7762 (void *)&cmd_read_reg_bit_field_read,
7763 (void *)&cmd_read_reg_bit_field_regfield,
7764 (void *)&cmd_read_reg_bit_field_port_id,
7765 (void *)&cmd_read_reg_bit_field_reg_off,
7766 (void *)&cmd_read_reg_bit_field_bit1_pos,
7767 (void *)&cmd_read_reg_bit_field_bit2_pos,
7772 /* *** READ PORT REGISTER BIT *** */
7773 struct cmd_read_reg_bit_result {
7774 cmdline_fixed_string_t read;
7775 cmdline_fixed_string_t regbit;
7782 cmd_read_reg_bit_parsed(void *parsed_result,
7783 __attribute__((unused)) struct cmdline *cl,
7784 __attribute__((unused)) void *data)
7786 struct cmd_read_reg_bit_result *res = parsed_result;
7787 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7790 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7791 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7792 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7793 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7795 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7796 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7797 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7798 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7799 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7800 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7802 cmdline_parse_inst_t cmd_read_reg_bit = {
7803 .f = cmd_read_reg_bit_parsed,
7805 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7807 (void *)&cmd_read_reg_bit_read,
7808 (void *)&cmd_read_reg_bit_regbit,
7809 (void *)&cmd_read_reg_bit_port_id,
7810 (void *)&cmd_read_reg_bit_reg_off,
7811 (void *)&cmd_read_reg_bit_bit_pos,
7816 /* *** WRITE PORT REGISTER *** */
7817 struct cmd_write_reg_result {
7818 cmdline_fixed_string_t write;
7819 cmdline_fixed_string_t reg;
7826 cmd_write_reg_parsed(void *parsed_result,
7827 __attribute__((unused)) struct cmdline *cl,
7828 __attribute__((unused)) void *data)
7830 struct cmd_write_reg_result *res = parsed_result;
7831 port_reg_set(res->port_id, res->reg_off, res->value);
7834 cmdline_parse_token_string_t cmd_write_reg_write =
7835 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7836 cmdline_parse_token_string_t cmd_write_reg_reg =
7837 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7838 cmdline_parse_token_num_t cmd_write_reg_port_id =
7839 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7840 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7841 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7842 cmdline_parse_token_num_t cmd_write_reg_value =
7843 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7845 cmdline_parse_inst_t cmd_write_reg = {
7846 .f = cmd_write_reg_parsed,
7848 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7850 (void *)&cmd_write_reg_write,
7851 (void *)&cmd_write_reg_reg,
7852 (void *)&cmd_write_reg_port_id,
7853 (void *)&cmd_write_reg_reg_off,
7854 (void *)&cmd_write_reg_value,
7859 /* *** WRITE PORT REGISTER BIT FIELD *** */
7860 struct cmd_write_reg_bit_field_result {
7861 cmdline_fixed_string_t write;
7862 cmdline_fixed_string_t regfield;
7871 cmd_write_reg_bit_field_parsed(void *parsed_result,
7872 __attribute__((unused)) struct cmdline *cl,
7873 __attribute__((unused)) void *data)
7875 struct cmd_write_reg_bit_field_result *res = parsed_result;
7876 port_reg_bit_field_set(res->port_id, res->reg_off,
7877 res->bit1_pos, res->bit2_pos, res->value);
7880 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7881 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7883 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7884 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7885 regfield, "regfield");
7886 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7887 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7889 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7890 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7892 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7893 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7895 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7896 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7898 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7899 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7902 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7903 .f = cmd_write_reg_bit_field_parsed,
7905 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7907 "Set register bit field between bit_x and bit_y included",
7909 (void *)&cmd_write_reg_bit_field_write,
7910 (void *)&cmd_write_reg_bit_field_regfield,
7911 (void *)&cmd_write_reg_bit_field_port_id,
7912 (void *)&cmd_write_reg_bit_field_reg_off,
7913 (void *)&cmd_write_reg_bit_field_bit1_pos,
7914 (void *)&cmd_write_reg_bit_field_bit2_pos,
7915 (void *)&cmd_write_reg_bit_field_value,
7920 /* *** WRITE PORT REGISTER BIT *** */
7921 struct cmd_write_reg_bit_result {
7922 cmdline_fixed_string_t write;
7923 cmdline_fixed_string_t regbit;
7931 cmd_write_reg_bit_parsed(void *parsed_result,
7932 __attribute__((unused)) struct cmdline *cl,
7933 __attribute__((unused)) void *data)
7935 struct cmd_write_reg_bit_result *res = parsed_result;
7936 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7939 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7940 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7942 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7943 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7945 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7946 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7947 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7948 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7949 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7950 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7951 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7952 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7954 cmdline_parse_inst_t cmd_write_reg_bit = {
7955 .f = cmd_write_reg_bit_parsed,
7957 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7960 (void *)&cmd_write_reg_bit_write,
7961 (void *)&cmd_write_reg_bit_regbit,
7962 (void *)&cmd_write_reg_bit_port_id,
7963 (void *)&cmd_write_reg_bit_reg_off,
7964 (void *)&cmd_write_reg_bit_bit_pos,
7965 (void *)&cmd_write_reg_bit_value,
7970 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7971 struct cmd_read_rxd_txd_result {
7972 cmdline_fixed_string_t read;
7973 cmdline_fixed_string_t rxd_txd;
7980 cmd_read_rxd_txd_parsed(void *parsed_result,
7981 __attribute__((unused)) struct cmdline *cl,
7982 __attribute__((unused)) void *data)
7984 struct cmd_read_rxd_txd_result *res = parsed_result;
7986 if (!strcmp(res->rxd_txd, "rxd"))
7987 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7988 else if (!strcmp(res->rxd_txd, "txd"))
7989 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7992 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7993 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7994 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7995 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7997 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7998 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7999 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8000 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8001 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8002 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8004 cmdline_parse_inst_t cmd_read_rxd_txd = {
8005 .f = cmd_read_rxd_txd_parsed,
8007 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8009 (void *)&cmd_read_rxd_txd_read,
8010 (void *)&cmd_read_rxd_txd_rxd_txd,
8011 (void *)&cmd_read_rxd_txd_port_id,
8012 (void *)&cmd_read_rxd_txd_queue_id,
8013 (void *)&cmd_read_rxd_txd_desc_id,
8019 struct cmd_quit_result {
8020 cmdline_fixed_string_t quit;
8023 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
8025 __attribute__((unused)) void *data)
8030 cmdline_parse_token_string_t cmd_quit_quit =
8031 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8033 cmdline_parse_inst_t cmd_quit = {
8034 .f = cmd_quit_parsed,
8036 .help_str = "quit: Exit application",
8038 (void *)&cmd_quit_quit,
8043 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8044 struct cmd_mac_addr_result {
8045 cmdline_fixed_string_t mac_addr_cmd;
8046 cmdline_fixed_string_t what;
8048 struct rte_ether_addr address;
8051 static void cmd_mac_addr_parsed(void *parsed_result,
8052 __attribute__((unused)) struct cmdline *cl,
8053 __attribute__((unused)) void *data)
8055 struct cmd_mac_addr_result *res = parsed_result;
8058 if (strcmp(res->what, "add") == 0)
8059 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8060 else if (strcmp(res->what, "set") == 0)
8061 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8064 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8066 /* check the return value and print it if is < 0 */
8068 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8072 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8073 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8075 cmdline_parse_token_string_t cmd_mac_addr_what =
8076 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8078 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8079 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8081 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8082 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8084 cmdline_parse_inst_t cmd_mac_addr = {
8085 .f = cmd_mac_addr_parsed,
8087 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8088 "Add/Remove/Set MAC address on port_id",
8090 (void *)&cmd_mac_addr_cmd,
8091 (void *)&cmd_mac_addr_what,
8092 (void *)&cmd_mac_addr_portnum,
8093 (void *)&cmd_mac_addr_addr,
8098 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8099 struct cmd_eth_peer_result {
8100 cmdline_fixed_string_t set;
8101 cmdline_fixed_string_t eth_peer;
8103 cmdline_fixed_string_t peer_addr;
8106 static void cmd_set_eth_peer_parsed(void *parsed_result,
8107 __attribute__((unused)) struct cmdline *cl,
8108 __attribute__((unused)) void *data)
8110 struct cmd_eth_peer_result *res = parsed_result;
8112 if (test_done == 0) {
8113 printf("Please stop forwarding first\n");
8116 if (!strcmp(res->eth_peer, "eth-peer")) {
8117 set_fwd_eth_peer(res->port_id, res->peer_addr);
8121 cmdline_parse_token_string_t cmd_eth_peer_set =
8122 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8123 cmdline_parse_token_string_t cmd_eth_peer =
8124 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8125 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8126 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8127 cmdline_parse_token_string_t cmd_eth_peer_addr =
8128 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8130 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8131 .f = cmd_set_eth_peer_parsed,
8133 .help_str = "set eth-peer <port_id> <peer_mac>",
8135 (void *)&cmd_eth_peer_set,
8136 (void *)&cmd_eth_peer,
8137 (void *)&cmd_eth_peer_port_id,
8138 (void *)&cmd_eth_peer_addr,
8143 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8144 struct cmd_set_qmap_result {
8145 cmdline_fixed_string_t set;
8146 cmdline_fixed_string_t qmap;
8147 cmdline_fixed_string_t what;
8154 cmd_set_qmap_parsed(void *parsed_result,
8155 __attribute__((unused)) struct cmdline *cl,
8156 __attribute__((unused)) void *data)
8158 struct cmd_set_qmap_result *res = parsed_result;
8159 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8161 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8164 cmdline_parse_token_string_t cmd_setqmap_set =
8165 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8167 cmdline_parse_token_string_t cmd_setqmap_qmap =
8168 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8170 cmdline_parse_token_string_t cmd_setqmap_what =
8171 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8173 cmdline_parse_token_num_t cmd_setqmap_portid =
8174 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8176 cmdline_parse_token_num_t cmd_setqmap_queueid =
8177 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8179 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8180 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8183 cmdline_parse_inst_t cmd_set_qmap = {
8184 .f = cmd_set_qmap_parsed,
8186 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8187 "Set statistics mapping value on tx|rx queue_id of port_id",
8189 (void *)&cmd_setqmap_set,
8190 (void *)&cmd_setqmap_qmap,
8191 (void *)&cmd_setqmap_what,
8192 (void *)&cmd_setqmap_portid,
8193 (void *)&cmd_setqmap_queueid,
8194 (void *)&cmd_setqmap_mapvalue,
8199 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8200 struct cmd_set_xstats_hide_zero_result {
8201 cmdline_fixed_string_t keyword;
8202 cmdline_fixed_string_t name;
8203 cmdline_fixed_string_t on_off;
8207 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8208 __attribute__((unused)) struct cmdline *cl,
8209 __attribute__((unused)) void *data)
8211 struct cmd_set_xstats_hide_zero_result *res;
8212 uint16_t on_off = 0;
8214 res = parsed_result;
8215 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8216 set_xstats_hide_zero(on_off);
8219 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8220 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8222 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8223 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8224 name, "xstats-hide-zero");
8225 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8226 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8229 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8230 .f = cmd_set_xstats_hide_zero_parsed,
8232 .help_str = "set xstats-hide-zero on|off",
8234 (void *)&cmd_set_xstats_hide_zero_keyword,
8235 (void *)&cmd_set_xstats_hide_zero_name,
8236 (void *)&cmd_set_xstats_hide_zero_on_off,
8241 /* *** CONFIGURE UNICAST HASH TABLE *** */
8242 struct cmd_set_uc_hash_table {
8243 cmdline_fixed_string_t set;
8244 cmdline_fixed_string_t port;
8246 cmdline_fixed_string_t what;
8247 struct rte_ether_addr address;
8248 cmdline_fixed_string_t mode;
8252 cmd_set_uc_hash_parsed(void *parsed_result,
8253 __attribute__((unused)) struct cmdline *cl,
8254 __attribute__((unused)) void *data)
8257 struct cmd_set_uc_hash_table *res = parsed_result;
8259 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8261 if (strcmp(res->what, "uta") == 0)
8262 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8263 &res->address,(uint8_t)is_on);
8265 printf("bad unicast hash table parameter, return code = %d \n", ret);
8269 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8270 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8272 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8273 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8275 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8276 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8278 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8279 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8281 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8282 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8284 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8285 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8288 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8289 .f = cmd_set_uc_hash_parsed,
8291 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8293 (void *)&cmd_set_uc_hash_set,
8294 (void *)&cmd_set_uc_hash_port,
8295 (void *)&cmd_set_uc_hash_portid,
8296 (void *)&cmd_set_uc_hash_what,
8297 (void *)&cmd_set_uc_hash_mac,
8298 (void *)&cmd_set_uc_hash_mode,
8303 struct cmd_set_uc_all_hash_table {
8304 cmdline_fixed_string_t set;
8305 cmdline_fixed_string_t port;
8307 cmdline_fixed_string_t what;
8308 cmdline_fixed_string_t value;
8309 cmdline_fixed_string_t mode;
8313 cmd_set_uc_all_hash_parsed(void *parsed_result,
8314 __attribute__((unused)) struct cmdline *cl,
8315 __attribute__((unused)) void *data)
8318 struct cmd_set_uc_all_hash_table *res = parsed_result;
8320 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8322 if ((strcmp(res->what, "uta") == 0) &&
8323 (strcmp(res->value, "all") == 0))
8324 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8326 printf("bad unicast hash table parameter,"
8327 "return code = %d \n", ret);
8330 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8331 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8333 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8334 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8336 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8337 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8339 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8340 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8342 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8343 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8345 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8346 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8349 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8350 .f = cmd_set_uc_all_hash_parsed,
8352 .help_str = "set port <port_id> uta all on|off",
8354 (void *)&cmd_set_uc_all_hash_set,
8355 (void *)&cmd_set_uc_all_hash_port,
8356 (void *)&cmd_set_uc_all_hash_portid,
8357 (void *)&cmd_set_uc_all_hash_what,
8358 (void *)&cmd_set_uc_all_hash_value,
8359 (void *)&cmd_set_uc_all_hash_mode,
8364 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8365 struct cmd_set_vf_macvlan_filter {
8366 cmdline_fixed_string_t set;
8367 cmdline_fixed_string_t port;
8369 cmdline_fixed_string_t vf;
8371 struct rte_ether_addr address;
8372 cmdline_fixed_string_t filter_type;
8373 cmdline_fixed_string_t mode;
8377 cmd_set_vf_macvlan_parsed(void *parsed_result,
8378 __attribute__((unused)) struct cmdline *cl,
8379 __attribute__((unused)) void *data)
8382 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8383 struct rte_eth_mac_filter filter;
8385 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8387 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8389 /* set VF MAC filter */
8393 filter.dst_id = res->vf_id;
8395 if (!strcmp(res->filter_type, "exact-mac"))
8396 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8397 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8398 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8399 else if (!strcmp(res->filter_type, "hashmac"))
8400 filter.filter_type = RTE_MAC_HASH_MATCH;
8401 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8402 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8404 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8407 ret = rte_eth_dev_filter_ctrl(res->port_id,
8408 RTE_ETH_FILTER_MACVLAN,
8412 ret = rte_eth_dev_filter_ctrl(res->port_id,
8413 RTE_ETH_FILTER_MACVLAN,
8414 RTE_ETH_FILTER_DELETE,
8418 printf("bad set MAC hash parameter, return code = %d\n", ret);
8422 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8423 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8425 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8426 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8428 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8429 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8431 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8432 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8434 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8435 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8437 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8438 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8440 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8441 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8442 filter_type, "exact-mac#exact-mac-vlan"
8443 "#hashmac#hashmac-vlan");
8444 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8445 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8448 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8449 .f = cmd_set_vf_macvlan_parsed,
8451 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8452 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8453 "Exact match rule: exact match of MAC or MAC and VLAN; "
8454 "hash match rule: hash match of MAC and exact match of VLAN",
8456 (void *)&cmd_set_vf_macvlan_set,
8457 (void *)&cmd_set_vf_macvlan_port,
8458 (void *)&cmd_set_vf_macvlan_portid,
8459 (void *)&cmd_set_vf_macvlan_vf,
8460 (void *)&cmd_set_vf_macvlan_vf_id,
8461 (void *)&cmd_set_vf_macvlan_mac,
8462 (void *)&cmd_set_vf_macvlan_filter_type,
8463 (void *)&cmd_set_vf_macvlan_mode,
8468 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8469 struct cmd_set_vf_traffic {
8470 cmdline_fixed_string_t set;
8471 cmdline_fixed_string_t port;
8473 cmdline_fixed_string_t vf;
8475 cmdline_fixed_string_t what;
8476 cmdline_fixed_string_t mode;
8480 cmd_set_vf_traffic_parsed(void *parsed_result,
8481 __attribute__((unused)) struct cmdline *cl,
8482 __attribute__((unused)) void *data)
8484 struct cmd_set_vf_traffic *res = parsed_result;
8485 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8486 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8488 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8491 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8492 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8494 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8495 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8497 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8498 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8500 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8501 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8503 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8504 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8506 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8507 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8509 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8510 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8513 cmdline_parse_inst_t cmd_set_vf_traffic = {
8514 .f = cmd_set_vf_traffic_parsed,
8516 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8518 (void *)&cmd_setvf_traffic_set,
8519 (void *)&cmd_setvf_traffic_port,
8520 (void *)&cmd_setvf_traffic_portid,
8521 (void *)&cmd_setvf_traffic_vf,
8522 (void *)&cmd_setvf_traffic_vfid,
8523 (void *)&cmd_setvf_traffic_what,
8524 (void *)&cmd_setvf_traffic_mode,
8529 /* *** CONFIGURE VF RECEIVE MODE *** */
8530 struct cmd_set_vf_rxmode {
8531 cmdline_fixed_string_t set;
8532 cmdline_fixed_string_t port;
8534 cmdline_fixed_string_t vf;
8536 cmdline_fixed_string_t what;
8537 cmdline_fixed_string_t mode;
8538 cmdline_fixed_string_t on;
8542 cmd_set_vf_rxmode_parsed(void *parsed_result,
8543 __attribute__((unused)) struct cmdline *cl,
8544 __attribute__((unused)) void *data)
8547 uint16_t vf_rxmode = 0;
8548 struct cmd_set_vf_rxmode *res = parsed_result;
8550 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8551 if (!strcmp(res->what,"rxmode")) {
8552 if (!strcmp(res->mode, "AUPE"))
8553 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8554 else if (!strcmp(res->mode, "ROPE"))
8555 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8556 else if (!strcmp(res->mode, "BAM"))
8557 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8558 else if (!strncmp(res->mode, "MPE",3))
8559 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8562 RTE_SET_USED(is_on);
8564 #ifdef RTE_LIBRTE_IXGBE_PMD
8565 if (ret == -ENOTSUP)
8566 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8567 vf_rxmode, (uint8_t)is_on);
8569 #ifdef RTE_LIBRTE_BNXT_PMD
8570 if (ret == -ENOTSUP)
8571 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8572 vf_rxmode, (uint8_t)is_on);
8575 printf("bad VF receive mode parameter, return code = %d \n",
8579 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8580 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8582 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8583 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8585 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8586 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8588 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8589 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8591 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8592 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8594 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8595 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8597 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8598 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8599 mode, "AUPE#ROPE#BAM#MPE");
8600 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8601 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8604 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8605 .f = cmd_set_vf_rxmode_parsed,
8607 .help_str = "set port <port_id> vf <vf_id> rxmode "
8608 "AUPE|ROPE|BAM|MPE on|off",
8610 (void *)&cmd_set_vf_rxmode_set,
8611 (void *)&cmd_set_vf_rxmode_port,
8612 (void *)&cmd_set_vf_rxmode_portid,
8613 (void *)&cmd_set_vf_rxmode_vf,
8614 (void *)&cmd_set_vf_rxmode_vfid,
8615 (void *)&cmd_set_vf_rxmode_what,
8616 (void *)&cmd_set_vf_rxmode_mode,
8617 (void *)&cmd_set_vf_rxmode_on,
8622 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8623 struct cmd_vf_mac_addr_result {
8624 cmdline_fixed_string_t mac_addr_cmd;
8625 cmdline_fixed_string_t what;
8626 cmdline_fixed_string_t port;
8628 cmdline_fixed_string_t vf;
8630 struct rte_ether_addr address;
8633 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8634 __attribute__((unused)) struct cmdline *cl,
8635 __attribute__((unused)) void *data)
8637 struct cmd_vf_mac_addr_result *res = parsed_result;
8640 if (strcmp(res->what, "add") != 0)
8643 #ifdef RTE_LIBRTE_I40E_PMD
8644 if (ret == -ENOTSUP)
8645 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8648 #ifdef RTE_LIBRTE_BNXT_PMD
8649 if (ret == -ENOTSUP)
8650 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8655 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8659 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8660 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8661 mac_addr_cmd,"mac_addr");
8662 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8663 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8665 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8666 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8668 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8669 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8671 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8672 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8674 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8675 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8677 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8678 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8681 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8682 .f = cmd_vf_mac_addr_parsed,
8684 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8685 "Add MAC address filtering for a VF on port_id",
8687 (void *)&cmd_vf_mac_addr_cmd,
8688 (void *)&cmd_vf_mac_addr_what,
8689 (void *)&cmd_vf_mac_addr_port,
8690 (void *)&cmd_vf_mac_addr_portnum,
8691 (void *)&cmd_vf_mac_addr_vf,
8692 (void *)&cmd_vf_mac_addr_vfnum,
8693 (void *)&cmd_vf_mac_addr_addr,
8698 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8699 struct cmd_vf_rx_vlan_filter {
8700 cmdline_fixed_string_t rx_vlan;
8701 cmdline_fixed_string_t what;
8703 cmdline_fixed_string_t port;
8705 cmdline_fixed_string_t vf;
8710 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8711 __attribute__((unused)) struct cmdline *cl,
8712 __attribute__((unused)) void *data)
8714 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8717 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8719 #ifdef RTE_LIBRTE_IXGBE_PMD
8720 if (ret == -ENOTSUP)
8721 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8722 res->vlan_id, res->vf_mask, is_add);
8724 #ifdef RTE_LIBRTE_I40E_PMD
8725 if (ret == -ENOTSUP)
8726 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8727 res->vlan_id, res->vf_mask, is_add);
8729 #ifdef RTE_LIBRTE_BNXT_PMD
8730 if (ret == -ENOTSUP)
8731 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8732 res->vlan_id, res->vf_mask, is_add);
8739 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8740 res->vlan_id, res->vf_mask);
8743 printf("invalid port_id %d\n", res->port_id);
8746 printf("function not implemented or supported\n");
8749 printf("programming error: (%s)\n", strerror(-ret));
8753 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8754 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8755 rx_vlan, "rx_vlan");
8756 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8757 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8759 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8760 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8762 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8763 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8765 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8766 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8768 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8769 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8771 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8772 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8775 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8776 .f = cmd_vf_rx_vlan_filter_parsed,
8778 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8779 "(vf_mask = hexadecimal VF mask)",
8781 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8782 (void *)&cmd_vf_rx_vlan_filter_what,
8783 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8784 (void *)&cmd_vf_rx_vlan_filter_port,
8785 (void *)&cmd_vf_rx_vlan_filter_portid,
8786 (void *)&cmd_vf_rx_vlan_filter_vf,
8787 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8792 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8793 struct cmd_queue_rate_limit_result {
8794 cmdline_fixed_string_t set;
8795 cmdline_fixed_string_t port;
8797 cmdline_fixed_string_t queue;
8799 cmdline_fixed_string_t rate;
8803 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8804 __attribute__((unused)) struct cmdline *cl,
8805 __attribute__((unused)) void *data)
8807 struct cmd_queue_rate_limit_result *res = parsed_result;
8810 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8811 && (strcmp(res->queue, "queue") == 0)
8812 && (strcmp(res->rate, "rate") == 0))
8813 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8816 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8820 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8821 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8823 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8824 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8826 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8827 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8829 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8830 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8832 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8833 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8835 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8836 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8838 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8839 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8842 cmdline_parse_inst_t cmd_queue_rate_limit = {
8843 .f = cmd_queue_rate_limit_parsed,
8845 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8846 "Set rate limit for a queue on port_id",
8848 (void *)&cmd_queue_rate_limit_set,
8849 (void *)&cmd_queue_rate_limit_port,
8850 (void *)&cmd_queue_rate_limit_portnum,
8851 (void *)&cmd_queue_rate_limit_queue,
8852 (void *)&cmd_queue_rate_limit_queuenum,
8853 (void *)&cmd_queue_rate_limit_rate,
8854 (void *)&cmd_queue_rate_limit_ratenum,
8859 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8860 struct cmd_vf_rate_limit_result {
8861 cmdline_fixed_string_t set;
8862 cmdline_fixed_string_t port;
8864 cmdline_fixed_string_t vf;
8866 cmdline_fixed_string_t rate;
8868 cmdline_fixed_string_t q_msk;
8872 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8873 __attribute__((unused)) struct cmdline *cl,
8874 __attribute__((unused)) void *data)
8876 struct cmd_vf_rate_limit_result *res = parsed_result;
8879 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8880 && (strcmp(res->vf, "vf") == 0)
8881 && (strcmp(res->rate, "rate") == 0)
8882 && (strcmp(res->q_msk, "queue_mask") == 0))
8883 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8884 res->rate_num, res->q_msk_val);
8886 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8890 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8891 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8893 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8894 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8896 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8897 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8899 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8900 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8902 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8903 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8905 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8906 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8908 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8909 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8911 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8912 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8913 q_msk, "queue_mask");
8914 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8915 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8918 cmdline_parse_inst_t cmd_vf_rate_limit = {
8919 .f = cmd_vf_rate_limit_parsed,
8921 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8922 "queue_mask <queue_mask_value>: "
8923 "Set rate limit for queues of VF on port_id",
8925 (void *)&cmd_vf_rate_limit_set,
8926 (void *)&cmd_vf_rate_limit_port,
8927 (void *)&cmd_vf_rate_limit_portnum,
8928 (void *)&cmd_vf_rate_limit_vf,
8929 (void *)&cmd_vf_rate_limit_vfnum,
8930 (void *)&cmd_vf_rate_limit_rate,
8931 (void *)&cmd_vf_rate_limit_ratenum,
8932 (void *)&cmd_vf_rate_limit_q_msk,
8933 (void *)&cmd_vf_rate_limit_q_msk_val,
8938 /* *** ADD TUNNEL FILTER OF A PORT *** */
8939 struct cmd_tunnel_filter_result {
8940 cmdline_fixed_string_t cmd;
8941 cmdline_fixed_string_t what;
8943 struct rte_ether_addr outer_mac;
8944 struct rte_ether_addr inner_mac;
8945 cmdline_ipaddr_t ip_value;
8946 uint16_t inner_vlan;
8947 cmdline_fixed_string_t tunnel_type;
8948 cmdline_fixed_string_t filter_type;
8954 cmd_tunnel_filter_parsed(void *parsed_result,
8955 __attribute__((unused)) struct cmdline *cl,
8956 __attribute__((unused)) void *data)
8958 struct cmd_tunnel_filter_result *res = parsed_result;
8959 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8962 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8964 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8965 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8966 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8968 if (res->ip_value.family == AF_INET) {
8969 tunnel_filter_conf.ip_addr.ipv4_addr =
8970 res->ip_value.addr.ipv4.s_addr;
8971 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8973 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8974 &(res->ip_value.addr.ipv6),
8975 sizeof(struct in6_addr));
8976 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8979 if (!strcmp(res->filter_type, "imac-ivlan"))
8980 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8981 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8982 tunnel_filter_conf.filter_type =
8983 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8984 else if (!strcmp(res->filter_type, "imac-tenid"))
8985 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8986 else if (!strcmp(res->filter_type, "imac"))
8987 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8988 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8989 tunnel_filter_conf.filter_type =
8990 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8991 else if (!strcmp(res->filter_type, "oip"))
8992 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8993 else if (!strcmp(res->filter_type, "iip"))
8994 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8996 printf("The filter type is not supported");
9000 if (!strcmp(res->tunnel_type, "vxlan"))
9001 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
9002 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
9003 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9004 else if (!strcmp(res->tunnel_type, "nvgre"))
9005 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
9006 else if (!strcmp(res->tunnel_type, "ipingre"))
9007 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
9009 printf("The tunnel type %s not supported.\n", res->tunnel_type);
9013 tunnel_filter_conf.tenant_id = res->tenant_id;
9014 tunnel_filter_conf.queue_id = res->queue_num;
9015 if (!strcmp(res->what, "add"))
9016 ret = rte_eth_dev_filter_ctrl(res->port_id,
9017 RTE_ETH_FILTER_TUNNEL,
9019 &tunnel_filter_conf);
9021 ret = rte_eth_dev_filter_ctrl(res->port_id,
9022 RTE_ETH_FILTER_TUNNEL,
9023 RTE_ETH_FILTER_DELETE,
9024 &tunnel_filter_conf);
9026 printf("cmd_tunnel_filter_parsed error: (%s)\n",
9030 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
9031 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9032 cmd, "tunnel_filter");
9033 cmdline_parse_token_string_t cmd_tunnel_filter_what =
9034 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9036 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
9037 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9039 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
9040 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9042 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
9043 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9045 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
9046 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9047 inner_vlan, UINT16);
9048 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
9049 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
9051 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
9052 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9053 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
9055 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
9056 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
9057 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
9058 "imac#omac-imac-tenid");
9059 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
9060 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9062 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
9063 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
9066 cmdline_parse_inst_t cmd_tunnel_filter = {
9067 .f = cmd_tunnel_filter_parsed,
9069 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
9070 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
9071 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
9072 "<queue_id>: Add/Rm tunnel filter of a port",
9074 (void *)&cmd_tunnel_filter_cmd,
9075 (void *)&cmd_tunnel_filter_what,
9076 (void *)&cmd_tunnel_filter_port_id,
9077 (void *)&cmd_tunnel_filter_outer_mac,
9078 (void *)&cmd_tunnel_filter_inner_mac,
9079 (void *)&cmd_tunnel_filter_ip_value,
9080 (void *)&cmd_tunnel_filter_innner_vlan,
9081 (void *)&cmd_tunnel_filter_tunnel_type,
9082 (void *)&cmd_tunnel_filter_filter_type,
9083 (void *)&cmd_tunnel_filter_tenant_id,
9084 (void *)&cmd_tunnel_filter_queue_num,
9089 /* *** CONFIGURE TUNNEL UDP PORT *** */
9090 struct cmd_tunnel_udp_config {
9091 cmdline_fixed_string_t cmd;
9092 cmdline_fixed_string_t what;
9098 cmd_tunnel_udp_config_parsed(void *parsed_result,
9099 __attribute__((unused)) struct cmdline *cl,
9100 __attribute__((unused)) void *data)
9102 struct cmd_tunnel_udp_config *res = parsed_result;
9103 struct rte_eth_udp_tunnel tunnel_udp;
9106 tunnel_udp.udp_port = res->udp_port;
9108 if (!strcmp(res->cmd, "rx_vxlan_port"))
9109 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9111 if (!strcmp(res->what, "add"))
9112 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9115 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9119 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9122 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9123 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9124 cmd, "rx_vxlan_port");
9125 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9126 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9128 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9129 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9131 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9132 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9135 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9136 .f = cmd_tunnel_udp_config_parsed,
9138 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9139 "Add/Remove a tunneling UDP port filter",
9141 (void *)&cmd_tunnel_udp_config_cmd,
9142 (void *)&cmd_tunnel_udp_config_what,
9143 (void *)&cmd_tunnel_udp_config_udp_port,
9144 (void *)&cmd_tunnel_udp_config_port_id,
9149 struct cmd_config_tunnel_udp_port {
9150 cmdline_fixed_string_t port;
9151 cmdline_fixed_string_t config;
9153 cmdline_fixed_string_t udp_tunnel_port;
9154 cmdline_fixed_string_t action;
9155 cmdline_fixed_string_t tunnel_type;
9160 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9161 __attribute__((unused)) struct cmdline *cl,
9162 __attribute__((unused)) void *data)
9164 struct cmd_config_tunnel_udp_port *res = parsed_result;
9165 struct rte_eth_udp_tunnel tunnel_udp;
9168 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9171 tunnel_udp.udp_port = res->udp_port;
9173 if (!strcmp(res->tunnel_type, "vxlan")) {
9174 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9175 } else if (!strcmp(res->tunnel_type, "geneve")) {
9176 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9177 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9178 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9180 printf("Invalid tunnel type\n");
9184 if (!strcmp(res->action, "add"))
9185 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9188 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9192 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9195 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9196 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9198 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9199 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9201 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9202 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9204 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9205 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9208 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9209 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9211 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9212 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9213 "vxlan#geneve#vxlan-gpe");
9214 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9215 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9218 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9219 .f = cmd_cfg_tunnel_udp_port_parsed,
9221 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9223 (void *)&cmd_config_tunnel_udp_port_port,
9224 (void *)&cmd_config_tunnel_udp_port_config,
9225 (void *)&cmd_config_tunnel_udp_port_port_id,
9226 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9227 (void *)&cmd_config_tunnel_udp_port_action,
9228 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9229 (void *)&cmd_config_tunnel_udp_port_value,
9234 /* *** GLOBAL CONFIG *** */
9235 struct cmd_global_config_result {
9236 cmdline_fixed_string_t cmd;
9238 cmdline_fixed_string_t cfg_type;
9243 cmd_global_config_parsed(void *parsed_result,
9244 __attribute__((unused)) struct cmdline *cl,
9245 __attribute__((unused)) void *data)
9247 struct cmd_global_config_result *res = parsed_result;
9248 struct rte_eth_global_cfg conf;
9251 memset(&conf, 0, sizeof(conf));
9252 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9253 conf.cfg.gre_key_len = res->len;
9254 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9255 RTE_ETH_FILTER_SET, &conf);
9257 printf("Global config error\n");
9260 cmdline_parse_token_string_t cmd_global_config_cmd =
9261 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9263 cmdline_parse_token_num_t cmd_global_config_port_id =
9264 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9266 cmdline_parse_token_string_t cmd_global_config_type =
9267 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9268 cfg_type, "gre-key-len");
9269 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9270 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9273 cmdline_parse_inst_t cmd_global_config = {
9274 .f = cmd_global_config_parsed,
9275 .data = (void *)NULL,
9276 .help_str = "global_config <port_id> gre-key-len <key_len>",
9278 (void *)&cmd_global_config_cmd,
9279 (void *)&cmd_global_config_port_id,
9280 (void *)&cmd_global_config_type,
9281 (void *)&cmd_global_config_gre_key_len,
9286 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9287 struct cmd_set_mirror_mask_result {
9288 cmdline_fixed_string_t set;
9289 cmdline_fixed_string_t port;
9291 cmdline_fixed_string_t mirror;
9293 cmdline_fixed_string_t what;
9294 cmdline_fixed_string_t value;
9295 cmdline_fixed_string_t dstpool;
9297 cmdline_fixed_string_t on;
9300 cmdline_parse_token_string_t cmd_mirror_mask_set =
9301 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9303 cmdline_parse_token_string_t cmd_mirror_mask_port =
9304 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9306 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9307 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9309 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9310 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9311 mirror, "mirror-rule");
9312 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9313 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9315 cmdline_parse_token_string_t cmd_mirror_mask_what =
9316 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9317 what, "pool-mirror-up#pool-mirror-down"
9319 cmdline_parse_token_string_t cmd_mirror_mask_value =
9320 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9322 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9323 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9324 dstpool, "dst-pool");
9325 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9326 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9328 cmdline_parse_token_string_t cmd_mirror_mask_on =
9329 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9333 cmd_set_mirror_mask_parsed(void *parsed_result,
9334 __attribute__((unused)) struct cmdline *cl,
9335 __attribute__((unused)) void *data)
9338 struct cmd_set_mirror_mask_result *res = parsed_result;
9339 struct rte_eth_mirror_conf mr_conf;
9341 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9343 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9345 mr_conf.dst_pool = res->dstpool_id;
9347 if (!strcmp(res->what, "pool-mirror-up")) {
9348 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9349 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9350 } else if (!strcmp(res->what, "pool-mirror-down")) {
9351 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9352 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9353 } else if (!strcmp(res->what, "vlan-mirror")) {
9354 mr_conf.rule_type = ETH_MIRROR_VLAN;
9355 nb_item = parse_item_list(res->value, "vlan",
9356 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9360 for (i = 0; i < nb_item; i++) {
9361 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9362 printf("Invalid vlan_id: must be < 4096\n");
9366 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9367 mr_conf.vlan.vlan_mask |= 1ULL << i;
9371 if (!strcmp(res->on, "on"))
9372 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9375 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9378 printf("mirror rule add error: (%s)\n", strerror(-ret));
9381 cmdline_parse_inst_t cmd_set_mirror_mask = {
9382 .f = cmd_set_mirror_mask_parsed,
9384 .help_str = "set port <port_id> mirror-rule <rule_id> "
9385 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9386 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9388 (void *)&cmd_mirror_mask_set,
9389 (void *)&cmd_mirror_mask_port,
9390 (void *)&cmd_mirror_mask_portid,
9391 (void *)&cmd_mirror_mask_mirror,
9392 (void *)&cmd_mirror_mask_ruleid,
9393 (void *)&cmd_mirror_mask_what,
9394 (void *)&cmd_mirror_mask_value,
9395 (void *)&cmd_mirror_mask_dstpool,
9396 (void *)&cmd_mirror_mask_poolid,
9397 (void *)&cmd_mirror_mask_on,
9402 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9403 struct cmd_set_mirror_link_result {
9404 cmdline_fixed_string_t set;
9405 cmdline_fixed_string_t port;
9407 cmdline_fixed_string_t mirror;
9409 cmdline_fixed_string_t what;
9410 cmdline_fixed_string_t dstpool;
9412 cmdline_fixed_string_t on;
9415 cmdline_parse_token_string_t cmd_mirror_link_set =
9416 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9418 cmdline_parse_token_string_t cmd_mirror_link_port =
9419 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9421 cmdline_parse_token_num_t cmd_mirror_link_portid =
9422 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9424 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9425 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9426 mirror, "mirror-rule");
9427 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9428 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9430 cmdline_parse_token_string_t cmd_mirror_link_what =
9431 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9432 what, "uplink-mirror#downlink-mirror");
9433 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9434 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9435 dstpool, "dst-pool");
9436 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9437 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9439 cmdline_parse_token_string_t cmd_mirror_link_on =
9440 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9444 cmd_set_mirror_link_parsed(void *parsed_result,
9445 __attribute__((unused)) struct cmdline *cl,
9446 __attribute__((unused)) void *data)
9449 struct cmd_set_mirror_link_result *res = parsed_result;
9450 struct rte_eth_mirror_conf mr_conf;
9452 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9453 if (!strcmp(res->what, "uplink-mirror"))
9454 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9456 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9458 mr_conf.dst_pool = res->dstpool_id;
9460 if (!strcmp(res->on, "on"))
9461 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9464 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9467 /* check the return value and print it if is < 0 */
9469 printf("mirror rule add error: (%s)\n", strerror(-ret));
9473 cmdline_parse_inst_t cmd_set_mirror_link = {
9474 .f = cmd_set_mirror_link_parsed,
9476 .help_str = "set port <port_id> mirror-rule <rule_id> "
9477 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9479 (void *)&cmd_mirror_link_set,
9480 (void *)&cmd_mirror_link_port,
9481 (void *)&cmd_mirror_link_portid,
9482 (void *)&cmd_mirror_link_mirror,
9483 (void *)&cmd_mirror_link_ruleid,
9484 (void *)&cmd_mirror_link_what,
9485 (void *)&cmd_mirror_link_dstpool,
9486 (void *)&cmd_mirror_link_poolid,
9487 (void *)&cmd_mirror_link_on,
9492 /* *** RESET VM MIRROR RULE *** */
9493 struct cmd_rm_mirror_rule_result {
9494 cmdline_fixed_string_t reset;
9495 cmdline_fixed_string_t port;
9497 cmdline_fixed_string_t mirror;
9501 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9502 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9504 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9505 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9507 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9508 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9510 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9511 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9512 mirror, "mirror-rule");
9513 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9514 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9518 cmd_reset_mirror_rule_parsed(void *parsed_result,
9519 __attribute__((unused)) struct cmdline *cl,
9520 __attribute__((unused)) void *data)
9523 struct cmd_set_mirror_link_result *res = parsed_result;
9525 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9527 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9530 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9531 .f = cmd_reset_mirror_rule_parsed,
9533 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9535 (void *)&cmd_rm_mirror_rule_reset,
9536 (void *)&cmd_rm_mirror_rule_port,
9537 (void *)&cmd_rm_mirror_rule_portid,
9538 (void *)&cmd_rm_mirror_rule_mirror,
9539 (void *)&cmd_rm_mirror_rule_ruleid,
9544 /* ******************************************************************************** */
9546 struct cmd_dump_result {
9547 cmdline_fixed_string_t dump;
9551 dump_struct_sizes(void)
9553 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9554 DUMP_SIZE(struct rte_mbuf);
9555 DUMP_SIZE(struct rte_mempool);
9556 DUMP_SIZE(struct rte_ring);
9560 static void cmd_dump_parsed(void *parsed_result,
9561 __attribute__((unused)) struct cmdline *cl,
9562 __attribute__((unused)) void *data)
9564 struct cmd_dump_result *res = parsed_result;
9566 if (!strcmp(res->dump, "dump_physmem"))
9567 rte_dump_physmem_layout(stdout);
9568 else if (!strcmp(res->dump, "dump_memzone"))
9569 rte_memzone_dump(stdout);
9570 else if (!strcmp(res->dump, "dump_struct_sizes"))
9571 dump_struct_sizes();
9572 else if (!strcmp(res->dump, "dump_ring"))
9573 rte_ring_list_dump(stdout);
9574 else if (!strcmp(res->dump, "dump_mempool"))
9575 rte_mempool_list_dump(stdout);
9576 else if (!strcmp(res->dump, "dump_devargs"))
9577 rte_devargs_dump(stdout);
9578 else if (!strcmp(res->dump, "dump_log_types"))
9579 rte_log_dump(stdout);
9582 cmdline_parse_token_string_t cmd_dump_dump =
9583 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9586 "dump_struct_sizes#"
9592 cmdline_parse_inst_t cmd_dump = {
9593 .f = cmd_dump_parsed, /* function to call */
9594 .data = NULL, /* 2nd arg of func */
9595 .help_str = "Dump status",
9596 .tokens = { /* token list, NULL terminated */
9597 (void *)&cmd_dump_dump,
9602 /* ******************************************************************************** */
9604 struct cmd_dump_one_result {
9605 cmdline_fixed_string_t dump;
9606 cmdline_fixed_string_t name;
9609 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9610 __attribute__((unused)) void *data)
9612 struct cmd_dump_one_result *res = parsed_result;
9614 if (!strcmp(res->dump, "dump_ring")) {
9616 r = rte_ring_lookup(res->name);
9618 cmdline_printf(cl, "Cannot find ring\n");
9621 rte_ring_dump(stdout, r);
9622 } else if (!strcmp(res->dump, "dump_mempool")) {
9623 struct rte_mempool *mp;
9624 mp = rte_mempool_lookup(res->name);
9626 cmdline_printf(cl, "Cannot find mempool\n");
9629 rte_mempool_dump(stdout, mp);
9633 cmdline_parse_token_string_t cmd_dump_one_dump =
9634 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9635 "dump_ring#dump_mempool");
9637 cmdline_parse_token_string_t cmd_dump_one_name =
9638 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9640 cmdline_parse_inst_t cmd_dump_one = {
9641 .f = cmd_dump_one_parsed, /* function to call */
9642 .data = NULL, /* 2nd arg of func */
9643 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9644 .tokens = { /* token list, NULL terminated */
9645 (void *)&cmd_dump_one_dump,
9646 (void *)&cmd_dump_one_name,
9651 /* *** Add/Del syn filter *** */
9652 struct cmd_syn_filter_result {
9653 cmdline_fixed_string_t filter;
9655 cmdline_fixed_string_t ops;
9656 cmdline_fixed_string_t priority;
9657 cmdline_fixed_string_t high;
9658 cmdline_fixed_string_t queue;
9663 cmd_syn_filter_parsed(void *parsed_result,
9664 __attribute__((unused)) struct cmdline *cl,
9665 __attribute__((unused)) void *data)
9667 struct cmd_syn_filter_result *res = parsed_result;
9668 struct rte_eth_syn_filter syn_filter;
9671 ret = rte_eth_dev_filter_supported(res->port_id,
9672 RTE_ETH_FILTER_SYN);
9674 printf("syn filter is not supported on port %u.\n",
9679 memset(&syn_filter, 0, sizeof(syn_filter));
9681 if (!strcmp(res->ops, "add")) {
9682 if (!strcmp(res->high, "high"))
9683 syn_filter.hig_pri = 1;
9685 syn_filter.hig_pri = 0;
9687 syn_filter.queue = res->queue_id;
9688 ret = rte_eth_dev_filter_ctrl(res->port_id,
9693 ret = rte_eth_dev_filter_ctrl(res->port_id,
9695 RTE_ETH_FILTER_DELETE,
9699 printf("syn filter programming error: (%s)\n",
9703 cmdline_parse_token_string_t cmd_syn_filter_filter =
9704 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9705 filter, "syn_filter");
9706 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9707 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9709 cmdline_parse_token_string_t cmd_syn_filter_ops =
9710 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9712 cmdline_parse_token_string_t cmd_syn_filter_priority =
9713 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9714 priority, "priority");
9715 cmdline_parse_token_string_t cmd_syn_filter_high =
9716 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9718 cmdline_parse_token_string_t cmd_syn_filter_queue =
9719 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9721 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9722 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9725 cmdline_parse_inst_t cmd_syn_filter = {
9726 .f = cmd_syn_filter_parsed,
9728 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9729 "<queue_id>: Add/Delete syn filter",
9731 (void *)&cmd_syn_filter_filter,
9732 (void *)&cmd_syn_filter_port_id,
9733 (void *)&cmd_syn_filter_ops,
9734 (void *)&cmd_syn_filter_priority,
9735 (void *)&cmd_syn_filter_high,
9736 (void *)&cmd_syn_filter_queue,
9737 (void *)&cmd_syn_filter_queue_id,
9742 /* *** queue region set *** */
9743 struct cmd_queue_region_result {
9744 cmdline_fixed_string_t set;
9745 cmdline_fixed_string_t port;
9747 cmdline_fixed_string_t cmd;
9748 cmdline_fixed_string_t region;
9750 cmdline_fixed_string_t queue_start_index;
9752 cmdline_fixed_string_t queue_num;
9753 uint8_t queue_num_value;
9757 cmd_queue_region_parsed(void *parsed_result,
9758 __attribute__((unused)) struct cmdline *cl,
9759 __attribute__((unused)) void *data)
9761 struct cmd_queue_region_result *res = parsed_result;
9763 #ifdef RTE_LIBRTE_I40E_PMD
9764 struct rte_pmd_i40e_queue_region_conf region_conf;
9765 enum rte_pmd_i40e_queue_region_op op_type;
9768 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9771 #ifdef RTE_LIBRTE_I40E_PMD
9772 memset(®ion_conf, 0, sizeof(region_conf));
9773 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9774 region_conf.region_id = res->region_id;
9775 region_conf.queue_num = res->queue_num_value;
9776 region_conf.queue_start_index = res->queue_id;
9778 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9779 op_type, ®ion_conf);
9786 printf("function not implemented or supported\n");
9789 printf("queue region config error: (%s)\n", strerror(-ret));
9793 cmdline_parse_token_string_t cmd_queue_region_set =
9794 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9796 cmdline_parse_token_string_t cmd_queue_region_port =
9797 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9798 cmdline_parse_token_num_t cmd_queue_region_port_id =
9799 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9801 cmdline_parse_token_string_t cmd_queue_region_cmd =
9802 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9803 cmd, "queue-region");
9804 cmdline_parse_token_string_t cmd_queue_region_id =
9805 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9806 region, "region_id");
9807 cmdline_parse_token_num_t cmd_queue_region_index =
9808 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9810 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9811 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9812 queue_start_index, "queue_start_index");
9813 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9814 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9816 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9817 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9818 queue_num, "queue_num");
9819 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9820 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9821 queue_num_value, UINT8);
9823 cmdline_parse_inst_t cmd_queue_region = {
9824 .f = cmd_queue_region_parsed,
9826 .help_str = "set port <port_id> queue-region region_id <value> "
9827 "queue_start_index <value> queue_num <value>: Set a queue region",
9829 (void *)&cmd_queue_region_set,
9830 (void *)&cmd_queue_region_port,
9831 (void *)&cmd_queue_region_port_id,
9832 (void *)&cmd_queue_region_cmd,
9833 (void *)&cmd_queue_region_id,
9834 (void *)&cmd_queue_region_index,
9835 (void *)&cmd_queue_region_queue_start_index,
9836 (void *)&cmd_queue_region_queue_id,
9837 (void *)&cmd_queue_region_queue_num,
9838 (void *)&cmd_queue_region_queue_num_value,
9843 /* *** queue region and flowtype set *** */
9844 struct cmd_region_flowtype_result {
9845 cmdline_fixed_string_t set;
9846 cmdline_fixed_string_t port;
9848 cmdline_fixed_string_t cmd;
9849 cmdline_fixed_string_t region;
9851 cmdline_fixed_string_t flowtype;
9852 uint8_t flowtype_id;
9856 cmd_region_flowtype_parsed(void *parsed_result,
9857 __attribute__((unused)) struct cmdline *cl,
9858 __attribute__((unused)) void *data)
9860 struct cmd_region_flowtype_result *res = parsed_result;
9862 #ifdef RTE_LIBRTE_I40E_PMD
9863 struct rte_pmd_i40e_queue_region_conf region_conf;
9864 enum rte_pmd_i40e_queue_region_op op_type;
9867 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9870 #ifdef RTE_LIBRTE_I40E_PMD
9871 memset(®ion_conf, 0, sizeof(region_conf));
9873 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9874 region_conf.region_id = res->region_id;
9875 region_conf.hw_flowtype = res->flowtype_id;
9877 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9878 op_type, ®ion_conf);
9885 printf("function not implemented or supported\n");
9888 printf("region flowtype config error: (%s)\n", strerror(-ret));
9892 cmdline_parse_token_string_t cmd_region_flowtype_set =
9893 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9895 cmdline_parse_token_string_t cmd_region_flowtype_port =
9896 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9898 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9899 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9901 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9902 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9903 cmd, "queue-region");
9904 cmdline_parse_token_string_t cmd_region_flowtype_index =
9905 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9906 region, "region_id");
9907 cmdline_parse_token_num_t cmd_region_flowtype_id =
9908 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9910 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9911 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9912 flowtype, "flowtype");
9913 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9914 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9915 flowtype_id, UINT8);
9916 cmdline_parse_inst_t cmd_region_flowtype = {
9917 .f = cmd_region_flowtype_parsed,
9919 .help_str = "set port <port_id> queue-region region_id <value> "
9920 "flowtype <value>: Set a flowtype region index",
9922 (void *)&cmd_region_flowtype_set,
9923 (void *)&cmd_region_flowtype_port,
9924 (void *)&cmd_region_flowtype_port_index,
9925 (void *)&cmd_region_flowtype_cmd,
9926 (void *)&cmd_region_flowtype_index,
9927 (void *)&cmd_region_flowtype_id,
9928 (void *)&cmd_region_flowtype_flow_index,
9929 (void *)&cmd_region_flowtype_flow_id,
9934 /* *** User Priority (UP) to queue region (region_id) set *** */
9935 struct cmd_user_priority_region_result {
9936 cmdline_fixed_string_t set;
9937 cmdline_fixed_string_t port;
9939 cmdline_fixed_string_t cmd;
9940 cmdline_fixed_string_t user_priority;
9941 uint8_t user_priority_id;
9942 cmdline_fixed_string_t region;
9947 cmd_user_priority_region_parsed(void *parsed_result,
9948 __attribute__((unused)) struct cmdline *cl,
9949 __attribute__((unused)) void *data)
9951 struct cmd_user_priority_region_result *res = parsed_result;
9953 #ifdef RTE_LIBRTE_I40E_PMD
9954 struct rte_pmd_i40e_queue_region_conf region_conf;
9955 enum rte_pmd_i40e_queue_region_op op_type;
9958 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9961 #ifdef RTE_LIBRTE_I40E_PMD
9962 memset(®ion_conf, 0, sizeof(region_conf));
9963 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9964 region_conf.user_priority = res->user_priority_id;
9965 region_conf.region_id = res->region_id;
9967 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9968 op_type, ®ion_conf);
9975 printf("function not implemented or supported\n");
9978 printf("user_priority region config error: (%s)\n",
9983 cmdline_parse_token_string_t cmd_user_priority_region_set =
9984 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9986 cmdline_parse_token_string_t cmd_user_priority_region_port =
9987 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9989 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9990 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9992 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9993 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9994 cmd, "queue-region");
9995 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9996 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9997 user_priority, "UP");
9998 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9999 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10000 user_priority_id, UINT8);
10001 cmdline_parse_token_string_t cmd_user_priority_region_region =
10002 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10003 region, "region_id");
10004 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10005 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10008 cmdline_parse_inst_t cmd_user_priority_region = {
10009 .f = cmd_user_priority_region_parsed,
10011 .help_str = "set port <port_id> queue-region UP <value> "
10012 "region_id <value>: Set the mapping of User Priority (UP) "
10013 "to queue region (region_id) ",
10015 (void *)&cmd_user_priority_region_set,
10016 (void *)&cmd_user_priority_region_port,
10017 (void *)&cmd_user_priority_region_port_index,
10018 (void *)&cmd_user_priority_region_cmd,
10019 (void *)&cmd_user_priority_region_UP,
10020 (void *)&cmd_user_priority_region_UP_id,
10021 (void *)&cmd_user_priority_region_region,
10022 (void *)&cmd_user_priority_region_region_id,
10027 /* *** flush all queue region related configuration *** */
10028 struct cmd_flush_queue_region_result {
10029 cmdline_fixed_string_t set;
10030 cmdline_fixed_string_t port;
10032 cmdline_fixed_string_t cmd;
10033 cmdline_fixed_string_t flush;
10034 cmdline_fixed_string_t what;
10038 cmd_flush_queue_region_parsed(void *parsed_result,
10039 __attribute__((unused)) struct cmdline *cl,
10040 __attribute__((unused)) void *data)
10042 struct cmd_flush_queue_region_result *res = parsed_result;
10043 int ret = -ENOTSUP;
10044 #ifdef RTE_LIBRTE_I40E_PMD
10045 struct rte_pmd_i40e_queue_region_conf region_conf;
10046 enum rte_pmd_i40e_queue_region_op op_type;
10049 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10052 #ifdef RTE_LIBRTE_I40E_PMD
10053 memset(®ion_conf, 0, sizeof(region_conf));
10055 if (strcmp(res->what, "on") == 0)
10056 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10058 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10060 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10061 op_type, ®ion_conf);
10068 printf("function not implemented or supported\n");
10071 printf("queue region config flush error: (%s)\n",
10076 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10077 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10079 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10080 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10082 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10083 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10085 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10086 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10087 cmd, "queue-region");
10088 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10089 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10091 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10092 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10095 cmdline_parse_inst_t cmd_flush_queue_region = {
10096 .f = cmd_flush_queue_region_parsed,
10098 .help_str = "set port <port_id> queue-region flush on|off"
10099 ": flush all queue region related configuration",
10101 (void *)&cmd_flush_queue_region_set,
10102 (void *)&cmd_flush_queue_region_port,
10103 (void *)&cmd_flush_queue_region_port_index,
10104 (void *)&cmd_flush_queue_region_cmd,
10105 (void *)&cmd_flush_queue_region_flush,
10106 (void *)&cmd_flush_queue_region_what,
10111 /* *** get all queue region related configuration info *** */
10112 struct cmd_show_queue_region_info {
10113 cmdline_fixed_string_t show;
10114 cmdline_fixed_string_t port;
10116 cmdline_fixed_string_t cmd;
10120 cmd_show_queue_region_info_parsed(void *parsed_result,
10121 __attribute__((unused)) struct cmdline *cl,
10122 __attribute__((unused)) void *data)
10124 struct cmd_show_queue_region_info *res = parsed_result;
10125 int ret = -ENOTSUP;
10126 #ifdef RTE_LIBRTE_I40E_PMD
10127 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10128 enum rte_pmd_i40e_queue_region_op op_type;
10131 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10134 #ifdef RTE_LIBRTE_I40E_PMD
10135 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10137 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10139 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10140 op_type, &rte_pmd_regions);
10142 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10149 printf("function not implemented or supported\n");
10152 printf("queue region config info show error: (%s)\n",
10157 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10158 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10160 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10161 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10163 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10164 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10166 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10167 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10168 cmd, "queue-region");
10170 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10171 .f = cmd_show_queue_region_info_parsed,
10173 .help_str = "show port <port_id> queue-region"
10174 ": show all queue region related configuration info",
10176 (void *)&cmd_show_queue_region_info_get,
10177 (void *)&cmd_show_queue_region_info_port,
10178 (void *)&cmd_show_queue_region_info_port_index,
10179 (void *)&cmd_show_queue_region_info_cmd,
10184 /* *** ADD/REMOVE A 2tuple FILTER *** */
10185 struct cmd_2tuple_filter_result {
10186 cmdline_fixed_string_t filter;
10188 cmdline_fixed_string_t ops;
10189 cmdline_fixed_string_t dst_port;
10190 uint16_t dst_port_value;
10191 cmdline_fixed_string_t protocol;
10192 uint8_t protocol_value;
10193 cmdline_fixed_string_t mask;
10194 uint8_t mask_value;
10195 cmdline_fixed_string_t tcp_flags;
10196 uint8_t tcp_flags_value;
10197 cmdline_fixed_string_t priority;
10198 uint8_t priority_value;
10199 cmdline_fixed_string_t queue;
10204 cmd_2tuple_filter_parsed(void *parsed_result,
10205 __attribute__((unused)) struct cmdline *cl,
10206 __attribute__((unused)) void *data)
10208 struct rte_eth_ntuple_filter filter;
10209 struct cmd_2tuple_filter_result *res = parsed_result;
10212 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10214 printf("ntuple filter is not supported on port %u.\n",
10219 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10221 filter.flags = RTE_2TUPLE_FLAGS;
10222 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10223 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10224 filter.proto = res->protocol_value;
10225 filter.priority = res->priority_value;
10226 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10227 printf("nonzero tcp_flags is only meaningful"
10228 " when protocol is TCP.\n");
10231 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10232 printf("invalid TCP flags.\n");
10236 if (res->tcp_flags_value != 0) {
10237 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10238 filter.tcp_flags = res->tcp_flags_value;
10241 /* need convert to big endian. */
10242 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10243 filter.queue = res->queue_id;
10245 if (!strcmp(res->ops, "add"))
10246 ret = rte_eth_dev_filter_ctrl(res->port_id,
10247 RTE_ETH_FILTER_NTUPLE,
10248 RTE_ETH_FILTER_ADD,
10251 ret = rte_eth_dev_filter_ctrl(res->port_id,
10252 RTE_ETH_FILTER_NTUPLE,
10253 RTE_ETH_FILTER_DELETE,
10256 printf("2tuple filter programming error: (%s)\n",
10261 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10262 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10263 filter, "2tuple_filter");
10264 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10265 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10267 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10268 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10270 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10271 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10272 dst_port, "dst_port");
10273 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10274 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10275 dst_port_value, UINT16);
10276 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10277 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10278 protocol, "protocol");
10279 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10280 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10281 protocol_value, UINT8);
10282 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10283 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10285 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10286 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10288 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10289 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10290 tcp_flags, "tcp_flags");
10291 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10292 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10293 tcp_flags_value, UINT8);
10294 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10295 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10296 priority, "priority");
10297 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10298 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10299 priority_value, UINT8);
10300 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10301 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10303 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10304 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10307 cmdline_parse_inst_t cmd_2tuple_filter = {
10308 .f = cmd_2tuple_filter_parsed,
10310 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10311 "<value> mask <value> tcp_flags <value> priority <value> queue "
10312 "<queue_id>: Add a 2tuple filter",
10314 (void *)&cmd_2tuple_filter_filter,
10315 (void *)&cmd_2tuple_filter_port_id,
10316 (void *)&cmd_2tuple_filter_ops,
10317 (void *)&cmd_2tuple_filter_dst_port,
10318 (void *)&cmd_2tuple_filter_dst_port_value,
10319 (void *)&cmd_2tuple_filter_protocol,
10320 (void *)&cmd_2tuple_filter_protocol_value,
10321 (void *)&cmd_2tuple_filter_mask,
10322 (void *)&cmd_2tuple_filter_mask_value,
10323 (void *)&cmd_2tuple_filter_tcp_flags,
10324 (void *)&cmd_2tuple_filter_tcp_flags_value,
10325 (void *)&cmd_2tuple_filter_priority,
10326 (void *)&cmd_2tuple_filter_priority_value,
10327 (void *)&cmd_2tuple_filter_queue,
10328 (void *)&cmd_2tuple_filter_queue_id,
10333 /* *** ADD/REMOVE A 5tuple FILTER *** */
10334 struct cmd_5tuple_filter_result {
10335 cmdline_fixed_string_t filter;
10337 cmdline_fixed_string_t ops;
10338 cmdline_fixed_string_t dst_ip;
10339 cmdline_ipaddr_t dst_ip_value;
10340 cmdline_fixed_string_t src_ip;
10341 cmdline_ipaddr_t src_ip_value;
10342 cmdline_fixed_string_t dst_port;
10343 uint16_t dst_port_value;
10344 cmdline_fixed_string_t src_port;
10345 uint16_t src_port_value;
10346 cmdline_fixed_string_t protocol;
10347 uint8_t protocol_value;
10348 cmdline_fixed_string_t mask;
10349 uint8_t mask_value;
10350 cmdline_fixed_string_t tcp_flags;
10351 uint8_t tcp_flags_value;
10352 cmdline_fixed_string_t priority;
10353 uint8_t priority_value;
10354 cmdline_fixed_string_t queue;
10359 cmd_5tuple_filter_parsed(void *parsed_result,
10360 __attribute__((unused)) struct cmdline *cl,
10361 __attribute__((unused)) void *data)
10363 struct rte_eth_ntuple_filter filter;
10364 struct cmd_5tuple_filter_result *res = parsed_result;
10367 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10369 printf("ntuple filter is not supported on port %u.\n",
10374 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10376 filter.flags = RTE_5TUPLE_FLAGS;
10377 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10378 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10379 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10380 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10381 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10382 filter.proto = res->protocol_value;
10383 filter.priority = res->priority_value;
10384 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10385 printf("nonzero tcp_flags is only meaningful"
10386 " when protocol is TCP.\n");
10389 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10390 printf("invalid TCP flags.\n");
10394 if (res->tcp_flags_value != 0) {
10395 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10396 filter.tcp_flags = res->tcp_flags_value;
10399 if (res->dst_ip_value.family == AF_INET)
10400 /* no need to convert, already big endian. */
10401 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10403 if (filter.dst_ip_mask == 0) {
10404 printf("can not support ipv6 involved compare.\n");
10410 if (res->src_ip_value.family == AF_INET)
10411 /* no need to convert, already big endian. */
10412 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10414 if (filter.src_ip_mask == 0) {
10415 printf("can not support ipv6 involved compare.\n");
10420 /* need convert to big endian. */
10421 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10422 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10423 filter.queue = res->queue_id;
10425 if (!strcmp(res->ops, "add"))
10426 ret = rte_eth_dev_filter_ctrl(res->port_id,
10427 RTE_ETH_FILTER_NTUPLE,
10428 RTE_ETH_FILTER_ADD,
10431 ret = rte_eth_dev_filter_ctrl(res->port_id,
10432 RTE_ETH_FILTER_NTUPLE,
10433 RTE_ETH_FILTER_DELETE,
10436 printf("5tuple filter programming error: (%s)\n",
10440 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10441 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10442 filter, "5tuple_filter");
10443 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10444 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10446 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10447 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10449 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10450 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10452 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10453 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10455 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10456 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10458 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10459 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10461 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10462 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10463 dst_port, "dst_port");
10464 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10465 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10466 dst_port_value, UINT16);
10467 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10468 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10469 src_port, "src_port");
10470 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10471 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10472 src_port_value, UINT16);
10473 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10474 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10475 protocol, "protocol");
10476 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10477 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10478 protocol_value, UINT8);
10479 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10480 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10482 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10483 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10485 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10486 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10487 tcp_flags, "tcp_flags");
10488 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10489 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10490 tcp_flags_value, UINT8);
10491 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10492 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10493 priority, "priority");
10494 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10495 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10496 priority_value, UINT8);
10497 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10498 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10500 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10501 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10504 cmdline_parse_inst_t cmd_5tuple_filter = {
10505 .f = cmd_5tuple_filter_parsed,
10507 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10508 "src_ip <value> dst_port <value> src_port <value> "
10509 "protocol <value> mask <value> tcp_flags <value> "
10510 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10512 (void *)&cmd_5tuple_filter_filter,
10513 (void *)&cmd_5tuple_filter_port_id,
10514 (void *)&cmd_5tuple_filter_ops,
10515 (void *)&cmd_5tuple_filter_dst_ip,
10516 (void *)&cmd_5tuple_filter_dst_ip_value,
10517 (void *)&cmd_5tuple_filter_src_ip,
10518 (void *)&cmd_5tuple_filter_src_ip_value,
10519 (void *)&cmd_5tuple_filter_dst_port,
10520 (void *)&cmd_5tuple_filter_dst_port_value,
10521 (void *)&cmd_5tuple_filter_src_port,
10522 (void *)&cmd_5tuple_filter_src_port_value,
10523 (void *)&cmd_5tuple_filter_protocol,
10524 (void *)&cmd_5tuple_filter_protocol_value,
10525 (void *)&cmd_5tuple_filter_mask,
10526 (void *)&cmd_5tuple_filter_mask_value,
10527 (void *)&cmd_5tuple_filter_tcp_flags,
10528 (void *)&cmd_5tuple_filter_tcp_flags_value,
10529 (void *)&cmd_5tuple_filter_priority,
10530 (void *)&cmd_5tuple_filter_priority_value,
10531 (void *)&cmd_5tuple_filter_queue,
10532 (void *)&cmd_5tuple_filter_queue_id,
10537 /* *** ADD/REMOVE A flex FILTER *** */
10538 struct cmd_flex_filter_result {
10539 cmdline_fixed_string_t filter;
10540 cmdline_fixed_string_t ops;
10542 cmdline_fixed_string_t len;
10544 cmdline_fixed_string_t bytes;
10545 cmdline_fixed_string_t bytes_value;
10546 cmdline_fixed_string_t mask;
10547 cmdline_fixed_string_t mask_value;
10548 cmdline_fixed_string_t priority;
10549 uint8_t priority_value;
10550 cmdline_fixed_string_t queue;
10554 static int xdigit2val(unsigned char c)
10559 else if (isupper(c))
10560 val = c - 'A' + 10;
10562 val = c - 'a' + 10;
10567 cmd_flex_filter_parsed(void *parsed_result,
10568 __attribute__((unused)) struct cmdline *cl,
10569 __attribute__((unused)) void *data)
10572 struct rte_eth_flex_filter filter;
10573 struct cmd_flex_filter_result *res = parsed_result;
10574 char *bytes_ptr, *mask_ptr;
10575 uint16_t len, i, j = 0;
10580 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10581 printf("the len exceed the max length 128\n");
10584 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10585 filter.len = res->len_value;
10586 filter.priority = res->priority_value;
10587 filter.queue = res->queue_id;
10588 bytes_ptr = res->bytes_value;
10589 mask_ptr = res->mask_value;
10591 /* translate bytes string to array. */
10592 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10593 (bytes_ptr[1] == 'X')))
10595 len = strnlen(bytes_ptr, res->len_value * 2);
10596 if (len == 0 || (len % 8 != 0)) {
10597 printf("please check len and bytes input\n");
10600 for (i = 0; i < len; i++) {
10602 if (isxdigit(c) == 0) {
10603 /* invalid characters. */
10604 printf("invalid input\n");
10607 val = xdigit2val(c);
10610 filter.bytes[j] = byte;
10611 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10618 /* translate mask string to uint8_t array. */
10619 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10620 (mask_ptr[1] == 'X')))
10622 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10624 printf("invalid input\n");
10629 for (i = 0; i < len; i++) {
10631 if (isxdigit(c) == 0) {
10632 /* invalid characters. */
10633 printf("invalid input\n");
10636 val = xdigit2val(c);
10639 filter.mask[j] = byte;
10640 printf("mask[%d]:%02x ", j, filter.mask[j]);
10648 if (!strcmp(res->ops, "add"))
10649 ret = rte_eth_dev_filter_ctrl(res->port_id,
10650 RTE_ETH_FILTER_FLEXIBLE,
10651 RTE_ETH_FILTER_ADD,
10654 ret = rte_eth_dev_filter_ctrl(res->port_id,
10655 RTE_ETH_FILTER_FLEXIBLE,
10656 RTE_ETH_FILTER_DELETE,
10660 printf("flex filter setting error: (%s)\n", strerror(-ret));
10663 cmdline_parse_token_string_t cmd_flex_filter_filter =
10664 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10665 filter, "flex_filter");
10666 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10667 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10669 cmdline_parse_token_string_t cmd_flex_filter_ops =
10670 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10672 cmdline_parse_token_string_t cmd_flex_filter_len =
10673 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10675 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10676 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10678 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10679 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10681 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10682 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10683 bytes_value, NULL);
10684 cmdline_parse_token_string_t cmd_flex_filter_mask =
10685 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10687 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10688 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10690 cmdline_parse_token_string_t cmd_flex_filter_priority =
10691 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10692 priority, "priority");
10693 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10694 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10695 priority_value, UINT8);
10696 cmdline_parse_token_string_t cmd_flex_filter_queue =
10697 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10699 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10700 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10702 cmdline_parse_inst_t cmd_flex_filter = {
10703 .f = cmd_flex_filter_parsed,
10705 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10706 "<value> mask <value> priority <value> queue <queue_id>: "
10707 "Add/Del a flex filter",
10709 (void *)&cmd_flex_filter_filter,
10710 (void *)&cmd_flex_filter_port_id,
10711 (void *)&cmd_flex_filter_ops,
10712 (void *)&cmd_flex_filter_len,
10713 (void *)&cmd_flex_filter_len_value,
10714 (void *)&cmd_flex_filter_bytes,
10715 (void *)&cmd_flex_filter_bytes_value,
10716 (void *)&cmd_flex_filter_mask,
10717 (void *)&cmd_flex_filter_mask_value,
10718 (void *)&cmd_flex_filter_priority,
10719 (void *)&cmd_flex_filter_priority_value,
10720 (void *)&cmd_flex_filter_queue,
10721 (void *)&cmd_flex_filter_queue_id,
10726 /* *** Filters Control *** */
10728 /* *** deal with ethertype filter *** */
10729 struct cmd_ethertype_filter_result {
10730 cmdline_fixed_string_t filter;
10732 cmdline_fixed_string_t ops;
10733 cmdline_fixed_string_t mac;
10734 struct rte_ether_addr mac_addr;
10735 cmdline_fixed_string_t ethertype;
10736 uint16_t ethertype_value;
10737 cmdline_fixed_string_t drop;
10738 cmdline_fixed_string_t queue;
10742 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10743 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10744 filter, "ethertype_filter");
10745 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10746 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10748 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10749 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10751 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10752 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10753 mac, "mac_addr#mac_ignr");
10754 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10755 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10757 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10758 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10759 ethertype, "ethertype");
10760 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10761 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10762 ethertype_value, UINT16);
10763 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10764 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10766 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10767 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10769 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10770 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10774 cmd_ethertype_filter_parsed(void *parsed_result,
10775 __attribute__((unused)) struct cmdline *cl,
10776 __attribute__((unused)) void *data)
10778 struct cmd_ethertype_filter_result *res = parsed_result;
10779 struct rte_eth_ethertype_filter filter;
10782 ret = rte_eth_dev_filter_supported(res->port_id,
10783 RTE_ETH_FILTER_ETHERTYPE);
10785 printf("ethertype filter is not supported on port %u.\n",
10790 memset(&filter, 0, sizeof(filter));
10791 if (!strcmp(res->mac, "mac_addr")) {
10792 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10793 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10794 sizeof(struct rte_ether_addr));
10796 if (!strcmp(res->drop, "drop"))
10797 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10798 filter.ether_type = res->ethertype_value;
10799 filter.queue = res->queue_id;
10801 if (!strcmp(res->ops, "add"))
10802 ret = rte_eth_dev_filter_ctrl(res->port_id,
10803 RTE_ETH_FILTER_ETHERTYPE,
10804 RTE_ETH_FILTER_ADD,
10807 ret = rte_eth_dev_filter_ctrl(res->port_id,
10808 RTE_ETH_FILTER_ETHERTYPE,
10809 RTE_ETH_FILTER_DELETE,
10812 printf("ethertype filter programming error: (%s)\n",
10816 cmdline_parse_inst_t cmd_ethertype_filter = {
10817 .f = cmd_ethertype_filter_parsed,
10819 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10820 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10821 "Add or delete an ethertype filter entry",
10823 (void *)&cmd_ethertype_filter_filter,
10824 (void *)&cmd_ethertype_filter_port_id,
10825 (void *)&cmd_ethertype_filter_ops,
10826 (void *)&cmd_ethertype_filter_mac,
10827 (void *)&cmd_ethertype_filter_mac_addr,
10828 (void *)&cmd_ethertype_filter_ethertype,
10829 (void *)&cmd_ethertype_filter_ethertype_value,
10830 (void *)&cmd_ethertype_filter_drop,
10831 (void *)&cmd_ethertype_filter_queue,
10832 (void *)&cmd_ethertype_filter_queue_id,
10837 /* *** deal with flow director filter *** */
10838 struct cmd_flow_director_result {
10839 cmdline_fixed_string_t flow_director_filter;
10841 cmdline_fixed_string_t mode;
10842 cmdline_fixed_string_t mode_value;
10843 cmdline_fixed_string_t ops;
10844 cmdline_fixed_string_t flow;
10845 cmdline_fixed_string_t flow_type;
10846 cmdline_fixed_string_t ether;
10847 uint16_t ether_type;
10848 cmdline_fixed_string_t src;
10849 cmdline_ipaddr_t ip_src;
10851 cmdline_fixed_string_t dst;
10852 cmdline_ipaddr_t ip_dst;
10854 cmdline_fixed_string_t verify_tag;
10855 uint32_t verify_tag_value;
10856 cmdline_fixed_string_t tos;
10858 cmdline_fixed_string_t proto;
10859 uint8_t proto_value;
10860 cmdline_fixed_string_t ttl;
10862 cmdline_fixed_string_t vlan;
10863 uint16_t vlan_value;
10864 cmdline_fixed_string_t flexbytes;
10865 cmdline_fixed_string_t flexbytes_value;
10866 cmdline_fixed_string_t pf_vf;
10867 cmdline_fixed_string_t drop;
10868 cmdline_fixed_string_t queue;
10870 cmdline_fixed_string_t fd_id;
10871 uint32_t fd_id_value;
10872 cmdline_fixed_string_t mac;
10873 struct rte_ether_addr mac_addr;
10874 cmdline_fixed_string_t tunnel;
10875 cmdline_fixed_string_t tunnel_type;
10876 cmdline_fixed_string_t tunnel_id;
10877 uint32_t tunnel_id_value;
10878 cmdline_fixed_string_t packet;
10883 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10886 const char *p, *p0 = q_arg;
10888 unsigned long int_fld;
10889 char *str_fld[max_num];
10894 p = strchr(p0, '(');
10898 p0 = strchr(p, ')');
10903 if (size >= sizeof(s))
10906 snprintf(s, sizeof(s), "%.*s", size, p);
10907 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10908 if (ret < 0 || ret > max_num)
10910 for (i = 0; i < ret; i++) {
10912 int_fld = strtoul(str_fld[i], &end, 0);
10913 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10915 flexbytes[i] = (uint8_t)int_fld;
10921 str2flowtype(char *string)
10924 static const struct {
10927 } flowtype_str[] = {
10928 {"raw", RTE_ETH_FLOW_RAW},
10929 {"ipv4", RTE_ETH_FLOW_IPV4},
10930 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10931 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10932 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10933 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10934 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10935 {"ipv6", RTE_ETH_FLOW_IPV6},
10936 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10937 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10938 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10939 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10940 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10941 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10944 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10945 if (!strcmp(flowtype_str[i].str, string))
10946 return flowtype_str[i].type;
10949 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10950 return (uint16_t)atoi(string);
10952 return RTE_ETH_FLOW_UNKNOWN;
10955 static enum rte_eth_fdir_tunnel_type
10956 str2fdir_tunneltype(char *string)
10960 static const struct {
10962 enum rte_eth_fdir_tunnel_type type;
10963 } tunneltype_str[] = {
10964 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10965 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10968 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10969 if (!strcmp(tunneltype_str[i].str, string))
10970 return tunneltype_str[i].type;
10972 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10975 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10977 if ((ip_addr).family == AF_INET) \
10978 (ip) = (ip_addr).addr.ipv4.s_addr; \
10980 printf("invalid parameter.\n"); \
10985 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10987 if ((ip_addr).family == AF_INET6) \
10988 rte_memcpy(&(ip), \
10989 &((ip_addr).addr.ipv6), \
10990 sizeof(struct in6_addr)); \
10992 printf("invalid parameter.\n"); \
10998 cmd_flow_director_filter_parsed(void *parsed_result,
10999 __attribute__((unused)) struct cmdline *cl,
11000 __attribute__((unused)) void *data)
11002 struct cmd_flow_director_result *res = parsed_result;
11003 struct rte_eth_fdir_filter entry;
11004 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
11006 unsigned long vf_id;
11009 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11011 printf("flow director is not supported on port %u.\n",
11015 memset(flexbytes, 0, sizeof(flexbytes));
11016 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
11018 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11019 if (strcmp(res->mode_value, "MAC-VLAN")) {
11020 printf("Please set mode to MAC-VLAN.\n");
11023 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11024 if (strcmp(res->mode_value, "Tunnel")) {
11025 printf("Please set mode to Tunnel.\n");
11029 if (!strcmp(res->mode_value, "raw")) {
11030 #ifdef RTE_LIBRTE_I40E_PMD
11031 struct rte_pmd_i40e_flow_type_mapping
11032 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
11033 struct rte_pmd_i40e_pkt_template_conf conf;
11034 uint16_t flow_type = str2flowtype(res->flow_type);
11035 uint16_t i, port = res->port_id;
11038 memset(&conf, 0, sizeof(conf));
11040 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
11041 printf("Invalid flow type specified.\n");
11044 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
11048 if (mapping[flow_type].pctype == 0ULL) {
11049 printf("Invalid flow type specified.\n");
11052 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
11053 if (mapping[flow_type].pctype & (1ULL << i)) {
11054 conf.input.pctype = i;
11059 conf.input.packet = open_file(res->filepath,
11060 &conf.input.length);
11061 if (!conf.input.packet)
11063 if (!strcmp(res->drop, "drop"))
11064 conf.action.behavior =
11065 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
11067 conf.action.behavior =
11068 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
11069 conf.action.report_status =
11070 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
11071 conf.action.rx_queue = res->queue_id;
11072 conf.soft_id = res->fd_id_value;
11073 add = strcmp(res->ops, "del") ? 1 : 0;
11074 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
11078 printf("flow director config error: (%s)\n",
11080 close_file(conf.input.packet);
11083 } else if (strcmp(res->mode_value, "IP")) {
11084 printf("Please set mode to IP or raw.\n");
11087 entry.input.flow_type = str2flowtype(res->flow_type);
11090 ret = parse_flexbytes(res->flexbytes_value,
11092 RTE_ETH_FDIR_MAX_FLEXLEN);
11094 printf("error: Cannot parse flexbytes input.\n");
11098 switch (entry.input.flow_type) {
11099 case RTE_ETH_FLOW_FRAG_IPV4:
11100 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11101 entry.input.flow.ip4_flow.proto = res->proto_value;
11103 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11104 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11105 IPV4_ADDR_TO_UINT(res->ip_dst,
11106 entry.input.flow.ip4_flow.dst_ip);
11107 IPV4_ADDR_TO_UINT(res->ip_src,
11108 entry.input.flow.ip4_flow.src_ip);
11109 entry.input.flow.ip4_flow.tos = res->tos_value;
11110 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11111 /* need convert to big endian. */
11112 entry.input.flow.udp4_flow.dst_port =
11113 rte_cpu_to_be_16(res->port_dst);
11114 entry.input.flow.udp4_flow.src_port =
11115 rte_cpu_to_be_16(res->port_src);
11117 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11118 IPV4_ADDR_TO_UINT(res->ip_dst,
11119 entry.input.flow.sctp4_flow.ip.dst_ip);
11120 IPV4_ADDR_TO_UINT(res->ip_src,
11121 entry.input.flow.sctp4_flow.ip.src_ip);
11122 entry.input.flow.ip4_flow.tos = res->tos_value;
11123 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11124 /* need convert to big endian. */
11125 entry.input.flow.sctp4_flow.dst_port =
11126 rte_cpu_to_be_16(res->port_dst);
11127 entry.input.flow.sctp4_flow.src_port =
11128 rte_cpu_to_be_16(res->port_src);
11129 entry.input.flow.sctp4_flow.verify_tag =
11130 rte_cpu_to_be_32(res->verify_tag_value);
11132 case RTE_ETH_FLOW_FRAG_IPV6:
11133 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11134 entry.input.flow.ipv6_flow.proto = res->proto_value;
11136 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11137 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11138 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11139 entry.input.flow.ipv6_flow.dst_ip);
11140 IPV6_ADDR_TO_ARRAY(res->ip_src,
11141 entry.input.flow.ipv6_flow.src_ip);
11142 entry.input.flow.ipv6_flow.tc = res->tos_value;
11143 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11144 /* need convert to big endian. */
11145 entry.input.flow.udp6_flow.dst_port =
11146 rte_cpu_to_be_16(res->port_dst);
11147 entry.input.flow.udp6_flow.src_port =
11148 rte_cpu_to_be_16(res->port_src);
11150 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11151 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11152 entry.input.flow.sctp6_flow.ip.dst_ip);
11153 IPV6_ADDR_TO_ARRAY(res->ip_src,
11154 entry.input.flow.sctp6_flow.ip.src_ip);
11155 entry.input.flow.ipv6_flow.tc = res->tos_value;
11156 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11157 /* need convert to big endian. */
11158 entry.input.flow.sctp6_flow.dst_port =
11159 rte_cpu_to_be_16(res->port_dst);
11160 entry.input.flow.sctp6_flow.src_port =
11161 rte_cpu_to_be_16(res->port_src);
11162 entry.input.flow.sctp6_flow.verify_tag =
11163 rte_cpu_to_be_32(res->verify_tag_value);
11165 case RTE_ETH_FLOW_L2_PAYLOAD:
11166 entry.input.flow.l2_flow.ether_type =
11167 rte_cpu_to_be_16(res->ether_type);
11173 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11174 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11176 sizeof(struct rte_ether_addr));
11178 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11179 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11181 sizeof(struct rte_ether_addr));
11182 entry.input.flow.tunnel_flow.tunnel_type =
11183 str2fdir_tunneltype(res->tunnel_type);
11184 entry.input.flow.tunnel_flow.tunnel_id =
11185 rte_cpu_to_be_32(res->tunnel_id_value);
11188 rte_memcpy(entry.input.flow_ext.flexbytes,
11190 RTE_ETH_FDIR_MAX_FLEXLEN);
11192 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11194 entry.action.flex_off = 0; /*use 0 by default */
11195 if (!strcmp(res->drop, "drop"))
11196 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11198 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11200 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11201 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11202 if (!strcmp(res->pf_vf, "pf"))
11203 entry.input.flow_ext.is_vf = 0;
11204 else if (!strncmp(res->pf_vf, "vf", 2)) {
11205 struct rte_eth_dev_info dev_info;
11207 ret = eth_dev_info_get_print_err(res->port_id,
11213 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11214 if (errno != 0 || *end != '\0' ||
11215 vf_id >= dev_info.max_vfs) {
11216 printf("invalid parameter %s.\n", res->pf_vf);
11219 entry.input.flow_ext.is_vf = 1;
11220 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11222 printf("invalid parameter %s.\n", res->pf_vf);
11227 /* set to report FD ID by default */
11228 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11229 entry.action.rx_queue = res->queue_id;
11230 entry.soft_id = res->fd_id_value;
11231 if (!strcmp(res->ops, "add"))
11232 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11233 RTE_ETH_FILTER_ADD, &entry);
11234 else if (!strcmp(res->ops, "del"))
11235 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11236 RTE_ETH_FILTER_DELETE, &entry);
11238 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11239 RTE_ETH_FILTER_UPDATE, &entry);
11241 printf("flow director programming error: (%s)\n",
11245 cmdline_parse_token_string_t cmd_flow_director_filter =
11246 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11247 flow_director_filter, "flow_director_filter");
11248 cmdline_parse_token_num_t cmd_flow_director_port_id =
11249 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11251 cmdline_parse_token_string_t cmd_flow_director_ops =
11252 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11253 ops, "add#del#update");
11254 cmdline_parse_token_string_t cmd_flow_director_flow =
11255 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11257 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11258 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11260 cmdline_parse_token_string_t cmd_flow_director_ether =
11261 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11263 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11264 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11265 ether_type, UINT16);
11266 cmdline_parse_token_string_t cmd_flow_director_src =
11267 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11269 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11270 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11272 cmdline_parse_token_num_t cmd_flow_director_port_src =
11273 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11275 cmdline_parse_token_string_t cmd_flow_director_dst =
11276 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11278 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11279 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11281 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11282 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11284 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11285 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11286 verify_tag, "verify_tag");
11287 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11288 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11289 verify_tag_value, UINT32);
11290 cmdline_parse_token_string_t cmd_flow_director_tos =
11291 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11293 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11294 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11296 cmdline_parse_token_string_t cmd_flow_director_proto =
11297 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11299 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11300 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11301 proto_value, UINT8);
11302 cmdline_parse_token_string_t cmd_flow_director_ttl =
11303 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11305 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11306 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11308 cmdline_parse_token_string_t cmd_flow_director_vlan =
11309 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11311 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11312 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11313 vlan_value, UINT16);
11314 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11315 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11316 flexbytes, "flexbytes");
11317 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11318 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11319 flexbytes_value, NULL);
11320 cmdline_parse_token_string_t cmd_flow_director_drop =
11321 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11323 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11324 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11326 cmdline_parse_token_string_t cmd_flow_director_queue =
11327 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11329 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11330 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11332 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11333 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11335 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11336 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11337 fd_id_value, UINT32);
11339 cmdline_parse_token_string_t cmd_flow_director_mode =
11340 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11342 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11343 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11345 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11346 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11347 mode_value, "MAC-VLAN");
11348 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11349 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11350 mode_value, "Tunnel");
11351 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11352 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11353 mode_value, "raw");
11354 cmdline_parse_token_string_t cmd_flow_director_mac =
11355 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11357 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11358 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11360 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11361 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11363 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11364 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11365 tunnel_type, "NVGRE#VxLAN");
11366 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11367 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11368 tunnel_id, "tunnel-id");
11369 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11370 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11371 tunnel_id_value, UINT32);
11372 cmdline_parse_token_string_t cmd_flow_director_packet =
11373 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11375 cmdline_parse_token_string_t cmd_flow_director_filepath =
11376 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11379 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11380 .f = cmd_flow_director_filter_parsed,
11382 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11383 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11384 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11385 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11386 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11387 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11388 "fd_id <fd_id_value>: "
11389 "Add or delete an ip flow director entry on NIC",
11391 (void *)&cmd_flow_director_filter,
11392 (void *)&cmd_flow_director_port_id,
11393 (void *)&cmd_flow_director_mode,
11394 (void *)&cmd_flow_director_mode_ip,
11395 (void *)&cmd_flow_director_ops,
11396 (void *)&cmd_flow_director_flow,
11397 (void *)&cmd_flow_director_flow_type,
11398 (void *)&cmd_flow_director_src,
11399 (void *)&cmd_flow_director_ip_src,
11400 (void *)&cmd_flow_director_dst,
11401 (void *)&cmd_flow_director_ip_dst,
11402 (void *)&cmd_flow_director_tos,
11403 (void *)&cmd_flow_director_tos_value,
11404 (void *)&cmd_flow_director_proto,
11405 (void *)&cmd_flow_director_proto_value,
11406 (void *)&cmd_flow_director_ttl,
11407 (void *)&cmd_flow_director_ttl_value,
11408 (void *)&cmd_flow_director_vlan,
11409 (void *)&cmd_flow_director_vlan_value,
11410 (void *)&cmd_flow_director_flexbytes,
11411 (void *)&cmd_flow_director_flexbytes_value,
11412 (void *)&cmd_flow_director_drop,
11413 (void *)&cmd_flow_director_pf_vf,
11414 (void *)&cmd_flow_director_queue,
11415 (void *)&cmd_flow_director_queue_id,
11416 (void *)&cmd_flow_director_fd_id,
11417 (void *)&cmd_flow_director_fd_id_value,
11422 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11423 .f = cmd_flow_director_filter_parsed,
11425 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11426 "director entry on NIC",
11428 (void *)&cmd_flow_director_filter,
11429 (void *)&cmd_flow_director_port_id,
11430 (void *)&cmd_flow_director_mode,
11431 (void *)&cmd_flow_director_mode_ip,
11432 (void *)&cmd_flow_director_ops,
11433 (void *)&cmd_flow_director_flow,
11434 (void *)&cmd_flow_director_flow_type,
11435 (void *)&cmd_flow_director_src,
11436 (void *)&cmd_flow_director_ip_src,
11437 (void *)&cmd_flow_director_port_src,
11438 (void *)&cmd_flow_director_dst,
11439 (void *)&cmd_flow_director_ip_dst,
11440 (void *)&cmd_flow_director_port_dst,
11441 (void *)&cmd_flow_director_tos,
11442 (void *)&cmd_flow_director_tos_value,
11443 (void *)&cmd_flow_director_ttl,
11444 (void *)&cmd_flow_director_ttl_value,
11445 (void *)&cmd_flow_director_vlan,
11446 (void *)&cmd_flow_director_vlan_value,
11447 (void *)&cmd_flow_director_flexbytes,
11448 (void *)&cmd_flow_director_flexbytes_value,
11449 (void *)&cmd_flow_director_drop,
11450 (void *)&cmd_flow_director_pf_vf,
11451 (void *)&cmd_flow_director_queue,
11452 (void *)&cmd_flow_director_queue_id,
11453 (void *)&cmd_flow_director_fd_id,
11454 (void *)&cmd_flow_director_fd_id_value,
11459 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11460 .f = cmd_flow_director_filter_parsed,
11462 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11463 "director entry on NIC",
11465 (void *)&cmd_flow_director_filter,
11466 (void *)&cmd_flow_director_port_id,
11467 (void *)&cmd_flow_director_mode,
11468 (void *)&cmd_flow_director_mode_ip,
11469 (void *)&cmd_flow_director_ops,
11470 (void *)&cmd_flow_director_flow,
11471 (void *)&cmd_flow_director_flow_type,
11472 (void *)&cmd_flow_director_src,
11473 (void *)&cmd_flow_director_ip_src,
11474 (void *)&cmd_flow_director_port_src,
11475 (void *)&cmd_flow_director_dst,
11476 (void *)&cmd_flow_director_ip_dst,
11477 (void *)&cmd_flow_director_port_dst,
11478 (void *)&cmd_flow_director_verify_tag,
11479 (void *)&cmd_flow_director_verify_tag_value,
11480 (void *)&cmd_flow_director_tos,
11481 (void *)&cmd_flow_director_tos_value,
11482 (void *)&cmd_flow_director_ttl,
11483 (void *)&cmd_flow_director_ttl_value,
11484 (void *)&cmd_flow_director_vlan,
11485 (void *)&cmd_flow_director_vlan_value,
11486 (void *)&cmd_flow_director_flexbytes,
11487 (void *)&cmd_flow_director_flexbytes_value,
11488 (void *)&cmd_flow_director_drop,
11489 (void *)&cmd_flow_director_pf_vf,
11490 (void *)&cmd_flow_director_queue,
11491 (void *)&cmd_flow_director_queue_id,
11492 (void *)&cmd_flow_director_fd_id,
11493 (void *)&cmd_flow_director_fd_id_value,
11498 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11499 .f = cmd_flow_director_filter_parsed,
11501 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11502 "director entry on NIC",
11504 (void *)&cmd_flow_director_filter,
11505 (void *)&cmd_flow_director_port_id,
11506 (void *)&cmd_flow_director_mode,
11507 (void *)&cmd_flow_director_mode_ip,
11508 (void *)&cmd_flow_director_ops,
11509 (void *)&cmd_flow_director_flow,
11510 (void *)&cmd_flow_director_flow_type,
11511 (void *)&cmd_flow_director_ether,
11512 (void *)&cmd_flow_director_ether_type,
11513 (void *)&cmd_flow_director_flexbytes,
11514 (void *)&cmd_flow_director_flexbytes_value,
11515 (void *)&cmd_flow_director_drop,
11516 (void *)&cmd_flow_director_pf_vf,
11517 (void *)&cmd_flow_director_queue,
11518 (void *)&cmd_flow_director_queue_id,
11519 (void *)&cmd_flow_director_fd_id,
11520 (void *)&cmd_flow_director_fd_id_value,
11525 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11526 .f = cmd_flow_director_filter_parsed,
11528 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11529 "director entry on NIC",
11531 (void *)&cmd_flow_director_filter,
11532 (void *)&cmd_flow_director_port_id,
11533 (void *)&cmd_flow_director_mode,
11534 (void *)&cmd_flow_director_mode_mac_vlan,
11535 (void *)&cmd_flow_director_ops,
11536 (void *)&cmd_flow_director_mac,
11537 (void *)&cmd_flow_director_mac_addr,
11538 (void *)&cmd_flow_director_vlan,
11539 (void *)&cmd_flow_director_vlan_value,
11540 (void *)&cmd_flow_director_flexbytes,
11541 (void *)&cmd_flow_director_flexbytes_value,
11542 (void *)&cmd_flow_director_drop,
11543 (void *)&cmd_flow_director_queue,
11544 (void *)&cmd_flow_director_queue_id,
11545 (void *)&cmd_flow_director_fd_id,
11546 (void *)&cmd_flow_director_fd_id_value,
11551 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11552 .f = cmd_flow_director_filter_parsed,
11554 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11555 "director entry on NIC",
11557 (void *)&cmd_flow_director_filter,
11558 (void *)&cmd_flow_director_port_id,
11559 (void *)&cmd_flow_director_mode,
11560 (void *)&cmd_flow_director_mode_tunnel,
11561 (void *)&cmd_flow_director_ops,
11562 (void *)&cmd_flow_director_mac,
11563 (void *)&cmd_flow_director_mac_addr,
11564 (void *)&cmd_flow_director_vlan,
11565 (void *)&cmd_flow_director_vlan_value,
11566 (void *)&cmd_flow_director_tunnel,
11567 (void *)&cmd_flow_director_tunnel_type,
11568 (void *)&cmd_flow_director_tunnel_id,
11569 (void *)&cmd_flow_director_tunnel_id_value,
11570 (void *)&cmd_flow_director_flexbytes,
11571 (void *)&cmd_flow_director_flexbytes_value,
11572 (void *)&cmd_flow_director_drop,
11573 (void *)&cmd_flow_director_queue,
11574 (void *)&cmd_flow_director_queue_id,
11575 (void *)&cmd_flow_director_fd_id,
11576 (void *)&cmd_flow_director_fd_id_value,
11581 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11582 .f = cmd_flow_director_filter_parsed,
11584 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11585 "director entry on NIC",
11587 (void *)&cmd_flow_director_filter,
11588 (void *)&cmd_flow_director_port_id,
11589 (void *)&cmd_flow_director_mode,
11590 (void *)&cmd_flow_director_mode_raw,
11591 (void *)&cmd_flow_director_ops,
11592 (void *)&cmd_flow_director_flow,
11593 (void *)&cmd_flow_director_flow_type,
11594 (void *)&cmd_flow_director_drop,
11595 (void *)&cmd_flow_director_queue,
11596 (void *)&cmd_flow_director_queue_id,
11597 (void *)&cmd_flow_director_fd_id,
11598 (void *)&cmd_flow_director_fd_id_value,
11599 (void *)&cmd_flow_director_packet,
11600 (void *)&cmd_flow_director_filepath,
11605 struct cmd_flush_flow_director_result {
11606 cmdline_fixed_string_t flush_flow_director;
11610 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11611 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11612 flush_flow_director, "flush_flow_director");
11613 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11614 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11618 cmd_flush_flow_director_parsed(void *parsed_result,
11619 __attribute__((unused)) struct cmdline *cl,
11620 __attribute__((unused)) void *data)
11622 struct cmd_flow_director_result *res = parsed_result;
11625 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11627 printf("flow director is not supported on port %u.\n",
11632 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11633 RTE_ETH_FILTER_FLUSH, NULL);
11635 printf("flow director table flushing error: (%s)\n",
11639 cmdline_parse_inst_t cmd_flush_flow_director = {
11640 .f = cmd_flush_flow_director_parsed,
11642 .help_str = "flush_flow_director <port_id>: "
11643 "Flush all flow director entries of a device on NIC",
11645 (void *)&cmd_flush_flow_director_flush,
11646 (void *)&cmd_flush_flow_director_port_id,
11651 /* *** deal with flow director mask *** */
11652 struct cmd_flow_director_mask_result {
11653 cmdline_fixed_string_t flow_director_mask;
11655 cmdline_fixed_string_t mode;
11656 cmdline_fixed_string_t mode_value;
11657 cmdline_fixed_string_t vlan;
11658 uint16_t vlan_mask;
11659 cmdline_fixed_string_t src_mask;
11660 cmdline_ipaddr_t ipv4_src;
11661 cmdline_ipaddr_t ipv6_src;
11663 cmdline_fixed_string_t dst_mask;
11664 cmdline_ipaddr_t ipv4_dst;
11665 cmdline_ipaddr_t ipv6_dst;
11667 cmdline_fixed_string_t mac;
11668 uint8_t mac_addr_byte_mask;
11669 cmdline_fixed_string_t tunnel_id;
11670 uint32_t tunnel_id_mask;
11671 cmdline_fixed_string_t tunnel_type;
11672 uint8_t tunnel_type_mask;
11676 cmd_flow_director_mask_parsed(void *parsed_result,
11677 __attribute__((unused)) struct cmdline *cl,
11678 __attribute__((unused)) void *data)
11680 struct cmd_flow_director_mask_result *res = parsed_result;
11681 struct rte_eth_fdir_masks *mask;
11682 struct rte_port *port;
11684 port = &ports[res->port_id];
11685 /** Check if the port is not started **/
11686 if (port->port_status != RTE_PORT_STOPPED) {
11687 printf("Please stop port %d first\n", res->port_id);
11691 mask = &port->dev_conf.fdir_conf.mask;
11693 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11694 if (strcmp(res->mode_value, "MAC-VLAN")) {
11695 printf("Please set mode to MAC-VLAN.\n");
11699 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11700 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11701 if (strcmp(res->mode_value, "Tunnel")) {
11702 printf("Please set mode to Tunnel.\n");
11706 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11707 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11708 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11709 mask->tunnel_type_mask = res->tunnel_type_mask;
11711 if (strcmp(res->mode_value, "IP")) {
11712 printf("Please set mode to IP.\n");
11716 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11717 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11718 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11719 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11720 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11721 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11722 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11725 cmd_reconfig_device_queue(res->port_id, 1, 1);
11728 cmdline_parse_token_string_t cmd_flow_director_mask =
11729 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11730 flow_director_mask, "flow_director_mask");
11731 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11732 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11734 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11735 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11737 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11738 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11739 vlan_mask, UINT16);
11740 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11741 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11742 src_mask, "src_mask");
11743 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11744 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11746 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11747 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11749 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11750 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11752 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11753 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11754 dst_mask, "dst_mask");
11755 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11756 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11758 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11759 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11761 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11762 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11765 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11766 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11768 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11769 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11771 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11772 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11773 mode_value, "MAC-VLAN");
11774 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11775 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11776 mode_value, "Tunnel");
11777 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11778 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11780 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11781 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11782 mac_addr_byte_mask, UINT8);
11783 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11784 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11785 tunnel_type, "tunnel-type");
11786 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11787 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11788 tunnel_type_mask, UINT8);
11789 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11790 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11791 tunnel_id, "tunnel-id");
11792 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11793 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11794 tunnel_id_mask, UINT32);
11796 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11797 .f = cmd_flow_director_mask_parsed,
11799 .help_str = "flow_director_mask ... : "
11800 "Set IP mode flow director's mask on NIC",
11802 (void *)&cmd_flow_director_mask,
11803 (void *)&cmd_flow_director_mask_port_id,
11804 (void *)&cmd_flow_director_mask_mode,
11805 (void *)&cmd_flow_director_mask_mode_ip,
11806 (void *)&cmd_flow_director_mask_vlan,
11807 (void *)&cmd_flow_director_mask_vlan_value,
11808 (void *)&cmd_flow_director_mask_src,
11809 (void *)&cmd_flow_director_mask_ipv4_src,
11810 (void *)&cmd_flow_director_mask_ipv6_src,
11811 (void *)&cmd_flow_director_mask_port_src,
11812 (void *)&cmd_flow_director_mask_dst,
11813 (void *)&cmd_flow_director_mask_ipv4_dst,
11814 (void *)&cmd_flow_director_mask_ipv6_dst,
11815 (void *)&cmd_flow_director_mask_port_dst,
11820 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11821 .f = cmd_flow_director_mask_parsed,
11823 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11824 "flow director's mask on NIC",
11826 (void *)&cmd_flow_director_mask,
11827 (void *)&cmd_flow_director_mask_port_id,
11828 (void *)&cmd_flow_director_mask_mode,
11829 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11830 (void *)&cmd_flow_director_mask_vlan,
11831 (void *)&cmd_flow_director_mask_vlan_value,
11836 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11837 .f = cmd_flow_director_mask_parsed,
11839 .help_str = "flow_director_mask ... : Set tunnel mode "
11840 "flow director's mask on NIC",
11842 (void *)&cmd_flow_director_mask,
11843 (void *)&cmd_flow_director_mask_port_id,
11844 (void *)&cmd_flow_director_mask_mode,
11845 (void *)&cmd_flow_director_mask_mode_tunnel,
11846 (void *)&cmd_flow_director_mask_vlan,
11847 (void *)&cmd_flow_director_mask_vlan_value,
11848 (void *)&cmd_flow_director_mask_mac,
11849 (void *)&cmd_flow_director_mask_mac_value,
11850 (void *)&cmd_flow_director_mask_tunnel_type,
11851 (void *)&cmd_flow_director_mask_tunnel_type_value,
11852 (void *)&cmd_flow_director_mask_tunnel_id,
11853 (void *)&cmd_flow_director_mask_tunnel_id_value,
11858 /* *** deal with flow director mask on flexible payload *** */
11859 struct cmd_flow_director_flex_mask_result {
11860 cmdline_fixed_string_t flow_director_flexmask;
11862 cmdline_fixed_string_t flow;
11863 cmdline_fixed_string_t flow_type;
11864 cmdline_fixed_string_t mask;
11868 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11869 __attribute__((unused)) struct cmdline *cl,
11870 __attribute__((unused)) void *data)
11872 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11873 struct rte_eth_fdir_info fdir_info;
11874 struct rte_eth_fdir_flex_mask flex_mask;
11875 struct rte_port *port;
11876 uint64_t flow_type_mask;
11880 port = &ports[res->port_id];
11881 /** Check if the port is not started **/
11882 if (port->port_status != RTE_PORT_STOPPED) {
11883 printf("Please stop port %d first\n", res->port_id);
11887 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11888 ret = parse_flexbytes(res->mask,
11890 RTE_ETH_FDIR_MAX_FLEXLEN);
11892 printf("error: Cannot parse mask input.\n");
11896 memset(&fdir_info, 0, sizeof(fdir_info));
11897 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11898 RTE_ETH_FILTER_INFO, &fdir_info);
11900 printf("Cannot get FDir filter info\n");
11904 if (!strcmp(res->flow_type, "none")) {
11905 /* means don't specify the flow type */
11906 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11907 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11908 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11909 0, sizeof(struct rte_eth_fdir_flex_mask));
11910 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11911 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11913 sizeof(struct rte_eth_fdir_flex_mask));
11914 cmd_reconfig_device_queue(res->port_id, 1, 1);
11917 flow_type_mask = fdir_info.flow_types_mask[0];
11918 if (!strcmp(res->flow_type, "all")) {
11919 if (!flow_type_mask) {
11920 printf("No flow type supported\n");
11923 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11924 if (flow_type_mask & (1ULL << i)) {
11925 flex_mask.flow_type = i;
11926 fdir_set_flex_mask(res->port_id, &flex_mask);
11929 cmd_reconfig_device_queue(res->port_id, 1, 1);
11932 flex_mask.flow_type = str2flowtype(res->flow_type);
11933 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11934 printf("Flow type %s not supported on port %d\n",
11935 res->flow_type, res->port_id);
11938 fdir_set_flex_mask(res->port_id, &flex_mask);
11939 cmd_reconfig_device_queue(res->port_id, 1, 1);
11942 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11943 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11944 flow_director_flexmask,
11945 "flow_director_flex_mask");
11946 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11947 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11949 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11950 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11952 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11953 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11954 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11955 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11956 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11957 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11960 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11961 .f = cmd_flow_director_flex_mask_parsed,
11963 .help_str = "flow_director_flex_mask ... : "
11964 "Set flow director's flex mask on NIC",
11966 (void *)&cmd_flow_director_flexmask,
11967 (void *)&cmd_flow_director_flexmask_port_id,
11968 (void *)&cmd_flow_director_flexmask_flow,
11969 (void *)&cmd_flow_director_flexmask_flow_type,
11970 (void *)&cmd_flow_director_flexmask_mask,
11975 /* *** deal with flow director flexible payload configuration *** */
11976 struct cmd_flow_director_flexpayload_result {
11977 cmdline_fixed_string_t flow_director_flexpayload;
11979 cmdline_fixed_string_t payload_layer;
11980 cmdline_fixed_string_t payload_cfg;
11984 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11987 const char *p, *p0 = q_arg;
11989 unsigned long int_fld;
11990 char *str_fld[max_num];
11995 p = strchr(p0, '(');
11999 p0 = strchr(p, ')');
12004 if (size >= sizeof(s))
12007 snprintf(s, sizeof(s), "%.*s", size, p);
12008 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
12009 if (ret < 0 || ret > max_num)
12011 for (i = 0; i < ret; i++) {
12013 int_fld = strtoul(str_fld[i], &end, 0);
12014 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
12016 offsets[i] = (uint16_t)int_fld;
12022 cmd_flow_director_flxpld_parsed(void *parsed_result,
12023 __attribute__((unused)) struct cmdline *cl,
12024 __attribute__((unused)) void *data)
12026 struct cmd_flow_director_flexpayload_result *res = parsed_result;
12027 struct rte_eth_flex_payload_cfg flex_cfg;
12028 struct rte_port *port;
12031 port = &ports[res->port_id];
12032 /** Check if the port is not started **/
12033 if (port->port_status != RTE_PORT_STOPPED) {
12034 printf("Please stop port %d first\n", res->port_id);
12038 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
12040 if (!strcmp(res->payload_layer, "raw"))
12041 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
12042 else if (!strcmp(res->payload_layer, "l2"))
12043 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
12044 else if (!strcmp(res->payload_layer, "l3"))
12045 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
12046 else if (!strcmp(res->payload_layer, "l4"))
12047 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
12049 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
12050 RTE_ETH_FDIR_MAX_FLEXLEN);
12052 printf("error: Cannot parse flex payload input.\n");
12056 fdir_set_flex_payload(res->port_id, &flex_cfg);
12057 cmd_reconfig_device_queue(res->port_id, 1, 1);
12060 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
12061 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12062 flow_director_flexpayload,
12063 "flow_director_flex_payload");
12064 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
12065 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12067 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
12068 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12069 payload_layer, "raw#l2#l3#l4");
12070 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
12071 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
12072 payload_cfg, NULL);
12074 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
12075 .f = cmd_flow_director_flxpld_parsed,
12077 .help_str = "flow_director_flexpayload ... : "
12078 "Set flow director's flex payload on NIC",
12080 (void *)&cmd_flow_director_flexpayload,
12081 (void *)&cmd_flow_director_flexpayload_port_id,
12082 (void *)&cmd_flow_director_flexpayload_payload_layer,
12083 (void *)&cmd_flow_director_flexpayload_payload_cfg,
12088 /* Generic flow interface command. */
12089 extern cmdline_parse_inst_t cmd_flow;
12091 /* *** Classification Filters Control *** */
12092 /* *** Get symmetric hash enable per port *** */
12093 struct cmd_get_sym_hash_ena_per_port_result {
12094 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12099 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12100 __rte_unused struct cmdline *cl,
12101 __rte_unused void *data)
12103 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12104 struct rte_eth_hash_filter_info info;
12107 if (rte_eth_dev_filter_supported(res->port_id,
12108 RTE_ETH_FILTER_HASH) < 0) {
12109 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12114 memset(&info, 0, sizeof(info));
12115 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12116 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12117 RTE_ETH_FILTER_GET, &info);
12120 printf("Cannot get symmetric hash enable per port "
12121 "on port %u\n", res->port_id);
12125 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12126 "enabled" : "disabled", res->port_id);
12129 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12130 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12131 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12132 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12133 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12136 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12137 .f = cmd_get_sym_hash_per_port_parsed,
12139 .help_str = "get_sym_hash_ena_per_port <port_id>",
12141 (void *)&cmd_get_sym_hash_ena_per_port_all,
12142 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12147 /* *** Set symmetric hash enable per port *** */
12148 struct cmd_set_sym_hash_ena_per_port_result {
12149 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12150 cmdline_fixed_string_t enable;
12155 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12156 __rte_unused struct cmdline *cl,
12157 __rte_unused void *data)
12159 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12160 struct rte_eth_hash_filter_info info;
12163 if (rte_eth_dev_filter_supported(res->port_id,
12164 RTE_ETH_FILTER_HASH) < 0) {
12165 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12170 memset(&info, 0, sizeof(info));
12171 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12172 if (!strcmp(res->enable, "enable"))
12173 info.info.enable = 1;
12174 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12175 RTE_ETH_FILTER_SET, &info);
12177 printf("Cannot set symmetric hash enable per port on "
12178 "port %u\n", res->port_id);
12181 printf("Symmetric hash has been set to %s on port %u\n",
12182 res->enable, res->port_id);
12185 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12186 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12187 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12188 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12189 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12191 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12192 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12193 enable, "enable#disable");
12195 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12196 .f = cmd_set_sym_hash_per_port_parsed,
12198 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12200 (void *)&cmd_set_sym_hash_ena_per_port_all,
12201 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12202 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12207 /* Get global config of hash function */
12208 struct cmd_get_hash_global_config_result {
12209 cmdline_fixed_string_t get_hash_global_config;
12214 flowtype_to_str(uint16_t ftype)
12220 } ftype_table[] = {
12221 {"ipv4", RTE_ETH_FLOW_IPV4},
12222 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12223 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12224 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12225 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12226 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12227 {"ipv6", RTE_ETH_FLOW_IPV6},
12228 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12229 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12230 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12231 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12232 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12233 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12234 {"port", RTE_ETH_FLOW_PORT},
12235 {"vxlan", RTE_ETH_FLOW_VXLAN},
12236 {"geneve", RTE_ETH_FLOW_GENEVE},
12237 {"nvgre", RTE_ETH_FLOW_NVGRE},
12238 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12241 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12242 if (ftype_table[i].ftype == ftype)
12243 return ftype_table[i].str;
12250 cmd_get_hash_global_config_parsed(void *parsed_result,
12251 __rte_unused struct cmdline *cl,
12252 __rte_unused void *data)
12254 struct cmd_get_hash_global_config_result *res = parsed_result;
12255 struct rte_eth_hash_filter_info info;
12256 uint32_t idx, offset;
12261 if (rte_eth_dev_filter_supported(res->port_id,
12262 RTE_ETH_FILTER_HASH) < 0) {
12263 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12268 memset(&info, 0, sizeof(info));
12269 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12270 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12271 RTE_ETH_FILTER_GET, &info);
12273 printf("Cannot get hash global configurations by port %d\n",
12278 switch (info.info.global_conf.hash_func) {
12279 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12280 printf("Hash function is Toeplitz\n");
12282 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12283 printf("Hash function is Simple XOR\n");
12285 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12286 printf("Hash function is Symmetric Toeplitz\n");
12289 printf("Unknown hash function\n");
12293 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12294 idx = i / UINT64_BIT;
12295 offset = i % UINT64_BIT;
12296 if (!(info.info.global_conf.valid_bit_mask[idx] &
12299 str = flowtype_to_str(i);
12302 printf("Symmetric hash is %s globally for flow type %s "
12304 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12305 (1ULL << offset)) ? "enabled" : "disabled"), str,
12310 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12311 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12312 get_hash_global_config, "get_hash_global_config");
12313 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12314 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12317 cmdline_parse_inst_t cmd_get_hash_global_config = {
12318 .f = cmd_get_hash_global_config_parsed,
12320 .help_str = "get_hash_global_config <port_id>",
12322 (void *)&cmd_get_hash_global_config_all,
12323 (void *)&cmd_get_hash_global_config_port_id,
12328 /* Set global config of hash function */
12329 struct cmd_set_hash_global_config_result {
12330 cmdline_fixed_string_t set_hash_global_config;
12332 cmdline_fixed_string_t hash_func;
12333 cmdline_fixed_string_t flow_type;
12334 cmdline_fixed_string_t enable;
12338 cmd_set_hash_global_config_parsed(void *parsed_result,
12339 __rte_unused struct cmdline *cl,
12340 __rte_unused void *data)
12342 struct cmd_set_hash_global_config_result *res = parsed_result;
12343 struct rte_eth_hash_filter_info info;
12344 uint32_t ftype, idx, offset;
12347 if (rte_eth_dev_filter_supported(res->port_id,
12348 RTE_ETH_FILTER_HASH) < 0) {
12349 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12353 memset(&info, 0, sizeof(info));
12354 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12355 if (!strcmp(res->hash_func, "toeplitz"))
12356 info.info.global_conf.hash_func =
12357 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12358 else if (!strcmp(res->hash_func, "simple_xor"))
12359 info.info.global_conf.hash_func =
12360 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12361 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12362 info.info.global_conf.hash_func =
12363 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12364 else if (!strcmp(res->hash_func, "default"))
12365 info.info.global_conf.hash_func =
12366 RTE_ETH_HASH_FUNCTION_DEFAULT;
12368 ftype = str2flowtype(res->flow_type);
12369 idx = ftype / UINT64_BIT;
12370 offset = ftype % UINT64_BIT;
12371 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12372 if (!strcmp(res->enable, "enable"))
12373 info.info.global_conf.sym_hash_enable_mask[idx] |=
12375 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12376 RTE_ETH_FILTER_SET, &info);
12378 printf("Cannot set global hash configurations by port %d\n",
12381 printf("Global hash configurations have been set "
12382 "successfully by port %d\n", res->port_id);
12385 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12386 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12387 set_hash_global_config, "set_hash_global_config");
12388 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12389 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12391 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12392 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12393 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12394 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12395 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12397 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12398 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12399 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12400 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12401 enable, "enable#disable");
12403 cmdline_parse_inst_t cmd_set_hash_global_config = {
12404 .f = cmd_set_hash_global_config_parsed,
12406 .help_str = "set_hash_global_config <port_id> "
12407 "toeplitz|simple_xor|symmetric_toeplitz|default "
12408 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12409 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12410 "l2_payload enable|disable",
12412 (void *)&cmd_set_hash_global_config_all,
12413 (void *)&cmd_set_hash_global_config_port_id,
12414 (void *)&cmd_set_hash_global_config_hash_func,
12415 (void *)&cmd_set_hash_global_config_flow_type,
12416 (void *)&cmd_set_hash_global_config_enable,
12421 /* Set hash input set */
12422 struct cmd_set_hash_input_set_result {
12423 cmdline_fixed_string_t set_hash_input_set;
12425 cmdline_fixed_string_t flow_type;
12426 cmdline_fixed_string_t inset_field;
12427 cmdline_fixed_string_t select;
12430 static enum rte_eth_input_set_field
12431 str2inset(char *string)
12435 static const struct {
12437 enum rte_eth_input_set_field inset;
12438 } inset_table[] = {
12439 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12440 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12441 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12442 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12443 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12444 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12445 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12446 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12447 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12448 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12449 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12450 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12451 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12452 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12453 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12454 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12455 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12456 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12457 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12458 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12459 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12460 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12461 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12462 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12463 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12464 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12465 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12466 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12467 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12468 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12469 {"none", RTE_ETH_INPUT_SET_NONE},
12472 for (i = 0; i < RTE_DIM(inset_table); i++) {
12473 if (!strcmp(string, inset_table[i].str))
12474 return inset_table[i].inset;
12477 return RTE_ETH_INPUT_SET_UNKNOWN;
12481 cmd_set_hash_input_set_parsed(void *parsed_result,
12482 __rte_unused struct cmdline *cl,
12483 __rte_unused void *data)
12485 struct cmd_set_hash_input_set_result *res = parsed_result;
12486 struct rte_eth_hash_filter_info info;
12488 memset(&info, 0, sizeof(info));
12489 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12490 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12491 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12492 info.info.input_set_conf.inset_size = 1;
12493 if (!strcmp(res->select, "select"))
12494 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12495 else if (!strcmp(res->select, "add"))
12496 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12497 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12498 RTE_ETH_FILTER_SET, &info);
12501 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12502 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12503 set_hash_input_set, "set_hash_input_set");
12504 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12505 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12507 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12508 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12510 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12511 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12513 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12514 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12515 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12516 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12517 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12519 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12520 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12521 select, "select#add");
12523 cmdline_parse_inst_t cmd_set_hash_input_set = {
12524 .f = cmd_set_hash_input_set_parsed,
12526 .help_str = "set_hash_input_set <port_id> "
12527 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12528 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12529 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12530 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12531 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12532 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12533 "fld-7th|fld-8th|none select|add",
12535 (void *)&cmd_set_hash_input_set_cmd,
12536 (void *)&cmd_set_hash_input_set_port_id,
12537 (void *)&cmd_set_hash_input_set_flow_type,
12538 (void *)&cmd_set_hash_input_set_field,
12539 (void *)&cmd_set_hash_input_set_select,
12544 /* Set flow director input set */
12545 struct cmd_set_fdir_input_set_result {
12546 cmdline_fixed_string_t set_fdir_input_set;
12548 cmdline_fixed_string_t flow_type;
12549 cmdline_fixed_string_t inset_field;
12550 cmdline_fixed_string_t select;
12554 cmd_set_fdir_input_set_parsed(void *parsed_result,
12555 __rte_unused struct cmdline *cl,
12556 __rte_unused void *data)
12558 struct cmd_set_fdir_input_set_result *res = parsed_result;
12559 struct rte_eth_fdir_filter_info info;
12561 memset(&info, 0, sizeof(info));
12562 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12563 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12564 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12565 info.info.input_set_conf.inset_size = 1;
12566 if (!strcmp(res->select, "select"))
12567 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12568 else if (!strcmp(res->select, "add"))
12569 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12570 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12571 RTE_ETH_FILTER_SET, &info);
12574 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12575 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12576 set_fdir_input_set, "set_fdir_input_set");
12577 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12578 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12580 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12581 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12583 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12584 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12585 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12586 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12588 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12589 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12590 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12591 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12592 "sctp-veri-tag#none");
12593 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12594 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12595 select, "select#add");
12597 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12598 .f = cmd_set_fdir_input_set_parsed,
12600 .help_str = "set_fdir_input_set <port_id> "
12601 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12602 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12603 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12604 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12605 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12606 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12607 "sctp-veri-tag|none select|add",
12609 (void *)&cmd_set_fdir_input_set_cmd,
12610 (void *)&cmd_set_fdir_input_set_port_id,
12611 (void *)&cmd_set_fdir_input_set_flow_type,
12612 (void *)&cmd_set_fdir_input_set_field,
12613 (void *)&cmd_set_fdir_input_set_select,
12618 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12619 struct cmd_mcast_addr_result {
12620 cmdline_fixed_string_t mcast_addr_cmd;
12621 cmdline_fixed_string_t what;
12623 struct rte_ether_addr mc_addr;
12626 static void cmd_mcast_addr_parsed(void *parsed_result,
12627 __attribute__((unused)) struct cmdline *cl,
12628 __attribute__((unused)) void *data)
12630 struct cmd_mcast_addr_result *res = parsed_result;
12632 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12633 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12634 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12635 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12636 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12639 if (strcmp(res->what, "add") == 0)
12640 mcast_addr_add(res->port_num, &res->mc_addr);
12642 mcast_addr_remove(res->port_num, &res->mc_addr);
12645 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12646 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12647 mcast_addr_cmd, "mcast_addr");
12648 cmdline_parse_token_string_t cmd_mcast_addr_what =
12649 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12651 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12652 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12653 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12654 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12656 cmdline_parse_inst_t cmd_mcast_addr = {
12657 .f = cmd_mcast_addr_parsed,
12659 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12660 "Add/Remove multicast MAC address on port_id",
12662 (void *)&cmd_mcast_addr_cmd,
12663 (void *)&cmd_mcast_addr_what,
12664 (void *)&cmd_mcast_addr_portnum,
12665 (void *)&cmd_mcast_addr_addr,
12670 /* l2 tunnel config
12671 * only support E-tag now.
12674 /* Ether type config */
12675 struct cmd_config_l2_tunnel_eth_type_result {
12676 cmdline_fixed_string_t port;
12677 cmdline_fixed_string_t config;
12678 cmdline_fixed_string_t all;
12680 cmdline_fixed_string_t l2_tunnel;
12681 cmdline_fixed_string_t l2_tunnel_type;
12682 cmdline_fixed_string_t eth_type;
12683 uint16_t eth_type_val;
12686 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12687 TOKEN_STRING_INITIALIZER
12688 (struct cmd_config_l2_tunnel_eth_type_result,
12690 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12691 TOKEN_STRING_INITIALIZER
12692 (struct cmd_config_l2_tunnel_eth_type_result,
12694 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12695 TOKEN_STRING_INITIALIZER
12696 (struct cmd_config_l2_tunnel_eth_type_result,
12698 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12699 TOKEN_NUM_INITIALIZER
12700 (struct cmd_config_l2_tunnel_eth_type_result,
12702 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12703 TOKEN_STRING_INITIALIZER
12704 (struct cmd_config_l2_tunnel_eth_type_result,
12705 l2_tunnel, "l2-tunnel");
12706 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12707 TOKEN_STRING_INITIALIZER
12708 (struct cmd_config_l2_tunnel_eth_type_result,
12709 l2_tunnel_type, "E-tag");
12710 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12711 TOKEN_STRING_INITIALIZER
12712 (struct cmd_config_l2_tunnel_eth_type_result,
12713 eth_type, "ether-type");
12714 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12715 TOKEN_NUM_INITIALIZER
12716 (struct cmd_config_l2_tunnel_eth_type_result,
12717 eth_type_val, UINT16);
12719 static enum rte_eth_tunnel_type
12720 str2fdir_l2_tunnel_type(char *string)
12724 static const struct {
12726 enum rte_eth_tunnel_type type;
12727 } l2_tunnel_type_str[] = {
12728 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12731 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12732 if (!strcmp(l2_tunnel_type_str[i].str, string))
12733 return l2_tunnel_type_str[i].type;
12735 return RTE_TUNNEL_TYPE_NONE;
12738 /* ether type config for all ports */
12740 cmd_config_l2_tunnel_eth_type_all_parsed
12741 (void *parsed_result,
12742 __attribute__((unused)) struct cmdline *cl,
12743 __attribute__((unused)) void *data)
12745 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12746 struct rte_eth_l2_tunnel_conf entry;
12749 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12750 entry.ether_type = res->eth_type_val;
12752 RTE_ETH_FOREACH_DEV(pid) {
12753 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12757 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12758 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12760 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12762 (void *)&cmd_config_l2_tunnel_eth_type_port,
12763 (void *)&cmd_config_l2_tunnel_eth_type_config,
12764 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12765 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12766 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12767 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12768 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12773 /* ether type config for a specific port */
12775 cmd_config_l2_tunnel_eth_type_specific_parsed(
12776 void *parsed_result,
12777 __attribute__((unused)) struct cmdline *cl,
12778 __attribute__((unused)) void *data)
12780 struct cmd_config_l2_tunnel_eth_type_result *res =
12782 struct rte_eth_l2_tunnel_conf entry;
12784 if (port_id_is_invalid(res->id, ENABLED_WARN))
12787 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12788 entry.ether_type = res->eth_type_val;
12790 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12793 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12794 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12796 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12798 (void *)&cmd_config_l2_tunnel_eth_type_port,
12799 (void *)&cmd_config_l2_tunnel_eth_type_config,
12800 (void *)&cmd_config_l2_tunnel_eth_type_id,
12801 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12802 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12803 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12804 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12809 /* Enable/disable l2 tunnel */
12810 struct cmd_config_l2_tunnel_en_dis_result {
12811 cmdline_fixed_string_t port;
12812 cmdline_fixed_string_t config;
12813 cmdline_fixed_string_t all;
12815 cmdline_fixed_string_t l2_tunnel;
12816 cmdline_fixed_string_t l2_tunnel_type;
12817 cmdline_fixed_string_t en_dis;
12820 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12821 TOKEN_STRING_INITIALIZER
12822 (struct cmd_config_l2_tunnel_en_dis_result,
12824 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12825 TOKEN_STRING_INITIALIZER
12826 (struct cmd_config_l2_tunnel_en_dis_result,
12828 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12829 TOKEN_STRING_INITIALIZER
12830 (struct cmd_config_l2_tunnel_en_dis_result,
12832 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12833 TOKEN_NUM_INITIALIZER
12834 (struct cmd_config_l2_tunnel_en_dis_result,
12836 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12837 TOKEN_STRING_INITIALIZER
12838 (struct cmd_config_l2_tunnel_en_dis_result,
12839 l2_tunnel, "l2-tunnel");
12840 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12841 TOKEN_STRING_INITIALIZER
12842 (struct cmd_config_l2_tunnel_en_dis_result,
12843 l2_tunnel_type, "E-tag");
12844 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12845 TOKEN_STRING_INITIALIZER
12846 (struct cmd_config_l2_tunnel_en_dis_result,
12847 en_dis, "enable#disable");
12849 /* enable/disable l2 tunnel for all ports */
12851 cmd_config_l2_tunnel_en_dis_all_parsed(
12852 void *parsed_result,
12853 __attribute__((unused)) struct cmdline *cl,
12854 __attribute__((unused)) void *data)
12856 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12857 struct rte_eth_l2_tunnel_conf entry;
12861 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12863 if (!strcmp("enable", res->en_dis))
12868 RTE_ETH_FOREACH_DEV(pid) {
12869 rte_eth_dev_l2_tunnel_offload_set(pid,
12871 ETH_L2_TUNNEL_ENABLE_MASK,
12876 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12877 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12879 .help_str = "port config all l2-tunnel E-tag enable|disable",
12881 (void *)&cmd_config_l2_tunnel_en_dis_port,
12882 (void *)&cmd_config_l2_tunnel_en_dis_config,
12883 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12884 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12885 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12886 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12891 /* enable/disable l2 tunnel for a port */
12893 cmd_config_l2_tunnel_en_dis_specific_parsed(
12894 void *parsed_result,
12895 __attribute__((unused)) struct cmdline *cl,
12896 __attribute__((unused)) void *data)
12898 struct cmd_config_l2_tunnel_en_dis_result *res =
12900 struct rte_eth_l2_tunnel_conf entry;
12902 if (port_id_is_invalid(res->id, ENABLED_WARN))
12905 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12907 if (!strcmp("enable", res->en_dis))
12908 rte_eth_dev_l2_tunnel_offload_set(res->id,
12910 ETH_L2_TUNNEL_ENABLE_MASK,
12913 rte_eth_dev_l2_tunnel_offload_set(res->id,
12915 ETH_L2_TUNNEL_ENABLE_MASK,
12919 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12920 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12922 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12924 (void *)&cmd_config_l2_tunnel_en_dis_port,
12925 (void *)&cmd_config_l2_tunnel_en_dis_config,
12926 (void *)&cmd_config_l2_tunnel_en_dis_id,
12927 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12928 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12929 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12934 /* E-tag configuration */
12936 /* Common result structure for all E-tag configuration */
12937 struct cmd_config_e_tag_result {
12938 cmdline_fixed_string_t e_tag;
12939 cmdline_fixed_string_t set;
12940 cmdline_fixed_string_t insertion;
12941 cmdline_fixed_string_t stripping;
12942 cmdline_fixed_string_t forwarding;
12943 cmdline_fixed_string_t filter;
12944 cmdline_fixed_string_t add;
12945 cmdline_fixed_string_t del;
12946 cmdline_fixed_string_t on;
12947 cmdline_fixed_string_t off;
12948 cmdline_fixed_string_t on_off;
12949 cmdline_fixed_string_t port_tag_id;
12950 uint32_t port_tag_id_val;
12951 cmdline_fixed_string_t e_tag_id;
12952 uint16_t e_tag_id_val;
12953 cmdline_fixed_string_t dst_pool;
12954 uint8_t dst_pool_val;
12955 cmdline_fixed_string_t port;
12957 cmdline_fixed_string_t vf;
12961 /* Common CLI fields for all E-tag configuration */
12962 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12963 TOKEN_STRING_INITIALIZER
12964 (struct cmd_config_e_tag_result,
12966 cmdline_parse_token_string_t cmd_config_e_tag_set =
12967 TOKEN_STRING_INITIALIZER
12968 (struct cmd_config_e_tag_result,
12970 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12971 TOKEN_STRING_INITIALIZER
12972 (struct cmd_config_e_tag_result,
12973 insertion, "insertion");
12974 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12975 TOKEN_STRING_INITIALIZER
12976 (struct cmd_config_e_tag_result,
12977 stripping, "stripping");
12978 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12979 TOKEN_STRING_INITIALIZER
12980 (struct cmd_config_e_tag_result,
12981 forwarding, "forwarding");
12982 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12983 TOKEN_STRING_INITIALIZER
12984 (struct cmd_config_e_tag_result,
12986 cmdline_parse_token_string_t cmd_config_e_tag_add =
12987 TOKEN_STRING_INITIALIZER
12988 (struct cmd_config_e_tag_result,
12990 cmdline_parse_token_string_t cmd_config_e_tag_del =
12991 TOKEN_STRING_INITIALIZER
12992 (struct cmd_config_e_tag_result,
12994 cmdline_parse_token_string_t cmd_config_e_tag_on =
12995 TOKEN_STRING_INITIALIZER
12996 (struct cmd_config_e_tag_result,
12998 cmdline_parse_token_string_t cmd_config_e_tag_off =
12999 TOKEN_STRING_INITIALIZER
13000 (struct cmd_config_e_tag_result,
13002 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
13003 TOKEN_STRING_INITIALIZER
13004 (struct cmd_config_e_tag_result,
13006 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
13007 TOKEN_STRING_INITIALIZER
13008 (struct cmd_config_e_tag_result,
13009 port_tag_id, "port-tag-id");
13010 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
13011 TOKEN_NUM_INITIALIZER
13012 (struct cmd_config_e_tag_result,
13013 port_tag_id_val, UINT32);
13014 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
13015 TOKEN_STRING_INITIALIZER
13016 (struct cmd_config_e_tag_result,
13017 e_tag_id, "e-tag-id");
13018 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
13019 TOKEN_NUM_INITIALIZER
13020 (struct cmd_config_e_tag_result,
13021 e_tag_id_val, UINT16);
13022 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
13023 TOKEN_STRING_INITIALIZER
13024 (struct cmd_config_e_tag_result,
13025 dst_pool, "dst-pool");
13026 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
13027 TOKEN_NUM_INITIALIZER
13028 (struct cmd_config_e_tag_result,
13029 dst_pool_val, UINT8);
13030 cmdline_parse_token_string_t cmd_config_e_tag_port =
13031 TOKEN_STRING_INITIALIZER
13032 (struct cmd_config_e_tag_result,
13034 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
13035 TOKEN_NUM_INITIALIZER
13036 (struct cmd_config_e_tag_result,
13038 cmdline_parse_token_string_t cmd_config_e_tag_vf =
13039 TOKEN_STRING_INITIALIZER
13040 (struct cmd_config_e_tag_result,
13042 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
13043 TOKEN_NUM_INITIALIZER
13044 (struct cmd_config_e_tag_result,
13047 /* E-tag insertion configuration */
13049 cmd_config_e_tag_insertion_en_parsed(
13050 void *parsed_result,
13051 __attribute__((unused)) struct cmdline *cl,
13052 __attribute__((unused)) void *data)
13054 struct cmd_config_e_tag_result *res =
13056 struct rte_eth_l2_tunnel_conf entry;
13058 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13061 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13062 entry.tunnel_id = res->port_tag_id_val;
13063 entry.vf_id = res->vf_id;
13064 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13066 ETH_L2_TUNNEL_INSERTION_MASK,
13071 cmd_config_e_tag_insertion_dis_parsed(
13072 void *parsed_result,
13073 __attribute__((unused)) struct cmdline *cl,
13074 __attribute__((unused)) void *data)
13076 struct cmd_config_e_tag_result *res =
13078 struct rte_eth_l2_tunnel_conf entry;
13080 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13083 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13084 entry.vf_id = res->vf_id;
13086 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
13088 ETH_L2_TUNNEL_INSERTION_MASK,
13092 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13093 .f = cmd_config_e_tag_insertion_en_parsed,
13095 .help_str = "E-tag ... : E-tag insertion enable",
13097 (void *)&cmd_config_e_tag_e_tag,
13098 (void *)&cmd_config_e_tag_set,
13099 (void *)&cmd_config_e_tag_insertion,
13100 (void *)&cmd_config_e_tag_on,
13101 (void *)&cmd_config_e_tag_port_tag_id,
13102 (void *)&cmd_config_e_tag_port_tag_id_val,
13103 (void *)&cmd_config_e_tag_port,
13104 (void *)&cmd_config_e_tag_port_id,
13105 (void *)&cmd_config_e_tag_vf,
13106 (void *)&cmd_config_e_tag_vf_id,
13111 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13112 .f = cmd_config_e_tag_insertion_dis_parsed,
13114 .help_str = "E-tag ... : E-tag insertion disable",
13116 (void *)&cmd_config_e_tag_e_tag,
13117 (void *)&cmd_config_e_tag_set,
13118 (void *)&cmd_config_e_tag_insertion,
13119 (void *)&cmd_config_e_tag_off,
13120 (void *)&cmd_config_e_tag_port,
13121 (void *)&cmd_config_e_tag_port_id,
13122 (void *)&cmd_config_e_tag_vf,
13123 (void *)&cmd_config_e_tag_vf_id,
13128 /* E-tag stripping configuration */
13130 cmd_config_e_tag_stripping_parsed(
13131 void *parsed_result,
13132 __attribute__((unused)) struct cmdline *cl,
13133 __attribute__((unused)) void *data)
13135 struct cmd_config_e_tag_result *res =
13137 struct rte_eth_l2_tunnel_conf entry;
13139 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13142 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13144 if (!strcmp(res->on_off, "on"))
13145 rte_eth_dev_l2_tunnel_offload_set
13148 ETH_L2_TUNNEL_STRIPPING_MASK,
13151 rte_eth_dev_l2_tunnel_offload_set
13154 ETH_L2_TUNNEL_STRIPPING_MASK,
13158 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13159 .f = cmd_config_e_tag_stripping_parsed,
13161 .help_str = "E-tag ... : E-tag stripping enable/disable",
13163 (void *)&cmd_config_e_tag_e_tag,
13164 (void *)&cmd_config_e_tag_set,
13165 (void *)&cmd_config_e_tag_stripping,
13166 (void *)&cmd_config_e_tag_on_off,
13167 (void *)&cmd_config_e_tag_port,
13168 (void *)&cmd_config_e_tag_port_id,
13173 /* E-tag forwarding configuration */
13175 cmd_config_e_tag_forwarding_parsed(
13176 void *parsed_result,
13177 __attribute__((unused)) struct cmdline *cl,
13178 __attribute__((unused)) void *data)
13180 struct cmd_config_e_tag_result *res = parsed_result;
13181 struct rte_eth_l2_tunnel_conf entry;
13183 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13186 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13188 if (!strcmp(res->on_off, "on"))
13189 rte_eth_dev_l2_tunnel_offload_set
13192 ETH_L2_TUNNEL_FORWARDING_MASK,
13195 rte_eth_dev_l2_tunnel_offload_set
13198 ETH_L2_TUNNEL_FORWARDING_MASK,
13202 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13203 .f = cmd_config_e_tag_forwarding_parsed,
13205 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13207 (void *)&cmd_config_e_tag_e_tag,
13208 (void *)&cmd_config_e_tag_set,
13209 (void *)&cmd_config_e_tag_forwarding,
13210 (void *)&cmd_config_e_tag_on_off,
13211 (void *)&cmd_config_e_tag_port,
13212 (void *)&cmd_config_e_tag_port_id,
13217 /* E-tag filter configuration */
13219 cmd_config_e_tag_filter_add_parsed(
13220 void *parsed_result,
13221 __attribute__((unused)) struct cmdline *cl,
13222 __attribute__((unused)) void *data)
13224 struct cmd_config_e_tag_result *res = parsed_result;
13225 struct rte_eth_l2_tunnel_conf entry;
13228 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13231 if (res->e_tag_id_val > 0x3fff) {
13232 printf("e-tag-id must be equal or less than 0x3fff.\n");
13236 ret = rte_eth_dev_filter_supported(res->port_id,
13237 RTE_ETH_FILTER_L2_TUNNEL);
13239 printf("E-tag filter is not supported on port %u.\n",
13244 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13245 entry.tunnel_id = res->e_tag_id_val;
13246 entry.pool = res->dst_pool_val;
13248 ret = rte_eth_dev_filter_ctrl(res->port_id,
13249 RTE_ETH_FILTER_L2_TUNNEL,
13250 RTE_ETH_FILTER_ADD,
13253 printf("E-tag filter programming error: (%s)\n",
13257 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13258 .f = cmd_config_e_tag_filter_add_parsed,
13260 .help_str = "E-tag ... : E-tag filter add",
13262 (void *)&cmd_config_e_tag_e_tag,
13263 (void *)&cmd_config_e_tag_set,
13264 (void *)&cmd_config_e_tag_filter,
13265 (void *)&cmd_config_e_tag_add,
13266 (void *)&cmd_config_e_tag_e_tag_id,
13267 (void *)&cmd_config_e_tag_e_tag_id_val,
13268 (void *)&cmd_config_e_tag_dst_pool,
13269 (void *)&cmd_config_e_tag_dst_pool_val,
13270 (void *)&cmd_config_e_tag_port,
13271 (void *)&cmd_config_e_tag_port_id,
13277 cmd_config_e_tag_filter_del_parsed(
13278 void *parsed_result,
13279 __attribute__((unused)) struct cmdline *cl,
13280 __attribute__((unused)) void *data)
13282 struct cmd_config_e_tag_result *res = parsed_result;
13283 struct rte_eth_l2_tunnel_conf entry;
13286 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13289 if (res->e_tag_id_val > 0x3fff) {
13290 printf("e-tag-id must be less than 0x3fff.\n");
13294 ret = rte_eth_dev_filter_supported(res->port_id,
13295 RTE_ETH_FILTER_L2_TUNNEL);
13297 printf("E-tag filter is not supported on port %u.\n",
13302 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13303 entry.tunnel_id = res->e_tag_id_val;
13305 ret = rte_eth_dev_filter_ctrl(res->port_id,
13306 RTE_ETH_FILTER_L2_TUNNEL,
13307 RTE_ETH_FILTER_DELETE,
13310 printf("E-tag filter programming error: (%s)\n",
13314 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13315 .f = cmd_config_e_tag_filter_del_parsed,
13317 .help_str = "E-tag ... : E-tag filter delete",
13319 (void *)&cmd_config_e_tag_e_tag,
13320 (void *)&cmd_config_e_tag_set,
13321 (void *)&cmd_config_e_tag_filter,
13322 (void *)&cmd_config_e_tag_del,
13323 (void *)&cmd_config_e_tag_e_tag_id,
13324 (void *)&cmd_config_e_tag_e_tag_id_val,
13325 (void *)&cmd_config_e_tag_port,
13326 (void *)&cmd_config_e_tag_port_id,
13331 /* vf vlan anti spoof configuration */
13333 /* Common result structure for vf vlan anti spoof */
13334 struct cmd_vf_vlan_anti_spoof_result {
13335 cmdline_fixed_string_t set;
13336 cmdline_fixed_string_t vf;
13337 cmdline_fixed_string_t vlan;
13338 cmdline_fixed_string_t antispoof;
13341 cmdline_fixed_string_t on_off;
13344 /* Common CLI fields for vf vlan anti spoof enable disable */
13345 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13346 TOKEN_STRING_INITIALIZER
13347 (struct cmd_vf_vlan_anti_spoof_result,
13349 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13350 TOKEN_STRING_INITIALIZER
13351 (struct cmd_vf_vlan_anti_spoof_result,
13353 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13354 TOKEN_STRING_INITIALIZER
13355 (struct cmd_vf_vlan_anti_spoof_result,
13357 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13358 TOKEN_STRING_INITIALIZER
13359 (struct cmd_vf_vlan_anti_spoof_result,
13360 antispoof, "antispoof");
13361 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13362 TOKEN_NUM_INITIALIZER
13363 (struct cmd_vf_vlan_anti_spoof_result,
13365 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13366 TOKEN_NUM_INITIALIZER
13367 (struct cmd_vf_vlan_anti_spoof_result,
13369 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13370 TOKEN_STRING_INITIALIZER
13371 (struct cmd_vf_vlan_anti_spoof_result,
13375 cmd_set_vf_vlan_anti_spoof_parsed(
13376 void *parsed_result,
13377 __attribute__((unused)) struct cmdline *cl,
13378 __attribute__((unused)) void *data)
13380 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13381 int ret = -ENOTSUP;
13383 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13385 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13388 #ifdef RTE_LIBRTE_IXGBE_PMD
13389 if (ret == -ENOTSUP)
13390 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13391 res->vf_id, is_on);
13393 #ifdef RTE_LIBRTE_I40E_PMD
13394 if (ret == -ENOTSUP)
13395 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13396 res->vf_id, is_on);
13398 #ifdef RTE_LIBRTE_BNXT_PMD
13399 if (ret == -ENOTSUP)
13400 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13401 res->vf_id, is_on);
13408 printf("invalid vf_id %d\n", res->vf_id);
13411 printf("invalid port_id %d\n", res->port_id);
13414 printf("function not implemented\n");
13417 printf("programming error: (%s)\n", strerror(-ret));
13421 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13422 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13424 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13426 (void *)&cmd_vf_vlan_anti_spoof_set,
13427 (void *)&cmd_vf_vlan_anti_spoof_vf,
13428 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13429 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13430 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13431 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13432 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13437 /* vf mac anti spoof configuration */
13439 /* Common result structure for vf mac anti spoof */
13440 struct cmd_vf_mac_anti_spoof_result {
13441 cmdline_fixed_string_t set;
13442 cmdline_fixed_string_t vf;
13443 cmdline_fixed_string_t mac;
13444 cmdline_fixed_string_t antispoof;
13447 cmdline_fixed_string_t on_off;
13450 /* Common CLI fields for vf mac anti spoof enable disable */
13451 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13452 TOKEN_STRING_INITIALIZER
13453 (struct cmd_vf_mac_anti_spoof_result,
13455 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13456 TOKEN_STRING_INITIALIZER
13457 (struct cmd_vf_mac_anti_spoof_result,
13459 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13460 TOKEN_STRING_INITIALIZER
13461 (struct cmd_vf_mac_anti_spoof_result,
13463 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13464 TOKEN_STRING_INITIALIZER
13465 (struct cmd_vf_mac_anti_spoof_result,
13466 antispoof, "antispoof");
13467 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13468 TOKEN_NUM_INITIALIZER
13469 (struct cmd_vf_mac_anti_spoof_result,
13471 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13472 TOKEN_NUM_INITIALIZER
13473 (struct cmd_vf_mac_anti_spoof_result,
13475 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13476 TOKEN_STRING_INITIALIZER
13477 (struct cmd_vf_mac_anti_spoof_result,
13481 cmd_set_vf_mac_anti_spoof_parsed(
13482 void *parsed_result,
13483 __attribute__((unused)) struct cmdline *cl,
13484 __attribute__((unused)) void *data)
13486 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13487 int ret = -ENOTSUP;
13489 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13491 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13494 #ifdef RTE_LIBRTE_IXGBE_PMD
13495 if (ret == -ENOTSUP)
13496 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13497 res->vf_id, is_on);
13499 #ifdef RTE_LIBRTE_I40E_PMD
13500 if (ret == -ENOTSUP)
13501 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13502 res->vf_id, is_on);
13504 #ifdef RTE_LIBRTE_BNXT_PMD
13505 if (ret == -ENOTSUP)
13506 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13507 res->vf_id, is_on);
13514 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13517 printf("invalid port_id %d\n", res->port_id);
13520 printf("function not implemented\n");
13523 printf("programming error: (%s)\n", strerror(-ret));
13527 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13528 .f = cmd_set_vf_mac_anti_spoof_parsed,
13530 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13532 (void *)&cmd_vf_mac_anti_spoof_set,
13533 (void *)&cmd_vf_mac_anti_spoof_vf,
13534 (void *)&cmd_vf_mac_anti_spoof_mac,
13535 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13536 (void *)&cmd_vf_mac_anti_spoof_port_id,
13537 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13538 (void *)&cmd_vf_mac_anti_spoof_on_off,
13543 /* vf vlan strip queue configuration */
13545 /* Common result structure for vf mac anti spoof */
13546 struct cmd_vf_vlan_stripq_result {
13547 cmdline_fixed_string_t set;
13548 cmdline_fixed_string_t vf;
13549 cmdline_fixed_string_t vlan;
13550 cmdline_fixed_string_t stripq;
13553 cmdline_fixed_string_t on_off;
13556 /* Common CLI fields for vf vlan strip enable disable */
13557 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13558 TOKEN_STRING_INITIALIZER
13559 (struct cmd_vf_vlan_stripq_result,
13561 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13562 TOKEN_STRING_INITIALIZER
13563 (struct cmd_vf_vlan_stripq_result,
13565 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13566 TOKEN_STRING_INITIALIZER
13567 (struct cmd_vf_vlan_stripq_result,
13569 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13570 TOKEN_STRING_INITIALIZER
13571 (struct cmd_vf_vlan_stripq_result,
13573 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13574 TOKEN_NUM_INITIALIZER
13575 (struct cmd_vf_vlan_stripq_result,
13577 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13578 TOKEN_NUM_INITIALIZER
13579 (struct cmd_vf_vlan_stripq_result,
13581 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13582 TOKEN_STRING_INITIALIZER
13583 (struct cmd_vf_vlan_stripq_result,
13587 cmd_set_vf_vlan_stripq_parsed(
13588 void *parsed_result,
13589 __attribute__((unused)) struct cmdline *cl,
13590 __attribute__((unused)) void *data)
13592 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13593 int ret = -ENOTSUP;
13595 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13597 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13600 #ifdef RTE_LIBRTE_IXGBE_PMD
13601 if (ret == -ENOTSUP)
13602 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13603 res->vf_id, is_on);
13605 #ifdef RTE_LIBRTE_I40E_PMD
13606 if (ret == -ENOTSUP)
13607 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13608 res->vf_id, is_on);
13610 #ifdef RTE_LIBRTE_BNXT_PMD
13611 if (ret == -ENOTSUP)
13612 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13613 res->vf_id, is_on);
13620 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13623 printf("invalid port_id %d\n", res->port_id);
13626 printf("function not implemented\n");
13629 printf("programming error: (%s)\n", strerror(-ret));
13633 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13634 .f = cmd_set_vf_vlan_stripq_parsed,
13636 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13638 (void *)&cmd_vf_vlan_stripq_set,
13639 (void *)&cmd_vf_vlan_stripq_vf,
13640 (void *)&cmd_vf_vlan_stripq_vlan,
13641 (void *)&cmd_vf_vlan_stripq_stripq,
13642 (void *)&cmd_vf_vlan_stripq_port_id,
13643 (void *)&cmd_vf_vlan_stripq_vf_id,
13644 (void *)&cmd_vf_vlan_stripq_on_off,
13649 /* vf vlan insert configuration */
13651 /* Common result structure for vf vlan insert */
13652 struct cmd_vf_vlan_insert_result {
13653 cmdline_fixed_string_t set;
13654 cmdline_fixed_string_t vf;
13655 cmdline_fixed_string_t vlan;
13656 cmdline_fixed_string_t insert;
13662 /* Common CLI fields for vf vlan insert enable disable */
13663 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13664 TOKEN_STRING_INITIALIZER
13665 (struct cmd_vf_vlan_insert_result,
13667 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13668 TOKEN_STRING_INITIALIZER
13669 (struct cmd_vf_vlan_insert_result,
13671 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13672 TOKEN_STRING_INITIALIZER
13673 (struct cmd_vf_vlan_insert_result,
13675 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13676 TOKEN_STRING_INITIALIZER
13677 (struct cmd_vf_vlan_insert_result,
13679 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13680 TOKEN_NUM_INITIALIZER
13681 (struct cmd_vf_vlan_insert_result,
13683 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13684 TOKEN_NUM_INITIALIZER
13685 (struct cmd_vf_vlan_insert_result,
13687 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13688 TOKEN_NUM_INITIALIZER
13689 (struct cmd_vf_vlan_insert_result,
13693 cmd_set_vf_vlan_insert_parsed(
13694 void *parsed_result,
13695 __attribute__((unused)) struct cmdline *cl,
13696 __attribute__((unused)) void *data)
13698 struct cmd_vf_vlan_insert_result *res = parsed_result;
13699 int ret = -ENOTSUP;
13701 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13704 #ifdef RTE_LIBRTE_IXGBE_PMD
13705 if (ret == -ENOTSUP)
13706 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13709 #ifdef RTE_LIBRTE_I40E_PMD
13710 if (ret == -ENOTSUP)
13711 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13714 #ifdef RTE_LIBRTE_BNXT_PMD
13715 if (ret == -ENOTSUP)
13716 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13724 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13727 printf("invalid port_id %d\n", res->port_id);
13730 printf("function not implemented\n");
13733 printf("programming error: (%s)\n", strerror(-ret));
13737 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13738 .f = cmd_set_vf_vlan_insert_parsed,
13740 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13742 (void *)&cmd_vf_vlan_insert_set,
13743 (void *)&cmd_vf_vlan_insert_vf,
13744 (void *)&cmd_vf_vlan_insert_vlan,
13745 (void *)&cmd_vf_vlan_insert_insert,
13746 (void *)&cmd_vf_vlan_insert_port_id,
13747 (void *)&cmd_vf_vlan_insert_vf_id,
13748 (void *)&cmd_vf_vlan_insert_vlan_id,
13753 /* tx loopback configuration */
13755 /* Common result structure for tx loopback */
13756 struct cmd_tx_loopback_result {
13757 cmdline_fixed_string_t set;
13758 cmdline_fixed_string_t tx;
13759 cmdline_fixed_string_t loopback;
13761 cmdline_fixed_string_t on_off;
13764 /* Common CLI fields for tx loopback enable disable */
13765 cmdline_parse_token_string_t cmd_tx_loopback_set =
13766 TOKEN_STRING_INITIALIZER
13767 (struct cmd_tx_loopback_result,
13769 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13770 TOKEN_STRING_INITIALIZER
13771 (struct cmd_tx_loopback_result,
13773 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13774 TOKEN_STRING_INITIALIZER
13775 (struct cmd_tx_loopback_result,
13776 loopback, "loopback");
13777 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13778 TOKEN_NUM_INITIALIZER
13779 (struct cmd_tx_loopback_result,
13781 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13782 TOKEN_STRING_INITIALIZER
13783 (struct cmd_tx_loopback_result,
13787 cmd_set_tx_loopback_parsed(
13788 void *parsed_result,
13789 __attribute__((unused)) struct cmdline *cl,
13790 __attribute__((unused)) void *data)
13792 struct cmd_tx_loopback_result *res = parsed_result;
13793 int ret = -ENOTSUP;
13795 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13797 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13800 #ifdef RTE_LIBRTE_IXGBE_PMD
13801 if (ret == -ENOTSUP)
13802 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13804 #ifdef RTE_LIBRTE_I40E_PMD
13805 if (ret == -ENOTSUP)
13806 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13808 #ifdef RTE_LIBRTE_BNXT_PMD
13809 if (ret == -ENOTSUP)
13810 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13812 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13813 if (ret == -ENOTSUP)
13814 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13821 printf("invalid is_on %d\n", is_on);
13824 printf("invalid port_id %d\n", res->port_id);
13827 printf("function not implemented\n");
13830 printf("programming error: (%s)\n", strerror(-ret));
13834 cmdline_parse_inst_t cmd_set_tx_loopback = {
13835 .f = cmd_set_tx_loopback_parsed,
13837 .help_str = "set tx loopback <port_id> on|off",
13839 (void *)&cmd_tx_loopback_set,
13840 (void *)&cmd_tx_loopback_tx,
13841 (void *)&cmd_tx_loopback_loopback,
13842 (void *)&cmd_tx_loopback_port_id,
13843 (void *)&cmd_tx_loopback_on_off,
13848 /* all queues drop enable configuration */
13850 /* Common result structure for all queues drop enable */
13851 struct cmd_all_queues_drop_en_result {
13852 cmdline_fixed_string_t set;
13853 cmdline_fixed_string_t all;
13854 cmdline_fixed_string_t queues;
13855 cmdline_fixed_string_t drop;
13857 cmdline_fixed_string_t on_off;
13860 /* Common CLI fields for tx loopback enable disable */
13861 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13862 TOKEN_STRING_INITIALIZER
13863 (struct cmd_all_queues_drop_en_result,
13865 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13866 TOKEN_STRING_INITIALIZER
13867 (struct cmd_all_queues_drop_en_result,
13869 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13870 TOKEN_STRING_INITIALIZER
13871 (struct cmd_all_queues_drop_en_result,
13873 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13874 TOKEN_STRING_INITIALIZER
13875 (struct cmd_all_queues_drop_en_result,
13877 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13878 TOKEN_NUM_INITIALIZER
13879 (struct cmd_all_queues_drop_en_result,
13881 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13882 TOKEN_STRING_INITIALIZER
13883 (struct cmd_all_queues_drop_en_result,
13887 cmd_set_all_queues_drop_en_parsed(
13888 void *parsed_result,
13889 __attribute__((unused)) struct cmdline *cl,
13890 __attribute__((unused)) void *data)
13892 struct cmd_all_queues_drop_en_result *res = parsed_result;
13893 int ret = -ENOTSUP;
13894 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13896 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13899 #ifdef RTE_LIBRTE_IXGBE_PMD
13900 if (ret == -ENOTSUP)
13901 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13903 #ifdef RTE_LIBRTE_BNXT_PMD
13904 if (ret == -ENOTSUP)
13905 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13911 printf("invalid is_on %d\n", is_on);
13914 printf("invalid port_id %d\n", res->port_id);
13917 printf("function not implemented\n");
13920 printf("programming error: (%s)\n", strerror(-ret));
13924 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13925 .f = cmd_set_all_queues_drop_en_parsed,
13927 .help_str = "set all queues drop <port_id> on|off",
13929 (void *)&cmd_all_queues_drop_en_set,
13930 (void *)&cmd_all_queues_drop_en_all,
13931 (void *)&cmd_all_queues_drop_en_queues,
13932 (void *)&cmd_all_queues_drop_en_drop,
13933 (void *)&cmd_all_queues_drop_en_port_id,
13934 (void *)&cmd_all_queues_drop_en_on_off,
13939 /* vf split drop enable configuration */
13941 /* Common result structure for vf split drop enable */
13942 struct cmd_vf_split_drop_en_result {
13943 cmdline_fixed_string_t set;
13944 cmdline_fixed_string_t vf;
13945 cmdline_fixed_string_t split;
13946 cmdline_fixed_string_t drop;
13949 cmdline_fixed_string_t on_off;
13952 /* Common CLI fields for vf split drop enable disable */
13953 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13954 TOKEN_STRING_INITIALIZER
13955 (struct cmd_vf_split_drop_en_result,
13957 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13958 TOKEN_STRING_INITIALIZER
13959 (struct cmd_vf_split_drop_en_result,
13961 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13962 TOKEN_STRING_INITIALIZER
13963 (struct cmd_vf_split_drop_en_result,
13965 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13966 TOKEN_STRING_INITIALIZER
13967 (struct cmd_vf_split_drop_en_result,
13969 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13970 TOKEN_NUM_INITIALIZER
13971 (struct cmd_vf_split_drop_en_result,
13973 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13974 TOKEN_NUM_INITIALIZER
13975 (struct cmd_vf_split_drop_en_result,
13977 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13978 TOKEN_STRING_INITIALIZER
13979 (struct cmd_vf_split_drop_en_result,
13983 cmd_set_vf_split_drop_en_parsed(
13984 void *parsed_result,
13985 __attribute__((unused)) struct cmdline *cl,
13986 __attribute__((unused)) void *data)
13988 struct cmd_vf_split_drop_en_result *res = parsed_result;
13989 int ret = -ENOTSUP;
13990 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13992 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13995 #ifdef RTE_LIBRTE_IXGBE_PMD
13996 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
14003 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14006 printf("invalid port_id %d\n", res->port_id);
14009 printf("not supported on port %d\n", res->port_id);
14012 printf("programming error: (%s)\n", strerror(-ret));
14016 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
14017 .f = cmd_set_vf_split_drop_en_parsed,
14019 .help_str = "set vf split drop <port_id> <vf_id> on|off",
14021 (void *)&cmd_vf_split_drop_en_set,
14022 (void *)&cmd_vf_split_drop_en_vf,
14023 (void *)&cmd_vf_split_drop_en_split,
14024 (void *)&cmd_vf_split_drop_en_drop,
14025 (void *)&cmd_vf_split_drop_en_port_id,
14026 (void *)&cmd_vf_split_drop_en_vf_id,
14027 (void *)&cmd_vf_split_drop_en_on_off,
14032 /* vf mac address configuration */
14034 /* Common result structure for vf mac address */
14035 struct cmd_set_vf_mac_addr_result {
14036 cmdline_fixed_string_t set;
14037 cmdline_fixed_string_t vf;
14038 cmdline_fixed_string_t mac;
14039 cmdline_fixed_string_t addr;
14042 struct rte_ether_addr mac_addr;
14046 /* Common CLI fields for vf split drop enable disable */
14047 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
14048 TOKEN_STRING_INITIALIZER
14049 (struct cmd_set_vf_mac_addr_result,
14051 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
14052 TOKEN_STRING_INITIALIZER
14053 (struct cmd_set_vf_mac_addr_result,
14055 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
14056 TOKEN_STRING_INITIALIZER
14057 (struct cmd_set_vf_mac_addr_result,
14059 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
14060 TOKEN_STRING_INITIALIZER
14061 (struct cmd_set_vf_mac_addr_result,
14063 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
14064 TOKEN_NUM_INITIALIZER
14065 (struct cmd_set_vf_mac_addr_result,
14067 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
14068 TOKEN_NUM_INITIALIZER
14069 (struct cmd_set_vf_mac_addr_result,
14071 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
14072 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
14076 cmd_set_vf_mac_addr_parsed(
14077 void *parsed_result,
14078 __attribute__((unused)) struct cmdline *cl,
14079 __attribute__((unused)) void *data)
14081 struct cmd_set_vf_mac_addr_result *res = parsed_result;
14082 int ret = -ENOTSUP;
14084 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14087 #ifdef RTE_LIBRTE_IXGBE_PMD
14088 if (ret == -ENOTSUP)
14089 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14092 #ifdef RTE_LIBRTE_I40E_PMD
14093 if (ret == -ENOTSUP)
14094 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14097 #ifdef RTE_LIBRTE_BNXT_PMD
14098 if (ret == -ENOTSUP)
14099 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14107 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14110 printf("invalid port_id %d\n", res->port_id);
14113 printf("function not implemented\n");
14116 printf("programming error: (%s)\n", strerror(-ret));
14120 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14121 .f = cmd_set_vf_mac_addr_parsed,
14123 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14125 (void *)&cmd_set_vf_mac_addr_set,
14126 (void *)&cmd_set_vf_mac_addr_vf,
14127 (void *)&cmd_set_vf_mac_addr_mac,
14128 (void *)&cmd_set_vf_mac_addr_addr,
14129 (void *)&cmd_set_vf_mac_addr_port_id,
14130 (void *)&cmd_set_vf_mac_addr_vf_id,
14131 (void *)&cmd_set_vf_mac_addr_mac_addr,
14136 /* MACsec configuration */
14138 /* Common result structure for MACsec offload enable */
14139 struct cmd_macsec_offload_on_result {
14140 cmdline_fixed_string_t set;
14141 cmdline_fixed_string_t macsec;
14142 cmdline_fixed_string_t offload;
14144 cmdline_fixed_string_t on;
14145 cmdline_fixed_string_t encrypt;
14146 cmdline_fixed_string_t en_on_off;
14147 cmdline_fixed_string_t replay_protect;
14148 cmdline_fixed_string_t rp_on_off;
14151 /* Common CLI fields for MACsec offload disable */
14152 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14153 TOKEN_STRING_INITIALIZER
14154 (struct cmd_macsec_offload_on_result,
14156 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14157 TOKEN_STRING_INITIALIZER
14158 (struct cmd_macsec_offload_on_result,
14160 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14161 TOKEN_STRING_INITIALIZER
14162 (struct cmd_macsec_offload_on_result,
14163 offload, "offload");
14164 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14165 TOKEN_NUM_INITIALIZER
14166 (struct cmd_macsec_offload_on_result,
14168 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14169 TOKEN_STRING_INITIALIZER
14170 (struct cmd_macsec_offload_on_result,
14172 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14173 TOKEN_STRING_INITIALIZER
14174 (struct cmd_macsec_offload_on_result,
14175 encrypt, "encrypt");
14176 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14177 TOKEN_STRING_INITIALIZER
14178 (struct cmd_macsec_offload_on_result,
14179 en_on_off, "on#off");
14180 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14181 TOKEN_STRING_INITIALIZER
14182 (struct cmd_macsec_offload_on_result,
14183 replay_protect, "replay-protect");
14184 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14185 TOKEN_STRING_INITIALIZER
14186 (struct cmd_macsec_offload_on_result,
14187 rp_on_off, "on#off");
14190 cmd_set_macsec_offload_on_parsed(
14191 void *parsed_result,
14192 __attribute__((unused)) struct cmdline *cl,
14193 __attribute__((unused)) void *data)
14195 struct cmd_macsec_offload_on_result *res = parsed_result;
14196 int ret = -ENOTSUP;
14197 portid_t port_id = res->port_id;
14198 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14199 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14200 struct rte_eth_dev_info dev_info;
14202 if (port_id_is_invalid(port_id, ENABLED_WARN))
14204 if (!port_is_stopped(port_id)) {
14205 printf("Please stop port %d first\n", port_id);
14209 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14213 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14214 #ifdef RTE_LIBRTE_IXGBE_PMD
14215 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14223 ports[port_id].dev_conf.txmode.offloads |=
14224 DEV_TX_OFFLOAD_MACSEC_INSERT;
14225 cmd_reconfig_device_queue(port_id, 1, 1);
14228 printf("invalid port_id %d\n", port_id);
14231 printf("not supported on port %d\n", port_id);
14234 printf("programming error: (%s)\n", strerror(-ret));
14238 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14239 .f = cmd_set_macsec_offload_on_parsed,
14241 .help_str = "set macsec offload <port_id> on "
14242 "encrypt on|off replay-protect on|off",
14244 (void *)&cmd_macsec_offload_on_set,
14245 (void *)&cmd_macsec_offload_on_macsec,
14246 (void *)&cmd_macsec_offload_on_offload,
14247 (void *)&cmd_macsec_offload_on_port_id,
14248 (void *)&cmd_macsec_offload_on_on,
14249 (void *)&cmd_macsec_offload_on_encrypt,
14250 (void *)&cmd_macsec_offload_on_en_on_off,
14251 (void *)&cmd_macsec_offload_on_replay_protect,
14252 (void *)&cmd_macsec_offload_on_rp_on_off,
14257 /* Common result structure for MACsec offload disable */
14258 struct cmd_macsec_offload_off_result {
14259 cmdline_fixed_string_t set;
14260 cmdline_fixed_string_t macsec;
14261 cmdline_fixed_string_t offload;
14263 cmdline_fixed_string_t off;
14266 /* Common CLI fields for MACsec offload disable */
14267 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14268 TOKEN_STRING_INITIALIZER
14269 (struct cmd_macsec_offload_off_result,
14271 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14272 TOKEN_STRING_INITIALIZER
14273 (struct cmd_macsec_offload_off_result,
14275 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14276 TOKEN_STRING_INITIALIZER
14277 (struct cmd_macsec_offload_off_result,
14278 offload, "offload");
14279 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14280 TOKEN_NUM_INITIALIZER
14281 (struct cmd_macsec_offload_off_result,
14283 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14284 TOKEN_STRING_INITIALIZER
14285 (struct cmd_macsec_offload_off_result,
14289 cmd_set_macsec_offload_off_parsed(
14290 void *parsed_result,
14291 __attribute__((unused)) struct cmdline *cl,
14292 __attribute__((unused)) void *data)
14294 struct cmd_macsec_offload_off_result *res = parsed_result;
14295 int ret = -ENOTSUP;
14296 struct rte_eth_dev_info dev_info;
14297 portid_t port_id = res->port_id;
14299 if (port_id_is_invalid(port_id, ENABLED_WARN))
14301 if (!port_is_stopped(port_id)) {
14302 printf("Please stop port %d first\n", port_id);
14306 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14310 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14311 #ifdef RTE_LIBRTE_IXGBE_PMD
14312 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14317 ports[port_id].dev_conf.txmode.offloads &=
14318 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14319 cmd_reconfig_device_queue(port_id, 1, 1);
14322 printf("invalid port_id %d\n", port_id);
14325 printf("not supported on port %d\n", port_id);
14328 printf("programming error: (%s)\n", strerror(-ret));
14332 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14333 .f = cmd_set_macsec_offload_off_parsed,
14335 .help_str = "set macsec offload <port_id> off",
14337 (void *)&cmd_macsec_offload_off_set,
14338 (void *)&cmd_macsec_offload_off_macsec,
14339 (void *)&cmd_macsec_offload_off_offload,
14340 (void *)&cmd_macsec_offload_off_port_id,
14341 (void *)&cmd_macsec_offload_off_off,
14346 /* Common result structure for MACsec secure connection configure */
14347 struct cmd_macsec_sc_result {
14348 cmdline_fixed_string_t set;
14349 cmdline_fixed_string_t macsec;
14350 cmdline_fixed_string_t sc;
14351 cmdline_fixed_string_t tx_rx;
14353 struct rte_ether_addr mac;
14357 /* Common CLI fields for MACsec secure connection configure */
14358 cmdline_parse_token_string_t cmd_macsec_sc_set =
14359 TOKEN_STRING_INITIALIZER
14360 (struct cmd_macsec_sc_result,
14362 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14363 TOKEN_STRING_INITIALIZER
14364 (struct cmd_macsec_sc_result,
14366 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14367 TOKEN_STRING_INITIALIZER
14368 (struct cmd_macsec_sc_result,
14370 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14371 TOKEN_STRING_INITIALIZER
14372 (struct cmd_macsec_sc_result,
14374 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14375 TOKEN_NUM_INITIALIZER
14376 (struct cmd_macsec_sc_result,
14378 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14379 TOKEN_ETHERADDR_INITIALIZER
14380 (struct cmd_macsec_sc_result,
14382 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14383 TOKEN_NUM_INITIALIZER
14384 (struct cmd_macsec_sc_result,
14388 cmd_set_macsec_sc_parsed(
14389 void *parsed_result,
14390 __attribute__((unused)) struct cmdline *cl,
14391 __attribute__((unused)) void *data)
14393 struct cmd_macsec_sc_result *res = parsed_result;
14394 int ret = -ENOTSUP;
14395 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14397 #ifdef RTE_LIBRTE_IXGBE_PMD
14399 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14400 res->mac.addr_bytes) :
14401 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14402 res->mac.addr_bytes, res->pi);
14404 RTE_SET_USED(is_tx);
14410 printf("invalid port_id %d\n", res->port_id);
14413 printf("not supported on port %d\n", res->port_id);
14416 printf("programming error: (%s)\n", strerror(-ret));
14420 cmdline_parse_inst_t cmd_set_macsec_sc = {
14421 .f = cmd_set_macsec_sc_parsed,
14423 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14425 (void *)&cmd_macsec_sc_set,
14426 (void *)&cmd_macsec_sc_macsec,
14427 (void *)&cmd_macsec_sc_sc,
14428 (void *)&cmd_macsec_sc_tx_rx,
14429 (void *)&cmd_macsec_sc_port_id,
14430 (void *)&cmd_macsec_sc_mac,
14431 (void *)&cmd_macsec_sc_pi,
14436 /* Common result structure for MACsec secure connection configure */
14437 struct cmd_macsec_sa_result {
14438 cmdline_fixed_string_t set;
14439 cmdline_fixed_string_t macsec;
14440 cmdline_fixed_string_t sa;
14441 cmdline_fixed_string_t tx_rx;
14446 cmdline_fixed_string_t key;
14449 /* Common CLI fields for MACsec secure connection configure */
14450 cmdline_parse_token_string_t cmd_macsec_sa_set =
14451 TOKEN_STRING_INITIALIZER
14452 (struct cmd_macsec_sa_result,
14454 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14455 TOKEN_STRING_INITIALIZER
14456 (struct cmd_macsec_sa_result,
14458 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14459 TOKEN_STRING_INITIALIZER
14460 (struct cmd_macsec_sa_result,
14462 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14463 TOKEN_STRING_INITIALIZER
14464 (struct cmd_macsec_sa_result,
14466 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14467 TOKEN_NUM_INITIALIZER
14468 (struct cmd_macsec_sa_result,
14470 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14471 TOKEN_NUM_INITIALIZER
14472 (struct cmd_macsec_sa_result,
14474 cmdline_parse_token_num_t cmd_macsec_sa_an =
14475 TOKEN_NUM_INITIALIZER
14476 (struct cmd_macsec_sa_result,
14478 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14479 TOKEN_NUM_INITIALIZER
14480 (struct cmd_macsec_sa_result,
14482 cmdline_parse_token_string_t cmd_macsec_sa_key =
14483 TOKEN_STRING_INITIALIZER
14484 (struct cmd_macsec_sa_result,
14488 cmd_set_macsec_sa_parsed(
14489 void *parsed_result,
14490 __attribute__((unused)) struct cmdline *cl,
14491 __attribute__((unused)) void *data)
14493 struct cmd_macsec_sa_result *res = parsed_result;
14494 int ret = -ENOTSUP;
14495 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14496 uint8_t key[16] = { 0 };
14502 key_len = strlen(res->key) / 2;
14506 for (i = 0; i < key_len; i++) {
14507 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14510 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14513 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14516 #ifdef RTE_LIBRTE_IXGBE_PMD
14518 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14519 res->idx, res->an, res->pn, key) :
14520 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14521 res->idx, res->an, res->pn, key);
14523 RTE_SET_USED(is_tx);
14530 printf("invalid idx %d or an %d\n", res->idx, res->an);
14533 printf("invalid port_id %d\n", res->port_id);
14536 printf("not supported on port %d\n", res->port_id);
14539 printf("programming error: (%s)\n", strerror(-ret));
14543 cmdline_parse_inst_t cmd_set_macsec_sa = {
14544 .f = cmd_set_macsec_sa_parsed,
14546 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14548 (void *)&cmd_macsec_sa_set,
14549 (void *)&cmd_macsec_sa_macsec,
14550 (void *)&cmd_macsec_sa_sa,
14551 (void *)&cmd_macsec_sa_tx_rx,
14552 (void *)&cmd_macsec_sa_port_id,
14553 (void *)&cmd_macsec_sa_idx,
14554 (void *)&cmd_macsec_sa_an,
14555 (void *)&cmd_macsec_sa_pn,
14556 (void *)&cmd_macsec_sa_key,
14561 /* VF unicast promiscuous mode configuration */
14563 /* Common result structure for VF unicast promiscuous mode */
14564 struct cmd_vf_promisc_result {
14565 cmdline_fixed_string_t set;
14566 cmdline_fixed_string_t vf;
14567 cmdline_fixed_string_t promisc;
14570 cmdline_fixed_string_t on_off;
14573 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14574 cmdline_parse_token_string_t cmd_vf_promisc_set =
14575 TOKEN_STRING_INITIALIZER
14576 (struct cmd_vf_promisc_result,
14578 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14579 TOKEN_STRING_INITIALIZER
14580 (struct cmd_vf_promisc_result,
14582 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14583 TOKEN_STRING_INITIALIZER
14584 (struct cmd_vf_promisc_result,
14585 promisc, "promisc");
14586 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14587 TOKEN_NUM_INITIALIZER
14588 (struct cmd_vf_promisc_result,
14590 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14591 TOKEN_NUM_INITIALIZER
14592 (struct cmd_vf_promisc_result,
14594 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14595 TOKEN_STRING_INITIALIZER
14596 (struct cmd_vf_promisc_result,
14600 cmd_set_vf_promisc_parsed(
14601 void *parsed_result,
14602 __attribute__((unused)) struct cmdline *cl,
14603 __attribute__((unused)) void *data)
14605 struct cmd_vf_promisc_result *res = parsed_result;
14606 int ret = -ENOTSUP;
14608 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14610 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14613 #ifdef RTE_LIBRTE_I40E_PMD
14614 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14615 res->vf_id, is_on);
14622 printf("invalid vf_id %d\n", res->vf_id);
14625 printf("invalid port_id %d\n", res->port_id);
14628 printf("function not implemented\n");
14631 printf("programming error: (%s)\n", strerror(-ret));
14635 cmdline_parse_inst_t cmd_set_vf_promisc = {
14636 .f = cmd_set_vf_promisc_parsed,
14638 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14639 "Set unicast promiscuous mode for a VF from the PF",
14641 (void *)&cmd_vf_promisc_set,
14642 (void *)&cmd_vf_promisc_vf,
14643 (void *)&cmd_vf_promisc_promisc,
14644 (void *)&cmd_vf_promisc_port_id,
14645 (void *)&cmd_vf_promisc_vf_id,
14646 (void *)&cmd_vf_promisc_on_off,
14651 /* VF multicast promiscuous mode configuration */
14653 /* Common result structure for VF multicast promiscuous mode */
14654 struct cmd_vf_allmulti_result {
14655 cmdline_fixed_string_t set;
14656 cmdline_fixed_string_t vf;
14657 cmdline_fixed_string_t allmulti;
14660 cmdline_fixed_string_t on_off;
14663 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14664 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14665 TOKEN_STRING_INITIALIZER
14666 (struct cmd_vf_allmulti_result,
14668 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14669 TOKEN_STRING_INITIALIZER
14670 (struct cmd_vf_allmulti_result,
14672 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14673 TOKEN_STRING_INITIALIZER
14674 (struct cmd_vf_allmulti_result,
14675 allmulti, "allmulti");
14676 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14677 TOKEN_NUM_INITIALIZER
14678 (struct cmd_vf_allmulti_result,
14680 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14681 TOKEN_NUM_INITIALIZER
14682 (struct cmd_vf_allmulti_result,
14684 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14685 TOKEN_STRING_INITIALIZER
14686 (struct cmd_vf_allmulti_result,
14690 cmd_set_vf_allmulti_parsed(
14691 void *parsed_result,
14692 __attribute__((unused)) struct cmdline *cl,
14693 __attribute__((unused)) void *data)
14695 struct cmd_vf_allmulti_result *res = parsed_result;
14696 int ret = -ENOTSUP;
14698 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14700 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14703 #ifdef RTE_LIBRTE_I40E_PMD
14704 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14705 res->vf_id, is_on);
14712 printf("invalid vf_id %d\n", res->vf_id);
14715 printf("invalid port_id %d\n", res->port_id);
14718 printf("function not implemented\n");
14721 printf("programming error: (%s)\n", strerror(-ret));
14725 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14726 .f = cmd_set_vf_allmulti_parsed,
14728 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14729 "Set multicast promiscuous mode for a VF from the PF",
14731 (void *)&cmd_vf_allmulti_set,
14732 (void *)&cmd_vf_allmulti_vf,
14733 (void *)&cmd_vf_allmulti_allmulti,
14734 (void *)&cmd_vf_allmulti_port_id,
14735 (void *)&cmd_vf_allmulti_vf_id,
14736 (void *)&cmd_vf_allmulti_on_off,
14741 /* vf broadcast mode configuration */
14743 /* Common result structure for vf broadcast */
14744 struct cmd_set_vf_broadcast_result {
14745 cmdline_fixed_string_t set;
14746 cmdline_fixed_string_t vf;
14747 cmdline_fixed_string_t broadcast;
14750 cmdline_fixed_string_t on_off;
14753 /* Common CLI fields for vf broadcast enable disable */
14754 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14755 TOKEN_STRING_INITIALIZER
14756 (struct cmd_set_vf_broadcast_result,
14758 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14759 TOKEN_STRING_INITIALIZER
14760 (struct cmd_set_vf_broadcast_result,
14762 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14763 TOKEN_STRING_INITIALIZER
14764 (struct cmd_set_vf_broadcast_result,
14765 broadcast, "broadcast");
14766 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14767 TOKEN_NUM_INITIALIZER
14768 (struct cmd_set_vf_broadcast_result,
14770 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14771 TOKEN_NUM_INITIALIZER
14772 (struct cmd_set_vf_broadcast_result,
14774 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14775 TOKEN_STRING_INITIALIZER
14776 (struct cmd_set_vf_broadcast_result,
14780 cmd_set_vf_broadcast_parsed(
14781 void *parsed_result,
14782 __attribute__((unused)) struct cmdline *cl,
14783 __attribute__((unused)) void *data)
14785 struct cmd_set_vf_broadcast_result *res = parsed_result;
14786 int ret = -ENOTSUP;
14788 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14790 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14793 #ifdef RTE_LIBRTE_I40E_PMD
14794 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14795 res->vf_id, is_on);
14802 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14805 printf("invalid port_id %d\n", res->port_id);
14808 printf("function not implemented\n");
14811 printf("programming error: (%s)\n", strerror(-ret));
14815 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14816 .f = cmd_set_vf_broadcast_parsed,
14818 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14820 (void *)&cmd_set_vf_broadcast_set,
14821 (void *)&cmd_set_vf_broadcast_vf,
14822 (void *)&cmd_set_vf_broadcast_broadcast,
14823 (void *)&cmd_set_vf_broadcast_port_id,
14824 (void *)&cmd_set_vf_broadcast_vf_id,
14825 (void *)&cmd_set_vf_broadcast_on_off,
14830 /* vf vlan tag configuration */
14832 /* Common result structure for vf vlan tag */
14833 struct cmd_set_vf_vlan_tag_result {
14834 cmdline_fixed_string_t set;
14835 cmdline_fixed_string_t vf;
14836 cmdline_fixed_string_t vlan;
14837 cmdline_fixed_string_t tag;
14840 cmdline_fixed_string_t on_off;
14843 /* Common CLI fields for vf vlan tag enable disable */
14844 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14845 TOKEN_STRING_INITIALIZER
14846 (struct cmd_set_vf_vlan_tag_result,
14848 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14849 TOKEN_STRING_INITIALIZER
14850 (struct cmd_set_vf_vlan_tag_result,
14852 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14853 TOKEN_STRING_INITIALIZER
14854 (struct cmd_set_vf_vlan_tag_result,
14856 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14857 TOKEN_STRING_INITIALIZER
14858 (struct cmd_set_vf_vlan_tag_result,
14860 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14861 TOKEN_NUM_INITIALIZER
14862 (struct cmd_set_vf_vlan_tag_result,
14864 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14865 TOKEN_NUM_INITIALIZER
14866 (struct cmd_set_vf_vlan_tag_result,
14868 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14869 TOKEN_STRING_INITIALIZER
14870 (struct cmd_set_vf_vlan_tag_result,
14874 cmd_set_vf_vlan_tag_parsed(
14875 void *parsed_result,
14876 __attribute__((unused)) struct cmdline *cl,
14877 __attribute__((unused)) void *data)
14879 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14880 int ret = -ENOTSUP;
14882 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14884 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14887 #ifdef RTE_LIBRTE_I40E_PMD
14888 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14889 res->vf_id, is_on);
14896 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14899 printf("invalid port_id %d\n", res->port_id);
14902 printf("function not implemented\n");
14905 printf("programming error: (%s)\n", strerror(-ret));
14909 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14910 .f = cmd_set_vf_vlan_tag_parsed,
14912 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14914 (void *)&cmd_set_vf_vlan_tag_set,
14915 (void *)&cmd_set_vf_vlan_tag_vf,
14916 (void *)&cmd_set_vf_vlan_tag_vlan,
14917 (void *)&cmd_set_vf_vlan_tag_tag,
14918 (void *)&cmd_set_vf_vlan_tag_port_id,
14919 (void *)&cmd_set_vf_vlan_tag_vf_id,
14920 (void *)&cmd_set_vf_vlan_tag_on_off,
14925 /* Common definition of VF and TC TX bandwidth configuration */
14926 struct cmd_vf_tc_bw_result {
14927 cmdline_fixed_string_t set;
14928 cmdline_fixed_string_t vf;
14929 cmdline_fixed_string_t tc;
14930 cmdline_fixed_string_t tx;
14931 cmdline_fixed_string_t min_bw;
14932 cmdline_fixed_string_t max_bw;
14933 cmdline_fixed_string_t strict_link_prio;
14938 cmdline_fixed_string_t bw_list;
14942 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14943 TOKEN_STRING_INITIALIZER
14944 (struct cmd_vf_tc_bw_result,
14946 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14947 TOKEN_STRING_INITIALIZER
14948 (struct cmd_vf_tc_bw_result,
14950 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14951 TOKEN_STRING_INITIALIZER
14952 (struct cmd_vf_tc_bw_result,
14954 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14955 TOKEN_STRING_INITIALIZER
14956 (struct cmd_vf_tc_bw_result,
14958 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14959 TOKEN_STRING_INITIALIZER
14960 (struct cmd_vf_tc_bw_result,
14961 strict_link_prio, "strict-link-priority");
14962 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14963 TOKEN_STRING_INITIALIZER
14964 (struct cmd_vf_tc_bw_result,
14965 min_bw, "min-bandwidth");
14966 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14967 TOKEN_STRING_INITIALIZER
14968 (struct cmd_vf_tc_bw_result,
14969 max_bw, "max-bandwidth");
14970 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14971 TOKEN_NUM_INITIALIZER
14972 (struct cmd_vf_tc_bw_result,
14974 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14975 TOKEN_NUM_INITIALIZER
14976 (struct cmd_vf_tc_bw_result,
14978 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14979 TOKEN_NUM_INITIALIZER
14980 (struct cmd_vf_tc_bw_result,
14982 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14983 TOKEN_NUM_INITIALIZER
14984 (struct cmd_vf_tc_bw_result,
14986 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14987 TOKEN_STRING_INITIALIZER
14988 (struct cmd_vf_tc_bw_result,
14990 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14991 TOKEN_NUM_INITIALIZER
14992 (struct cmd_vf_tc_bw_result,
14995 /* VF max bandwidth setting */
14997 cmd_vf_max_bw_parsed(
14998 void *parsed_result,
14999 __attribute__((unused)) struct cmdline *cl,
15000 __attribute__((unused)) void *data)
15002 struct cmd_vf_tc_bw_result *res = parsed_result;
15003 int ret = -ENOTSUP;
15005 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15008 #ifdef RTE_LIBRTE_I40E_PMD
15009 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
15010 res->vf_id, res->bw);
15017 printf("invalid vf_id %d or bandwidth %d\n",
15018 res->vf_id, res->bw);
15021 printf("invalid port_id %d\n", res->port_id);
15024 printf("function not implemented\n");
15027 printf("programming error: (%s)\n", strerror(-ret));
15031 cmdline_parse_inst_t cmd_vf_max_bw = {
15032 .f = cmd_vf_max_bw_parsed,
15034 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
15036 (void *)&cmd_vf_tc_bw_set,
15037 (void *)&cmd_vf_tc_bw_vf,
15038 (void *)&cmd_vf_tc_bw_tx,
15039 (void *)&cmd_vf_tc_bw_max_bw,
15040 (void *)&cmd_vf_tc_bw_port_id,
15041 (void *)&cmd_vf_tc_bw_vf_id,
15042 (void *)&cmd_vf_tc_bw_bw,
15048 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
15053 const char *p, *p0 = str;
15060 p = strchr(p0, '(');
15062 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15066 p0 = strchr(p, ')');
15068 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
15072 if (size >= sizeof(s)) {
15073 printf("The string size exceeds the internal buffer size\n");
15076 snprintf(s, sizeof(s), "%.*s", size, p);
15077 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
15079 printf("Failed to get the bandwidth list. ");
15083 for (i = 0; i < ret; i++)
15084 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
15089 /* TC min bandwidth setting */
15091 cmd_vf_tc_min_bw_parsed(
15092 void *parsed_result,
15093 __attribute__((unused)) struct cmdline *cl,
15094 __attribute__((unused)) void *data)
15096 struct cmd_vf_tc_bw_result *res = parsed_result;
15099 int ret = -ENOTSUP;
15101 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15104 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15108 #ifdef RTE_LIBRTE_I40E_PMD
15109 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15117 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15120 printf("invalid port_id %d\n", res->port_id);
15123 printf("function not implemented\n");
15126 printf("programming error: (%s)\n", strerror(-ret));
15130 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15131 .f = cmd_vf_tc_min_bw_parsed,
15133 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15134 " <bw1, bw2, ...>",
15136 (void *)&cmd_vf_tc_bw_set,
15137 (void *)&cmd_vf_tc_bw_vf,
15138 (void *)&cmd_vf_tc_bw_tc,
15139 (void *)&cmd_vf_tc_bw_tx,
15140 (void *)&cmd_vf_tc_bw_min_bw,
15141 (void *)&cmd_vf_tc_bw_port_id,
15142 (void *)&cmd_vf_tc_bw_vf_id,
15143 (void *)&cmd_vf_tc_bw_bw_list,
15149 cmd_tc_min_bw_parsed(
15150 void *parsed_result,
15151 __attribute__((unused)) struct cmdline *cl,
15152 __attribute__((unused)) void *data)
15154 struct cmd_vf_tc_bw_result *res = parsed_result;
15155 struct rte_port *port;
15158 int ret = -ENOTSUP;
15160 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15163 port = &ports[res->port_id];
15164 /** Check if the port is not started **/
15165 if (port->port_status != RTE_PORT_STOPPED) {
15166 printf("Please stop port %d first\n", res->port_id);
15170 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15174 #ifdef RTE_LIBRTE_IXGBE_PMD
15175 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15182 printf("invalid bandwidth\n");
15185 printf("invalid port_id %d\n", res->port_id);
15188 printf("function not implemented\n");
15191 printf("programming error: (%s)\n", strerror(-ret));
15195 cmdline_parse_inst_t cmd_tc_min_bw = {
15196 .f = cmd_tc_min_bw_parsed,
15198 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15200 (void *)&cmd_vf_tc_bw_set,
15201 (void *)&cmd_vf_tc_bw_tc,
15202 (void *)&cmd_vf_tc_bw_tx,
15203 (void *)&cmd_vf_tc_bw_min_bw,
15204 (void *)&cmd_vf_tc_bw_port_id,
15205 (void *)&cmd_vf_tc_bw_bw_list,
15210 /* TC max bandwidth setting */
15212 cmd_vf_tc_max_bw_parsed(
15213 void *parsed_result,
15214 __attribute__((unused)) struct cmdline *cl,
15215 __attribute__((unused)) void *data)
15217 struct cmd_vf_tc_bw_result *res = parsed_result;
15218 int ret = -ENOTSUP;
15220 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15223 #ifdef RTE_LIBRTE_I40E_PMD
15224 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15225 res->tc_no, res->bw);
15232 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15233 res->vf_id, res->tc_no, res->bw);
15236 printf("invalid port_id %d\n", res->port_id);
15239 printf("function not implemented\n");
15242 printf("programming error: (%s)\n", strerror(-ret));
15246 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15247 .f = cmd_vf_tc_max_bw_parsed,
15249 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15252 (void *)&cmd_vf_tc_bw_set,
15253 (void *)&cmd_vf_tc_bw_vf,
15254 (void *)&cmd_vf_tc_bw_tc,
15255 (void *)&cmd_vf_tc_bw_tx,
15256 (void *)&cmd_vf_tc_bw_max_bw,
15257 (void *)&cmd_vf_tc_bw_port_id,
15258 (void *)&cmd_vf_tc_bw_vf_id,
15259 (void *)&cmd_vf_tc_bw_tc_no,
15260 (void *)&cmd_vf_tc_bw_bw,
15266 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15268 /* *** Set Port default Traffic Management Hierarchy *** */
15269 struct cmd_set_port_tm_hierarchy_default_result {
15270 cmdline_fixed_string_t set;
15271 cmdline_fixed_string_t port;
15272 cmdline_fixed_string_t tm;
15273 cmdline_fixed_string_t hierarchy;
15274 cmdline_fixed_string_t def;
15278 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15279 TOKEN_STRING_INITIALIZER(
15280 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15281 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15282 TOKEN_STRING_INITIALIZER(
15283 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15284 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15285 TOKEN_STRING_INITIALIZER(
15286 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15287 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15288 TOKEN_STRING_INITIALIZER(
15289 struct cmd_set_port_tm_hierarchy_default_result,
15290 hierarchy, "hierarchy");
15291 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15292 TOKEN_STRING_INITIALIZER(
15293 struct cmd_set_port_tm_hierarchy_default_result,
15295 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15296 TOKEN_NUM_INITIALIZER(
15297 struct cmd_set_port_tm_hierarchy_default_result,
15300 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15301 __attribute__((unused)) struct cmdline *cl,
15302 __attribute__((unused)) void *data)
15304 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15305 struct rte_port *p;
15306 portid_t port_id = res->port_id;
15308 if (port_id_is_invalid(port_id, ENABLED_WARN))
15311 p = &ports[port_id];
15313 /* Forward mode: tm */
15314 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15315 printf(" softnicfwd mode not enabled(error)\n");
15319 /* Set the default tm hierarchy */
15320 p->softport.default_tm_hierarchy_enable = 1;
15323 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15324 .f = cmd_set_port_tm_hierarchy_default_parsed,
15326 .help_str = "set port tm hierarchy default <port_id>",
15328 (void *)&cmd_set_port_tm_hierarchy_default_set,
15329 (void *)&cmd_set_port_tm_hierarchy_default_port,
15330 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15331 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15332 (void *)&cmd_set_port_tm_hierarchy_default_default,
15333 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15339 /** Set VXLAN encapsulation details */
15340 struct cmd_set_vxlan_result {
15341 cmdline_fixed_string_t set;
15342 cmdline_fixed_string_t vxlan;
15343 cmdline_fixed_string_t pos_token;
15344 cmdline_fixed_string_t ip_version;
15345 uint32_t vlan_present:1;
15349 cmdline_ipaddr_t ip_src;
15350 cmdline_ipaddr_t ip_dst;
15354 struct rte_ether_addr eth_src;
15355 struct rte_ether_addr eth_dst;
15358 cmdline_parse_token_string_t cmd_set_vxlan_set =
15359 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15360 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15361 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15362 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15363 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15365 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15366 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15367 "vxlan-with-vlan");
15368 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15369 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15371 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15372 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15374 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15375 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15377 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15378 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15379 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15380 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15382 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15383 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15384 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15385 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15387 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15388 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15389 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15390 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15392 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15393 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15394 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15395 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15397 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15398 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15399 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15400 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15402 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15403 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15404 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15405 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15407 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15408 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15409 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15410 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15412 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15413 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15414 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15415 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15417 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15418 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15419 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15420 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15422 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15423 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15425 static void cmd_set_vxlan_parsed(void *parsed_result,
15426 __attribute__((unused)) struct cmdline *cl,
15427 __attribute__((unused)) void *data)
15429 struct cmd_set_vxlan_result *res = parsed_result;
15434 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15437 vxlan_encap_conf.select_tos_ttl = 0;
15438 if (strcmp(res->vxlan, "vxlan") == 0)
15439 vxlan_encap_conf.select_vlan = 0;
15440 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15441 vxlan_encap_conf.select_vlan = 1;
15442 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15443 vxlan_encap_conf.select_vlan = 0;
15444 vxlan_encap_conf.select_tos_ttl = 1;
15446 if (strcmp(res->ip_version, "ipv4") == 0)
15447 vxlan_encap_conf.select_ipv4 = 1;
15448 else if (strcmp(res->ip_version, "ipv6") == 0)
15449 vxlan_encap_conf.select_ipv4 = 0;
15452 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15453 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15454 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15455 vxlan_encap_conf.ip_tos = res->tos;
15456 vxlan_encap_conf.ip_ttl = res->ttl;
15457 if (vxlan_encap_conf.select_ipv4) {
15458 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15459 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15461 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15462 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15464 if (vxlan_encap_conf.select_vlan)
15465 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15466 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15467 RTE_ETHER_ADDR_LEN);
15468 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15469 RTE_ETHER_ADDR_LEN);
15472 cmdline_parse_inst_t cmd_set_vxlan = {
15473 .f = cmd_set_vxlan_parsed,
15475 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15476 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15477 " eth-src <eth-src> eth-dst <eth-dst>",
15479 (void *)&cmd_set_vxlan_set,
15480 (void *)&cmd_set_vxlan_vxlan,
15481 (void *)&cmd_set_vxlan_ip_version,
15482 (void *)&cmd_set_vxlan_ip_version_value,
15483 (void *)&cmd_set_vxlan_vni,
15484 (void *)&cmd_set_vxlan_vni_value,
15485 (void *)&cmd_set_vxlan_udp_src,
15486 (void *)&cmd_set_vxlan_udp_src_value,
15487 (void *)&cmd_set_vxlan_udp_dst,
15488 (void *)&cmd_set_vxlan_udp_dst_value,
15489 (void *)&cmd_set_vxlan_ip_src,
15490 (void *)&cmd_set_vxlan_ip_src_value,
15491 (void *)&cmd_set_vxlan_ip_dst,
15492 (void *)&cmd_set_vxlan_ip_dst_value,
15493 (void *)&cmd_set_vxlan_eth_src,
15494 (void *)&cmd_set_vxlan_eth_src_value,
15495 (void *)&cmd_set_vxlan_eth_dst,
15496 (void *)&cmd_set_vxlan_eth_dst_value,
15501 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15502 .f = cmd_set_vxlan_parsed,
15504 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15505 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15506 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15507 " eth-dst <eth-dst>",
15509 (void *)&cmd_set_vxlan_set,
15510 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15511 (void *)&cmd_set_vxlan_ip_version,
15512 (void *)&cmd_set_vxlan_ip_version_value,
15513 (void *)&cmd_set_vxlan_vni,
15514 (void *)&cmd_set_vxlan_vni_value,
15515 (void *)&cmd_set_vxlan_udp_src,
15516 (void *)&cmd_set_vxlan_udp_src_value,
15517 (void *)&cmd_set_vxlan_udp_dst,
15518 (void *)&cmd_set_vxlan_udp_dst_value,
15519 (void *)&cmd_set_vxlan_ip_tos,
15520 (void *)&cmd_set_vxlan_ip_tos_value,
15521 (void *)&cmd_set_vxlan_ip_ttl,
15522 (void *)&cmd_set_vxlan_ip_ttl_value,
15523 (void *)&cmd_set_vxlan_ip_src,
15524 (void *)&cmd_set_vxlan_ip_src_value,
15525 (void *)&cmd_set_vxlan_ip_dst,
15526 (void *)&cmd_set_vxlan_ip_dst_value,
15527 (void *)&cmd_set_vxlan_eth_src,
15528 (void *)&cmd_set_vxlan_eth_src_value,
15529 (void *)&cmd_set_vxlan_eth_dst,
15530 (void *)&cmd_set_vxlan_eth_dst_value,
15535 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15536 .f = cmd_set_vxlan_parsed,
15538 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15539 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15540 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15543 (void *)&cmd_set_vxlan_set,
15544 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15545 (void *)&cmd_set_vxlan_ip_version,
15546 (void *)&cmd_set_vxlan_ip_version_value,
15547 (void *)&cmd_set_vxlan_vni,
15548 (void *)&cmd_set_vxlan_vni_value,
15549 (void *)&cmd_set_vxlan_udp_src,
15550 (void *)&cmd_set_vxlan_udp_src_value,
15551 (void *)&cmd_set_vxlan_udp_dst,
15552 (void *)&cmd_set_vxlan_udp_dst_value,
15553 (void *)&cmd_set_vxlan_ip_src,
15554 (void *)&cmd_set_vxlan_ip_src_value,
15555 (void *)&cmd_set_vxlan_ip_dst,
15556 (void *)&cmd_set_vxlan_ip_dst_value,
15557 (void *)&cmd_set_vxlan_vlan,
15558 (void *)&cmd_set_vxlan_vlan_value,
15559 (void *)&cmd_set_vxlan_eth_src,
15560 (void *)&cmd_set_vxlan_eth_src_value,
15561 (void *)&cmd_set_vxlan_eth_dst,
15562 (void *)&cmd_set_vxlan_eth_dst_value,
15567 /** Set NVGRE encapsulation details */
15568 struct cmd_set_nvgre_result {
15569 cmdline_fixed_string_t set;
15570 cmdline_fixed_string_t nvgre;
15571 cmdline_fixed_string_t pos_token;
15572 cmdline_fixed_string_t ip_version;
15574 cmdline_ipaddr_t ip_src;
15575 cmdline_ipaddr_t ip_dst;
15577 struct rte_ether_addr eth_src;
15578 struct rte_ether_addr eth_dst;
15581 cmdline_parse_token_string_t cmd_set_nvgre_set =
15582 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15583 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15584 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15585 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15586 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15587 "nvgre-with-vlan");
15588 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15589 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15591 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15592 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15594 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15595 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15597 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15598 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15599 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15600 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15602 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15603 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15604 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15605 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15607 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15608 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15609 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15610 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15612 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15613 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15614 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15615 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15617 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15618 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15619 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15620 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15622 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15623 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15625 static void cmd_set_nvgre_parsed(void *parsed_result,
15626 __attribute__((unused)) struct cmdline *cl,
15627 __attribute__((unused)) void *data)
15629 struct cmd_set_nvgre_result *res = parsed_result;
15631 uint32_t nvgre_tni;
15634 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15637 if (strcmp(res->nvgre, "nvgre") == 0)
15638 nvgre_encap_conf.select_vlan = 0;
15639 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15640 nvgre_encap_conf.select_vlan = 1;
15641 if (strcmp(res->ip_version, "ipv4") == 0)
15642 nvgre_encap_conf.select_ipv4 = 1;
15643 else if (strcmp(res->ip_version, "ipv6") == 0)
15644 nvgre_encap_conf.select_ipv4 = 0;
15647 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15648 if (nvgre_encap_conf.select_ipv4) {
15649 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15650 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15652 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15653 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15655 if (nvgre_encap_conf.select_vlan)
15656 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15657 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15658 RTE_ETHER_ADDR_LEN);
15659 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15660 RTE_ETHER_ADDR_LEN);
15663 cmdline_parse_inst_t cmd_set_nvgre = {
15664 .f = cmd_set_nvgre_parsed,
15666 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15667 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15668 " eth-dst <eth-dst>",
15670 (void *)&cmd_set_nvgre_set,
15671 (void *)&cmd_set_nvgre_nvgre,
15672 (void *)&cmd_set_nvgre_ip_version,
15673 (void *)&cmd_set_nvgre_ip_version_value,
15674 (void *)&cmd_set_nvgre_tni,
15675 (void *)&cmd_set_nvgre_tni_value,
15676 (void *)&cmd_set_nvgre_ip_src,
15677 (void *)&cmd_set_nvgre_ip_src_value,
15678 (void *)&cmd_set_nvgre_ip_dst,
15679 (void *)&cmd_set_nvgre_ip_dst_value,
15680 (void *)&cmd_set_nvgre_eth_src,
15681 (void *)&cmd_set_nvgre_eth_src_value,
15682 (void *)&cmd_set_nvgre_eth_dst,
15683 (void *)&cmd_set_nvgre_eth_dst_value,
15688 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15689 .f = cmd_set_nvgre_parsed,
15691 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15692 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15693 " eth-src <eth-src> eth-dst <eth-dst>",
15695 (void *)&cmd_set_nvgre_set,
15696 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15697 (void *)&cmd_set_nvgre_ip_version,
15698 (void *)&cmd_set_nvgre_ip_version_value,
15699 (void *)&cmd_set_nvgre_tni,
15700 (void *)&cmd_set_nvgre_tni_value,
15701 (void *)&cmd_set_nvgre_ip_src,
15702 (void *)&cmd_set_nvgre_ip_src_value,
15703 (void *)&cmd_set_nvgre_ip_dst,
15704 (void *)&cmd_set_nvgre_ip_dst_value,
15705 (void *)&cmd_set_nvgre_vlan,
15706 (void *)&cmd_set_nvgre_vlan_value,
15707 (void *)&cmd_set_nvgre_eth_src,
15708 (void *)&cmd_set_nvgre_eth_src_value,
15709 (void *)&cmd_set_nvgre_eth_dst,
15710 (void *)&cmd_set_nvgre_eth_dst_value,
15715 /** Set L2 encapsulation details */
15716 struct cmd_set_l2_encap_result {
15717 cmdline_fixed_string_t set;
15718 cmdline_fixed_string_t l2_encap;
15719 cmdline_fixed_string_t pos_token;
15720 cmdline_fixed_string_t ip_version;
15721 uint32_t vlan_present:1;
15723 struct rte_ether_addr eth_src;
15724 struct rte_ether_addr eth_dst;
15727 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15728 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15729 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15730 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15731 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15732 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15733 "l2_encap-with-vlan");
15734 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15735 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15737 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15738 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15740 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15741 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15743 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15744 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15745 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15746 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15748 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15749 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15750 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15751 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15753 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15754 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15756 static void cmd_set_l2_encap_parsed(void *parsed_result,
15757 __attribute__((unused)) struct cmdline *cl,
15758 __attribute__((unused)) void *data)
15760 struct cmd_set_l2_encap_result *res = parsed_result;
15762 if (strcmp(res->l2_encap, "l2_encap") == 0)
15763 l2_encap_conf.select_vlan = 0;
15764 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15765 l2_encap_conf.select_vlan = 1;
15766 if (strcmp(res->ip_version, "ipv4") == 0)
15767 l2_encap_conf.select_ipv4 = 1;
15768 else if (strcmp(res->ip_version, "ipv6") == 0)
15769 l2_encap_conf.select_ipv4 = 0;
15772 if (l2_encap_conf.select_vlan)
15773 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15774 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15775 RTE_ETHER_ADDR_LEN);
15776 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15777 RTE_ETHER_ADDR_LEN);
15780 cmdline_parse_inst_t cmd_set_l2_encap = {
15781 .f = cmd_set_l2_encap_parsed,
15783 .help_str = "set l2_encap ip-version ipv4|ipv6"
15784 " eth-src <eth-src> eth-dst <eth-dst>",
15786 (void *)&cmd_set_l2_encap_set,
15787 (void *)&cmd_set_l2_encap_l2_encap,
15788 (void *)&cmd_set_l2_encap_ip_version,
15789 (void *)&cmd_set_l2_encap_ip_version_value,
15790 (void *)&cmd_set_l2_encap_eth_src,
15791 (void *)&cmd_set_l2_encap_eth_src_value,
15792 (void *)&cmd_set_l2_encap_eth_dst,
15793 (void *)&cmd_set_l2_encap_eth_dst_value,
15798 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15799 .f = cmd_set_l2_encap_parsed,
15801 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15802 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15804 (void *)&cmd_set_l2_encap_set,
15805 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15806 (void *)&cmd_set_l2_encap_ip_version,
15807 (void *)&cmd_set_l2_encap_ip_version_value,
15808 (void *)&cmd_set_l2_encap_vlan,
15809 (void *)&cmd_set_l2_encap_vlan_value,
15810 (void *)&cmd_set_l2_encap_eth_src,
15811 (void *)&cmd_set_l2_encap_eth_src_value,
15812 (void *)&cmd_set_l2_encap_eth_dst,
15813 (void *)&cmd_set_l2_encap_eth_dst_value,
15818 /** Set L2 decapsulation details */
15819 struct cmd_set_l2_decap_result {
15820 cmdline_fixed_string_t set;
15821 cmdline_fixed_string_t l2_decap;
15822 cmdline_fixed_string_t pos_token;
15823 uint32_t vlan_present:1;
15826 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15827 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15828 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15829 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15831 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15832 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15833 "l2_decap-with-vlan");
15835 static void cmd_set_l2_decap_parsed(void *parsed_result,
15836 __attribute__((unused)) struct cmdline *cl,
15837 __attribute__((unused)) void *data)
15839 struct cmd_set_l2_decap_result *res = parsed_result;
15841 if (strcmp(res->l2_decap, "l2_decap") == 0)
15842 l2_decap_conf.select_vlan = 0;
15843 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15844 l2_decap_conf.select_vlan = 1;
15847 cmdline_parse_inst_t cmd_set_l2_decap = {
15848 .f = cmd_set_l2_decap_parsed,
15850 .help_str = "set l2_decap",
15852 (void *)&cmd_set_l2_decap_set,
15853 (void *)&cmd_set_l2_decap_l2_decap,
15858 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15859 .f = cmd_set_l2_decap_parsed,
15861 .help_str = "set l2_decap-with-vlan",
15863 (void *)&cmd_set_l2_decap_set,
15864 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15869 /** Set MPLSoGRE encapsulation details */
15870 struct cmd_set_mplsogre_encap_result {
15871 cmdline_fixed_string_t set;
15872 cmdline_fixed_string_t mplsogre;
15873 cmdline_fixed_string_t pos_token;
15874 cmdline_fixed_string_t ip_version;
15875 uint32_t vlan_present:1;
15877 cmdline_ipaddr_t ip_src;
15878 cmdline_ipaddr_t ip_dst;
15880 struct rte_ether_addr eth_src;
15881 struct rte_ether_addr eth_dst;
15884 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15885 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15887 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15888 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15890 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15891 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15892 mplsogre, "mplsogre_encap-with-vlan");
15893 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15894 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15895 pos_token, "ip-version");
15896 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15897 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15898 ip_version, "ipv4#ipv6");
15899 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15900 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15901 pos_token, "label");
15902 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15903 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15905 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15906 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15907 pos_token, "ip-src");
15908 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15909 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15910 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15911 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15912 pos_token, "ip-dst");
15913 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15914 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15915 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15916 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15917 pos_token, "vlan-tci");
15918 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15919 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15921 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15922 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15923 pos_token, "eth-src");
15924 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15925 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15927 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15928 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15929 pos_token, "eth-dst");
15930 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15931 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15934 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15935 __attribute__((unused)) struct cmdline *cl,
15936 __attribute__((unused)) void *data)
15938 struct cmd_set_mplsogre_encap_result *res = parsed_result;
15940 uint32_t mplsogre_label;
15943 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15946 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15947 mplsogre_encap_conf.select_vlan = 0;
15948 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15949 mplsogre_encap_conf.select_vlan = 1;
15950 if (strcmp(res->ip_version, "ipv4") == 0)
15951 mplsogre_encap_conf.select_ipv4 = 1;
15952 else if (strcmp(res->ip_version, "ipv6") == 0)
15953 mplsogre_encap_conf.select_ipv4 = 0;
15956 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15957 if (mplsogre_encap_conf.select_ipv4) {
15958 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15959 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15961 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15962 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15964 if (mplsogre_encap_conf.select_vlan)
15965 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15966 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15967 RTE_ETHER_ADDR_LEN);
15968 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15969 RTE_ETHER_ADDR_LEN);
15972 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15973 .f = cmd_set_mplsogre_encap_parsed,
15975 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15976 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15977 " eth-dst <eth-dst>",
15979 (void *)&cmd_set_mplsogre_encap_set,
15980 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15981 (void *)&cmd_set_mplsogre_encap_ip_version,
15982 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15983 (void *)&cmd_set_mplsogre_encap_label,
15984 (void *)&cmd_set_mplsogre_encap_label_value,
15985 (void *)&cmd_set_mplsogre_encap_ip_src,
15986 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15987 (void *)&cmd_set_mplsogre_encap_ip_dst,
15988 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15989 (void *)&cmd_set_mplsogre_encap_eth_src,
15990 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15991 (void *)&cmd_set_mplsogre_encap_eth_dst,
15992 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15997 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
15998 .f = cmd_set_mplsogre_encap_parsed,
16000 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
16001 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
16002 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
16004 (void *)&cmd_set_mplsogre_encap_set,
16005 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
16006 (void *)&cmd_set_mplsogre_encap_ip_version,
16007 (void *)&cmd_set_mplsogre_encap_ip_version_value,
16008 (void *)&cmd_set_mplsogre_encap_label,
16009 (void *)&cmd_set_mplsogre_encap_label_value,
16010 (void *)&cmd_set_mplsogre_encap_ip_src,
16011 (void *)&cmd_set_mplsogre_encap_ip_src_value,
16012 (void *)&cmd_set_mplsogre_encap_ip_dst,
16013 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
16014 (void *)&cmd_set_mplsogre_encap_vlan,
16015 (void *)&cmd_set_mplsogre_encap_vlan_value,
16016 (void *)&cmd_set_mplsogre_encap_eth_src,
16017 (void *)&cmd_set_mplsogre_encap_eth_src_value,
16018 (void *)&cmd_set_mplsogre_encap_eth_dst,
16019 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
16024 /** Set MPLSoGRE decapsulation details */
16025 struct cmd_set_mplsogre_decap_result {
16026 cmdline_fixed_string_t set;
16027 cmdline_fixed_string_t mplsogre;
16028 cmdline_fixed_string_t pos_token;
16029 cmdline_fixed_string_t ip_version;
16030 uint32_t vlan_present:1;
16033 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
16034 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
16036 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
16037 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
16039 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
16040 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16041 mplsogre, "mplsogre_decap-with-vlan");
16042 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
16043 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16044 pos_token, "ip-version");
16045 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
16046 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
16047 ip_version, "ipv4#ipv6");
16049 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
16050 __attribute__((unused)) struct cmdline *cl,
16051 __attribute__((unused)) void *data)
16053 struct cmd_set_mplsogre_decap_result *res = parsed_result;
16055 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
16056 mplsogre_decap_conf.select_vlan = 0;
16057 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
16058 mplsogre_decap_conf.select_vlan = 1;
16059 if (strcmp(res->ip_version, "ipv4") == 0)
16060 mplsogre_decap_conf.select_ipv4 = 1;
16061 else if (strcmp(res->ip_version, "ipv6") == 0)
16062 mplsogre_decap_conf.select_ipv4 = 0;
16065 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
16066 .f = cmd_set_mplsogre_decap_parsed,
16068 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
16070 (void *)&cmd_set_mplsogre_decap_set,
16071 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
16072 (void *)&cmd_set_mplsogre_decap_ip_version,
16073 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16078 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
16079 .f = cmd_set_mplsogre_decap_parsed,
16081 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
16083 (void *)&cmd_set_mplsogre_decap_set,
16084 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
16085 (void *)&cmd_set_mplsogre_decap_ip_version,
16086 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16091 /** Set MPLSoUDP encapsulation details */
16092 struct cmd_set_mplsoudp_encap_result {
16093 cmdline_fixed_string_t set;
16094 cmdline_fixed_string_t mplsoudp;
16095 cmdline_fixed_string_t pos_token;
16096 cmdline_fixed_string_t ip_version;
16097 uint32_t vlan_present:1;
16101 cmdline_ipaddr_t ip_src;
16102 cmdline_ipaddr_t ip_dst;
16104 struct rte_ether_addr eth_src;
16105 struct rte_ether_addr eth_dst;
16108 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16109 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16111 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16112 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16114 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16115 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16116 mplsoudp, "mplsoudp_encap-with-vlan");
16117 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16118 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16119 pos_token, "ip-version");
16120 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16121 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16122 ip_version, "ipv4#ipv6");
16123 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16124 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16125 pos_token, "label");
16126 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16127 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16129 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16130 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16131 pos_token, "udp-src");
16132 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16133 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16135 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16136 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16137 pos_token, "udp-dst");
16138 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16139 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16141 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16142 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16143 pos_token, "ip-src");
16144 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16145 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16146 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16147 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16148 pos_token, "ip-dst");
16149 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16150 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16151 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16152 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16153 pos_token, "vlan-tci");
16154 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16155 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16157 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16158 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16159 pos_token, "eth-src");
16160 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16161 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16163 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16164 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16165 pos_token, "eth-dst");
16166 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16167 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16170 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16171 __attribute__((unused)) struct cmdline *cl,
16172 __attribute__((unused)) void *data)
16174 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16176 uint32_t mplsoudp_label;
16179 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16182 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16183 mplsoudp_encap_conf.select_vlan = 0;
16184 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16185 mplsoudp_encap_conf.select_vlan = 1;
16186 if (strcmp(res->ip_version, "ipv4") == 0)
16187 mplsoudp_encap_conf.select_ipv4 = 1;
16188 else if (strcmp(res->ip_version, "ipv6") == 0)
16189 mplsoudp_encap_conf.select_ipv4 = 0;
16192 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16193 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16194 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16195 if (mplsoudp_encap_conf.select_ipv4) {
16196 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16197 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16199 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16200 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16202 if (mplsoudp_encap_conf.select_vlan)
16203 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16204 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16205 RTE_ETHER_ADDR_LEN);
16206 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16207 RTE_ETHER_ADDR_LEN);
16210 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16211 .f = cmd_set_mplsoudp_encap_parsed,
16213 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16214 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16215 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16217 (void *)&cmd_set_mplsoudp_encap_set,
16218 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16219 (void *)&cmd_set_mplsoudp_encap_ip_version,
16220 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16221 (void *)&cmd_set_mplsoudp_encap_label,
16222 (void *)&cmd_set_mplsoudp_encap_label_value,
16223 (void *)&cmd_set_mplsoudp_encap_udp_src,
16224 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16225 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16226 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16227 (void *)&cmd_set_mplsoudp_encap_ip_src,
16228 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16229 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16230 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16231 (void *)&cmd_set_mplsoudp_encap_eth_src,
16232 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16233 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16234 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16239 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16240 .f = cmd_set_mplsoudp_encap_parsed,
16242 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16243 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16244 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16245 " eth-src <eth-src> eth-dst <eth-dst>",
16247 (void *)&cmd_set_mplsoudp_encap_set,
16248 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16249 (void *)&cmd_set_mplsoudp_encap_ip_version,
16250 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16251 (void *)&cmd_set_mplsoudp_encap_label,
16252 (void *)&cmd_set_mplsoudp_encap_label_value,
16253 (void *)&cmd_set_mplsoudp_encap_udp_src,
16254 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16255 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16256 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16257 (void *)&cmd_set_mplsoudp_encap_ip_src,
16258 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16259 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16260 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16261 (void *)&cmd_set_mplsoudp_encap_vlan,
16262 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16263 (void *)&cmd_set_mplsoudp_encap_eth_src,
16264 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16265 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16266 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16271 /** Set MPLSoUDP decapsulation details */
16272 struct cmd_set_mplsoudp_decap_result {
16273 cmdline_fixed_string_t set;
16274 cmdline_fixed_string_t mplsoudp;
16275 cmdline_fixed_string_t pos_token;
16276 cmdline_fixed_string_t ip_version;
16277 uint32_t vlan_present:1;
16280 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16281 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16283 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16284 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16286 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16287 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16288 mplsoudp, "mplsoudp_decap-with-vlan");
16289 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16290 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16291 pos_token, "ip-version");
16292 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16293 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16294 ip_version, "ipv4#ipv6");
16296 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16297 __attribute__((unused)) struct cmdline *cl,
16298 __attribute__((unused)) void *data)
16300 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16302 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16303 mplsoudp_decap_conf.select_vlan = 0;
16304 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16305 mplsoudp_decap_conf.select_vlan = 1;
16306 if (strcmp(res->ip_version, "ipv4") == 0)
16307 mplsoudp_decap_conf.select_ipv4 = 1;
16308 else if (strcmp(res->ip_version, "ipv6") == 0)
16309 mplsoudp_decap_conf.select_ipv4 = 0;
16312 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16313 .f = cmd_set_mplsoudp_decap_parsed,
16315 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16317 (void *)&cmd_set_mplsoudp_decap_set,
16318 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16319 (void *)&cmd_set_mplsoudp_decap_ip_version,
16320 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16325 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16326 .f = cmd_set_mplsoudp_decap_parsed,
16328 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16330 (void *)&cmd_set_mplsoudp_decap_set,
16331 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16332 (void *)&cmd_set_mplsoudp_decap_ip_version,
16333 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16338 /* Strict link priority scheduling mode setting */
16340 cmd_strict_link_prio_parsed(
16341 void *parsed_result,
16342 __attribute__((unused)) struct cmdline *cl,
16343 __attribute__((unused)) void *data)
16345 struct cmd_vf_tc_bw_result *res = parsed_result;
16346 int ret = -ENOTSUP;
16348 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16351 #ifdef RTE_LIBRTE_I40E_PMD
16352 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16359 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16362 printf("invalid port_id %d\n", res->port_id);
16365 printf("function not implemented\n");
16368 printf("programming error: (%s)\n", strerror(-ret));
16372 cmdline_parse_inst_t cmd_strict_link_prio = {
16373 .f = cmd_strict_link_prio_parsed,
16375 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16377 (void *)&cmd_vf_tc_bw_set,
16378 (void *)&cmd_vf_tc_bw_tx,
16379 (void *)&cmd_vf_tc_bw_strict_link_prio,
16380 (void *)&cmd_vf_tc_bw_port_id,
16381 (void *)&cmd_vf_tc_bw_tc_map,
16386 /* Load dynamic device personalization*/
16387 struct cmd_ddp_add_result {
16388 cmdline_fixed_string_t ddp;
16389 cmdline_fixed_string_t add;
16394 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16395 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16396 cmdline_parse_token_string_t cmd_ddp_add_add =
16397 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16398 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16399 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16400 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16401 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16404 cmd_ddp_add_parsed(
16405 void *parsed_result,
16406 __attribute__((unused)) struct cmdline *cl,
16407 __attribute__((unused)) void *data)
16409 struct cmd_ddp_add_result *res = parsed_result;
16415 int ret = -ENOTSUP;
16417 if (!all_ports_stopped()) {
16418 printf("Please stop all ports first\n");
16422 filepath = strdup(res->filepath);
16423 if (filepath == NULL) {
16424 printf("Failed to allocate memory\n");
16427 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16429 buff = open_file(file_fld[0], &size);
16431 free((void *)filepath);
16435 #ifdef RTE_LIBRTE_I40E_PMD
16436 if (ret == -ENOTSUP)
16437 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16439 RTE_PMD_I40E_PKG_OP_WR_ADD);
16442 if (ret == -EEXIST)
16443 printf("Profile has already existed.\n");
16445 printf("Failed to load profile.\n");
16446 else if (file_num == 2)
16447 save_file(file_fld[1], buff, size);
16450 free((void *)filepath);
16453 cmdline_parse_inst_t cmd_ddp_add = {
16454 .f = cmd_ddp_add_parsed,
16456 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16458 (void *)&cmd_ddp_add_ddp,
16459 (void *)&cmd_ddp_add_add,
16460 (void *)&cmd_ddp_add_port_id,
16461 (void *)&cmd_ddp_add_filepath,
16466 /* Delete dynamic device personalization*/
16467 struct cmd_ddp_del_result {
16468 cmdline_fixed_string_t ddp;
16469 cmdline_fixed_string_t del;
16474 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16475 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16476 cmdline_parse_token_string_t cmd_ddp_del_del =
16477 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16478 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16479 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16480 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16481 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16484 cmd_ddp_del_parsed(
16485 void *parsed_result,
16486 __attribute__((unused)) struct cmdline *cl,
16487 __attribute__((unused)) void *data)
16489 struct cmd_ddp_del_result *res = parsed_result;
16492 int ret = -ENOTSUP;
16494 if (!all_ports_stopped()) {
16495 printf("Please stop all ports first\n");
16499 buff = open_file(res->filepath, &size);
16503 #ifdef RTE_LIBRTE_I40E_PMD
16504 if (ret == -ENOTSUP)
16505 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16507 RTE_PMD_I40E_PKG_OP_WR_DEL);
16510 if (ret == -EACCES)
16511 printf("Profile does not exist.\n");
16513 printf("Failed to delete profile.\n");
16518 cmdline_parse_inst_t cmd_ddp_del = {
16519 .f = cmd_ddp_del_parsed,
16521 .help_str = "ddp del <port_id> <backup_profile_path>",
16523 (void *)&cmd_ddp_del_ddp,
16524 (void *)&cmd_ddp_del_del,
16525 (void *)&cmd_ddp_del_port_id,
16526 (void *)&cmd_ddp_del_filepath,
16531 /* Get dynamic device personalization profile info */
16532 struct cmd_ddp_info_result {
16533 cmdline_fixed_string_t ddp;
16534 cmdline_fixed_string_t get;
16535 cmdline_fixed_string_t info;
16539 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16540 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16541 cmdline_parse_token_string_t cmd_ddp_info_get =
16542 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16543 cmdline_parse_token_string_t cmd_ddp_info_info =
16544 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16545 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16546 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16549 cmd_ddp_info_parsed(
16550 void *parsed_result,
16551 __attribute__((unused)) struct cmdline *cl,
16552 __attribute__((unused)) void *data)
16554 struct cmd_ddp_info_result *res = parsed_result;
16557 int ret = -ENOTSUP;
16558 #ifdef RTE_LIBRTE_I40E_PMD
16561 uint32_t buff_size = 0;
16562 struct rte_pmd_i40e_profile_info info;
16563 uint32_t dev_num = 0;
16564 struct rte_pmd_i40e_ddp_device_id *devs;
16565 uint32_t proto_num = 0;
16566 struct rte_pmd_i40e_proto_info *proto = NULL;
16567 uint32_t pctype_num = 0;
16568 struct rte_pmd_i40e_ptype_info *pctype;
16569 uint32_t ptype_num = 0;
16570 struct rte_pmd_i40e_ptype_info *ptype;
16575 pkg = open_file(res->filepath, &pkg_size);
16579 #ifdef RTE_LIBRTE_I40E_PMD
16580 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16581 (uint8_t *)&info, sizeof(info),
16582 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16584 printf("Global Track id: 0x%x\n", info.track_id);
16585 printf("Global Version: %d.%d.%d.%d\n",
16586 info.version.major,
16587 info.version.minor,
16588 info.version.update,
16589 info.version.draft);
16590 printf("Global Package name: %s\n\n", info.name);
16593 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16594 (uint8_t *)&info, sizeof(info),
16595 RTE_PMD_I40E_PKG_INFO_HEADER);
16597 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16598 printf("i40e Profile Version: %d.%d.%d.%d\n",
16599 info.version.major,
16600 info.version.minor,
16601 info.version.update,
16602 info.version.draft);
16603 printf("i40e Profile name: %s\n\n", info.name);
16606 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16607 (uint8_t *)&buff_size, sizeof(buff_size),
16608 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16609 if (!ret && buff_size) {
16610 buff = (uint8_t *)malloc(buff_size);
16612 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16614 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16616 printf("Package Notes:\n%s\n\n", buff);
16621 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16622 (uint8_t *)&dev_num, sizeof(dev_num),
16623 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16624 if (!ret && dev_num) {
16625 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16626 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16628 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16629 (uint8_t *)devs, buff_size,
16630 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16632 printf("List of supported devices:\n");
16633 for (i = 0; i < dev_num; i++) {
16634 printf(" %04X:%04X %04X:%04X\n",
16635 devs[i].vendor_dev_id >> 16,
16636 devs[i].vendor_dev_id & 0xFFFF,
16637 devs[i].sub_vendor_dev_id >> 16,
16638 devs[i].sub_vendor_dev_id & 0xFFFF);
16646 /* get information about protocols and packet types */
16647 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16648 (uint8_t *)&proto_num, sizeof(proto_num),
16649 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16650 if (ret || !proto_num)
16651 goto no_print_return;
16653 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16654 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16656 goto no_print_return;
16658 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16660 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16662 printf("List of used protocols:\n");
16663 for (i = 0; i < proto_num; i++)
16664 printf(" %2u: %s\n", proto[i].proto_id,
16668 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16669 (uint8_t *)&pctype_num, sizeof(pctype_num),
16670 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16671 if (ret || !pctype_num)
16672 goto no_print_pctypes;
16674 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16675 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16677 goto no_print_pctypes;
16679 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16681 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16684 goto no_print_pctypes;
16687 printf("List of defined packet classification types:\n");
16688 for (i = 0; i < pctype_num; i++) {
16689 printf(" %2u:", pctype[i].ptype_id);
16690 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16691 proto_id = pctype[i].protocols[j];
16692 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16693 for (n = 0; n < proto_num; n++) {
16694 if (proto[n].proto_id == proto_id) {
16695 printf(" %s", proto[n].name);
16708 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16710 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16711 if (ret || !ptype_num)
16712 goto no_print_return;
16714 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16715 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16717 goto no_print_return;
16719 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16721 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16724 goto no_print_return;
16726 printf("List of defined packet types:\n");
16727 for (i = 0; i < ptype_num; i++) {
16728 printf(" %2u:", ptype[i].ptype_id);
16729 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16730 proto_id = ptype[i].protocols[j];
16731 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16732 for (n = 0; n < proto_num; n++) {
16733 if (proto[n].proto_id == proto_id) {
16734 printf(" %s", proto[n].name);
16750 if (ret == -ENOTSUP)
16751 printf("Function not supported in PMD driver\n");
16755 cmdline_parse_inst_t cmd_ddp_get_info = {
16756 .f = cmd_ddp_info_parsed,
16758 .help_str = "ddp get info <profile_path>",
16760 (void *)&cmd_ddp_info_ddp,
16761 (void *)&cmd_ddp_info_get,
16762 (void *)&cmd_ddp_info_info,
16763 (void *)&cmd_ddp_info_filepath,
16768 /* Get dynamic device personalization profile info list*/
16769 #define PROFILE_INFO_SIZE 48
16770 #define MAX_PROFILE_NUM 16
16772 struct cmd_ddp_get_list_result {
16773 cmdline_fixed_string_t ddp;
16774 cmdline_fixed_string_t get;
16775 cmdline_fixed_string_t list;
16779 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16780 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16781 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16782 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16783 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16784 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16785 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16786 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16789 cmd_ddp_get_list_parsed(
16790 __attribute__((unused)) void *parsed_result,
16791 __attribute__((unused)) struct cmdline *cl,
16792 __attribute__((unused)) void *data)
16794 #ifdef RTE_LIBRTE_I40E_PMD
16795 struct cmd_ddp_get_list_result *res = parsed_result;
16796 struct rte_pmd_i40e_profile_list *p_list;
16797 struct rte_pmd_i40e_profile_info *p_info;
16802 int ret = -ENOTSUP;
16804 #ifdef RTE_LIBRTE_I40E_PMD
16805 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16806 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16808 printf("%s: Failed to malloc buffer\n", __func__);
16810 if (ret == -ENOTSUP)
16811 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16812 (uint8_t *)p_list, size);
16815 p_num = p_list->p_count;
16816 printf("Profile number is: %d\n\n", p_num);
16818 for (i = 0; i < p_num; i++) {
16819 p_info = &p_list->p_info[i];
16820 printf("Profile %d:\n", i);
16821 printf("Track id: 0x%x\n", p_info->track_id);
16822 printf("Version: %d.%d.%d.%d\n",
16823 p_info->version.major,
16824 p_info->version.minor,
16825 p_info->version.update,
16826 p_info->version.draft);
16827 printf("Profile name: %s\n\n", p_info->name);
16835 printf("Failed to get ddp list\n");
16838 cmdline_parse_inst_t cmd_ddp_get_list = {
16839 .f = cmd_ddp_get_list_parsed,
16841 .help_str = "ddp get list <port_id>",
16843 (void *)&cmd_ddp_get_list_ddp,
16844 (void *)&cmd_ddp_get_list_get,
16845 (void *)&cmd_ddp_get_list_list,
16846 (void *)&cmd_ddp_get_list_port_id,
16851 /* Configure input set */
16852 struct cmd_cfg_input_set_result {
16853 cmdline_fixed_string_t port;
16854 cmdline_fixed_string_t cfg;
16856 cmdline_fixed_string_t pctype;
16858 cmdline_fixed_string_t inset_type;
16859 cmdline_fixed_string_t opt;
16860 cmdline_fixed_string_t field;
16865 cmd_cfg_input_set_parsed(
16866 __attribute__((unused)) void *parsed_result,
16867 __attribute__((unused)) struct cmdline *cl,
16868 __attribute__((unused)) void *data)
16870 #ifdef RTE_LIBRTE_I40E_PMD
16871 struct cmd_cfg_input_set_result *res = parsed_result;
16872 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16873 struct rte_pmd_i40e_inset inset;
16875 int ret = -ENOTSUP;
16877 if (!all_ports_stopped()) {
16878 printf("Please stop all ports first\n");
16882 #ifdef RTE_LIBRTE_I40E_PMD
16883 if (!strcmp(res->inset_type, "hash_inset"))
16884 inset_type = INSET_HASH;
16885 else if (!strcmp(res->inset_type, "fdir_inset"))
16886 inset_type = INSET_FDIR;
16887 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16888 inset_type = INSET_FDIR_FLX;
16889 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16890 &inset, inset_type);
16892 printf("Failed to get input set.\n");
16896 if (!strcmp(res->opt, "get")) {
16897 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16900 printf("Field index %d is enabled.\n", res->field_idx);
16902 printf("Field index %d is disabled.\n", res->field_idx);
16904 } else if (!strcmp(res->opt, "set"))
16905 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16907 else if (!strcmp(res->opt, "clear"))
16908 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16911 printf("Failed to configure input set field.\n");
16915 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16916 &inset, inset_type);
16918 printf("Failed to set input set.\n");
16923 if (ret == -ENOTSUP)
16924 printf("Function not supported\n");
16927 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16928 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16930 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16931 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16933 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16934 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16936 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16937 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16939 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16940 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16942 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16943 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16945 "hash_inset#fdir_inset#fdir_flx_inset");
16946 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16947 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16948 opt, "get#set#clear");
16949 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16950 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16952 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16953 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16956 cmdline_parse_inst_t cmd_cfg_input_set = {
16957 .f = cmd_cfg_input_set_parsed,
16959 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16960 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16962 (void *)&cmd_cfg_input_set_port,
16963 (void *)&cmd_cfg_input_set_cfg,
16964 (void *)&cmd_cfg_input_set_port_id,
16965 (void *)&cmd_cfg_input_set_pctype,
16966 (void *)&cmd_cfg_input_set_pctype_id,
16967 (void *)&cmd_cfg_input_set_inset_type,
16968 (void *)&cmd_cfg_input_set_opt,
16969 (void *)&cmd_cfg_input_set_field,
16970 (void *)&cmd_cfg_input_set_field_idx,
16975 /* Clear input set */
16976 struct cmd_clear_input_set_result {
16977 cmdline_fixed_string_t port;
16978 cmdline_fixed_string_t cfg;
16980 cmdline_fixed_string_t pctype;
16982 cmdline_fixed_string_t inset_type;
16983 cmdline_fixed_string_t clear;
16984 cmdline_fixed_string_t all;
16988 cmd_clear_input_set_parsed(
16989 __attribute__((unused)) void *parsed_result,
16990 __attribute__((unused)) struct cmdline *cl,
16991 __attribute__((unused)) void *data)
16993 #ifdef RTE_LIBRTE_I40E_PMD
16994 struct cmd_clear_input_set_result *res = parsed_result;
16995 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16996 struct rte_pmd_i40e_inset inset;
16998 int ret = -ENOTSUP;
17000 if (!all_ports_stopped()) {
17001 printf("Please stop all ports first\n");
17005 #ifdef RTE_LIBRTE_I40E_PMD
17006 if (!strcmp(res->inset_type, "hash_inset"))
17007 inset_type = INSET_HASH;
17008 else if (!strcmp(res->inset_type, "fdir_inset"))
17009 inset_type = INSET_FDIR;
17010 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
17011 inset_type = INSET_FDIR_FLX;
17013 memset(&inset, 0, sizeof(inset));
17015 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
17016 &inset, inset_type);
17018 printf("Failed to clear input set.\n");
17024 if (ret == -ENOTSUP)
17025 printf("Function not supported\n");
17028 cmdline_parse_token_string_t cmd_clear_input_set_port =
17029 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17031 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
17032 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17034 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
17035 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17037 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
17038 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17040 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
17041 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
17043 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
17044 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17046 "hash_inset#fdir_inset#fdir_flx_inset");
17047 cmdline_parse_token_string_t cmd_clear_input_set_clear =
17048 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17050 cmdline_parse_token_string_t cmd_clear_input_set_all =
17051 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
17054 cmdline_parse_inst_t cmd_clear_input_set = {
17055 .f = cmd_clear_input_set_parsed,
17057 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
17058 "fdir_inset|fdir_flx_inset clear all",
17060 (void *)&cmd_clear_input_set_port,
17061 (void *)&cmd_clear_input_set_cfg,
17062 (void *)&cmd_clear_input_set_port_id,
17063 (void *)&cmd_clear_input_set_pctype,
17064 (void *)&cmd_clear_input_set_pctype_id,
17065 (void *)&cmd_clear_input_set_inset_type,
17066 (void *)&cmd_clear_input_set_clear,
17067 (void *)&cmd_clear_input_set_all,
17072 /* show vf stats */
17074 /* Common result structure for show vf stats */
17075 struct cmd_show_vf_stats_result {
17076 cmdline_fixed_string_t show;
17077 cmdline_fixed_string_t vf;
17078 cmdline_fixed_string_t stats;
17083 /* Common CLI fields show vf stats*/
17084 cmdline_parse_token_string_t cmd_show_vf_stats_show =
17085 TOKEN_STRING_INITIALIZER
17086 (struct cmd_show_vf_stats_result,
17088 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
17089 TOKEN_STRING_INITIALIZER
17090 (struct cmd_show_vf_stats_result,
17092 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17093 TOKEN_STRING_INITIALIZER
17094 (struct cmd_show_vf_stats_result,
17096 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17097 TOKEN_NUM_INITIALIZER
17098 (struct cmd_show_vf_stats_result,
17100 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17101 TOKEN_NUM_INITIALIZER
17102 (struct cmd_show_vf_stats_result,
17106 cmd_show_vf_stats_parsed(
17107 void *parsed_result,
17108 __attribute__((unused)) struct cmdline *cl,
17109 __attribute__((unused)) void *data)
17111 struct cmd_show_vf_stats_result *res = parsed_result;
17112 struct rte_eth_stats stats;
17113 int ret = -ENOTSUP;
17114 static const char *nic_stats_border = "########################";
17116 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17119 memset(&stats, 0, sizeof(stats));
17121 #ifdef RTE_LIBRTE_I40E_PMD
17122 if (ret == -ENOTSUP)
17123 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17127 #ifdef RTE_LIBRTE_BNXT_PMD
17128 if (ret == -ENOTSUP)
17129 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17138 printf("invalid vf_id %d\n", res->vf_id);
17141 printf("invalid port_id %d\n", res->port_id);
17144 printf("function not implemented\n");
17147 printf("programming error: (%s)\n", strerror(-ret));
17150 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17151 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17153 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17155 stats.ipackets, stats.imissed, stats.ibytes);
17156 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17157 printf(" RX-nombuf: %-10"PRIu64"\n",
17159 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17161 stats.opackets, stats.oerrors, stats.obytes);
17163 printf(" %s############################%s\n",
17164 nic_stats_border, nic_stats_border);
17167 cmdline_parse_inst_t cmd_show_vf_stats = {
17168 .f = cmd_show_vf_stats_parsed,
17170 .help_str = "show vf stats <port_id> <vf_id>",
17172 (void *)&cmd_show_vf_stats_show,
17173 (void *)&cmd_show_vf_stats_vf,
17174 (void *)&cmd_show_vf_stats_stats,
17175 (void *)&cmd_show_vf_stats_port_id,
17176 (void *)&cmd_show_vf_stats_vf_id,
17181 /* clear vf stats */
17183 /* Common result structure for clear vf stats */
17184 struct cmd_clear_vf_stats_result {
17185 cmdline_fixed_string_t clear;
17186 cmdline_fixed_string_t vf;
17187 cmdline_fixed_string_t stats;
17192 /* Common CLI fields clear vf stats*/
17193 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17194 TOKEN_STRING_INITIALIZER
17195 (struct cmd_clear_vf_stats_result,
17197 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17198 TOKEN_STRING_INITIALIZER
17199 (struct cmd_clear_vf_stats_result,
17201 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17202 TOKEN_STRING_INITIALIZER
17203 (struct cmd_clear_vf_stats_result,
17205 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17206 TOKEN_NUM_INITIALIZER
17207 (struct cmd_clear_vf_stats_result,
17209 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17210 TOKEN_NUM_INITIALIZER
17211 (struct cmd_clear_vf_stats_result,
17215 cmd_clear_vf_stats_parsed(
17216 void *parsed_result,
17217 __attribute__((unused)) struct cmdline *cl,
17218 __attribute__((unused)) void *data)
17220 struct cmd_clear_vf_stats_result *res = parsed_result;
17221 int ret = -ENOTSUP;
17223 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17226 #ifdef RTE_LIBRTE_I40E_PMD
17227 if (ret == -ENOTSUP)
17228 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17231 #ifdef RTE_LIBRTE_BNXT_PMD
17232 if (ret == -ENOTSUP)
17233 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17241 printf("invalid vf_id %d\n", res->vf_id);
17244 printf("invalid port_id %d\n", res->port_id);
17247 printf("function not implemented\n");
17250 printf("programming error: (%s)\n", strerror(-ret));
17254 cmdline_parse_inst_t cmd_clear_vf_stats = {
17255 .f = cmd_clear_vf_stats_parsed,
17257 .help_str = "clear vf stats <port_id> <vf_id>",
17259 (void *)&cmd_clear_vf_stats_clear,
17260 (void *)&cmd_clear_vf_stats_vf,
17261 (void *)&cmd_clear_vf_stats_stats,
17262 (void *)&cmd_clear_vf_stats_port_id,
17263 (void *)&cmd_clear_vf_stats_vf_id,
17268 /* port config pctype mapping reset */
17270 /* Common result structure for port config pctype mapping reset */
17271 struct cmd_pctype_mapping_reset_result {
17272 cmdline_fixed_string_t port;
17273 cmdline_fixed_string_t config;
17275 cmdline_fixed_string_t pctype;
17276 cmdline_fixed_string_t mapping;
17277 cmdline_fixed_string_t reset;
17280 /* Common CLI fields for port config pctype mapping reset*/
17281 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17282 TOKEN_STRING_INITIALIZER
17283 (struct cmd_pctype_mapping_reset_result,
17285 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17286 TOKEN_STRING_INITIALIZER
17287 (struct cmd_pctype_mapping_reset_result,
17289 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17290 TOKEN_NUM_INITIALIZER
17291 (struct cmd_pctype_mapping_reset_result,
17293 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17294 TOKEN_STRING_INITIALIZER
17295 (struct cmd_pctype_mapping_reset_result,
17297 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17298 TOKEN_STRING_INITIALIZER
17299 (struct cmd_pctype_mapping_reset_result,
17300 mapping, "mapping");
17301 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17302 TOKEN_STRING_INITIALIZER
17303 (struct cmd_pctype_mapping_reset_result,
17307 cmd_pctype_mapping_reset_parsed(
17308 void *parsed_result,
17309 __attribute__((unused)) struct cmdline *cl,
17310 __attribute__((unused)) void *data)
17312 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17313 int ret = -ENOTSUP;
17315 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17318 #ifdef RTE_LIBRTE_I40E_PMD
17319 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17326 printf("invalid port_id %d\n", res->port_id);
17329 printf("function not implemented\n");
17332 printf("programming error: (%s)\n", strerror(-ret));
17336 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17337 .f = cmd_pctype_mapping_reset_parsed,
17339 .help_str = "port config <port_id> pctype mapping reset",
17341 (void *)&cmd_pctype_mapping_reset_port,
17342 (void *)&cmd_pctype_mapping_reset_config,
17343 (void *)&cmd_pctype_mapping_reset_port_id,
17344 (void *)&cmd_pctype_mapping_reset_pctype,
17345 (void *)&cmd_pctype_mapping_reset_mapping,
17346 (void *)&cmd_pctype_mapping_reset_reset,
17351 /* show port pctype mapping */
17353 /* Common result structure for show port pctype mapping */
17354 struct cmd_pctype_mapping_get_result {
17355 cmdline_fixed_string_t show;
17356 cmdline_fixed_string_t port;
17358 cmdline_fixed_string_t pctype;
17359 cmdline_fixed_string_t mapping;
17362 /* Common CLI fields for pctype mapping get */
17363 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17364 TOKEN_STRING_INITIALIZER
17365 (struct cmd_pctype_mapping_get_result,
17367 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17368 TOKEN_STRING_INITIALIZER
17369 (struct cmd_pctype_mapping_get_result,
17371 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17372 TOKEN_NUM_INITIALIZER
17373 (struct cmd_pctype_mapping_get_result,
17375 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17376 TOKEN_STRING_INITIALIZER
17377 (struct cmd_pctype_mapping_get_result,
17379 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17380 TOKEN_STRING_INITIALIZER
17381 (struct cmd_pctype_mapping_get_result,
17382 mapping, "mapping");
17385 cmd_pctype_mapping_get_parsed(
17386 void *parsed_result,
17387 __attribute__((unused)) struct cmdline *cl,
17388 __attribute__((unused)) void *data)
17390 struct cmd_pctype_mapping_get_result *res = parsed_result;
17391 int ret = -ENOTSUP;
17392 #ifdef RTE_LIBRTE_I40E_PMD
17393 struct rte_pmd_i40e_flow_type_mapping
17394 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17395 int i, j, first_pctype;
17398 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17401 #ifdef RTE_LIBRTE_I40E_PMD
17402 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17409 printf("invalid port_id %d\n", res->port_id);
17412 printf("function not implemented\n");
17415 printf("programming error: (%s)\n", strerror(-ret));
17419 #ifdef RTE_LIBRTE_I40E_PMD
17420 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17421 if (mapping[i].pctype != 0ULL) {
17424 printf("pctype: ");
17425 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17426 if (mapping[i].pctype & (1ULL << j)) {
17427 printf(first_pctype ?
17428 "%02d" : ",%02d", j);
17432 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17438 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17439 .f = cmd_pctype_mapping_get_parsed,
17441 .help_str = "show port <port_id> pctype mapping",
17443 (void *)&cmd_pctype_mapping_get_show,
17444 (void *)&cmd_pctype_mapping_get_port,
17445 (void *)&cmd_pctype_mapping_get_port_id,
17446 (void *)&cmd_pctype_mapping_get_pctype,
17447 (void *)&cmd_pctype_mapping_get_mapping,
17452 /* port config pctype mapping update */
17454 /* Common result structure for port config pctype mapping update */
17455 struct cmd_pctype_mapping_update_result {
17456 cmdline_fixed_string_t port;
17457 cmdline_fixed_string_t config;
17459 cmdline_fixed_string_t pctype;
17460 cmdline_fixed_string_t mapping;
17461 cmdline_fixed_string_t update;
17462 cmdline_fixed_string_t pctype_list;
17463 uint16_t flow_type;
17466 /* Common CLI fields for pctype mapping update*/
17467 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17468 TOKEN_STRING_INITIALIZER
17469 (struct cmd_pctype_mapping_update_result,
17471 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17472 TOKEN_STRING_INITIALIZER
17473 (struct cmd_pctype_mapping_update_result,
17475 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17476 TOKEN_NUM_INITIALIZER
17477 (struct cmd_pctype_mapping_update_result,
17479 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17480 TOKEN_STRING_INITIALIZER
17481 (struct cmd_pctype_mapping_update_result,
17483 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17484 TOKEN_STRING_INITIALIZER
17485 (struct cmd_pctype_mapping_update_result,
17486 mapping, "mapping");
17487 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17488 TOKEN_STRING_INITIALIZER
17489 (struct cmd_pctype_mapping_update_result,
17491 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17492 TOKEN_STRING_INITIALIZER
17493 (struct cmd_pctype_mapping_update_result,
17494 pctype_list, NULL);
17495 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17496 TOKEN_NUM_INITIALIZER
17497 (struct cmd_pctype_mapping_update_result,
17498 flow_type, UINT16);
17501 cmd_pctype_mapping_update_parsed(
17502 void *parsed_result,
17503 __attribute__((unused)) struct cmdline *cl,
17504 __attribute__((unused)) void *data)
17506 struct cmd_pctype_mapping_update_result *res = parsed_result;
17507 int ret = -ENOTSUP;
17508 #ifdef RTE_LIBRTE_I40E_PMD
17509 struct rte_pmd_i40e_flow_type_mapping mapping;
17511 unsigned int nb_item;
17512 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17515 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17518 #ifdef RTE_LIBRTE_I40E_PMD
17519 nb_item = parse_item_list(res->pctype_list, "pctypes",
17520 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17521 mapping.flow_type = res->flow_type;
17522 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17523 mapping.pctype |= (1ULL << pctype_list[i]);
17524 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17534 printf("invalid pctype or flow type\n");
17537 printf("invalid port_id %d\n", res->port_id);
17540 printf("function not implemented\n");
17543 printf("programming error: (%s)\n", strerror(-ret));
17547 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17548 .f = cmd_pctype_mapping_update_parsed,
17550 .help_str = "port config <port_id> pctype mapping update"
17551 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17553 (void *)&cmd_pctype_mapping_update_port,
17554 (void *)&cmd_pctype_mapping_update_config,
17555 (void *)&cmd_pctype_mapping_update_port_id,
17556 (void *)&cmd_pctype_mapping_update_pctype,
17557 (void *)&cmd_pctype_mapping_update_mapping,
17558 (void *)&cmd_pctype_mapping_update_update,
17559 (void *)&cmd_pctype_mapping_update_pc_type,
17560 (void *)&cmd_pctype_mapping_update_flow_type,
17565 /* ptype mapping get */
17567 /* Common result structure for ptype mapping get */
17568 struct cmd_ptype_mapping_get_result {
17569 cmdline_fixed_string_t ptype;
17570 cmdline_fixed_string_t mapping;
17571 cmdline_fixed_string_t get;
17573 uint8_t valid_only;
17576 /* Common CLI fields for ptype mapping get */
17577 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17578 TOKEN_STRING_INITIALIZER
17579 (struct cmd_ptype_mapping_get_result,
17581 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17582 TOKEN_STRING_INITIALIZER
17583 (struct cmd_ptype_mapping_get_result,
17584 mapping, "mapping");
17585 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17586 TOKEN_STRING_INITIALIZER
17587 (struct cmd_ptype_mapping_get_result,
17589 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17590 TOKEN_NUM_INITIALIZER
17591 (struct cmd_ptype_mapping_get_result,
17593 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17594 TOKEN_NUM_INITIALIZER
17595 (struct cmd_ptype_mapping_get_result,
17596 valid_only, UINT8);
17599 cmd_ptype_mapping_get_parsed(
17600 void *parsed_result,
17601 __attribute__((unused)) struct cmdline *cl,
17602 __attribute__((unused)) void *data)
17604 struct cmd_ptype_mapping_get_result *res = parsed_result;
17605 int ret = -ENOTSUP;
17606 #ifdef RTE_LIBRTE_I40E_PMD
17607 int max_ptype_num = 256;
17608 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17613 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17616 #ifdef RTE_LIBRTE_I40E_PMD
17617 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17628 printf("invalid port_id %d\n", res->port_id);
17631 printf("function not implemented\n");
17634 printf("programming error: (%s)\n", strerror(-ret));
17637 #ifdef RTE_LIBRTE_I40E_PMD
17639 for (i = 0; i < count; i++)
17640 printf("%3d\t0x%08x\n",
17641 mapping[i].hw_ptype, mapping[i].sw_ptype);
17646 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17647 .f = cmd_ptype_mapping_get_parsed,
17649 .help_str = "ptype mapping get <port_id> <valid_only>",
17651 (void *)&cmd_ptype_mapping_get_ptype,
17652 (void *)&cmd_ptype_mapping_get_mapping,
17653 (void *)&cmd_ptype_mapping_get_get,
17654 (void *)&cmd_ptype_mapping_get_port_id,
17655 (void *)&cmd_ptype_mapping_get_valid_only,
17660 /* ptype mapping replace */
17662 /* Common result structure for ptype mapping replace */
17663 struct cmd_ptype_mapping_replace_result {
17664 cmdline_fixed_string_t ptype;
17665 cmdline_fixed_string_t mapping;
17666 cmdline_fixed_string_t replace;
17673 /* Common CLI fields for ptype mapping replace */
17674 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17675 TOKEN_STRING_INITIALIZER
17676 (struct cmd_ptype_mapping_replace_result,
17678 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17679 TOKEN_STRING_INITIALIZER
17680 (struct cmd_ptype_mapping_replace_result,
17681 mapping, "mapping");
17682 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17683 TOKEN_STRING_INITIALIZER
17684 (struct cmd_ptype_mapping_replace_result,
17685 replace, "replace");
17686 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17687 TOKEN_NUM_INITIALIZER
17688 (struct cmd_ptype_mapping_replace_result,
17690 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17691 TOKEN_NUM_INITIALIZER
17692 (struct cmd_ptype_mapping_replace_result,
17694 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17695 TOKEN_NUM_INITIALIZER
17696 (struct cmd_ptype_mapping_replace_result,
17698 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17699 TOKEN_NUM_INITIALIZER
17700 (struct cmd_ptype_mapping_replace_result,
17704 cmd_ptype_mapping_replace_parsed(
17705 void *parsed_result,
17706 __attribute__((unused)) struct cmdline *cl,
17707 __attribute__((unused)) void *data)
17709 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17710 int ret = -ENOTSUP;
17712 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17715 #ifdef RTE_LIBRTE_I40E_PMD
17716 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17726 printf("invalid ptype 0x%8x or 0x%8x\n",
17727 res->target, res->pkt_type);
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_replace = {
17741 .f = cmd_ptype_mapping_replace_parsed,
17744 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17746 (void *)&cmd_ptype_mapping_replace_ptype,
17747 (void *)&cmd_ptype_mapping_replace_mapping,
17748 (void *)&cmd_ptype_mapping_replace_replace,
17749 (void *)&cmd_ptype_mapping_replace_port_id,
17750 (void *)&cmd_ptype_mapping_replace_target,
17751 (void *)&cmd_ptype_mapping_replace_mask,
17752 (void *)&cmd_ptype_mapping_replace_pkt_type,
17757 /* ptype mapping reset */
17759 /* Common result structure for ptype mapping reset */
17760 struct cmd_ptype_mapping_reset_result {
17761 cmdline_fixed_string_t ptype;
17762 cmdline_fixed_string_t mapping;
17763 cmdline_fixed_string_t reset;
17767 /* Common CLI fields for ptype mapping reset*/
17768 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17769 TOKEN_STRING_INITIALIZER
17770 (struct cmd_ptype_mapping_reset_result,
17772 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17773 TOKEN_STRING_INITIALIZER
17774 (struct cmd_ptype_mapping_reset_result,
17775 mapping, "mapping");
17776 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17777 TOKEN_STRING_INITIALIZER
17778 (struct cmd_ptype_mapping_reset_result,
17780 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17781 TOKEN_NUM_INITIALIZER
17782 (struct cmd_ptype_mapping_reset_result,
17786 cmd_ptype_mapping_reset_parsed(
17787 void *parsed_result,
17788 __attribute__((unused)) struct cmdline *cl,
17789 __attribute__((unused)) void *data)
17791 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17792 int ret = -ENOTSUP;
17794 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17797 #ifdef RTE_LIBRTE_I40E_PMD
17798 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17805 printf("invalid port_id %d\n", res->port_id);
17808 printf("function not implemented\n");
17811 printf("programming error: (%s)\n", strerror(-ret));
17815 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17816 .f = cmd_ptype_mapping_reset_parsed,
17818 .help_str = "ptype mapping reset <port_id>",
17820 (void *)&cmd_ptype_mapping_reset_ptype,
17821 (void *)&cmd_ptype_mapping_reset_mapping,
17822 (void *)&cmd_ptype_mapping_reset_reset,
17823 (void *)&cmd_ptype_mapping_reset_port_id,
17828 /* ptype mapping update */
17830 /* Common result structure for ptype mapping update */
17831 struct cmd_ptype_mapping_update_result {
17832 cmdline_fixed_string_t ptype;
17833 cmdline_fixed_string_t mapping;
17834 cmdline_fixed_string_t reset;
17840 /* Common CLI fields for ptype mapping update*/
17841 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17842 TOKEN_STRING_INITIALIZER
17843 (struct cmd_ptype_mapping_update_result,
17845 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17846 TOKEN_STRING_INITIALIZER
17847 (struct cmd_ptype_mapping_update_result,
17848 mapping, "mapping");
17849 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17850 TOKEN_STRING_INITIALIZER
17851 (struct cmd_ptype_mapping_update_result,
17853 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17854 TOKEN_NUM_INITIALIZER
17855 (struct cmd_ptype_mapping_update_result,
17857 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17858 TOKEN_NUM_INITIALIZER
17859 (struct cmd_ptype_mapping_update_result,
17861 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17862 TOKEN_NUM_INITIALIZER
17863 (struct cmd_ptype_mapping_update_result,
17867 cmd_ptype_mapping_update_parsed(
17868 void *parsed_result,
17869 __attribute__((unused)) struct cmdline *cl,
17870 __attribute__((unused)) void *data)
17872 struct cmd_ptype_mapping_update_result *res = parsed_result;
17873 int ret = -ENOTSUP;
17874 #ifdef RTE_LIBRTE_I40E_PMD
17875 struct rte_pmd_i40e_ptype_mapping mapping;
17877 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17880 #ifdef RTE_LIBRTE_I40E_PMD
17881 mapping.hw_ptype = res->hw_ptype;
17882 mapping.sw_ptype = res->sw_ptype;
17883 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17893 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17896 printf("invalid port_id %d\n", res->port_id);
17899 printf("function not implemented\n");
17902 printf("programming error: (%s)\n", strerror(-ret));
17906 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17907 .f = cmd_ptype_mapping_update_parsed,
17909 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17911 (void *)&cmd_ptype_mapping_update_ptype,
17912 (void *)&cmd_ptype_mapping_update_mapping,
17913 (void *)&cmd_ptype_mapping_update_update,
17914 (void *)&cmd_ptype_mapping_update_port_id,
17915 (void *)&cmd_ptype_mapping_update_hw_ptype,
17916 (void *)&cmd_ptype_mapping_update_sw_ptype,
17921 /* Common result structure for file commands */
17922 struct cmd_cmdfile_result {
17923 cmdline_fixed_string_t load;
17924 cmdline_fixed_string_t filename;
17927 /* Common CLI fields for file commands */
17928 cmdline_parse_token_string_t cmd_load_cmdfile =
17929 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17930 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17931 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17934 cmd_load_from_file_parsed(
17935 void *parsed_result,
17936 __attribute__((unused)) struct cmdline *cl,
17937 __attribute__((unused)) void *data)
17939 struct cmd_cmdfile_result *res = parsed_result;
17941 cmdline_read_from_file(res->filename);
17944 cmdline_parse_inst_t cmd_load_from_file = {
17945 .f = cmd_load_from_file_parsed,
17947 .help_str = "load <filename>",
17949 (void *)&cmd_load_cmdfile,
17950 (void *)&cmd_load_cmdfile_filename,
17955 /* Get Rx offloads capabilities */
17956 struct cmd_rx_offload_get_capa_result {
17957 cmdline_fixed_string_t show;
17958 cmdline_fixed_string_t port;
17960 cmdline_fixed_string_t rx_offload;
17961 cmdline_fixed_string_t capabilities;
17964 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17965 TOKEN_STRING_INITIALIZER
17966 (struct cmd_rx_offload_get_capa_result,
17968 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17969 TOKEN_STRING_INITIALIZER
17970 (struct cmd_rx_offload_get_capa_result,
17972 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17973 TOKEN_NUM_INITIALIZER
17974 (struct cmd_rx_offload_get_capa_result,
17976 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17977 TOKEN_STRING_INITIALIZER
17978 (struct cmd_rx_offload_get_capa_result,
17979 rx_offload, "rx_offload");
17980 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17981 TOKEN_STRING_INITIALIZER
17982 (struct cmd_rx_offload_get_capa_result,
17983 capabilities, "capabilities");
17986 print_rx_offloads(uint64_t offloads)
17988 uint64_t single_offload;
17996 begin = __builtin_ctzll(offloads);
17997 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17999 single_offload = 1ULL << begin;
18000 for (bit = begin; bit < end; bit++) {
18001 if (offloads & single_offload)
18003 rte_eth_dev_rx_offload_name(single_offload));
18004 single_offload <<= 1;
18009 cmd_rx_offload_get_capa_parsed(
18010 void *parsed_result,
18011 __attribute__((unused)) struct cmdline *cl,
18012 __attribute__((unused)) void *data)
18014 struct cmd_rx_offload_get_capa_result *res = parsed_result;
18015 struct rte_eth_dev_info dev_info;
18016 portid_t port_id = res->port_id;
18017 uint64_t queue_offloads;
18018 uint64_t port_offloads;
18021 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18025 queue_offloads = dev_info.rx_queue_offload_capa;
18026 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
18028 printf("Rx Offloading Capabilities of port %d :\n", port_id);
18029 printf(" Per Queue :");
18030 print_rx_offloads(queue_offloads);
18033 printf(" Per Port :");
18034 print_rx_offloads(port_offloads);
18038 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
18039 .f = cmd_rx_offload_get_capa_parsed,
18041 .help_str = "show port <port_id> rx_offload capabilities",
18043 (void *)&cmd_rx_offload_get_capa_show,
18044 (void *)&cmd_rx_offload_get_capa_port,
18045 (void *)&cmd_rx_offload_get_capa_port_id,
18046 (void *)&cmd_rx_offload_get_capa_rx_offload,
18047 (void *)&cmd_rx_offload_get_capa_capabilities,
18052 /* Get Rx offloads configuration */
18053 struct cmd_rx_offload_get_configuration_result {
18054 cmdline_fixed_string_t show;
18055 cmdline_fixed_string_t port;
18057 cmdline_fixed_string_t rx_offload;
18058 cmdline_fixed_string_t configuration;
18061 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
18062 TOKEN_STRING_INITIALIZER
18063 (struct cmd_rx_offload_get_configuration_result,
18065 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
18066 TOKEN_STRING_INITIALIZER
18067 (struct cmd_rx_offload_get_configuration_result,
18069 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
18070 TOKEN_NUM_INITIALIZER
18071 (struct cmd_rx_offload_get_configuration_result,
18073 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
18074 TOKEN_STRING_INITIALIZER
18075 (struct cmd_rx_offload_get_configuration_result,
18076 rx_offload, "rx_offload");
18077 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
18078 TOKEN_STRING_INITIALIZER
18079 (struct cmd_rx_offload_get_configuration_result,
18080 configuration, "configuration");
18083 cmd_rx_offload_get_configuration_parsed(
18084 void *parsed_result,
18085 __attribute__((unused)) struct cmdline *cl,
18086 __attribute__((unused)) void *data)
18088 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
18089 struct rte_eth_dev_info dev_info;
18090 portid_t port_id = res->port_id;
18091 struct rte_port *port = &ports[port_id];
18092 uint64_t port_offloads;
18093 uint64_t queue_offloads;
18094 uint16_t nb_rx_queues;
18098 printf("Rx Offloading Configuration of port %d :\n", port_id);
18100 port_offloads = port->dev_conf.rxmode.offloads;
18102 print_rx_offloads(port_offloads);
18105 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18109 nb_rx_queues = dev_info.nb_rx_queues;
18110 for (q = 0; q < nb_rx_queues; q++) {
18111 queue_offloads = port->rx_conf[q].offloads;
18112 printf(" Queue[%2d] :", q);
18113 print_rx_offloads(queue_offloads);
18119 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18120 .f = cmd_rx_offload_get_configuration_parsed,
18122 .help_str = "show port <port_id> rx_offload configuration",
18124 (void *)&cmd_rx_offload_get_configuration_show,
18125 (void *)&cmd_rx_offload_get_configuration_port,
18126 (void *)&cmd_rx_offload_get_configuration_port_id,
18127 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18128 (void *)&cmd_rx_offload_get_configuration_configuration,
18133 /* Enable/Disable a per port offloading */
18134 struct cmd_config_per_port_rx_offload_result {
18135 cmdline_fixed_string_t port;
18136 cmdline_fixed_string_t config;
18138 cmdline_fixed_string_t rx_offload;
18139 cmdline_fixed_string_t offload;
18140 cmdline_fixed_string_t on_off;
18143 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18144 TOKEN_STRING_INITIALIZER
18145 (struct cmd_config_per_port_rx_offload_result,
18147 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18148 TOKEN_STRING_INITIALIZER
18149 (struct cmd_config_per_port_rx_offload_result,
18151 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18152 TOKEN_NUM_INITIALIZER
18153 (struct cmd_config_per_port_rx_offload_result,
18155 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18156 TOKEN_STRING_INITIALIZER
18157 (struct cmd_config_per_port_rx_offload_result,
18158 rx_offload, "rx_offload");
18159 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18160 TOKEN_STRING_INITIALIZER
18161 (struct cmd_config_per_port_rx_offload_result,
18162 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18163 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18164 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18165 "scatter#timestamp#security#keep_crc#rss_hash");
18166 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18167 TOKEN_STRING_INITIALIZER
18168 (struct cmd_config_per_port_rx_offload_result,
18172 search_rx_offload(const char *name)
18174 uint64_t single_offload;
18175 const char *single_name;
18179 single_offload = 1;
18180 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18181 single_name = rte_eth_dev_rx_offload_name(single_offload);
18182 if (!strcasecmp(single_name, name)) {
18186 single_offload <<= 1;
18190 return single_offload;
18196 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18197 __attribute__((unused)) struct cmdline *cl,
18198 __attribute__((unused)) void *data)
18200 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18201 portid_t port_id = res->port_id;
18202 struct rte_eth_dev_info dev_info;
18203 struct rte_port *port = &ports[port_id];
18204 uint64_t single_offload;
18205 uint16_t nb_rx_queues;
18209 if (port->port_status != RTE_PORT_STOPPED) {
18210 printf("Error: Can't config offload when Port %d "
18211 "is not stopped\n", port_id);
18215 single_offload = search_rx_offload(res->offload);
18216 if (single_offload == 0) {
18217 printf("Unknown offload name: %s\n", res->offload);
18221 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18225 nb_rx_queues = dev_info.nb_rx_queues;
18226 if (!strcmp(res->on_off, "on")) {
18227 port->dev_conf.rxmode.offloads |= single_offload;
18228 for (q = 0; q < nb_rx_queues; q++)
18229 port->rx_conf[q].offloads |= single_offload;
18231 port->dev_conf.rxmode.offloads &= ~single_offload;
18232 for (q = 0; q < nb_rx_queues; q++)
18233 port->rx_conf[q].offloads &= ~single_offload;
18236 cmd_reconfig_device_queue(port_id, 1, 1);
18239 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18240 .f = cmd_config_per_port_rx_offload_parsed,
18242 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18243 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18244 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18245 "jumbo_frame|scatter|timestamp|security|keep_crc|rss_hash "
18248 (void *)&cmd_config_per_port_rx_offload_result_port,
18249 (void *)&cmd_config_per_port_rx_offload_result_config,
18250 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18251 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18252 (void *)&cmd_config_per_port_rx_offload_result_offload,
18253 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18258 /* Enable/Disable a per queue offloading */
18259 struct cmd_config_per_queue_rx_offload_result {
18260 cmdline_fixed_string_t port;
18262 cmdline_fixed_string_t rxq;
18264 cmdline_fixed_string_t rx_offload;
18265 cmdline_fixed_string_t offload;
18266 cmdline_fixed_string_t on_off;
18269 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18270 TOKEN_STRING_INITIALIZER
18271 (struct cmd_config_per_queue_rx_offload_result,
18273 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18274 TOKEN_NUM_INITIALIZER
18275 (struct cmd_config_per_queue_rx_offload_result,
18277 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18278 TOKEN_STRING_INITIALIZER
18279 (struct cmd_config_per_queue_rx_offload_result,
18281 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18282 TOKEN_NUM_INITIALIZER
18283 (struct cmd_config_per_queue_rx_offload_result,
18285 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18286 TOKEN_STRING_INITIALIZER
18287 (struct cmd_config_per_queue_rx_offload_result,
18288 rx_offload, "rx_offload");
18289 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18290 TOKEN_STRING_INITIALIZER
18291 (struct cmd_config_per_queue_rx_offload_result,
18292 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18293 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18294 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18295 "scatter#timestamp#security#keep_crc");
18296 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18297 TOKEN_STRING_INITIALIZER
18298 (struct cmd_config_per_queue_rx_offload_result,
18302 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18303 __attribute__((unused)) struct cmdline *cl,
18304 __attribute__((unused)) void *data)
18306 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18307 struct rte_eth_dev_info dev_info;
18308 portid_t port_id = res->port_id;
18309 uint16_t queue_id = res->queue_id;
18310 struct rte_port *port = &ports[port_id];
18311 uint64_t single_offload;
18314 if (port->port_status != RTE_PORT_STOPPED) {
18315 printf("Error: Can't config offload when Port %d "
18316 "is not stopped\n", port_id);
18320 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18324 if (queue_id >= dev_info.nb_rx_queues) {
18325 printf("Error: input queue_id should be 0 ... "
18326 "%d\n", dev_info.nb_rx_queues - 1);
18330 single_offload = search_rx_offload(res->offload);
18331 if (single_offload == 0) {
18332 printf("Unknown offload name: %s\n", res->offload);
18336 if (!strcmp(res->on_off, "on"))
18337 port->rx_conf[queue_id].offloads |= single_offload;
18339 port->rx_conf[queue_id].offloads &= ~single_offload;
18341 cmd_reconfig_device_queue(port_id, 1, 1);
18344 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18345 .f = cmd_config_per_queue_rx_offload_parsed,
18347 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18348 "vlan_strip|ipv4_cksum|"
18349 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18350 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18351 "jumbo_frame|scatter|timestamp|security|keep_crc "
18354 (void *)&cmd_config_per_queue_rx_offload_result_port,
18355 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18356 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18357 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18358 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18359 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18360 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18365 /* Get Tx offloads capabilities */
18366 struct cmd_tx_offload_get_capa_result {
18367 cmdline_fixed_string_t show;
18368 cmdline_fixed_string_t port;
18370 cmdline_fixed_string_t tx_offload;
18371 cmdline_fixed_string_t capabilities;
18374 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18375 TOKEN_STRING_INITIALIZER
18376 (struct cmd_tx_offload_get_capa_result,
18378 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18379 TOKEN_STRING_INITIALIZER
18380 (struct cmd_tx_offload_get_capa_result,
18382 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18383 TOKEN_NUM_INITIALIZER
18384 (struct cmd_tx_offload_get_capa_result,
18386 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18387 TOKEN_STRING_INITIALIZER
18388 (struct cmd_tx_offload_get_capa_result,
18389 tx_offload, "tx_offload");
18390 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18391 TOKEN_STRING_INITIALIZER
18392 (struct cmd_tx_offload_get_capa_result,
18393 capabilities, "capabilities");
18396 print_tx_offloads(uint64_t offloads)
18398 uint64_t single_offload;
18406 begin = __builtin_ctzll(offloads);
18407 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18409 single_offload = 1ULL << begin;
18410 for (bit = begin; bit < end; bit++) {
18411 if (offloads & single_offload)
18413 rte_eth_dev_tx_offload_name(single_offload));
18414 single_offload <<= 1;
18419 cmd_tx_offload_get_capa_parsed(
18420 void *parsed_result,
18421 __attribute__((unused)) struct cmdline *cl,
18422 __attribute__((unused)) void *data)
18424 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18425 struct rte_eth_dev_info dev_info;
18426 portid_t port_id = res->port_id;
18427 uint64_t queue_offloads;
18428 uint64_t port_offloads;
18431 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18435 queue_offloads = dev_info.tx_queue_offload_capa;
18436 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18438 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18439 printf(" Per Queue :");
18440 print_tx_offloads(queue_offloads);
18443 printf(" Per Port :");
18444 print_tx_offloads(port_offloads);
18448 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18449 .f = cmd_tx_offload_get_capa_parsed,
18451 .help_str = "show port <port_id> tx_offload capabilities",
18453 (void *)&cmd_tx_offload_get_capa_show,
18454 (void *)&cmd_tx_offload_get_capa_port,
18455 (void *)&cmd_tx_offload_get_capa_port_id,
18456 (void *)&cmd_tx_offload_get_capa_tx_offload,
18457 (void *)&cmd_tx_offload_get_capa_capabilities,
18462 /* Get Tx offloads configuration */
18463 struct cmd_tx_offload_get_configuration_result {
18464 cmdline_fixed_string_t show;
18465 cmdline_fixed_string_t port;
18467 cmdline_fixed_string_t tx_offload;
18468 cmdline_fixed_string_t configuration;
18471 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18472 TOKEN_STRING_INITIALIZER
18473 (struct cmd_tx_offload_get_configuration_result,
18475 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18476 TOKEN_STRING_INITIALIZER
18477 (struct cmd_tx_offload_get_configuration_result,
18479 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18480 TOKEN_NUM_INITIALIZER
18481 (struct cmd_tx_offload_get_configuration_result,
18483 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18484 TOKEN_STRING_INITIALIZER
18485 (struct cmd_tx_offload_get_configuration_result,
18486 tx_offload, "tx_offload");
18487 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18488 TOKEN_STRING_INITIALIZER
18489 (struct cmd_tx_offload_get_configuration_result,
18490 configuration, "configuration");
18493 cmd_tx_offload_get_configuration_parsed(
18494 void *parsed_result,
18495 __attribute__((unused)) struct cmdline *cl,
18496 __attribute__((unused)) void *data)
18498 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18499 struct rte_eth_dev_info dev_info;
18500 portid_t port_id = res->port_id;
18501 struct rte_port *port = &ports[port_id];
18502 uint64_t port_offloads;
18503 uint64_t queue_offloads;
18504 uint16_t nb_tx_queues;
18508 printf("Tx Offloading Configuration of port %d :\n", port_id);
18510 port_offloads = port->dev_conf.txmode.offloads;
18512 print_tx_offloads(port_offloads);
18515 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18519 nb_tx_queues = dev_info.nb_tx_queues;
18520 for (q = 0; q < nb_tx_queues; q++) {
18521 queue_offloads = port->tx_conf[q].offloads;
18522 printf(" Queue[%2d] :", q);
18523 print_tx_offloads(queue_offloads);
18529 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18530 .f = cmd_tx_offload_get_configuration_parsed,
18532 .help_str = "show port <port_id> tx_offload configuration",
18534 (void *)&cmd_tx_offload_get_configuration_show,
18535 (void *)&cmd_tx_offload_get_configuration_port,
18536 (void *)&cmd_tx_offload_get_configuration_port_id,
18537 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18538 (void *)&cmd_tx_offload_get_configuration_configuration,
18543 /* Enable/Disable a per port offloading */
18544 struct cmd_config_per_port_tx_offload_result {
18545 cmdline_fixed_string_t port;
18546 cmdline_fixed_string_t config;
18548 cmdline_fixed_string_t tx_offload;
18549 cmdline_fixed_string_t offload;
18550 cmdline_fixed_string_t on_off;
18553 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18554 TOKEN_STRING_INITIALIZER
18555 (struct cmd_config_per_port_tx_offload_result,
18557 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18558 TOKEN_STRING_INITIALIZER
18559 (struct cmd_config_per_port_tx_offload_result,
18561 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18562 TOKEN_NUM_INITIALIZER
18563 (struct cmd_config_per_port_tx_offload_result,
18565 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18566 TOKEN_STRING_INITIALIZER
18567 (struct cmd_config_per_port_tx_offload_result,
18568 tx_offload, "tx_offload");
18569 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18570 TOKEN_STRING_INITIALIZER
18571 (struct cmd_config_per_port_tx_offload_result,
18572 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18573 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18574 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18575 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18576 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18578 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18579 TOKEN_STRING_INITIALIZER
18580 (struct cmd_config_per_port_tx_offload_result,
18584 search_tx_offload(const char *name)
18586 uint64_t single_offload;
18587 const char *single_name;
18591 single_offload = 1;
18592 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18593 single_name = rte_eth_dev_tx_offload_name(single_offload);
18594 if (single_name == NULL)
18596 if (!strcasecmp(single_name, name)) {
18599 } else if (!strcasecmp(single_name, "UNKNOWN"))
18601 single_offload <<= 1;
18605 return single_offload;
18611 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18612 __attribute__((unused)) struct cmdline *cl,
18613 __attribute__((unused)) void *data)
18615 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18616 portid_t port_id = res->port_id;
18617 struct rte_eth_dev_info dev_info;
18618 struct rte_port *port = &ports[port_id];
18619 uint64_t single_offload;
18620 uint16_t nb_tx_queues;
18624 if (port->port_status != RTE_PORT_STOPPED) {
18625 printf("Error: Can't config offload when Port %d "
18626 "is not stopped\n", port_id);
18630 single_offload = search_tx_offload(res->offload);
18631 if (single_offload == 0) {
18632 printf("Unknown offload name: %s\n", res->offload);
18636 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18640 nb_tx_queues = dev_info.nb_tx_queues;
18641 if (!strcmp(res->on_off, "on")) {
18642 port->dev_conf.txmode.offloads |= single_offload;
18643 for (q = 0; q < nb_tx_queues; q++)
18644 port->tx_conf[q].offloads |= single_offload;
18646 port->dev_conf.txmode.offloads &= ~single_offload;
18647 for (q = 0; q < nb_tx_queues; q++)
18648 port->tx_conf[q].offloads &= ~single_offload;
18651 cmd_reconfig_device_queue(port_id, 1, 1);
18654 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18655 .f = cmd_config_per_port_tx_offload_parsed,
18657 .help_str = "port config <port_id> tx_offload "
18658 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18659 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18660 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18661 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18662 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18663 "match_metadata on|off",
18665 (void *)&cmd_config_per_port_tx_offload_result_port,
18666 (void *)&cmd_config_per_port_tx_offload_result_config,
18667 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18668 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18669 (void *)&cmd_config_per_port_tx_offload_result_offload,
18670 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18675 /* Enable/Disable a per queue offloading */
18676 struct cmd_config_per_queue_tx_offload_result {
18677 cmdline_fixed_string_t port;
18679 cmdline_fixed_string_t txq;
18681 cmdline_fixed_string_t tx_offload;
18682 cmdline_fixed_string_t offload;
18683 cmdline_fixed_string_t on_off;
18686 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18687 TOKEN_STRING_INITIALIZER
18688 (struct cmd_config_per_queue_tx_offload_result,
18690 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18691 TOKEN_NUM_INITIALIZER
18692 (struct cmd_config_per_queue_tx_offload_result,
18694 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18695 TOKEN_STRING_INITIALIZER
18696 (struct cmd_config_per_queue_tx_offload_result,
18698 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18699 TOKEN_NUM_INITIALIZER
18700 (struct cmd_config_per_queue_tx_offload_result,
18702 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18703 TOKEN_STRING_INITIALIZER
18704 (struct cmd_config_per_queue_tx_offload_result,
18705 tx_offload, "tx_offload");
18706 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18707 TOKEN_STRING_INITIALIZER
18708 (struct cmd_config_per_queue_tx_offload_result,
18709 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18710 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18711 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18712 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18713 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18714 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18715 TOKEN_STRING_INITIALIZER
18716 (struct cmd_config_per_queue_tx_offload_result,
18720 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18721 __attribute__((unused)) struct cmdline *cl,
18722 __attribute__((unused)) void *data)
18724 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18725 struct rte_eth_dev_info dev_info;
18726 portid_t port_id = res->port_id;
18727 uint16_t queue_id = res->queue_id;
18728 struct rte_port *port = &ports[port_id];
18729 uint64_t single_offload;
18732 if (port->port_status != RTE_PORT_STOPPED) {
18733 printf("Error: Can't config offload when Port %d "
18734 "is not stopped\n", port_id);
18738 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18742 if (queue_id >= dev_info.nb_tx_queues) {
18743 printf("Error: input queue_id should be 0 ... "
18744 "%d\n", dev_info.nb_tx_queues - 1);
18748 single_offload = search_tx_offload(res->offload);
18749 if (single_offload == 0) {
18750 printf("Unknown offload name: %s\n", res->offload);
18754 if (!strcmp(res->on_off, "on"))
18755 port->tx_conf[queue_id].offloads |= single_offload;
18757 port->tx_conf[queue_id].offloads &= ~single_offload;
18759 cmd_reconfig_device_queue(port_id, 1, 1);
18762 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18763 .f = cmd_config_per_queue_tx_offload_parsed,
18765 .help_str = "port <port_id> txq <queue_id> tx_offload "
18766 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18767 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18768 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18769 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18770 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18773 (void *)&cmd_config_per_queue_tx_offload_result_port,
18774 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18775 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18776 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18777 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18778 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18779 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18784 /* *** configure tx_metadata for specific port *** */
18785 struct cmd_config_tx_metadata_specific_result {
18786 cmdline_fixed_string_t port;
18787 cmdline_fixed_string_t keyword;
18789 cmdline_fixed_string_t item;
18794 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18795 __attribute__((unused)) struct cmdline *cl,
18796 __attribute__((unused)) void *data)
18798 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18800 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18802 ports[res->port_id].tx_metadata = res->value;
18803 /* Add/remove callback to insert valid metadata in every Tx packet. */
18804 if (ports[res->port_id].tx_metadata)
18805 add_tx_md_callback(res->port_id);
18807 remove_tx_md_callback(res->port_id);
18808 rte_flow_dynf_metadata_register();
18811 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18812 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18814 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18815 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18816 keyword, "config");
18817 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18818 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18820 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18821 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18822 item, "tx_metadata");
18823 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18824 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18827 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18828 .f = cmd_config_tx_metadata_specific_parsed,
18830 .help_str = "port config <port_id> tx_metadata <value>",
18832 (void *)&cmd_config_tx_metadata_specific_port,
18833 (void *)&cmd_config_tx_metadata_specific_keyword,
18834 (void *)&cmd_config_tx_metadata_specific_id,
18835 (void *)&cmd_config_tx_metadata_specific_item,
18836 (void *)&cmd_config_tx_metadata_specific_value,
18841 /* *** display tx_metadata per port configuration *** */
18842 struct cmd_show_tx_metadata_result {
18843 cmdline_fixed_string_t cmd_show;
18844 cmdline_fixed_string_t cmd_port;
18845 cmdline_fixed_string_t cmd_keyword;
18850 cmd_show_tx_metadata_parsed(void *parsed_result,
18851 __attribute__((unused)) struct cmdline *cl,
18852 __attribute__((unused)) void *data)
18854 struct cmd_show_tx_metadata_result *res = parsed_result;
18856 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18857 printf("invalid port id %u\n", res->cmd_pid);
18860 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18861 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18862 rte_be_to_cpu_32(ports[res->cmd_pid].tx_metadata));
18866 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18867 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18869 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18870 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18872 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18873 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18875 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18876 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18877 cmd_keyword, "tx_metadata");
18879 cmdline_parse_inst_t cmd_show_tx_metadata = {
18880 .f = cmd_show_tx_metadata_parsed,
18882 .help_str = "show port <port_id> tx_metadata",
18884 (void *)&cmd_show_tx_metadata_show,
18885 (void *)&cmd_show_tx_metadata_port,
18886 (void *)&cmd_show_tx_metadata_pid,
18887 (void *)&cmd_show_tx_metadata_keyword,
18892 /* show port supported ptypes */
18894 /* Common result structure for show port ptypes */
18895 struct cmd_show_port_supported_ptypes_result {
18896 cmdline_fixed_string_t show;
18897 cmdline_fixed_string_t port;
18899 cmdline_fixed_string_t ptypes;
18902 /* Common CLI fields for show port ptypes */
18903 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
18904 TOKEN_STRING_INITIALIZER
18905 (struct cmd_show_port_supported_ptypes_result,
18907 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
18908 TOKEN_STRING_INITIALIZER
18909 (struct cmd_show_port_supported_ptypes_result,
18911 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
18912 TOKEN_NUM_INITIALIZER
18913 (struct cmd_show_port_supported_ptypes_result,
18915 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
18916 TOKEN_STRING_INITIALIZER
18917 (struct cmd_show_port_supported_ptypes_result,
18921 cmd_show_port_supported_ptypes_parsed(
18922 void *parsed_result,
18923 __attribute__((unused)) struct cmdline *cl,
18924 __attribute__((unused)) void *data)
18926 #define RSVD_PTYPE_MASK 0xf0000000
18927 #define MAX_PTYPES_PER_LAYER 16
18928 #define LTYPE_NAMESIZE 32
18929 #define PTYPE_NAMESIZE 256
18930 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
18931 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
18932 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
18933 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
18934 uint16_t port_id = res->port_id;
18937 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
18941 while (ptype_mask != RSVD_PTYPE_MASK) {
18943 switch (ptype_mask) {
18944 case RTE_PTYPE_L2_MASK:
18945 strlcpy(ltype, "L2", sizeof(ltype));
18947 case RTE_PTYPE_L3_MASK:
18948 strlcpy(ltype, "L3", sizeof(ltype));
18950 case RTE_PTYPE_L4_MASK:
18951 strlcpy(ltype, "L4", sizeof(ltype));
18953 case RTE_PTYPE_TUNNEL_MASK:
18954 strlcpy(ltype, "Tunnel", sizeof(ltype));
18956 case RTE_PTYPE_INNER_L2_MASK:
18957 strlcpy(ltype, "Inner L2", sizeof(ltype));
18959 case RTE_PTYPE_INNER_L3_MASK:
18960 strlcpy(ltype, "Inner L3", sizeof(ltype));
18962 case RTE_PTYPE_INNER_L4_MASK:
18963 strlcpy(ltype, "Inner L4", sizeof(ltype));
18969 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
18970 ptype_mask, ptypes,
18971 MAX_PTYPES_PER_LAYER);
18974 printf("Supported %s ptypes:\n", ltype);
18976 printf("%s ptypes unsupported\n", ltype);
18978 for (i = 0; i < ret; ++i) {
18979 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
18980 printf("%s\n", buf);
18987 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
18988 .f = cmd_show_port_supported_ptypes_parsed,
18990 .help_str = "show port <port_id> ptypes",
18992 (void *)&cmd_show_port_supported_ptypes_show,
18993 (void *)&cmd_show_port_supported_ptypes_port,
18994 (void *)&cmd_show_port_supported_ptypes_port_id,
18995 (void *)&cmd_show_port_supported_ptypes_ptypes,
19000 /* *** display rx/tx descriptor status *** */
19001 struct cmd_show_rx_tx_desc_status_result {
19002 cmdline_fixed_string_t cmd_show;
19003 cmdline_fixed_string_t cmd_port;
19004 cmdline_fixed_string_t cmd_keyword;
19005 cmdline_fixed_string_t cmd_desc;
19006 cmdline_fixed_string_t cmd_status;
19013 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
19014 __attribute__((unused)) struct cmdline *cl,
19015 __attribute__((unused)) void *data)
19017 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
19020 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
19021 printf("invalid port id %u\n", res->cmd_pid);
19025 if (!strcmp(res->cmd_keyword, "rxq")) {
19026 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
19029 printf("Invalid queueid = %d\n", res->cmd_qid);
19032 if (rc == RTE_ETH_RX_DESC_AVAIL)
19033 printf("Desc status = AVAILABLE\n");
19034 else if (rc == RTE_ETH_RX_DESC_DONE)
19035 printf("Desc status = DONE\n");
19037 printf("Desc status = UNAVAILABLE\n");
19038 } else if (!strcmp(res->cmd_keyword, "txq")) {
19039 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
19042 printf("Invalid queueid = %d\n", res->cmd_qid);
19045 if (rc == RTE_ETH_TX_DESC_FULL)
19046 printf("Desc status = FULL\n");
19047 else if (rc == RTE_ETH_TX_DESC_DONE)
19048 printf("Desc status = DONE\n");
19050 printf("Desc status = UNAVAILABLE\n");
19054 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
19055 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19057 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
19058 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19060 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
19061 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19063 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
19064 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19065 cmd_keyword, "rxq#txq");
19066 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
19067 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19069 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
19070 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19072 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
19073 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19075 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
19076 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
19077 cmd_status, "status");
19078 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
19079 .f = cmd_show_rx_tx_desc_status_parsed,
19081 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
19084 (void *)&cmd_show_rx_tx_desc_status_show,
19085 (void *)&cmd_show_rx_tx_desc_status_port,
19086 (void *)&cmd_show_rx_tx_desc_status_pid,
19087 (void *)&cmd_show_rx_tx_desc_status_keyword,
19088 (void *)&cmd_show_rx_tx_desc_status_qid,
19089 (void *)&cmd_show_rx_tx_desc_status_desc,
19090 (void *)&cmd_show_rx_tx_desc_status_did,
19091 (void *)&cmd_show_rx_tx_desc_status_status,
19096 /* Common result structure for set port ptypes */
19097 struct cmd_set_port_ptypes_result {
19098 cmdline_fixed_string_t set;
19099 cmdline_fixed_string_t port;
19101 cmdline_fixed_string_t ptype_mask;
19105 /* Common CLI fields for set port ptypes */
19106 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
19107 TOKEN_STRING_INITIALIZER
19108 (struct cmd_set_port_ptypes_result,
19110 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
19111 TOKEN_STRING_INITIALIZER
19112 (struct cmd_set_port_ptypes_result,
19114 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
19115 TOKEN_NUM_INITIALIZER
19116 (struct cmd_set_port_ptypes_result,
19118 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
19119 TOKEN_STRING_INITIALIZER
19120 (struct cmd_set_port_ptypes_result,
19121 ptype_mask, "ptype_mask");
19122 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
19123 TOKEN_NUM_INITIALIZER
19124 (struct cmd_set_port_ptypes_result,
19128 cmd_set_port_ptypes_parsed(
19129 void *parsed_result,
19130 __attribute__((unused)) struct cmdline *cl,
19131 __attribute__((unused)) void *data)
19133 struct cmd_set_port_ptypes_result *res = parsed_result;
19134 #define PTYPE_NAMESIZE 256
19135 char ptype_name[PTYPE_NAMESIZE];
19136 uint16_t port_id = res->port_id;
19137 uint32_t ptype_mask = res->mask;
19140 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
19143 printf("Port %d doesn't support any ptypes.\n", port_id);
19147 uint32_t ptypes[ret];
19149 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
19151 printf("Unable to set requested ptypes for Port %d\n", port_id);
19155 printf("Successfully set following ptypes for Port %d\n", port_id);
19156 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
19157 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
19158 printf("%s\n", ptype_name);
19161 clear_ptypes = false;
19164 cmdline_parse_inst_t cmd_set_port_ptypes = {
19165 .f = cmd_set_port_ptypes_parsed,
19167 .help_str = "set port <port_id> ptype_mask <mask>",
19169 (void *)&cmd_set_port_ptypes_set,
19170 (void *)&cmd_set_port_ptypes_port,
19171 (void *)&cmd_set_port_ptypes_port_id,
19172 (void *)&cmd_set_port_ptypes_mask_str,
19173 (void *)&cmd_set_port_ptypes_mask_u32,
19178 /* ******************************************************************************** */
19180 /* list of instructions */
19181 cmdline_parse_ctx_t main_ctx[] = {
19182 (cmdline_parse_inst_t *)&cmd_help_brief,
19183 (cmdline_parse_inst_t *)&cmd_help_long,
19184 (cmdline_parse_inst_t *)&cmd_quit,
19185 (cmdline_parse_inst_t *)&cmd_load_from_file,
19186 (cmdline_parse_inst_t *)&cmd_showport,
19187 (cmdline_parse_inst_t *)&cmd_showqueue,
19188 (cmdline_parse_inst_t *)&cmd_showportall,
19189 (cmdline_parse_inst_t *)&cmd_showdevice,
19190 (cmdline_parse_inst_t *)&cmd_showcfg,
19191 (cmdline_parse_inst_t *)&cmd_showfwdall,
19192 (cmdline_parse_inst_t *)&cmd_start,
19193 (cmdline_parse_inst_t *)&cmd_start_tx_first,
19194 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
19195 (cmdline_parse_inst_t *)&cmd_set_link_up,
19196 (cmdline_parse_inst_t *)&cmd_set_link_down,
19197 (cmdline_parse_inst_t *)&cmd_reset,
19198 (cmdline_parse_inst_t *)&cmd_set_numbers,
19199 (cmdline_parse_inst_t *)&cmd_set_log,
19200 (cmdline_parse_inst_t *)&cmd_set_txpkts,
19201 (cmdline_parse_inst_t *)&cmd_set_txsplit,
19202 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
19203 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
19204 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
19205 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
19206 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
19207 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
19208 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
19209 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
19210 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
19211 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
19212 (cmdline_parse_inst_t *)&cmd_set_link_check,
19213 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
19214 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
19215 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
19216 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
19217 #ifdef RTE_LIBRTE_PMD_BOND
19218 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
19219 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
19220 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
19221 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
19222 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
19223 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
19224 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
19225 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
19226 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
19227 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
19228 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
19230 (cmdline_parse_inst_t *)&cmd_vlan_offload,
19231 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
19232 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
19233 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
19234 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
19235 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
19236 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
19237 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
19238 (cmdline_parse_inst_t *)&cmd_csum_set,
19239 (cmdline_parse_inst_t *)&cmd_csum_show,
19240 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
19241 (cmdline_parse_inst_t *)&cmd_tso_set,
19242 (cmdline_parse_inst_t *)&cmd_tso_show,
19243 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
19244 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
19245 (cmdline_parse_inst_t *)&cmd_gro_enable,
19246 (cmdline_parse_inst_t *)&cmd_gro_flush,
19247 (cmdline_parse_inst_t *)&cmd_gro_show,
19248 (cmdline_parse_inst_t *)&cmd_gso_enable,
19249 (cmdline_parse_inst_t *)&cmd_gso_size,
19250 (cmdline_parse_inst_t *)&cmd_gso_show,
19251 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
19252 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
19253 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
19254 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
19255 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
19256 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
19257 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
19258 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
19259 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
19260 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
19261 (cmdline_parse_inst_t *)&cmd_config_dcb,
19262 (cmdline_parse_inst_t *)&cmd_read_reg,
19263 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
19264 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
19265 (cmdline_parse_inst_t *)&cmd_write_reg,
19266 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
19267 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
19268 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
19269 (cmdline_parse_inst_t *)&cmd_stop,
19270 (cmdline_parse_inst_t *)&cmd_mac_addr,
19271 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
19272 (cmdline_parse_inst_t *)&cmd_set_qmap,
19273 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
19274 (cmdline_parse_inst_t *)&cmd_operate_port,
19275 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
19276 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
19277 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
19278 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
19279 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
19280 (cmdline_parse_inst_t *)&cmd_config_speed_all,
19281 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
19282 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
19283 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
19284 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
19285 (cmdline_parse_inst_t *)&cmd_config_mtu,
19286 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
19287 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
19288 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
19289 (cmdline_parse_inst_t *)&cmd_config_rss,
19290 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
19291 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
19292 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
19293 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
19294 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
19295 (cmdline_parse_inst_t *)&cmd_showport_reta,
19296 (cmdline_parse_inst_t *)&cmd_config_burst,
19297 (cmdline_parse_inst_t *)&cmd_config_thresh,
19298 (cmdline_parse_inst_t *)&cmd_config_threshold,
19299 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
19300 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
19301 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
19302 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
19303 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
19304 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
19305 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
19306 (cmdline_parse_inst_t *)&cmd_global_config,
19307 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
19308 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
19309 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
19310 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
19311 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
19312 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
19313 (cmdline_parse_inst_t *)&cmd_dump,
19314 (cmdline_parse_inst_t *)&cmd_dump_one,
19315 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
19316 (cmdline_parse_inst_t *)&cmd_syn_filter,
19317 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
19318 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
19319 (cmdline_parse_inst_t *)&cmd_flex_filter,
19320 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
19321 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
19322 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
19323 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
19324 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
19325 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
19326 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
19327 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
19328 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
19329 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
19330 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
19331 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
19332 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
19333 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
19334 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
19335 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
19336 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
19337 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
19338 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
19339 (cmdline_parse_inst_t *)&cmd_flow,
19340 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
19341 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
19342 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
19343 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
19344 (cmdline_parse_inst_t *)&cmd_create_port_meter,
19345 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
19346 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
19347 (cmdline_parse_inst_t *)&cmd_del_port_meter,
19348 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
19349 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
19350 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
19351 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
19352 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
19353 (cmdline_parse_inst_t *)&cmd_mcast_addr,
19354 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
19355 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
19356 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
19357 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
19358 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
19359 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
19360 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
19361 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
19362 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
19363 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
19364 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
19365 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
19366 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
19367 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
19368 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
19369 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
19370 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
19371 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
19372 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
19373 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
19374 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
19375 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
19376 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
19377 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19378 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19379 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19380 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19381 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19382 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19383 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19384 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19385 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19386 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19387 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19388 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19389 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
19390 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
19392 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19393 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19394 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19395 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19396 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19397 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19398 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19399 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19400 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19401 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19402 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19403 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19404 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19405 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19406 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19407 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19408 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19409 (cmdline_parse_inst_t *)&cmd_ddp_add,
19410 (cmdline_parse_inst_t *)&cmd_ddp_del,
19411 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19412 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19413 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19414 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19415 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19416 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19417 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
19418 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
19419 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19420 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19421 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19422 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19424 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19425 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19426 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19427 (cmdline_parse_inst_t *)&cmd_queue_region,
19428 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19429 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19430 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19431 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19432 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19433 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19434 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19435 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19436 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19437 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19438 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19439 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19440 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19441 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19442 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19443 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19444 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19445 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19446 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19447 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19448 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19449 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19450 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19451 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19452 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19453 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19454 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19455 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19456 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19457 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19458 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19459 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19460 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19461 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19462 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19463 #ifdef RTE_LIBRTE_BPF
19464 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19465 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19467 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19468 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19469 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
19470 (cmdline_parse_inst_t *)&cmd_set_raw,
19471 (cmdline_parse_inst_t *)&cmd_show_set_raw,
19472 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
19476 /* read cmdline commands from file */
19478 cmdline_read_from_file(const char *filename)
19480 struct cmdline *cl;
19482 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19484 printf("Failed to create file based cmdline context: %s\n",
19489 cmdline_interact(cl);
19494 printf("Read CLI commands from %s\n", filename);
19497 /* prompt function, called from main on MASTER lcore */
19501 /* initialize non-constant commands */
19502 cmd_set_fwd_mode_init();
19503 cmd_set_fwd_retry_mode_init();
19505 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19506 if (testpmd_cl == NULL)
19508 cmdline_interact(testpmd_cl);
19509 cmdline_stdin_exit(testpmd_cl);
19515 if (testpmd_cl != NULL)
19516 cmdline_quit(testpmd_cl);
19520 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19522 if (id == (portid_t)RTE_PORT_ALL) {
19525 RTE_ETH_FOREACH_DEV(pid) {
19526 /* check if need_reconfig has been set to 1 */
19527 if (ports[pid].need_reconfig == 0)
19528 ports[pid].need_reconfig = dev;
19529 /* check if need_reconfig_queues has been set to 1 */
19530 if (ports[pid].need_reconfig_queues == 0)
19531 ports[pid].need_reconfig_queues = queue;
19533 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19534 /* check if need_reconfig has been set to 1 */
19535 if (ports[id].need_reconfig == 0)
19536 ports[id].need_reconfig = dev;
19537 /* check if need_reconfig_queues has been set to 1 */
19538 if (ports[id].need_reconfig_queues == 0)
19539 ports[id].need_reconfig_queues = queue;