1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
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 device info (<identifier>|all)"
238 " Show general information about devices probed.\n\n"
242 if (show_all || !strcmp(res->section, "config")) {
248 "Configuration changes only become active when"
249 " forwarding is started/restarted.\n\n"
252 " Reset forwarding to the default configuration.\n\n"
254 "set verbose (level)\n"
255 " Set the debug verbosity level X.\n\n"
257 "set log global|(type) (level)\n"
258 " Set the log level.\n\n"
261 " Set number of ports.\n\n"
264 " Set number of cores.\n\n"
266 "set coremask (mask)\n"
267 " Set the forwarding cores hexadecimal mask.\n\n"
269 "set portmask (mask)\n"
270 " Set the forwarding ports hexadecimal mask.\n\n"
273 " Set number of packets per burst.\n\n"
275 "set burst tx delay (microseconds) retry (num)\n"
276 " Set the transmit delay time and number of retries,"
277 " effective when retry is enabled.\n\n"
279 "set txpkts (x[,y]*)\n"
280 " Set the length of each segment of TXONLY"
281 " and optionally CSUM packets.\n\n"
283 "set txsplit (off|on|rand)\n"
284 " Set the split policy for the TX packets."
285 " Right now only applicable for CSUM and TXONLY"
288 "set corelist (x[,y]*)\n"
289 " Set the list of forwarding cores.\n\n"
291 "set portlist (x[,y]*)\n"
292 " Set the list of forwarding ports.\n\n"
294 "set port setup on (iterator|event)\n"
295 " Select how attached port is retrieved for setup.\n\n"
297 "set tx loopback (port_id) (on|off)\n"
298 " Enable or disable tx loopback.\n\n"
300 "set all queues drop (port_id) (on|off)\n"
301 " Set drop enable bit for all queues.\n\n"
303 "set vf split drop (port_id) (vf_id) (on|off)\n"
304 " Set split drop enable bit for a VF from the PF.\n\n"
306 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
307 " Set MAC antispoof for a VF from the PF.\n\n"
309 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
310 " Enable MACsec offload.\n\n"
312 "set macsec offload (port_id) off\n"
313 " Disable MACsec offload.\n\n"
315 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
316 " Configure MACsec secure connection (SC).\n\n"
318 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
319 " Configure MACsec secure association (SA).\n\n"
321 "set vf broadcast (port_id) (vf_id) (on|off)\n"
322 " Set VF broadcast for a VF from the PF.\n\n"
324 "vlan set strip (on|off) (port_id)\n"
325 " Set the VLAN strip on a port.\n\n"
327 "vlan set stripq (on|off) (port_id,queue_id)\n"
328 " Set the VLAN strip for a queue on a port.\n\n"
330 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
331 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
333 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
334 " Set VLAN insert for a VF from the PF.\n\n"
336 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
337 " Set VLAN antispoof for a VF from the PF.\n\n"
339 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
340 " Set VLAN tag for a VF from the PF.\n\n"
342 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
343 " Set a VF's max bandwidth(Mbps).\n\n"
345 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
346 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
348 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
349 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
351 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
352 " Set some TCs' strict link priority mode on a physical port.\n\n"
354 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
355 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
357 "vlan set filter (on|off) (port_id)\n"
358 " Set the VLAN filter on a port.\n\n"
360 "vlan set qinq (on|off) (port_id)\n"
361 " Set the VLAN QinQ (extended queue in queue)"
364 "vlan set (inner|outer) tpid (value) (port_id)\n"
365 " Set the VLAN TPID for Packet Filtering on"
368 "rx_vlan add (vlan_id|all) (port_id)\n"
369 " Add a vlan_id, or all identifiers, to the set"
370 " of VLAN identifiers filtered by port_id.\n\n"
372 "rx_vlan rm (vlan_id|all) (port_id)\n"
373 " Remove a vlan_id, or all identifiers, from the set"
374 " of VLAN identifiers filtered by port_id.\n\n"
376 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
377 " Add a vlan_id, to the set of VLAN identifiers"
378 "filtered for VF(s) from port_id.\n\n"
380 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
381 " Remove a vlan_id, to the set of VLAN identifiers"
382 "filtered for VF(s) from port_id.\n\n"
384 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
385 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
386 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
387 " add a tunnel filter of a port.\n\n"
389 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
390 "(inner_vlan) (vxlan|nvgre|ipingre|vxlan-gpe) (imac-ivlan|imac-ivlan-tenid|"
391 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
392 " remove a tunnel filter of a port.\n\n"
394 "rx_vxlan_port add (udp_port) (port_id)\n"
395 " Add an UDP port for VXLAN packet filter on a port\n\n"
397 "rx_vxlan_port rm (udp_port) (port_id)\n"
398 " Remove an UDP port for VXLAN packet filter on a port\n\n"
400 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
401 " Set hardware insertion of VLAN IDs (single or double VLAN "
402 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
404 "tx_vlan set pvid port_id vlan_id (on|off)\n"
405 " Set port based TX VLAN insertion.\n\n"
407 "tx_vlan reset (port_id)\n"
408 " Disable hardware insertion of a VLAN header in"
409 " packets sent on a port.\n\n"
411 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
412 " Select hardware or software calculation of the"
413 " checksum when transmitting a packet using the"
414 " csum forward engine.\n"
415 " ip|udp|tcp|sctp always concern the inner layer.\n"
416 " outer-ip concerns the outer IP layer in"
417 " outer-udp concerns the outer UDP layer in"
418 " case the packet is recognized as a tunnel packet by"
419 " the forward engine (vxlan, gre and ipip are supported)\n"
420 " Please check the NIC datasheet for HW limits.\n\n"
422 "csum parse-tunnel (on|off) (tx_port_id)\n"
423 " If disabled, treat tunnel packets as non-tunneled"
424 " packets (treat inner headers as payload). The port\n"
425 " argument is the port used for TX in csum forward"
428 "csum show (port_id)\n"
429 " Display tx checksum offload configuration\n\n"
431 "tso set (segsize) (portid)\n"
432 " Enable TCP Segmentation Offload in csum forward"
434 " Please check the NIC datasheet for HW limits.\n\n"
437 " Display the status of TCP Segmentation Offload.\n\n"
439 "set port (port_id) gro on|off\n"
440 " Enable or disable Generic Receive Offload in"
441 " csum forwarding engine.\n\n"
443 "show port (port_id) gro\n"
444 " Display GRO configuration.\n\n"
446 "set gro flush (cycles)\n"
447 " Set the cycle to flush GROed packets from"
448 " reassembly tables.\n\n"
450 "set port (port_id) gso (on|off)"
451 " Enable or disable Generic Segmentation Offload in"
452 " csum forwarding engine.\n\n"
454 "set gso segsz (length)\n"
455 " Set max packet length for output GSO segments,"
456 " including packet header and payload.\n\n"
458 "show port (port_id) gso\n"
459 " Show GSO configuration.\n\n"
462 " Set packet forwarding mode.\n\n"
464 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
465 " Add a MAC address on port_id.\n\n"
467 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
468 " Remove a MAC address from port_id.\n\n"
470 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
471 " Set the default MAC address for port_id.\n\n"
473 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
474 " Add a MAC address for a VF on the port.\n\n"
476 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
477 " Set the MAC address for a VF from the PF.\n\n"
479 "set eth-peer (port_id) (peer_addr)\n"
480 " set the peer address for certain port.\n\n"
482 "set port (port_id) uta (mac_address|all) (on|off)\n"
483 " Add/Remove a or all unicast hash filter(s)"
486 "set promisc (port_id|all) (on|off)\n"
487 " Set the promiscuous mode on port_id, or all.\n\n"
489 "set allmulti (port_id|all) (on|off)\n"
490 " Set the allmulti mode on port_id, or all.\n\n"
492 "set vf promisc (port_id) (vf_id) (on|off)\n"
493 " Set unicast promiscuous mode for a VF from the PF.\n\n"
495 "set vf allmulti (port_id) (vf_id) (on|off)\n"
496 " Set multicast promiscuous mode for a VF from the PF.\n\n"
498 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
499 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
500 " (on|off) autoneg (on|off) (port_id)\n"
501 "set flow_ctrl rx (on|off) (portid)\n"
502 "set flow_ctrl tx (on|off) (portid)\n"
503 "set flow_ctrl high_water (high_water) (portid)\n"
504 "set flow_ctrl low_water (low_water) (portid)\n"
505 "set flow_ctrl pause_time (pause_time) (portid)\n"
506 "set flow_ctrl send_xon (send_xon) (portid)\n"
507 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
508 "set flow_ctrl autoneg (on|off) (port_id)\n"
509 " Set the link flow control parameter on a port.\n\n"
511 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
512 " (low_water) (pause_time) (priority) (port_id)\n"
513 " Set the priority flow control parameter on a"
516 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
517 " Set statistics mapping (qmapping 0..15) for RX/TX"
519 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
520 " on port 0 to mapping 5.\n\n"
522 "set xstats-hide-zero on|off\n"
523 " Set the option to hide the zero values"
524 " for xstats display.\n"
526 "set port (port_id) vf (vf_id) rx|tx on|off\n"
527 " Enable/Disable a VF receive/tranmit from a port\n\n"
529 "set port (port_id) vf (vf_id) (mac_addr)"
530 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
531 " Add/Remove unicast or multicast MAC addr filter"
534 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
536 " AUPE:accepts untagged VLAN;"
537 "ROPE:accept unicast hash\n\n"
538 " BAM:accepts broadcast packets;"
539 "MPE:accepts all multicast packets\n\n"
540 " Enable/Disable a VF receive mode of a port\n\n"
542 "set port (port_id) queue (queue_id) rate (rate_num)\n"
543 " Set rate limit for a queue of a port\n\n"
545 "set port (port_id) vf (vf_id) rate (rate_num) "
546 "queue_mask (queue_mask_value)\n"
547 " Set rate limit for queues in VF of a port\n\n"
549 "set port (port_id) mirror-rule (rule_id)"
550 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
551 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
552 " Set pool or vlan type mirror rule on a port.\n"
553 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
554 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
557 "set port (port_id) mirror-rule (rule_id)"
558 " (uplink-mirror|downlink-mirror) dst-pool"
559 " (pool_id) (on|off)\n"
560 " Set uplink or downlink type mirror rule on a port.\n"
561 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
562 " 0 on' enable mirror income traffic to pool 0.\n\n"
564 "reset port (port_id) mirror-rule (rule_id)\n"
565 " Reset a mirror rule.\n\n"
567 "set flush_rx (on|off)\n"
568 " Flush (default) or don't flush RX streams before"
569 " forwarding. Mainly used with PCAP drivers.\n\n"
571 "set bypass mode (normal|bypass|isolate) (port_id)\n"
572 " Set the bypass mode for the lowest port on bypass enabled"
575 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
576 "mode (normal|bypass|isolate) (port_id)\n"
577 " Set the event required to initiate specified bypass mode for"
578 " the lowest port on a bypass enabled NIC where:\n"
579 " timeout = enable bypass after watchdog timeout.\n"
580 " os_on = enable bypass when OS/board is powered on.\n"
581 " os_off = enable bypass when OS/board is powered off.\n"
582 " power_on = enable bypass when power supply is turned on.\n"
583 " power_off = enable bypass when power supply is turned off."
586 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
587 " Set the bypass watchdog timeout to 'n' seconds"
588 " where 0 = instant.\n\n"
590 "show bypass config (port_id)\n"
591 " Show the bypass configuration for a bypass enabled NIC"
592 " using the lowest port on the NIC.\n\n"
594 #ifdef RTE_LIBRTE_PMD_BOND
595 "create bonded device (mode) (socket)\n"
596 " Create a new bonded device with specific bonding mode and socket.\n\n"
598 "add bonding slave (slave_id) (port_id)\n"
599 " Add a slave device to a bonded device.\n\n"
601 "remove bonding slave (slave_id) (port_id)\n"
602 " Remove a slave device from a bonded device.\n\n"
604 "set bonding mode (value) (port_id)\n"
605 " Set the bonding mode on a bonded device.\n\n"
607 "set bonding primary (slave_id) (port_id)\n"
608 " Set the primary slave for a bonded device.\n\n"
610 "show bonding config (port_id)\n"
611 " Show the bonding config for port_id.\n\n"
613 "set bonding mac_addr (port_id) (address)\n"
614 " Set the MAC address of a bonded device.\n\n"
616 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
617 " Set Aggregation mode for IEEE802.3AD (mode 4)"
619 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
620 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
622 "set bonding mon_period (port_id) (value)\n"
623 " Set the bonding link status monitoring polling period in ms.\n\n"
625 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
626 " Enable/disable dedicated queues for LACP control traffic.\n\n"
629 "set link-up port (port_id)\n"
630 " Set link up for a port.\n\n"
632 "set link-down port (port_id)\n"
633 " Set link down for a port.\n\n"
635 "E-tag set insertion on port-tag-id (value)"
636 " port (port_id) vf (vf_id)\n"
637 " Enable E-tag insertion for a VF on a port\n\n"
639 "E-tag set insertion off port (port_id) vf (vf_id)\n"
640 " Disable E-tag insertion for a VF on a port\n\n"
642 "E-tag set stripping (on|off) port (port_id)\n"
643 " Enable/disable E-tag stripping on a port\n\n"
645 "E-tag set forwarding (on|off) port (port_id)\n"
646 " Enable/disable E-tag based forwarding"
649 "E-tag set filter add e-tag-id (value) dst-pool"
650 " (pool_id) port (port_id)\n"
651 " Add an E-tag forwarding filter on a port\n\n"
653 "E-tag set filter del e-tag-id (value) port (port_id)\n"
654 " Delete an E-tag forwarding filter on a port\n\n"
656 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
657 " Load a profile package on a port\n\n"
659 "ddp del (port_id) (backup_profile_path)\n"
660 " Delete a profile package from a port\n\n"
662 "ptype mapping get (port_id) (valid_only)\n"
663 " Get ptype mapping on a port\n\n"
665 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
666 " Replace target with the pkt_type in ptype mapping\n\n"
668 "ptype mapping reset (port_id)\n"
669 " Reset ptype mapping on a port\n\n"
671 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
672 " Update a ptype mapping item on a port\n\n"
674 "set port (port_id) queue-region region_id (value) "
675 "queue_start_index (value) queue_num (value)\n"
676 " Set a queue region on a port\n\n"
678 "set port (port_id) queue-region region_id (value) "
680 " Set a flowtype region index on a port\n\n"
682 "set port (port_id) queue-region UP (value) region_id (value)\n"
683 " Set the mapping of User Priority to "
684 "queue region on a port\n\n"
686 "set port (port_id) queue-region flush (on|off)\n"
687 " flush all queue region related configuration\n\n"
689 "show port meter cap (port_id)\n"
690 " Show port meter capability information\n\n"
692 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
693 " meter profile add - srtcm rfc 2697\n\n"
695 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
696 " meter profile add - trtcm rfc 2698\n\n"
698 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
699 " meter profile add - trtcm rfc 4115\n\n"
701 "del port meter profile (port_id) (profile_id)\n"
702 " meter profile delete\n\n"
704 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
705 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
706 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
707 "(dscp_tbl_entry63)]\n"
710 "enable port meter (port_id) (mtr_id)\n"
713 "disable port meter (port_id) (mtr_id)\n"
716 "del port meter (port_id) (mtr_id)\n"
719 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
720 " meter update meter profile\n\n"
722 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
723 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
724 " update meter dscp table entries\n\n"
726 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
727 "(action0) [(action1) (action2)]\n"
728 " meter update policer action\n\n"
730 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
731 " meter update stats\n\n"
733 "show port (port_id) queue-region\n"
734 " show all queue region related configuration info\n\n"
736 , list_pkt_forwarding_modes()
740 if (show_all || !strcmp(res->section, "ports")) {
746 "----------------\n\n"
748 "port start (port_id|all)\n"
749 " Start all ports or port_id.\n\n"
751 "port stop (port_id|all)\n"
752 " Stop all ports or port_id.\n\n"
754 "port close (port_id|all)\n"
755 " Close all ports or port_id.\n\n"
757 "port reset (port_id|all)\n"
758 " Reset all ports or port_id.\n\n"
760 "port attach (ident)\n"
761 " Attach physical or virtual dev by pci address or virtual device name\n\n"
763 "port detach (port_id)\n"
764 " Detach physical or virtual dev by port_id\n\n"
766 "port config (port_id|all)"
767 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
768 " duplex (half|full|auto)\n"
769 " Set speed and duplex for all ports or port_id\n\n"
771 "port config (port_id|all) loopback (mode)\n"
772 " Set loopback mode for all ports or port_id\n\n"
774 "port config all (rxq|txq|rxd|txd) (value)\n"
775 " Set number for rxq/txq/rxd/txd.\n\n"
777 "port config all max-pkt-len (value)\n"
778 " Set the max packet length.\n\n"
780 "port config all drop-en (on|off)\n"
781 " Enable or disable packet drop on all RX queues of all ports when no "
782 "receive buffers available.\n\n"
784 "port config all rss (all|default|ip|tcp|udp|sctp|"
785 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n"
786 " Set the RSS mode.\n\n"
788 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
789 " Set the RSS redirection table.\n\n"
791 "port config (port_id) dcb vt (on|off) (traffic_class)"
793 " Set the DCB mode.\n\n"
795 "port config all burst (value)\n"
796 " Set the number of packets per burst.\n\n"
798 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
800 " Set the ring prefetch/host/writeback threshold"
801 " for tx/rx queue.\n\n"
803 "port config all (txfreet|txrst|rxfreet) (value)\n"
804 " Set free threshold for rx/tx, or set"
805 " tx rs bit threshold.\n\n"
806 "port config mtu X value\n"
807 " Set the MTU of port X to a given value\n\n"
809 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
810 " Set a rx/tx queue's ring size configuration, the new"
811 " value will take effect after command that (re-)start the port"
812 " or command that setup the specific queue\n\n"
814 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
815 " Start/stop a rx/tx queue of port X. Only take effect"
816 " when port X is started\n\n"
818 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
819 " Switch on/off a deferred start of port X rx/tx queue. Only"
820 " take effect when port X is stopped.\n\n"
822 "port (port_id) (rxq|txq) (queue_id) setup\n"
823 " Setup a rx/tx queue of port X.\n\n"
825 "port config (port_id|all) l2-tunnel E-tag ether-type"
827 " Set the value of E-tag ether-type.\n\n"
829 "port config (port_id|all) l2-tunnel E-tag"
830 " (enable|disable)\n"
831 " Enable/disable the E-tag support.\n\n"
833 "port config (port_id) pctype mapping reset\n"
834 " Reset flow type to pctype mapping on a port\n\n"
836 "port config (port_id) pctype mapping update"
837 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
838 " Update a flow type to pctype mapping item on a port\n\n"
840 "port config (port_id) pctype (pctype_id) hash_inset|"
841 "fdir_inset|fdir_flx_inset get|set|clear field\n"
843 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
845 "port config (port_id) pctype (pctype_id) hash_inset|"
846 "fdir_inset|fdir_flx_inset clear all"
847 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
849 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
850 " Add/remove UDP tunnel port for tunneling offload\n\n"
852 "port config <port_id> rx_offload vlan_strip|"
853 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
854 "outer_ipv4_cksum|macsec_strip|header_split|"
855 "vlan_filter|vlan_extend|jumbo_frame|crc_strip|"
856 "scatter|timestamp|security|keep_crc on|off\n"
857 " Enable or disable a per port Rx offloading"
858 " on all Rx queues of a port\n\n"
860 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
861 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
862 "outer_ipv4_cksum|macsec_strip|header_split|"
863 "vlan_filter|vlan_extend|jumbo_frame|crc_strip|"
864 "scatter|timestamp|security|keep_crc on|off\n"
865 " Enable or disable a per queue Rx offloading"
866 " only on a specific Rx queue\n\n"
868 "port config (port_id) tx_offload vlan_insert|"
869 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
870 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
871 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
872 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
873 "security|match_metadata on|off\n"
874 " Enable or disable a per port Tx offloading"
875 " on all Tx queues of a port\n\n"
877 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
878 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
879 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
880 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
881 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
883 " Enable or disable a per queue Tx offloading"
884 " only on a specific Tx queue\n\n"
886 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
887 " Load an eBPF program as a callback"
888 " for particular RX/TX queue\n\n"
890 "bpf-unload rx|tx (port) (queue)\n"
891 " Unload previously loaded eBPF program"
892 " for particular RX/TX queue\n\n"
894 "port config (port_id) tx_metadata (value)\n"
895 " Set Tx metadata value per port. Testpmd will add this value"
896 " to any Tx packet sent from this port\n\n"
900 if (show_all || !strcmp(res->section, "registers")) {
908 "read reg (port_id) (address)\n"
909 " Display value of a port register.\n\n"
911 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
912 " Display a port register bit field.\n\n"
914 "read regbit (port_id) (address) (bit_x)\n"
915 " Display a single port register bit.\n\n"
917 "write reg (port_id) (address) (value)\n"
918 " Set value of a port register.\n\n"
920 "write regfield (port_id) (address) (bit_x) (bit_y)"
922 " Set bit field of a port register.\n\n"
924 "write regbit (port_id) (address) (bit_x) (value)\n"
925 " Set single bit value of a port register.\n\n"
928 if (show_all || !strcmp(res->section, "filters")) {
936 "ethertype_filter (port_id) (add|del)"
937 " (mac_addr|mac_ignr) (mac_address) ethertype"
938 " (ether_type) (drop|fwd) queue (queue_id)\n"
939 " Add/Del an ethertype filter.\n\n"
941 "2tuple_filter (port_id) (add|del)"
942 " dst_port (dst_port_value) protocol (protocol_value)"
943 " mask (mask_value) tcp_flags (tcp_flags_value)"
944 " priority (prio_value) queue (queue_id)\n"
945 " Add/Del a 2tuple filter.\n\n"
947 "5tuple_filter (port_id) (add|del)"
948 " dst_ip (dst_address) src_ip (src_address)"
949 " dst_port (dst_port_value) src_port (src_port_value)"
950 " protocol (protocol_value)"
951 " mask (mask_value) tcp_flags (tcp_flags_value)"
952 " priority (prio_value) queue (queue_id)\n"
953 " Add/Del a 5tuple filter.\n\n"
955 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
956 " Add/Del syn filter.\n\n"
958 "flex_filter (port_id) (add|del) len (len_value)"
959 " bytes (bytes_value) mask (mask_value)"
960 " priority (prio_value) queue (queue_id)\n"
961 " Add/Del a flex filter.\n\n"
963 "flow_director_filter (port_id) mode IP (add|del|update)"
964 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
965 " src (src_ip_address) dst (dst_ip_address)"
966 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
967 " vlan (vlan_value) flexbytes (flexbytes_value)"
968 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
969 " fd_id (fd_id_value)\n"
970 " Add/Del an IP type flow director filter.\n\n"
972 "flow_director_filter (port_id) mode IP (add|del|update)"
973 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
974 " src (src_ip_address) (src_port)"
975 " dst (dst_ip_address) (dst_port)"
976 " tos (tos_value) ttl (ttl_value)"
977 " vlan (vlan_value) flexbytes (flexbytes_value)"
978 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
979 " fd_id (fd_id_value)\n"
980 " Add/Del an UDP/TCP type flow director filter.\n\n"
982 "flow_director_filter (port_id) mode IP (add|del|update)"
983 " flow (ipv4-sctp|ipv6-sctp)"
984 " src (src_ip_address) (src_port)"
985 " dst (dst_ip_address) (dst_port)"
986 " tag (verification_tag) "
987 " tos (tos_value) ttl (ttl_value)"
989 " flexbytes (flexbytes_value) (drop|fwd)"
990 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
991 " Add/Del a SCTP type flow director filter.\n\n"
993 "flow_director_filter (port_id) mode IP (add|del|update)"
994 " flow l2_payload ether (ethertype)"
995 " flexbytes (flexbytes_value) (drop|fwd)"
996 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
997 " Add/Del a l2 payload type flow director filter.\n\n"
999 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1000 " mac (mac_address) vlan (vlan_value)"
1001 " flexbytes (flexbytes_value) (drop|fwd)"
1002 " queue (queue_id) fd_id (fd_id_value)\n"
1003 " Add/Del a MAC-VLAN flow director filter.\n\n"
1005 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1006 " mac (mac_address) vlan (vlan_value)"
1007 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1008 " flexbytes (flexbytes_value) (drop|fwd)"
1009 " queue (queue_id) fd_id (fd_id_value)\n"
1010 " Add/Del a Tunnel flow director filter.\n\n"
1012 "flow_director_filter (port_id) mode raw (add|del|update)"
1013 " flow (flow_id) (drop|fwd) queue (queue_id)"
1014 " fd_id (fd_id_value) packet (packet file name)\n"
1015 " Add/Del a raw type flow director filter.\n\n"
1017 "flush_flow_director (port_id)\n"
1018 " Flush all flow director entries of a device.\n\n"
1020 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1021 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1022 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1023 " Set flow director IP mask.\n\n"
1025 "flow_director_mask (port_id) mode MAC-VLAN"
1026 " vlan (vlan_value)\n"
1027 " Set flow director MAC-VLAN mask.\n\n"
1029 "flow_director_mask (port_id) mode Tunnel"
1030 " vlan (vlan_value) mac (mac_value)"
1031 " tunnel-type (tunnel_type_value)"
1032 " tunnel-id (tunnel_id_value)\n"
1033 " Set flow director Tunnel mask.\n\n"
1035 "flow_director_flex_mask (port_id)"
1036 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1037 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1039 " Configure mask of flex payload.\n\n"
1041 "flow_director_flex_payload (port_id)"
1042 " (raw|l2|l3|l4) (config)\n"
1043 " Configure flex payload selection.\n\n"
1045 "get_sym_hash_ena_per_port (port_id)\n"
1046 " get symmetric hash enable configuration per port.\n\n"
1048 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1049 " set symmetric hash enable configuration per port"
1050 " to enable or disable.\n\n"
1052 "get_hash_global_config (port_id)\n"
1053 " Get the global configurations of hash filters.\n\n"
1055 "set_hash_global_config (port_id) (toeplitz|simple_xor|symmetric_toeplitz|default)"
1056 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1057 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1058 " (enable|disable)\n"
1059 " Set the global configurations of hash filters.\n\n"
1061 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1062 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1063 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1064 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1065 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1066 "ipv6-next-header|udp-src-port|udp-dst-port|"
1067 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1068 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1069 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1070 "fld-8th|none) (select|add)\n"
1071 " Set the input set for hash.\n\n"
1073 "set_fdir_input_set (port_id) "
1074 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1075 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1076 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1077 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1078 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1079 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1080 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1082 " Set the input set for FDir.\n\n"
1084 "flow validate {port_id}"
1085 " [group {group_id}] [priority {level}]"
1086 " [ingress] [egress]"
1087 " pattern {item} [/ {item} [...]] / end"
1088 " actions {action} [/ {action} [...]] / end\n"
1089 " Check whether a flow rule can be created.\n\n"
1091 "flow create {port_id}"
1092 " [group {group_id}] [priority {level}]"
1093 " [ingress] [egress]"
1094 " pattern {item} [/ {item} [...]] / end"
1095 " actions {action} [/ {action} [...]] / end\n"
1096 " Create a flow rule.\n\n"
1098 "flow destroy {port_id} rule {rule_id} [...]\n"
1099 " Destroy specific flow rules.\n\n"
1101 "flow flush {port_id}\n"
1102 " Destroy all flow rules.\n\n"
1104 "flow query {port_id} {rule_id} {action}\n"
1105 " Query an existing flow rule.\n\n"
1107 "flow list {port_id} [group {group_id}] [...]\n"
1108 " List existing flow rules sorted by priority,"
1109 " filtered by group identifiers.\n\n"
1111 "flow isolate {port_id} {boolean}\n"
1112 " Restrict ingress traffic to the defined"
1115 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1116 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1117 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1118 " Configure the VXLAN encapsulation for flows.\n\n"
1120 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1121 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1122 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1123 " eth-dst (eth-dst)\n"
1124 " Configure the VXLAN encapsulation for flows.\n\n"
1126 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1127 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1128 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1129 " eth-dst (eth-dst)\n"
1130 " Configure the VXLAN encapsulation for flows.\n\n"
1132 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1133 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1135 " Configure the NVGRE encapsulation for flows.\n\n"
1137 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1138 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1139 " eth-src (eth-src) eth-dst (eth-dst)\n"
1140 " Configure the NVGRE encapsulation for flows.\n\n"
1142 "set raw_encap {flow items}\n"
1143 " Configure the encapsulation with raw data.\n\n"
1145 "set raw_decap {flow items}\n"
1146 " Configure the decapsulation with raw data.\n\n"
1151 if (show_all || !strcmp(res->section, "traffic_management")) {
1155 "Traffic Management:\n"
1157 "show port tm cap (port_id)\n"
1158 " Display the port TM capability.\n\n"
1160 "show port tm level cap (port_id) (level_id)\n"
1161 " Display the port TM hierarchical level capability.\n\n"
1163 "show port tm node cap (port_id) (node_id)\n"
1164 " Display the port TM node capability.\n\n"
1166 "show port tm node type (port_id) (node_id)\n"
1167 " Display the port TM node type.\n\n"
1169 "show port tm node stats (port_id) (node_id) (clear)\n"
1170 " Display the port TM node stats.\n\n"
1172 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
1173 "set port tm hierarchy default (port_id)\n"
1174 " Set default traffic Management hierarchy on a port\n\n"
1177 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1178 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1179 " (packet_length_adjust)\n"
1180 " Add port tm node private shaper profile.\n\n"
1182 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1183 " Delete port tm node private shaper profile.\n\n"
1185 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1186 " (shaper_profile_id)\n"
1187 " Add/update port tm node shared shaper.\n\n"
1189 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1190 " Delete port tm node shared shaper.\n\n"
1192 "set port tm node shaper profile (port_id) (node_id)"
1193 " (shaper_profile_id)\n"
1194 " Set port tm node shaper profile.\n\n"
1196 "add port tm node wred profile (port_id) (wred_profile_id)"
1197 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1198 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1199 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1200 " Add port tm node wred profile.\n\n"
1202 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1203 " Delete port tm node wred profile.\n\n"
1205 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1206 " (priority) (weight) (level_id) (shaper_profile_id)"
1207 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1208 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1209 " Add port tm nonleaf node.\n\n"
1211 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1212 " (priority) (weight) (level_id) (shaper_profile_id)"
1213 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1214 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1215 " Add port tm leaf node.\n\n"
1217 "del port tm node (port_id) (node_id)\n"
1218 " Delete port tm node.\n\n"
1220 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1221 " (priority) (weight)\n"
1222 " Set port tm node parent.\n\n"
1224 "suspend port tm node (port_id) (node_id)"
1225 " Suspend tm node.\n\n"
1227 "resume port tm node (port_id) (node_id)"
1228 " Resume tm node.\n\n"
1230 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1231 " Commit tm hierarchy.\n\n"
1233 "set port tm mark ip_ecn (port) (green) (yellow)"
1235 " Enables/Disables the traffic management marking"
1236 " for IP ECN (Explicit Congestion Notification)"
1237 " packets on a given port\n\n"
1239 "set port tm mark ip_dscp (port) (green) (yellow)"
1241 " Enables/Disables the traffic management marking"
1242 " on the port for IP dscp packets\n\n"
1244 "set port tm mark vlan_dei (port) (green) (yellow)"
1246 " Enables/Disables the traffic management marking"
1247 " on the port for VLAN packets with DEI enabled\n\n"
1251 if (show_all || !strcmp(res->section, "devices")) {
1255 "Device Operations:\n"
1257 "device detach (identifier)\n"
1258 " Detach device by identifier.\n\n"
1264 cmdline_parse_token_string_t cmd_help_long_help =
1265 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1267 cmdline_parse_token_string_t cmd_help_long_section =
1268 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1269 "all#control#display#config#"
1270 "ports#registers#filters#traffic_management#devices");
1272 cmdline_parse_inst_t cmd_help_long = {
1273 .f = cmd_help_long_parsed,
1275 .help_str = "help all|control|display|config|ports|register|"
1276 "filters|traffic_management|devices: "
1279 (void *)&cmd_help_long_help,
1280 (void *)&cmd_help_long_section,
1286 /* *** start/stop/close all ports *** */
1287 struct cmd_operate_port_result {
1288 cmdline_fixed_string_t keyword;
1289 cmdline_fixed_string_t name;
1290 cmdline_fixed_string_t value;
1293 static void cmd_operate_port_parsed(void *parsed_result,
1294 __attribute__((unused)) struct cmdline *cl,
1295 __attribute__((unused)) void *data)
1297 struct cmd_operate_port_result *res = parsed_result;
1299 if (!strcmp(res->name, "start"))
1300 start_port(RTE_PORT_ALL);
1301 else if (!strcmp(res->name, "stop"))
1302 stop_port(RTE_PORT_ALL);
1303 else if (!strcmp(res->name, "close"))
1304 close_port(RTE_PORT_ALL);
1305 else if (!strcmp(res->name, "reset"))
1306 reset_port(RTE_PORT_ALL);
1308 printf("Unknown parameter\n");
1311 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1312 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1314 cmdline_parse_token_string_t cmd_operate_port_all_port =
1315 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1316 "start#stop#close#reset");
1317 cmdline_parse_token_string_t cmd_operate_port_all_all =
1318 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1320 cmdline_parse_inst_t cmd_operate_port = {
1321 .f = cmd_operate_port_parsed,
1323 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1325 (void *)&cmd_operate_port_all_cmd,
1326 (void *)&cmd_operate_port_all_port,
1327 (void *)&cmd_operate_port_all_all,
1332 /* *** start/stop/close specific port *** */
1333 struct cmd_operate_specific_port_result {
1334 cmdline_fixed_string_t keyword;
1335 cmdline_fixed_string_t name;
1339 static void cmd_operate_specific_port_parsed(void *parsed_result,
1340 __attribute__((unused)) struct cmdline *cl,
1341 __attribute__((unused)) void *data)
1343 struct cmd_operate_specific_port_result *res = parsed_result;
1345 if (!strcmp(res->name, "start"))
1346 start_port(res->value);
1347 else if (!strcmp(res->name, "stop"))
1348 stop_port(res->value);
1349 else if (!strcmp(res->name, "close"))
1350 close_port(res->value);
1351 else if (!strcmp(res->name, "reset"))
1352 reset_port(res->value);
1354 printf("Unknown parameter\n");
1357 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1358 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1360 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1361 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1362 name, "start#stop#close#reset");
1363 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1364 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1367 cmdline_parse_inst_t cmd_operate_specific_port = {
1368 .f = cmd_operate_specific_port_parsed,
1370 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1372 (void *)&cmd_operate_specific_port_cmd,
1373 (void *)&cmd_operate_specific_port_port,
1374 (void *)&cmd_operate_specific_port_id,
1379 /* *** enable port setup (after attach) via iterator or event *** */
1380 struct cmd_set_port_setup_on_result {
1381 cmdline_fixed_string_t set;
1382 cmdline_fixed_string_t port;
1383 cmdline_fixed_string_t setup;
1384 cmdline_fixed_string_t on;
1385 cmdline_fixed_string_t mode;
1388 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1389 __attribute__((unused)) struct cmdline *cl,
1390 __attribute__((unused)) void *data)
1392 struct cmd_set_port_setup_on_result *res = parsed_result;
1394 if (strcmp(res->mode, "event") == 0)
1395 setup_on_probe_event = true;
1396 else if (strcmp(res->mode, "iterator") == 0)
1397 setup_on_probe_event = false;
1399 printf("Unknown mode\n");
1402 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1403 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1405 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1406 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1408 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1409 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1411 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1412 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1414 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1415 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1416 mode, "iterator#event");
1418 cmdline_parse_inst_t cmd_set_port_setup_on = {
1419 .f = cmd_set_port_setup_on_parsed,
1421 .help_str = "set port setup on iterator|event",
1423 (void *)&cmd_set_port_setup_on_set,
1424 (void *)&cmd_set_port_setup_on_port,
1425 (void *)&cmd_set_port_setup_on_setup,
1426 (void *)&cmd_set_port_setup_on_on,
1427 (void *)&cmd_set_port_setup_on_mode,
1432 /* *** attach a specified port *** */
1433 struct cmd_operate_attach_port_result {
1434 cmdline_fixed_string_t port;
1435 cmdline_fixed_string_t keyword;
1436 cmdline_fixed_string_t identifier;
1439 static void cmd_operate_attach_port_parsed(void *parsed_result,
1440 __attribute__((unused)) struct cmdline *cl,
1441 __attribute__((unused)) void *data)
1443 struct cmd_operate_attach_port_result *res = parsed_result;
1445 if (!strcmp(res->keyword, "attach"))
1446 attach_port(res->identifier);
1448 printf("Unknown parameter\n");
1451 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1452 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1454 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1455 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1457 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1458 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1461 cmdline_parse_inst_t cmd_operate_attach_port = {
1462 .f = cmd_operate_attach_port_parsed,
1464 .help_str = "port attach <identifier>: "
1465 "(identifier: pci address or virtual dev name)",
1467 (void *)&cmd_operate_attach_port_port,
1468 (void *)&cmd_operate_attach_port_keyword,
1469 (void *)&cmd_operate_attach_port_identifier,
1474 /* *** detach a specified port *** */
1475 struct cmd_operate_detach_port_result {
1476 cmdline_fixed_string_t port;
1477 cmdline_fixed_string_t keyword;
1481 static void cmd_operate_detach_port_parsed(void *parsed_result,
1482 __attribute__((unused)) struct cmdline *cl,
1483 __attribute__((unused)) void *data)
1485 struct cmd_operate_detach_port_result *res = parsed_result;
1487 if (!strcmp(res->keyword, "detach"))
1488 detach_port_device(res->port_id);
1490 printf("Unknown parameter\n");
1493 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1494 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1496 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1497 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1499 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1500 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1503 cmdline_parse_inst_t cmd_operate_detach_port = {
1504 .f = cmd_operate_detach_port_parsed,
1506 .help_str = "port detach <port_id>",
1508 (void *)&cmd_operate_detach_port_port,
1509 (void *)&cmd_operate_detach_port_keyword,
1510 (void *)&cmd_operate_detach_port_port_id,
1515 /* *** detach device by identifier *** */
1516 struct cmd_operate_detach_device_result {
1517 cmdline_fixed_string_t device;
1518 cmdline_fixed_string_t keyword;
1519 cmdline_fixed_string_t identifier;
1522 static void cmd_operate_detach_device_parsed(void *parsed_result,
1523 __attribute__((unused)) struct cmdline *cl,
1524 __attribute__((unused)) void *data)
1526 struct cmd_operate_detach_device_result *res = parsed_result;
1528 if (!strcmp(res->keyword, "detach"))
1529 detach_device(res->identifier);
1531 printf("Unknown parameter\n");
1534 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1535 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1537 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1538 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1540 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1541 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1544 cmdline_parse_inst_t cmd_operate_detach_device = {
1545 .f = cmd_operate_detach_device_parsed,
1547 .help_str = "device detach <identifier>:"
1548 "(identifier: pci address or virtual dev name)",
1550 (void *)&cmd_operate_detach_device_device,
1551 (void *)&cmd_operate_detach_device_keyword,
1552 (void *)&cmd_operate_detach_device_identifier,
1556 /* *** configure speed for all ports *** */
1557 struct cmd_config_speed_all {
1558 cmdline_fixed_string_t port;
1559 cmdline_fixed_string_t keyword;
1560 cmdline_fixed_string_t all;
1561 cmdline_fixed_string_t item1;
1562 cmdline_fixed_string_t item2;
1563 cmdline_fixed_string_t value1;
1564 cmdline_fixed_string_t value2;
1568 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1573 if (!strcmp(duplexstr, "half")) {
1574 duplex = ETH_LINK_HALF_DUPLEX;
1575 } else if (!strcmp(duplexstr, "full")) {
1576 duplex = ETH_LINK_FULL_DUPLEX;
1577 } else if (!strcmp(duplexstr, "auto")) {
1578 duplex = ETH_LINK_FULL_DUPLEX;
1580 printf("Unknown duplex parameter\n");
1584 if (!strcmp(speedstr, "10")) {
1585 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1586 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1587 } else if (!strcmp(speedstr, "100")) {
1588 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1589 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1591 if (duplex != ETH_LINK_FULL_DUPLEX) {
1592 printf("Invalid speed/duplex parameters\n");
1595 if (!strcmp(speedstr, "1000")) {
1596 *speed = ETH_LINK_SPEED_1G;
1597 } else if (!strcmp(speedstr, "10000")) {
1598 *speed = ETH_LINK_SPEED_10G;
1599 } else if (!strcmp(speedstr, "25000")) {
1600 *speed = ETH_LINK_SPEED_25G;
1601 } else if (!strcmp(speedstr, "40000")) {
1602 *speed = ETH_LINK_SPEED_40G;
1603 } else if (!strcmp(speedstr, "50000")) {
1604 *speed = ETH_LINK_SPEED_50G;
1605 } else if (!strcmp(speedstr, "100000")) {
1606 *speed = ETH_LINK_SPEED_100G;
1607 } else if (!strcmp(speedstr, "auto")) {
1608 *speed = ETH_LINK_SPEED_AUTONEG;
1610 printf("Unknown speed parameter\n");
1619 cmd_config_speed_all_parsed(void *parsed_result,
1620 __attribute__((unused)) struct cmdline *cl,
1621 __attribute__((unused)) void *data)
1623 struct cmd_config_speed_all *res = parsed_result;
1624 uint32_t link_speed;
1627 if (!all_ports_stopped()) {
1628 printf("Please stop all ports first\n");
1632 if (parse_and_check_speed_duplex(res->value1, res->value2,
1636 RTE_ETH_FOREACH_DEV(pid) {
1637 ports[pid].dev_conf.link_speeds = link_speed;
1640 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1643 cmdline_parse_token_string_t cmd_config_speed_all_port =
1644 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1645 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1646 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1648 cmdline_parse_token_string_t cmd_config_speed_all_all =
1649 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1650 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1651 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1652 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1653 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1654 "10#100#1000#10000#25000#40000#50000#100000#auto");
1655 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1656 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1657 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1658 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1661 cmdline_parse_inst_t cmd_config_speed_all = {
1662 .f = cmd_config_speed_all_parsed,
1664 .help_str = "port config all speed "
1665 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1668 (void *)&cmd_config_speed_all_port,
1669 (void *)&cmd_config_speed_all_keyword,
1670 (void *)&cmd_config_speed_all_all,
1671 (void *)&cmd_config_speed_all_item1,
1672 (void *)&cmd_config_speed_all_value1,
1673 (void *)&cmd_config_speed_all_item2,
1674 (void *)&cmd_config_speed_all_value2,
1679 /* *** configure speed for specific port *** */
1680 struct cmd_config_speed_specific {
1681 cmdline_fixed_string_t port;
1682 cmdline_fixed_string_t keyword;
1684 cmdline_fixed_string_t item1;
1685 cmdline_fixed_string_t item2;
1686 cmdline_fixed_string_t value1;
1687 cmdline_fixed_string_t value2;
1691 cmd_config_speed_specific_parsed(void *parsed_result,
1692 __attribute__((unused)) struct cmdline *cl,
1693 __attribute__((unused)) void *data)
1695 struct cmd_config_speed_specific *res = parsed_result;
1696 uint32_t link_speed;
1698 if (!all_ports_stopped()) {
1699 printf("Please stop all ports first\n");
1703 if (port_id_is_invalid(res->id, ENABLED_WARN))
1706 if (parse_and_check_speed_duplex(res->value1, res->value2,
1710 ports[res->id].dev_conf.link_speeds = link_speed;
1712 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1716 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1717 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1719 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1720 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1722 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1723 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1724 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1725 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1727 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1728 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1729 "10#100#1000#10000#25000#40000#50000#100000#auto");
1730 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1731 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1733 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1734 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1737 cmdline_parse_inst_t cmd_config_speed_specific = {
1738 .f = cmd_config_speed_specific_parsed,
1740 .help_str = "port config <port_id> speed "
1741 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1744 (void *)&cmd_config_speed_specific_port,
1745 (void *)&cmd_config_speed_specific_keyword,
1746 (void *)&cmd_config_speed_specific_id,
1747 (void *)&cmd_config_speed_specific_item1,
1748 (void *)&cmd_config_speed_specific_value1,
1749 (void *)&cmd_config_speed_specific_item2,
1750 (void *)&cmd_config_speed_specific_value2,
1755 /* *** configure loopback for all ports *** */
1756 struct cmd_config_loopback_all {
1757 cmdline_fixed_string_t port;
1758 cmdline_fixed_string_t keyword;
1759 cmdline_fixed_string_t all;
1760 cmdline_fixed_string_t item;
1765 cmd_config_loopback_all_parsed(void *parsed_result,
1766 __attribute__((unused)) struct cmdline *cl,
1767 __attribute__((unused)) void *data)
1769 struct cmd_config_loopback_all *res = parsed_result;
1772 if (!all_ports_stopped()) {
1773 printf("Please stop all ports first\n");
1777 RTE_ETH_FOREACH_DEV(pid) {
1778 ports[pid].dev_conf.lpbk_mode = res->mode;
1781 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1784 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1785 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1786 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1787 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1789 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1790 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1791 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1792 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1794 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1795 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1797 cmdline_parse_inst_t cmd_config_loopback_all = {
1798 .f = cmd_config_loopback_all_parsed,
1800 .help_str = "port config all loopback <mode>",
1802 (void *)&cmd_config_loopback_all_port,
1803 (void *)&cmd_config_loopback_all_keyword,
1804 (void *)&cmd_config_loopback_all_all,
1805 (void *)&cmd_config_loopback_all_item,
1806 (void *)&cmd_config_loopback_all_mode,
1811 /* *** configure loopback for specific port *** */
1812 struct cmd_config_loopback_specific {
1813 cmdline_fixed_string_t port;
1814 cmdline_fixed_string_t keyword;
1816 cmdline_fixed_string_t item;
1821 cmd_config_loopback_specific_parsed(void *parsed_result,
1822 __attribute__((unused)) struct cmdline *cl,
1823 __attribute__((unused)) void *data)
1825 struct cmd_config_loopback_specific *res = parsed_result;
1827 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1830 if (!port_is_stopped(res->port_id)) {
1831 printf("Please stop port %u first\n", res->port_id);
1835 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1837 cmd_reconfig_device_queue(res->port_id, 1, 1);
1841 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1842 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1844 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1845 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1847 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1848 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1850 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1851 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1853 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1854 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1857 cmdline_parse_inst_t cmd_config_loopback_specific = {
1858 .f = cmd_config_loopback_specific_parsed,
1860 .help_str = "port config <port_id> loopback <mode>",
1862 (void *)&cmd_config_loopback_specific_port,
1863 (void *)&cmd_config_loopback_specific_keyword,
1864 (void *)&cmd_config_loopback_specific_id,
1865 (void *)&cmd_config_loopback_specific_item,
1866 (void *)&cmd_config_loopback_specific_mode,
1871 /* *** configure txq/rxq, txd/rxd *** */
1872 struct cmd_config_rx_tx {
1873 cmdline_fixed_string_t port;
1874 cmdline_fixed_string_t keyword;
1875 cmdline_fixed_string_t all;
1876 cmdline_fixed_string_t name;
1881 cmd_config_rx_tx_parsed(void *parsed_result,
1882 __attribute__((unused)) struct cmdline *cl,
1883 __attribute__((unused)) void *data)
1885 struct cmd_config_rx_tx *res = parsed_result;
1887 if (!all_ports_stopped()) {
1888 printf("Please stop all ports first\n");
1891 if (!strcmp(res->name, "rxq")) {
1892 if (!res->value && !nb_txq) {
1893 printf("Warning: Either rx or tx queues should be non zero\n");
1896 if (check_nb_rxq(res->value) != 0)
1898 nb_rxq = res->value;
1900 else if (!strcmp(res->name, "txq")) {
1901 if (!res->value && !nb_rxq) {
1902 printf("Warning: Either rx or tx queues should be non zero\n");
1905 if (check_nb_txq(res->value) != 0)
1907 nb_txq = res->value;
1909 else if (!strcmp(res->name, "rxd")) {
1910 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1911 printf("rxd %d invalid - must be > 0 && <= %d\n",
1912 res->value, RTE_TEST_RX_DESC_MAX);
1915 nb_rxd = res->value;
1916 } else if (!strcmp(res->name, "txd")) {
1917 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1918 printf("txd %d invalid - must be > 0 && <= %d\n",
1919 res->value, RTE_TEST_TX_DESC_MAX);
1922 nb_txd = res->value;
1924 printf("Unknown parameter\n");
1932 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1935 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1936 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1937 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1938 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1939 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1940 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1941 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1942 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1944 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1945 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1947 cmdline_parse_inst_t cmd_config_rx_tx = {
1948 .f = cmd_config_rx_tx_parsed,
1950 .help_str = "port config all rxq|txq|rxd|txd <value>",
1952 (void *)&cmd_config_rx_tx_port,
1953 (void *)&cmd_config_rx_tx_keyword,
1954 (void *)&cmd_config_rx_tx_all,
1955 (void *)&cmd_config_rx_tx_name,
1956 (void *)&cmd_config_rx_tx_value,
1961 /* *** config max packet length *** */
1962 struct cmd_config_max_pkt_len_result {
1963 cmdline_fixed_string_t port;
1964 cmdline_fixed_string_t keyword;
1965 cmdline_fixed_string_t all;
1966 cmdline_fixed_string_t name;
1971 cmd_config_max_pkt_len_parsed(void *parsed_result,
1972 __attribute__((unused)) struct cmdline *cl,
1973 __attribute__((unused)) void *data)
1975 struct cmd_config_max_pkt_len_result *res = parsed_result;
1978 if (!all_ports_stopped()) {
1979 printf("Please stop all ports first\n");
1983 RTE_ETH_FOREACH_DEV(pid) {
1984 struct rte_port *port = &ports[pid];
1985 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1987 if (!strcmp(res->name, "max-pkt-len")) {
1988 if (res->value < RTE_ETHER_MIN_LEN) {
1989 printf("max-pkt-len can not be less than %d\n",
1993 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1996 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1997 if (res->value > RTE_ETHER_MAX_LEN)
1998 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
2000 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
2001 port->dev_conf.rxmode.offloads = rx_offloads;
2003 printf("Unknown parameter\n");
2010 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2013 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2014 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2016 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2017 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2019 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2020 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2022 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2023 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2025 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2026 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2029 cmdline_parse_inst_t cmd_config_max_pkt_len = {
2030 .f = cmd_config_max_pkt_len_parsed,
2032 .help_str = "port config all max-pkt-len <value>",
2034 (void *)&cmd_config_max_pkt_len_port,
2035 (void *)&cmd_config_max_pkt_len_keyword,
2036 (void *)&cmd_config_max_pkt_len_all,
2037 (void *)&cmd_config_max_pkt_len_name,
2038 (void *)&cmd_config_max_pkt_len_value,
2043 /* *** configure port MTU *** */
2044 struct cmd_config_mtu_result {
2045 cmdline_fixed_string_t port;
2046 cmdline_fixed_string_t keyword;
2047 cmdline_fixed_string_t mtu;
2053 cmd_config_mtu_parsed(void *parsed_result,
2054 __attribute__((unused)) struct cmdline *cl,
2055 __attribute__((unused)) void *data)
2057 struct cmd_config_mtu_result *res = parsed_result;
2059 if (res->value < RTE_ETHER_MIN_LEN) {
2060 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2063 port_mtu_set(res->port_id, res->value);
2066 cmdline_parse_token_string_t cmd_config_mtu_port =
2067 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2069 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2070 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2072 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2073 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2075 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2076 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2077 cmdline_parse_token_num_t cmd_config_mtu_value =
2078 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2080 cmdline_parse_inst_t cmd_config_mtu = {
2081 .f = cmd_config_mtu_parsed,
2083 .help_str = "port config mtu <port_id> <value>",
2085 (void *)&cmd_config_mtu_port,
2086 (void *)&cmd_config_mtu_keyword,
2087 (void *)&cmd_config_mtu_mtu,
2088 (void *)&cmd_config_mtu_port_id,
2089 (void *)&cmd_config_mtu_value,
2094 /* *** configure rx mode *** */
2095 struct cmd_config_rx_mode_flag {
2096 cmdline_fixed_string_t port;
2097 cmdline_fixed_string_t keyword;
2098 cmdline_fixed_string_t all;
2099 cmdline_fixed_string_t name;
2100 cmdline_fixed_string_t value;
2104 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2105 __attribute__((unused)) struct cmdline *cl,
2106 __attribute__((unused)) void *data)
2108 struct cmd_config_rx_mode_flag *res = parsed_result;
2110 if (!all_ports_stopped()) {
2111 printf("Please stop all ports first\n");
2115 if (!strcmp(res->name, "drop-en")) {
2116 if (!strcmp(res->value, "on"))
2118 else if (!strcmp(res->value, "off"))
2121 printf("Unknown parameter\n");
2125 printf("Unknown parameter\n");
2131 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2134 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2135 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2136 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2137 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2139 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2140 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2141 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2142 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2144 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2145 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2148 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2149 .f = cmd_config_rx_mode_flag_parsed,
2151 .help_str = "port config all drop-en on|off",
2153 (void *)&cmd_config_rx_mode_flag_port,
2154 (void *)&cmd_config_rx_mode_flag_keyword,
2155 (void *)&cmd_config_rx_mode_flag_all,
2156 (void *)&cmd_config_rx_mode_flag_name,
2157 (void *)&cmd_config_rx_mode_flag_value,
2162 /* *** configure rss *** */
2163 struct cmd_config_rss {
2164 cmdline_fixed_string_t port;
2165 cmdline_fixed_string_t keyword;
2166 cmdline_fixed_string_t all;
2167 cmdline_fixed_string_t name;
2168 cmdline_fixed_string_t value;
2172 cmd_config_rss_parsed(void *parsed_result,
2173 __attribute__((unused)) struct cmdline *cl,
2174 __attribute__((unused)) void *data)
2176 struct cmd_config_rss *res = parsed_result;
2177 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2178 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2179 int use_default = 0;
2180 int all_updated = 1;
2185 if (!strcmp(res->value, "all"))
2186 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2187 ETH_RSS_UDP | ETH_RSS_SCTP |
2189 else if (!strcmp(res->value, "ip"))
2190 rss_conf.rss_hf = ETH_RSS_IP;
2191 else if (!strcmp(res->value, "udp"))
2192 rss_conf.rss_hf = ETH_RSS_UDP;
2193 else if (!strcmp(res->value, "tcp"))
2194 rss_conf.rss_hf = ETH_RSS_TCP;
2195 else if (!strcmp(res->value, "sctp"))
2196 rss_conf.rss_hf = ETH_RSS_SCTP;
2197 else if (!strcmp(res->value, "ether"))
2198 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2199 else if (!strcmp(res->value, "port"))
2200 rss_conf.rss_hf = ETH_RSS_PORT;
2201 else if (!strcmp(res->value, "vxlan"))
2202 rss_conf.rss_hf = ETH_RSS_VXLAN;
2203 else if (!strcmp(res->value, "geneve"))
2204 rss_conf.rss_hf = ETH_RSS_GENEVE;
2205 else if (!strcmp(res->value, "nvgre"))
2206 rss_conf.rss_hf = ETH_RSS_NVGRE;
2207 else if (!strcmp(res->value, "none"))
2208 rss_conf.rss_hf = 0;
2209 else if (!strcmp(res->value, "default"))
2211 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2212 atoi(res->value) < 64)
2213 rss_conf.rss_hf = 1ULL << atoi(res->value);
2215 printf("Unknown parameter\n");
2218 rss_conf.rss_key = NULL;
2219 /* Update global configuration for RSS types. */
2220 RTE_ETH_FOREACH_DEV(i) {
2221 struct rte_eth_rss_conf local_rss_conf;
2223 ret = eth_dev_info_get_print_err(i, &dev_info);
2228 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2230 local_rss_conf = rss_conf;
2231 local_rss_conf.rss_hf = rss_conf.rss_hf &
2232 dev_info.flow_type_rss_offloads;
2233 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2234 printf("Port %u modified RSS hash function based on hardware support,"
2235 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2236 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2238 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2241 printf("Configuration of RSS hash at ethernet port %d "
2242 "failed with error (%d): %s.\n",
2243 i, -diag, strerror(-diag));
2246 if (all_updated && !use_default)
2247 rss_hf = rss_conf.rss_hf;
2250 cmdline_parse_token_string_t cmd_config_rss_port =
2251 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2252 cmdline_parse_token_string_t cmd_config_rss_keyword =
2253 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2254 cmdline_parse_token_string_t cmd_config_rss_all =
2255 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2256 cmdline_parse_token_string_t cmd_config_rss_name =
2257 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2258 cmdline_parse_token_string_t cmd_config_rss_value =
2259 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2261 cmdline_parse_inst_t cmd_config_rss = {
2262 .f = cmd_config_rss_parsed,
2264 .help_str = "port config all rss "
2265 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>",
2267 (void *)&cmd_config_rss_port,
2268 (void *)&cmd_config_rss_keyword,
2269 (void *)&cmd_config_rss_all,
2270 (void *)&cmd_config_rss_name,
2271 (void *)&cmd_config_rss_value,
2276 /* *** configure rss hash key *** */
2277 struct cmd_config_rss_hash_key {
2278 cmdline_fixed_string_t port;
2279 cmdline_fixed_string_t config;
2281 cmdline_fixed_string_t rss_hash_key;
2282 cmdline_fixed_string_t rss_type;
2283 cmdline_fixed_string_t key;
2287 hexa_digit_to_value(char hexa_digit)
2289 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2290 return (uint8_t) (hexa_digit - '0');
2291 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2292 return (uint8_t) ((hexa_digit - 'a') + 10);
2293 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2294 return (uint8_t) ((hexa_digit - 'A') + 10);
2295 /* Invalid hexa digit */
2300 parse_and_check_key_hexa_digit(char *key, int idx)
2304 hexa_v = hexa_digit_to_value(key[idx]);
2306 printf("invalid key: character %c at position %d is not a "
2307 "valid hexa digit\n", key[idx], idx);
2312 cmd_config_rss_hash_key_parsed(void *parsed_result,
2313 __attribute__((unused)) struct cmdline *cl,
2314 __attribute__((unused)) void *data)
2316 struct cmd_config_rss_hash_key *res = parsed_result;
2317 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2321 struct rte_eth_dev_info dev_info;
2322 uint8_t hash_key_size;
2326 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2330 if (dev_info.hash_key_size > 0 &&
2331 dev_info.hash_key_size <= sizeof(hash_key))
2332 hash_key_size = dev_info.hash_key_size;
2334 printf("dev_info did not provide a valid hash key size\n");
2337 /* Check the length of the RSS hash key */
2338 key_len = strlen(res->key);
2339 if (key_len != (hash_key_size * 2)) {
2340 printf("key length: %d invalid - key must be a string of %d"
2341 " hexa-decimal numbers\n",
2342 (int) key_len, hash_key_size * 2);
2345 /* Translate RSS hash key into binary representation */
2346 for (i = 0; i < hash_key_size; i++) {
2347 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2350 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2353 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2355 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2359 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2360 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2361 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2362 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2364 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2365 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2366 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2367 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2368 rss_hash_key, "rss-hash-key");
2369 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2370 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2371 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2372 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2373 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2374 "ipv6-tcp-ex#ipv6-udp-ex");
2375 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2376 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2378 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2379 .f = cmd_config_rss_hash_key_parsed,
2381 .help_str = "port config <port_id> rss-hash-key "
2382 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2383 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2384 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2385 "<string of hex digits (variable length, NIC dependent)>",
2387 (void *)&cmd_config_rss_hash_key_port,
2388 (void *)&cmd_config_rss_hash_key_config,
2389 (void *)&cmd_config_rss_hash_key_port_id,
2390 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2391 (void *)&cmd_config_rss_hash_key_rss_type,
2392 (void *)&cmd_config_rss_hash_key_value,
2397 /* *** configure port rxq/txq ring size *** */
2398 struct cmd_config_rxtx_ring_size {
2399 cmdline_fixed_string_t port;
2400 cmdline_fixed_string_t config;
2402 cmdline_fixed_string_t rxtxq;
2404 cmdline_fixed_string_t rsize;
2409 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2410 __attribute__((unused)) struct cmdline *cl,
2411 __attribute__((unused)) void *data)
2413 struct cmd_config_rxtx_ring_size *res = parsed_result;
2414 struct rte_port *port;
2417 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2420 if (res->portid == (portid_t)RTE_PORT_ALL) {
2421 printf("Invalid port id\n");
2425 port = &ports[res->portid];
2427 if (!strcmp(res->rxtxq, "rxq"))
2429 else if (!strcmp(res->rxtxq, "txq"))
2432 printf("Unknown parameter\n");
2436 if (isrx && rx_queue_id_is_invalid(res->qid))
2438 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2441 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2442 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2448 port->nb_rx_desc[res->qid] = res->size;
2450 port->nb_tx_desc[res->qid] = res->size;
2452 cmd_reconfig_device_queue(res->portid, 0, 1);
2455 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2456 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2458 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2459 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2461 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2462 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2464 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2465 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2467 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2468 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2470 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2471 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2472 rsize, "ring_size");
2473 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2474 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2477 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2478 .f = cmd_config_rxtx_ring_size_parsed,
2480 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2482 (void *)&cmd_config_rxtx_ring_size_port,
2483 (void *)&cmd_config_rxtx_ring_size_config,
2484 (void *)&cmd_config_rxtx_ring_size_portid,
2485 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2486 (void *)&cmd_config_rxtx_ring_size_qid,
2487 (void *)&cmd_config_rxtx_ring_size_rsize,
2488 (void *)&cmd_config_rxtx_ring_size_size,
2493 /* *** configure port rxq/txq start/stop *** */
2494 struct cmd_config_rxtx_queue {
2495 cmdline_fixed_string_t port;
2497 cmdline_fixed_string_t rxtxq;
2499 cmdline_fixed_string_t opname;
2503 cmd_config_rxtx_queue_parsed(void *parsed_result,
2504 __attribute__((unused)) struct cmdline *cl,
2505 __attribute__((unused)) void *data)
2507 struct cmd_config_rxtx_queue *res = parsed_result;
2512 if (test_done == 0) {
2513 printf("Please stop forwarding first\n");
2517 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2520 if (port_is_started(res->portid) != 1) {
2521 printf("Please start port %u first\n", res->portid);
2525 if (!strcmp(res->rxtxq, "rxq"))
2527 else if (!strcmp(res->rxtxq, "txq"))
2530 printf("Unknown parameter\n");
2534 if (isrx && rx_queue_id_is_invalid(res->qid))
2536 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2539 if (!strcmp(res->opname, "start"))
2541 else if (!strcmp(res->opname, "stop"))
2544 printf("Unknown parameter\n");
2548 if (isstart && isrx)
2549 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2550 else if (!isstart && isrx)
2551 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2552 else if (isstart && !isrx)
2553 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2555 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2557 if (ret == -ENOTSUP)
2558 printf("Function not supported in PMD driver\n");
2561 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2562 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2563 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2564 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2565 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2566 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2567 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2568 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2569 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2570 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2573 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2574 .f = cmd_config_rxtx_queue_parsed,
2576 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2578 (void *)&cmd_config_rxtx_queue_port,
2579 (void *)&cmd_config_rxtx_queue_portid,
2580 (void *)&cmd_config_rxtx_queue_rxtxq,
2581 (void *)&cmd_config_rxtx_queue_qid,
2582 (void *)&cmd_config_rxtx_queue_opname,
2587 /* *** configure port rxq/txq deferred start on/off *** */
2588 struct cmd_config_deferred_start_rxtx_queue {
2589 cmdline_fixed_string_t port;
2591 cmdline_fixed_string_t rxtxq;
2593 cmdline_fixed_string_t opname;
2594 cmdline_fixed_string_t state;
2598 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2599 __attribute__((unused)) struct cmdline *cl,
2600 __attribute__((unused)) void *data)
2602 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2603 struct rte_port *port;
2606 uint8_t needreconfig = 0;
2608 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2611 if (port_is_started(res->port_id) != 0) {
2612 printf("Please stop port %u first\n", res->port_id);
2616 port = &ports[res->port_id];
2618 isrx = !strcmp(res->rxtxq, "rxq");
2620 if (isrx && rx_queue_id_is_invalid(res->qid))
2622 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2625 ison = !strcmp(res->state, "on");
2627 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2628 port->rx_conf[res->qid].rx_deferred_start = ison;
2630 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2631 port->tx_conf[res->qid].tx_deferred_start = ison;
2636 cmd_reconfig_device_queue(res->port_id, 0, 1);
2639 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2640 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2642 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2643 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2645 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2646 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2648 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2649 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2651 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2652 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2653 opname, "deferred_start");
2654 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2655 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2658 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2659 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2661 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2663 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2664 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2665 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2666 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2667 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2668 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2673 /* *** configure port rxq/txq setup *** */
2674 struct cmd_setup_rxtx_queue {
2675 cmdline_fixed_string_t port;
2677 cmdline_fixed_string_t rxtxq;
2679 cmdline_fixed_string_t setup;
2682 /* Common CLI fields for queue setup */
2683 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2684 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2685 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2686 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2687 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2688 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2689 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2690 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2691 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2692 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2695 cmd_setup_rxtx_queue_parsed(
2696 void *parsed_result,
2697 __attribute__((unused)) struct cmdline *cl,
2698 __attribute__((unused)) void *data)
2700 struct cmd_setup_rxtx_queue *res = parsed_result;
2701 struct rte_port *port;
2702 struct rte_mempool *mp;
2703 unsigned int socket_id;
2707 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2710 if (res->portid == (portid_t)RTE_PORT_ALL) {
2711 printf("Invalid port id\n");
2715 if (!strcmp(res->rxtxq, "rxq"))
2717 else if (!strcmp(res->rxtxq, "txq"))
2720 printf("Unknown parameter\n");
2724 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2725 printf("Invalid rx queue\n");
2727 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2728 printf("Invalid tx queue\n");
2732 port = &ports[res->portid];
2734 socket_id = rxring_numa[res->portid];
2735 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2736 socket_id = port->socket_id;
2738 mp = mbuf_pool_find(socket_id);
2740 printf("Failed to setup RX queue: "
2741 "No mempool allocation"
2742 " on the socket %d\n",
2743 rxring_numa[res->portid]);
2746 ret = rte_eth_rx_queue_setup(res->portid,
2748 port->nb_rx_desc[res->qid],
2750 &port->rx_conf[res->qid],
2753 printf("Failed to setup RX queue\n");
2755 socket_id = txring_numa[res->portid];
2756 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2757 socket_id = port->socket_id;
2759 ret = rte_eth_tx_queue_setup(res->portid,
2761 port->nb_tx_desc[res->qid],
2763 &port->tx_conf[res->qid]);
2765 printf("Failed to setup TX queue\n");
2769 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2770 .f = cmd_setup_rxtx_queue_parsed,
2772 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2774 (void *)&cmd_setup_rxtx_queue_port,
2775 (void *)&cmd_setup_rxtx_queue_portid,
2776 (void *)&cmd_setup_rxtx_queue_rxtxq,
2777 (void *)&cmd_setup_rxtx_queue_qid,
2778 (void *)&cmd_setup_rxtx_queue_setup,
2784 /* *** Configure RSS RETA *** */
2785 struct cmd_config_rss_reta {
2786 cmdline_fixed_string_t port;
2787 cmdline_fixed_string_t keyword;
2789 cmdline_fixed_string_t name;
2790 cmdline_fixed_string_t list_name;
2791 cmdline_fixed_string_t list_of_items;
2795 parse_reta_config(const char *str,
2796 struct rte_eth_rss_reta_entry64 *reta_conf,
2797 uint16_t nb_entries)
2801 uint16_t hash_index, idx, shift;
2804 const char *p, *p0 = str;
2811 unsigned long int_fld[_NUM_FLD];
2812 char *str_fld[_NUM_FLD];
2814 while ((p = strchr(p0,'(')) != NULL) {
2816 if((p0 = strchr(p,')')) == NULL)
2820 if(size >= sizeof(s))
2823 snprintf(s, sizeof(s), "%.*s", size, p);
2824 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2826 for (i = 0; i < _NUM_FLD; i++) {
2828 int_fld[i] = strtoul(str_fld[i], &end, 0);
2829 if (errno != 0 || end == str_fld[i] ||
2834 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2835 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2837 if (hash_index >= nb_entries) {
2838 printf("Invalid RETA hash index=%d\n", hash_index);
2842 idx = hash_index / RTE_RETA_GROUP_SIZE;
2843 shift = hash_index % RTE_RETA_GROUP_SIZE;
2844 reta_conf[idx].mask |= (1ULL << shift);
2845 reta_conf[idx].reta[shift] = nb_queue;
2852 cmd_set_rss_reta_parsed(void *parsed_result,
2853 __attribute__((unused)) struct cmdline *cl,
2854 __attribute__((unused)) void *data)
2857 struct rte_eth_dev_info dev_info;
2858 struct rte_eth_rss_reta_entry64 reta_conf[8];
2859 struct cmd_config_rss_reta *res = parsed_result;
2861 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2865 if (dev_info.reta_size == 0) {
2866 printf("Redirection table size is 0 which is "
2867 "invalid for RSS\n");
2870 printf("The reta size of port %d is %u\n",
2871 res->port_id, dev_info.reta_size);
2872 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2873 printf("Currently do not support more than %u entries of "
2874 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2878 memset(reta_conf, 0, sizeof(reta_conf));
2879 if (!strcmp(res->list_name, "reta")) {
2880 if (parse_reta_config(res->list_of_items, reta_conf,
2881 dev_info.reta_size)) {
2882 printf("Invalid RSS Redirection Table "
2883 "config entered\n");
2886 ret = rte_eth_dev_rss_reta_update(res->port_id,
2887 reta_conf, dev_info.reta_size);
2889 printf("Bad redirection table parameter, "
2890 "return code = %d \n", ret);
2894 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2895 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2896 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2897 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2898 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2899 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2900 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2901 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2902 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2903 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2904 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2905 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2907 cmdline_parse_inst_t cmd_config_rss_reta = {
2908 .f = cmd_set_rss_reta_parsed,
2910 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2912 (void *)&cmd_config_rss_reta_port,
2913 (void *)&cmd_config_rss_reta_keyword,
2914 (void *)&cmd_config_rss_reta_port_id,
2915 (void *)&cmd_config_rss_reta_name,
2916 (void *)&cmd_config_rss_reta_list_name,
2917 (void *)&cmd_config_rss_reta_list_of_items,
2922 /* *** SHOW PORT RETA INFO *** */
2923 struct cmd_showport_reta {
2924 cmdline_fixed_string_t show;
2925 cmdline_fixed_string_t port;
2927 cmdline_fixed_string_t rss;
2928 cmdline_fixed_string_t reta;
2930 cmdline_fixed_string_t list_of_items;
2934 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2935 uint16_t nb_entries,
2939 const char *p, *p0 = str;
2944 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2945 RTE_RETA_GROUP_SIZE;
2948 p = strchr(p0, '(');
2952 p0 = strchr(p, ')');
2956 if (size >= sizeof(s)) {
2957 printf("The string size exceeds the internal buffer size\n");
2960 snprintf(s, sizeof(s), "%.*s", size, p);
2961 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2962 if (ret <= 0 || ret != num) {
2963 printf("The bits of masks do not match the number of "
2964 "reta entries: %u\n", num);
2967 for (i = 0; i < ret; i++)
2968 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2974 cmd_showport_reta_parsed(void *parsed_result,
2975 __attribute__((unused)) struct cmdline *cl,
2976 __attribute__((unused)) void *data)
2978 struct cmd_showport_reta *res = parsed_result;
2979 struct rte_eth_rss_reta_entry64 reta_conf[8];
2980 struct rte_eth_dev_info dev_info;
2981 uint16_t max_reta_size;
2984 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2988 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2989 if (res->size == 0 || res->size > max_reta_size) {
2990 printf("Invalid redirection table size: %u (1-%u)\n",
2991 res->size, max_reta_size);
2995 memset(reta_conf, 0, sizeof(reta_conf));
2996 if (showport_parse_reta_config(reta_conf, res->size,
2997 res->list_of_items) < 0) {
2998 printf("Invalid string: %s for reta masks\n",
2999 res->list_of_items);
3002 port_rss_reta_info(res->port_id, reta_conf, res->size);
3005 cmdline_parse_token_string_t cmd_showport_reta_show =
3006 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3007 cmdline_parse_token_string_t cmd_showport_reta_port =
3008 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3009 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3010 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3011 cmdline_parse_token_string_t cmd_showport_reta_rss =
3012 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3013 cmdline_parse_token_string_t cmd_showport_reta_reta =
3014 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3015 cmdline_parse_token_num_t cmd_showport_reta_size =
3016 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3017 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3018 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3019 list_of_items, NULL);
3021 cmdline_parse_inst_t cmd_showport_reta = {
3022 .f = cmd_showport_reta_parsed,
3024 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3026 (void *)&cmd_showport_reta_show,
3027 (void *)&cmd_showport_reta_port,
3028 (void *)&cmd_showport_reta_port_id,
3029 (void *)&cmd_showport_reta_rss,
3030 (void *)&cmd_showport_reta_reta,
3031 (void *)&cmd_showport_reta_size,
3032 (void *)&cmd_showport_reta_list_of_items,
3037 /* *** Show RSS hash configuration *** */
3038 struct cmd_showport_rss_hash {
3039 cmdline_fixed_string_t show;
3040 cmdline_fixed_string_t port;
3042 cmdline_fixed_string_t rss_hash;
3043 cmdline_fixed_string_t rss_type;
3044 cmdline_fixed_string_t key; /* optional argument */
3047 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3048 __attribute__((unused)) struct cmdline *cl,
3051 struct cmd_showport_rss_hash *res = parsed_result;
3053 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3056 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3057 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3058 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3059 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3060 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3061 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3062 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3063 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3065 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3066 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3068 cmdline_parse_inst_t cmd_showport_rss_hash = {
3069 .f = cmd_showport_rss_hash_parsed,
3071 .help_str = "show port <port_id> rss-hash",
3073 (void *)&cmd_showport_rss_hash_show,
3074 (void *)&cmd_showport_rss_hash_port,
3075 (void *)&cmd_showport_rss_hash_port_id,
3076 (void *)&cmd_showport_rss_hash_rss_hash,
3081 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3082 .f = cmd_showport_rss_hash_parsed,
3084 .help_str = "show port <port_id> rss-hash key",
3086 (void *)&cmd_showport_rss_hash_show,
3087 (void *)&cmd_showport_rss_hash_port,
3088 (void *)&cmd_showport_rss_hash_port_id,
3089 (void *)&cmd_showport_rss_hash_rss_hash,
3090 (void *)&cmd_showport_rss_hash_rss_key,
3095 /* *** Configure DCB *** */
3096 struct cmd_config_dcb {
3097 cmdline_fixed_string_t port;
3098 cmdline_fixed_string_t config;
3100 cmdline_fixed_string_t dcb;
3101 cmdline_fixed_string_t vt;
3102 cmdline_fixed_string_t vt_en;
3104 cmdline_fixed_string_t pfc;
3105 cmdline_fixed_string_t pfc_en;
3109 cmd_config_dcb_parsed(void *parsed_result,
3110 __attribute__((unused)) struct cmdline *cl,
3111 __attribute__((unused)) void *data)
3113 struct cmd_config_dcb *res = parsed_result;
3114 portid_t port_id = res->port_id;
3115 struct rte_port *port;
3119 port = &ports[port_id];
3120 /** Check if the port is not started **/
3121 if (port->port_status != RTE_PORT_STOPPED) {
3122 printf("Please stop port %d first\n", port_id);
3126 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3127 printf("The invalid number of traffic class,"
3128 " only 4 or 8 allowed.\n");
3132 if (nb_fwd_lcores < res->num_tcs) {
3133 printf("nb_cores shouldn't be less than number of TCs.\n");
3136 if (!strncmp(res->pfc_en, "on", 2))
3141 /* DCB in VT mode */
3142 if (!strncmp(res->vt_en, "on", 2))
3143 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3144 (enum rte_eth_nb_tcs)res->num_tcs,
3147 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3148 (enum rte_eth_nb_tcs)res->num_tcs,
3153 printf("Cannot initialize network ports.\n");
3157 cmd_reconfig_device_queue(port_id, 1, 1);
3160 cmdline_parse_token_string_t cmd_config_dcb_port =
3161 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3162 cmdline_parse_token_string_t cmd_config_dcb_config =
3163 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3164 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3165 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3166 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3167 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3168 cmdline_parse_token_string_t cmd_config_dcb_vt =
3169 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3170 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3171 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3172 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3173 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3174 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3175 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3176 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3177 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3179 cmdline_parse_inst_t cmd_config_dcb = {
3180 .f = cmd_config_dcb_parsed,
3182 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3184 (void *)&cmd_config_dcb_port,
3185 (void *)&cmd_config_dcb_config,
3186 (void *)&cmd_config_dcb_port_id,
3187 (void *)&cmd_config_dcb_dcb,
3188 (void *)&cmd_config_dcb_vt,
3189 (void *)&cmd_config_dcb_vt_en,
3190 (void *)&cmd_config_dcb_num_tcs,
3191 (void *)&cmd_config_dcb_pfc,
3192 (void *)&cmd_config_dcb_pfc_en,
3197 /* *** configure number of packets per burst *** */
3198 struct cmd_config_burst {
3199 cmdline_fixed_string_t port;
3200 cmdline_fixed_string_t keyword;
3201 cmdline_fixed_string_t all;
3202 cmdline_fixed_string_t name;
3207 cmd_config_burst_parsed(void *parsed_result,
3208 __attribute__((unused)) struct cmdline *cl,
3209 __attribute__((unused)) void *data)
3211 struct cmd_config_burst *res = parsed_result;
3212 struct rte_eth_dev_info dev_info;
3213 uint16_t rec_nb_pkts;
3216 if (!all_ports_stopped()) {
3217 printf("Please stop all ports first\n");
3221 if (!strcmp(res->name, "burst")) {
3222 if (res->value == 0) {
3223 /* If user gives a value of zero, query the PMD for
3224 * its recommended Rx burst size. Testpmd uses a single
3225 * size for all ports, so assume all ports are the same
3226 * NIC model and use the values from Port 0.
3228 ret = eth_dev_info_get_print_err(0, &dev_info);
3232 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3234 if (rec_nb_pkts == 0) {
3235 printf("PMD does not recommend a burst size.\n"
3236 "User provided value must be between"
3237 " 1 and %d\n", MAX_PKT_BURST);
3239 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3240 printf("PMD recommended burst size of %d"
3241 " exceeds maximum value of %d\n",
3242 rec_nb_pkts, MAX_PKT_BURST);
3245 printf("Using PMD-provided burst value of %d\n",
3247 nb_pkt_per_burst = rec_nb_pkts;
3248 } else if (res->value > MAX_PKT_BURST) {
3249 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3252 nb_pkt_per_burst = res->value;
3254 printf("Unknown parameter\n");
3260 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3263 cmdline_parse_token_string_t cmd_config_burst_port =
3264 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3265 cmdline_parse_token_string_t cmd_config_burst_keyword =
3266 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3267 cmdline_parse_token_string_t cmd_config_burst_all =
3268 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3269 cmdline_parse_token_string_t cmd_config_burst_name =
3270 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3271 cmdline_parse_token_num_t cmd_config_burst_value =
3272 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3274 cmdline_parse_inst_t cmd_config_burst = {
3275 .f = cmd_config_burst_parsed,
3277 .help_str = "port config all burst <value>",
3279 (void *)&cmd_config_burst_port,
3280 (void *)&cmd_config_burst_keyword,
3281 (void *)&cmd_config_burst_all,
3282 (void *)&cmd_config_burst_name,
3283 (void *)&cmd_config_burst_value,
3288 /* *** configure rx/tx queues *** */
3289 struct cmd_config_thresh {
3290 cmdline_fixed_string_t port;
3291 cmdline_fixed_string_t keyword;
3292 cmdline_fixed_string_t all;
3293 cmdline_fixed_string_t name;
3298 cmd_config_thresh_parsed(void *parsed_result,
3299 __attribute__((unused)) struct cmdline *cl,
3300 __attribute__((unused)) void *data)
3302 struct cmd_config_thresh *res = parsed_result;
3304 if (!all_ports_stopped()) {
3305 printf("Please stop all ports first\n");
3309 if (!strcmp(res->name, "txpt"))
3310 tx_pthresh = res->value;
3311 else if(!strcmp(res->name, "txht"))
3312 tx_hthresh = res->value;
3313 else if(!strcmp(res->name, "txwt"))
3314 tx_wthresh = res->value;
3315 else if(!strcmp(res->name, "rxpt"))
3316 rx_pthresh = res->value;
3317 else if(!strcmp(res->name, "rxht"))
3318 rx_hthresh = res->value;
3319 else if(!strcmp(res->name, "rxwt"))
3320 rx_wthresh = res->value;
3322 printf("Unknown parameter\n");
3328 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3331 cmdline_parse_token_string_t cmd_config_thresh_port =
3332 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3333 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3334 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3335 cmdline_parse_token_string_t cmd_config_thresh_all =
3336 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3337 cmdline_parse_token_string_t cmd_config_thresh_name =
3338 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3339 "txpt#txht#txwt#rxpt#rxht#rxwt");
3340 cmdline_parse_token_num_t cmd_config_thresh_value =
3341 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3343 cmdline_parse_inst_t cmd_config_thresh = {
3344 .f = cmd_config_thresh_parsed,
3346 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3348 (void *)&cmd_config_thresh_port,
3349 (void *)&cmd_config_thresh_keyword,
3350 (void *)&cmd_config_thresh_all,
3351 (void *)&cmd_config_thresh_name,
3352 (void *)&cmd_config_thresh_value,
3357 /* *** configure free/rs threshold *** */
3358 struct cmd_config_threshold {
3359 cmdline_fixed_string_t port;
3360 cmdline_fixed_string_t keyword;
3361 cmdline_fixed_string_t all;
3362 cmdline_fixed_string_t name;
3367 cmd_config_threshold_parsed(void *parsed_result,
3368 __attribute__((unused)) struct cmdline *cl,
3369 __attribute__((unused)) void *data)
3371 struct cmd_config_threshold *res = parsed_result;
3373 if (!all_ports_stopped()) {
3374 printf("Please stop all ports first\n");
3378 if (!strcmp(res->name, "txfreet"))
3379 tx_free_thresh = res->value;
3380 else if (!strcmp(res->name, "txrst"))
3381 tx_rs_thresh = res->value;
3382 else if (!strcmp(res->name, "rxfreet"))
3383 rx_free_thresh = res->value;
3385 printf("Unknown parameter\n");
3391 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3394 cmdline_parse_token_string_t cmd_config_threshold_port =
3395 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3396 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3397 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3399 cmdline_parse_token_string_t cmd_config_threshold_all =
3400 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3401 cmdline_parse_token_string_t cmd_config_threshold_name =
3402 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3403 "txfreet#txrst#rxfreet");
3404 cmdline_parse_token_num_t cmd_config_threshold_value =
3405 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3407 cmdline_parse_inst_t cmd_config_threshold = {
3408 .f = cmd_config_threshold_parsed,
3410 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3412 (void *)&cmd_config_threshold_port,
3413 (void *)&cmd_config_threshold_keyword,
3414 (void *)&cmd_config_threshold_all,
3415 (void *)&cmd_config_threshold_name,
3416 (void *)&cmd_config_threshold_value,
3422 struct cmd_stop_result {
3423 cmdline_fixed_string_t stop;
3426 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3427 __attribute__((unused)) struct cmdline *cl,
3428 __attribute__((unused)) void *data)
3430 stop_packet_forwarding();
3433 cmdline_parse_token_string_t cmd_stop_stop =
3434 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3436 cmdline_parse_inst_t cmd_stop = {
3437 .f = cmd_stop_parsed,
3439 .help_str = "stop: Stop packet forwarding",
3441 (void *)&cmd_stop_stop,
3446 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3449 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3450 unsigned int *parsed_items, int check_unique_values)
3452 unsigned int nb_item;
3460 * First parse all items in the list and store their value.
3465 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3467 if ((c >= '0') && (c <= '9')) {
3468 value = (unsigned int) (value * 10 + (c - '0'));
3473 printf("character %c is not a decimal digit\n", c);
3477 printf("No valid value before comma\n");
3480 if (nb_item < max_items) {
3481 parsed_items[nb_item] = value;
3487 if (nb_item >= max_items) {
3488 printf("Number of %s = %u > %u (maximum items)\n",
3489 item_name, nb_item + 1, max_items);
3492 parsed_items[nb_item++] = value;
3493 if (! check_unique_values)
3497 * Then, check that all values in the list are differents.
3498 * No optimization here...
3500 for (i = 0; i < nb_item; i++) {
3501 for (j = i + 1; j < nb_item; j++) {
3502 if (parsed_items[j] == parsed_items[i]) {
3503 printf("duplicated %s %u at index %u and %u\n",
3504 item_name, parsed_items[i], i, j);
3512 struct cmd_set_list_result {
3513 cmdline_fixed_string_t cmd_keyword;
3514 cmdline_fixed_string_t list_name;
3515 cmdline_fixed_string_t list_of_items;
3518 static void cmd_set_list_parsed(void *parsed_result,
3519 __attribute__((unused)) struct cmdline *cl,
3520 __attribute__((unused)) void *data)
3522 struct cmd_set_list_result *res;
3524 unsigned int lcorelist[RTE_MAX_LCORE];
3525 unsigned int portlist[RTE_MAX_ETHPORTS];
3527 unsigned int nb_item;
3529 if (test_done == 0) {
3530 printf("Please stop forwarding first\n");
3534 res = parsed_result;
3535 if (!strcmp(res->list_name, "corelist")) {
3536 nb_item = parse_item_list(res->list_of_items, "core",
3538 parsed_items.lcorelist, 1);
3540 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3545 if (!strcmp(res->list_name, "portlist")) {
3546 nb_item = parse_item_list(res->list_of_items, "port",
3548 parsed_items.portlist, 1);
3550 set_fwd_ports_list(parsed_items.portlist, nb_item);
3556 cmdline_parse_token_string_t cmd_set_list_keyword =
3557 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3559 cmdline_parse_token_string_t cmd_set_list_name =
3560 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3561 "corelist#portlist");
3562 cmdline_parse_token_string_t cmd_set_list_of_items =
3563 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3566 cmdline_parse_inst_t cmd_set_fwd_list = {
3567 .f = cmd_set_list_parsed,
3569 .help_str = "set corelist|portlist <list0[,list1]*>",
3571 (void *)&cmd_set_list_keyword,
3572 (void *)&cmd_set_list_name,
3573 (void *)&cmd_set_list_of_items,
3578 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3580 struct cmd_setmask_result {
3581 cmdline_fixed_string_t set;
3582 cmdline_fixed_string_t mask;
3586 static void cmd_set_mask_parsed(void *parsed_result,
3587 __attribute__((unused)) struct cmdline *cl,
3588 __attribute__((unused)) void *data)
3590 struct cmd_setmask_result *res = parsed_result;
3592 if (test_done == 0) {
3593 printf("Please stop forwarding first\n");
3596 if (!strcmp(res->mask, "coremask")) {
3597 set_fwd_lcores_mask(res->hexavalue);
3599 } else if (!strcmp(res->mask, "portmask")) {
3600 set_fwd_ports_mask(res->hexavalue);
3605 cmdline_parse_token_string_t cmd_setmask_set =
3606 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3607 cmdline_parse_token_string_t cmd_setmask_mask =
3608 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3609 "coremask#portmask");
3610 cmdline_parse_token_num_t cmd_setmask_value =
3611 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3613 cmdline_parse_inst_t cmd_set_fwd_mask = {
3614 .f = cmd_set_mask_parsed,
3616 .help_str = "set coremask|portmask <hexadecimal value>",
3618 (void *)&cmd_setmask_set,
3619 (void *)&cmd_setmask_mask,
3620 (void *)&cmd_setmask_value,
3626 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3628 struct cmd_set_result {
3629 cmdline_fixed_string_t set;
3630 cmdline_fixed_string_t what;
3634 static void cmd_set_parsed(void *parsed_result,
3635 __attribute__((unused)) struct cmdline *cl,
3636 __attribute__((unused)) void *data)
3638 struct cmd_set_result *res = parsed_result;
3639 if (!strcmp(res->what, "nbport")) {
3640 set_fwd_ports_number(res->value);
3642 } else if (!strcmp(res->what, "nbcore")) {
3643 set_fwd_lcores_number(res->value);
3645 } else if (!strcmp(res->what, "burst"))
3646 set_nb_pkt_per_burst(res->value);
3647 else if (!strcmp(res->what, "verbose"))
3648 set_verbose_level(res->value);
3651 cmdline_parse_token_string_t cmd_set_set =
3652 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3653 cmdline_parse_token_string_t cmd_set_what =
3654 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3655 "nbport#nbcore#burst#verbose");
3656 cmdline_parse_token_num_t cmd_set_value =
3657 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3659 cmdline_parse_inst_t cmd_set_numbers = {
3660 .f = cmd_set_parsed,
3662 .help_str = "set nbport|nbcore|burst|verbose <value>",
3664 (void *)&cmd_set_set,
3665 (void *)&cmd_set_what,
3666 (void *)&cmd_set_value,
3671 /* *** SET LOG LEVEL CONFIGURATION *** */
3673 struct cmd_set_log_result {
3674 cmdline_fixed_string_t set;
3675 cmdline_fixed_string_t log;
3676 cmdline_fixed_string_t type;
3681 cmd_set_log_parsed(void *parsed_result,
3682 __attribute__((unused)) struct cmdline *cl,
3683 __attribute__((unused)) void *data)
3685 struct cmd_set_log_result *res;
3688 res = parsed_result;
3689 if (!strcmp(res->type, "global"))
3690 rte_log_set_global_level(res->level);
3692 ret = rte_log_set_level_regexp(res->type, res->level);
3694 printf("Unable to set log level\n");
3698 cmdline_parse_token_string_t cmd_set_log_set =
3699 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3700 cmdline_parse_token_string_t cmd_set_log_log =
3701 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3702 cmdline_parse_token_string_t cmd_set_log_type =
3703 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3704 cmdline_parse_token_num_t cmd_set_log_level =
3705 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3707 cmdline_parse_inst_t cmd_set_log = {
3708 .f = cmd_set_log_parsed,
3710 .help_str = "set log global|<type> <level>",
3712 (void *)&cmd_set_log_set,
3713 (void *)&cmd_set_log_log,
3714 (void *)&cmd_set_log_type,
3715 (void *)&cmd_set_log_level,
3720 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3722 struct cmd_set_txpkts_result {
3723 cmdline_fixed_string_t cmd_keyword;
3724 cmdline_fixed_string_t txpkts;
3725 cmdline_fixed_string_t seg_lengths;
3729 cmd_set_txpkts_parsed(void *parsed_result,
3730 __attribute__((unused)) struct cmdline *cl,
3731 __attribute__((unused)) void *data)
3733 struct cmd_set_txpkts_result *res;
3734 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3735 unsigned int nb_segs;
3737 res = parsed_result;
3738 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3739 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3741 set_tx_pkt_segments(seg_lengths, nb_segs);
3744 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3745 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3746 cmd_keyword, "set");
3747 cmdline_parse_token_string_t cmd_set_txpkts_name =
3748 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3750 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3751 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3754 cmdline_parse_inst_t cmd_set_txpkts = {
3755 .f = cmd_set_txpkts_parsed,
3757 .help_str = "set txpkts <len0[,len1]*>",
3759 (void *)&cmd_set_txpkts_keyword,
3760 (void *)&cmd_set_txpkts_name,
3761 (void *)&cmd_set_txpkts_lengths,
3766 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3768 struct cmd_set_txsplit_result {
3769 cmdline_fixed_string_t cmd_keyword;
3770 cmdline_fixed_string_t txsplit;
3771 cmdline_fixed_string_t mode;
3775 cmd_set_txsplit_parsed(void *parsed_result,
3776 __attribute__((unused)) struct cmdline *cl,
3777 __attribute__((unused)) void *data)
3779 struct cmd_set_txsplit_result *res;
3781 res = parsed_result;
3782 set_tx_pkt_split(res->mode);
3785 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3786 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3787 cmd_keyword, "set");
3788 cmdline_parse_token_string_t cmd_set_txsplit_name =
3789 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3790 txsplit, "txsplit");
3791 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3792 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3795 cmdline_parse_inst_t cmd_set_txsplit = {
3796 .f = cmd_set_txsplit_parsed,
3798 .help_str = "set txsplit on|off|rand",
3800 (void *)&cmd_set_txsplit_keyword,
3801 (void *)&cmd_set_txsplit_name,
3802 (void *)&cmd_set_txsplit_mode,
3807 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3808 struct cmd_rx_vlan_filter_all_result {
3809 cmdline_fixed_string_t rx_vlan;
3810 cmdline_fixed_string_t what;
3811 cmdline_fixed_string_t all;
3816 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3817 __attribute__((unused)) struct cmdline *cl,
3818 __attribute__((unused)) void *data)
3820 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3822 if (!strcmp(res->what, "add"))
3823 rx_vlan_all_filter_set(res->port_id, 1);
3825 rx_vlan_all_filter_set(res->port_id, 0);
3828 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3829 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3830 rx_vlan, "rx_vlan");
3831 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3832 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3834 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3835 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3837 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3838 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3841 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3842 .f = cmd_rx_vlan_filter_all_parsed,
3844 .help_str = "rx_vlan add|rm all <port_id>: "
3845 "Add/Remove all identifiers to/from the set of VLAN "
3846 "identifiers filtered by a port",
3848 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3849 (void *)&cmd_rx_vlan_filter_all_what,
3850 (void *)&cmd_rx_vlan_filter_all_all,
3851 (void *)&cmd_rx_vlan_filter_all_portid,
3856 /* *** VLAN OFFLOAD SET ON A PORT *** */
3857 struct cmd_vlan_offload_result {
3858 cmdline_fixed_string_t vlan;
3859 cmdline_fixed_string_t set;
3860 cmdline_fixed_string_t vlan_type;
3861 cmdline_fixed_string_t what;
3862 cmdline_fixed_string_t on;
3863 cmdline_fixed_string_t port_id;
3867 cmd_vlan_offload_parsed(void *parsed_result,
3868 __attribute__((unused)) struct cmdline *cl,
3869 __attribute__((unused)) void *data)
3872 struct cmd_vlan_offload_result *res = parsed_result;
3875 portid_t port_id = 0;
3879 len = strnlen(str, STR_TOKEN_SIZE);
3881 /* Get port_id first */
3889 tmp = strtoul(str, NULL, 0);
3890 /* If port_id greater that what portid_t can represent, return */
3891 if(tmp >= RTE_MAX_ETHPORTS)
3893 port_id = (portid_t)tmp;
3895 if (!strcmp(res->on, "on"))
3900 if (!strcmp(res->what, "strip"))
3901 rx_vlan_strip_set(port_id, on);
3902 else if(!strcmp(res->what, "stripq")){
3903 uint16_t queue_id = 0;
3905 /* No queue_id, return */
3907 printf("must specify (port,queue_id)\n");
3910 tmp = strtoul(str + i + 1, NULL, 0);
3911 /* If queue_id greater that what 16-bits can represent, return */
3915 queue_id = (uint16_t)tmp;
3916 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3918 else if (!strcmp(res->what, "filter"))
3919 rx_vlan_filter_set(port_id, on);
3921 vlan_extend_set(port_id, on);
3926 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3927 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3929 cmdline_parse_token_string_t cmd_vlan_offload_set =
3930 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3932 cmdline_parse_token_string_t cmd_vlan_offload_what =
3933 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3934 what, "strip#filter#qinq#stripq");
3935 cmdline_parse_token_string_t cmd_vlan_offload_on =
3936 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3938 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3939 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3942 cmdline_parse_inst_t cmd_vlan_offload = {
3943 .f = cmd_vlan_offload_parsed,
3945 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3946 "<port_id[,queue_id]>: "
3947 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3949 (void *)&cmd_vlan_offload_vlan,
3950 (void *)&cmd_vlan_offload_set,
3951 (void *)&cmd_vlan_offload_what,
3952 (void *)&cmd_vlan_offload_on,
3953 (void *)&cmd_vlan_offload_portid,
3958 /* *** VLAN TPID SET ON A PORT *** */
3959 struct cmd_vlan_tpid_result {
3960 cmdline_fixed_string_t vlan;
3961 cmdline_fixed_string_t set;
3962 cmdline_fixed_string_t vlan_type;
3963 cmdline_fixed_string_t what;
3969 cmd_vlan_tpid_parsed(void *parsed_result,
3970 __attribute__((unused)) struct cmdline *cl,
3971 __attribute__((unused)) void *data)
3973 struct cmd_vlan_tpid_result *res = parsed_result;
3974 enum rte_vlan_type vlan_type;
3976 if (!strcmp(res->vlan_type, "inner"))
3977 vlan_type = ETH_VLAN_TYPE_INNER;
3978 else if (!strcmp(res->vlan_type, "outer"))
3979 vlan_type = ETH_VLAN_TYPE_OUTER;
3981 printf("Unknown vlan type\n");
3984 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3987 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3988 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3990 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3991 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3993 cmdline_parse_token_string_t cmd_vlan_type =
3994 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3995 vlan_type, "inner#outer");
3996 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3997 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3999 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4000 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4002 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4003 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4006 cmdline_parse_inst_t cmd_vlan_tpid = {
4007 .f = cmd_vlan_tpid_parsed,
4009 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4010 "Set the VLAN Ether type",
4012 (void *)&cmd_vlan_tpid_vlan,
4013 (void *)&cmd_vlan_tpid_set,
4014 (void *)&cmd_vlan_type,
4015 (void *)&cmd_vlan_tpid_what,
4016 (void *)&cmd_vlan_tpid_tpid,
4017 (void *)&cmd_vlan_tpid_portid,
4022 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4023 struct cmd_rx_vlan_filter_result {
4024 cmdline_fixed_string_t rx_vlan;
4025 cmdline_fixed_string_t what;
4031 cmd_rx_vlan_filter_parsed(void *parsed_result,
4032 __attribute__((unused)) struct cmdline *cl,
4033 __attribute__((unused)) void *data)
4035 struct cmd_rx_vlan_filter_result *res = parsed_result;
4037 if (!strcmp(res->what, "add"))
4038 rx_vft_set(res->port_id, res->vlan_id, 1);
4040 rx_vft_set(res->port_id, res->vlan_id, 0);
4043 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4044 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4045 rx_vlan, "rx_vlan");
4046 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4047 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4049 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4050 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4052 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4053 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4056 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4057 .f = cmd_rx_vlan_filter_parsed,
4059 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4060 "Add/Remove a VLAN identifier to/from the set of VLAN "
4061 "identifiers filtered by a port",
4063 (void *)&cmd_rx_vlan_filter_rx_vlan,
4064 (void *)&cmd_rx_vlan_filter_what,
4065 (void *)&cmd_rx_vlan_filter_vlanid,
4066 (void *)&cmd_rx_vlan_filter_portid,
4071 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4072 struct cmd_tx_vlan_set_result {
4073 cmdline_fixed_string_t tx_vlan;
4074 cmdline_fixed_string_t set;
4080 cmd_tx_vlan_set_parsed(void *parsed_result,
4081 __attribute__((unused)) struct cmdline *cl,
4082 __attribute__((unused)) void *data)
4084 struct cmd_tx_vlan_set_result *res = parsed_result;
4086 if (!port_is_stopped(res->port_id)) {
4087 printf("Please stop port %d first\n", res->port_id);
4091 tx_vlan_set(res->port_id, res->vlan_id);
4093 cmd_reconfig_device_queue(res->port_id, 1, 1);
4096 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4097 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4098 tx_vlan, "tx_vlan");
4099 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4100 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4102 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4103 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4105 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4106 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4109 cmdline_parse_inst_t cmd_tx_vlan_set = {
4110 .f = cmd_tx_vlan_set_parsed,
4112 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4113 "Enable hardware insertion of a single VLAN header "
4114 "with a given TAG Identifier in packets sent on a port",
4116 (void *)&cmd_tx_vlan_set_tx_vlan,
4117 (void *)&cmd_tx_vlan_set_set,
4118 (void *)&cmd_tx_vlan_set_portid,
4119 (void *)&cmd_tx_vlan_set_vlanid,
4124 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4125 struct cmd_tx_vlan_set_qinq_result {
4126 cmdline_fixed_string_t tx_vlan;
4127 cmdline_fixed_string_t set;
4130 uint16_t vlan_id_outer;
4134 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4135 __attribute__((unused)) struct cmdline *cl,
4136 __attribute__((unused)) void *data)
4138 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4140 if (!port_is_stopped(res->port_id)) {
4141 printf("Please stop port %d first\n", res->port_id);
4145 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4147 cmd_reconfig_device_queue(res->port_id, 1, 1);
4150 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4151 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4152 tx_vlan, "tx_vlan");
4153 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4154 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4156 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4157 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4159 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4160 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4162 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4163 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4164 vlan_id_outer, UINT16);
4166 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4167 .f = cmd_tx_vlan_set_qinq_parsed,
4169 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4170 "Enable hardware insertion of double VLAN header "
4171 "with given TAG Identifiers in packets sent on a port",
4173 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4174 (void *)&cmd_tx_vlan_set_qinq_set,
4175 (void *)&cmd_tx_vlan_set_qinq_portid,
4176 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4177 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4182 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4183 struct cmd_tx_vlan_set_pvid_result {
4184 cmdline_fixed_string_t tx_vlan;
4185 cmdline_fixed_string_t set;
4186 cmdline_fixed_string_t pvid;
4189 cmdline_fixed_string_t mode;
4193 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4194 __attribute__((unused)) struct cmdline *cl,
4195 __attribute__((unused)) void *data)
4197 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4199 if (strcmp(res->mode, "on") == 0)
4200 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4202 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4205 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4206 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4207 tx_vlan, "tx_vlan");
4208 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4209 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4211 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4212 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4214 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4215 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4217 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4218 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4220 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4221 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4224 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4225 .f = cmd_tx_vlan_set_pvid_parsed,
4227 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4229 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4230 (void *)&cmd_tx_vlan_set_pvid_set,
4231 (void *)&cmd_tx_vlan_set_pvid_pvid,
4232 (void *)&cmd_tx_vlan_set_pvid_port_id,
4233 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4234 (void *)&cmd_tx_vlan_set_pvid_mode,
4239 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4240 struct cmd_tx_vlan_reset_result {
4241 cmdline_fixed_string_t tx_vlan;
4242 cmdline_fixed_string_t reset;
4247 cmd_tx_vlan_reset_parsed(void *parsed_result,
4248 __attribute__((unused)) struct cmdline *cl,
4249 __attribute__((unused)) void *data)
4251 struct cmd_tx_vlan_reset_result *res = parsed_result;
4253 if (!port_is_stopped(res->port_id)) {
4254 printf("Please stop port %d first\n", res->port_id);
4258 tx_vlan_reset(res->port_id);
4260 cmd_reconfig_device_queue(res->port_id, 1, 1);
4263 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4264 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4265 tx_vlan, "tx_vlan");
4266 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4267 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4269 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4270 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4273 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4274 .f = cmd_tx_vlan_reset_parsed,
4276 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4277 "VLAN header in packets sent on a port",
4279 (void *)&cmd_tx_vlan_reset_tx_vlan,
4280 (void *)&cmd_tx_vlan_reset_reset,
4281 (void *)&cmd_tx_vlan_reset_portid,
4287 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4288 struct cmd_csum_result {
4289 cmdline_fixed_string_t csum;
4290 cmdline_fixed_string_t mode;
4291 cmdline_fixed_string_t proto;
4292 cmdline_fixed_string_t hwsw;
4297 csum_show(int port_id)
4299 struct rte_eth_dev_info dev_info;
4300 uint64_t tx_offloads;
4303 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4304 printf("Parse tunnel is %s\n",
4305 (ports[port_id].parse_tunnel) ? "on" : "off");
4306 printf("IP checksum offload is %s\n",
4307 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4308 printf("UDP checksum offload is %s\n",
4309 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4310 printf("TCP checksum offload is %s\n",
4311 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4312 printf("SCTP checksum offload is %s\n",
4313 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4314 printf("Outer-Ip checksum offload is %s\n",
4315 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4316 printf("Outer-Udp checksum offload is %s\n",
4317 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4319 /* display warnings if configuration is not supported by the NIC */
4320 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4324 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4325 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4326 printf("Warning: hardware IP checksum enabled but not "
4327 "supported by port %d\n", port_id);
4329 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4330 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4331 printf("Warning: hardware UDP checksum enabled but not "
4332 "supported by port %d\n", port_id);
4334 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4335 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4336 printf("Warning: hardware TCP checksum enabled but not "
4337 "supported by port %d\n", port_id);
4339 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4340 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4341 printf("Warning: hardware SCTP checksum enabled but not "
4342 "supported by port %d\n", port_id);
4344 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4345 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4346 printf("Warning: hardware outer IP checksum enabled but not "
4347 "supported by port %d\n", port_id);
4349 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4350 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4352 printf("Warning: hardware outer UDP checksum enabled but not "
4353 "supported by port %d\n", port_id);
4358 cmd_config_queue_tx_offloads(struct rte_port *port)
4362 /* Apply queue tx offloads configuration */
4363 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4364 port->tx_conf[k].offloads =
4365 port->dev_conf.txmode.offloads;
4369 cmd_csum_parsed(void *parsed_result,
4370 __attribute__((unused)) struct cmdline *cl,
4371 __attribute__((unused)) void *data)
4373 struct cmd_csum_result *res = parsed_result;
4375 uint64_t csum_offloads = 0;
4376 struct rte_eth_dev_info dev_info;
4379 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4380 printf("invalid port %d\n", res->port_id);
4383 if (!port_is_stopped(res->port_id)) {
4384 printf("Please stop port %d first\n", res->port_id);
4388 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4392 if (!strcmp(res->mode, "set")) {
4394 if (!strcmp(res->hwsw, "hw"))
4397 if (!strcmp(res->proto, "ip")) {
4398 if (hw == 0 || (dev_info.tx_offload_capa &
4399 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4400 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4402 printf("IP checksum offload is not supported "
4403 "by port %u\n", res->port_id);
4405 } else if (!strcmp(res->proto, "udp")) {
4406 if (hw == 0 || (dev_info.tx_offload_capa &
4407 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4408 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4410 printf("UDP checksum offload is not supported "
4411 "by port %u\n", res->port_id);
4413 } else if (!strcmp(res->proto, "tcp")) {
4414 if (hw == 0 || (dev_info.tx_offload_capa &
4415 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4416 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4418 printf("TCP checksum offload is not supported "
4419 "by port %u\n", res->port_id);
4421 } else if (!strcmp(res->proto, "sctp")) {
4422 if (hw == 0 || (dev_info.tx_offload_capa &
4423 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4424 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4426 printf("SCTP checksum offload is not supported "
4427 "by port %u\n", res->port_id);
4429 } else if (!strcmp(res->proto, "outer-ip")) {
4430 if (hw == 0 || (dev_info.tx_offload_capa &
4431 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4433 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4435 printf("Outer IP checksum offload is not "
4436 "supported by port %u\n", res->port_id);
4438 } else if (!strcmp(res->proto, "outer-udp")) {
4439 if (hw == 0 || (dev_info.tx_offload_capa &
4440 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4442 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4444 printf("Outer UDP checksum offload is not "
4445 "supported by port %u\n", res->port_id);
4450 ports[res->port_id].dev_conf.txmode.offloads |=
4453 ports[res->port_id].dev_conf.txmode.offloads &=
4456 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4458 csum_show(res->port_id);
4460 cmd_reconfig_device_queue(res->port_id, 1, 1);
4463 cmdline_parse_token_string_t cmd_csum_csum =
4464 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4466 cmdline_parse_token_string_t cmd_csum_mode =
4467 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4469 cmdline_parse_token_string_t cmd_csum_proto =
4470 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4471 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4472 cmdline_parse_token_string_t cmd_csum_hwsw =
4473 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4475 cmdline_parse_token_num_t cmd_csum_portid =
4476 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4479 cmdline_parse_inst_t cmd_csum_set = {
4480 .f = cmd_csum_parsed,
4482 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4483 "Enable/Disable hardware calculation of L3/L4 checksum when "
4484 "using csum forward engine",
4486 (void *)&cmd_csum_csum,
4487 (void *)&cmd_csum_mode,
4488 (void *)&cmd_csum_proto,
4489 (void *)&cmd_csum_hwsw,
4490 (void *)&cmd_csum_portid,
4495 cmdline_parse_token_string_t cmd_csum_mode_show =
4496 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4499 cmdline_parse_inst_t cmd_csum_show = {
4500 .f = cmd_csum_parsed,
4502 .help_str = "csum show <port_id>: Show checksum offload configuration",
4504 (void *)&cmd_csum_csum,
4505 (void *)&cmd_csum_mode_show,
4506 (void *)&cmd_csum_portid,
4511 /* Enable/disable tunnel parsing */
4512 struct cmd_csum_tunnel_result {
4513 cmdline_fixed_string_t csum;
4514 cmdline_fixed_string_t parse;
4515 cmdline_fixed_string_t onoff;
4520 cmd_csum_tunnel_parsed(void *parsed_result,
4521 __attribute__((unused)) struct cmdline *cl,
4522 __attribute__((unused)) void *data)
4524 struct cmd_csum_tunnel_result *res = parsed_result;
4526 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4529 if (!strcmp(res->onoff, "on"))
4530 ports[res->port_id].parse_tunnel = 1;
4532 ports[res->port_id].parse_tunnel = 0;
4534 csum_show(res->port_id);
4537 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4538 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4540 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4541 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4542 parse, "parse-tunnel");
4543 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4544 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4546 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4547 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4550 cmdline_parse_inst_t cmd_csum_tunnel = {
4551 .f = cmd_csum_tunnel_parsed,
4553 .help_str = "csum parse-tunnel on|off <port_id>: "
4554 "Enable/Disable parsing of tunnels for csum engine",
4556 (void *)&cmd_csum_tunnel_csum,
4557 (void *)&cmd_csum_tunnel_parse,
4558 (void *)&cmd_csum_tunnel_onoff,
4559 (void *)&cmd_csum_tunnel_portid,
4564 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4565 struct cmd_tso_set_result {
4566 cmdline_fixed_string_t tso;
4567 cmdline_fixed_string_t mode;
4573 cmd_tso_set_parsed(void *parsed_result,
4574 __attribute__((unused)) struct cmdline *cl,
4575 __attribute__((unused)) void *data)
4577 struct cmd_tso_set_result *res = parsed_result;
4578 struct rte_eth_dev_info dev_info;
4581 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4583 if (!port_is_stopped(res->port_id)) {
4584 printf("Please stop port %d first\n", res->port_id);
4588 if (!strcmp(res->mode, "set"))
4589 ports[res->port_id].tso_segsz = res->tso_segsz;
4591 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4595 if ((ports[res->port_id].tso_segsz != 0) &&
4596 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4597 printf("Error: TSO is not supported by port %d\n",
4602 if (ports[res->port_id].tso_segsz == 0) {
4603 ports[res->port_id].dev_conf.txmode.offloads &=
4604 ~DEV_TX_OFFLOAD_TCP_TSO;
4605 printf("TSO for non-tunneled packets is disabled\n");
4607 ports[res->port_id].dev_conf.txmode.offloads |=
4608 DEV_TX_OFFLOAD_TCP_TSO;
4609 printf("TSO segment size for non-tunneled packets is %d\n",
4610 ports[res->port_id].tso_segsz);
4612 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4614 /* display warnings if configuration is not supported by the NIC */
4615 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4619 if ((ports[res->port_id].tso_segsz != 0) &&
4620 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4621 printf("Warning: TSO enabled but not "
4622 "supported by port %d\n", res->port_id);
4625 cmd_reconfig_device_queue(res->port_id, 1, 1);
4628 cmdline_parse_token_string_t cmd_tso_set_tso =
4629 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4631 cmdline_parse_token_string_t cmd_tso_set_mode =
4632 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4634 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4635 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4637 cmdline_parse_token_num_t cmd_tso_set_portid =
4638 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4641 cmdline_parse_inst_t cmd_tso_set = {
4642 .f = cmd_tso_set_parsed,
4644 .help_str = "tso set <tso_segsz> <port_id>: "
4645 "Set TSO segment size of non-tunneled packets for csum engine "
4648 (void *)&cmd_tso_set_tso,
4649 (void *)&cmd_tso_set_mode,
4650 (void *)&cmd_tso_set_tso_segsz,
4651 (void *)&cmd_tso_set_portid,
4656 cmdline_parse_token_string_t cmd_tso_show_mode =
4657 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4661 cmdline_parse_inst_t cmd_tso_show = {
4662 .f = cmd_tso_set_parsed,
4664 .help_str = "tso show <port_id>: "
4665 "Show TSO segment size of non-tunneled packets for csum engine",
4667 (void *)&cmd_tso_set_tso,
4668 (void *)&cmd_tso_show_mode,
4669 (void *)&cmd_tso_set_portid,
4674 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4675 struct cmd_tunnel_tso_set_result {
4676 cmdline_fixed_string_t tso;
4677 cmdline_fixed_string_t mode;
4682 static struct rte_eth_dev_info
4683 check_tunnel_tso_nic_support(portid_t port_id)
4685 struct rte_eth_dev_info dev_info;
4687 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4690 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4691 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4692 "not enabled for port %d\n", port_id);
4693 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4694 printf("Warning: GRE TUNNEL TSO not supported therefore "
4695 "not enabled for port %d\n", port_id);
4696 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4697 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4698 "not enabled for port %d\n", port_id);
4699 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4700 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4701 "not enabled for port %d\n", port_id);
4702 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4703 printf("Warning: IP TUNNEL TSO not supported therefore "
4704 "not enabled for port %d\n", port_id);
4705 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4706 printf("Warning: UDP TUNNEL TSO not supported therefore "
4707 "not enabled for port %d\n", port_id);
4712 cmd_tunnel_tso_set_parsed(void *parsed_result,
4713 __attribute__((unused)) struct cmdline *cl,
4714 __attribute__((unused)) void *data)
4716 struct cmd_tunnel_tso_set_result *res = parsed_result;
4717 struct rte_eth_dev_info dev_info;
4719 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4721 if (!port_is_stopped(res->port_id)) {
4722 printf("Please stop port %d first\n", res->port_id);
4726 if (!strcmp(res->mode, "set"))
4727 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4729 dev_info = check_tunnel_tso_nic_support(res->port_id);
4730 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4731 ports[res->port_id].dev_conf.txmode.offloads &=
4732 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4733 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4734 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4735 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4736 DEV_TX_OFFLOAD_IP_TNL_TSO |
4737 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4738 printf("TSO for tunneled packets is disabled\n");
4740 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4741 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4742 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4743 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4744 DEV_TX_OFFLOAD_IP_TNL_TSO |
4745 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4747 ports[res->port_id].dev_conf.txmode.offloads |=
4748 (tso_offloads & dev_info.tx_offload_capa);
4749 printf("TSO segment size for tunneled packets is %d\n",
4750 ports[res->port_id].tunnel_tso_segsz);
4752 /* Below conditions are needed to make it work:
4753 * (1) tunnel TSO is supported by the NIC;
4754 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4756 * (3) for tunneled pkts with outer L3 of IPv4,
4757 * "csum set outer-ip" must be set to hw, because after tso,
4758 * total_len of outer IP header is changed, and the checksum
4759 * of outer IP header calculated by sw should be wrong; that
4760 * is not necessary for IPv6 tunneled pkts because there's no
4761 * checksum in IP header anymore.
4764 if (!ports[res->port_id].parse_tunnel)
4765 printf("Warning: csum parse_tunnel must be set "
4766 "so that tunneled packets are recognized\n");
4767 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4768 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4769 printf("Warning: csum set outer-ip must be set to hw "
4770 "if outer L3 is IPv4; not necessary for IPv6\n");
4773 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4774 cmd_reconfig_device_queue(res->port_id, 1, 1);
4777 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4778 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4780 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4781 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4783 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4784 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4786 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4787 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4790 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4791 .f = cmd_tunnel_tso_set_parsed,
4793 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4794 "Set TSO segment size of tunneled packets for csum engine "
4797 (void *)&cmd_tunnel_tso_set_tso,
4798 (void *)&cmd_tunnel_tso_set_mode,
4799 (void *)&cmd_tunnel_tso_set_tso_segsz,
4800 (void *)&cmd_tunnel_tso_set_portid,
4805 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4806 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4810 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4811 .f = cmd_tunnel_tso_set_parsed,
4813 .help_str = "tunnel_tso show <port_id> "
4814 "Show TSO segment size of tunneled packets for csum engine",
4816 (void *)&cmd_tunnel_tso_set_tso,
4817 (void *)&cmd_tunnel_tso_show_mode,
4818 (void *)&cmd_tunnel_tso_set_portid,
4823 /* *** SET GRO FOR A PORT *** */
4824 struct cmd_gro_enable_result {
4825 cmdline_fixed_string_t cmd_set;
4826 cmdline_fixed_string_t cmd_port;
4827 cmdline_fixed_string_t cmd_keyword;
4828 cmdline_fixed_string_t cmd_onoff;
4833 cmd_gro_enable_parsed(void *parsed_result,
4834 __attribute__((unused)) struct cmdline *cl,
4835 __attribute__((unused)) void *data)
4837 struct cmd_gro_enable_result *res;
4839 res = parsed_result;
4840 if (!strcmp(res->cmd_keyword, "gro"))
4841 setup_gro(res->cmd_onoff, res->cmd_pid);
4844 cmdline_parse_token_string_t cmd_gro_enable_set =
4845 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4847 cmdline_parse_token_string_t cmd_gro_enable_port =
4848 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4849 cmd_keyword, "port");
4850 cmdline_parse_token_num_t cmd_gro_enable_pid =
4851 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4853 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4854 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4855 cmd_keyword, "gro");
4856 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4857 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4858 cmd_onoff, "on#off");
4860 cmdline_parse_inst_t cmd_gro_enable = {
4861 .f = cmd_gro_enable_parsed,
4863 .help_str = "set port <port_id> gro on|off",
4865 (void *)&cmd_gro_enable_set,
4866 (void *)&cmd_gro_enable_port,
4867 (void *)&cmd_gro_enable_pid,
4868 (void *)&cmd_gro_enable_keyword,
4869 (void *)&cmd_gro_enable_onoff,
4874 /* *** DISPLAY GRO CONFIGURATION *** */
4875 struct cmd_gro_show_result {
4876 cmdline_fixed_string_t cmd_show;
4877 cmdline_fixed_string_t cmd_port;
4878 cmdline_fixed_string_t cmd_keyword;
4883 cmd_gro_show_parsed(void *parsed_result,
4884 __attribute__((unused)) struct cmdline *cl,
4885 __attribute__((unused)) void *data)
4887 struct cmd_gro_show_result *res;
4889 res = parsed_result;
4890 if (!strcmp(res->cmd_keyword, "gro"))
4891 show_gro(res->cmd_pid);
4894 cmdline_parse_token_string_t cmd_gro_show_show =
4895 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4897 cmdline_parse_token_string_t cmd_gro_show_port =
4898 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4900 cmdline_parse_token_num_t cmd_gro_show_pid =
4901 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4903 cmdline_parse_token_string_t cmd_gro_show_keyword =
4904 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4905 cmd_keyword, "gro");
4907 cmdline_parse_inst_t cmd_gro_show = {
4908 .f = cmd_gro_show_parsed,
4910 .help_str = "show port <port_id> gro",
4912 (void *)&cmd_gro_show_show,
4913 (void *)&cmd_gro_show_port,
4914 (void *)&cmd_gro_show_pid,
4915 (void *)&cmd_gro_show_keyword,
4920 /* *** SET FLUSH CYCLES FOR GRO *** */
4921 struct cmd_gro_flush_result {
4922 cmdline_fixed_string_t cmd_set;
4923 cmdline_fixed_string_t cmd_keyword;
4924 cmdline_fixed_string_t cmd_flush;
4929 cmd_gro_flush_parsed(void *parsed_result,
4930 __attribute__((unused)) struct cmdline *cl,
4931 __attribute__((unused)) void *data)
4933 struct cmd_gro_flush_result *res;
4935 res = parsed_result;
4936 if ((!strcmp(res->cmd_keyword, "gro")) &&
4937 (!strcmp(res->cmd_flush, "flush")))
4938 setup_gro_flush_cycles(res->cmd_cycles);
4941 cmdline_parse_token_string_t cmd_gro_flush_set =
4942 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4944 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4945 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4946 cmd_keyword, "gro");
4947 cmdline_parse_token_string_t cmd_gro_flush_flush =
4948 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4949 cmd_flush, "flush");
4950 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4951 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4954 cmdline_parse_inst_t cmd_gro_flush = {
4955 .f = cmd_gro_flush_parsed,
4957 .help_str = "set gro flush <cycles>",
4959 (void *)&cmd_gro_flush_set,
4960 (void *)&cmd_gro_flush_keyword,
4961 (void *)&cmd_gro_flush_flush,
4962 (void *)&cmd_gro_flush_cycles,
4967 /* *** ENABLE/DISABLE GSO *** */
4968 struct cmd_gso_enable_result {
4969 cmdline_fixed_string_t cmd_set;
4970 cmdline_fixed_string_t cmd_port;
4971 cmdline_fixed_string_t cmd_keyword;
4972 cmdline_fixed_string_t cmd_mode;
4977 cmd_gso_enable_parsed(void *parsed_result,
4978 __attribute__((unused)) struct cmdline *cl,
4979 __attribute__((unused)) void *data)
4981 struct cmd_gso_enable_result *res;
4983 res = parsed_result;
4984 if (!strcmp(res->cmd_keyword, "gso"))
4985 setup_gso(res->cmd_mode, res->cmd_pid);
4988 cmdline_parse_token_string_t cmd_gso_enable_set =
4989 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4991 cmdline_parse_token_string_t cmd_gso_enable_port =
4992 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4994 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4995 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4996 cmd_keyword, "gso");
4997 cmdline_parse_token_string_t cmd_gso_enable_mode =
4998 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4999 cmd_mode, "on#off");
5000 cmdline_parse_token_num_t cmd_gso_enable_pid =
5001 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5004 cmdline_parse_inst_t cmd_gso_enable = {
5005 .f = cmd_gso_enable_parsed,
5007 .help_str = "set port <port_id> gso on|off",
5009 (void *)&cmd_gso_enable_set,
5010 (void *)&cmd_gso_enable_port,
5011 (void *)&cmd_gso_enable_pid,
5012 (void *)&cmd_gso_enable_keyword,
5013 (void *)&cmd_gso_enable_mode,
5018 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5019 struct cmd_gso_size_result {
5020 cmdline_fixed_string_t cmd_set;
5021 cmdline_fixed_string_t cmd_keyword;
5022 cmdline_fixed_string_t cmd_segsz;
5027 cmd_gso_size_parsed(void *parsed_result,
5028 __attribute__((unused)) struct cmdline *cl,
5029 __attribute__((unused)) void *data)
5031 struct cmd_gso_size_result *res = parsed_result;
5033 if (test_done == 0) {
5034 printf("Before setting GSO segsz, please first"
5035 " stop fowarding\n");
5039 if (!strcmp(res->cmd_keyword, "gso") &&
5040 !strcmp(res->cmd_segsz, "segsz")) {
5041 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5042 printf("gso_size should be larger than %zu."
5043 " Please input a legal value\n",
5044 RTE_GSO_SEG_SIZE_MIN);
5046 gso_max_segment_size = res->cmd_size;
5050 cmdline_parse_token_string_t cmd_gso_size_set =
5051 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5053 cmdline_parse_token_string_t cmd_gso_size_keyword =
5054 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5055 cmd_keyword, "gso");
5056 cmdline_parse_token_string_t cmd_gso_size_segsz =
5057 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5058 cmd_segsz, "segsz");
5059 cmdline_parse_token_num_t cmd_gso_size_size =
5060 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5063 cmdline_parse_inst_t cmd_gso_size = {
5064 .f = cmd_gso_size_parsed,
5066 .help_str = "set gso segsz <length>",
5068 (void *)&cmd_gso_size_set,
5069 (void *)&cmd_gso_size_keyword,
5070 (void *)&cmd_gso_size_segsz,
5071 (void *)&cmd_gso_size_size,
5076 /* *** SHOW GSO CONFIGURATION *** */
5077 struct cmd_gso_show_result {
5078 cmdline_fixed_string_t cmd_show;
5079 cmdline_fixed_string_t cmd_port;
5080 cmdline_fixed_string_t cmd_keyword;
5085 cmd_gso_show_parsed(void *parsed_result,
5086 __attribute__((unused)) struct cmdline *cl,
5087 __attribute__((unused)) void *data)
5089 struct cmd_gso_show_result *res = parsed_result;
5091 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5092 printf("invalid port id %u\n", res->cmd_pid);
5095 if (!strcmp(res->cmd_keyword, "gso")) {
5096 if (gso_ports[res->cmd_pid].enable) {
5097 printf("Max GSO'd packet size: %uB\n"
5098 "Supported GSO types: TCP/IPv4, "
5099 "UDP/IPv4, VxLAN with inner "
5100 "TCP/IPv4 packet, GRE with inner "
5101 "TCP/IPv4 packet\n",
5102 gso_max_segment_size);
5104 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5108 cmdline_parse_token_string_t cmd_gso_show_show =
5109 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5111 cmdline_parse_token_string_t cmd_gso_show_port =
5112 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5114 cmdline_parse_token_string_t cmd_gso_show_keyword =
5115 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5116 cmd_keyword, "gso");
5117 cmdline_parse_token_num_t cmd_gso_show_pid =
5118 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5121 cmdline_parse_inst_t cmd_gso_show = {
5122 .f = cmd_gso_show_parsed,
5124 .help_str = "show port <port_id> gso",
5126 (void *)&cmd_gso_show_show,
5127 (void *)&cmd_gso_show_port,
5128 (void *)&cmd_gso_show_pid,
5129 (void *)&cmd_gso_show_keyword,
5134 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5135 struct cmd_set_flush_rx {
5136 cmdline_fixed_string_t set;
5137 cmdline_fixed_string_t flush_rx;
5138 cmdline_fixed_string_t mode;
5142 cmd_set_flush_rx_parsed(void *parsed_result,
5143 __attribute__((unused)) struct cmdline *cl,
5144 __attribute__((unused)) void *data)
5146 struct cmd_set_flush_rx *res = parsed_result;
5147 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5150 cmdline_parse_token_string_t cmd_setflushrx_set =
5151 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5153 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5154 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5155 flush_rx, "flush_rx");
5156 cmdline_parse_token_string_t cmd_setflushrx_mode =
5157 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5161 cmdline_parse_inst_t cmd_set_flush_rx = {
5162 .f = cmd_set_flush_rx_parsed,
5163 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5166 (void *)&cmd_setflushrx_set,
5167 (void *)&cmd_setflushrx_flush_rx,
5168 (void *)&cmd_setflushrx_mode,
5173 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5174 struct cmd_set_link_check {
5175 cmdline_fixed_string_t set;
5176 cmdline_fixed_string_t link_check;
5177 cmdline_fixed_string_t mode;
5181 cmd_set_link_check_parsed(void *parsed_result,
5182 __attribute__((unused)) struct cmdline *cl,
5183 __attribute__((unused)) void *data)
5185 struct cmd_set_link_check *res = parsed_result;
5186 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5189 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5190 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5192 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5193 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5194 link_check, "link_check");
5195 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5196 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5200 cmdline_parse_inst_t cmd_set_link_check = {
5201 .f = cmd_set_link_check_parsed,
5202 .help_str = "set link_check on|off: Enable/Disable link status check "
5203 "when starting/stopping a port",
5206 (void *)&cmd_setlinkcheck_set,
5207 (void *)&cmd_setlinkcheck_link_check,
5208 (void *)&cmd_setlinkcheck_mode,
5213 /* *** SET NIC BYPASS MODE *** */
5214 struct cmd_set_bypass_mode_result {
5215 cmdline_fixed_string_t set;
5216 cmdline_fixed_string_t bypass;
5217 cmdline_fixed_string_t mode;
5218 cmdline_fixed_string_t value;
5223 cmd_set_bypass_mode_parsed(void *parsed_result,
5224 __attribute__((unused)) struct cmdline *cl,
5225 __attribute__((unused)) void *data)
5227 struct cmd_set_bypass_mode_result *res = parsed_result;
5228 portid_t port_id = res->port_id;
5229 int32_t rc = -EINVAL;
5231 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5232 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5234 if (!strcmp(res->value, "bypass"))
5235 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5236 else if (!strcmp(res->value, "isolate"))
5237 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5239 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5241 /* Set the bypass mode for the relevant port. */
5242 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5245 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5248 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5249 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5251 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5252 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5254 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5255 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5257 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5258 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5259 value, "normal#bypass#isolate");
5260 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5261 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5264 cmdline_parse_inst_t cmd_set_bypass_mode = {
5265 .f = cmd_set_bypass_mode_parsed,
5266 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5267 "Set the NIC bypass mode for port_id",
5270 (void *)&cmd_setbypass_mode_set,
5271 (void *)&cmd_setbypass_mode_bypass,
5272 (void *)&cmd_setbypass_mode_mode,
5273 (void *)&cmd_setbypass_mode_value,
5274 (void *)&cmd_setbypass_mode_port,
5279 /* *** SET NIC BYPASS EVENT *** */
5280 struct cmd_set_bypass_event_result {
5281 cmdline_fixed_string_t set;
5282 cmdline_fixed_string_t bypass;
5283 cmdline_fixed_string_t event;
5284 cmdline_fixed_string_t event_value;
5285 cmdline_fixed_string_t mode;
5286 cmdline_fixed_string_t mode_value;
5291 cmd_set_bypass_event_parsed(void *parsed_result,
5292 __attribute__((unused)) struct cmdline *cl,
5293 __attribute__((unused)) void *data)
5295 int32_t rc = -EINVAL;
5296 struct cmd_set_bypass_event_result *res = parsed_result;
5297 portid_t port_id = res->port_id;
5299 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5300 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5301 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5303 if (!strcmp(res->event_value, "timeout"))
5304 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5305 else if (!strcmp(res->event_value, "os_on"))
5306 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5307 else if (!strcmp(res->event_value, "os_off"))
5308 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5309 else if (!strcmp(res->event_value, "power_on"))
5310 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5311 else if (!strcmp(res->event_value, "power_off"))
5312 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5314 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5316 if (!strcmp(res->mode_value, "bypass"))
5317 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5318 else if (!strcmp(res->mode_value, "isolate"))
5319 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5321 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5323 /* Set the watchdog timeout. */
5324 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5327 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5328 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5332 printf("Failed to set timeout value %u "
5333 "for port %d, errto code: %d.\n",
5334 bypass_timeout, port_id, rc);
5338 /* Set the bypass event to transition to bypass mode. */
5339 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5344 printf("\t Failed to set bypass event for port = %d.\n",
5348 cmdline_parse_token_string_t cmd_setbypass_event_set =
5349 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5351 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5352 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5354 cmdline_parse_token_string_t cmd_setbypass_event_event =
5355 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5357 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5358 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5359 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5360 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5361 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5363 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5364 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5365 mode_value, "normal#bypass#isolate");
5366 cmdline_parse_token_num_t cmd_setbypass_event_port =
5367 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5370 cmdline_parse_inst_t cmd_set_bypass_event = {
5371 .f = cmd_set_bypass_event_parsed,
5372 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5373 "power_off mode normal|bypass|isolate <port_id>: "
5374 "Set the NIC bypass event mode for port_id",
5377 (void *)&cmd_setbypass_event_set,
5378 (void *)&cmd_setbypass_event_bypass,
5379 (void *)&cmd_setbypass_event_event,
5380 (void *)&cmd_setbypass_event_event_value,
5381 (void *)&cmd_setbypass_event_mode,
5382 (void *)&cmd_setbypass_event_mode_value,
5383 (void *)&cmd_setbypass_event_port,
5389 /* *** SET NIC BYPASS TIMEOUT *** */
5390 struct cmd_set_bypass_timeout_result {
5391 cmdline_fixed_string_t set;
5392 cmdline_fixed_string_t bypass;
5393 cmdline_fixed_string_t timeout;
5394 cmdline_fixed_string_t value;
5398 cmd_set_bypass_timeout_parsed(void *parsed_result,
5399 __attribute__((unused)) struct cmdline *cl,
5400 __attribute__((unused)) void *data)
5402 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5404 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5405 if (!strcmp(res->value, "1.5"))
5406 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5407 else if (!strcmp(res->value, "2"))
5408 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5409 else if (!strcmp(res->value, "3"))
5410 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5411 else if (!strcmp(res->value, "4"))
5412 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5413 else if (!strcmp(res->value, "8"))
5414 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5415 else if (!strcmp(res->value, "16"))
5416 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5417 else if (!strcmp(res->value, "32"))
5418 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5420 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5424 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5425 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5427 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5428 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5430 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5431 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5432 timeout, "timeout");
5433 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5434 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5435 value, "0#1.5#2#3#4#8#16#32");
5437 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5438 .f = cmd_set_bypass_timeout_parsed,
5439 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5440 "Set the NIC bypass watchdog timeout in seconds",
5443 (void *)&cmd_setbypass_timeout_set,
5444 (void *)&cmd_setbypass_timeout_bypass,
5445 (void *)&cmd_setbypass_timeout_timeout,
5446 (void *)&cmd_setbypass_timeout_value,
5451 /* *** SHOW NIC BYPASS MODE *** */
5452 struct cmd_show_bypass_config_result {
5453 cmdline_fixed_string_t show;
5454 cmdline_fixed_string_t bypass;
5455 cmdline_fixed_string_t config;
5460 cmd_show_bypass_config_parsed(void *parsed_result,
5461 __attribute__((unused)) struct cmdline *cl,
5462 __attribute__((unused)) void *data)
5464 struct cmd_show_bypass_config_result *res = parsed_result;
5465 portid_t port_id = res->port_id;
5467 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5468 uint32_t event_mode;
5469 uint32_t bypass_mode;
5470 uint32_t timeout = bypass_timeout;
5473 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5474 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5475 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5476 {"UNKNOWN", "normal", "bypass", "isolate"};
5477 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5484 int num_events = (sizeof events) / (sizeof events[0]);
5486 /* Display the bypass mode.*/
5487 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5488 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5492 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5493 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5495 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5498 /* Display the bypass timeout.*/
5499 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5500 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5502 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5504 /* Display the bypass events and associated modes. */
5505 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5507 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5508 printf("\tFailed to get bypass mode for event = %s\n",
5511 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5512 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5514 printf("\tbypass event: %-16s = %s\n", events[i],
5520 printf("\tFailed to get bypass configuration for port = %d\n",
5524 cmdline_parse_token_string_t cmd_showbypass_config_show =
5525 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5527 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5528 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5530 cmdline_parse_token_string_t cmd_showbypass_config_config =
5531 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5533 cmdline_parse_token_num_t cmd_showbypass_config_port =
5534 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5537 cmdline_parse_inst_t cmd_show_bypass_config = {
5538 .f = cmd_show_bypass_config_parsed,
5539 .help_str = "show bypass config <port_id>: "
5540 "Show the NIC bypass config for port_id",
5543 (void *)&cmd_showbypass_config_show,
5544 (void *)&cmd_showbypass_config_bypass,
5545 (void *)&cmd_showbypass_config_config,
5546 (void *)&cmd_showbypass_config_port,
5551 #ifdef RTE_LIBRTE_PMD_BOND
5552 /* *** SET BONDING MODE *** */
5553 struct cmd_set_bonding_mode_result {
5554 cmdline_fixed_string_t set;
5555 cmdline_fixed_string_t bonding;
5556 cmdline_fixed_string_t mode;
5561 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5562 __attribute__((unused)) struct cmdline *cl,
5563 __attribute__((unused)) void *data)
5565 struct cmd_set_bonding_mode_result *res = parsed_result;
5566 portid_t port_id = res->port_id;
5568 /* Set the bonding mode for the relevant port. */
5569 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5570 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5573 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5574 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5576 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5577 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5578 bonding, "bonding");
5579 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5580 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5582 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5583 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5585 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5586 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5589 cmdline_parse_inst_t cmd_set_bonding_mode = {
5590 .f = cmd_set_bonding_mode_parsed,
5591 .help_str = "set bonding mode <mode_value> <port_id>: "
5592 "Set the bonding mode for port_id",
5595 (void *) &cmd_setbonding_mode_set,
5596 (void *) &cmd_setbonding_mode_bonding,
5597 (void *) &cmd_setbonding_mode_mode,
5598 (void *) &cmd_setbonding_mode_value,
5599 (void *) &cmd_setbonding_mode_port,
5604 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5605 struct cmd_set_bonding_lacp_dedicated_queues_result {
5606 cmdline_fixed_string_t set;
5607 cmdline_fixed_string_t bonding;
5608 cmdline_fixed_string_t lacp;
5609 cmdline_fixed_string_t dedicated_queues;
5611 cmdline_fixed_string_t mode;
5614 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5615 __attribute__((unused)) struct cmdline *cl,
5616 __attribute__((unused)) void *data)
5618 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5619 portid_t port_id = res->port_id;
5620 struct rte_port *port;
5622 port = &ports[port_id];
5624 /** Check if the port is not started **/
5625 if (port->port_status != RTE_PORT_STOPPED) {
5626 printf("Please stop port %d first\n", port_id);
5630 if (!strcmp(res->mode, "enable")) {
5631 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5632 printf("Dedicate queues for LACP control packets"
5635 printf("Enabling dedicate queues for LACP control "
5636 "packets on port %d failed\n", port_id);
5637 } else if (!strcmp(res->mode, "disable")) {
5638 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5639 printf("Dedicated queues for LACP control packets "
5642 printf("Disabling dedicated queues for LACP control "
5643 "traffic on port %d failed\n", port_id);
5647 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5648 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5650 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5651 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5652 bonding, "bonding");
5653 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5654 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5656 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5657 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5658 dedicated_queues, "dedicated_queues");
5659 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5660 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5662 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5663 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5664 mode, "enable#disable");
5666 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5667 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5668 .help_str = "set bonding lacp dedicated_queues <port_id> "
5670 "Enable/disable dedicated queues for LACP control traffic for port_id",
5673 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5674 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5675 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5676 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5677 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5678 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5683 /* *** SET BALANCE XMIT POLICY *** */
5684 struct cmd_set_bonding_balance_xmit_policy_result {
5685 cmdline_fixed_string_t set;
5686 cmdline_fixed_string_t bonding;
5687 cmdline_fixed_string_t balance_xmit_policy;
5689 cmdline_fixed_string_t policy;
5692 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5693 __attribute__((unused)) struct cmdline *cl,
5694 __attribute__((unused)) void *data)
5696 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5697 portid_t port_id = res->port_id;
5700 if (!strcmp(res->policy, "l2")) {
5701 policy = BALANCE_XMIT_POLICY_LAYER2;
5702 } else if (!strcmp(res->policy, "l23")) {
5703 policy = BALANCE_XMIT_POLICY_LAYER23;
5704 } else if (!strcmp(res->policy, "l34")) {
5705 policy = BALANCE_XMIT_POLICY_LAYER34;
5707 printf("\t Invalid xmit policy selection");
5711 /* Set the bonding mode for the relevant port. */
5712 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5713 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5718 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5719 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5721 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5722 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5723 bonding, "bonding");
5724 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5725 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5726 balance_xmit_policy, "balance_xmit_policy");
5727 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5728 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5730 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5731 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5732 policy, "l2#l23#l34");
5734 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5735 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5736 .help_str = "set bonding balance_xmit_policy <port_id> "
5738 "Set the bonding balance_xmit_policy for port_id",
5741 (void *)&cmd_setbonding_balance_xmit_policy_set,
5742 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5743 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5744 (void *)&cmd_setbonding_balance_xmit_policy_port,
5745 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5750 /* *** SHOW NIC BONDING CONFIGURATION *** */
5751 struct cmd_show_bonding_config_result {
5752 cmdline_fixed_string_t show;
5753 cmdline_fixed_string_t bonding;
5754 cmdline_fixed_string_t config;
5758 static void cmd_show_bonding_config_parsed(void *parsed_result,
5759 __attribute__((unused)) struct cmdline *cl,
5760 __attribute__((unused)) void *data)
5762 struct cmd_show_bonding_config_result *res = parsed_result;
5763 int bonding_mode, agg_mode;
5764 portid_t slaves[RTE_MAX_ETHPORTS];
5765 int num_slaves, num_active_slaves;
5768 portid_t port_id = res->port_id;
5770 /* Display the bonding mode.*/
5771 bonding_mode = rte_eth_bond_mode_get(port_id);
5772 if (bonding_mode < 0) {
5773 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5776 printf("\tBonding mode: %d\n", bonding_mode);
5778 if (bonding_mode == BONDING_MODE_BALANCE) {
5779 int balance_xmit_policy;
5781 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5782 if (balance_xmit_policy < 0) {
5783 printf("\tFailed to get balance xmit policy for port = %d\n",
5787 printf("\tBalance Xmit Policy: ");
5789 switch (balance_xmit_policy) {
5790 case BALANCE_XMIT_POLICY_LAYER2:
5791 printf("BALANCE_XMIT_POLICY_LAYER2");
5793 case BALANCE_XMIT_POLICY_LAYER23:
5794 printf("BALANCE_XMIT_POLICY_LAYER23");
5796 case BALANCE_XMIT_POLICY_LAYER34:
5797 printf("BALANCE_XMIT_POLICY_LAYER34");
5804 if (bonding_mode == BONDING_MODE_8023AD) {
5805 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5806 printf("\tIEEE802.3AD Aggregator Mode: ");
5809 printf("bandwidth");
5821 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5823 if (num_slaves < 0) {
5824 printf("\tFailed to get slave list for port = %d\n", port_id);
5827 if (num_slaves > 0) {
5828 printf("\tSlaves (%d): [", num_slaves);
5829 for (i = 0; i < num_slaves - 1; i++)
5830 printf("%d ", slaves[i]);
5832 printf("%d]\n", slaves[num_slaves - 1]);
5834 printf("\tSlaves: []\n");
5838 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5841 if (num_active_slaves < 0) {
5842 printf("\tFailed to get active slave list for port = %d\n", port_id);
5845 if (num_active_slaves > 0) {
5846 printf("\tActive Slaves (%d): [", num_active_slaves);
5847 for (i = 0; i < num_active_slaves - 1; i++)
5848 printf("%d ", slaves[i]);
5850 printf("%d]\n", slaves[num_active_slaves - 1]);
5853 printf("\tActive Slaves: []\n");
5857 primary_id = rte_eth_bond_primary_get(port_id);
5858 if (primary_id < 0) {
5859 printf("\tFailed to get primary slave for port = %d\n", port_id);
5862 printf("\tPrimary: [%d]\n", primary_id);
5866 cmdline_parse_token_string_t cmd_showbonding_config_show =
5867 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5869 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5870 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5871 bonding, "bonding");
5872 cmdline_parse_token_string_t cmd_showbonding_config_config =
5873 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5875 cmdline_parse_token_num_t cmd_showbonding_config_port =
5876 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5879 cmdline_parse_inst_t cmd_show_bonding_config = {
5880 .f = cmd_show_bonding_config_parsed,
5881 .help_str = "show bonding config <port_id>: "
5882 "Show the bonding config for port_id",
5885 (void *)&cmd_showbonding_config_show,
5886 (void *)&cmd_showbonding_config_bonding,
5887 (void *)&cmd_showbonding_config_config,
5888 (void *)&cmd_showbonding_config_port,
5893 /* *** SET BONDING PRIMARY *** */
5894 struct cmd_set_bonding_primary_result {
5895 cmdline_fixed_string_t set;
5896 cmdline_fixed_string_t bonding;
5897 cmdline_fixed_string_t primary;
5902 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5903 __attribute__((unused)) struct cmdline *cl,
5904 __attribute__((unused)) void *data)
5906 struct cmd_set_bonding_primary_result *res = parsed_result;
5907 portid_t master_port_id = res->port_id;
5908 portid_t slave_port_id = res->slave_id;
5910 /* Set the primary slave for a bonded device. */
5911 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5912 printf("\t Failed to set primary slave for port = %d.\n",
5919 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5920 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5922 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5923 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5924 bonding, "bonding");
5925 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5926 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5927 primary, "primary");
5928 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5929 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5931 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5932 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5935 cmdline_parse_inst_t cmd_set_bonding_primary = {
5936 .f = cmd_set_bonding_primary_parsed,
5937 .help_str = "set bonding primary <slave_id> <port_id>: "
5938 "Set the primary slave for port_id",
5941 (void *)&cmd_setbonding_primary_set,
5942 (void *)&cmd_setbonding_primary_bonding,
5943 (void *)&cmd_setbonding_primary_primary,
5944 (void *)&cmd_setbonding_primary_slave,
5945 (void *)&cmd_setbonding_primary_port,
5950 /* *** ADD SLAVE *** */
5951 struct cmd_add_bonding_slave_result {
5952 cmdline_fixed_string_t add;
5953 cmdline_fixed_string_t bonding;
5954 cmdline_fixed_string_t slave;
5959 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5960 __attribute__((unused)) struct cmdline *cl,
5961 __attribute__((unused)) void *data)
5963 struct cmd_add_bonding_slave_result *res = parsed_result;
5964 portid_t master_port_id = res->port_id;
5965 portid_t slave_port_id = res->slave_id;
5967 /* add the slave for a bonded device. */
5968 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5969 printf("\t Failed to add slave %d to master port = %d.\n",
5970 slave_port_id, master_port_id);
5974 set_port_slave_flag(slave_port_id);
5977 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5978 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5980 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5981 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5982 bonding, "bonding");
5983 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5984 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5986 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5987 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5989 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5990 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5993 cmdline_parse_inst_t cmd_add_bonding_slave = {
5994 .f = cmd_add_bonding_slave_parsed,
5995 .help_str = "add bonding slave <slave_id> <port_id>: "
5996 "Add a slave device to a bonded device",
5999 (void *)&cmd_addbonding_slave_add,
6000 (void *)&cmd_addbonding_slave_bonding,
6001 (void *)&cmd_addbonding_slave_slave,
6002 (void *)&cmd_addbonding_slave_slaveid,
6003 (void *)&cmd_addbonding_slave_port,
6008 /* *** REMOVE SLAVE *** */
6009 struct cmd_remove_bonding_slave_result {
6010 cmdline_fixed_string_t remove;
6011 cmdline_fixed_string_t bonding;
6012 cmdline_fixed_string_t slave;
6017 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6018 __attribute__((unused)) struct cmdline *cl,
6019 __attribute__((unused)) void *data)
6021 struct cmd_remove_bonding_slave_result *res = parsed_result;
6022 portid_t master_port_id = res->port_id;
6023 portid_t slave_port_id = res->slave_id;
6025 /* remove the slave from a bonded device. */
6026 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6027 printf("\t Failed to remove slave %d from master port = %d.\n",
6028 slave_port_id, master_port_id);
6032 clear_port_slave_flag(slave_port_id);
6035 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6036 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6038 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6039 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6040 bonding, "bonding");
6041 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6042 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6044 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6045 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6047 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6048 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6051 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6052 .f = cmd_remove_bonding_slave_parsed,
6053 .help_str = "remove bonding slave <slave_id> <port_id>: "
6054 "Remove a slave device from a bonded device",
6057 (void *)&cmd_removebonding_slave_remove,
6058 (void *)&cmd_removebonding_slave_bonding,
6059 (void *)&cmd_removebonding_slave_slave,
6060 (void *)&cmd_removebonding_slave_slaveid,
6061 (void *)&cmd_removebonding_slave_port,
6066 /* *** CREATE BONDED DEVICE *** */
6067 struct cmd_create_bonded_device_result {
6068 cmdline_fixed_string_t create;
6069 cmdline_fixed_string_t bonded;
6070 cmdline_fixed_string_t device;
6075 static int bond_dev_num = 0;
6077 static void cmd_create_bonded_device_parsed(void *parsed_result,
6078 __attribute__((unused)) struct cmdline *cl,
6079 __attribute__((unused)) void *data)
6081 struct cmd_create_bonded_device_result *res = parsed_result;
6082 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6086 if (test_done == 0) {
6087 printf("Please stop forwarding first\n");
6091 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6094 /* Create a new bonded device. */
6095 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6097 printf("\t Failed to create bonded device.\n");
6100 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6103 /* Update number of ports */
6104 nb_ports = rte_eth_dev_count_avail();
6105 reconfig(port_id, res->socket);
6106 ret = rte_eth_promiscuous_enable(port_id);
6108 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6109 port_id, rte_strerror(-ret));
6111 ports[port_id].need_setup = 0;
6112 ports[port_id].port_status = RTE_PORT_STOPPED;
6117 cmdline_parse_token_string_t cmd_createbonded_device_create =
6118 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6120 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6121 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6123 cmdline_parse_token_string_t cmd_createbonded_device_device =
6124 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6126 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6127 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6129 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6130 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6133 cmdline_parse_inst_t cmd_create_bonded_device = {
6134 .f = cmd_create_bonded_device_parsed,
6135 .help_str = "create bonded device <mode> <socket>: "
6136 "Create a new bonded device with specific bonding mode and socket",
6139 (void *)&cmd_createbonded_device_create,
6140 (void *)&cmd_createbonded_device_bonded,
6141 (void *)&cmd_createbonded_device_device,
6142 (void *)&cmd_createbonded_device_mode,
6143 (void *)&cmd_createbonded_device_socket,
6148 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6149 struct cmd_set_bond_mac_addr_result {
6150 cmdline_fixed_string_t set;
6151 cmdline_fixed_string_t bonding;
6152 cmdline_fixed_string_t mac_addr;
6154 struct rte_ether_addr address;
6157 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6158 __attribute__((unused)) struct cmdline *cl,
6159 __attribute__((unused)) void *data)
6161 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6164 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6167 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6169 /* check the return value and print it if is < 0 */
6171 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6174 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6175 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6176 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6177 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6179 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6180 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6182 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6183 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6185 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6186 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6188 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6189 .f = cmd_set_bond_mac_addr_parsed,
6191 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6193 (void *)&cmd_set_bond_mac_addr_set,
6194 (void *)&cmd_set_bond_mac_addr_bonding,
6195 (void *)&cmd_set_bond_mac_addr_mac,
6196 (void *)&cmd_set_bond_mac_addr_portnum,
6197 (void *)&cmd_set_bond_mac_addr_addr,
6203 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6204 struct cmd_set_bond_mon_period_result {
6205 cmdline_fixed_string_t set;
6206 cmdline_fixed_string_t bonding;
6207 cmdline_fixed_string_t mon_period;
6212 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6213 __attribute__((unused)) struct cmdline *cl,
6214 __attribute__((unused)) void *data)
6216 struct cmd_set_bond_mon_period_result *res = parsed_result;
6219 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6221 /* check the return value and print it if is < 0 */
6223 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6226 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6227 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6229 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6230 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6231 bonding, "bonding");
6232 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6233 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6234 mon_period, "mon_period");
6235 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6236 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6238 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6239 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6242 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6243 .f = cmd_set_bond_mon_period_parsed,
6245 .help_str = "set bonding mon_period <port_id> <period_ms>",
6247 (void *)&cmd_set_bond_mon_period_set,
6248 (void *)&cmd_set_bond_mon_period_bonding,
6249 (void *)&cmd_set_bond_mon_period_mon_period,
6250 (void *)&cmd_set_bond_mon_period_portnum,
6251 (void *)&cmd_set_bond_mon_period_period_ms,
6258 struct cmd_set_bonding_agg_mode_policy_result {
6259 cmdline_fixed_string_t set;
6260 cmdline_fixed_string_t bonding;
6261 cmdline_fixed_string_t agg_mode;
6263 cmdline_fixed_string_t policy;
6268 cmd_set_bonding_agg_mode(void *parsed_result,
6269 __attribute__((unused)) struct cmdline *cl,
6270 __attribute__((unused)) void *data)
6272 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6273 uint8_t policy = AGG_BANDWIDTH;
6275 if (!strcmp(res->policy, "bandwidth"))
6276 policy = AGG_BANDWIDTH;
6277 else if (!strcmp(res->policy, "stable"))
6278 policy = AGG_STABLE;
6279 else if (!strcmp(res->policy, "count"))
6282 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6286 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6287 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6289 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6290 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6291 bonding, "bonding");
6293 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6294 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6295 agg_mode, "agg_mode");
6297 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6298 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6301 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6302 TOKEN_STRING_INITIALIZER(
6303 struct cmd_set_bonding_balance_xmit_policy_result,
6304 policy, "stable#bandwidth#count");
6306 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6307 .f = cmd_set_bonding_agg_mode,
6309 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6311 (void *)&cmd_set_bonding_agg_mode_set,
6312 (void *)&cmd_set_bonding_agg_mode_bonding,
6313 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6314 (void *)&cmd_set_bonding_agg_mode_portnum,
6315 (void *)&cmd_set_bonding_agg_mode_policy_string,
6321 #endif /* RTE_LIBRTE_PMD_BOND */
6323 /* *** SET FORWARDING MODE *** */
6324 struct cmd_set_fwd_mode_result {
6325 cmdline_fixed_string_t set;
6326 cmdline_fixed_string_t fwd;
6327 cmdline_fixed_string_t mode;
6330 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6331 __attribute__((unused)) struct cmdline *cl,
6332 __attribute__((unused)) void *data)
6334 struct cmd_set_fwd_mode_result *res = parsed_result;
6337 set_pkt_forwarding_mode(res->mode);
6340 cmdline_parse_token_string_t cmd_setfwd_set =
6341 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6342 cmdline_parse_token_string_t cmd_setfwd_fwd =
6343 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6344 cmdline_parse_token_string_t cmd_setfwd_mode =
6345 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6346 "" /* defined at init */);
6348 cmdline_parse_inst_t cmd_set_fwd_mode = {
6349 .f = cmd_set_fwd_mode_parsed,
6351 .help_str = NULL, /* defined at init */
6353 (void *)&cmd_setfwd_set,
6354 (void *)&cmd_setfwd_fwd,
6355 (void *)&cmd_setfwd_mode,
6360 static void cmd_set_fwd_mode_init(void)
6363 static char token[128];
6364 static char help[256];
6365 cmdline_parse_token_string_t *token_struct;
6367 modes = list_pkt_forwarding_modes();
6368 snprintf(help, sizeof(help), "set fwd %s: "
6369 "Set packet forwarding mode", modes);
6370 cmd_set_fwd_mode.help_str = help;
6372 /* string token separator is # */
6373 for (c = token; *modes != '\0'; modes++)
6378 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6379 token_struct->string_data.str = token;
6382 /* *** SET RETRY FORWARDING MODE *** */
6383 struct cmd_set_fwd_retry_mode_result {
6384 cmdline_fixed_string_t set;
6385 cmdline_fixed_string_t fwd;
6386 cmdline_fixed_string_t mode;
6387 cmdline_fixed_string_t retry;
6390 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6391 __attribute__((unused)) struct cmdline *cl,
6392 __attribute__((unused)) void *data)
6394 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6397 set_pkt_forwarding_mode(res->mode);
6400 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6401 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6403 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6404 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6406 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6407 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6409 "" /* defined at init */);
6410 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6411 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6414 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6415 .f = cmd_set_fwd_retry_mode_parsed,
6417 .help_str = NULL, /* defined at init */
6419 (void *)&cmd_setfwd_retry_set,
6420 (void *)&cmd_setfwd_retry_fwd,
6421 (void *)&cmd_setfwd_retry_mode,
6422 (void *)&cmd_setfwd_retry_retry,
6427 static void cmd_set_fwd_retry_mode_init(void)
6430 static char token[128];
6431 static char help[256];
6432 cmdline_parse_token_string_t *token_struct;
6434 modes = list_pkt_forwarding_retry_modes();
6435 snprintf(help, sizeof(help), "set fwd %s retry: "
6436 "Set packet forwarding mode with retry", modes);
6437 cmd_set_fwd_retry_mode.help_str = help;
6439 /* string token separator is # */
6440 for (c = token; *modes != '\0'; modes++)
6445 token_struct = (cmdline_parse_token_string_t *)
6446 cmd_set_fwd_retry_mode.tokens[2];
6447 token_struct->string_data.str = token;
6450 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6451 struct cmd_set_burst_tx_retry_result {
6452 cmdline_fixed_string_t set;
6453 cmdline_fixed_string_t burst;
6454 cmdline_fixed_string_t tx;
6455 cmdline_fixed_string_t delay;
6457 cmdline_fixed_string_t retry;
6461 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6462 __attribute__((unused)) struct cmdline *cl,
6463 __attribute__((unused)) void *data)
6465 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6467 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6468 && !strcmp(res->tx, "tx")) {
6469 if (!strcmp(res->delay, "delay"))
6470 burst_tx_delay_time = res->time;
6471 if (!strcmp(res->retry, "retry"))
6472 burst_tx_retry_num = res->retry_num;
6477 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6478 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6479 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6480 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6482 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6483 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6484 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6485 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6486 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6487 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6488 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6489 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6490 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6491 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6493 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6494 .f = cmd_set_burst_tx_retry_parsed,
6495 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6497 (void *)&cmd_set_burst_tx_retry_set,
6498 (void *)&cmd_set_burst_tx_retry_burst,
6499 (void *)&cmd_set_burst_tx_retry_tx,
6500 (void *)&cmd_set_burst_tx_retry_delay,
6501 (void *)&cmd_set_burst_tx_retry_time,
6502 (void *)&cmd_set_burst_tx_retry_retry,
6503 (void *)&cmd_set_burst_tx_retry_retry_num,
6508 /* *** SET PROMISC MODE *** */
6509 struct cmd_set_promisc_mode_result {
6510 cmdline_fixed_string_t set;
6511 cmdline_fixed_string_t promisc;
6512 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6513 uint16_t port_num; /* valid if "allports" argument == 0 */
6514 cmdline_fixed_string_t mode;
6517 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6518 __attribute__((unused)) struct cmdline *cl,
6521 struct cmd_set_promisc_mode_result *res = parsed_result;
6525 if (!strcmp(res->mode, "on"))
6532 RTE_ETH_FOREACH_DEV(i)
6533 eth_set_promisc_mode(i, enable);
6535 eth_set_promisc_mode(res->port_num, enable);
6539 cmdline_parse_token_string_t cmd_setpromisc_set =
6540 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6541 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6542 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6544 cmdline_parse_token_string_t cmd_setpromisc_portall =
6545 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6547 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6548 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6550 cmdline_parse_token_string_t cmd_setpromisc_mode =
6551 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6554 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6555 .f = cmd_set_promisc_mode_parsed,
6557 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6559 (void *)&cmd_setpromisc_set,
6560 (void *)&cmd_setpromisc_promisc,
6561 (void *)&cmd_setpromisc_portall,
6562 (void *)&cmd_setpromisc_mode,
6567 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6568 .f = cmd_set_promisc_mode_parsed,
6570 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6572 (void *)&cmd_setpromisc_set,
6573 (void *)&cmd_setpromisc_promisc,
6574 (void *)&cmd_setpromisc_portnum,
6575 (void *)&cmd_setpromisc_mode,
6580 /* *** SET ALLMULTI MODE *** */
6581 struct cmd_set_allmulti_mode_result {
6582 cmdline_fixed_string_t set;
6583 cmdline_fixed_string_t allmulti;
6584 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6585 uint16_t port_num; /* valid if "allports" argument == 0 */
6586 cmdline_fixed_string_t mode;
6589 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6590 __attribute__((unused)) struct cmdline *cl,
6593 struct cmd_set_allmulti_mode_result *res = parsed_result;
6597 if (!strcmp(res->mode, "on"))
6604 RTE_ETH_FOREACH_DEV(i) {
6605 eth_set_allmulticast_mode(i, enable);
6609 eth_set_allmulticast_mode(res->port_num, enable);
6613 cmdline_parse_token_string_t cmd_setallmulti_set =
6614 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6615 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6616 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6618 cmdline_parse_token_string_t cmd_setallmulti_portall =
6619 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6621 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6622 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6624 cmdline_parse_token_string_t cmd_setallmulti_mode =
6625 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6628 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6629 .f = cmd_set_allmulti_mode_parsed,
6631 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6633 (void *)&cmd_setallmulti_set,
6634 (void *)&cmd_setallmulti_allmulti,
6635 (void *)&cmd_setallmulti_portall,
6636 (void *)&cmd_setallmulti_mode,
6641 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6642 .f = cmd_set_allmulti_mode_parsed,
6644 .help_str = "set allmulti <port_id> on|off: "
6645 "Set allmulti mode on port_id",
6647 (void *)&cmd_setallmulti_set,
6648 (void *)&cmd_setallmulti_allmulti,
6649 (void *)&cmd_setallmulti_portnum,
6650 (void *)&cmd_setallmulti_mode,
6655 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6656 struct cmd_link_flow_ctrl_set_result {
6657 cmdline_fixed_string_t set;
6658 cmdline_fixed_string_t flow_ctrl;
6659 cmdline_fixed_string_t rx;
6660 cmdline_fixed_string_t rx_lfc_mode;
6661 cmdline_fixed_string_t tx;
6662 cmdline_fixed_string_t tx_lfc_mode;
6663 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6664 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6665 cmdline_fixed_string_t autoneg_str;
6666 cmdline_fixed_string_t autoneg;
6667 cmdline_fixed_string_t hw_str;
6668 uint32_t high_water;
6669 cmdline_fixed_string_t lw_str;
6671 cmdline_fixed_string_t pt_str;
6672 uint16_t pause_time;
6673 cmdline_fixed_string_t xon_str;
6678 cmdline_parse_token_string_t cmd_lfc_set_set =
6679 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6681 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6682 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6683 flow_ctrl, "flow_ctrl");
6684 cmdline_parse_token_string_t cmd_lfc_set_rx =
6685 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6687 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6688 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6689 rx_lfc_mode, "on#off");
6690 cmdline_parse_token_string_t cmd_lfc_set_tx =
6691 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6693 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6694 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6695 tx_lfc_mode, "on#off");
6696 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6697 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6698 hw_str, "high_water");
6699 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6700 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6701 high_water, UINT32);
6702 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6703 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6704 lw_str, "low_water");
6705 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6706 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6708 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6709 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6710 pt_str, "pause_time");
6711 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6712 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6713 pause_time, UINT16);
6714 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6715 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6716 xon_str, "send_xon");
6717 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6718 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6720 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6721 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6722 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6723 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6724 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6725 mac_ctrl_frame_fwd_mode, "on#off");
6726 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6727 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6728 autoneg_str, "autoneg");
6729 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6730 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6732 cmdline_parse_token_num_t cmd_lfc_set_portid =
6733 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6736 /* forward declaration */
6738 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6741 cmdline_parse_inst_t cmd_link_flow_control_set = {
6742 .f = cmd_link_flow_ctrl_set_parsed,
6744 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6745 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6746 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6748 (void *)&cmd_lfc_set_set,
6749 (void *)&cmd_lfc_set_flow_ctrl,
6750 (void *)&cmd_lfc_set_rx,
6751 (void *)&cmd_lfc_set_rx_mode,
6752 (void *)&cmd_lfc_set_tx,
6753 (void *)&cmd_lfc_set_tx_mode,
6754 (void *)&cmd_lfc_set_high_water,
6755 (void *)&cmd_lfc_set_low_water,
6756 (void *)&cmd_lfc_set_pause_time,
6757 (void *)&cmd_lfc_set_send_xon,
6758 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6759 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6760 (void *)&cmd_lfc_set_autoneg_str,
6761 (void *)&cmd_lfc_set_autoneg,
6762 (void *)&cmd_lfc_set_portid,
6767 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6768 .f = cmd_link_flow_ctrl_set_parsed,
6769 .data = (void *)&cmd_link_flow_control_set_rx,
6770 .help_str = "set flow_ctrl rx on|off <port_id>: "
6771 "Change rx flow control parameter",
6773 (void *)&cmd_lfc_set_set,
6774 (void *)&cmd_lfc_set_flow_ctrl,
6775 (void *)&cmd_lfc_set_rx,
6776 (void *)&cmd_lfc_set_rx_mode,
6777 (void *)&cmd_lfc_set_portid,
6782 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6783 .f = cmd_link_flow_ctrl_set_parsed,
6784 .data = (void *)&cmd_link_flow_control_set_tx,
6785 .help_str = "set flow_ctrl tx on|off <port_id>: "
6786 "Change tx flow control parameter",
6788 (void *)&cmd_lfc_set_set,
6789 (void *)&cmd_lfc_set_flow_ctrl,
6790 (void *)&cmd_lfc_set_tx,
6791 (void *)&cmd_lfc_set_tx_mode,
6792 (void *)&cmd_lfc_set_portid,
6797 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6798 .f = cmd_link_flow_ctrl_set_parsed,
6799 .data = (void *)&cmd_link_flow_control_set_hw,
6800 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6801 "Change high water flow control parameter",
6803 (void *)&cmd_lfc_set_set,
6804 (void *)&cmd_lfc_set_flow_ctrl,
6805 (void *)&cmd_lfc_set_high_water_str,
6806 (void *)&cmd_lfc_set_high_water,
6807 (void *)&cmd_lfc_set_portid,
6812 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6813 .f = cmd_link_flow_ctrl_set_parsed,
6814 .data = (void *)&cmd_link_flow_control_set_lw,
6815 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6816 "Change low water flow control parameter",
6818 (void *)&cmd_lfc_set_set,
6819 (void *)&cmd_lfc_set_flow_ctrl,
6820 (void *)&cmd_lfc_set_low_water_str,
6821 (void *)&cmd_lfc_set_low_water,
6822 (void *)&cmd_lfc_set_portid,
6827 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6828 .f = cmd_link_flow_ctrl_set_parsed,
6829 .data = (void *)&cmd_link_flow_control_set_pt,
6830 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6831 "Change pause time flow control parameter",
6833 (void *)&cmd_lfc_set_set,
6834 (void *)&cmd_lfc_set_flow_ctrl,
6835 (void *)&cmd_lfc_set_pause_time_str,
6836 (void *)&cmd_lfc_set_pause_time,
6837 (void *)&cmd_lfc_set_portid,
6842 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6843 .f = cmd_link_flow_ctrl_set_parsed,
6844 .data = (void *)&cmd_link_flow_control_set_xon,
6845 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6846 "Change send_xon flow control parameter",
6848 (void *)&cmd_lfc_set_set,
6849 (void *)&cmd_lfc_set_flow_ctrl,
6850 (void *)&cmd_lfc_set_send_xon_str,
6851 (void *)&cmd_lfc_set_send_xon,
6852 (void *)&cmd_lfc_set_portid,
6857 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6858 .f = cmd_link_flow_ctrl_set_parsed,
6859 .data = (void *)&cmd_link_flow_control_set_macfwd,
6860 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6861 "Change mac ctrl fwd flow control parameter",
6863 (void *)&cmd_lfc_set_set,
6864 (void *)&cmd_lfc_set_flow_ctrl,
6865 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6866 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6867 (void *)&cmd_lfc_set_portid,
6872 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6873 .f = cmd_link_flow_ctrl_set_parsed,
6874 .data = (void *)&cmd_link_flow_control_set_autoneg,
6875 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6876 "Change autoneg flow control parameter",
6878 (void *)&cmd_lfc_set_set,
6879 (void *)&cmd_lfc_set_flow_ctrl,
6880 (void *)&cmd_lfc_set_autoneg_str,
6881 (void *)&cmd_lfc_set_autoneg,
6882 (void *)&cmd_lfc_set_portid,
6888 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6889 __attribute__((unused)) struct cmdline *cl,
6892 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6893 cmdline_parse_inst_t *cmd = data;
6894 struct rte_eth_fc_conf fc_conf;
6900 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6901 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6902 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6903 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6905 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6906 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6909 /* Partial command line, retrieve current configuration */
6911 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6913 printf("cannot get current flow ctrl parameters, return"
6914 "code = %d\n", ret);
6918 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6919 (fc_conf.mode == RTE_FC_FULL))
6921 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6922 (fc_conf.mode == RTE_FC_FULL))
6926 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6927 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6929 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6930 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6932 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6934 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6935 fc_conf.high_water = res->high_water;
6937 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6938 fc_conf.low_water = res->low_water;
6940 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6941 fc_conf.pause_time = res->pause_time;
6943 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6944 fc_conf.send_xon = res->send_xon;
6946 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6947 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6948 fc_conf.mac_ctrl_frame_fwd = 1;
6950 fc_conf.mac_ctrl_frame_fwd = 0;
6953 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6954 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6956 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6958 printf("bad flow contrl parameter, return code = %d \n", ret);
6961 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6962 struct cmd_priority_flow_ctrl_set_result {
6963 cmdline_fixed_string_t set;
6964 cmdline_fixed_string_t pfc_ctrl;
6965 cmdline_fixed_string_t rx;
6966 cmdline_fixed_string_t rx_pfc_mode;
6967 cmdline_fixed_string_t tx;
6968 cmdline_fixed_string_t tx_pfc_mode;
6969 uint32_t high_water;
6971 uint16_t pause_time;
6977 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6978 __attribute__((unused)) struct cmdline *cl,
6979 __attribute__((unused)) void *data)
6981 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6982 struct rte_eth_pfc_conf pfc_conf;
6983 int rx_fc_enable, tx_fc_enable;
6987 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6988 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6989 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6990 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6992 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6993 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6996 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6997 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6998 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6999 pfc_conf.fc.high_water = res->high_water;
7000 pfc_conf.fc.low_water = res->low_water;
7001 pfc_conf.fc.pause_time = res->pause_time;
7002 pfc_conf.priority = res->priority;
7004 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7006 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7009 cmdline_parse_token_string_t cmd_pfc_set_set =
7010 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7012 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7013 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7014 pfc_ctrl, "pfc_ctrl");
7015 cmdline_parse_token_string_t cmd_pfc_set_rx =
7016 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7018 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7019 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7020 rx_pfc_mode, "on#off");
7021 cmdline_parse_token_string_t cmd_pfc_set_tx =
7022 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7024 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7025 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7026 tx_pfc_mode, "on#off");
7027 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7028 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7029 high_water, UINT32);
7030 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7031 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7033 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7034 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7035 pause_time, UINT16);
7036 cmdline_parse_token_num_t cmd_pfc_set_priority =
7037 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7039 cmdline_parse_token_num_t cmd_pfc_set_portid =
7040 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7043 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7044 .f = cmd_priority_flow_ctrl_set_parsed,
7046 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7047 "<pause_time> <priority> <port_id>: "
7048 "Configure the Ethernet priority flow control",
7050 (void *)&cmd_pfc_set_set,
7051 (void *)&cmd_pfc_set_flow_ctrl,
7052 (void *)&cmd_pfc_set_rx,
7053 (void *)&cmd_pfc_set_rx_mode,
7054 (void *)&cmd_pfc_set_tx,
7055 (void *)&cmd_pfc_set_tx_mode,
7056 (void *)&cmd_pfc_set_high_water,
7057 (void *)&cmd_pfc_set_low_water,
7058 (void *)&cmd_pfc_set_pause_time,
7059 (void *)&cmd_pfc_set_priority,
7060 (void *)&cmd_pfc_set_portid,
7065 /* *** RESET CONFIGURATION *** */
7066 struct cmd_reset_result {
7067 cmdline_fixed_string_t reset;
7068 cmdline_fixed_string_t def;
7071 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
7073 __attribute__((unused)) void *data)
7075 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7076 set_def_fwd_config();
7079 cmdline_parse_token_string_t cmd_reset_set =
7080 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7081 cmdline_parse_token_string_t cmd_reset_def =
7082 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7085 cmdline_parse_inst_t cmd_reset = {
7086 .f = cmd_reset_parsed,
7088 .help_str = "set default: Reset default forwarding configuration",
7090 (void *)&cmd_reset_set,
7091 (void *)&cmd_reset_def,
7096 /* *** START FORWARDING *** */
7097 struct cmd_start_result {
7098 cmdline_fixed_string_t start;
7101 cmdline_parse_token_string_t cmd_start_start =
7102 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7104 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
7105 __attribute__((unused)) struct cmdline *cl,
7106 __attribute__((unused)) void *data)
7108 start_packet_forwarding(0);
7111 cmdline_parse_inst_t cmd_start = {
7112 .f = cmd_start_parsed,
7114 .help_str = "start: Start packet forwarding",
7116 (void *)&cmd_start_start,
7121 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7122 struct cmd_start_tx_first_result {
7123 cmdline_fixed_string_t start;
7124 cmdline_fixed_string_t tx_first;
7128 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
7129 __attribute__((unused)) struct cmdline *cl,
7130 __attribute__((unused)) void *data)
7132 start_packet_forwarding(1);
7135 cmdline_parse_token_string_t cmd_start_tx_first_start =
7136 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7138 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7139 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7140 tx_first, "tx_first");
7142 cmdline_parse_inst_t cmd_start_tx_first = {
7143 .f = cmd_start_tx_first_parsed,
7145 .help_str = "start tx_first: Start packet forwarding, "
7146 "after sending 1 burst of packets",
7148 (void *)&cmd_start_tx_first_start,
7149 (void *)&cmd_start_tx_first_tx_first,
7154 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7155 struct cmd_start_tx_first_n_result {
7156 cmdline_fixed_string_t start;
7157 cmdline_fixed_string_t tx_first;
7162 cmd_start_tx_first_n_parsed(void *parsed_result,
7163 __attribute__((unused)) struct cmdline *cl,
7164 __attribute__((unused)) void *data)
7166 struct cmd_start_tx_first_n_result *res = parsed_result;
7168 start_packet_forwarding(res->tx_num);
7171 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7172 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7174 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7175 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7176 tx_first, "tx_first");
7177 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7178 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7181 cmdline_parse_inst_t cmd_start_tx_first_n = {
7182 .f = cmd_start_tx_first_n_parsed,
7184 .help_str = "start tx_first <num>: "
7185 "packet forwarding, after sending <num> bursts of packets",
7187 (void *)&cmd_start_tx_first_n_start,
7188 (void *)&cmd_start_tx_first_n_tx_first,
7189 (void *)&cmd_start_tx_first_n_tx_num,
7194 /* *** SET LINK UP *** */
7195 struct cmd_set_link_up_result {
7196 cmdline_fixed_string_t set;
7197 cmdline_fixed_string_t link_up;
7198 cmdline_fixed_string_t port;
7202 cmdline_parse_token_string_t cmd_set_link_up_set =
7203 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7204 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7205 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7207 cmdline_parse_token_string_t cmd_set_link_up_port =
7208 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7209 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7210 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7212 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
7213 __attribute__((unused)) struct cmdline *cl,
7214 __attribute__((unused)) void *data)
7216 struct cmd_set_link_up_result *res = parsed_result;
7217 dev_set_link_up(res->port_id);
7220 cmdline_parse_inst_t cmd_set_link_up = {
7221 .f = cmd_set_link_up_parsed,
7223 .help_str = "set link-up port <port id>",
7225 (void *)&cmd_set_link_up_set,
7226 (void *)&cmd_set_link_up_link_up,
7227 (void *)&cmd_set_link_up_port,
7228 (void *)&cmd_set_link_up_port_id,
7233 /* *** SET LINK DOWN *** */
7234 struct cmd_set_link_down_result {
7235 cmdline_fixed_string_t set;
7236 cmdline_fixed_string_t link_down;
7237 cmdline_fixed_string_t port;
7241 cmdline_parse_token_string_t cmd_set_link_down_set =
7242 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7243 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7244 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7246 cmdline_parse_token_string_t cmd_set_link_down_port =
7247 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7248 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7249 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7251 static void cmd_set_link_down_parsed(
7252 __attribute__((unused)) void *parsed_result,
7253 __attribute__((unused)) struct cmdline *cl,
7254 __attribute__((unused)) void *data)
7256 struct cmd_set_link_down_result *res = parsed_result;
7257 dev_set_link_down(res->port_id);
7260 cmdline_parse_inst_t cmd_set_link_down = {
7261 .f = cmd_set_link_down_parsed,
7263 .help_str = "set link-down port <port id>",
7265 (void *)&cmd_set_link_down_set,
7266 (void *)&cmd_set_link_down_link_down,
7267 (void *)&cmd_set_link_down_port,
7268 (void *)&cmd_set_link_down_port_id,
7273 /* *** SHOW CFG *** */
7274 struct cmd_showcfg_result {
7275 cmdline_fixed_string_t show;
7276 cmdline_fixed_string_t cfg;
7277 cmdline_fixed_string_t what;
7280 static void cmd_showcfg_parsed(void *parsed_result,
7281 __attribute__((unused)) struct cmdline *cl,
7282 __attribute__((unused)) void *data)
7284 struct cmd_showcfg_result *res = parsed_result;
7285 if (!strcmp(res->what, "rxtx"))
7286 rxtx_config_display();
7287 else if (!strcmp(res->what, "cores"))
7288 fwd_lcores_config_display();
7289 else if (!strcmp(res->what, "fwd"))
7290 pkt_fwd_config_display(&cur_fwd_config);
7291 else if (!strcmp(res->what, "txpkts"))
7292 show_tx_pkt_segments();
7295 cmdline_parse_token_string_t cmd_showcfg_show =
7296 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7297 cmdline_parse_token_string_t cmd_showcfg_port =
7298 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7299 cmdline_parse_token_string_t cmd_showcfg_what =
7300 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7301 "rxtx#cores#fwd#txpkts");
7303 cmdline_parse_inst_t cmd_showcfg = {
7304 .f = cmd_showcfg_parsed,
7306 .help_str = "show config rxtx|cores|fwd|txpkts",
7308 (void *)&cmd_showcfg_show,
7309 (void *)&cmd_showcfg_port,
7310 (void *)&cmd_showcfg_what,
7315 /* *** SHOW ALL PORT INFO *** */
7316 struct cmd_showportall_result {
7317 cmdline_fixed_string_t show;
7318 cmdline_fixed_string_t port;
7319 cmdline_fixed_string_t what;
7320 cmdline_fixed_string_t all;
7323 static void cmd_showportall_parsed(void *parsed_result,
7324 __attribute__((unused)) struct cmdline *cl,
7325 __attribute__((unused)) void *data)
7329 struct cmd_showportall_result *res = parsed_result;
7330 if (!strcmp(res->show, "clear")) {
7331 if (!strcmp(res->what, "stats"))
7332 RTE_ETH_FOREACH_DEV(i)
7334 else if (!strcmp(res->what, "xstats"))
7335 RTE_ETH_FOREACH_DEV(i)
7336 nic_xstats_clear(i);
7337 } else if (!strcmp(res->what, "info"))
7338 RTE_ETH_FOREACH_DEV(i)
7339 port_infos_display(i);
7340 else if (!strcmp(res->what, "summary")) {
7341 port_summary_header_display();
7342 RTE_ETH_FOREACH_DEV(i)
7343 port_summary_display(i);
7345 else if (!strcmp(res->what, "stats"))
7346 RTE_ETH_FOREACH_DEV(i)
7347 nic_stats_display(i);
7348 else if (!strcmp(res->what, "xstats"))
7349 RTE_ETH_FOREACH_DEV(i)
7350 nic_xstats_display(i);
7351 else if (!strcmp(res->what, "fdir"))
7352 RTE_ETH_FOREACH_DEV(i)
7354 else if (!strcmp(res->what, "stat_qmap"))
7355 RTE_ETH_FOREACH_DEV(i)
7356 nic_stats_mapping_display(i);
7357 else if (!strcmp(res->what, "dcb_tc"))
7358 RTE_ETH_FOREACH_DEV(i)
7359 port_dcb_info_display(i);
7360 else if (!strcmp(res->what, "cap"))
7361 RTE_ETH_FOREACH_DEV(i)
7362 port_offload_cap_display(i);
7365 cmdline_parse_token_string_t cmd_showportall_show =
7366 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7368 cmdline_parse_token_string_t cmd_showportall_port =
7369 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7370 cmdline_parse_token_string_t cmd_showportall_what =
7371 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7372 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7373 cmdline_parse_token_string_t cmd_showportall_all =
7374 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7375 cmdline_parse_inst_t cmd_showportall = {
7376 .f = cmd_showportall_parsed,
7378 .help_str = "show|clear port "
7379 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7381 (void *)&cmd_showportall_show,
7382 (void *)&cmd_showportall_port,
7383 (void *)&cmd_showportall_what,
7384 (void *)&cmd_showportall_all,
7389 /* *** SHOW PORT INFO *** */
7390 struct cmd_showport_result {
7391 cmdline_fixed_string_t show;
7392 cmdline_fixed_string_t port;
7393 cmdline_fixed_string_t what;
7397 static void cmd_showport_parsed(void *parsed_result,
7398 __attribute__((unused)) struct cmdline *cl,
7399 __attribute__((unused)) void *data)
7401 struct cmd_showport_result *res = parsed_result;
7402 if (!strcmp(res->show, "clear")) {
7403 if (!strcmp(res->what, "stats"))
7404 nic_stats_clear(res->portnum);
7405 else if (!strcmp(res->what, "xstats"))
7406 nic_xstats_clear(res->portnum);
7407 } else if (!strcmp(res->what, "info"))
7408 port_infos_display(res->portnum);
7409 else if (!strcmp(res->what, "summary")) {
7410 port_summary_header_display();
7411 port_summary_display(res->portnum);
7413 else if (!strcmp(res->what, "stats"))
7414 nic_stats_display(res->portnum);
7415 else if (!strcmp(res->what, "xstats"))
7416 nic_xstats_display(res->portnum);
7417 else if (!strcmp(res->what, "fdir"))
7418 fdir_get_infos(res->portnum);
7419 else if (!strcmp(res->what, "stat_qmap"))
7420 nic_stats_mapping_display(res->portnum);
7421 else if (!strcmp(res->what, "dcb_tc"))
7422 port_dcb_info_display(res->portnum);
7423 else if (!strcmp(res->what, "cap"))
7424 port_offload_cap_display(res->portnum);
7427 cmdline_parse_token_string_t cmd_showport_show =
7428 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7430 cmdline_parse_token_string_t cmd_showport_port =
7431 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7432 cmdline_parse_token_string_t cmd_showport_what =
7433 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7434 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7435 cmdline_parse_token_num_t cmd_showport_portnum =
7436 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7438 cmdline_parse_inst_t cmd_showport = {
7439 .f = cmd_showport_parsed,
7441 .help_str = "show|clear port "
7442 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7445 (void *)&cmd_showport_show,
7446 (void *)&cmd_showport_port,
7447 (void *)&cmd_showport_what,
7448 (void *)&cmd_showport_portnum,
7453 /* *** SHOW DEVICE INFO *** */
7454 struct cmd_showdevice_result {
7455 cmdline_fixed_string_t show;
7456 cmdline_fixed_string_t device;
7457 cmdline_fixed_string_t what;
7458 cmdline_fixed_string_t identifier;
7461 static void cmd_showdevice_parsed(void *parsed_result,
7462 __attribute__((unused)) struct cmdline *cl,
7463 __attribute__((unused)) void *data)
7465 struct cmd_showdevice_result *res = parsed_result;
7466 if (!strcmp(res->what, "info")) {
7467 if (!strcmp(res->identifier, "all"))
7468 device_infos_display(NULL);
7470 device_infos_display(res->identifier);
7474 cmdline_parse_token_string_t cmd_showdevice_show =
7475 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7477 cmdline_parse_token_string_t cmd_showdevice_device =
7478 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7479 cmdline_parse_token_string_t cmd_showdevice_what =
7480 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7482 cmdline_parse_token_string_t cmd_showdevice_identifier =
7483 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7486 cmdline_parse_inst_t cmd_showdevice = {
7487 .f = cmd_showdevice_parsed,
7489 .help_str = "show device info <identifier>|all",
7491 (void *)&cmd_showdevice_show,
7492 (void *)&cmd_showdevice_device,
7493 (void *)&cmd_showdevice_what,
7494 (void *)&cmd_showdevice_identifier,
7498 /* *** SHOW QUEUE INFO *** */
7499 struct cmd_showqueue_result {
7500 cmdline_fixed_string_t show;
7501 cmdline_fixed_string_t type;
7502 cmdline_fixed_string_t what;
7508 cmd_showqueue_parsed(void *parsed_result,
7509 __attribute__((unused)) struct cmdline *cl,
7510 __attribute__((unused)) void *data)
7512 struct cmd_showqueue_result *res = parsed_result;
7514 if (!strcmp(res->type, "rxq"))
7515 rx_queue_infos_display(res->portnum, res->queuenum);
7516 else if (!strcmp(res->type, "txq"))
7517 tx_queue_infos_display(res->portnum, res->queuenum);
7520 cmdline_parse_token_string_t cmd_showqueue_show =
7521 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7522 cmdline_parse_token_string_t cmd_showqueue_type =
7523 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7524 cmdline_parse_token_string_t cmd_showqueue_what =
7525 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7526 cmdline_parse_token_num_t cmd_showqueue_portnum =
7527 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7528 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7529 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7531 cmdline_parse_inst_t cmd_showqueue = {
7532 .f = cmd_showqueue_parsed,
7534 .help_str = "show rxq|txq info <port_id> <queue_id>",
7536 (void *)&cmd_showqueue_show,
7537 (void *)&cmd_showqueue_type,
7538 (void *)&cmd_showqueue_what,
7539 (void *)&cmd_showqueue_portnum,
7540 (void *)&cmd_showqueue_queuenum,
7545 /* show/clear fwd engine statistics */
7547 cmdline_fixed_string_t action;
7548 cmdline_fixed_string_t fwd;
7549 cmdline_fixed_string_t stats;
7550 cmdline_fixed_string_t all;
7553 cmdline_parse_token_string_t cmd_fwd_action =
7554 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7555 cmdline_parse_token_string_t cmd_fwd_fwd =
7556 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7557 cmdline_parse_token_string_t cmd_fwd_stats =
7558 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7559 cmdline_parse_token_string_t cmd_fwd_all =
7560 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7563 cmd_showfwdall_parsed(void *parsed_result,
7564 __rte_unused struct cmdline *cl,
7565 __rte_unused void *data)
7567 struct fwd_result *res = parsed_result;
7569 if (!strcmp(res->action, "show"))
7570 fwd_stats_display();
7575 static cmdline_parse_inst_t cmd_showfwdall = {
7576 .f = cmd_showfwdall_parsed,
7578 .help_str = "show|clear fwd stats all",
7580 (void *)&cmd_fwd_action,
7581 (void *)&cmd_fwd_fwd,
7582 (void *)&cmd_fwd_stats,
7583 (void *)&cmd_fwd_all,
7588 /* *** READ PORT REGISTER *** */
7589 struct cmd_read_reg_result {
7590 cmdline_fixed_string_t read;
7591 cmdline_fixed_string_t reg;
7597 cmd_read_reg_parsed(void *parsed_result,
7598 __attribute__((unused)) struct cmdline *cl,
7599 __attribute__((unused)) void *data)
7601 struct cmd_read_reg_result *res = parsed_result;
7602 port_reg_display(res->port_id, res->reg_off);
7605 cmdline_parse_token_string_t cmd_read_reg_read =
7606 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7607 cmdline_parse_token_string_t cmd_read_reg_reg =
7608 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7609 cmdline_parse_token_num_t cmd_read_reg_port_id =
7610 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7611 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7612 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7614 cmdline_parse_inst_t cmd_read_reg = {
7615 .f = cmd_read_reg_parsed,
7617 .help_str = "read reg <port_id> <reg_off>",
7619 (void *)&cmd_read_reg_read,
7620 (void *)&cmd_read_reg_reg,
7621 (void *)&cmd_read_reg_port_id,
7622 (void *)&cmd_read_reg_reg_off,
7627 /* *** READ PORT REGISTER BIT FIELD *** */
7628 struct cmd_read_reg_bit_field_result {
7629 cmdline_fixed_string_t read;
7630 cmdline_fixed_string_t regfield;
7638 cmd_read_reg_bit_field_parsed(void *parsed_result,
7639 __attribute__((unused)) struct cmdline *cl,
7640 __attribute__((unused)) void *data)
7642 struct cmd_read_reg_bit_field_result *res = parsed_result;
7643 port_reg_bit_field_display(res->port_id, res->reg_off,
7644 res->bit1_pos, res->bit2_pos);
7647 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7648 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7650 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7651 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7652 regfield, "regfield");
7653 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7654 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7656 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7657 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7659 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7660 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7662 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7663 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7666 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7667 .f = cmd_read_reg_bit_field_parsed,
7669 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7670 "Read register bit field between bit_x and bit_y included",
7672 (void *)&cmd_read_reg_bit_field_read,
7673 (void *)&cmd_read_reg_bit_field_regfield,
7674 (void *)&cmd_read_reg_bit_field_port_id,
7675 (void *)&cmd_read_reg_bit_field_reg_off,
7676 (void *)&cmd_read_reg_bit_field_bit1_pos,
7677 (void *)&cmd_read_reg_bit_field_bit2_pos,
7682 /* *** READ PORT REGISTER BIT *** */
7683 struct cmd_read_reg_bit_result {
7684 cmdline_fixed_string_t read;
7685 cmdline_fixed_string_t regbit;
7692 cmd_read_reg_bit_parsed(void *parsed_result,
7693 __attribute__((unused)) struct cmdline *cl,
7694 __attribute__((unused)) void *data)
7696 struct cmd_read_reg_bit_result *res = parsed_result;
7697 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7700 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7701 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7702 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7703 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7705 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7706 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7707 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7708 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7709 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7710 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7712 cmdline_parse_inst_t cmd_read_reg_bit = {
7713 .f = cmd_read_reg_bit_parsed,
7715 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7717 (void *)&cmd_read_reg_bit_read,
7718 (void *)&cmd_read_reg_bit_regbit,
7719 (void *)&cmd_read_reg_bit_port_id,
7720 (void *)&cmd_read_reg_bit_reg_off,
7721 (void *)&cmd_read_reg_bit_bit_pos,
7726 /* *** WRITE PORT REGISTER *** */
7727 struct cmd_write_reg_result {
7728 cmdline_fixed_string_t write;
7729 cmdline_fixed_string_t reg;
7736 cmd_write_reg_parsed(void *parsed_result,
7737 __attribute__((unused)) struct cmdline *cl,
7738 __attribute__((unused)) void *data)
7740 struct cmd_write_reg_result *res = parsed_result;
7741 port_reg_set(res->port_id, res->reg_off, res->value);
7744 cmdline_parse_token_string_t cmd_write_reg_write =
7745 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7746 cmdline_parse_token_string_t cmd_write_reg_reg =
7747 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7748 cmdline_parse_token_num_t cmd_write_reg_port_id =
7749 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7750 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7751 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7752 cmdline_parse_token_num_t cmd_write_reg_value =
7753 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7755 cmdline_parse_inst_t cmd_write_reg = {
7756 .f = cmd_write_reg_parsed,
7758 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7760 (void *)&cmd_write_reg_write,
7761 (void *)&cmd_write_reg_reg,
7762 (void *)&cmd_write_reg_port_id,
7763 (void *)&cmd_write_reg_reg_off,
7764 (void *)&cmd_write_reg_value,
7769 /* *** WRITE PORT REGISTER BIT FIELD *** */
7770 struct cmd_write_reg_bit_field_result {
7771 cmdline_fixed_string_t write;
7772 cmdline_fixed_string_t regfield;
7781 cmd_write_reg_bit_field_parsed(void *parsed_result,
7782 __attribute__((unused)) struct cmdline *cl,
7783 __attribute__((unused)) void *data)
7785 struct cmd_write_reg_bit_field_result *res = parsed_result;
7786 port_reg_bit_field_set(res->port_id, res->reg_off,
7787 res->bit1_pos, res->bit2_pos, res->value);
7790 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7791 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7793 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7794 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7795 regfield, "regfield");
7796 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7797 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7799 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7800 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7802 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7803 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7805 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7806 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7808 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7809 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7812 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7813 .f = cmd_write_reg_bit_field_parsed,
7815 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7817 "Set register bit field between bit_x and bit_y included",
7819 (void *)&cmd_write_reg_bit_field_write,
7820 (void *)&cmd_write_reg_bit_field_regfield,
7821 (void *)&cmd_write_reg_bit_field_port_id,
7822 (void *)&cmd_write_reg_bit_field_reg_off,
7823 (void *)&cmd_write_reg_bit_field_bit1_pos,
7824 (void *)&cmd_write_reg_bit_field_bit2_pos,
7825 (void *)&cmd_write_reg_bit_field_value,
7830 /* *** WRITE PORT REGISTER BIT *** */
7831 struct cmd_write_reg_bit_result {
7832 cmdline_fixed_string_t write;
7833 cmdline_fixed_string_t regbit;
7841 cmd_write_reg_bit_parsed(void *parsed_result,
7842 __attribute__((unused)) struct cmdline *cl,
7843 __attribute__((unused)) void *data)
7845 struct cmd_write_reg_bit_result *res = parsed_result;
7846 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7849 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7850 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7852 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7853 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7855 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7856 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7857 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7858 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7859 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7860 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7861 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7862 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7864 cmdline_parse_inst_t cmd_write_reg_bit = {
7865 .f = cmd_write_reg_bit_parsed,
7867 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7870 (void *)&cmd_write_reg_bit_write,
7871 (void *)&cmd_write_reg_bit_regbit,
7872 (void *)&cmd_write_reg_bit_port_id,
7873 (void *)&cmd_write_reg_bit_reg_off,
7874 (void *)&cmd_write_reg_bit_bit_pos,
7875 (void *)&cmd_write_reg_bit_value,
7880 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7881 struct cmd_read_rxd_txd_result {
7882 cmdline_fixed_string_t read;
7883 cmdline_fixed_string_t rxd_txd;
7890 cmd_read_rxd_txd_parsed(void *parsed_result,
7891 __attribute__((unused)) struct cmdline *cl,
7892 __attribute__((unused)) void *data)
7894 struct cmd_read_rxd_txd_result *res = parsed_result;
7896 if (!strcmp(res->rxd_txd, "rxd"))
7897 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7898 else if (!strcmp(res->rxd_txd, "txd"))
7899 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7902 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7903 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7904 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7905 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7907 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7908 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7909 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7910 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7911 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7912 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7914 cmdline_parse_inst_t cmd_read_rxd_txd = {
7915 .f = cmd_read_rxd_txd_parsed,
7917 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7919 (void *)&cmd_read_rxd_txd_read,
7920 (void *)&cmd_read_rxd_txd_rxd_txd,
7921 (void *)&cmd_read_rxd_txd_port_id,
7922 (void *)&cmd_read_rxd_txd_queue_id,
7923 (void *)&cmd_read_rxd_txd_desc_id,
7929 struct cmd_quit_result {
7930 cmdline_fixed_string_t quit;
7933 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7935 __attribute__((unused)) void *data)
7940 cmdline_parse_token_string_t cmd_quit_quit =
7941 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7943 cmdline_parse_inst_t cmd_quit = {
7944 .f = cmd_quit_parsed,
7946 .help_str = "quit: Exit application",
7948 (void *)&cmd_quit_quit,
7953 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7954 struct cmd_mac_addr_result {
7955 cmdline_fixed_string_t mac_addr_cmd;
7956 cmdline_fixed_string_t what;
7958 struct rte_ether_addr address;
7961 static void cmd_mac_addr_parsed(void *parsed_result,
7962 __attribute__((unused)) struct cmdline *cl,
7963 __attribute__((unused)) void *data)
7965 struct cmd_mac_addr_result *res = parsed_result;
7968 if (strcmp(res->what, "add") == 0)
7969 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7970 else if (strcmp(res->what, "set") == 0)
7971 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7974 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7976 /* check the return value and print it if is < 0 */
7978 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7982 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7983 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7985 cmdline_parse_token_string_t cmd_mac_addr_what =
7986 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7988 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7989 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7991 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7992 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7994 cmdline_parse_inst_t cmd_mac_addr = {
7995 .f = cmd_mac_addr_parsed,
7997 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7998 "Add/Remove/Set MAC address on port_id",
8000 (void *)&cmd_mac_addr_cmd,
8001 (void *)&cmd_mac_addr_what,
8002 (void *)&cmd_mac_addr_portnum,
8003 (void *)&cmd_mac_addr_addr,
8008 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8009 struct cmd_eth_peer_result {
8010 cmdline_fixed_string_t set;
8011 cmdline_fixed_string_t eth_peer;
8013 cmdline_fixed_string_t peer_addr;
8016 static void cmd_set_eth_peer_parsed(void *parsed_result,
8017 __attribute__((unused)) struct cmdline *cl,
8018 __attribute__((unused)) void *data)
8020 struct cmd_eth_peer_result *res = parsed_result;
8022 if (test_done == 0) {
8023 printf("Please stop forwarding first\n");
8026 if (!strcmp(res->eth_peer, "eth-peer")) {
8027 set_fwd_eth_peer(res->port_id, res->peer_addr);
8031 cmdline_parse_token_string_t cmd_eth_peer_set =
8032 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8033 cmdline_parse_token_string_t cmd_eth_peer =
8034 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8035 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8036 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8037 cmdline_parse_token_string_t cmd_eth_peer_addr =
8038 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8040 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8041 .f = cmd_set_eth_peer_parsed,
8043 .help_str = "set eth-peer <port_id> <peer_mac>",
8045 (void *)&cmd_eth_peer_set,
8046 (void *)&cmd_eth_peer,
8047 (void *)&cmd_eth_peer_port_id,
8048 (void *)&cmd_eth_peer_addr,
8053 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8054 struct cmd_set_qmap_result {
8055 cmdline_fixed_string_t set;
8056 cmdline_fixed_string_t qmap;
8057 cmdline_fixed_string_t what;
8064 cmd_set_qmap_parsed(void *parsed_result,
8065 __attribute__((unused)) struct cmdline *cl,
8066 __attribute__((unused)) void *data)
8068 struct cmd_set_qmap_result *res = parsed_result;
8069 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8071 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8074 cmdline_parse_token_string_t cmd_setqmap_set =
8075 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8077 cmdline_parse_token_string_t cmd_setqmap_qmap =
8078 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8080 cmdline_parse_token_string_t cmd_setqmap_what =
8081 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8083 cmdline_parse_token_num_t cmd_setqmap_portid =
8084 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8086 cmdline_parse_token_num_t cmd_setqmap_queueid =
8087 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8089 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8090 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8093 cmdline_parse_inst_t cmd_set_qmap = {
8094 .f = cmd_set_qmap_parsed,
8096 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8097 "Set statistics mapping value on tx|rx queue_id of port_id",
8099 (void *)&cmd_setqmap_set,
8100 (void *)&cmd_setqmap_qmap,
8101 (void *)&cmd_setqmap_what,
8102 (void *)&cmd_setqmap_portid,
8103 (void *)&cmd_setqmap_queueid,
8104 (void *)&cmd_setqmap_mapvalue,
8109 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8110 struct cmd_set_xstats_hide_zero_result {
8111 cmdline_fixed_string_t keyword;
8112 cmdline_fixed_string_t name;
8113 cmdline_fixed_string_t on_off;
8117 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8118 __attribute__((unused)) struct cmdline *cl,
8119 __attribute__((unused)) void *data)
8121 struct cmd_set_xstats_hide_zero_result *res;
8122 uint16_t on_off = 0;
8124 res = parsed_result;
8125 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8126 set_xstats_hide_zero(on_off);
8129 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8130 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8132 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8133 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8134 name, "xstats-hide-zero");
8135 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8136 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8139 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8140 .f = cmd_set_xstats_hide_zero_parsed,
8142 .help_str = "set xstats-hide-zero on|off",
8144 (void *)&cmd_set_xstats_hide_zero_keyword,
8145 (void *)&cmd_set_xstats_hide_zero_name,
8146 (void *)&cmd_set_xstats_hide_zero_on_off,
8151 /* *** CONFIGURE UNICAST HASH TABLE *** */
8152 struct cmd_set_uc_hash_table {
8153 cmdline_fixed_string_t set;
8154 cmdline_fixed_string_t port;
8156 cmdline_fixed_string_t what;
8157 struct rte_ether_addr address;
8158 cmdline_fixed_string_t mode;
8162 cmd_set_uc_hash_parsed(void *parsed_result,
8163 __attribute__((unused)) struct cmdline *cl,
8164 __attribute__((unused)) void *data)
8167 struct cmd_set_uc_hash_table *res = parsed_result;
8169 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8171 if (strcmp(res->what, "uta") == 0)
8172 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8173 &res->address,(uint8_t)is_on);
8175 printf("bad unicast hash table parameter, return code = %d \n", ret);
8179 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8180 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8182 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8183 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8185 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8186 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8188 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8189 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8191 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8192 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8194 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8195 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8198 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8199 .f = cmd_set_uc_hash_parsed,
8201 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8203 (void *)&cmd_set_uc_hash_set,
8204 (void *)&cmd_set_uc_hash_port,
8205 (void *)&cmd_set_uc_hash_portid,
8206 (void *)&cmd_set_uc_hash_what,
8207 (void *)&cmd_set_uc_hash_mac,
8208 (void *)&cmd_set_uc_hash_mode,
8213 struct cmd_set_uc_all_hash_table {
8214 cmdline_fixed_string_t set;
8215 cmdline_fixed_string_t port;
8217 cmdline_fixed_string_t what;
8218 cmdline_fixed_string_t value;
8219 cmdline_fixed_string_t mode;
8223 cmd_set_uc_all_hash_parsed(void *parsed_result,
8224 __attribute__((unused)) struct cmdline *cl,
8225 __attribute__((unused)) void *data)
8228 struct cmd_set_uc_all_hash_table *res = parsed_result;
8230 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8232 if ((strcmp(res->what, "uta") == 0) &&
8233 (strcmp(res->value, "all") == 0))
8234 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8236 printf("bad unicast hash table parameter,"
8237 "return code = %d \n", ret);
8240 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8241 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8243 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8244 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8246 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8247 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8249 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8250 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8252 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8253 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8255 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8256 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8259 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8260 .f = cmd_set_uc_all_hash_parsed,
8262 .help_str = "set port <port_id> uta all on|off",
8264 (void *)&cmd_set_uc_all_hash_set,
8265 (void *)&cmd_set_uc_all_hash_port,
8266 (void *)&cmd_set_uc_all_hash_portid,
8267 (void *)&cmd_set_uc_all_hash_what,
8268 (void *)&cmd_set_uc_all_hash_value,
8269 (void *)&cmd_set_uc_all_hash_mode,
8274 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8275 struct cmd_set_vf_macvlan_filter {
8276 cmdline_fixed_string_t set;
8277 cmdline_fixed_string_t port;
8279 cmdline_fixed_string_t vf;
8281 struct rte_ether_addr address;
8282 cmdline_fixed_string_t filter_type;
8283 cmdline_fixed_string_t mode;
8287 cmd_set_vf_macvlan_parsed(void *parsed_result,
8288 __attribute__((unused)) struct cmdline *cl,
8289 __attribute__((unused)) void *data)
8292 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8293 struct rte_eth_mac_filter filter;
8295 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8297 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8299 /* set VF MAC filter */
8303 filter.dst_id = res->vf_id;
8305 if (!strcmp(res->filter_type, "exact-mac"))
8306 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8307 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8308 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8309 else if (!strcmp(res->filter_type, "hashmac"))
8310 filter.filter_type = RTE_MAC_HASH_MATCH;
8311 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8312 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8314 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8317 ret = rte_eth_dev_filter_ctrl(res->port_id,
8318 RTE_ETH_FILTER_MACVLAN,
8322 ret = rte_eth_dev_filter_ctrl(res->port_id,
8323 RTE_ETH_FILTER_MACVLAN,
8324 RTE_ETH_FILTER_DELETE,
8328 printf("bad set MAC hash parameter, return code = %d\n", ret);
8332 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8333 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8335 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8336 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8338 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8339 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8341 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8342 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8344 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8345 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8347 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8348 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8350 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8351 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8352 filter_type, "exact-mac#exact-mac-vlan"
8353 "#hashmac#hashmac-vlan");
8354 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8355 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8358 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8359 .f = cmd_set_vf_macvlan_parsed,
8361 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8362 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8363 "Exact match rule: exact match of MAC or MAC and VLAN; "
8364 "hash match rule: hash match of MAC and exact match of VLAN",
8366 (void *)&cmd_set_vf_macvlan_set,
8367 (void *)&cmd_set_vf_macvlan_port,
8368 (void *)&cmd_set_vf_macvlan_portid,
8369 (void *)&cmd_set_vf_macvlan_vf,
8370 (void *)&cmd_set_vf_macvlan_vf_id,
8371 (void *)&cmd_set_vf_macvlan_mac,
8372 (void *)&cmd_set_vf_macvlan_filter_type,
8373 (void *)&cmd_set_vf_macvlan_mode,
8378 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8379 struct cmd_set_vf_traffic {
8380 cmdline_fixed_string_t set;
8381 cmdline_fixed_string_t port;
8383 cmdline_fixed_string_t vf;
8385 cmdline_fixed_string_t what;
8386 cmdline_fixed_string_t mode;
8390 cmd_set_vf_traffic_parsed(void *parsed_result,
8391 __attribute__((unused)) struct cmdline *cl,
8392 __attribute__((unused)) void *data)
8394 struct cmd_set_vf_traffic *res = parsed_result;
8395 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8396 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8398 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8401 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8402 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8404 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8405 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8407 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8408 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8410 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8411 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8413 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8414 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8416 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8417 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8419 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8420 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8423 cmdline_parse_inst_t cmd_set_vf_traffic = {
8424 .f = cmd_set_vf_traffic_parsed,
8426 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8428 (void *)&cmd_setvf_traffic_set,
8429 (void *)&cmd_setvf_traffic_port,
8430 (void *)&cmd_setvf_traffic_portid,
8431 (void *)&cmd_setvf_traffic_vf,
8432 (void *)&cmd_setvf_traffic_vfid,
8433 (void *)&cmd_setvf_traffic_what,
8434 (void *)&cmd_setvf_traffic_mode,
8439 /* *** CONFIGURE VF RECEIVE MODE *** */
8440 struct cmd_set_vf_rxmode {
8441 cmdline_fixed_string_t set;
8442 cmdline_fixed_string_t port;
8444 cmdline_fixed_string_t vf;
8446 cmdline_fixed_string_t what;
8447 cmdline_fixed_string_t mode;
8448 cmdline_fixed_string_t on;
8452 cmd_set_vf_rxmode_parsed(void *parsed_result,
8453 __attribute__((unused)) struct cmdline *cl,
8454 __attribute__((unused)) void *data)
8457 uint16_t vf_rxmode = 0;
8458 struct cmd_set_vf_rxmode *res = parsed_result;
8460 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8461 if (!strcmp(res->what,"rxmode")) {
8462 if (!strcmp(res->mode, "AUPE"))
8463 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8464 else if (!strcmp(res->mode, "ROPE"))
8465 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8466 else if (!strcmp(res->mode, "BAM"))
8467 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8468 else if (!strncmp(res->mode, "MPE",3))
8469 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8472 RTE_SET_USED(is_on);
8474 #ifdef RTE_LIBRTE_IXGBE_PMD
8475 if (ret == -ENOTSUP)
8476 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8477 vf_rxmode, (uint8_t)is_on);
8479 #ifdef RTE_LIBRTE_BNXT_PMD
8480 if (ret == -ENOTSUP)
8481 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8482 vf_rxmode, (uint8_t)is_on);
8485 printf("bad VF receive mode parameter, return code = %d \n",
8489 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8490 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8492 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8493 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8495 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8496 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8498 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8499 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8501 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8502 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8504 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8505 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8507 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8508 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8509 mode, "AUPE#ROPE#BAM#MPE");
8510 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8511 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8514 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8515 .f = cmd_set_vf_rxmode_parsed,
8517 .help_str = "set port <port_id> vf <vf_id> rxmode "
8518 "AUPE|ROPE|BAM|MPE on|off",
8520 (void *)&cmd_set_vf_rxmode_set,
8521 (void *)&cmd_set_vf_rxmode_port,
8522 (void *)&cmd_set_vf_rxmode_portid,
8523 (void *)&cmd_set_vf_rxmode_vf,
8524 (void *)&cmd_set_vf_rxmode_vfid,
8525 (void *)&cmd_set_vf_rxmode_what,
8526 (void *)&cmd_set_vf_rxmode_mode,
8527 (void *)&cmd_set_vf_rxmode_on,
8532 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8533 struct cmd_vf_mac_addr_result {
8534 cmdline_fixed_string_t mac_addr_cmd;
8535 cmdline_fixed_string_t what;
8536 cmdline_fixed_string_t port;
8538 cmdline_fixed_string_t vf;
8540 struct rte_ether_addr address;
8543 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8544 __attribute__((unused)) struct cmdline *cl,
8545 __attribute__((unused)) void *data)
8547 struct cmd_vf_mac_addr_result *res = parsed_result;
8550 if (strcmp(res->what, "add") != 0)
8553 #ifdef RTE_LIBRTE_I40E_PMD
8554 if (ret == -ENOTSUP)
8555 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8558 #ifdef RTE_LIBRTE_BNXT_PMD
8559 if (ret == -ENOTSUP)
8560 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8565 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8569 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8570 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8571 mac_addr_cmd,"mac_addr");
8572 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8573 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8575 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8576 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8578 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8579 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8581 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8582 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8584 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8585 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8587 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8588 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8591 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8592 .f = cmd_vf_mac_addr_parsed,
8594 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8595 "Add MAC address filtering for a VF on port_id",
8597 (void *)&cmd_vf_mac_addr_cmd,
8598 (void *)&cmd_vf_mac_addr_what,
8599 (void *)&cmd_vf_mac_addr_port,
8600 (void *)&cmd_vf_mac_addr_portnum,
8601 (void *)&cmd_vf_mac_addr_vf,
8602 (void *)&cmd_vf_mac_addr_vfnum,
8603 (void *)&cmd_vf_mac_addr_addr,
8608 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8609 struct cmd_vf_rx_vlan_filter {
8610 cmdline_fixed_string_t rx_vlan;
8611 cmdline_fixed_string_t what;
8613 cmdline_fixed_string_t port;
8615 cmdline_fixed_string_t vf;
8620 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8621 __attribute__((unused)) struct cmdline *cl,
8622 __attribute__((unused)) void *data)
8624 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8627 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8629 #ifdef RTE_LIBRTE_IXGBE_PMD
8630 if (ret == -ENOTSUP)
8631 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8632 res->vlan_id, res->vf_mask, is_add);
8634 #ifdef RTE_LIBRTE_I40E_PMD
8635 if (ret == -ENOTSUP)
8636 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8637 res->vlan_id, res->vf_mask, is_add);
8639 #ifdef RTE_LIBRTE_BNXT_PMD
8640 if (ret == -ENOTSUP)
8641 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8642 res->vlan_id, res->vf_mask, is_add);
8649 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8650 res->vlan_id, res->vf_mask);
8653 printf("invalid port_id %d\n", res->port_id);
8656 printf("function not implemented or supported\n");
8659 printf("programming error: (%s)\n", strerror(-ret));
8663 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8664 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8665 rx_vlan, "rx_vlan");
8666 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8667 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8669 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8670 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8672 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8673 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8675 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8676 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8678 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8679 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8681 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8682 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8685 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8686 .f = cmd_vf_rx_vlan_filter_parsed,
8688 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8689 "(vf_mask = hexadecimal VF mask)",
8691 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8692 (void *)&cmd_vf_rx_vlan_filter_what,
8693 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8694 (void *)&cmd_vf_rx_vlan_filter_port,
8695 (void *)&cmd_vf_rx_vlan_filter_portid,
8696 (void *)&cmd_vf_rx_vlan_filter_vf,
8697 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8702 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8703 struct cmd_queue_rate_limit_result {
8704 cmdline_fixed_string_t set;
8705 cmdline_fixed_string_t port;
8707 cmdline_fixed_string_t queue;
8709 cmdline_fixed_string_t rate;
8713 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8714 __attribute__((unused)) struct cmdline *cl,
8715 __attribute__((unused)) void *data)
8717 struct cmd_queue_rate_limit_result *res = parsed_result;
8720 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8721 && (strcmp(res->queue, "queue") == 0)
8722 && (strcmp(res->rate, "rate") == 0))
8723 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8726 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8730 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8731 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8733 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8734 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8736 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8737 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8739 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8740 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8742 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8743 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8745 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8746 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8748 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8749 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8752 cmdline_parse_inst_t cmd_queue_rate_limit = {
8753 .f = cmd_queue_rate_limit_parsed,
8755 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8756 "Set rate limit for a queue on port_id",
8758 (void *)&cmd_queue_rate_limit_set,
8759 (void *)&cmd_queue_rate_limit_port,
8760 (void *)&cmd_queue_rate_limit_portnum,
8761 (void *)&cmd_queue_rate_limit_queue,
8762 (void *)&cmd_queue_rate_limit_queuenum,
8763 (void *)&cmd_queue_rate_limit_rate,
8764 (void *)&cmd_queue_rate_limit_ratenum,
8769 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8770 struct cmd_vf_rate_limit_result {
8771 cmdline_fixed_string_t set;
8772 cmdline_fixed_string_t port;
8774 cmdline_fixed_string_t vf;
8776 cmdline_fixed_string_t rate;
8778 cmdline_fixed_string_t q_msk;
8782 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8783 __attribute__((unused)) struct cmdline *cl,
8784 __attribute__((unused)) void *data)
8786 struct cmd_vf_rate_limit_result *res = parsed_result;
8789 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8790 && (strcmp(res->vf, "vf") == 0)
8791 && (strcmp(res->rate, "rate") == 0)
8792 && (strcmp(res->q_msk, "queue_mask") == 0))
8793 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8794 res->rate_num, res->q_msk_val);
8796 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8800 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8801 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8803 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8804 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8806 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8807 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8809 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8810 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8812 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8813 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8815 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8816 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8818 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8819 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8821 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8822 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8823 q_msk, "queue_mask");
8824 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8825 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8828 cmdline_parse_inst_t cmd_vf_rate_limit = {
8829 .f = cmd_vf_rate_limit_parsed,
8831 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8832 "queue_mask <queue_mask_value>: "
8833 "Set rate limit for queues of VF on port_id",
8835 (void *)&cmd_vf_rate_limit_set,
8836 (void *)&cmd_vf_rate_limit_port,
8837 (void *)&cmd_vf_rate_limit_portnum,
8838 (void *)&cmd_vf_rate_limit_vf,
8839 (void *)&cmd_vf_rate_limit_vfnum,
8840 (void *)&cmd_vf_rate_limit_rate,
8841 (void *)&cmd_vf_rate_limit_ratenum,
8842 (void *)&cmd_vf_rate_limit_q_msk,
8843 (void *)&cmd_vf_rate_limit_q_msk_val,
8848 /* *** ADD TUNNEL FILTER OF A PORT *** */
8849 struct cmd_tunnel_filter_result {
8850 cmdline_fixed_string_t cmd;
8851 cmdline_fixed_string_t what;
8853 struct rte_ether_addr outer_mac;
8854 struct rte_ether_addr inner_mac;
8855 cmdline_ipaddr_t ip_value;
8856 uint16_t inner_vlan;
8857 cmdline_fixed_string_t tunnel_type;
8858 cmdline_fixed_string_t filter_type;
8864 cmd_tunnel_filter_parsed(void *parsed_result,
8865 __attribute__((unused)) struct cmdline *cl,
8866 __attribute__((unused)) void *data)
8868 struct cmd_tunnel_filter_result *res = parsed_result;
8869 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8872 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8874 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8875 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8876 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8878 if (res->ip_value.family == AF_INET) {
8879 tunnel_filter_conf.ip_addr.ipv4_addr =
8880 res->ip_value.addr.ipv4.s_addr;
8881 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8883 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8884 &(res->ip_value.addr.ipv6),
8885 sizeof(struct in6_addr));
8886 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8889 if (!strcmp(res->filter_type, "imac-ivlan"))
8890 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8891 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8892 tunnel_filter_conf.filter_type =
8893 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8894 else if (!strcmp(res->filter_type, "imac-tenid"))
8895 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8896 else if (!strcmp(res->filter_type, "imac"))
8897 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8898 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8899 tunnel_filter_conf.filter_type =
8900 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8901 else if (!strcmp(res->filter_type, "oip"))
8902 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8903 else if (!strcmp(res->filter_type, "iip"))
8904 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8906 printf("The filter type is not supported");
8910 if (!strcmp(res->tunnel_type, "vxlan"))
8911 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8912 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
8913 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
8914 else if (!strcmp(res->tunnel_type, "nvgre"))
8915 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8916 else if (!strcmp(res->tunnel_type, "ipingre"))
8917 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8919 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8923 tunnel_filter_conf.tenant_id = res->tenant_id;
8924 tunnel_filter_conf.queue_id = res->queue_num;
8925 if (!strcmp(res->what, "add"))
8926 ret = rte_eth_dev_filter_ctrl(res->port_id,
8927 RTE_ETH_FILTER_TUNNEL,
8929 &tunnel_filter_conf);
8931 ret = rte_eth_dev_filter_ctrl(res->port_id,
8932 RTE_ETH_FILTER_TUNNEL,
8933 RTE_ETH_FILTER_DELETE,
8934 &tunnel_filter_conf);
8936 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8940 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8941 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8942 cmd, "tunnel_filter");
8943 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8944 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8946 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8947 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8949 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8950 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8952 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8953 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8955 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8956 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8957 inner_vlan, UINT16);
8958 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8959 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8961 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8962 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8963 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
8965 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8966 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8967 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8968 "imac#omac-imac-tenid");
8969 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8970 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8972 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8973 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8976 cmdline_parse_inst_t cmd_tunnel_filter = {
8977 .f = cmd_tunnel_filter_parsed,
8979 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8980 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8981 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8982 "<queue_id>: Add/Rm tunnel filter of a port",
8984 (void *)&cmd_tunnel_filter_cmd,
8985 (void *)&cmd_tunnel_filter_what,
8986 (void *)&cmd_tunnel_filter_port_id,
8987 (void *)&cmd_tunnel_filter_outer_mac,
8988 (void *)&cmd_tunnel_filter_inner_mac,
8989 (void *)&cmd_tunnel_filter_ip_value,
8990 (void *)&cmd_tunnel_filter_innner_vlan,
8991 (void *)&cmd_tunnel_filter_tunnel_type,
8992 (void *)&cmd_tunnel_filter_filter_type,
8993 (void *)&cmd_tunnel_filter_tenant_id,
8994 (void *)&cmd_tunnel_filter_queue_num,
8999 /* *** CONFIGURE TUNNEL UDP PORT *** */
9000 struct cmd_tunnel_udp_config {
9001 cmdline_fixed_string_t cmd;
9002 cmdline_fixed_string_t what;
9008 cmd_tunnel_udp_config_parsed(void *parsed_result,
9009 __attribute__((unused)) struct cmdline *cl,
9010 __attribute__((unused)) void *data)
9012 struct cmd_tunnel_udp_config *res = parsed_result;
9013 struct rte_eth_udp_tunnel tunnel_udp;
9016 tunnel_udp.udp_port = res->udp_port;
9018 if (!strcmp(res->cmd, "rx_vxlan_port"))
9019 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9021 if (!strcmp(res->what, "add"))
9022 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9025 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9029 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9032 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9033 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9034 cmd, "rx_vxlan_port");
9035 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9036 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9038 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9039 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9041 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9042 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9045 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9046 .f = cmd_tunnel_udp_config_parsed,
9048 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9049 "Add/Remove a tunneling UDP port filter",
9051 (void *)&cmd_tunnel_udp_config_cmd,
9052 (void *)&cmd_tunnel_udp_config_what,
9053 (void *)&cmd_tunnel_udp_config_udp_port,
9054 (void *)&cmd_tunnel_udp_config_port_id,
9059 struct cmd_config_tunnel_udp_port {
9060 cmdline_fixed_string_t port;
9061 cmdline_fixed_string_t config;
9063 cmdline_fixed_string_t udp_tunnel_port;
9064 cmdline_fixed_string_t action;
9065 cmdline_fixed_string_t tunnel_type;
9070 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9071 __attribute__((unused)) struct cmdline *cl,
9072 __attribute__((unused)) void *data)
9074 struct cmd_config_tunnel_udp_port *res = parsed_result;
9075 struct rte_eth_udp_tunnel tunnel_udp;
9078 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9081 tunnel_udp.udp_port = res->udp_port;
9083 if (!strcmp(res->tunnel_type, "vxlan")) {
9084 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9085 } else if (!strcmp(res->tunnel_type, "geneve")) {
9086 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9087 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9088 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9090 printf("Invalid tunnel type\n");
9094 if (!strcmp(res->action, "add"))
9095 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9098 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9102 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9105 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9106 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9108 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9109 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9111 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9112 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9114 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9115 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9118 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9119 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9121 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9122 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9123 "vxlan#geneve#vxlan-gpe");
9124 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9125 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9128 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9129 .f = cmd_cfg_tunnel_udp_port_parsed,
9131 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9133 (void *)&cmd_config_tunnel_udp_port_port,
9134 (void *)&cmd_config_tunnel_udp_port_config,
9135 (void *)&cmd_config_tunnel_udp_port_port_id,
9136 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9137 (void *)&cmd_config_tunnel_udp_port_action,
9138 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9139 (void *)&cmd_config_tunnel_udp_port_value,
9144 /* *** GLOBAL CONFIG *** */
9145 struct cmd_global_config_result {
9146 cmdline_fixed_string_t cmd;
9148 cmdline_fixed_string_t cfg_type;
9153 cmd_global_config_parsed(void *parsed_result,
9154 __attribute__((unused)) struct cmdline *cl,
9155 __attribute__((unused)) void *data)
9157 struct cmd_global_config_result *res = parsed_result;
9158 struct rte_eth_global_cfg conf;
9161 memset(&conf, 0, sizeof(conf));
9162 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9163 conf.cfg.gre_key_len = res->len;
9164 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9165 RTE_ETH_FILTER_SET, &conf);
9167 printf("Global config error\n");
9170 cmdline_parse_token_string_t cmd_global_config_cmd =
9171 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9173 cmdline_parse_token_num_t cmd_global_config_port_id =
9174 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9176 cmdline_parse_token_string_t cmd_global_config_type =
9177 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9178 cfg_type, "gre-key-len");
9179 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9180 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9183 cmdline_parse_inst_t cmd_global_config = {
9184 .f = cmd_global_config_parsed,
9185 .data = (void *)NULL,
9186 .help_str = "global_config <port_id> gre-key-len <key_len>",
9188 (void *)&cmd_global_config_cmd,
9189 (void *)&cmd_global_config_port_id,
9190 (void *)&cmd_global_config_type,
9191 (void *)&cmd_global_config_gre_key_len,
9196 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9197 struct cmd_set_mirror_mask_result {
9198 cmdline_fixed_string_t set;
9199 cmdline_fixed_string_t port;
9201 cmdline_fixed_string_t mirror;
9203 cmdline_fixed_string_t what;
9204 cmdline_fixed_string_t value;
9205 cmdline_fixed_string_t dstpool;
9207 cmdline_fixed_string_t on;
9210 cmdline_parse_token_string_t cmd_mirror_mask_set =
9211 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9213 cmdline_parse_token_string_t cmd_mirror_mask_port =
9214 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9216 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9217 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9219 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9220 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9221 mirror, "mirror-rule");
9222 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9223 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9225 cmdline_parse_token_string_t cmd_mirror_mask_what =
9226 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9227 what, "pool-mirror-up#pool-mirror-down"
9229 cmdline_parse_token_string_t cmd_mirror_mask_value =
9230 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9232 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9233 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9234 dstpool, "dst-pool");
9235 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9236 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9238 cmdline_parse_token_string_t cmd_mirror_mask_on =
9239 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9243 cmd_set_mirror_mask_parsed(void *parsed_result,
9244 __attribute__((unused)) struct cmdline *cl,
9245 __attribute__((unused)) void *data)
9248 struct cmd_set_mirror_mask_result *res = parsed_result;
9249 struct rte_eth_mirror_conf mr_conf;
9251 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9253 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9255 mr_conf.dst_pool = res->dstpool_id;
9257 if (!strcmp(res->what, "pool-mirror-up")) {
9258 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9259 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9260 } else if (!strcmp(res->what, "pool-mirror-down")) {
9261 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9262 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9263 } else if (!strcmp(res->what, "vlan-mirror")) {
9264 mr_conf.rule_type = ETH_MIRROR_VLAN;
9265 nb_item = parse_item_list(res->value, "vlan",
9266 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9270 for (i = 0; i < nb_item; i++) {
9271 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9272 printf("Invalid vlan_id: must be < 4096\n");
9276 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9277 mr_conf.vlan.vlan_mask |= 1ULL << i;
9281 if (!strcmp(res->on, "on"))
9282 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9285 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9288 printf("mirror rule add error: (%s)\n", strerror(-ret));
9291 cmdline_parse_inst_t cmd_set_mirror_mask = {
9292 .f = cmd_set_mirror_mask_parsed,
9294 .help_str = "set port <port_id> mirror-rule <rule_id> "
9295 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9296 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9298 (void *)&cmd_mirror_mask_set,
9299 (void *)&cmd_mirror_mask_port,
9300 (void *)&cmd_mirror_mask_portid,
9301 (void *)&cmd_mirror_mask_mirror,
9302 (void *)&cmd_mirror_mask_ruleid,
9303 (void *)&cmd_mirror_mask_what,
9304 (void *)&cmd_mirror_mask_value,
9305 (void *)&cmd_mirror_mask_dstpool,
9306 (void *)&cmd_mirror_mask_poolid,
9307 (void *)&cmd_mirror_mask_on,
9312 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9313 struct cmd_set_mirror_link_result {
9314 cmdline_fixed_string_t set;
9315 cmdline_fixed_string_t port;
9317 cmdline_fixed_string_t mirror;
9319 cmdline_fixed_string_t what;
9320 cmdline_fixed_string_t dstpool;
9322 cmdline_fixed_string_t on;
9325 cmdline_parse_token_string_t cmd_mirror_link_set =
9326 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9328 cmdline_parse_token_string_t cmd_mirror_link_port =
9329 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9331 cmdline_parse_token_num_t cmd_mirror_link_portid =
9332 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9334 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9335 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9336 mirror, "mirror-rule");
9337 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9338 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9340 cmdline_parse_token_string_t cmd_mirror_link_what =
9341 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9342 what, "uplink-mirror#downlink-mirror");
9343 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9344 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9345 dstpool, "dst-pool");
9346 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9347 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9349 cmdline_parse_token_string_t cmd_mirror_link_on =
9350 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9354 cmd_set_mirror_link_parsed(void *parsed_result,
9355 __attribute__((unused)) struct cmdline *cl,
9356 __attribute__((unused)) void *data)
9359 struct cmd_set_mirror_link_result *res = parsed_result;
9360 struct rte_eth_mirror_conf mr_conf;
9362 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9363 if (!strcmp(res->what, "uplink-mirror"))
9364 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9366 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9368 mr_conf.dst_pool = res->dstpool_id;
9370 if (!strcmp(res->on, "on"))
9371 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9374 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9377 /* check the return value and print it if is < 0 */
9379 printf("mirror rule add error: (%s)\n", strerror(-ret));
9383 cmdline_parse_inst_t cmd_set_mirror_link = {
9384 .f = cmd_set_mirror_link_parsed,
9386 .help_str = "set port <port_id> mirror-rule <rule_id> "
9387 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9389 (void *)&cmd_mirror_link_set,
9390 (void *)&cmd_mirror_link_port,
9391 (void *)&cmd_mirror_link_portid,
9392 (void *)&cmd_mirror_link_mirror,
9393 (void *)&cmd_mirror_link_ruleid,
9394 (void *)&cmd_mirror_link_what,
9395 (void *)&cmd_mirror_link_dstpool,
9396 (void *)&cmd_mirror_link_poolid,
9397 (void *)&cmd_mirror_link_on,
9402 /* *** RESET VM MIRROR RULE *** */
9403 struct cmd_rm_mirror_rule_result {
9404 cmdline_fixed_string_t reset;
9405 cmdline_fixed_string_t port;
9407 cmdline_fixed_string_t mirror;
9411 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9412 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9414 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9415 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9417 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9418 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9420 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9421 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9422 mirror, "mirror-rule");
9423 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9424 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9428 cmd_reset_mirror_rule_parsed(void *parsed_result,
9429 __attribute__((unused)) struct cmdline *cl,
9430 __attribute__((unused)) void *data)
9433 struct cmd_set_mirror_link_result *res = parsed_result;
9435 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9437 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9440 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9441 .f = cmd_reset_mirror_rule_parsed,
9443 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9445 (void *)&cmd_rm_mirror_rule_reset,
9446 (void *)&cmd_rm_mirror_rule_port,
9447 (void *)&cmd_rm_mirror_rule_portid,
9448 (void *)&cmd_rm_mirror_rule_mirror,
9449 (void *)&cmd_rm_mirror_rule_ruleid,
9454 /* ******************************************************************************** */
9456 struct cmd_dump_result {
9457 cmdline_fixed_string_t dump;
9461 dump_struct_sizes(void)
9463 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9464 DUMP_SIZE(struct rte_mbuf);
9465 DUMP_SIZE(struct rte_mempool);
9466 DUMP_SIZE(struct rte_ring);
9470 static void cmd_dump_parsed(void *parsed_result,
9471 __attribute__((unused)) struct cmdline *cl,
9472 __attribute__((unused)) void *data)
9474 struct cmd_dump_result *res = parsed_result;
9476 if (!strcmp(res->dump, "dump_physmem"))
9477 rte_dump_physmem_layout(stdout);
9478 else if (!strcmp(res->dump, "dump_memzone"))
9479 rte_memzone_dump(stdout);
9480 else if (!strcmp(res->dump, "dump_struct_sizes"))
9481 dump_struct_sizes();
9482 else if (!strcmp(res->dump, "dump_ring"))
9483 rte_ring_list_dump(stdout);
9484 else if (!strcmp(res->dump, "dump_mempool"))
9485 rte_mempool_list_dump(stdout);
9486 else if (!strcmp(res->dump, "dump_devargs"))
9487 rte_devargs_dump(stdout);
9488 else if (!strcmp(res->dump, "dump_log_types"))
9489 rte_log_dump(stdout);
9492 cmdline_parse_token_string_t cmd_dump_dump =
9493 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9496 "dump_struct_sizes#"
9502 cmdline_parse_inst_t cmd_dump = {
9503 .f = cmd_dump_parsed, /* function to call */
9504 .data = NULL, /* 2nd arg of func */
9505 .help_str = "Dump status",
9506 .tokens = { /* token list, NULL terminated */
9507 (void *)&cmd_dump_dump,
9512 /* ******************************************************************************** */
9514 struct cmd_dump_one_result {
9515 cmdline_fixed_string_t dump;
9516 cmdline_fixed_string_t name;
9519 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9520 __attribute__((unused)) void *data)
9522 struct cmd_dump_one_result *res = parsed_result;
9524 if (!strcmp(res->dump, "dump_ring")) {
9526 r = rte_ring_lookup(res->name);
9528 cmdline_printf(cl, "Cannot find ring\n");
9531 rte_ring_dump(stdout, r);
9532 } else if (!strcmp(res->dump, "dump_mempool")) {
9533 struct rte_mempool *mp;
9534 mp = rte_mempool_lookup(res->name);
9536 cmdline_printf(cl, "Cannot find mempool\n");
9539 rte_mempool_dump(stdout, mp);
9543 cmdline_parse_token_string_t cmd_dump_one_dump =
9544 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9545 "dump_ring#dump_mempool");
9547 cmdline_parse_token_string_t cmd_dump_one_name =
9548 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9550 cmdline_parse_inst_t cmd_dump_one = {
9551 .f = cmd_dump_one_parsed, /* function to call */
9552 .data = NULL, /* 2nd arg of func */
9553 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9554 .tokens = { /* token list, NULL terminated */
9555 (void *)&cmd_dump_one_dump,
9556 (void *)&cmd_dump_one_name,
9561 /* *** Add/Del syn filter *** */
9562 struct cmd_syn_filter_result {
9563 cmdline_fixed_string_t filter;
9565 cmdline_fixed_string_t ops;
9566 cmdline_fixed_string_t priority;
9567 cmdline_fixed_string_t high;
9568 cmdline_fixed_string_t queue;
9573 cmd_syn_filter_parsed(void *parsed_result,
9574 __attribute__((unused)) struct cmdline *cl,
9575 __attribute__((unused)) void *data)
9577 struct cmd_syn_filter_result *res = parsed_result;
9578 struct rte_eth_syn_filter syn_filter;
9581 ret = rte_eth_dev_filter_supported(res->port_id,
9582 RTE_ETH_FILTER_SYN);
9584 printf("syn filter is not supported on port %u.\n",
9589 memset(&syn_filter, 0, sizeof(syn_filter));
9591 if (!strcmp(res->ops, "add")) {
9592 if (!strcmp(res->high, "high"))
9593 syn_filter.hig_pri = 1;
9595 syn_filter.hig_pri = 0;
9597 syn_filter.queue = res->queue_id;
9598 ret = rte_eth_dev_filter_ctrl(res->port_id,
9603 ret = rte_eth_dev_filter_ctrl(res->port_id,
9605 RTE_ETH_FILTER_DELETE,
9609 printf("syn filter programming error: (%s)\n",
9613 cmdline_parse_token_string_t cmd_syn_filter_filter =
9614 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9615 filter, "syn_filter");
9616 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9617 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9619 cmdline_parse_token_string_t cmd_syn_filter_ops =
9620 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9622 cmdline_parse_token_string_t cmd_syn_filter_priority =
9623 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9624 priority, "priority");
9625 cmdline_parse_token_string_t cmd_syn_filter_high =
9626 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9628 cmdline_parse_token_string_t cmd_syn_filter_queue =
9629 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9631 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9632 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9635 cmdline_parse_inst_t cmd_syn_filter = {
9636 .f = cmd_syn_filter_parsed,
9638 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9639 "<queue_id>: Add/Delete syn filter",
9641 (void *)&cmd_syn_filter_filter,
9642 (void *)&cmd_syn_filter_port_id,
9643 (void *)&cmd_syn_filter_ops,
9644 (void *)&cmd_syn_filter_priority,
9645 (void *)&cmd_syn_filter_high,
9646 (void *)&cmd_syn_filter_queue,
9647 (void *)&cmd_syn_filter_queue_id,
9652 /* *** queue region set *** */
9653 struct cmd_queue_region_result {
9654 cmdline_fixed_string_t set;
9655 cmdline_fixed_string_t port;
9657 cmdline_fixed_string_t cmd;
9658 cmdline_fixed_string_t region;
9660 cmdline_fixed_string_t queue_start_index;
9662 cmdline_fixed_string_t queue_num;
9663 uint8_t queue_num_value;
9667 cmd_queue_region_parsed(void *parsed_result,
9668 __attribute__((unused)) struct cmdline *cl,
9669 __attribute__((unused)) void *data)
9671 struct cmd_queue_region_result *res = parsed_result;
9673 #ifdef RTE_LIBRTE_I40E_PMD
9674 struct rte_pmd_i40e_queue_region_conf region_conf;
9675 enum rte_pmd_i40e_queue_region_op op_type;
9678 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9681 #ifdef RTE_LIBRTE_I40E_PMD
9682 memset(®ion_conf, 0, sizeof(region_conf));
9683 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9684 region_conf.region_id = res->region_id;
9685 region_conf.queue_num = res->queue_num_value;
9686 region_conf.queue_start_index = res->queue_id;
9688 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9689 op_type, ®ion_conf);
9696 printf("function not implemented or supported\n");
9699 printf("queue region config error: (%s)\n", strerror(-ret));
9703 cmdline_parse_token_string_t cmd_queue_region_set =
9704 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9706 cmdline_parse_token_string_t cmd_queue_region_port =
9707 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9708 cmdline_parse_token_num_t cmd_queue_region_port_id =
9709 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9711 cmdline_parse_token_string_t cmd_queue_region_cmd =
9712 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9713 cmd, "queue-region");
9714 cmdline_parse_token_string_t cmd_queue_region_id =
9715 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9716 region, "region_id");
9717 cmdline_parse_token_num_t cmd_queue_region_index =
9718 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9720 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9721 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9722 queue_start_index, "queue_start_index");
9723 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9724 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9726 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9727 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9728 queue_num, "queue_num");
9729 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9730 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9731 queue_num_value, UINT8);
9733 cmdline_parse_inst_t cmd_queue_region = {
9734 .f = cmd_queue_region_parsed,
9736 .help_str = "set port <port_id> queue-region region_id <value> "
9737 "queue_start_index <value> queue_num <value>: Set a queue region",
9739 (void *)&cmd_queue_region_set,
9740 (void *)&cmd_queue_region_port,
9741 (void *)&cmd_queue_region_port_id,
9742 (void *)&cmd_queue_region_cmd,
9743 (void *)&cmd_queue_region_id,
9744 (void *)&cmd_queue_region_index,
9745 (void *)&cmd_queue_region_queue_start_index,
9746 (void *)&cmd_queue_region_queue_id,
9747 (void *)&cmd_queue_region_queue_num,
9748 (void *)&cmd_queue_region_queue_num_value,
9753 /* *** queue region and flowtype set *** */
9754 struct cmd_region_flowtype_result {
9755 cmdline_fixed_string_t set;
9756 cmdline_fixed_string_t port;
9758 cmdline_fixed_string_t cmd;
9759 cmdline_fixed_string_t region;
9761 cmdline_fixed_string_t flowtype;
9762 uint8_t flowtype_id;
9766 cmd_region_flowtype_parsed(void *parsed_result,
9767 __attribute__((unused)) struct cmdline *cl,
9768 __attribute__((unused)) void *data)
9770 struct cmd_region_flowtype_result *res = parsed_result;
9772 #ifdef RTE_LIBRTE_I40E_PMD
9773 struct rte_pmd_i40e_queue_region_conf region_conf;
9774 enum rte_pmd_i40e_queue_region_op op_type;
9777 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9780 #ifdef RTE_LIBRTE_I40E_PMD
9781 memset(®ion_conf, 0, sizeof(region_conf));
9783 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9784 region_conf.region_id = res->region_id;
9785 region_conf.hw_flowtype = res->flowtype_id;
9787 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9788 op_type, ®ion_conf);
9795 printf("function not implemented or supported\n");
9798 printf("region flowtype config error: (%s)\n", strerror(-ret));
9802 cmdline_parse_token_string_t cmd_region_flowtype_set =
9803 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9805 cmdline_parse_token_string_t cmd_region_flowtype_port =
9806 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9808 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9809 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9811 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9812 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9813 cmd, "queue-region");
9814 cmdline_parse_token_string_t cmd_region_flowtype_index =
9815 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9816 region, "region_id");
9817 cmdline_parse_token_num_t cmd_region_flowtype_id =
9818 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9820 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9821 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9822 flowtype, "flowtype");
9823 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9824 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9825 flowtype_id, UINT8);
9826 cmdline_parse_inst_t cmd_region_flowtype = {
9827 .f = cmd_region_flowtype_parsed,
9829 .help_str = "set port <port_id> queue-region region_id <value> "
9830 "flowtype <value>: Set a flowtype region index",
9832 (void *)&cmd_region_flowtype_set,
9833 (void *)&cmd_region_flowtype_port,
9834 (void *)&cmd_region_flowtype_port_index,
9835 (void *)&cmd_region_flowtype_cmd,
9836 (void *)&cmd_region_flowtype_index,
9837 (void *)&cmd_region_flowtype_id,
9838 (void *)&cmd_region_flowtype_flow_index,
9839 (void *)&cmd_region_flowtype_flow_id,
9844 /* *** User Priority (UP) to queue region (region_id) set *** */
9845 struct cmd_user_priority_region_result {
9846 cmdline_fixed_string_t set;
9847 cmdline_fixed_string_t port;
9849 cmdline_fixed_string_t cmd;
9850 cmdline_fixed_string_t user_priority;
9851 uint8_t user_priority_id;
9852 cmdline_fixed_string_t region;
9857 cmd_user_priority_region_parsed(void *parsed_result,
9858 __attribute__((unused)) struct cmdline *cl,
9859 __attribute__((unused)) void *data)
9861 struct cmd_user_priority_region_result *res = parsed_result;
9863 #ifdef RTE_LIBRTE_I40E_PMD
9864 struct rte_pmd_i40e_queue_region_conf region_conf;
9865 enum rte_pmd_i40e_queue_region_op op_type;
9868 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9871 #ifdef RTE_LIBRTE_I40E_PMD
9872 memset(®ion_conf, 0, sizeof(region_conf));
9873 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9874 region_conf.user_priority = res->user_priority_id;
9875 region_conf.region_id = res->region_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("user_priority region config error: (%s)\n",
9893 cmdline_parse_token_string_t cmd_user_priority_region_set =
9894 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9896 cmdline_parse_token_string_t cmd_user_priority_region_port =
9897 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9899 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9900 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9902 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9903 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9904 cmd, "queue-region");
9905 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9906 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9907 user_priority, "UP");
9908 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9909 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9910 user_priority_id, UINT8);
9911 cmdline_parse_token_string_t cmd_user_priority_region_region =
9912 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9913 region, "region_id");
9914 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9915 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9918 cmdline_parse_inst_t cmd_user_priority_region = {
9919 .f = cmd_user_priority_region_parsed,
9921 .help_str = "set port <port_id> queue-region UP <value> "
9922 "region_id <value>: Set the mapping of User Priority (UP) "
9923 "to queue region (region_id) ",
9925 (void *)&cmd_user_priority_region_set,
9926 (void *)&cmd_user_priority_region_port,
9927 (void *)&cmd_user_priority_region_port_index,
9928 (void *)&cmd_user_priority_region_cmd,
9929 (void *)&cmd_user_priority_region_UP,
9930 (void *)&cmd_user_priority_region_UP_id,
9931 (void *)&cmd_user_priority_region_region,
9932 (void *)&cmd_user_priority_region_region_id,
9937 /* *** flush all queue region related configuration *** */
9938 struct cmd_flush_queue_region_result {
9939 cmdline_fixed_string_t set;
9940 cmdline_fixed_string_t port;
9942 cmdline_fixed_string_t cmd;
9943 cmdline_fixed_string_t flush;
9944 cmdline_fixed_string_t what;
9948 cmd_flush_queue_region_parsed(void *parsed_result,
9949 __attribute__((unused)) struct cmdline *cl,
9950 __attribute__((unused)) void *data)
9952 struct cmd_flush_queue_region_result *res = parsed_result;
9954 #ifdef RTE_LIBRTE_I40E_PMD
9955 struct rte_pmd_i40e_queue_region_conf region_conf;
9956 enum rte_pmd_i40e_queue_region_op op_type;
9959 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9962 #ifdef RTE_LIBRTE_I40E_PMD
9963 memset(®ion_conf, 0, sizeof(region_conf));
9965 if (strcmp(res->what, "on") == 0)
9966 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9968 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9970 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9971 op_type, ®ion_conf);
9978 printf("function not implemented or supported\n");
9981 printf("queue region config flush error: (%s)\n",
9986 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9987 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9989 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9990 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9992 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9993 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9995 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9996 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9997 cmd, "queue-region");
9998 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9999 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10001 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10002 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10005 cmdline_parse_inst_t cmd_flush_queue_region = {
10006 .f = cmd_flush_queue_region_parsed,
10008 .help_str = "set port <port_id> queue-region flush on|off"
10009 ": flush all queue region related configuration",
10011 (void *)&cmd_flush_queue_region_set,
10012 (void *)&cmd_flush_queue_region_port,
10013 (void *)&cmd_flush_queue_region_port_index,
10014 (void *)&cmd_flush_queue_region_cmd,
10015 (void *)&cmd_flush_queue_region_flush,
10016 (void *)&cmd_flush_queue_region_what,
10021 /* *** get all queue region related configuration info *** */
10022 struct cmd_show_queue_region_info {
10023 cmdline_fixed_string_t show;
10024 cmdline_fixed_string_t port;
10026 cmdline_fixed_string_t cmd;
10030 cmd_show_queue_region_info_parsed(void *parsed_result,
10031 __attribute__((unused)) struct cmdline *cl,
10032 __attribute__((unused)) void *data)
10034 struct cmd_show_queue_region_info *res = parsed_result;
10035 int ret = -ENOTSUP;
10036 #ifdef RTE_LIBRTE_I40E_PMD
10037 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10038 enum rte_pmd_i40e_queue_region_op op_type;
10041 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10044 #ifdef RTE_LIBRTE_I40E_PMD
10045 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10047 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10049 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10050 op_type, &rte_pmd_regions);
10052 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10059 printf("function not implemented or supported\n");
10062 printf("queue region config info show error: (%s)\n",
10067 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10068 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10070 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10071 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10073 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10074 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10076 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10077 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10078 cmd, "queue-region");
10080 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10081 .f = cmd_show_queue_region_info_parsed,
10083 .help_str = "show port <port_id> queue-region"
10084 ": show all queue region related configuration info",
10086 (void *)&cmd_show_queue_region_info_get,
10087 (void *)&cmd_show_queue_region_info_port,
10088 (void *)&cmd_show_queue_region_info_port_index,
10089 (void *)&cmd_show_queue_region_info_cmd,
10094 /* *** ADD/REMOVE A 2tuple FILTER *** */
10095 struct cmd_2tuple_filter_result {
10096 cmdline_fixed_string_t filter;
10098 cmdline_fixed_string_t ops;
10099 cmdline_fixed_string_t dst_port;
10100 uint16_t dst_port_value;
10101 cmdline_fixed_string_t protocol;
10102 uint8_t protocol_value;
10103 cmdline_fixed_string_t mask;
10104 uint8_t mask_value;
10105 cmdline_fixed_string_t tcp_flags;
10106 uint8_t tcp_flags_value;
10107 cmdline_fixed_string_t priority;
10108 uint8_t priority_value;
10109 cmdline_fixed_string_t queue;
10114 cmd_2tuple_filter_parsed(void *parsed_result,
10115 __attribute__((unused)) struct cmdline *cl,
10116 __attribute__((unused)) void *data)
10118 struct rte_eth_ntuple_filter filter;
10119 struct cmd_2tuple_filter_result *res = parsed_result;
10122 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10124 printf("ntuple filter is not supported on port %u.\n",
10129 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10131 filter.flags = RTE_2TUPLE_FLAGS;
10132 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10133 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10134 filter.proto = res->protocol_value;
10135 filter.priority = res->priority_value;
10136 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10137 printf("nonzero tcp_flags is only meaningful"
10138 " when protocol is TCP.\n");
10141 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10142 printf("invalid TCP flags.\n");
10146 if (res->tcp_flags_value != 0) {
10147 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10148 filter.tcp_flags = res->tcp_flags_value;
10151 /* need convert to big endian. */
10152 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10153 filter.queue = res->queue_id;
10155 if (!strcmp(res->ops, "add"))
10156 ret = rte_eth_dev_filter_ctrl(res->port_id,
10157 RTE_ETH_FILTER_NTUPLE,
10158 RTE_ETH_FILTER_ADD,
10161 ret = rte_eth_dev_filter_ctrl(res->port_id,
10162 RTE_ETH_FILTER_NTUPLE,
10163 RTE_ETH_FILTER_DELETE,
10166 printf("2tuple filter programming error: (%s)\n",
10171 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10172 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10173 filter, "2tuple_filter");
10174 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10175 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10177 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10178 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10180 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10181 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10182 dst_port, "dst_port");
10183 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10184 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10185 dst_port_value, UINT16);
10186 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10187 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10188 protocol, "protocol");
10189 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10190 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10191 protocol_value, UINT8);
10192 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10193 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10195 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10196 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10198 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10199 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10200 tcp_flags, "tcp_flags");
10201 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10202 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10203 tcp_flags_value, UINT8);
10204 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10205 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10206 priority, "priority");
10207 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10208 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10209 priority_value, UINT8);
10210 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10211 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10213 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10214 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10217 cmdline_parse_inst_t cmd_2tuple_filter = {
10218 .f = cmd_2tuple_filter_parsed,
10220 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10221 "<value> mask <value> tcp_flags <value> priority <value> queue "
10222 "<queue_id>: Add a 2tuple filter",
10224 (void *)&cmd_2tuple_filter_filter,
10225 (void *)&cmd_2tuple_filter_port_id,
10226 (void *)&cmd_2tuple_filter_ops,
10227 (void *)&cmd_2tuple_filter_dst_port,
10228 (void *)&cmd_2tuple_filter_dst_port_value,
10229 (void *)&cmd_2tuple_filter_protocol,
10230 (void *)&cmd_2tuple_filter_protocol_value,
10231 (void *)&cmd_2tuple_filter_mask,
10232 (void *)&cmd_2tuple_filter_mask_value,
10233 (void *)&cmd_2tuple_filter_tcp_flags,
10234 (void *)&cmd_2tuple_filter_tcp_flags_value,
10235 (void *)&cmd_2tuple_filter_priority,
10236 (void *)&cmd_2tuple_filter_priority_value,
10237 (void *)&cmd_2tuple_filter_queue,
10238 (void *)&cmd_2tuple_filter_queue_id,
10243 /* *** ADD/REMOVE A 5tuple FILTER *** */
10244 struct cmd_5tuple_filter_result {
10245 cmdline_fixed_string_t filter;
10247 cmdline_fixed_string_t ops;
10248 cmdline_fixed_string_t dst_ip;
10249 cmdline_ipaddr_t dst_ip_value;
10250 cmdline_fixed_string_t src_ip;
10251 cmdline_ipaddr_t src_ip_value;
10252 cmdline_fixed_string_t dst_port;
10253 uint16_t dst_port_value;
10254 cmdline_fixed_string_t src_port;
10255 uint16_t src_port_value;
10256 cmdline_fixed_string_t protocol;
10257 uint8_t protocol_value;
10258 cmdline_fixed_string_t mask;
10259 uint8_t mask_value;
10260 cmdline_fixed_string_t tcp_flags;
10261 uint8_t tcp_flags_value;
10262 cmdline_fixed_string_t priority;
10263 uint8_t priority_value;
10264 cmdline_fixed_string_t queue;
10269 cmd_5tuple_filter_parsed(void *parsed_result,
10270 __attribute__((unused)) struct cmdline *cl,
10271 __attribute__((unused)) void *data)
10273 struct rte_eth_ntuple_filter filter;
10274 struct cmd_5tuple_filter_result *res = parsed_result;
10277 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10279 printf("ntuple filter is not supported on port %u.\n",
10284 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10286 filter.flags = RTE_5TUPLE_FLAGS;
10287 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10288 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10289 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10290 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10291 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10292 filter.proto = res->protocol_value;
10293 filter.priority = res->priority_value;
10294 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10295 printf("nonzero tcp_flags is only meaningful"
10296 " when protocol is TCP.\n");
10299 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10300 printf("invalid TCP flags.\n");
10304 if (res->tcp_flags_value != 0) {
10305 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10306 filter.tcp_flags = res->tcp_flags_value;
10309 if (res->dst_ip_value.family == AF_INET)
10310 /* no need to convert, already big endian. */
10311 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10313 if (filter.dst_ip_mask == 0) {
10314 printf("can not support ipv6 involved compare.\n");
10320 if (res->src_ip_value.family == AF_INET)
10321 /* no need to convert, already big endian. */
10322 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10324 if (filter.src_ip_mask == 0) {
10325 printf("can not support ipv6 involved compare.\n");
10330 /* need convert to big endian. */
10331 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10332 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10333 filter.queue = res->queue_id;
10335 if (!strcmp(res->ops, "add"))
10336 ret = rte_eth_dev_filter_ctrl(res->port_id,
10337 RTE_ETH_FILTER_NTUPLE,
10338 RTE_ETH_FILTER_ADD,
10341 ret = rte_eth_dev_filter_ctrl(res->port_id,
10342 RTE_ETH_FILTER_NTUPLE,
10343 RTE_ETH_FILTER_DELETE,
10346 printf("5tuple filter programming error: (%s)\n",
10350 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10351 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10352 filter, "5tuple_filter");
10353 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10354 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10356 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10357 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10359 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10360 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10362 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10363 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10365 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10366 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10368 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10369 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10371 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10372 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10373 dst_port, "dst_port");
10374 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10375 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10376 dst_port_value, UINT16);
10377 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10378 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10379 src_port, "src_port");
10380 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10381 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10382 src_port_value, UINT16);
10383 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10384 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10385 protocol, "protocol");
10386 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10387 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10388 protocol_value, UINT8);
10389 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10390 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10392 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10393 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10395 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10396 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10397 tcp_flags, "tcp_flags");
10398 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10399 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10400 tcp_flags_value, UINT8);
10401 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10402 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10403 priority, "priority");
10404 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10405 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10406 priority_value, UINT8);
10407 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10408 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10410 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10411 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10414 cmdline_parse_inst_t cmd_5tuple_filter = {
10415 .f = cmd_5tuple_filter_parsed,
10417 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10418 "src_ip <value> dst_port <value> src_port <value> "
10419 "protocol <value> mask <value> tcp_flags <value> "
10420 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10422 (void *)&cmd_5tuple_filter_filter,
10423 (void *)&cmd_5tuple_filter_port_id,
10424 (void *)&cmd_5tuple_filter_ops,
10425 (void *)&cmd_5tuple_filter_dst_ip,
10426 (void *)&cmd_5tuple_filter_dst_ip_value,
10427 (void *)&cmd_5tuple_filter_src_ip,
10428 (void *)&cmd_5tuple_filter_src_ip_value,
10429 (void *)&cmd_5tuple_filter_dst_port,
10430 (void *)&cmd_5tuple_filter_dst_port_value,
10431 (void *)&cmd_5tuple_filter_src_port,
10432 (void *)&cmd_5tuple_filter_src_port_value,
10433 (void *)&cmd_5tuple_filter_protocol,
10434 (void *)&cmd_5tuple_filter_protocol_value,
10435 (void *)&cmd_5tuple_filter_mask,
10436 (void *)&cmd_5tuple_filter_mask_value,
10437 (void *)&cmd_5tuple_filter_tcp_flags,
10438 (void *)&cmd_5tuple_filter_tcp_flags_value,
10439 (void *)&cmd_5tuple_filter_priority,
10440 (void *)&cmd_5tuple_filter_priority_value,
10441 (void *)&cmd_5tuple_filter_queue,
10442 (void *)&cmd_5tuple_filter_queue_id,
10447 /* *** ADD/REMOVE A flex FILTER *** */
10448 struct cmd_flex_filter_result {
10449 cmdline_fixed_string_t filter;
10450 cmdline_fixed_string_t ops;
10452 cmdline_fixed_string_t len;
10454 cmdline_fixed_string_t bytes;
10455 cmdline_fixed_string_t bytes_value;
10456 cmdline_fixed_string_t mask;
10457 cmdline_fixed_string_t mask_value;
10458 cmdline_fixed_string_t priority;
10459 uint8_t priority_value;
10460 cmdline_fixed_string_t queue;
10464 static int xdigit2val(unsigned char c)
10469 else if (isupper(c))
10470 val = c - 'A' + 10;
10472 val = c - 'a' + 10;
10477 cmd_flex_filter_parsed(void *parsed_result,
10478 __attribute__((unused)) struct cmdline *cl,
10479 __attribute__((unused)) void *data)
10482 struct rte_eth_flex_filter filter;
10483 struct cmd_flex_filter_result *res = parsed_result;
10484 char *bytes_ptr, *mask_ptr;
10485 uint16_t len, i, j = 0;
10490 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10491 printf("the len exceed the max length 128\n");
10494 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10495 filter.len = res->len_value;
10496 filter.priority = res->priority_value;
10497 filter.queue = res->queue_id;
10498 bytes_ptr = res->bytes_value;
10499 mask_ptr = res->mask_value;
10501 /* translate bytes string to array. */
10502 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10503 (bytes_ptr[1] == 'X')))
10505 len = strnlen(bytes_ptr, res->len_value * 2);
10506 if (len == 0 || (len % 8 != 0)) {
10507 printf("please check len and bytes input\n");
10510 for (i = 0; i < len; i++) {
10512 if (isxdigit(c) == 0) {
10513 /* invalid characters. */
10514 printf("invalid input\n");
10517 val = xdigit2val(c);
10520 filter.bytes[j] = byte;
10521 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10528 /* translate mask string to uint8_t array. */
10529 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10530 (mask_ptr[1] == 'X')))
10532 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10534 printf("invalid input\n");
10539 for (i = 0; i < len; i++) {
10541 if (isxdigit(c) == 0) {
10542 /* invalid characters. */
10543 printf("invalid input\n");
10546 val = xdigit2val(c);
10549 filter.mask[j] = byte;
10550 printf("mask[%d]:%02x ", j, filter.mask[j]);
10558 if (!strcmp(res->ops, "add"))
10559 ret = rte_eth_dev_filter_ctrl(res->port_id,
10560 RTE_ETH_FILTER_FLEXIBLE,
10561 RTE_ETH_FILTER_ADD,
10564 ret = rte_eth_dev_filter_ctrl(res->port_id,
10565 RTE_ETH_FILTER_FLEXIBLE,
10566 RTE_ETH_FILTER_DELETE,
10570 printf("flex filter setting error: (%s)\n", strerror(-ret));
10573 cmdline_parse_token_string_t cmd_flex_filter_filter =
10574 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10575 filter, "flex_filter");
10576 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10577 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10579 cmdline_parse_token_string_t cmd_flex_filter_ops =
10580 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10582 cmdline_parse_token_string_t cmd_flex_filter_len =
10583 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10585 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10586 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10588 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10589 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10591 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10592 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10593 bytes_value, NULL);
10594 cmdline_parse_token_string_t cmd_flex_filter_mask =
10595 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10597 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10598 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10600 cmdline_parse_token_string_t cmd_flex_filter_priority =
10601 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10602 priority, "priority");
10603 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10604 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10605 priority_value, UINT8);
10606 cmdline_parse_token_string_t cmd_flex_filter_queue =
10607 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10609 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10610 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10612 cmdline_parse_inst_t cmd_flex_filter = {
10613 .f = cmd_flex_filter_parsed,
10615 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10616 "<value> mask <value> priority <value> queue <queue_id>: "
10617 "Add/Del a flex filter",
10619 (void *)&cmd_flex_filter_filter,
10620 (void *)&cmd_flex_filter_port_id,
10621 (void *)&cmd_flex_filter_ops,
10622 (void *)&cmd_flex_filter_len,
10623 (void *)&cmd_flex_filter_len_value,
10624 (void *)&cmd_flex_filter_bytes,
10625 (void *)&cmd_flex_filter_bytes_value,
10626 (void *)&cmd_flex_filter_mask,
10627 (void *)&cmd_flex_filter_mask_value,
10628 (void *)&cmd_flex_filter_priority,
10629 (void *)&cmd_flex_filter_priority_value,
10630 (void *)&cmd_flex_filter_queue,
10631 (void *)&cmd_flex_filter_queue_id,
10636 /* *** Filters Control *** */
10638 /* *** deal with ethertype filter *** */
10639 struct cmd_ethertype_filter_result {
10640 cmdline_fixed_string_t filter;
10642 cmdline_fixed_string_t ops;
10643 cmdline_fixed_string_t mac;
10644 struct rte_ether_addr mac_addr;
10645 cmdline_fixed_string_t ethertype;
10646 uint16_t ethertype_value;
10647 cmdline_fixed_string_t drop;
10648 cmdline_fixed_string_t queue;
10652 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10653 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10654 filter, "ethertype_filter");
10655 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10656 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10658 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10659 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10661 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10662 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10663 mac, "mac_addr#mac_ignr");
10664 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10665 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10667 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10668 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10669 ethertype, "ethertype");
10670 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10671 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10672 ethertype_value, UINT16);
10673 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10674 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10676 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10677 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10679 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10680 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10684 cmd_ethertype_filter_parsed(void *parsed_result,
10685 __attribute__((unused)) struct cmdline *cl,
10686 __attribute__((unused)) void *data)
10688 struct cmd_ethertype_filter_result *res = parsed_result;
10689 struct rte_eth_ethertype_filter filter;
10692 ret = rte_eth_dev_filter_supported(res->port_id,
10693 RTE_ETH_FILTER_ETHERTYPE);
10695 printf("ethertype filter is not supported on port %u.\n",
10700 memset(&filter, 0, sizeof(filter));
10701 if (!strcmp(res->mac, "mac_addr")) {
10702 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10703 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10704 sizeof(struct rte_ether_addr));
10706 if (!strcmp(res->drop, "drop"))
10707 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10708 filter.ether_type = res->ethertype_value;
10709 filter.queue = res->queue_id;
10711 if (!strcmp(res->ops, "add"))
10712 ret = rte_eth_dev_filter_ctrl(res->port_id,
10713 RTE_ETH_FILTER_ETHERTYPE,
10714 RTE_ETH_FILTER_ADD,
10717 ret = rte_eth_dev_filter_ctrl(res->port_id,
10718 RTE_ETH_FILTER_ETHERTYPE,
10719 RTE_ETH_FILTER_DELETE,
10722 printf("ethertype filter programming error: (%s)\n",
10726 cmdline_parse_inst_t cmd_ethertype_filter = {
10727 .f = cmd_ethertype_filter_parsed,
10729 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10730 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10731 "Add or delete an ethertype filter entry",
10733 (void *)&cmd_ethertype_filter_filter,
10734 (void *)&cmd_ethertype_filter_port_id,
10735 (void *)&cmd_ethertype_filter_ops,
10736 (void *)&cmd_ethertype_filter_mac,
10737 (void *)&cmd_ethertype_filter_mac_addr,
10738 (void *)&cmd_ethertype_filter_ethertype,
10739 (void *)&cmd_ethertype_filter_ethertype_value,
10740 (void *)&cmd_ethertype_filter_drop,
10741 (void *)&cmd_ethertype_filter_queue,
10742 (void *)&cmd_ethertype_filter_queue_id,
10747 /* *** deal with flow director filter *** */
10748 struct cmd_flow_director_result {
10749 cmdline_fixed_string_t flow_director_filter;
10751 cmdline_fixed_string_t mode;
10752 cmdline_fixed_string_t mode_value;
10753 cmdline_fixed_string_t ops;
10754 cmdline_fixed_string_t flow;
10755 cmdline_fixed_string_t flow_type;
10756 cmdline_fixed_string_t ether;
10757 uint16_t ether_type;
10758 cmdline_fixed_string_t src;
10759 cmdline_ipaddr_t ip_src;
10761 cmdline_fixed_string_t dst;
10762 cmdline_ipaddr_t ip_dst;
10764 cmdline_fixed_string_t verify_tag;
10765 uint32_t verify_tag_value;
10766 cmdline_fixed_string_t tos;
10768 cmdline_fixed_string_t proto;
10769 uint8_t proto_value;
10770 cmdline_fixed_string_t ttl;
10772 cmdline_fixed_string_t vlan;
10773 uint16_t vlan_value;
10774 cmdline_fixed_string_t flexbytes;
10775 cmdline_fixed_string_t flexbytes_value;
10776 cmdline_fixed_string_t pf_vf;
10777 cmdline_fixed_string_t drop;
10778 cmdline_fixed_string_t queue;
10780 cmdline_fixed_string_t fd_id;
10781 uint32_t fd_id_value;
10782 cmdline_fixed_string_t mac;
10783 struct rte_ether_addr mac_addr;
10784 cmdline_fixed_string_t tunnel;
10785 cmdline_fixed_string_t tunnel_type;
10786 cmdline_fixed_string_t tunnel_id;
10787 uint32_t tunnel_id_value;
10788 cmdline_fixed_string_t packet;
10793 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10796 const char *p, *p0 = q_arg;
10798 unsigned long int_fld;
10799 char *str_fld[max_num];
10804 p = strchr(p0, '(');
10808 p0 = strchr(p, ')');
10813 if (size >= sizeof(s))
10816 snprintf(s, sizeof(s), "%.*s", size, p);
10817 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10818 if (ret < 0 || ret > max_num)
10820 for (i = 0; i < ret; i++) {
10822 int_fld = strtoul(str_fld[i], &end, 0);
10823 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10825 flexbytes[i] = (uint8_t)int_fld;
10831 str2flowtype(char *string)
10834 static const struct {
10837 } flowtype_str[] = {
10838 {"raw", RTE_ETH_FLOW_RAW},
10839 {"ipv4", RTE_ETH_FLOW_IPV4},
10840 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10841 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10842 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10843 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10844 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10845 {"ipv6", RTE_ETH_FLOW_IPV6},
10846 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10847 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10848 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10849 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10850 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10851 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10854 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10855 if (!strcmp(flowtype_str[i].str, string))
10856 return flowtype_str[i].type;
10859 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10860 return (uint16_t)atoi(string);
10862 return RTE_ETH_FLOW_UNKNOWN;
10865 static enum rte_eth_fdir_tunnel_type
10866 str2fdir_tunneltype(char *string)
10870 static const struct {
10872 enum rte_eth_fdir_tunnel_type type;
10873 } tunneltype_str[] = {
10874 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10875 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10878 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10879 if (!strcmp(tunneltype_str[i].str, string))
10880 return tunneltype_str[i].type;
10882 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10885 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10887 if ((ip_addr).family == AF_INET) \
10888 (ip) = (ip_addr).addr.ipv4.s_addr; \
10890 printf("invalid parameter.\n"); \
10895 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10897 if ((ip_addr).family == AF_INET6) \
10898 rte_memcpy(&(ip), \
10899 &((ip_addr).addr.ipv6), \
10900 sizeof(struct in6_addr)); \
10902 printf("invalid parameter.\n"); \
10908 cmd_flow_director_filter_parsed(void *parsed_result,
10909 __attribute__((unused)) struct cmdline *cl,
10910 __attribute__((unused)) void *data)
10912 struct cmd_flow_director_result *res = parsed_result;
10913 struct rte_eth_fdir_filter entry;
10914 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10916 unsigned long vf_id;
10919 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10921 printf("flow director is not supported on port %u.\n",
10925 memset(flexbytes, 0, sizeof(flexbytes));
10926 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10928 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10929 if (strcmp(res->mode_value, "MAC-VLAN")) {
10930 printf("Please set mode to MAC-VLAN.\n");
10933 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10934 if (strcmp(res->mode_value, "Tunnel")) {
10935 printf("Please set mode to Tunnel.\n");
10939 if (!strcmp(res->mode_value, "raw")) {
10940 #ifdef RTE_LIBRTE_I40E_PMD
10941 struct rte_pmd_i40e_flow_type_mapping
10942 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10943 struct rte_pmd_i40e_pkt_template_conf conf;
10944 uint16_t flow_type = str2flowtype(res->flow_type);
10945 uint16_t i, port = res->port_id;
10948 memset(&conf, 0, sizeof(conf));
10950 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10951 printf("Invalid flow type specified.\n");
10954 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10958 if (mapping[flow_type].pctype == 0ULL) {
10959 printf("Invalid flow type specified.\n");
10962 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10963 if (mapping[flow_type].pctype & (1ULL << i)) {
10964 conf.input.pctype = i;
10969 conf.input.packet = open_file(res->filepath,
10970 &conf.input.length);
10971 if (!conf.input.packet)
10973 if (!strcmp(res->drop, "drop"))
10974 conf.action.behavior =
10975 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10977 conf.action.behavior =
10978 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10979 conf.action.report_status =
10980 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10981 conf.action.rx_queue = res->queue_id;
10982 conf.soft_id = res->fd_id_value;
10983 add = strcmp(res->ops, "del") ? 1 : 0;
10984 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10988 printf("flow director config error: (%s)\n",
10990 close_file(conf.input.packet);
10993 } else if (strcmp(res->mode_value, "IP")) {
10994 printf("Please set mode to IP or raw.\n");
10997 entry.input.flow_type = str2flowtype(res->flow_type);
11000 ret = parse_flexbytes(res->flexbytes_value,
11002 RTE_ETH_FDIR_MAX_FLEXLEN);
11004 printf("error: Cannot parse flexbytes input.\n");
11008 switch (entry.input.flow_type) {
11009 case RTE_ETH_FLOW_FRAG_IPV4:
11010 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
11011 entry.input.flow.ip4_flow.proto = res->proto_value;
11013 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
11014 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
11015 IPV4_ADDR_TO_UINT(res->ip_dst,
11016 entry.input.flow.ip4_flow.dst_ip);
11017 IPV4_ADDR_TO_UINT(res->ip_src,
11018 entry.input.flow.ip4_flow.src_ip);
11019 entry.input.flow.ip4_flow.tos = res->tos_value;
11020 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11021 /* need convert to big endian. */
11022 entry.input.flow.udp4_flow.dst_port =
11023 rte_cpu_to_be_16(res->port_dst);
11024 entry.input.flow.udp4_flow.src_port =
11025 rte_cpu_to_be_16(res->port_src);
11027 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
11028 IPV4_ADDR_TO_UINT(res->ip_dst,
11029 entry.input.flow.sctp4_flow.ip.dst_ip);
11030 IPV4_ADDR_TO_UINT(res->ip_src,
11031 entry.input.flow.sctp4_flow.ip.src_ip);
11032 entry.input.flow.ip4_flow.tos = res->tos_value;
11033 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11034 /* need convert to big endian. */
11035 entry.input.flow.sctp4_flow.dst_port =
11036 rte_cpu_to_be_16(res->port_dst);
11037 entry.input.flow.sctp4_flow.src_port =
11038 rte_cpu_to_be_16(res->port_src);
11039 entry.input.flow.sctp4_flow.verify_tag =
11040 rte_cpu_to_be_32(res->verify_tag_value);
11042 case RTE_ETH_FLOW_FRAG_IPV6:
11043 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11044 entry.input.flow.ipv6_flow.proto = res->proto_value;
11046 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11047 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11048 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11049 entry.input.flow.ipv6_flow.dst_ip);
11050 IPV6_ADDR_TO_ARRAY(res->ip_src,
11051 entry.input.flow.ipv6_flow.src_ip);
11052 entry.input.flow.ipv6_flow.tc = res->tos_value;
11053 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11054 /* need convert to big endian. */
11055 entry.input.flow.udp6_flow.dst_port =
11056 rte_cpu_to_be_16(res->port_dst);
11057 entry.input.flow.udp6_flow.src_port =
11058 rte_cpu_to_be_16(res->port_src);
11060 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11061 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11062 entry.input.flow.sctp6_flow.ip.dst_ip);
11063 IPV6_ADDR_TO_ARRAY(res->ip_src,
11064 entry.input.flow.sctp6_flow.ip.src_ip);
11065 entry.input.flow.ipv6_flow.tc = res->tos_value;
11066 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11067 /* need convert to big endian. */
11068 entry.input.flow.sctp6_flow.dst_port =
11069 rte_cpu_to_be_16(res->port_dst);
11070 entry.input.flow.sctp6_flow.src_port =
11071 rte_cpu_to_be_16(res->port_src);
11072 entry.input.flow.sctp6_flow.verify_tag =
11073 rte_cpu_to_be_32(res->verify_tag_value);
11075 case RTE_ETH_FLOW_L2_PAYLOAD:
11076 entry.input.flow.l2_flow.ether_type =
11077 rte_cpu_to_be_16(res->ether_type);
11083 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11084 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11086 sizeof(struct rte_ether_addr));
11088 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11089 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11091 sizeof(struct rte_ether_addr));
11092 entry.input.flow.tunnel_flow.tunnel_type =
11093 str2fdir_tunneltype(res->tunnel_type);
11094 entry.input.flow.tunnel_flow.tunnel_id =
11095 rte_cpu_to_be_32(res->tunnel_id_value);
11098 rte_memcpy(entry.input.flow_ext.flexbytes,
11100 RTE_ETH_FDIR_MAX_FLEXLEN);
11102 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11104 entry.action.flex_off = 0; /*use 0 by default */
11105 if (!strcmp(res->drop, "drop"))
11106 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11108 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11110 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11111 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11112 if (!strcmp(res->pf_vf, "pf"))
11113 entry.input.flow_ext.is_vf = 0;
11114 else if (!strncmp(res->pf_vf, "vf", 2)) {
11115 struct rte_eth_dev_info dev_info;
11117 ret = eth_dev_info_get_print_err(res->port_id,
11123 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11124 if (errno != 0 || *end != '\0' ||
11125 vf_id >= dev_info.max_vfs) {
11126 printf("invalid parameter %s.\n", res->pf_vf);
11129 entry.input.flow_ext.is_vf = 1;
11130 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11132 printf("invalid parameter %s.\n", res->pf_vf);
11137 /* set to report FD ID by default */
11138 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11139 entry.action.rx_queue = res->queue_id;
11140 entry.soft_id = res->fd_id_value;
11141 if (!strcmp(res->ops, "add"))
11142 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11143 RTE_ETH_FILTER_ADD, &entry);
11144 else if (!strcmp(res->ops, "del"))
11145 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11146 RTE_ETH_FILTER_DELETE, &entry);
11148 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11149 RTE_ETH_FILTER_UPDATE, &entry);
11151 printf("flow director programming error: (%s)\n",
11155 cmdline_parse_token_string_t cmd_flow_director_filter =
11156 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11157 flow_director_filter, "flow_director_filter");
11158 cmdline_parse_token_num_t cmd_flow_director_port_id =
11159 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11161 cmdline_parse_token_string_t cmd_flow_director_ops =
11162 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11163 ops, "add#del#update");
11164 cmdline_parse_token_string_t cmd_flow_director_flow =
11165 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11167 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11168 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11170 cmdline_parse_token_string_t cmd_flow_director_ether =
11171 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11173 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11174 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11175 ether_type, UINT16);
11176 cmdline_parse_token_string_t cmd_flow_director_src =
11177 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11179 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11180 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11182 cmdline_parse_token_num_t cmd_flow_director_port_src =
11183 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11185 cmdline_parse_token_string_t cmd_flow_director_dst =
11186 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11188 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11189 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11191 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11192 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11194 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11195 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11196 verify_tag, "verify_tag");
11197 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11198 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11199 verify_tag_value, UINT32);
11200 cmdline_parse_token_string_t cmd_flow_director_tos =
11201 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11203 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11204 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11206 cmdline_parse_token_string_t cmd_flow_director_proto =
11207 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11209 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11210 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11211 proto_value, UINT8);
11212 cmdline_parse_token_string_t cmd_flow_director_ttl =
11213 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11215 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11216 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11218 cmdline_parse_token_string_t cmd_flow_director_vlan =
11219 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11221 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11222 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11223 vlan_value, UINT16);
11224 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11225 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11226 flexbytes, "flexbytes");
11227 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11228 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11229 flexbytes_value, NULL);
11230 cmdline_parse_token_string_t cmd_flow_director_drop =
11231 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11233 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11234 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11236 cmdline_parse_token_string_t cmd_flow_director_queue =
11237 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11239 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11240 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11242 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11243 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11245 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11246 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11247 fd_id_value, UINT32);
11249 cmdline_parse_token_string_t cmd_flow_director_mode =
11250 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11252 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11253 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11255 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11256 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11257 mode_value, "MAC-VLAN");
11258 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11259 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11260 mode_value, "Tunnel");
11261 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11262 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11263 mode_value, "raw");
11264 cmdline_parse_token_string_t cmd_flow_director_mac =
11265 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11267 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11268 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11270 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11271 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11273 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11274 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11275 tunnel_type, "NVGRE#VxLAN");
11276 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11277 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11278 tunnel_id, "tunnel-id");
11279 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11280 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11281 tunnel_id_value, UINT32);
11282 cmdline_parse_token_string_t cmd_flow_director_packet =
11283 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11285 cmdline_parse_token_string_t cmd_flow_director_filepath =
11286 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11289 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11290 .f = cmd_flow_director_filter_parsed,
11292 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11293 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11294 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11295 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11296 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11297 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11298 "fd_id <fd_id_value>: "
11299 "Add or delete an ip flow director entry on NIC",
11301 (void *)&cmd_flow_director_filter,
11302 (void *)&cmd_flow_director_port_id,
11303 (void *)&cmd_flow_director_mode,
11304 (void *)&cmd_flow_director_mode_ip,
11305 (void *)&cmd_flow_director_ops,
11306 (void *)&cmd_flow_director_flow,
11307 (void *)&cmd_flow_director_flow_type,
11308 (void *)&cmd_flow_director_src,
11309 (void *)&cmd_flow_director_ip_src,
11310 (void *)&cmd_flow_director_dst,
11311 (void *)&cmd_flow_director_ip_dst,
11312 (void *)&cmd_flow_director_tos,
11313 (void *)&cmd_flow_director_tos_value,
11314 (void *)&cmd_flow_director_proto,
11315 (void *)&cmd_flow_director_proto_value,
11316 (void *)&cmd_flow_director_ttl,
11317 (void *)&cmd_flow_director_ttl_value,
11318 (void *)&cmd_flow_director_vlan,
11319 (void *)&cmd_flow_director_vlan_value,
11320 (void *)&cmd_flow_director_flexbytes,
11321 (void *)&cmd_flow_director_flexbytes_value,
11322 (void *)&cmd_flow_director_drop,
11323 (void *)&cmd_flow_director_pf_vf,
11324 (void *)&cmd_flow_director_queue,
11325 (void *)&cmd_flow_director_queue_id,
11326 (void *)&cmd_flow_director_fd_id,
11327 (void *)&cmd_flow_director_fd_id_value,
11332 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11333 .f = cmd_flow_director_filter_parsed,
11335 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11336 "director entry on NIC",
11338 (void *)&cmd_flow_director_filter,
11339 (void *)&cmd_flow_director_port_id,
11340 (void *)&cmd_flow_director_mode,
11341 (void *)&cmd_flow_director_mode_ip,
11342 (void *)&cmd_flow_director_ops,
11343 (void *)&cmd_flow_director_flow,
11344 (void *)&cmd_flow_director_flow_type,
11345 (void *)&cmd_flow_director_src,
11346 (void *)&cmd_flow_director_ip_src,
11347 (void *)&cmd_flow_director_port_src,
11348 (void *)&cmd_flow_director_dst,
11349 (void *)&cmd_flow_director_ip_dst,
11350 (void *)&cmd_flow_director_port_dst,
11351 (void *)&cmd_flow_director_tos,
11352 (void *)&cmd_flow_director_tos_value,
11353 (void *)&cmd_flow_director_ttl,
11354 (void *)&cmd_flow_director_ttl_value,
11355 (void *)&cmd_flow_director_vlan,
11356 (void *)&cmd_flow_director_vlan_value,
11357 (void *)&cmd_flow_director_flexbytes,
11358 (void *)&cmd_flow_director_flexbytes_value,
11359 (void *)&cmd_flow_director_drop,
11360 (void *)&cmd_flow_director_pf_vf,
11361 (void *)&cmd_flow_director_queue,
11362 (void *)&cmd_flow_director_queue_id,
11363 (void *)&cmd_flow_director_fd_id,
11364 (void *)&cmd_flow_director_fd_id_value,
11369 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11370 .f = cmd_flow_director_filter_parsed,
11372 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11373 "director entry on NIC",
11375 (void *)&cmd_flow_director_filter,
11376 (void *)&cmd_flow_director_port_id,
11377 (void *)&cmd_flow_director_mode,
11378 (void *)&cmd_flow_director_mode_ip,
11379 (void *)&cmd_flow_director_ops,
11380 (void *)&cmd_flow_director_flow,
11381 (void *)&cmd_flow_director_flow_type,
11382 (void *)&cmd_flow_director_src,
11383 (void *)&cmd_flow_director_ip_src,
11384 (void *)&cmd_flow_director_port_src,
11385 (void *)&cmd_flow_director_dst,
11386 (void *)&cmd_flow_director_ip_dst,
11387 (void *)&cmd_flow_director_port_dst,
11388 (void *)&cmd_flow_director_verify_tag,
11389 (void *)&cmd_flow_director_verify_tag_value,
11390 (void *)&cmd_flow_director_tos,
11391 (void *)&cmd_flow_director_tos_value,
11392 (void *)&cmd_flow_director_ttl,
11393 (void *)&cmd_flow_director_ttl_value,
11394 (void *)&cmd_flow_director_vlan,
11395 (void *)&cmd_flow_director_vlan_value,
11396 (void *)&cmd_flow_director_flexbytes,
11397 (void *)&cmd_flow_director_flexbytes_value,
11398 (void *)&cmd_flow_director_drop,
11399 (void *)&cmd_flow_director_pf_vf,
11400 (void *)&cmd_flow_director_queue,
11401 (void *)&cmd_flow_director_queue_id,
11402 (void *)&cmd_flow_director_fd_id,
11403 (void *)&cmd_flow_director_fd_id_value,
11408 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11409 .f = cmd_flow_director_filter_parsed,
11411 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11412 "director entry on NIC",
11414 (void *)&cmd_flow_director_filter,
11415 (void *)&cmd_flow_director_port_id,
11416 (void *)&cmd_flow_director_mode,
11417 (void *)&cmd_flow_director_mode_ip,
11418 (void *)&cmd_flow_director_ops,
11419 (void *)&cmd_flow_director_flow,
11420 (void *)&cmd_flow_director_flow_type,
11421 (void *)&cmd_flow_director_ether,
11422 (void *)&cmd_flow_director_ether_type,
11423 (void *)&cmd_flow_director_flexbytes,
11424 (void *)&cmd_flow_director_flexbytes_value,
11425 (void *)&cmd_flow_director_drop,
11426 (void *)&cmd_flow_director_pf_vf,
11427 (void *)&cmd_flow_director_queue,
11428 (void *)&cmd_flow_director_queue_id,
11429 (void *)&cmd_flow_director_fd_id,
11430 (void *)&cmd_flow_director_fd_id_value,
11435 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11436 .f = cmd_flow_director_filter_parsed,
11438 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11439 "director entry on NIC",
11441 (void *)&cmd_flow_director_filter,
11442 (void *)&cmd_flow_director_port_id,
11443 (void *)&cmd_flow_director_mode,
11444 (void *)&cmd_flow_director_mode_mac_vlan,
11445 (void *)&cmd_flow_director_ops,
11446 (void *)&cmd_flow_director_mac,
11447 (void *)&cmd_flow_director_mac_addr,
11448 (void *)&cmd_flow_director_vlan,
11449 (void *)&cmd_flow_director_vlan_value,
11450 (void *)&cmd_flow_director_flexbytes,
11451 (void *)&cmd_flow_director_flexbytes_value,
11452 (void *)&cmd_flow_director_drop,
11453 (void *)&cmd_flow_director_queue,
11454 (void *)&cmd_flow_director_queue_id,
11455 (void *)&cmd_flow_director_fd_id,
11456 (void *)&cmd_flow_director_fd_id_value,
11461 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11462 .f = cmd_flow_director_filter_parsed,
11464 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11465 "director entry on NIC",
11467 (void *)&cmd_flow_director_filter,
11468 (void *)&cmd_flow_director_port_id,
11469 (void *)&cmd_flow_director_mode,
11470 (void *)&cmd_flow_director_mode_tunnel,
11471 (void *)&cmd_flow_director_ops,
11472 (void *)&cmd_flow_director_mac,
11473 (void *)&cmd_flow_director_mac_addr,
11474 (void *)&cmd_flow_director_vlan,
11475 (void *)&cmd_flow_director_vlan_value,
11476 (void *)&cmd_flow_director_tunnel,
11477 (void *)&cmd_flow_director_tunnel_type,
11478 (void *)&cmd_flow_director_tunnel_id,
11479 (void *)&cmd_flow_director_tunnel_id_value,
11480 (void *)&cmd_flow_director_flexbytes,
11481 (void *)&cmd_flow_director_flexbytes_value,
11482 (void *)&cmd_flow_director_drop,
11483 (void *)&cmd_flow_director_queue,
11484 (void *)&cmd_flow_director_queue_id,
11485 (void *)&cmd_flow_director_fd_id,
11486 (void *)&cmd_flow_director_fd_id_value,
11491 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11492 .f = cmd_flow_director_filter_parsed,
11494 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11495 "director entry on NIC",
11497 (void *)&cmd_flow_director_filter,
11498 (void *)&cmd_flow_director_port_id,
11499 (void *)&cmd_flow_director_mode,
11500 (void *)&cmd_flow_director_mode_raw,
11501 (void *)&cmd_flow_director_ops,
11502 (void *)&cmd_flow_director_flow,
11503 (void *)&cmd_flow_director_flow_type,
11504 (void *)&cmd_flow_director_drop,
11505 (void *)&cmd_flow_director_queue,
11506 (void *)&cmd_flow_director_queue_id,
11507 (void *)&cmd_flow_director_fd_id,
11508 (void *)&cmd_flow_director_fd_id_value,
11509 (void *)&cmd_flow_director_packet,
11510 (void *)&cmd_flow_director_filepath,
11515 struct cmd_flush_flow_director_result {
11516 cmdline_fixed_string_t flush_flow_director;
11520 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11521 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11522 flush_flow_director, "flush_flow_director");
11523 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11524 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11528 cmd_flush_flow_director_parsed(void *parsed_result,
11529 __attribute__((unused)) struct cmdline *cl,
11530 __attribute__((unused)) void *data)
11532 struct cmd_flow_director_result *res = parsed_result;
11535 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11537 printf("flow director is not supported on port %u.\n",
11542 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11543 RTE_ETH_FILTER_FLUSH, NULL);
11545 printf("flow director table flushing error: (%s)\n",
11549 cmdline_parse_inst_t cmd_flush_flow_director = {
11550 .f = cmd_flush_flow_director_parsed,
11552 .help_str = "flush_flow_director <port_id>: "
11553 "Flush all flow director entries of a device on NIC",
11555 (void *)&cmd_flush_flow_director_flush,
11556 (void *)&cmd_flush_flow_director_port_id,
11561 /* *** deal with flow director mask *** */
11562 struct cmd_flow_director_mask_result {
11563 cmdline_fixed_string_t flow_director_mask;
11565 cmdline_fixed_string_t mode;
11566 cmdline_fixed_string_t mode_value;
11567 cmdline_fixed_string_t vlan;
11568 uint16_t vlan_mask;
11569 cmdline_fixed_string_t src_mask;
11570 cmdline_ipaddr_t ipv4_src;
11571 cmdline_ipaddr_t ipv6_src;
11573 cmdline_fixed_string_t dst_mask;
11574 cmdline_ipaddr_t ipv4_dst;
11575 cmdline_ipaddr_t ipv6_dst;
11577 cmdline_fixed_string_t mac;
11578 uint8_t mac_addr_byte_mask;
11579 cmdline_fixed_string_t tunnel_id;
11580 uint32_t tunnel_id_mask;
11581 cmdline_fixed_string_t tunnel_type;
11582 uint8_t tunnel_type_mask;
11586 cmd_flow_director_mask_parsed(void *parsed_result,
11587 __attribute__((unused)) struct cmdline *cl,
11588 __attribute__((unused)) void *data)
11590 struct cmd_flow_director_mask_result *res = parsed_result;
11591 struct rte_eth_fdir_masks *mask;
11592 struct rte_port *port;
11594 port = &ports[res->port_id];
11595 /** Check if the port is not started **/
11596 if (port->port_status != RTE_PORT_STOPPED) {
11597 printf("Please stop port %d first\n", res->port_id);
11601 mask = &port->dev_conf.fdir_conf.mask;
11603 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11604 if (strcmp(res->mode_value, "MAC-VLAN")) {
11605 printf("Please set mode to MAC-VLAN.\n");
11609 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11610 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11611 if (strcmp(res->mode_value, "Tunnel")) {
11612 printf("Please set mode to Tunnel.\n");
11616 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11617 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11618 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11619 mask->tunnel_type_mask = res->tunnel_type_mask;
11621 if (strcmp(res->mode_value, "IP")) {
11622 printf("Please set mode to IP.\n");
11626 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11627 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11628 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11629 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11630 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11631 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11632 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11635 cmd_reconfig_device_queue(res->port_id, 1, 1);
11638 cmdline_parse_token_string_t cmd_flow_director_mask =
11639 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11640 flow_director_mask, "flow_director_mask");
11641 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11642 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11644 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11645 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11647 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11648 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11649 vlan_mask, UINT16);
11650 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11651 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11652 src_mask, "src_mask");
11653 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11654 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11656 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11657 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11659 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11660 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11662 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11663 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11664 dst_mask, "dst_mask");
11665 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11666 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11668 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11669 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11671 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11672 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11675 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11676 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11678 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11679 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11681 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11682 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11683 mode_value, "MAC-VLAN");
11684 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11685 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11686 mode_value, "Tunnel");
11687 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11688 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11690 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11691 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11692 mac_addr_byte_mask, UINT8);
11693 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11694 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11695 tunnel_type, "tunnel-type");
11696 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11697 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11698 tunnel_type_mask, UINT8);
11699 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11700 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11701 tunnel_id, "tunnel-id");
11702 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11703 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11704 tunnel_id_mask, UINT32);
11706 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11707 .f = cmd_flow_director_mask_parsed,
11709 .help_str = "flow_director_mask ... : "
11710 "Set IP mode flow director's mask on NIC",
11712 (void *)&cmd_flow_director_mask,
11713 (void *)&cmd_flow_director_mask_port_id,
11714 (void *)&cmd_flow_director_mask_mode,
11715 (void *)&cmd_flow_director_mask_mode_ip,
11716 (void *)&cmd_flow_director_mask_vlan,
11717 (void *)&cmd_flow_director_mask_vlan_value,
11718 (void *)&cmd_flow_director_mask_src,
11719 (void *)&cmd_flow_director_mask_ipv4_src,
11720 (void *)&cmd_flow_director_mask_ipv6_src,
11721 (void *)&cmd_flow_director_mask_port_src,
11722 (void *)&cmd_flow_director_mask_dst,
11723 (void *)&cmd_flow_director_mask_ipv4_dst,
11724 (void *)&cmd_flow_director_mask_ipv6_dst,
11725 (void *)&cmd_flow_director_mask_port_dst,
11730 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11731 .f = cmd_flow_director_mask_parsed,
11733 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11734 "flow director's mask on NIC",
11736 (void *)&cmd_flow_director_mask,
11737 (void *)&cmd_flow_director_mask_port_id,
11738 (void *)&cmd_flow_director_mask_mode,
11739 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11740 (void *)&cmd_flow_director_mask_vlan,
11741 (void *)&cmd_flow_director_mask_vlan_value,
11746 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11747 .f = cmd_flow_director_mask_parsed,
11749 .help_str = "flow_director_mask ... : Set tunnel mode "
11750 "flow director's mask on NIC",
11752 (void *)&cmd_flow_director_mask,
11753 (void *)&cmd_flow_director_mask_port_id,
11754 (void *)&cmd_flow_director_mask_mode,
11755 (void *)&cmd_flow_director_mask_mode_tunnel,
11756 (void *)&cmd_flow_director_mask_vlan,
11757 (void *)&cmd_flow_director_mask_vlan_value,
11758 (void *)&cmd_flow_director_mask_mac,
11759 (void *)&cmd_flow_director_mask_mac_value,
11760 (void *)&cmd_flow_director_mask_tunnel_type,
11761 (void *)&cmd_flow_director_mask_tunnel_type_value,
11762 (void *)&cmd_flow_director_mask_tunnel_id,
11763 (void *)&cmd_flow_director_mask_tunnel_id_value,
11768 /* *** deal with flow director mask on flexible payload *** */
11769 struct cmd_flow_director_flex_mask_result {
11770 cmdline_fixed_string_t flow_director_flexmask;
11772 cmdline_fixed_string_t flow;
11773 cmdline_fixed_string_t flow_type;
11774 cmdline_fixed_string_t mask;
11778 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11779 __attribute__((unused)) struct cmdline *cl,
11780 __attribute__((unused)) void *data)
11782 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11783 struct rte_eth_fdir_info fdir_info;
11784 struct rte_eth_fdir_flex_mask flex_mask;
11785 struct rte_port *port;
11786 uint64_t flow_type_mask;
11790 port = &ports[res->port_id];
11791 /** Check if the port is not started **/
11792 if (port->port_status != RTE_PORT_STOPPED) {
11793 printf("Please stop port %d first\n", res->port_id);
11797 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11798 ret = parse_flexbytes(res->mask,
11800 RTE_ETH_FDIR_MAX_FLEXLEN);
11802 printf("error: Cannot parse mask input.\n");
11806 memset(&fdir_info, 0, sizeof(fdir_info));
11807 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11808 RTE_ETH_FILTER_INFO, &fdir_info);
11810 printf("Cannot get FDir filter info\n");
11814 if (!strcmp(res->flow_type, "none")) {
11815 /* means don't specify the flow type */
11816 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11817 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11818 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11819 0, sizeof(struct rte_eth_fdir_flex_mask));
11820 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11821 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11823 sizeof(struct rte_eth_fdir_flex_mask));
11824 cmd_reconfig_device_queue(res->port_id, 1, 1);
11827 flow_type_mask = fdir_info.flow_types_mask[0];
11828 if (!strcmp(res->flow_type, "all")) {
11829 if (!flow_type_mask) {
11830 printf("No flow type supported\n");
11833 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11834 if (flow_type_mask & (1ULL << i)) {
11835 flex_mask.flow_type = i;
11836 fdir_set_flex_mask(res->port_id, &flex_mask);
11839 cmd_reconfig_device_queue(res->port_id, 1, 1);
11842 flex_mask.flow_type = str2flowtype(res->flow_type);
11843 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11844 printf("Flow type %s not supported on port %d\n",
11845 res->flow_type, res->port_id);
11848 fdir_set_flex_mask(res->port_id, &flex_mask);
11849 cmd_reconfig_device_queue(res->port_id, 1, 1);
11852 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11853 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11854 flow_director_flexmask,
11855 "flow_director_flex_mask");
11856 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11857 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11859 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11860 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11862 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11863 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11864 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11865 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11866 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11867 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11870 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11871 .f = cmd_flow_director_flex_mask_parsed,
11873 .help_str = "flow_director_flex_mask ... : "
11874 "Set flow director's flex mask on NIC",
11876 (void *)&cmd_flow_director_flexmask,
11877 (void *)&cmd_flow_director_flexmask_port_id,
11878 (void *)&cmd_flow_director_flexmask_flow,
11879 (void *)&cmd_flow_director_flexmask_flow_type,
11880 (void *)&cmd_flow_director_flexmask_mask,
11885 /* *** deal with flow director flexible payload configuration *** */
11886 struct cmd_flow_director_flexpayload_result {
11887 cmdline_fixed_string_t flow_director_flexpayload;
11889 cmdline_fixed_string_t payload_layer;
11890 cmdline_fixed_string_t payload_cfg;
11894 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11897 const char *p, *p0 = q_arg;
11899 unsigned long int_fld;
11900 char *str_fld[max_num];
11905 p = strchr(p0, '(');
11909 p0 = strchr(p, ')');
11914 if (size >= sizeof(s))
11917 snprintf(s, sizeof(s), "%.*s", size, p);
11918 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11919 if (ret < 0 || ret > max_num)
11921 for (i = 0; i < ret; i++) {
11923 int_fld = strtoul(str_fld[i], &end, 0);
11924 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11926 offsets[i] = (uint16_t)int_fld;
11932 cmd_flow_director_flxpld_parsed(void *parsed_result,
11933 __attribute__((unused)) struct cmdline *cl,
11934 __attribute__((unused)) void *data)
11936 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11937 struct rte_eth_flex_payload_cfg flex_cfg;
11938 struct rte_port *port;
11941 port = &ports[res->port_id];
11942 /** Check if the port is not started **/
11943 if (port->port_status != RTE_PORT_STOPPED) {
11944 printf("Please stop port %d first\n", res->port_id);
11948 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11950 if (!strcmp(res->payload_layer, "raw"))
11951 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11952 else if (!strcmp(res->payload_layer, "l2"))
11953 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11954 else if (!strcmp(res->payload_layer, "l3"))
11955 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11956 else if (!strcmp(res->payload_layer, "l4"))
11957 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11959 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11960 RTE_ETH_FDIR_MAX_FLEXLEN);
11962 printf("error: Cannot parse flex payload input.\n");
11966 fdir_set_flex_payload(res->port_id, &flex_cfg);
11967 cmd_reconfig_device_queue(res->port_id, 1, 1);
11970 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11971 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11972 flow_director_flexpayload,
11973 "flow_director_flex_payload");
11974 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11975 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11977 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11978 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11979 payload_layer, "raw#l2#l3#l4");
11980 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11981 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11982 payload_cfg, NULL);
11984 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11985 .f = cmd_flow_director_flxpld_parsed,
11987 .help_str = "flow_director_flexpayload ... : "
11988 "Set flow director's flex payload on NIC",
11990 (void *)&cmd_flow_director_flexpayload,
11991 (void *)&cmd_flow_director_flexpayload_port_id,
11992 (void *)&cmd_flow_director_flexpayload_payload_layer,
11993 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11998 /* Generic flow interface command. */
11999 extern cmdline_parse_inst_t cmd_flow;
12001 /* *** Classification Filters Control *** */
12002 /* *** Get symmetric hash enable per port *** */
12003 struct cmd_get_sym_hash_ena_per_port_result {
12004 cmdline_fixed_string_t get_sym_hash_ena_per_port;
12009 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
12010 __rte_unused struct cmdline *cl,
12011 __rte_unused void *data)
12013 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
12014 struct rte_eth_hash_filter_info info;
12017 if (rte_eth_dev_filter_supported(res->port_id,
12018 RTE_ETH_FILTER_HASH) < 0) {
12019 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12024 memset(&info, 0, sizeof(info));
12025 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12026 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12027 RTE_ETH_FILTER_GET, &info);
12030 printf("Cannot get symmetric hash enable per port "
12031 "on port %u\n", res->port_id);
12035 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12036 "enabled" : "disabled", res->port_id);
12039 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12040 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12041 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12042 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12043 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12046 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12047 .f = cmd_get_sym_hash_per_port_parsed,
12049 .help_str = "get_sym_hash_ena_per_port <port_id>",
12051 (void *)&cmd_get_sym_hash_ena_per_port_all,
12052 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12057 /* *** Set symmetric hash enable per port *** */
12058 struct cmd_set_sym_hash_ena_per_port_result {
12059 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12060 cmdline_fixed_string_t enable;
12065 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12066 __rte_unused struct cmdline *cl,
12067 __rte_unused void *data)
12069 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12070 struct rte_eth_hash_filter_info info;
12073 if (rte_eth_dev_filter_supported(res->port_id,
12074 RTE_ETH_FILTER_HASH) < 0) {
12075 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12080 memset(&info, 0, sizeof(info));
12081 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12082 if (!strcmp(res->enable, "enable"))
12083 info.info.enable = 1;
12084 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12085 RTE_ETH_FILTER_SET, &info);
12087 printf("Cannot set symmetric hash enable per port on "
12088 "port %u\n", res->port_id);
12091 printf("Symmetric hash has been set to %s on port %u\n",
12092 res->enable, res->port_id);
12095 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12096 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12097 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12098 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12099 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12101 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12102 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12103 enable, "enable#disable");
12105 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12106 .f = cmd_set_sym_hash_per_port_parsed,
12108 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12110 (void *)&cmd_set_sym_hash_ena_per_port_all,
12111 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12112 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12117 /* Get global config of hash function */
12118 struct cmd_get_hash_global_config_result {
12119 cmdline_fixed_string_t get_hash_global_config;
12124 flowtype_to_str(uint16_t ftype)
12130 } ftype_table[] = {
12131 {"ipv4", RTE_ETH_FLOW_IPV4},
12132 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12133 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12134 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12135 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12136 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12137 {"ipv6", RTE_ETH_FLOW_IPV6},
12138 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12139 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12140 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12141 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12142 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12143 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12144 {"port", RTE_ETH_FLOW_PORT},
12145 {"vxlan", RTE_ETH_FLOW_VXLAN},
12146 {"geneve", RTE_ETH_FLOW_GENEVE},
12147 {"nvgre", RTE_ETH_FLOW_NVGRE},
12148 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12151 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12152 if (ftype_table[i].ftype == ftype)
12153 return ftype_table[i].str;
12160 cmd_get_hash_global_config_parsed(void *parsed_result,
12161 __rte_unused struct cmdline *cl,
12162 __rte_unused void *data)
12164 struct cmd_get_hash_global_config_result *res = parsed_result;
12165 struct rte_eth_hash_filter_info info;
12166 uint32_t idx, offset;
12171 if (rte_eth_dev_filter_supported(res->port_id,
12172 RTE_ETH_FILTER_HASH) < 0) {
12173 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12178 memset(&info, 0, sizeof(info));
12179 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12180 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12181 RTE_ETH_FILTER_GET, &info);
12183 printf("Cannot get hash global configurations by port %d\n",
12188 switch (info.info.global_conf.hash_func) {
12189 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12190 printf("Hash function is Toeplitz\n");
12192 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12193 printf("Hash function is Simple XOR\n");
12195 case RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ:
12196 printf("Hash function is Symmetric Toeplitz\n");
12199 printf("Unknown hash function\n");
12203 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12204 idx = i / UINT64_BIT;
12205 offset = i % UINT64_BIT;
12206 if (!(info.info.global_conf.valid_bit_mask[idx] &
12209 str = flowtype_to_str(i);
12212 printf("Symmetric hash is %s globally for flow type %s "
12214 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12215 (1ULL << offset)) ? "enabled" : "disabled"), str,
12220 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12221 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12222 get_hash_global_config, "get_hash_global_config");
12223 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12224 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12227 cmdline_parse_inst_t cmd_get_hash_global_config = {
12228 .f = cmd_get_hash_global_config_parsed,
12230 .help_str = "get_hash_global_config <port_id>",
12232 (void *)&cmd_get_hash_global_config_all,
12233 (void *)&cmd_get_hash_global_config_port_id,
12238 /* Set global config of hash function */
12239 struct cmd_set_hash_global_config_result {
12240 cmdline_fixed_string_t set_hash_global_config;
12242 cmdline_fixed_string_t hash_func;
12243 cmdline_fixed_string_t flow_type;
12244 cmdline_fixed_string_t enable;
12248 cmd_set_hash_global_config_parsed(void *parsed_result,
12249 __rte_unused struct cmdline *cl,
12250 __rte_unused void *data)
12252 struct cmd_set_hash_global_config_result *res = parsed_result;
12253 struct rte_eth_hash_filter_info info;
12254 uint32_t ftype, idx, offset;
12257 if (rte_eth_dev_filter_supported(res->port_id,
12258 RTE_ETH_FILTER_HASH) < 0) {
12259 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12263 memset(&info, 0, sizeof(info));
12264 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12265 if (!strcmp(res->hash_func, "toeplitz"))
12266 info.info.global_conf.hash_func =
12267 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12268 else if (!strcmp(res->hash_func, "simple_xor"))
12269 info.info.global_conf.hash_func =
12270 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12271 else if (!strcmp(res->hash_func, "symmetric_toeplitz"))
12272 info.info.global_conf.hash_func =
12273 RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
12274 else if (!strcmp(res->hash_func, "default"))
12275 info.info.global_conf.hash_func =
12276 RTE_ETH_HASH_FUNCTION_DEFAULT;
12278 ftype = str2flowtype(res->flow_type);
12279 idx = ftype / UINT64_BIT;
12280 offset = ftype % UINT64_BIT;
12281 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12282 if (!strcmp(res->enable, "enable"))
12283 info.info.global_conf.sym_hash_enable_mask[idx] |=
12285 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12286 RTE_ETH_FILTER_SET, &info);
12288 printf("Cannot set global hash configurations by port %d\n",
12291 printf("Global hash configurations have been set "
12292 "successfully by port %d\n", res->port_id);
12295 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12296 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12297 set_hash_global_config, "set_hash_global_config");
12298 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12299 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12301 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12302 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12303 hash_func, "toeplitz#simple_xor#symmetric_toeplitz#default");
12304 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12305 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12307 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12308 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12309 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12310 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12311 enable, "enable#disable");
12313 cmdline_parse_inst_t cmd_set_hash_global_config = {
12314 .f = cmd_set_hash_global_config_parsed,
12316 .help_str = "set_hash_global_config <port_id> "
12317 "toeplitz|simple_xor|symmetric_toeplitz|default "
12318 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12319 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12320 "l2_payload enable|disable",
12322 (void *)&cmd_set_hash_global_config_all,
12323 (void *)&cmd_set_hash_global_config_port_id,
12324 (void *)&cmd_set_hash_global_config_hash_func,
12325 (void *)&cmd_set_hash_global_config_flow_type,
12326 (void *)&cmd_set_hash_global_config_enable,
12331 /* Set hash input set */
12332 struct cmd_set_hash_input_set_result {
12333 cmdline_fixed_string_t set_hash_input_set;
12335 cmdline_fixed_string_t flow_type;
12336 cmdline_fixed_string_t inset_field;
12337 cmdline_fixed_string_t select;
12340 static enum rte_eth_input_set_field
12341 str2inset(char *string)
12345 static const struct {
12347 enum rte_eth_input_set_field inset;
12348 } inset_table[] = {
12349 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12350 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12351 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12352 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12353 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12354 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12355 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12356 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12357 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12358 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12359 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12360 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12361 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12362 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12363 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12364 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12365 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12366 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12367 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12368 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12369 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12370 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12371 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12372 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12373 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12374 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12375 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12376 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12377 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12378 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12379 {"none", RTE_ETH_INPUT_SET_NONE},
12382 for (i = 0; i < RTE_DIM(inset_table); i++) {
12383 if (!strcmp(string, inset_table[i].str))
12384 return inset_table[i].inset;
12387 return RTE_ETH_INPUT_SET_UNKNOWN;
12391 cmd_set_hash_input_set_parsed(void *parsed_result,
12392 __rte_unused struct cmdline *cl,
12393 __rte_unused void *data)
12395 struct cmd_set_hash_input_set_result *res = parsed_result;
12396 struct rte_eth_hash_filter_info info;
12398 memset(&info, 0, sizeof(info));
12399 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12400 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12401 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12402 info.info.input_set_conf.inset_size = 1;
12403 if (!strcmp(res->select, "select"))
12404 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12405 else if (!strcmp(res->select, "add"))
12406 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12407 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12408 RTE_ETH_FILTER_SET, &info);
12411 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12412 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12413 set_hash_input_set, "set_hash_input_set");
12414 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12415 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12417 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12418 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12420 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12421 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12423 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12424 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12425 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12426 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12427 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12429 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12430 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12431 select, "select#add");
12433 cmdline_parse_inst_t cmd_set_hash_input_set = {
12434 .f = cmd_set_hash_input_set_parsed,
12436 .help_str = "set_hash_input_set <port_id> "
12437 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12438 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12439 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12440 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12441 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12442 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12443 "fld-7th|fld-8th|none select|add",
12445 (void *)&cmd_set_hash_input_set_cmd,
12446 (void *)&cmd_set_hash_input_set_port_id,
12447 (void *)&cmd_set_hash_input_set_flow_type,
12448 (void *)&cmd_set_hash_input_set_field,
12449 (void *)&cmd_set_hash_input_set_select,
12454 /* Set flow director input set */
12455 struct cmd_set_fdir_input_set_result {
12456 cmdline_fixed_string_t set_fdir_input_set;
12458 cmdline_fixed_string_t flow_type;
12459 cmdline_fixed_string_t inset_field;
12460 cmdline_fixed_string_t select;
12464 cmd_set_fdir_input_set_parsed(void *parsed_result,
12465 __rte_unused struct cmdline *cl,
12466 __rte_unused void *data)
12468 struct cmd_set_fdir_input_set_result *res = parsed_result;
12469 struct rte_eth_fdir_filter_info info;
12471 memset(&info, 0, sizeof(info));
12472 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12473 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12474 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12475 info.info.input_set_conf.inset_size = 1;
12476 if (!strcmp(res->select, "select"))
12477 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12478 else if (!strcmp(res->select, "add"))
12479 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12480 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12481 RTE_ETH_FILTER_SET, &info);
12484 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12485 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12486 set_fdir_input_set, "set_fdir_input_set");
12487 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12488 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12490 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12491 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12493 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12494 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12495 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12496 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12498 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12499 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12500 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12501 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12502 "sctp-veri-tag#none");
12503 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12504 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12505 select, "select#add");
12507 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12508 .f = cmd_set_fdir_input_set_parsed,
12510 .help_str = "set_fdir_input_set <port_id> "
12511 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12512 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12513 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12514 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12515 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12516 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12517 "sctp-veri-tag|none select|add",
12519 (void *)&cmd_set_fdir_input_set_cmd,
12520 (void *)&cmd_set_fdir_input_set_port_id,
12521 (void *)&cmd_set_fdir_input_set_flow_type,
12522 (void *)&cmd_set_fdir_input_set_field,
12523 (void *)&cmd_set_fdir_input_set_select,
12528 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12529 struct cmd_mcast_addr_result {
12530 cmdline_fixed_string_t mcast_addr_cmd;
12531 cmdline_fixed_string_t what;
12533 struct rte_ether_addr mc_addr;
12536 static void cmd_mcast_addr_parsed(void *parsed_result,
12537 __attribute__((unused)) struct cmdline *cl,
12538 __attribute__((unused)) void *data)
12540 struct cmd_mcast_addr_result *res = parsed_result;
12542 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12543 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12544 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12545 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12546 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12549 if (strcmp(res->what, "add") == 0)
12550 mcast_addr_add(res->port_num, &res->mc_addr);
12552 mcast_addr_remove(res->port_num, &res->mc_addr);
12555 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12556 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12557 mcast_addr_cmd, "mcast_addr");
12558 cmdline_parse_token_string_t cmd_mcast_addr_what =
12559 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12561 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12562 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12563 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12564 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12566 cmdline_parse_inst_t cmd_mcast_addr = {
12567 .f = cmd_mcast_addr_parsed,
12569 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12570 "Add/Remove multicast MAC address on port_id",
12572 (void *)&cmd_mcast_addr_cmd,
12573 (void *)&cmd_mcast_addr_what,
12574 (void *)&cmd_mcast_addr_portnum,
12575 (void *)&cmd_mcast_addr_addr,
12580 /* l2 tunnel config
12581 * only support E-tag now.
12584 /* Ether type config */
12585 struct cmd_config_l2_tunnel_eth_type_result {
12586 cmdline_fixed_string_t port;
12587 cmdline_fixed_string_t config;
12588 cmdline_fixed_string_t all;
12590 cmdline_fixed_string_t l2_tunnel;
12591 cmdline_fixed_string_t l2_tunnel_type;
12592 cmdline_fixed_string_t eth_type;
12593 uint16_t eth_type_val;
12596 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12597 TOKEN_STRING_INITIALIZER
12598 (struct cmd_config_l2_tunnel_eth_type_result,
12600 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12601 TOKEN_STRING_INITIALIZER
12602 (struct cmd_config_l2_tunnel_eth_type_result,
12604 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12605 TOKEN_STRING_INITIALIZER
12606 (struct cmd_config_l2_tunnel_eth_type_result,
12608 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12609 TOKEN_NUM_INITIALIZER
12610 (struct cmd_config_l2_tunnel_eth_type_result,
12612 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12613 TOKEN_STRING_INITIALIZER
12614 (struct cmd_config_l2_tunnel_eth_type_result,
12615 l2_tunnel, "l2-tunnel");
12616 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12617 TOKEN_STRING_INITIALIZER
12618 (struct cmd_config_l2_tunnel_eth_type_result,
12619 l2_tunnel_type, "E-tag");
12620 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12621 TOKEN_STRING_INITIALIZER
12622 (struct cmd_config_l2_tunnel_eth_type_result,
12623 eth_type, "ether-type");
12624 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12625 TOKEN_NUM_INITIALIZER
12626 (struct cmd_config_l2_tunnel_eth_type_result,
12627 eth_type_val, UINT16);
12629 static enum rte_eth_tunnel_type
12630 str2fdir_l2_tunnel_type(char *string)
12634 static const struct {
12636 enum rte_eth_tunnel_type type;
12637 } l2_tunnel_type_str[] = {
12638 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12641 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12642 if (!strcmp(l2_tunnel_type_str[i].str, string))
12643 return l2_tunnel_type_str[i].type;
12645 return RTE_TUNNEL_TYPE_NONE;
12648 /* ether type config for all ports */
12650 cmd_config_l2_tunnel_eth_type_all_parsed
12651 (void *parsed_result,
12652 __attribute__((unused)) struct cmdline *cl,
12653 __attribute__((unused)) void *data)
12655 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12656 struct rte_eth_l2_tunnel_conf entry;
12659 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12660 entry.ether_type = res->eth_type_val;
12662 RTE_ETH_FOREACH_DEV(pid) {
12663 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12667 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12668 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12670 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12672 (void *)&cmd_config_l2_tunnel_eth_type_port,
12673 (void *)&cmd_config_l2_tunnel_eth_type_config,
12674 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12675 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12676 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12677 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12678 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12683 /* ether type config for a specific port */
12685 cmd_config_l2_tunnel_eth_type_specific_parsed(
12686 void *parsed_result,
12687 __attribute__((unused)) struct cmdline *cl,
12688 __attribute__((unused)) void *data)
12690 struct cmd_config_l2_tunnel_eth_type_result *res =
12692 struct rte_eth_l2_tunnel_conf entry;
12694 if (port_id_is_invalid(res->id, ENABLED_WARN))
12697 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12698 entry.ether_type = res->eth_type_val;
12700 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12703 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12704 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12706 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12708 (void *)&cmd_config_l2_tunnel_eth_type_port,
12709 (void *)&cmd_config_l2_tunnel_eth_type_config,
12710 (void *)&cmd_config_l2_tunnel_eth_type_id,
12711 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12712 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12713 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12714 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12719 /* Enable/disable l2 tunnel */
12720 struct cmd_config_l2_tunnel_en_dis_result {
12721 cmdline_fixed_string_t port;
12722 cmdline_fixed_string_t config;
12723 cmdline_fixed_string_t all;
12725 cmdline_fixed_string_t l2_tunnel;
12726 cmdline_fixed_string_t l2_tunnel_type;
12727 cmdline_fixed_string_t en_dis;
12730 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12731 TOKEN_STRING_INITIALIZER
12732 (struct cmd_config_l2_tunnel_en_dis_result,
12734 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12735 TOKEN_STRING_INITIALIZER
12736 (struct cmd_config_l2_tunnel_en_dis_result,
12738 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12739 TOKEN_STRING_INITIALIZER
12740 (struct cmd_config_l2_tunnel_en_dis_result,
12742 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12743 TOKEN_NUM_INITIALIZER
12744 (struct cmd_config_l2_tunnel_en_dis_result,
12746 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12747 TOKEN_STRING_INITIALIZER
12748 (struct cmd_config_l2_tunnel_en_dis_result,
12749 l2_tunnel, "l2-tunnel");
12750 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12751 TOKEN_STRING_INITIALIZER
12752 (struct cmd_config_l2_tunnel_en_dis_result,
12753 l2_tunnel_type, "E-tag");
12754 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12755 TOKEN_STRING_INITIALIZER
12756 (struct cmd_config_l2_tunnel_en_dis_result,
12757 en_dis, "enable#disable");
12759 /* enable/disable l2 tunnel for all ports */
12761 cmd_config_l2_tunnel_en_dis_all_parsed(
12762 void *parsed_result,
12763 __attribute__((unused)) struct cmdline *cl,
12764 __attribute__((unused)) void *data)
12766 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12767 struct rte_eth_l2_tunnel_conf entry;
12771 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12773 if (!strcmp("enable", res->en_dis))
12778 RTE_ETH_FOREACH_DEV(pid) {
12779 rte_eth_dev_l2_tunnel_offload_set(pid,
12781 ETH_L2_TUNNEL_ENABLE_MASK,
12786 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12787 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12789 .help_str = "port config all l2-tunnel E-tag enable|disable",
12791 (void *)&cmd_config_l2_tunnel_en_dis_port,
12792 (void *)&cmd_config_l2_tunnel_en_dis_config,
12793 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12794 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12795 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12796 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12801 /* enable/disable l2 tunnel for a port */
12803 cmd_config_l2_tunnel_en_dis_specific_parsed(
12804 void *parsed_result,
12805 __attribute__((unused)) struct cmdline *cl,
12806 __attribute__((unused)) void *data)
12808 struct cmd_config_l2_tunnel_en_dis_result *res =
12810 struct rte_eth_l2_tunnel_conf entry;
12812 if (port_id_is_invalid(res->id, ENABLED_WARN))
12815 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12817 if (!strcmp("enable", res->en_dis))
12818 rte_eth_dev_l2_tunnel_offload_set(res->id,
12820 ETH_L2_TUNNEL_ENABLE_MASK,
12823 rte_eth_dev_l2_tunnel_offload_set(res->id,
12825 ETH_L2_TUNNEL_ENABLE_MASK,
12829 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12830 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12832 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12834 (void *)&cmd_config_l2_tunnel_en_dis_port,
12835 (void *)&cmd_config_l2_tunnel_en_dis_config,
12836 (void *)&cmd_config_l2_tunnel_en_dis_id,
12837 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12838 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12839 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12844 /* E-tag configuration */
12846 /* Common result structure for all E-tag configuration */
12847 struct cmd_config_e_tag_result {
12848 cmdline_fixed_string_t e_tag;
12849 cmdline_fixed_string_t set;
12850 cmdline_fixed_string_t insertion;
12851 cmdline_fixed_string_t stripping;
12852 cmdline_fixed_string_t forwarding;
12853 cmdline_fixed_string_t filter;
12854 cmdline_fixed_string_t add;
12855 cmdline_fixed_string_t del;
12856 cmdline_fixed_string_t on;
12857 cmdline_fixed_string_t off;
12858 cmdline_fixed_string_t on_off;
12859 cmdline_fixed_string_t port_tag_id;
12860 uint32_t port_tag_id_val;
12861 cmdline_fixed_string_t e_tag_id;
12862 uint16_t e_tag_id_val;
12863 cmdline_fixed_string_t dst_pool;
12864 uint8_t dst_pool_val;
12865 cmdline_fixed_string_t port;
12867 cmdline_fixed_string_t vf;
12871 /* Common CLI fields for all E-tag configuration */
12872 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12873 TOKEN_STRING_INITIALIZER
12874 (struct cmd_config_e_tag_result,
12876 cmdline_parse_token_string_t cmd_config_e_tag_set =
12877 TOKEN_STRING_INITIALIZER
12878 (struct cmd_config_e_tag_result,
12880 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12881 TOKEN_STRING_INITIALIZER
12882 (struct cmd_config_e_tag_result,
12883 insertion, "insertion");
12884 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12885 TOKEN_STRING_INITIALIZER
12886 (struct cmd_config_e_tag_result,
12887 stripping, "stripping");
12888 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12889 TOKEN_STRING_INITIALIZER
12890 (struct cmd_config_e_tag_result,
12891 forwarding, "forwarding");
12892 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12893 TOKEN_STRING_INITIALIZER
12894 (struct cmd_config_e_tag_result,
12896 cmdline_parse_token_string_t cmd_config_e_tag_add =
12897 TOKEN_STRING_INITIALIZER
12898 (struct cmd_config_e_tag_result,
12900 cmdline_parse_token_string_t cmd_config_e_tag_del =
12901 TOKEN_STRING_INITIALIZER
12902 (struct cmd_config_e_tag_result,
12904 cmdline_parse_token_string_t cmd_config_e_tag_on =
12905 TOKEN_STRING_INITIALIZER
12906 (struct cmd_config_e_tag_result,
12908 cmdline_parse_token_string_t cmd_config_e_tag_off =
12909 TOKEN_STRING_INITIALIZER
12910 (struct cmd_config_e_tag_result,
12912 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12913 TOKEN_STRING_INITIALIZER
12914 (struct cmd_config_e_tag_result,
12916 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12917 TOKEN_STRING_INITIALIZER
12918 (struct cmd_config_e_tag_result,
12919 port_tag_id, "port-tag-id");
12920 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12921 TOKEN_NUM_INITIALIZER
12922 (struct cmd_config_e_tag_result,
12923 port_tag_id_val, UINT32);
12924 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12925 TOKEN_STRING_INITIALIZER
12926 (struct cmd_config_e_tag_result,
12927 e_tag_id, "e-tag-id");
12928 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12929 TOKEN_NUM_INITIALIZER
12930 (struct cmd_config_e_tag_result,
12931 e_tag_id_val, UINT16);
12932 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12933 TOKEN_STRING_INITIALIZER
12934 (struct cmd_config_e_tag_result,
12935 dst_pool, "dst-pool");
12936 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12937 TOKEN_NUM_INITIALIZER
12938 (struct cmd_config_e_tag_result,
12939 dst_pool_val, UINT8);
12940 cmdline_parse_token_string_t cmd_config_e_tag_port =
12941 TOKEN_STRING_INITIALIZER
12942 (struct cmd_config_e_tag_result,
12944 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12945 TOKEN_NUM_INITIALIZER
12946 (struct cmd_config_e_tag_result,
12948 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12949 TOKEN_STRING_INITIALIZER
12950 (struct cmd_config_e_tag_result,
12952 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12953 TOKEN_NUM_INITIALIZER
12954 (struct cmd_config_e_tag_result,
12957 /* E-tag insertion configuration */
12959 cmd_config_e_tag_insertion_en_parsed(
12960 void *parsed_result,
12961 __attribute__((unused)) struct cmdline *cl,
12962 __attribute__((unused)) void *data)
12964 struct cmd_config_e_tag_result *res =
12966 struct rte_eth_l2_tunnel_conf entry;
12968 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12971 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12972 entry.tunnel_id = res->port_tag_id_val;
12973 entry.vf_id = res->vf_id;
12974 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12976 ETH_L2_TUNNEL_INSERTION_MASK,
12981 cmd_config_e_tag_insertion_dis_parsed(
12982 void *parsed_result,
12983 __attribute__((unused)) struct cmdline *cl,
12984 __attribute__((unused)) void *data)
12986 struct cmd_config_e_tag_result *res =
12988 struct rte_eth_l2_tunnel_conf entry;
12990 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12993 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12994 entry.vf_id = res->vf_id;
12996 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12998 ETH_L2_TUNNEL_INSERTION_MASK,
13002 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
13003 .f = cmd_config_e_tag_insertion_en_parsed,
13005 .help_str = "E-tag ... : E-tag insertion enable",
13007 (void *)&cmd_config_e_tag_e_tag,
13008 (void *)&cmd_config_e_tag_set,
13009 (void *)&cmd_config_e_tag_insertion,
13010 (void *)&cmd_config_e_tag_on,
13011 (void *)&cmd_config_e_tag_port_tag_id,
13012 (void *)&cmd_config_e_tag_port_tag_id_val,
13013 (void *)&cmd_config_e_tag_port,
13014 (void *)&cmd_config_e_tag_port_id,
13015 (void *)&cmd_config_e_tag_vf,
13016 (void *)&cmd_config_e_tag_vf_id,
13021 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
13022 .f = cmd_config_e_tag_insertion_dis_parsed,
13024 .help_str = "E-tag ... : E-tag insertion disable",
13026 (void *)&cmd_config_e_tag_e_tag,
13027 (void *)&cmd_config_e_tag_set,
13028 (void *)&cmd_config_e_tag_insertion,
13029 (void *)&cmd_config_e_tag_off,
13030 (void *)&cmd_config_e_tag_port,
13031 (void *)&cmd_config_e_tag_port_id,
13032 (void *)&cmd_config_e_tag_vf,
13033 (void *)&cmd_config_e_tag_vf_id,
13038 /* E-tag stripping configuration */
13040 cmd_config_e_tag_stripping_parsed(
13041 void *parsed_result,
13042 __attribute__((unused)) struct cmdline *cl,
13043 __attribute__((unused)) void *data)
13045 struct cmd_config_e_tag_result *res =
13047 struct rte_eth_l2_tunnel_conf entry;
13049 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13052 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13054 if (!strcmp(res->on_off, "on"))
13055 rte_eth_dev_l2_tunnel_offload_set
13058 ETH_L2_TUNNEL_STRIPPING_MASK,
13061 rte_eth_dev_l2_tunnel_offload_set
13064 ETH_L2_TUNNEL_STRIPPING_MASK,
13068 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13069 .f = cmd_config_e_tag_stripping_parsed,
13071 .help_str = "E-tag ... : E-tag stripping enable/disable",
13073 (void *)&cmd_config_e_tag_e_tag,
13074 (void *)&cmd_config_e_tag_set,
13075 (void *)&cmd_config_e_tag_stripping,
13076 (void *)&cmd_config_e_tag_on_off,
13077 (void *)&cmd_config_e_tag_port,
13078 (void *)&cmd_config_e_tag_port_id,
13083 /* E-tag forwarding configuration */
13085 cmd_config_e_tag_forwarding_parsed(
13086 void *parsed_result,
13087 __attribute__((unused)) struct cmdline *cl,
13088 __attribute__((unused)) void *data)
13090 struct cmd_config_e_tag_result *res = parsed_result;
13091 struct rte_eth_l2_tunnel_conf entry;
13093 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13096 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13098 if (!strcmp(res->on_off, "on"))
13099 rte_eth_dev_l2_tunnel_offload_set
13102 ETH_L2_TUNNEL_FORWARDING_MASK,
13105 rte_eth_dev_l2_tunnel_offload_set
13108 ETH_L2_TUNNEL_FORWARDING_MASK,
13112 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13113 .f = cmd_config_e_tag_forwarding_parsed,
13115 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13117 (void *)&cmd_config_e_tag_e_tag,
13118 (void *)&cmd_config_e_tag_set,
13119 (void *)&cmd_config_e_tag_forwarding,
13120 (void *)&cmd_config_e_tag_on_off,
13121 (void *)&cmd_config_e_tag_port,
13122 (void *)&cmd_config_e_tag_port_id,
13127 /* E-tag filter configuration */
13129 cmd_config_e_tag_filter_add_parsed(
13130 void *parsed_result,
13131 __attribute__((unused)) struct cmdline *cl,
13132 __attribute__((unused)) void *data)
13134 struct cmd_config_e_tag_result *res = parsed_result;
13135 struct rte_eth_l2_tunnel_conf entry;
13138 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13141 if (res->e_tag_id_val > 0x3fff) {
13142 printf("e-tag-id must be equal or less than 0x3fff.\n");
13146 ret = rte_eth_dev_filter_supported(res->port_id,
13147 RTE_ETH_FILTER_L2_TUNNEL);
13149 printf("E-tag filter is not supported on port %u.\n",
13154 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13155 entry.tunnel_id = res->e_tag_id_val;
13156 entry.pool = res->dst_pool_val;
13158 ret = rte_eth_dev_filter_ctrl(res->port_id,
13159 RTE_ETH_FILTER_L2_TUNNEL,
13160 RTE_ETH_FILTER_ADD,
13163 printf("E-tag filter programming error: (%s)\n",
13167 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13168 .f = cmd_config_e_tag_filter_add_parsed,
13170 .help_str = "E-tag ... : E-tag filter add",
13172 (void *)&cmd_config_e_tag_e_tag,
13173 (void *)&cmd_config_e_tag_set,
13174 (void *)&cmd_config_e_tag_filter,
13175 (void *)&cmd_config_e_tag_add,
13176 (void *)&cmd_config_e_tag_e_tag_id,
13177 (void *)&cmd_config_e_tag_e_tag_id_val,
13178 (void *)&cmd_config_e_tag_dst_pool,
13179 (void *)&cmd_config_e_tag_dst_pool_val,
13180 (void *)&cmd_config_e_tag_port,
13181 (void *)&cmd_config_e_tag_port_id,
13187 cmd_config_e_tag_filter_del_parsed(
13188 void *parsed_result,
13189 __attribute__((unused)) struct cmdline *cl,
13190 __attribute__((unused)) void *data)
13192 struct cmd_config_e_tag_result *res = parsed_result;
13193 struct rte_eth_l2_tunnel_conf entry;
13196 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13199 if (res->e_tag_id_val > 0x3fff) {
13200 printf("e-tag-id must be less than 0x3fff.\n");
13204 ret = rte_eth_dev_filter_supported(res->port_id,
13205 RTE_ETH_FILTER_L2_TUNNEL);
13207 printf("E-tag filter is not supported on port %u.\n",
13212 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13213 entry.tunnel_id = res->e_tag_id_val;
13215 ret = rte_eth_dev_filter_ctrl(res->port_id,
13216 RTE_ETH_FILTER_L2_TUNNEL,
13217 RTE_ETH_FILTER_DELETE,
13220 printf("E-tag filter programming error: (%s)\n",
13224 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13225 .f = cmd_config_e_tag_filter_del_parsed,
13227 .help_str = "E-tag ... : E-tag filter delete",
13229 (void *)&cmd_config_e_tag_e_tag,
13230 (void *)&cmd_config_e_tag_set,
13231 (void *)&cmd_config_e_tag_filter,
13232 (void *)&cmd_config_e_tag_del,
13233 (void *)&cmd_config_e_tag_e_tag_id,
13234 (void *)&cmd_config_e_tag_e_tag_id_val,
13235 (void *)&cmd_config_e_tag_port,
13236 (void *)&cmd_config_e_tag_port_id,
13241 /* vf vlan anti spoof configuration */
13243 /* Common result structure for vf vlan anti spoof */
13244 struct cmd_vf_vlan_anti_spoof_result {
13245 cmdline_fixed_string_t set;
13246 cmdline_fixed_string_t vf;
13247 cmdline_fixed_string_t vlan;
13248 cmdline_fixed_string_t antispoof;
13251 cmdline_fixed_string_t on_off;
13254 /* Common CLI fields for vf vlan anti spoof enable disable */
13255 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13256 TOKEN_STRING_INITIALIZER
13257 (struct cmd_vf_vlan_anti_spoof_result,
13259 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13260 TOKEN_STRING_INITIALIZER
13261 (struct cmd_vf_vlan_anti_spoof_result,
13263 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13264 TOKEN_STRING_INITIALIZER
13265 (struct cmd_vf_vlan_anti_spoof_result,
13267 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13268 TOKEN_STRING_INITIALIZER
13269 (struct cmd_vf_vlan_anti_spoof_result,
13270 antispoof, "antispoof");
13271 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13272 TOKEN_NUM_INITIALIZER
13273 (struct cmd_vf_vlan_anti_spoof_result,
13275 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13276 TOKEN_NUM_INITIALIZER
13277 (struct cmd_vf_vlan_anti_spoof_result,
13279 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13280 TOKEN_STRING_INITIALIZER
13281 (struct cmd_vf_vlan_anti_spoof_result,
13285 cmd_set_vf_vlan_anti_spoof_parsed(
13286 void *parsed_result,
13287 __attribute__((unused)) struct cmdline *cl,
13288 __attribute__((unused)) void *data)
13290 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13291 int ret = -ENOTSUP;
13293 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13295 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13298 #ifdef RTE_LIBRTE_IXGBE_PMD
13299 if (ret == -ENOTSUP)
13300 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13301 res->vf_id, is_on);
13303 #ifdef RTE_LIBRTE_I40E_PMD
13304 if (ret == -ENOTSUP)
13305 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13306 res->vf_id, is_on);
13308 #ifdef RTE_LIBRTE_BNXT_PMD
13309 if (ret == -ENOTSUP)
13310 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13311 res->vf_id, is_on);
13318 printf("invalid vf_id %d\n", res->vf_id);
13321 printf("invalid port_id %d\n", res->port_id);
13324 printf("function not implemented\n");
13327 printf("programming error: (%s)\n", strerror(-ret));
13331 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13332 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13334 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13336 (void *)&cmd_vf_vlan_anti_spoof_set,
13337 (void *)&cmd_vf_vlan_anti_spoof_vf,
13338 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13339 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13340 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13341 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13342 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13347 /* vf mac anti spoof configuration */
13349 /* Common result structure for vf mac anti spoof */
13350 struct cmd_vf_mac_anti_spoof_result {
13351 cmdline_fixed_string_t set;
13352 cmdline_fixed_string_t vf;
13353 cmdline_fixed_string_t mac;
13354 cmdline_fixed_string_t antispoof;
13357 cmdline_fixed_string_t on_off;
13360 /* Common CLI fields for vf mac anti spoof enable disable */
13361 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13362 TOKEN_STRING_INITIALIZER
13363 (struct cmd_vf_mac_anti_spoof_result,
13365 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13366 TOKEN_STRING_INITIALIZER
13367 (struct cmd_vf_mac_anti_spoof_result,
13369 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13370 TOKEN_STRING_INITIALIZER
13371 (struct cmd_vf_mac_anti_spoof_result,
13373 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13374 TOKEN_STRING_INITIALIZER
13375 (struct cmd_vf_mac_anti_spoof_result,
13376 antispoof, "antispoof");
13377 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13378 TOKEN_NUM_INITIALIZER
13379 (struct cmd_vf_mac_anti_spoof_result,
13381 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13382 TOKEN_NUM_INITIALIZER
13383 (struct cmd_vf_mac_anti_spoof_result,
13385 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13386 TOKEN_STRING_INITIALIZER
13387 (struct cmd_vf_mac_anti_spoof_result,
13391 cmd_set_vf_mac_anti_spoof_parsed(
13392 void *parsed_result,
13393 __attribute__((unused)) struct cmdline *cl,
13394 __attribute__((unused)) void *data)
13396 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13397 int ret = -ENOTSUP;
13399 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13401 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13404 #ifdef RTE_LIBRTE_IXGBE_PMD
13405 if (ret == -ENOTSUP)
13406 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13407 res->vf_id, is_on);
13409 #ifdef RTE_LIBRTE_I40E_PMD
13410 if (ret == -ENOTSUP)
13411 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13412 res->vf_id, is_on);
13414 #ifdef RTE_LIBRTE_BNXT_PMD
13415 if (ret == -ENOTSUP)
13416 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13417 res->vf_id, is_on);
13424 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13427 printf("invalid port_id %d\n", res->port_id);
13430 printf("function not implemented\n");
13433 printf("programming error: (%s)\n", strerror(-ret));
13437 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13438 .f = cmd_set_vf_mac_anti_spoof_parsed,
13440 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13442 (void *)&cmd_vf_mac_anti_spoof_set,
13443 (void *)&cmd_vf_mac_anti_spoof_vf,
13444 (void *)&cmd_vf_mac_anti_spoof_mac,
13445 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13446 (void *)&cmd_vf_mac_anti_spoof_port_id,
13447 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13448 (void *)&cmd_vf_mac_anti_spoof_on_off,
13453 /* vf vlan strip queue configuration */
13455 /* Common result structure for vf mac anti spoof */
13456 struct cmd_vf_vlan_stripq_result {
13457 cmdline_fixed_string_t set;
13458 cmdline_fixed_string_t vf;
13459 cmdline_fixed_string_t vlan;
13460 cmdline_fixed_string_t stripq;
13463 cmdline_fixed_string_t on_off;
13466 /* Common CLI fields for vf vlan strip enable disable */
13467 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13468 TOKEN_STRING_INITIALIZER
13469 (struct cmd_vf_vlan_stripq_result,
13471 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13472 TOKEN_STRING_INITIALIZER
13473 (struct cmd_vf_vlan_stripq_result,
13475 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13476 TOKEN_STRING_INITIALIZER
13477 (struct cmd_vf_vlan_stripq_result,
13479 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13480 TOKEN_STRING_INITIALIZER
13481 (struct cmd_vf_vlan_stripq_result,
13483 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13484 TOKEN_NUM_INITIALIZER
13485 (struct cmd_vf_vlan_stripq_result,
13487 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13488 TOKEN_NUM_INITIALIZER
13489 (struct cmd_vf_vlan_stripq_result,
13491 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13492 TOKEN_STRING_INITIALIZER
13493 (struct cmd_vf_vlan_stripq_result,
13497 cmd_set_vf_vlan_stripq_parsed(
13498 void *parsed_result,
13499 __attribute__((unused)) struct cmdline *cl,
13500 __attribute__((unused)) void *data)
13502 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13503 int ret = -ENOTSUP;
13505 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13507 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13510 #ifdef RTE_LIBRTE_IXGBE_PMD
13511 if (ret == -ENOTSUP)
13512 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13513 res->vf_id, is_on);
13515 #ifdef RTE_LIBRTE_I40E_PMD
13516 if (ret == -ENOTSUP)
13517 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13518 res->vf_id, is_on);
13520 #ifdef RTE_LIBRTE_BNXT_PMD
13521 if (ret == -ENOTSUP)
13522 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13523 res->vf_id, is_on);
13530 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13533 printf("invalid port_id %d\n", res->port_id);
13536 printf("function not implemented\n");
13539 printf("programming error: (%s)\n", strerror(-ret));
13543 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13544 .f = cmd_set_vf_vlan_stripq_parsed,
13546 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13548 (void *)&cmd_vf_vlan_stripq_set,
13549 (void *)&cmd_vf_vlan_stripq_vf,
13550 (void *)&cmd_vf_vlan_stripq_vlan,
13551 (void *)&cmd_vf_vlan_stripq_stripq,
13552 (void *)&cmd_vf_vlan_stripq_port_id,
13553 (void *)&cmd_vf_vlan_stripq_vf_id,
13554 (void *)&cmd_vf_vlan_stripq_on_off,
13559 /* vf vlan insert configuration */
13561 /* Common result structure for vf vlan insert */
13562 struct cmd_vf_vlan_insert_result {
13563 cmdline_fixed_string_t set;
13564 cmdline_fixed_string_t vf;
13565 cmdline_fixed_string_t vlan;
13566 cmdline_fixed_string_t insert;
13572 /* Common CLI fields for vf vlan insert enable disable */
13573 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13574 TOKEN_STRING_INITIALIZER
13575 (struct cmd_vf_vlan_insert_result,
13577 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13578 TOKEN_STRING_INITIALIZER
13579 (struct cmd_vf_vlan_insert_result,
13581 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13582 TOKEN_STRING_INITIALIZER
13583 (struct cmd_vf_vlan_insert_result,
13585 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13586 TOKEN_STRING_INITIALIZER
13587 (struct cmd_vf_vlan_insert_result,
13589 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13590 TOKEN_NUM_INITIALIZER
13591 (struct cmd_vf_vlan_insert_result,
13593 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13594 TOKEN_NUM_INITIALIZER
13595 (struct cmd_vf_vlan_insert_result,
13597 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13598 TOKEN_NUM_INITIALIZER
13599 (struct cmd_vf_vlan_insert_result,
13603 cmd_set_vf_vlan_insert_parsed(
13604 void *parsed_result,
13605 __attribute__((unused)) struct cmdline *cl,
13606 __attribute__((unused)) void *data)
13608 struct cmd_vf_vlan_insert_result *res = parsed_result;
13609 int ret = -ENOTSUP;
13611 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13614 #ifdef RTE_LIBRTE_IXGBE_PMD
13615 if (ret == -ENOTSUP)
13616 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13619 #ifdef RTE_LIBRTE_I40E_PMD
13620 if (ret == -ENOTSUP)
13621 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13624 #ifdef RTE_LIBRTE_BNXT_PMD
13625 if (ret == -ENOTSUP)
13626 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13634 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13637 printf("invalid port_id %d\n", res->port_id);
13640 printf("function not implemented\n");
13643 printf("programming error: (%s)\n", strerror(-ret));
13647 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13648 .f = cmd_set_vf_vlan_insert_parsed,
13650 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13652 (void *)&cmd_vf_vlan_insert_set,
13653 (void *)&cmd_vf_vlan_insert_vf,
13654 (void *)&cmd_vf_vlan_insert_vlan,
13655 (void *)&cmd_vf_vlan_insert_insert,
13656 (void *)&cmd_vf_vlan_insert_port_id,
13657 (void *)&cmd_vf_vlan_insert_vf_id,
13658 (void *)&cmd_vf_vlan_insert_vlan_id,
13663 /* tx loopback configuration */
13665 /* Common result structure for tx loopback */
13666 struct cmd_tx_loopback_result {
13667 cmdline_fixed_string_t set;
13668 cmdline_fixed_string_t tx;
13669 cmdline_fixed_string_t loopback;
13671 cmdline_fixed_string_t on_off;
13674 /* Common CLI fields for tx loopback enable disable */
13675 cmdline_parse_token_string_t cmd_tx_loopback_set =
13676 TOKEN_STRING_INITIALIZER
13677 (struct cmd_tx_loopback_result,
13679 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13680 TOKEN_STRING_INITIALIZER
13681 (struct cmd_tx_loopback_result,
13683 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13684 TOKEN_STRING_INITIALIZER
13685 (struct cmd_tx_loopback_result,
13686 loopback, "loopback");
13687 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13688 TOKEN_NUM_INITIALIZER
13689 (struct cmd_tx_loopback_result,
13691 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13692 TOKEN_STRING_INITIALIZER
13693 (struct cmd_tx_loopback_result,
13697 cmd_set_tx_loopback_parsed(
13698 void *parsed_result,
13699 __attribute__((unused)) struct cmdline *cl,
13700 __attribute__((unused)) void *data)
13702 struct cmd_tx_loopback_result *res = parsed_result;
13703 int ret = -ENOTSUP;
13705 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13707 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13710 #ifdef RTE_LIBRTE_IXGBE_PMD
13711 if (ret == -ENOTSUP)
13712 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13714 #ifdef RTE_LIBRTE_I40E_PMD
13715 if (ret == -ENOTSUP)
13716 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13718 #ifdef RTE_LIBRTE_BNXT_PMD
13719 if (ret == -ENOTSUP)
13720 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13722 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13723 if (ret == -ENOTSUP)
13724 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13731 printf("invalid is_on %d\n", is_on);
13734 printf("invalid port_id %d\n", res->port_id);
13737 printf("function not implemented\n");
13740 printf("programming error: (%s)\n", strerror(-ret));
13744 cmdline_parse_inst_t cmd_set_tx_loopback = {
13745 .f = cmd_set_tx_loopback_parsed,
13747 .help_str = "set tx loopback <port_id> on|off",
13749 (void *)&cmd_tx_loopback_set,
13750 (void *)&cmd_tx_loopback_tx,
13751 (void *)&cmd_tx_loopback_loopback,
13752 (void *)&cmd_tx_loopback_port_id,
13753 (void *)&cmd_tx_loopback_on_off,
13758 /* all queues drop enable configuration */
13760 /* Common result structure for all queues drop enable */
13761 struct cmd_all_queues_drop_en_result {
13762 cmdline_fixed_string_t set;
13763 cmdline_fixed_string_t all;
13764 cmdline_fixed_string_t queues;
13765 cmdline_fixed_string_t drop;
13767 cmdline_fixed_string_t on_off;
13770 /* Common CLI fields for tx loopback enable disable */
13771 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13772 TOKEN_STRING_INITIALIZER
13773 (struct cmd_all_queues_drop_en_result,
13775 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13776 TOKEN_STRING_INITIALIZER
13777 (struct cmd_all_queues_drop_en_result,
13779 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13780 TOKEN_STRING_INITIALIZER
13781 (struct cmd_all_queues_drop_en_result,
13783 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13784 TOKEN_STRING_INITIALIZER
13785 (struct cmd_all_queues_drop_en_result,
13787 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13788 TOKEN_NUM_INITIALIZER
13789 (struct cmd_all_queues_drop_en_result,
13791 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13792 TOKEN_STRING_INITIALIZER
13793 (struct cmd_all_queues_drop_en_result,
13797 cmd_set_all_queues_drop_en_parsed(
13798 void *parsed_result,
13799 __attribute__((unused)) struct cmdline *cl,
13800 __attribute__((unused)) void *data)
13802 struct cmd_all_queues_drop_en_result *res = parsed_result;
13803 int ret = -ENOTSUP;
13804 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13806 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13809 #ifdef RTE_LIBRTE_IXGBE_PMD
13810 if (ret == -ENOTSUP)
13811 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13813 #ifdef RTE_LIBRTE_BNXT_PMD
13814 if (ret == -ENOTSUP)
13815 ret = rte_pmd_bnxt_set_all_queues_drop_en(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_all_queues_drop_en = {
13835 .f = cmd_set_all_queues_drop_en_parsed,
13837 .help_str = "set all queues drop <port_id> on|off",
13839 (void *)&cmd_all_queues_drop_en_set,
13840 (void *)&cmd_all_queues_drop_en_all,
13841 (void *)&cmd_all_queues_drop_en_queues,
13842 (void *)&cmd_all_queues_drop_en_drop,
13843 (void *)&cmd_all_queues_drop_en_port_id,
13844 (void *)&cmd_all_queues_drop_en_on_off,
13849 /* vf split drop enable configuration */
13851 /* Common result structure for vf split drop enable */
13852 struct cmd_vf_split_drop_en_result {
13853 cmdline_fixed_string_t set;
13854 cmdline_fixed_string_t vf;
13855 cmdline_fixed_string_t split;
13856 cmdline_fixed_string_t drop;
13859 cmdline_fixed_string_t on_off;
13862 /* Common CLI fields for vf split drop enable disable */
13863 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13864 TOKEN_STRING_INITIALIZER
13865 (struct cmd_vf_split_drop_en_result,
13867 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13868 TOKEN_STRING_INITIALIZER
13869 (struct cmd_vf_split_drop_en_result,
13871 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13872 TOKEN_STRING_INITIALIZER
13873 (struct cmd_vf_split_drop_en_result,
13875 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13876 TOKEN_STRING_INITIALIZER
13877 (struct cmd_vf_split_drop_en_result,
13879 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13880 TOKEN_NUM_INITIALIZER
13881 (struct cmd_vf_split_drop_en_result,
13883 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13884 TOKEN_NUM_INITIALIZER
13885 (struct cmd_vf_split_drop_en_result,
13887 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13888 TOKEN_STRING_INITIALIZER
13889 (struct cmd_vf_split_drop_en_result,
13893 cmd_set_vf_split_drop_en_parsed(
13894 void *parsed_result,
13895 __attribute__((unused)) struct cmdline *cl,
13896 __attribute__((unused)) void *data)
13898 struct cmd_vf_split_drop_en_result *res = parsed_result;
13899 int ret = -ENOTSUP;
13900 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13902 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13905 #ifdef RTE_LIBRTE_IXGBE_PMD
13906 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13913 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13916 printf("invalid port_id %d\n", res->port_id);
13919 printf("not supported on port %d\n", res->port_id);
13922 printf("programming error: (%s)\n", strerror(-ret));
13926 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13927 .f = cmd_set_vf_split_drop_en_parsed,
13929 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13931 (void *)&cmd_vf_split_drop_en_set,
13932 (void *)&cmd_vf_split_drop_en_vf,
13933 (void *)&cmd_vf_split_drop_en_split,
13934 (void *)&cmd_vf_split_drop_en_drop,
13935 (void *)&cmd_vf_split_drop_en_port_id,
13936 (void *)&cmd_vf_split_drop_en_vf_id,
13937 (void *)&cmd_vf_split_drop_en_on_off,
13942 /* vf mac address configuration */
13944 /* Common result structure for vf mac address */
13945 struct cmd_set_vf_mac_addr_result {
13946 cmdline_fixed_string_t set;
13947 cmdline_fixed_string_t vf;
13948 cmdline_fixed_string_t mac;
13949 cmdline_fixed_string_t addr;
13952 struct rte_ether_addr mac_addr;
13956 /* Common CLI fields for vf split drop enable disable */
13957 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13958 TOKEN_STRING_INITIALIZER
13959 (struct cmd_set_vf_mac_addr_result,
13961 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13962 TOKEN_STRING_INITIALIZER
13963 (struct cmd_set_vf_mac_addr_result,
13965 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13966 TOKEN_STRING_INITIALIZER
13967 (struct cmd_set_vf_mac_addr_result,
13969 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13970 TOKEN_STRING_INITIALIZER
13971 (struct cmd_set_vf_mac_addr_result,
13973 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13974 TOKEN_NUM_INITIALIZER
13975 (struct cmd_set_vf_mac_addr_result,
13977 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13978 TOKEN_NUM_INITIALIZER
13979 (struct cmd_set_vf_mac_addr_result,
13981 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13982 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13986 cmd_set_vf_mac_addr_parsed(
13987 void *parsed_result,
13988 __attribute__((unused)) struct cmdline *cl,
13989 __attribute__((unused)) void *data)
13991 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13992 int ret = -ENOTSUP;
13994 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13997 #ifdef RTE_LIBRTE_IXGBE_PMD
13998 if (ret == -ENOTSUP)
13999 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
14002 #ifdef RTE_LIBRTE_I40E_PMD
14003 if (ret == -ENOTSUP)
14004 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
14007 #ifdef RTE_LIBRTE_BNXT_PMD
14008 if (ret == -ENOTSUP)
14009 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
14017 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
14020 printf("invalid port_id %d\n", res->port_id);
14023 printf("function not implemented\n");
14026 printf("programming error: (%s)\n", strerror(-ret));
14030 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
14031 .f = cmd_set_vf_mac_addr_parsed,
14033 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
14035 (void *)&cmd_set_vf_mac_addr_set,
14036 (void *)&cmd_set_vf_mac_addr_vf,
14037 (void *)&cmd_set_vf_mac_addr_mac,
14038 (void *)&cmd_set_vf_mac_addr_addr,
14039 (void *)&cmd_set_vf_mac_addr_port_id,
14040 (void *)&cmd_set_vf_mac_addr_vf_id,
14041 (void *)&cmd_set_vf_mac_addr_mac_addr,
14046 /* MACsec configuration */
14048 /* Common result structure for MACsec offload enable */
14049 struct cmd_macsec_offload_on_result {
14050 cmdline_fixed_string_t set;
14051 cmdline_fixed_string_t macsec;
14052 cmdline_fixed_string_t offload;
14054 cmdline_fixed_string_t on;
14055 cmdline_fixed_string_t encrypt;
14056 cmdline_fixed_string_t en_on_off;
14057 cmdline_fixed_string_t replay_protect;
14058 cmdline_fixed_string_t rp_on_off;
14061 /* Common CLI fields for MACsec offload disable */
14062 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14063 TOKEN_STRING_INITIALIZER
14064 (struct cmd_macsec_offload_on_result,
14066 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14067 TOKEN_STRING_INITIALIZER
14068 (struct cmd_macsec_offload_on_result,
14070 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14071 TOKEN_STRING_INITIALIZER
14072 (struct cmd_macsec_offload_on_result,
14073 offload, "offload");
14074 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14075 TOKEN_NUM_INITIALIZER
14076 (struct cmd_macsec_offload_on_result,
14078 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14079 TOKEN_STRING_INITIALIZER
14080 (struct cmd_macsec_offload_on_result,
14082 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14083 TOKEN_STRING_INITIALIZER
14084 (struct cmd_macsec_offload_on_result,
14085 encrypt, "encrypt");
14086 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14087 TOKEN_STRING_INITIALIZER
14088 (struct cmd_macsec_offload_on_result,
14089 en_on_off, "on#off");
14090 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14091 TOKEN_STRING_INITIALIZER
14092 (struct cmd_macsec_offload_on_result,
14093 replay_protect, "replay-protect");
14094 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14095 TOKEN_STRING_INITIALIZER
14096 (struct cmd_macsec_offload_on_result,
14097 rp_on_off, "on#off");
14100 cmd_set_macsec_offload_on_parsed(
14101 void *parsed_result,
14102 __attribute__((unused)) struct cmdline *cl,
14103 __attribute__((unused)) void *data)
14105 struct cmd_macsec_offload_on_result *res = parsed_result;
14106 int ret = -ENOTSUP;
14107 portid_t port_id = res->port_id;
14108 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14109 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14110 struct rte_eth_dev_info dev_info;
14112 if (port_id_is_invalid(port_id, ENABLED_WARN))
14114 if (!port_is_stopped(port_id)) {
14115 printf("Please stop port %d first\n", port_id);
14119 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14123 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14124 #ifdef RTE_LIBRTE_IXGBE_PMD
14125 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14133 ports[port_id].dev_conf.txmode.offloads |=
14134 DEV_TX_OFFLOAD_MACSEC_INSERT;
14135 cmd_reconfig_device_queue(port_id, 1, 1);
14138 printf("invalid port_id %d\n", port_id);
14141 printf("not supported on port %d\n", port_id);
14144 printf("programming error: (%s)\n", strerror(-ret));
14148 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14149 .f = cmd_set_macsec_offload_on_parsed,
14151 .help_str = "set macsec offload <port_id> on "
14152 "encrypt on|off replay-protect on|off",
14154 (void *)&cmd_macsec_offload_on_set,
14155 (void *)&cmd_macsec_offload_on_macsec,
14156 (void *)&cmd_macsec_offload_on_offload,
14157 (void *)&cmd_macsec_offload_on_port_id,
14158 (void *)&cmd_macsec_offload_on_on,
14159 (void *)&cmd_macsec_offload_on_encrypt,
14160 (void *)&cmd_macsec_offload_on_en_on_off,
14161 (void *)&cmd_macsec_offload_on_replay_protect,
14162 (void *)&cmd_macsec_offload_on_rp_on_off,
14167 /* Common result structure for MACsec offload disable */
14168 struct cmd_macsec_offload_off_result {
14169 cmdline_fixed_string_t set;
14170 cmdline_fixed_string_t macsec;
14171 cmdline_fixed_string_t offload;
14173 cmdline_fixed_string_t off;
14176 /* Common CLI fields for MACsec offload disable */
14177 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14178 TOKEN_STRING_INITIALIZER
14179 (struct cmd_macsec_offload_off_result,
14181 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14182 TOKEN_STRING_INITIALIZER
14183 (struct cmd_macsec_offload_off_result,
14185 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14186 TOKEN_STRING_INITIALIZER
14187 (struct cmd_macsec_offload_off_result,
14188 offload, "offload");
14189 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14190 TOKEN_NUM_INITIALIZER
14191 (struct cmd_macsec_offload_off_result,
14193 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14194 TOKEN_STRING_INITIALIZER
14195 (struct cmd_macsec_offload_off_result,
14199 cmd_set_macsec_offload_off_parsed(
14200 void *parsed_result,
14201 __attribute__((unused)) struct cmdline *cl,
14202 __attribute__((unused)) void *data)
14204 struct cmd_macsec_offload_off_result *res = parsed_result;
14205 int ret = -ENOTSUP;
14206 struct rte_eth_dev_info dev_info;
14207 portid_t port_id = res->port_id;
14209 if (port_id_is_invalid(port_id, ENABLED_WARN))
14211 if (!port_is_stopped(port_id)) {
14212 printf("Please stop port %d first\n", port_id);
14216 ret = eth_dev_info_get_print_err(port_id, &dev_info);
14220 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14221 #ifdef RTE_LIBRTE_IXGBE_PMD
14222 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14227 ports[port_id].dev_conf.txmode.offloads &=
14228 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14229 cmd_reconfig_device_queue(port_id, 1, 1);
14232 printf("invalid port_id %d\n", port_id);
14235 printf("not supported on port %d\n", port_id);
14238 printf("programming error: (%s)\n", strerror(-ret));
14242 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14243 .f = cmd_set_macsec_offload_off_parsed,
14245 .help_str = "set macsec offload <port_id> off",
14247 (void *)&cmd_macsec_offload_off_set,
14248 (void *)&cmd_macsec_offload_off_macsec,
14249 (void *)&cmd_macsec_offload_off_offload,
14250 (void *)&cmd_macsec_offload_off_port_id,
14251 (void *)&cmd_macsec_offload_off_off,
14256 /* Common result structure for MACsec secure connection configure */
14257 struct cmd_macsec_sc_result {
14258 cmdline_fixed_string_t set;
14259 cmdline_fixed_string_t macsec;
14260 cmdline_fixed_string_t sc;
14261 cmdline_fixed_string_t tx_rx;
14263 struct rte_ether_addr mac;
14267 /* Common CLI fields for MACsec secure connection configure */
14268 cmdline_parse_token_string_t cmd_macsec_sc_set =
14269 TOKEN_STRING_INITIALIZER
14270 (struct cmd_macsec_sc_result,
14272 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14273 TOKEN_STRING_INITIALIZER
14274 (struct cmd_macsec_sc_result,
14276 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14277 TOKEN_STRING_INITIALIZER
14278 (struct cmd_macsec_sc_result,
14280 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14281 TOKEN_STRING_INITIALIZER
14282 (struct cmd_macsec_sc_result,
14284 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14285 TOKEN_NUM_INITIALIZER
14286 (struct cmd_macsec_sc_result,
14288 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14289 TOKEN_ETHERADDR_INITIALIZER
14290 (struct cmd_macsec_sc_result,
14292 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14293 TOKEN_NUM_INITIALIZER
14294 (struct cmd_macsec_sc_result,
14298 cmd_set_macsec_sc_parsed(
14299 void *parsed_result,
14300 __attribute__((unused)) struct cmdline *cl,
14301 __attribute__((unused)) void *data)
14303 struct cmd_macsec_sc_result *res = parsed_result;
14304 int ret = -ENOTSUP;
14305 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14307 #ifdef RTE_LIBRTE_IXGBE_PMD
14309 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14310 res->mac.addr_bytes) :
14311 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14312 res->mac.addr_bytes, res->pi);
14314 RTE_SET_USED(is_tx);
14320 printf("invalid port_id %d\n", res->port_id);
14323 printf("not supported on port %d\n", res->port_id);
14326 printf("programming error: (%s)\n", strerror(-ret));
14330 cmdline_parse_inst_t cmd_set_macsec_sc = {
14331 .f = cmd_set_macsec_sc_parsed,
14333 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14335 (void *)&cmd_macsec_sc_set,
14336 (void *)&cmd_macsec_sc_macsec,
14337 (void *)&cmd_macsec_sc_sc,
14338 (void *)&cmd_macsec_sc_tx_rx,
14339 (void *)&cmd_macsec_sc_port_id,
14340 (void *)&cmd_macsec_sc_mac,
14341 (void *)&cmd_macsec_sc_pi,
14346 /* Common result structure for MACsec secure connection configure */
14347 struct cmd_macsec_sa_result {
14348 cmdline_fixed_string_t set;
14349 cmdline_fixed_string_t macsec;
14350 cmdline_fixed_string_t sa;
14351 cmdline_fixed_string_t tx_rx;
14356 cmdline_fixed_string_t key;
14359 /* Common CLI fields for MACsec secure connection configure */
14360 cmdline_parse_token_string_t cmd_macsec_sa_set =
14361 TOKEN_STRING_INITIALIZER
14362 (struct cmd_macsec_sa_result,
14364 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14365 TOKEN_STRING_INITIALIZER
14366 (struct cmd_macsec_sa_result,
14368 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14369 TOKEN_STRING_INITIALIZER
14370 (struct cmd_macsec_sa_result,
14372 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14373 TOKEN_STRING_INITIALIZER
14374 (struct cmd_macsec_sa_result,
14376 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14377 TOKEN_NUM_INITIALIZER
14378 (struct cmd_macsec_sa_result,
14380 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14381 TOKEN_NUM_INITIALIZER
14382 (struct cmd_macsec_sa_result,
14384 cmdline_parse_token_num_t cmd_macsec_sa_an =
14385 TOKEN_NUM_INITIALIZER
14386 (struct cmd_macsec_sa_result,
14388 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14389 TOKEN_NUM_INITIALIZER
14390 (struct cmd_macsec_sa_result,
14392 cmdline_parse_token_string_t cmd_macsec_sa_key =
14393 TOKEN_STRING_INITIALIZER
14394 (struct cmd_macsec_sa_result,
14398 cmd_set_macsec_sa_parsed(
14399 void *parsed_result,
14400 __attribute__((unused)) struct cmdline *cl,
14401 __attribute__((unused)) void *data)
14403 struct cmd_macsec_sa_result *res = parsed_result;
14404 int ret = -ENOTSUP;
14405 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14406 uint8_t key[16] = { 0 };
14412 key_len = strlen(res->key) / 2;
14416 for (i = 0; i < key_len; i++) {
14417 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14420 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14423 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14426 #ifdef RTE_LIBRTE_IXGBE_PMD
14428 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14429 res->idx, res->an, res->pn, key) :
14430 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14431 res->idx, res->an, res->pn, key);
14433 RTE_SET_USED(is_tx);
14440 printf("invalid idx %d or an %d\n", res->idx, res->an);
14443 printf("invalid port_id %d\n", res->port_id);
14446 printf("not supported on port %d\n", res->port_id);
14449 printf("programming error: (%s)\n", strerror(-ret));
14453 cmdline_parse_inst_t cmd_set_macsec_sa = {
14454 .f = cmd_set_macsec_sa_parsed,
14456 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14458 (void *)&cmd_macsec_sa_set,
14459 (void *)&cmd_macsec_sa_macsec,
14460 (void *)&cmd_macsec_sa_sa,
14461 (void *)&cmd_macsec_sa_tx_rx,
14462 (void *)&cmd_macsec_sa_port_id,
14463 (void *)&cmd_macsec_sa_idx,
14464 (void *)&cmd_macsec_sa_an,
14465 (void *)&cmd_macsec_sa_pn,
14466 (void *)&cmd_macsec_sa_key,
14471 /* VF unicast promiscuous mode configuration */
14473 /* Common result structure for VF unicast promiscuous mode */
14474 struct cmd_vf_promisc_result {
14475 cmdline_fixed_string_t set;
14476 cmdline_fixed_string_t vf;
14477 cmdline_fixed_string_t promisc;
14480 cmdline_fixed_string_t on_off;
14483 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14484 cmdline_parse_token_string_t cmd_vf_promisc_set =
14485 TOKEN_STRING_INITIALIZER
14486 (struct cmd_vf_promisc_result,
14488 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14489 TOKEN_STRING_INITIALIZER
14490 (struct cmd_vf_promisc_result,
14492 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14493 TOKEN_STRING_INITIALIZER
14494 (struct cmd_vf_promisc_result,
14495 promisc, "promisc");
14496 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14497 TOKEN_NUM_INITIALIZER
14498 (struct cmd_vf_promisc_result,
14500 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14501 TOKEN_NUM_INITIALIZER
14502 (struct cmd_vf_promisc_result,
14504 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14505 TOKEN_STRING_INITIALIZER
14506 (struct cmd_vf_promisc_result,
14510 cmd_set_vf_promisc_parsed(
14511 void *parsed_result,
14512 __attribute__((unused)) struct cmdline *cl,
14513 __attribute__((unused)) void *data)
14515 struct cmd_vf_promisc_result *res = parsed_result;
14516 int ret = -ENOTSUP;
14518 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14520 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14523 #ifdef RTE_LIBRTE_I40E_PMD
14524 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14525 res->vf_id, is_on);
14532 printf("invalid vf_id %d\n", res->vf_id);
14535 printf("invalid port_id %d\n", res->port_id);
14538 printf("function not implemented\n");
14541 printf("programming error: (%s)\n", strerror(-ret));
14545 cmdline_parse_inst_t cmd_set_vf_promisc = {
14546 .f = cmd_set_vf_promisc_parsed,
14548 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14549 "Set unicast promiscuous mode for a VF from the PF",
14551 (void *)&cmd_vf_promisc_set,
14552 (void *)&cmd_vf_promisc_vf,
14553 (void *)&cmd_vf_promisc_promisc,
14554 (void *)&cmd_vf_promisc_port_id,
14555 (void *)&cmd_vf_promisc_vf_id,
14556 (void *)&cmd_vf_promisc_on_off,
14561 /* VF multicast promiscuous mode configuration */
14563 /* Common result structure for VF multicast promiscuous mode */
14564 struct cmd_vf_allmulti_result {
14565 cmdline_fixed_string_t set;
14566 cmdline_fixed_string_t vf;
14567 cmdline_fixed_string_t allmulti;
14570 cmdline_fixed_string_t on_off;
14573 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14574 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14575 TOKEN_STRING_INITIALIZER
14576 (struct cmd_vf_allmulti_result,
14578 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14579 TOKEN_STRING_INITIALIZER
14580 (struct cmd_vf_allmulti_result,
14582 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14583 TOKEN_STRING_INITIALIZER
14584 (struct cmd_vf_allmulti_result,
14585 allmulti, "allmulti");
14586 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14587 TOKEN_NUM_INITIALIZER
14588 (struct cmd_vf_allmulti_result,
14590 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14591 TOKEN_NUM_INITIALIZER
14592 (struct cmd_vf_allmulti_result,
14594 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14595 TOKEN_STRING_INITIALIZER
14596 (struct cmd_vf_allmulti_result,
14600 cmd_set_vf_allmulti_parsed(
14601 void *parsed_result,
14602 __attribute__((unused)) struct cmdline *cl,
14603 __attribute__((unused)) void *data)
14605 struct cmd_vf_allmulti_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_multicast_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_allmulti = {
14636 .f = cmd_set_vf_allmulti_parsed,
14638 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14639 "Set multicast promiscuous mode for a VF from the PF",
14641 (void *)&cmd_vf_allmulti_set,
14642 (void *)&cmd_vf_allmulti_vf,
14643 (void *)&cmd_vf_allmulti_allmulti,
14644 (void *)&cmd_vf_allmulti_port_id,
14645 (void *)&cmd_vf_allmulti_vf_id,
14646 (void *)&cmd_vf_allmulti_on_off,
14651 /* vf broadcast mode configuration */
14653 /* Common result structure for vf broadcast */
14654 struct cmd_set_vf_broadcast_result {
14655 cmdline_fixed_string_t set;
14656 cmdline_fixed_string_t vf;
14657 cmdline_fixed_string_t broadcast;
14660 cmdline_fixed_string_t on_off;
14663 /* Common CLI fields for vf broadcast enable disable */
14664 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14665 TOKEN_STRING_INITIALIZER
14666 (struct cmd_set_vf_broadcast_result,
14668 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14669 TOKEN_STRING_INITIALIZER
14670 (struct cmd_set_vf_broadcast_result,
14672 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14673 TOKEN_STRING_INITIALIZER
14674 (struct cmd_set_vf_broadcast_result,
14675 broadcast, "broadcast");
14676 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14677 TOKEN_NUM_INITIALIZER
14678 (struct cmd_set_vf_broadcast_result,
14680 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14681 TOKEN_NUM_INITIALIZER
14682 (struct cmd_set_vf_broadcast_result,
14684 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14685 TOKEN_STRING_INITIALIZER
14686 (struct cmd_set_vf_broadcast_result,
14690 cmd_set_vf_broadcast_parsed(
14691 void *parsed_result,
14692 __attribute__((unused)) struct cmdline *cl,
14693 __attribute__((unused)) void *data)
14695 struct cmd_set_vf_broadcast_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_broadcast(res->port_id,
14705 res->vf_id, is_on);
14712 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
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_broadcast = {
14726 .f = cmd_set_vf_broadcast_parsed,
14728 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14730 (void *)&cmd_set_vf_broadcast_set,
14731 (void *)&cmd_set_vf_broadcast_vf,
14732 (void *)&cmd_set_vf_broadcast_broadcast,
14733 (void *)&cmd_set_vf_broadcast_port_id,
14734 (void *)&cmd_set_vf_broadcast_vf_id,
14735 (void *)&cmd_set_vf_broadcast_on_off,
14740 /* vf vlan tag configuration */
14742 /* Common result structure for vf vlan tag */
14743 struct cmd_set_vf_vlan_tag_result {
14744 cmdline_fixed_string_t set;
14745 cmdline_fixed_string_t vf;
14746 cmdline_fixed_string_t vlan;
14747 cmdline_fixed_string_t tag;
14750 cmdline_fixed_string_t on_off;
14753 /* Common CLI fields for vf vlan tag enable disable */
14754 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14755 TOKEN_STRING_INITIALIZER
14756 (struct cmd_set_vf_vlan_tag_result,
14758 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14759 TOKEN_STRING_INITIALIZER
14760 (struct cmd_set_vf_vlan_tag_result,
14762 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14763 TOKEN_STRING_INITIALIZER
14764 (struct cmd_set_vf_vlan_tag_result,
14766 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14767 TOKEN_STRING_INITIALIZER
14768 (struct cmd_set_vf_vlan_tag_result,
14770 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14771 TOKEN_NUM_INITIALIZER
14772 (struct cmd_set_vf_vlan_tag_result,
14774 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14775 TOKEN_NUM_INITIALIZER
14776 (struct cmd_set_vf_vlan_tag_result,
14778 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14779 TOKEN_STRING_INITIALIZER
14780 (struct cmd_set_vf_vlan_tag_result,
14784 cmd_set_vf_vlan_tag_parsed(
14785 void *parsed_result,
14786 __attribute__((unused)) struct cmdline *cl,
14787 __attribute__((unused)) void *data)
14789 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14790 int ret = -ENOTSUP;
14792 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14794 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14797 #ifdef RTE_LIBRTE_I40E_PMD
14798 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14799 res->vf_id, is_on);
14806 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14809 printf("invalid port_id %d\n", res->port_id);
14812 printf("function not implemented\n");
14815 printf("programming error: (%s)\n", strerror(-ret));
14819 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14820 .f = cmd_set_vf_vlan_tag_parsed,
14822 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14824 (void *)&cmd_set_vf_vlan_tag_set,
14825 (void *)&cmd_set_vf_vlan_tag_vf,
14826 (void *)&cmd_set_vf_vlan_tag_vlan,
14827 (void *)&cmd_set_vf_vlan_tag_tag,
14828 (void *)&cmd_set_vf_vlan_tag_port_id,
14829 (void *)&cmd_set_vf_vlan_tag_vf_id,
14830 (void *)&cmd_set_vf_vlan_tag_on_off,
14835 /* Common definition of VF and TC TX bandwidth configuration */
14836 struct cmd_vf_tc_bw_result {
14837 cmdline_fixed_string_t set;
14838 cmdline_fixed_string_t vf;
14839 cmdline_fixed_string_t tc;
14840 cmdline_fixed_string_t tx;
14841 cmdline_fixed_string_t min_bw;
14842 cmdline_fixed_string_t max_bw;
14843 cmdline_fixed_string_t strict_link_prio;
14848 cmdline_fixed_string_t bw_list;
14852 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14853 TOKEN_STRING_INITIALIZER
14854 (struct cmd_vf_tc_bw_result,
14856 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14857 TOKEN_STRING_INITIALIZER
14858 (struct cmd_vf_tc_bw_result,
14860 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14861 TOKEN_STRING_INITIALIZER
14862 (struct cmd_vf_tc_bw_result,
14864 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14865 TOKEN_STRING_INITIALIZER
14866 (struct cmd_vf_tc_bw_result,
14868 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14869 TOKEN_STRING_INITIALIZER
14870 (struct cmd_vf_tc_bw_result,
14871 strict_link_prio, "strict-link-priority");
14872 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14873 TOKEN_STRING_INITIALIZER
14874 (struct cmd_vf_tc_bw_result,
14875 min_bw, "min-bandwidth");
14876 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14877 TOKEN_STRING_INITIALIZER
14878 (struct cmd_vf_tc_bw_result,
14879 max_bw, "max-bandwidth");
14880 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14881 TOKEN_NUM_INITIALIZER
14882 (struct cmd_vf_tc_bw_result,
14884 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14885 TOKEN_NUM_INITIALIZER
14886 (struct cmd_vf_tc_bw_result,
14888 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14889 TOKEN_NUM_INITIALIZER
14890 (struct cmd_vf_tc_bw_result,
14892 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14893 TOKEN_NUM_INITIALIZER
14894 (struct cmd_vf_tc_bw_result,
14896 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14897 TOKEN_STRING_INITIALIZER
14898 (struct cmd_vf_tc_bw_result,
14900 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14901 TOKEN_NUM_INITIALIZER
14902 (struct cmd_vf_tc_bw_result,
14905 /* VF max bandwidth setting */
14907 cmd_vf_max_bw_parsed(
14908 void *parsed_result,
14909 __attribute__((unused)) struct cmdline *cl,
14910 __attribute__((unused)) void *data)
14912 struct cmd_vf_tc_bw_result *res = parsed_result;
14913 int ret = -ENOTSUP;
14915 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14918 #ifdef RTE_LIBRTE_I40E_PMD
14919 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14920 res->vf_id, res->bw);
14927 printf("invalid vf_id %d or bandwidth %d\n",
14928 res->vf_id, res->bw);
14931 printf("invalid port_id %d\n", res->port_id);
14934 printf("function not implemented\n");
14937 printf("programming error: (%s)\n", strerror(-ret));
14941 cmdline_parse_inst_t cmd_vf_max_bw = {
14942 .f = cmd_vf_max_bw_parsed,
14944 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14946 (void *)&cmd_vf_tc_bw_set,
14947 (void *)&cmd_vf_tc_bw_vf,
14948 (void *)&cmd_vf_tc_bw_tx,
14949 (void *)&cmd_vf_tc_bw_max_bw,
14950 (void *)&cmd_vf_tc_bw_port_id,
14951 (void *)&cmd_vf_tc_bw_vf_id,
14952 (void *)&cmd_vf_tc_bw_bw,
14958 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14963 const char *p, *p0 = str;
14970 p = strchr(p0, '(');
14972 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14976 p0 = strchr(p, ')');
14978 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14982 if (size >= sizeof(s)) {
14983 printf("The string size exceeds the internal buffer size\n");
14986 snprintf(s, sizeof(s), "%.*s", size, p);
14987 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14989 printf("Failed to get the bandwidth list. ");
14993 for (i = 0; i < ret; i++)
14994 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14999 /* TC min bandwidth setting */
15001 cmd_vf_tc_min_bw_parsed(
15002 void *parsed_result,
15003 __attribute__((unused)) struct cmdline *cl,
15004 __attribute__((unused)) void *data)
15006 struct cmd_vf_tc_bw_result *res = parsed_result;
15009 int ret = -ENOTSUP;
15011 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15014 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15018 #ifdef RTE_LIBRTE_I40E_PMD
15019 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
15027 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
15030 printf("invalid port_id %d\n", res->port_id);
15033 printf("function not implemented\n");
15036 printf("programming error: (%s)\n", strerror(-ret));
15040 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
15041 .f = cmd_vf_tc_min_bw_parsed,
15043 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
15044 " <bw1, bw2, ...>",
15046 (void *)&cmd_vf_tc_bw_set,
15047 (void *)&cmd_vf_tc_bw_vf,
15048 (void *)&cmd_vf_tc_bw_tc,
15049 (void *)&cmd_vf_tc_bw_tx,
15050 (void *)&cmd_vf_tc_bw_min_bw,
15051 (void *)&cmd_vf_tc_bw_port_id,
15052 (void *)&cmd_vf_tc_bw_vf_id,
15053 (void *)&cmd_vf_tc_bw_bw_list,
15059 cmd_tc_min_bw_parsed(
15060 void *parsed_result,
15061 __attribute__((unused)) struct cmdline *cl,
15062 __attribute__((unused)) void *data)
15064 struct cmd_vf_tc_bw_result *res = parsed_result;
15065 struct rte_port *port;
15068 int ret = -ENOTSUP;
15070 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15073 port = &ports[res->port_id];
15074 /** Check if the port is not started **/
15075 if (port->port_status != RTE_PORT_STOPPED) {
15076 printf("Please stop port %d first\n", res->port_id);
15080 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15084 #ifdef RTE_LIBRTE_IXGBE_PMD
15085 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15092 printf("invalid bandwidth\n");
15095 printf("invalid port_id %d\n", res->port_id);
15098 printf("function not implemented\n");
15101 printf("programming error: (%s)\n", strerror(-ret));
15105 cmdline_parse_inst_t cmd_tc_min_bw = {
15106 .f = cmd_tc_min_bw_parsed,
15108 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15110 (void *)&cmd_vf_tc_bw_set,
15111 (void *)&cmd_vf_tc_bw_tc,
15112 (void *)&cmd_vf_tc_bw_tx,
15113 (void *)&cmd_vf_tc_bw_min_bw,
15114 (void *)&cmd_vf_tc_bw_port_id,
15115 (void *)&cmd_vf_tc_bw_bw_list,
15120 /* TC max bandwidth setting */
15122 cmd_vf_tc_max_bw_parsed(
15123 void *parsed_result,
15124 __attribute__((unused)) struct cmdline *cl,
15125 __attribute__((unused)) void *data)
15127 struct cmd_vf_tc_bw_result *res = parsed_result;
15128 int ret = -ENOTSUP;
15130 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15133 #ifdef RTE_LIBRTE_I40E_PMD
15134 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15135 res->tc_no, res->bw);
15142 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15143 res->vf_id, res->tc_no, res->bw);
15146 printf("invalid port_id %d\n", res->port_id);
15149 printf("function not implemented\n");
15152 printf("programming error: (%s)\n", strerror(-ret));
15156 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15157 .f = cmd_vf_tc_max_bw_parsed,
15159 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15162 (void *)&cmd_vf_tc_bw_set,
15163 (void *)&cmd_vf_tc_bw_vf,
15164 (void *)&cmd_vf_tc_bw_tc,
15165 (void *)&cmd_vf_tc_bw_tx,
15166 (void *)&cmd_vf_tc_bw_max_bw,
15167 (void *)&cmd_vf_tc_bw_port_id,
15168 (void *)&cmd_vf_tc_bw_vf_id,
15169 (void *)&cmd_vf_tc_bw_tc_no,
15170 (void *)&cmd_vf_tc_bw_bw,
15176 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15178 /* *** Set Port default Traffic Management Hierarchy *** */
15179 struct cmd_set_port_tm_hierarchy_default_result {
15180 cmdline_fixed_string_t set;
15181 cmdline_fixed_string_t port;
15182 cmdline_fixed_string_t tm;
15183 cmdline_fixed_string_t hierarchy;
15184 cmdline_fixed_string_t def;
15188 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15189 TOKEN_STRING_INITIALIZER(
15190 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15191 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15192 TOKEN_STRING_INITIALIZER(
15193 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15194 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15195 TOKEN_STRING_INITIALIZER(
15196 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15197 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15198 TOKEN_STRING_INITIALIZER(
15199 struct cmd_set_port_tm_hierarchy_default_result,
15200 hierarchy, "hierarchy");
15201 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15202 TOKEN_STRING_INITIALIZER(
15203 struct cmd_set_port_tm_hierarchy_default_result,
15205 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15206 TOKEN_NUM_INITIALIZER(
15207 struct cmd_set_port_tm_hierarchy_default_result,
15210 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15211 __attribute__((unused)) struct cmdline *cl,
15212 __attribute__((unused)) void *data)
15214 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15215 struct rte_port *p;
15216 portid_t port_id = res->port_id;
15218 if (port_id_is_invalid(port_id, ENABLED_WARN))
15221 p = &ports[port_id];
15223 /* Forward mode: tm */
15224 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15225 printf(" softnicfwd mode not enabled(error)\n");
15229 /* Set the default tm hierarchy */
15230 p->softport.default_tm_hierarchy_enable = 1;
15233 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15234 .f = cmd_set_port_tm_hierarchy_default_parsed,
15236 .help_str = "set port tm hierarchy default <port_id>",
15238 (void *)&cmd_set_port_tm_hierarchy_default_set,
15239 (void *)&cmd_set_port_tm_hierarchy_default_port,
15240 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15241 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15242 (void *)&cmd_set_port_tm_hierarchy_default_default,
15243 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15249 /** Set VXLAN encapsulation details */
15250 struct cmd_set_vxlan_result {
15251 cmdline_fixed_string_t set;
15252 cmdline_fixed_string_t vxlan;
15253 cmdline_fixed_string_t pos_token;
15254 cmdline_fixed_string_t ip_version;
15255 uint32_t vlan_present:1;
15259 cmdline_ipaddr_t ip_src;
15260 cmdline_ipaddr_t ip_dst;
15264 struct rte_ether_addr eth_src;
15265 struct rte_ether_addr eth_dst;
15268 cmdline_parse_token_string_t cmd_set_vxlan_set =
15269 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15270 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15271 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15272 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15273 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15275 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15276 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15277 "vxlan-with-vlan");
15278 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15279 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15281 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15282 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15284 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15285 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15287 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15288 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15289 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15290 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15292 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15293 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15294 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15295 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15297 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15298 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15299 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15300 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15302 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15303 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15304 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15305 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15307 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15308 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15309 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15310 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15312 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15313 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15314 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15315 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15317 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15318 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15319 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15320 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15322 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15323 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15324 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15325 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15327 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15328 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15329 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15330 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15332 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15333 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15335 static void cmd_set_vxlan_parsed(void *parsed_result,
15336 __attribute__((unused)) struct cmdline *cl,
15337 __attribute__((unused)) void *data)
15339 struct cmd_set_vxlan_result *res = parsed_result;
15344 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15347 vxlan_encap_conf.select_tos_ttl = 0;
15348 if (strcmp(res->vxlan, "vxlan") == 0)
15349 vxlan_encap_conf.select_vlan = 0;
15350 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15351 vxlan_encap_conf.select_vlan = 1;
15352 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15353 vxlan_encap_conf.select_vlan = 0;
15354 vxlan_encap_conf.select_tos_ttl = 1;
15356 if (strcmp(res->ip_version, "ipv4") == 0)
15357 vxlan_encap_conf.select_ipv4 = 1;
15358 else if (strcmp(res->ip_version, "ipv6") == 0)
15359 vxlan_encap_conf.select_ipv4 = 0;
15362 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15363 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15364 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15365 vxlan_encap_conf.ip_tos = res->tos;
15366 vxlan_encap_conf.ip_ttl = res->ttl;
15367 if (vxlan_encap_conf.select_ipv4) {
15368 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15369 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15371 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15372 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15374 if (vxlan_encap_conf.select_vlan)
15375 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15376 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15377 RTE_ETHER_ADDR_LEN);
15378 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15379 RTE_ETHER_ADDR_LEN);
15382 cmdline_parse_inst_t cmd_set_vxlan = {
15383 .f = cmd_set_vxlan_parsed,
15385 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15386 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15387 " eth-src <eth-src> eth-dst <eth-dst>",
15389 (void *)&cmd_set_vxlan_set,
15390 (void *)&cmd_set_vxlan_vxlan,
15391 (void *)&cmd_set_vxlan_ip_version,
15392 (void *)&cmd_set_vxlan_ip_version_value,
15393 (void *)&cmd_set_vxlan_vni,
15394 (void *)&cmd_set_vxlan_vni_value,
15395 (void *)&cmd_set_vxlan_udp_src,
15396 (void *)&cmd_set_vxlan_udp_src_value,
15397 (void *)&cmd_set_vxlan_udp_dst,
15398 (void *)&cmd_set_vxlan_udp_dst_value,
15399 (void *)&cmd_set_vxlan_ip_src,
15400 (void *)&cmd_set_vxlan_ip_src_value,
15401 (void *)&cmd_set_vxlan_ip_dst,
15402 (void *)&cmd_set_vxlan_ip_dst_value,
15403 (void *)&cmd_set_vxlan_eth_src,
15404 (void *)&cmd_set_vxlan_eth_src_value,
15405 (void *)&cmd_set_vxlan_eth_dst,
15406 (void *)&cmd_set_vxlan_eth_dst_value,
15411 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15412 .f = cmd_set_vxlan_parsed,
15414 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15415 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15416 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15417 " eth-dst <eth-dst>",
15419 (void *)&cmd_set_vxlan_set,
15420 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15421 (void *)&cmd_set_vxlan_ip_version,
15422 (void *)&cmd_set_vxlan_ip_version_value,
15423 (void *)&cmd_set_vxlan_vni,
15424 (void *)&cmd_set_vxlan_vni_value,
15425 (void *)&cmd_set_vxlan_udp_src,
15426 (void *)&cmd_set_vxlan_udp_src_value,
15427 (void *)&cmd_set_vxlan_udp_dst,
15428 (void *)&cmd_set_vxlan_udp_dst_value,
15429 (void *)&cmd_set_vxlan_ip_tos,
15430 (void *)&cmd_set_vxlan_ip_tos_value,
15431 (void *)&cmd_set_vxlan_ip_ttl,
15432 (void *)&cmd_set_vxlan_ip_ttl_value,
15433 (void *)&cmd_set_vxlan_ip_src,
15434 (void *)&cmd_set_vxlan_ip_src_value,
15435 (void *)&cmd_set_vxlan_ip_dst,
15436 (void *)&cmd_set_vxlan_ip_dst_value,
15437 (void *)&cmd_set_vxlan_eth_src,
15438 (void *)&cmd_set_vxlan_eth_src_value,
15439 (void *)&cmd_set_vxlan_eth_dst,
15440 (void *)&cmd_set_vxlan_eth_dst_value,
15445 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15446 .f = cmd_set_vxlan_parsed,
15448 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15449 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15450 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15453 (void *)&cmd_set_vxlan_set,
15454 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15455 (void *)&cmd_set_vxlan_ip_version,
15456 (void *)&cmd_set_vxlan_ip_version_value,
15457 (void *)&cmd_set_vxlan_vni,
15458 (void *)&cmd_set_vxlan_vni_value,
15459 (void *)&cmd_set_vxlan_udp_src,
15460 (void *)&cmd_set_vxlan_udp_src_value,
15461 (void *)&cmd_set_vxlan_udp_dst,
15462 (void *)&cmd_set_vxlan_udp_dst_value,
15463 (void *)&cmd_set_vxlan_ip_src,
15464 (void *)&cmd_set_vxlan_ip_src_value,
15465 (void *)&cmd_set_vxlan_ip_dst,
15466 (void *)&cmd_set_vxlan_ip_dst_value,
15467 (void *)&cmd_set_vxlan_vlan,
15468 (void *)&cmd_set_vxlan_vlan_value,
15469 (void *)&cmd_set_vxlan_eth_src,
15470 (void *)&cmd_set_vxlan_eth_src_value,
15471 (void *)&cmd_set_vxlan_eth_dst,
15472 (void *)&cmd_set_vxlan_eth_dst_value,
15477 /** Set NVGRE encapsulation details */
15478 struct cmd_set_nvgre_result {
15479 cmdline_fixed_string_t set;
15480 cmdline_fixed_string_t nvgre;
15481 cmdline_fixed_string_t pos_token;
15482 cmdline_fixed_string_t ip_version;
15484 cmdline_ipaddr_t ip_src;
15485 cmdline_ipaddr_t ip_dst;
15487 struct rte_ether_addr eth_src;
15488 struct rte_ether_addr eth_dst;
15491 cmdline_parse_token_string_t cmd_set_nvgre_set =
15492 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15493 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15494 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15495 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15496 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15497 "nvgre-with-vlan");
15498 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15499 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15501 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15502 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15504 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15505 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15507 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15508 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15509 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15510 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15512 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15513 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15514 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15515 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15517 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15518 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15519 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15520 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15522 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15523 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15524 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15525 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15527 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15528 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15529 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15530 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15532 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15533 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15535 static void cmd_set_nvgre_parsed(void *parsed_result,
15536 __attribute__((unused)) struct cmdline *cl,
15537 __attribute__((unused)) void *data)
15539 struct cmd_set_nvgre_result *res = parsed_result;
15541 uint32_t nvgre_tni;
15544 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15547 if (strcmp(res->nvgre, "nvgre") == 0)
15548 nvgre_encap_conf.select_vlan = 0;
15549 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15550 nvgre_encap_conf.select_vlan = 1;
15551 if (strcmp(res->ip_version, "ipv4") == 0)
15552 nvgre_encap_conf.select_ipv4 = 1;
15553 else if (strcmp(res->ip_version, "ipv6") == 0)
15554 nvgre_encap_conf.select_ipv4 = 0;
15557 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15558 if (nvgre_encap_conf.select_ipv4) {
15559 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15560 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15562 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15563 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15565 if (nvgre_encap_conf.select_vlan)
15566 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15567 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15568 RTE_ETHER_ADDR_LEN);
15569 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15570 RTE_ETHER_ADDR_LEN);
15573 cmdline_parse_inst_t cmd_set_nvgre = {
15574 .f = cmd_set_nvgre_parsed,
15576 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15577 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15578 " eth-dst <eth-dst>",
15580 (void *)&cmd_set_nvgre_set,
15581 (void *)&cmd_set_nvgre_nvgre,
15582 (void *)&cmd_set_nvgre_ip_version,
15583 (void *)&cmd_set_nvgre_ip_version_value,
15584 (void *)&cmd_set_nvgre_tni,
15585 (void *)&cmd_set_nvgre_tni_value,
15586 (void *)&cmd_set_nvgre_ip_src,
15587 (void *)&cmd_set_nvgre_ip_src_value,
15588 (void *)&cmd_set_nvgre_ip_dst,
15589 (void *)&cmd_set_nvgre_ip_dst_value,
15590 (void *)&cmd_set_nvgre_eth_src,
15591 (void *)&cmd_set_nvgre_eth_src_value,
15592 (void *)&cmd_set_nvgre_eth_dst,
15593 (void *)&cmd_set_nvgre_eth_dst_value,
15598 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15599 .f = cmd_set_nvgre_parsed,
15601 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15602 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15603 " eth-src <eth-src> eth-dst <eth-dst>",
15605 (void *)&cmd_set_nvgre_set,
15606 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15607 (void *)&cmd_set_nvgre_ip_version,
15608 (void *)&cmd_set_nvgre_ip_version_value,
15609 (void *)&cmd_set_nvgre_tni,
15610 (void *)&cmd_set_nvgre_tni_value,
15611 (void *)&cmd_set_nvgre_ip_src,
15612 (void *)&cmd_set_nvgre_ip_src_value,
15613 (void *)&cmd_set_nvgre_ip_dst,
15614 (void *)&cmd_set_nvgre_ip_dst_value,
15615 (void *)&cmd_set_nvgre_vlan,
15616 (void *)&cmd_set_nvgre_vlan_value,
15617 (void *)&cmd_set_nvgre_eth_src,
15618 (void *)&cmd_set_nvgre_eth_src_value,
15619 (void *)&cmd_set_nvgre_eth_dst,
15620 (void *)&cmd_set_nvgre_eth_dst_value,
15625 /** Set L2 encapsulation details */
15626 struct cmd_set_l2_encap_result {
15627 cmdline_fixed_string_t set;
15628 cmdline_fixed_string_t l2_encap;
15629 cmdline_fixed_string_t pos_token;
15630 cmdline_fixed_string_t ip_version;
15631 uint32_t vlan_present:1;
15633 struct rte_ether_addr eth_src;
15634 struct rte_ether_addr eth_dst;
15637 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15638 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15639 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15640 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15641 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15642 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15643 "l2_encap-with-vlan");
15644 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15645 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15647 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15648 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15650 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15651 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15653 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15654 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15655 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15656 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15658 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15659 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15660 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15661 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15663 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15664 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15666 static void cmd_set_l2_encap_parsed(void *parsed_result,
15667 __attribute__((unused)) struct cmdline *cl,
15668 __attribute__((unused)) void *data)
15670 struct cmd_set_l2_encap_result *res = parsed_result;
15672 if (strcmp(res->l2_encap, "l2_encap") == 0)
15673 l2_encap_conf.select_vlan = 0;
15674 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15675 l2_encap_conf.select_vlan = 1;
15676 if (strcmp(res->ip_version, "ipv4") == 0)
15677 l2_encap_conf.select_ipv4 = 1;
15678 else if (strcmp(res->ip_version, "ipv6") == 0)
15679 l2_encap_conf.select_ipv4 = 0;
15682 if (l2_encap_conf.select_vlan)
15683 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15684 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15685 RTE_ETHER_ADDR_LEN);
15686 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15687 RTE_ETHER_ADDR_LEN);
15690 cmdline_parse_inst_t cmd_set_l2_encap = {
15691 .f = cmd_set_l2_encap_parsed,
15693 .help_str = "set l2_encap ip-version ipv4|ipv6"
15694 " eth-src <eth-src> eth-dst <eth-dst>",
15696 (void *)&cmd_set_l2_encap_set,
15697 (void *)&cmd_set_l2_encap_l2_encap,
15698 (void *)&cmd_set_l2_encap_ip_version,
15699 (void *)&cmd_set_l2_encap_ip_version_value,
15700 (void *)&cmd_set_l2_encap_eth_src,
15701 (void *)&cmd_set_l2_encap_eth_src_value,
15702 (void *)&cmd_set_l2_encap_eth_dst,
15703 (void *)&cmd_set_l2_encap_eth_dst_value,
15708 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15709 .f = cmd_set_l2_encap_parsed,
15711 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15712 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15714 (void *)&cmd_set_l2_encap_set,
15715 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15716 (void *)&cmd_set_l2_encap_ip_version,
15717 (void *)&cmd_set_l2_encap_ip_version_value,
15718 (void *)&cmd_set_l2_encap_vlan,
15719 (void *)&cmd_set_l2_encap_vlan_value,
15720 (void *)&cmd_set_l2_encap_eth_src,
15721 (void *)&cmd_set_l2_encap_eth_src_value,
15722 (void *)&cmd_set_l2_encap_eth_dst,
15723 (void *)&cmd_set_l2_encap_eth_dst_value,
15728 /** Set L2 decapsulation details */
15729 struct cmd_set_l2_decap_result {
15730 cmdline_fixed_string_t set;
15731 cmdline_fixed_string_t l2_decap;
15732 cmdline_fixed_string_t pos_token;
15733 uint32_t vlan_present:1;
15736 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15737 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15738 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15739 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15741 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15742 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15743 "l2_decap-with-vlan");
15745 static void cmd_set_l2_decap_parsed(void *parsed_result,
15746 __attribute__((unused)) struct cmdline *cl,
15747 __attribute__((unused)) void *data)
15749 struct cmd_set_l2_decap_result *res = parsed_result;
15751 if (strcmp(res->l2_decap, "l2_decap") == 0)
15752 l2_decap_conf.select_vlan = 0;
15753 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15754 l2_decap_conf.select_vlan = 1;
15757 cmdline_parse_inst_t cmd_set_l2_decap = {
15758 .f = cmd_set_l2_decap_parsed,
15760 .help_str = "set l2_decap",
15762 (void *)&cmd_set_l2_decap_set,
15763 (void *)&cmd_set_l2_decap_l2_decap,
15768 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15769 .f = cmd_set_l2_decap_parsed,
15771 .help_str = "set l2_decap-with-vlan",
15773 (void *)&cmd_set_l2_decap_set,
15774 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15779 /** Set MPLSoGRE encapsulation details */
15780 struct cmd_set_mplsogre_encap_result {
15781 cmdline_fixed_string_t set;
15782 cmdline_fixed_string_t mplsogre;
15783 cmdline_fixed_string_t pos_token;
15784 cmdline_fixed_string_t ip_version;
15785 uint32_t vlan_present:1;
15787 cmdline_ipaddr_t ip_src;
15788 cmdline_ipaddr_t ip_dst;
15790 struct rte_ether_addr eth_src;
15791 struct rte_ether_addr eth_dst;
15794 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15795 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15797 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15798 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15800 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15801 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15802 mplsogre, "mplsogre_encap-with-vlan");
15803 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15804 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15805 pos_token, "ip-version");
15806 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15807 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15808 ip_version, "ipv4#ipv6");
15809 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15810 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15811 pos_token, "label");
15812 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15813 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15815 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15816 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15817 pos_token, "ip-src");
15818 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15819 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15820 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15821 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15822 pos_token, "ip-dst");
15823 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15824 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15825 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15826 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15827 pos_token, "vlan-tci");
15828 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15829 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15831 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15832 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15833 pos_token, "eth-src");
15834 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15835 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15837 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15838 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15839 pos_token, "eth-dst");
15840 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15841 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15844 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15845 __attribute__((unused)) struct cmdline *cl,
15846 __attribute__((unused)) void *data)
15848 struct cmd_set_mplsogre_encap_result *res = parsed_result;
15850 uint32_t mplsogre_label;
15853 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15856 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15857 mplsogre_encap_conf.select_vlan = 0;
15858 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15859 mplsogre_encap_conf.select_vlan = 1;
15860 if (strcmp(res->ip_version, "ipv4") == 0)
15861 mplsogre_encap_conf.select_ipv4 = 1;
15862 else if (strcmp(res->ip_version, "ipv6") == 0)
15863 mplsogre_encap_conf.select_ipv4 = 0;
15866 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15867 if (mplsogre_encap_conf.select_ipv4) {
15868 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15869 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15871 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15872 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15874 if (mplsogre_encap_conf.select_vlan)
15875 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15876 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15877 RTE_ETHER_ADDR_LEN);
15878 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15879 RTE_ETHER_ADDR_LEN);
15882 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15883 .f = cmd_set_mplsogre_encap_parsed,
15885 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15886 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15887 " eth-dst <eth-dst>",
15889 (void *)&cmd_set_mplsogre_encap_set,
15890 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15891 (void *)&cmd_set_mplsogre_encap_ip_version,
15892 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15893 (void *)&cmd_set_mplsogre_encap_label,
15894 (void *)&cmd_set_mplsogre_encap_label_value,
15895 (void *)&cmd_set_mplsogre_encap_ip_src,
15896 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15897 (void *)&cmd_set_mplsogre_encap_ip_dst,
15898 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15899 (void *)&cmd_set_mplsogre_encap_eth_src,
15900 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15901 (void *)&cmd_set_mplsogre_encap_eth_dst,
15902 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15907 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
15908 .f = cmd_set_mplsogre_encap_parsed,
15910 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
15911 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
15912 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15914 (void *)&cmd_set_mplsogre_encap_set,
15915 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
15916 (void *)&cmd_set_mplsogre_encap_ip_version,
15917 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15918 (void *)&cmd_set_mplsogre_encap_label,
15919 (void *)&cmd_set_mplsogre_encap_label_value,
15920 (void *)&cmd_set_mplsogre_encap_ip_src,
15921 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15922 (void *)&cmd_set_mplsogre_encap_ip_dst,
15923 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15924 (void *)&cmd_set_mplsogre_encap_vlan,
15925 (void *)&cmd_set_mplsogre_encap_vlan_value,
15926 (void *)&cmd_set_mplsogre_encap_eth_src,
15927 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15928 (void *)&cmd_set_mplsogre_encap_eth_dst,
15929 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15934 /** Set MPLSoGRE decapsulation details */
15935 struct cmd_set_mplsogre_decap_result {
15936 cmdline_fixed_string_t set;
15937 cmdline_fixed_string_t mplsogre;
15938 cmdline_fixed_string_t pos_token;
15939 cmdline_fixed_string_t ip_version;
15940 uint32_t vlan_present:1;
15943 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
15944 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
15946 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
15947 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
15949 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
15950 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15951 mplsogre, "mplsogre_decap-with-vlan");
15952 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
15953 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15954 pos_token, "ip-version");
15955 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
15956 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15957 ip_version, "ipv4#ipv6");
15959 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
15960 __attribute__((unused)) struct cmdline *cl,
15961 __attribute__((unused)) void *data)
15963 struct cmd_set_mplsogre_decap_result *res = parsed_result;
15965 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
15966 mplsogre_decap_conf.select_vlan = 0;
15967 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
15968 mplsogre_decap_conf.select_vlan = 1;
15969 if (strcmp(res->ip_version, "ipv4") == 0)
15970 mplsogre_decap_conf.select_ipv4 = 1;
15971 else if (strcmp(res->ip_version, "ipv6") == 0)
15972 mplsogre_decap_conf.select_ipv4 = 0;
15975 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
15976 .f = cmd_set_mplsogre_decap_parsed,
15978 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
15980 (void *)&cmd_set_mplsogre_decap_set,
15981 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
15982 (void *)&cmd_set_mplsogre_decap_ip_version,
15983 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15988 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
15989 .f = cmd_set_mplsogre_decap_parsed,
15991 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
15993 (void *)&cmd_set_mplsogre_decap_set,
15994 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
15995 (void *)&cmd_set_mplsogre_decap_ip_version,
15996 (void *)&cmd_set_mplsogre_decap_ip_version_value,
16001 /** Set MPLSoUDP encapsulation details */
16002 struct cmd_set_mplsoudp_encap_result {
16003 cmdline_fixed_string_t set;
16004 cmdline_fixed_string_t mplsoudp;
16005 cmdline_fixed_string_t pos_token;
16006 cmdline_fixed_string_t ip_version;
16007 uint32_t vlan_present:1;
16011 cmdline_ipaddr_t ip_src;
16012 cmdline_ipaddr_t ip_dst;
16014 struct rte_ether_addr eth_src;
16015 struct rte_ether_addr eth_dst;
16018 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
16019 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
16021 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
16022 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
16024 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
16025 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16026 mplsoudp, "mplsoudp_encap-with-vlan");
16027 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
16028 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16029 pos_token, "ip-version");
16030 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
16031 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16032 ip_version, "ipv4#ipv6");
16033 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
16034 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16035 pos_token, "label");
16036 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
16037 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
16039 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
16040 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16041 pos_token, "udp-src");
16042 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
16043 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
16045 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
16046 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16047 pos_token, "udp-dst");
16048 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16049 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16051 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16052 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16053 pos_token, "ip-src");
16054 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16055 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16056 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16057 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16058 pos_token, "ip-dst");
16059 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16060 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16061 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16062 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16063 pos_token, "vlan-tci");
16064 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16065 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16067 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16068 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16069 pos_token, "eth-src");
16070 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16071 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16073 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16074 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16075 pos_token, "eth-dst");
16076 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16077 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16080 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16081 __attribute__((unused)) struct cmdline *cl,
16082 __attribute__((unused)) void *data)
16084 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16086 uint32_t mplsoudp_label;
16089 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16092 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16093 mplsoudp_encap_conf.select_vlan = 0;
16094 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16095 mplsoudp_encap_conf.select_vlan = 1;
16096 if (strcmp(res->ip_version, "ipv4") == 0)
16097 mplsoudp_encap_conf.select_ipv4 = 1;
16098 else if (strcmp(res->ip_version, "ipv6") == 0)
16099 mplsoudp_encap_conf.select_ipv4 = 0;
16102 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16103 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16104 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16105 if (mplsoudp_encap_conf.select_ipv4) {
16106 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16107 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16109 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16110 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16112 if (mplsoudp_encap_conf.select_vlan)
16113 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16114 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16115 RTE_ETHER_ADDR_LEN);
16116 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16117 RTE_ETHER_ADDR_LEN);
16120 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16121 .f = cmd_set_mplsoudp_encap_parsed,
16123 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16124 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16125 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16127 (void *)&cmd_set_mplsoudp_encap_set,
16128 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16129 (void *)&cmd_set_mplsoudp_encap_ip_version,
16130 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16131 (void *)&cmd_set_mplsoudp_encap_label,
16132 (void *)&cmd_set_mplsoudp_encap_label_value,
16133 (void *)&cmd_set_mplsoudp_encap_udp_src,
16134 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16135 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16136 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16137 (void *)&cmd_set_mplsoudp_encap_ip_src,
16138 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16139 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16140 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16141 (void *)&cmd_set_mplsoudp_encap_eth_src,
16142 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16143 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16144 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16149 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16150 .f = cmd_set_mplsoudp_encap_parsed,
16152 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16153 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16154 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16155 " eth-src <eth-src> eth-dst <eth-dst>",
16157 (void *)&cmd_set_mplsoudp_encap_set,
16158 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16159 (void *)&cmd_set_mplsoudp_encap_ip_version,
16160 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16161 (void *)&cmd_set_mplsoudp_encap_label,
16162 (void *)&cmd_set_mplsoudp_encap_label_value,
16163 (void *)&cmd_set_mplsoudp_encap_udp_src,
16164 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16165 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16166 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16167 (void *)&cmd_set_mplsoudp_encap_ip_src,
16168 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16169 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16170 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16171 (void *)&cmd_set_mplsoudp_encap_vlan,
16172 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16173 (void *)&cmd_set_mplsoudp_encap_eth_src,
16174 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16175 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16176 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16181 /** Set MPLSoUDP decapsulation details */
16182 struct cmd_set_mplsoudp_decap_result {
16183 cmdline_fixed_string_t set;
16184 cmdline_fixed_string_t mplsoudp;
16185 cmdline_fixed_string_t pos_token;
16186 cmdline_fixed_string_t ip_version;
16187 uint32_t vlan_present:1;
16190 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16191 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16193 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16194 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16196 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16197 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16198 mplsoudp, "mplsoudp_decap-with-vlan");
16199 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16200 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16201 pos_token, "ip-version");
16202 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16203 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16204 ip_version, "ipv4#ipv6");
16206 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16207 __attribute__((unused)) struct cmdline *cl,
16208 __attribute__((unused)) void *data)
16210 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16212 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16213 mplsoudp_decap_conf.select_vlan = 0;
16214 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16215 mplsoudp_decap_conf.select_vlan = 1;
16216 if (strcmp(res->ip_version, "ipv4") == 0)
16217 mplsoudp_decap_conf.select_ipv4 = 1;
16218 else if (strcmp(res->ip_version, "ipv6") == 0)
16219 mplsoudp_decap_conf.select_ipv4 = 0;
16222 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16223 .f = cmd_set_mplsoudp_decap_parsed,
16225 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16227 (void *)&cmd_set_mplsoudp_decap_set,
16228 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16229 (void *)&cmd_set_mplsoudp_decap_ip_version,
16230 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16235 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16236 .f = cmd_set_mplsoudp_decap_parsed,
16238 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16240 (void *)&cmd_set_mplsoudp_decap_set,
16241 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16242 (void *)&cmd_set_mplsoudp_decap_ip_version,
16243 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16248 /* Strict link priority scheduling mode setting */
16250 cmd_strict_link_prio_parsed(
16251 void *parsed_result,
16252 __attribute__((unused)) struct cmdline *cl,
16253 __attribute__((unused)) void *data)
16255 struct cmd_vf_tc_bw_result *res = parsed_result;
16256 int ret = -ENOTSUP;
16258 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16261 #ifdef RTE_LIBRTE_I40E_PMD
16262 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16269 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16272 printf("invalid port_id %d\n", res->port_id);
16275 printf("function not implemented\n");
16278 printf("programming error: (%s)\n", strerror(-ret));
16282 cmdline_parse_inst_t cmd_strict_link_prio = {
16283 .f = cmd_strict_link_prio_parsed,
16285 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16287 (void *)&cmd_vf_tc_bw_set,
16288 (void *)&cmd_vf_tc_bw_tx,
16289 (void *)&cmd_vf_tc_bw_strict_link_prio,
16290 (void *)&cmd_vf_tc_bw_port_id,
16291 (void *)&cmd_vf_tc_bw_tc_map,
16296 /* Load dynamic device personalization*/
16297 struct cmd_ddp_add_result {
16298 cmdline_fixed_string_t ddp;
16299 cmdline_fixed_string_t add;
16304 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16305 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16306 cmdline_parse_token_string_t cmd_ddp_add_add =
16307 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16308 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16309 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16310 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16311 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16314 cmd_ddp_add_parsed(
16315 void *parsed_result,
16316 __attribute__((unused)) struct cmdline *cl,
16317 __attribute__((unused)) void *data)
16319 struct cmd_ddp_add_result *res = parsed_result;
16325 int ret = -ENOTSUP;
16327 if (!all_ports_stopped()) {
16328 printf("Please stop all ports first\n");
16332 filepath = strdup(res->filepath);
16333 if (filepath == NULL) {
16334 printf("Failed to allocate memory\n");
16337 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16339 buff = open_file(file_fld[0], &size);
16341 free((void *)filepath);
16345 #ifdef RTE_LIBRTE_I40E_PMD
16346 if (ret == -ENOTSUP)
16347 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16349 RTE_PMD_I40E_PKG_OP_WR_ADD);
16352 if (ret == -EEXIST)
16353 printf("Profile has already existed.\n");
16355 printf("Failed to load profile.\n");
16356 else if (file_num == 2)
16357 save_file(file_fld[1], buff, size);
16360 free((void *)filepath);
16363 cmdline_parse_inst_t cmd_ddp_add = {
16364 .f = cmd_ddp_add_parsed,
16366 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16368 (void *)&cmd_ddp_add_ddp,
16369 (void *)&cmd_ddp_add_add,
16370 (void *)&cmd_ddp_add_port_id,
16371 (void *)&cmd_ddp_add_filepath,
16376 /* Delete dynamic device personalization*/
16377 struct cmd_ddp_del_result {
16378 cmdline_fixed_string_t ddp;
16379 cmdline_fixed_string_t del;
16384 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16385 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16386 cmdline_parse_token_string_t cmd_ddp_del_del =
16387 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16388 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16389 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16390 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16391 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16394 cmd_ddp_del_parsed(
16395 void *parsed_result,
16396 __attribute__((unused)) struct cmdline *cl,
16397 __attribute__((unused)) void *data)
16399 struct cmd_ddp_del_result *res = parsed_result;
16402 int ret = -ENOTSUP;
16404 if (!all_ports_stopped()) {
16405 printf("Please stop all ports first\n");
16409 buff = open_file(res->filepath, &size);
16413 #ifdef RTE_LIBRTE_I40E_PMD
16414 if (ret == -ENOTSUP)
16415 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16417 RTE_PMD_I40E_PKG_OP_WR_DEL);
16420 if (ret == -EACCES)
16421 printf("Profile does not exist.\n");
16423 printf("Failed to delete profile.\n");
16428 cmdline_parse_inst_t cmd_ddp_del = {
16429 .f = cmd_ddp_del_parsed,
16431 .help_str = "ddp del <port_id> <backup_profile_path>",
16433 (void *)&cmd_ddp_del_ddp,
16434 (void *)&cmd_ddp_del_del,
16435 (void *)&cmd_ddp_del_port_id,
16436 (void *)&cmd_ddp_del_filepath,
16441 /* Get dynamic device personalization profile info */
16442 struct cmd_ddp_info_result {
16443 cmdline_fixed_string_t ddp;
16444 cmdline_fixed_string_t get;
16445 cmdline_fixed_string_t info;
16449 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16450 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16451 cmdline_parse_token_string_t cmd_ddp_info_get =
16452 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16453 cmdline_parse_token_string_t cmd_ddp_info_info =
16454 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16455 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16456 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16459 cmd_ddp_info_parsed(
16460 void *parsed_result,
16461 __attribute__((unused)) struct cmdline *cl,
16462 __attribute__((unused)) void *data)
16464 struct cmd_ddp_info_result *res = parsed_result;
16467 int ret = -ENOTSUP;
16468 #ifdef RTE_LIBRTE_I40E_PMD
16471 uint32_t buff_size = 0;
16472 struct rte_pmd_i40e_profile_info info;
16473 uint32_t dev_num = 0;
16474 struct rte_pmd_i40e_ddp_device_id *devs;
16475 uint32_t proto_num = 0;
16476 struct rte_pmd_i40e_proto_info *proto = NULL;
16477 uint32_t pctype_num = 0;
16478 struct rte_pmd_i40e_ptype_info *pctype;
16479 uint32_t ptype_num = 0;
16480 struct rte_pmd_i40e_ptype_info *ptype;
16485 pkg = open_file(res->filepath, &pkg_size);
16489 #ifdef RTE_LIBRTE_I40E_PMD
16490 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16491 (uint8_t *)&info, sizeof(info),
16492 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16494 printf("Global Track id: 0x%x\n", info.track_id);
16495 printf("Global Version: %d.%d.%d.%d\n",
16496 info.version.major,
16497 info.version.minor,
16498 info.version.update,
16499 info.version.draft);
16500 printf("Global Package name: %s\n\n", info.name);
16503 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16504 (uint8_t *)&info, sizeof(info),
16505 RTE_PMD_I40E_PKG_INFO_HEADER);
16507 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16508 printf("i40e Profile Version: %d.%d.%d.%d\n",
16509 info.version.major,
16510 info.version.minor,
16511 info.version.update,
16512 info.version.draft);
16513 printf("i40e Profile name: %s\n\n", info.name);
16516 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16517 (uint8_t *)&buff_size, sizeof(buff_size),
16518 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16519 if (!ret && buff_size) {
16520 buff = (uint8_t *)malloc(buff_size);
16522 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16524 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16526 printf("Package Notes:\n%s\n\n", buff);
16531 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16532 (uint8_t *)&dev_num, sizeof(dev_num),
16533 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16534 if (!ret && dev_num) {
16535 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16536 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16538 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16539 (uint8_t *)devs, buff_size,
16540 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16542 printf("List of supported devices:\n");
16543 for (i = 0; i < dev_num; i++) {
16544 printf(" %04X:%04X %04X:%04X\n",
16545 devs[i].vendor_dev_id >> 16,
16546 devs[i].vendor_dev_id & 0xFFFF,
16547 devs[i].sub_vendor_dev_id >> 16,
16548 devs[i].sub_vendor_dev_id & 0xFFFF);
16556 /* get information about protocols and packet types */
16557 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16558 (uint8_t *)&proto_num, sizeof(proto_num),
16559 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16560 if (ret || !proto_num)
16561 goto no_print_return;
16563 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16564 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16566 goto no_print_return;
16568 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16570 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16572 printf("List of used protocols:\n");
16573 for (i = 0; i < proto_num; i++)
16574 printf(" %2u: %s\n", proto[i].proto_id,
16578 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16579 (uint8_t *)&pctype_num, sizeof(pctype_num),
16580 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16581 if (ret || !pctype_num)
16582 goto no_print_pctypes;
16584 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16585 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16587 goto no_print_pctypes;
16589 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16591 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16594 goto no_print_pctypes;
16597 printf("List of defined packet classification types:\n");
16598 for (i = 0; i < pctype_num; i++) {
16599 printf(" %2u:", pctype[i].ptype_id);
16600 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16601 proto_id = pctype[i].protocols[j];
16602 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16603 for (n = 0; n < proto_num; n++) {
16604 if (proto[n].proto_id == proto_id) {
16605 printf(" %s", proto[n].name);
16618 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16620 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16621 if (ret || !ptype_num)
16622 goto no_print_return;
16624 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16625 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16627 goto no_print_return;
16629 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16631 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16634 goto no_print_return;
16636 printf("List of defined packet types:\n");
16637 for (i = 0; i < ptype_num; i++) {
16638 printf(" %2u:", ptype[i].ptype_id);
16639 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16640 proto_id = ptype[i].protocols[j];
16641 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16642 for (n = 0; n < proto_num; n++) {
16643 if (proto[n].proto_id == proto_id) {
16644 printf(" %s", proto[n].name);
16660 if (ret == -ENOTSUP)
16661 printf("Function not supported in PMD driver\n");
16665 cmdline_parse_inst_t cmd_ddp_get_info = {
16666 .f = cmd_ddp_info_parsed,
16668 .help_str = "ddp get info <profile_path>",
16670 (void *)&cmd_ddp_info_ddp,
16671 (void *)&cmd_ddp_info_get,
16672 (void *)&cmd_ddp_info_info,
16673 (void *)&cmd_ddp_info_filepath,
16678 /* Get dynamic device personalization profile info list*/
16679 #define PROFILE_INFO_SIZE 48
16680 #define MAX_PROFILE_NUM 16
16682 struct cmd_ddp_get_list_result {
16683 cmdline_fixed_string_t ddp;
16684 cmdline_fixed_string_t get;
16685 cmdline_fixed_string_t list;
16689 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16690 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16691 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16692 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16693 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16694 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16695 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16696 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16699 cmd_ddp_get_list_parsed(
16700 __attribute__((unused)) void *parsed_result,
16701 __attribute__((unused)) struct cmdline *cl,
16702 __attribute__((unused)) void *data)
16704 #ifdef RTE_LIBRTE_I40E_PMD
16705 struct cmd_ddp_get_list_result *res = parsed_result;
16706 struct rte_pmd_i40e_profile_list *p_list;
16707 struct rte_pmd_i40e_profile_info *p_info;
16712 int ret = -ENOTSUP;
16714 #ifdef RTE_LIBRTE_I40E_PMD
16715 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16716 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16718 printf("%s: Failed to malloc buffer\n", __func__);
16720 if (ret == -ENOTSUP)
16721 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16722 (uint8_t *)p_list, size);
16725 p_num = p_list->p_count;
16726 printf("Profile number is: %d\n\n", p_num);
16728 for (i = 0; i < p_num; i++) {
16729 p_info = &p_list->p_info[i];
16730 printf("Profile %d:\n", i);
16731 printf("Track id: 0x%x\n", p_info->track_id);
16732 printf("Version: %d.%d.%d.%d\n",
16733 p_info->version.major,
16734 p_info->version.minor,
16735 p_info->version.update,
16736 p_info->version.draft);
16737 printf("Profile name: %s\n\n", p_info->name);
16745 printf("Failed to get ddp list\n");
16748 cmdline_parse_inst_t cmd_ddp_get_list = {
16749 .f = cmd_ddp_get_list_parsed,
16751 .help_str = "ddp get list <port_id>",
16753 (void *)&cmd_ddp_get_list_ddp,
16754 (void *)&cmd_ddp_get_list_get,
16755 (void *)&cmd_ddp_get_list_list,
16756 (void *)&cmd_ddp_get_list_port_id,
16761 /* Configure input set */
16762 struct cmd_cfg_input_set_result {
16763 cmdline_fixed_string_t port;
16764 cmdline_fixed_string_t cfg;
16766 cmdline_fixed_string_t pctype;
16768 cmdline_fixed_string_t inset_type;
16769 cmdline_fixed_string_t opt;
16770 cmdline_fixed_string_t field;
16775 cmd_cfg_input_set_parsed(
16776 __attribute__((unused)) void *parsed_result,
16777 __attribute__((unused)) struct cmdline *cl,
16778 __attribute__((unused)) void *data)
16780 #ifdef RTE_LIBRTE_I40E_PMD
16781 struct cmd_cfg_input_set_result *res = parsed_result;
16782 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16783 struct rte_pmd_i40e_inset inset;
16785 int ret = -ENOTSUP;
16787 if (!all_ports_stopped()) {
16788 printf("Please stop all ports first\n");
16792 #ifdef RTE_LIBRTE_I40E_PMD
16793 if (!strcmp(res->inset_type, "hash_inset"))
16794 inset_type = INSET_HASH;
16795 else if (!strcmp(res->inset_type, "fdir_inset"))
16796 inset_type = INSET_FDIR;
16797 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16798 inset_type = INSET_FDIR_FLX;
16799 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16800 &inset, inset_type);
16802 printf("Failed to get input set.\n");
16806 if (!strcmp(res->opt, "get")) {
16807 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16810 printf("Field index %d is enabled.\n", res->field_idx);
16812 printf("Field index %d is disabled.\n", res->field_idx);
16814 } else if (!strcmp(res->opt, "set"))
16815 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16817 else if (!strcmp(res->opt, "clear"))
16818 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16821 printf("Failed to configure input set field.\n");
16825 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16826 &inset, inset_type);
16828 printf("Failed to set input set.\n");
16833 if (ret == -ENOTSUP)
16834 printf("Function not supported\n");
16837 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16838 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16840 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16841 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16843 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16844 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16846 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16847 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16849 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16850 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16852 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16853 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16855 "hash_inset#fdir_inset#fdir_flx_inset");
16856 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16857 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16858 opt, "get#set#clear");
16859 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16860 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16862 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16863 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16866 cmdline_parse_inst_t cmd_cfg_input_set = {
16867 .f = cmd_cfg_input_set_parsed,
16869 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16870 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16872 (void *)&cmd_cfg_input_set_port,
16873 (void *)&cmd_cfg_input_set_cfg,
16874 (void *)&cmd_cfg_input_set_port_id,
16875 (void *)&cmd_cfg_input_set_pctype,
16876 (void *)&cmd_cfg_input_set_pctype_id,
16877 (void *)&cmd_cfg_input_set_inset_type,
16878 (void *)&cmd_cfg_input_set_opt,
16879 (void *)&cmd_cfg_input_set_field,
16880 (void *)&cmd_cfg_input_set_field_idx,
16885 /* Clear input set */
16886 struct cmd_clear_input_set_result {
16887 cmdline_fixed_string_t port;
16888 cmdline_fixed_string_t cfg;
16890 cmdline_fixed_string_t pctype;
16892 cmdline_fixed_string_t inset_type;
16893 cmdline_fixed_string_t clear;
16894 cmdline_fixed_string_t all;
16898 cmd_clear_input_set_parsed(
16899 __attribute__((unused)) void *parsed_result,
16900 __attribute__((unused)) struct cmdline *cl,
16901 __attribute__((unused)) void *data)
16903 #ifdef RTE_LIBRTE_I40E_PMD
16904 struct cmd_clear_input_set_result *res = parsed_result;
16905 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16906 struct rte_pmd_i40e_inset inset;
16908 int ret = -ENOTSUP;
16910 if (!all_ports_stopped()) {
16911 printf("Please stop all ports first\n");
16915 #ifdef RTE_LIBRTE_I40E_PMD
16916 if (!strcmp(res->inset_type, "hash_inset"))
16917 inset_type = INSET_HASH;
16918 else if (!strcmp(res->inset_type, "fdir_inset"))
16919 inset_type = INSET_FDIR;
16920 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16921 inset_type = INSET_FDIR_FLX;
16923 memset(&inset, 0, sizeof(inset));
16925 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16926 &inset, inset_type);
16928 printf("Failed to clear input set.\n");
16934 if (ret == -ENOTSUP)
16935 printf("Function not supported\n");
16938 cmdline_parse_token_string_t cmd_clear_input_set_port =
16939 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16941 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
16942 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16944 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
16945 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16947 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
16948 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16950 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
16951 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16953 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
16954 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16956 "hash_inset#fdir_inset#fdir_flx_inset");
16957 cmdline_parse_token_string_t cmd_clear_input_set_clear =
16958 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16960 cmdline_parse_token_string_t cmd_clear_input_set_all =
16961 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16964 cmdline_parse_inst_t cmd_clear_input_set = {
16965 .f = cmd_clear_input_set_parsed,
16967 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16968 "fdir_inset|fdir_flx_inset clear all",
16970 (void *)&cmd_clear_input_set_port,
16971 (void *)&cmd_clear_input_set_cfg,
16972 (void *)&cmd_clear_input_set_port_id,
16973 (void *)&cmd_clear_input_set_pctype,
16974 (void *)&cmd_clear_input_set_pctype_id,
16975 (void *)&cmd_clear_input_set_inset_type,
16976 (void *)&cmd_clear_input_set_clear,
16977 (void *)&cmd_clear_input_set_all,
16982 /* show vf stats */
16984 /* Common result structure for show vf stats */
16985 struct cmd_show_vf_stats_result {
16986 cmdline_fixed_string_t show;
16987 cmdline_fixed_string_t vf;
16988 cmdline_fixed_string_t stats;
16993 /* Common CLI fields show vf stats*/
16994 cmdline_parse_token_string_t cmd_show_vf_stats_show =
16995 TOKEN_STRING_INITIALIZER
16996 (struct cmd_show_vf_stats_result,
16998 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
16999 TOKEN_STRING_INITIALIZER
17000 (struct cmd_show_vf_stats_result,
17002 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
17003 TOKEN_STRING_INITIALIZER
17004 (struct cmd_show_vf_stats_result,
17006 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
17007 TOKEN_NUM_INITIALIZER
17008 (struct cmd_show_vf_stats_result,
17010 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
17011 TOKEN_NUM_INITIALIZER
17012 (struct cmd_show_vf_stats_result,
17016 cmd_show_vf_stats_parsed(
17017 void *parsed_result,
17018 __attribute__((unused)) struct cmdline *cl,
17019 __attribute__((unused)) void *data)
17021 struct cmd_show_vf_stats_result *res = parsed_result;
17022 struct rte_eth_stats stats;
17023 int ret = -ENOTSUP;
17024 static const char *nic_stats_border = "########################";
17026 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17029 memset(&stats, 0, sizeof(stats));
17031 #ifdef RTE_LIBRTE_I40E_PMD
17032 if (ret == -ENOTSUP)
17033 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
17037 #ifdef RTE_LIBRTE_BNXT_PMD
17038 if (ret == -ENOTSUP)
17039 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17048 printf("invalid vf_id %d\n", res->vf_id);
17051 printf("invalid port_id %d\n", res->port_id);
17054 printf("function not implemented\n");
17057 printf("programming error: (%s)\n", strerror(-ret));
17060 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17061 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17063 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17065 stats.ipackets, stats.imissed, stats.ibytes);
17066 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17067 printf(" RX-nombuf: %-10"PRIu64"\n",
17069 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17071 stats.opackets, stats.oerrors, stats.obytes);
17073 printf(" %s############################%s\n",
17074 nic_stats_border, nic_stats_border);
17077 cmdline_parse_inst_t cmd_show_vf_stats = {
17078 .f = cmd_show_vf_stats_parsed,
17080 .help_str = "show vf stats <port_id> <vf_id>",
17082 (void *)&cmd_show_vf_stats_show,
17083 (void *)&cmd_show_vf_stats_vf,
17084 (void *)&cmd_show_vf_stats_stats,
17085 (void *)&cmd_show_vf_stats_port_id,
17086 (void *)&cmd_show_vf_stats_vf_id,
17091 /* clear vf stats */
17093 /* Common result structure for clear vf stats */
17094 struct cmd_clear_vf_stats_result {
17095 cmdline_fixed_string_t clear;
17096 cmdline_fixed_string_t vf;
17097 cmdline_fixed_string_t stats;
17102 /* Common CLI fields clear vf stats*/
17103 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17104 TOKEN_STRING_INITIALIZER
17105 (struct cmd_clear_vf_stats_result,
17107 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17108 TOKEN_STRING_INITIALIZER
17109 (struct cmd_clear_vf_stats_result,
17111 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17112 TOKEN_STRING_INITIALIZER
17113 (struct cmd_clear_vf_stats_result,
17115 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17116 TOKEN_NUM_INITIALIZER
17117 (struct cmd_clear_vf_stats_result,
17119 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17120 TOKEN_NUM_INITIALIZER
17121 (struct cmd_clear_vf_stats_result,
17125 cmd_clear_vf_stats_parsed(
17126 void *parsed_result,
17127 __attribute__((unused)) struct cmdline *cl,
17128 __attribute__((unused)) void *data)
17130 struct cmd_clear_vf_stats_result *res = parsed_result;
17131 int ret = -ENOTSUP;
17133 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17136 #ifdef RTE_LIBRTE_I40E_PMD
17137 if (ret == -ENOTSUP)
17138 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17141 #ifdef RTE_LIBRTE_BNXT_PMD
17142 if (ret == -ENOTSUP)
17143 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17151 printf("invalid vf_id %d\n", res->vf_id);
17154 printf("invalid port_id %d\n", res->port_id);
17157 printf("function not implemented\n");
17160 printf("programming error: (%s)\n", strerror(-ret));
17164 cmdline_parse_inst_t cmd_clear_vf_stats = {
17165 .f = cmd_clear_vf_stats_parsed,
17167 .help_str = "clear vf stats <port_id> <vf_id>",
17169 (void *)&cmd_clear_vf_stats_clear,
17170 (void *)&cmd_clear_vf_stats_vf,
17171 (void *)&cmd_clear_vf_stats_stats,
17172 (void *)&cmd_clear_vf_stats_port_id,
17173 (void *)&cmd_clear_vf_stats_vf_id,
17178 /* port config pctype mapping reset */
17180 /* Common result structure for port config pctype mapping reset */
17181 struct cmd_pctype_mapping_reset_result {
17182 cmdline_fixed_string_t port;
17183 cmdline_fixed_string_t config;
17185 cmdline_fixed_string_t pctype;
17186 cmdline_fixed_string_t mapping;
17187 cmdline_fixed_string_t reset;
17190 /* Common CLI fields for port config pctype mapping reset*/
17191 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17192 TOKEN_STRING_INITIALIZER
17193 (struct cmd_pctype_mapping_reset_result,
17195 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17196 TOKEN_STRING_INITIALIZER
17197 (struct cmd_pctype_mapping_reset_result,
17199 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17200 TOKEN_NUM_INITIALIZER
17201 (struct cmd_pctype_mapping_reset_result,
17203 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17204 TOKEN_STRING_INITIALIZER
17205 (struct cmd_pctype_mapping_reset_result,
17207 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17208 TOKEN_STRING_INITIALIZER
17209 (struct cmd_pctype_mapping_reset_result,
17210 mapping, "mapping");
17211 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17212 TOKEN_STRING_INITIALIZER
17213 (struct cmd_pctype_mapping_reset_result,
17217 cmd_pctype_mapping_reset_parsed(
17218 void *parsed_result,
17219 __attribute__((unused)) struct cmdline *cl,
17220 __attribute__((unused)) void *data)
17222 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17223 int ret = -ENOTSUP;
17225 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17228 #ifdef RTE_LIBRTE_I40E_PMD
17229 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17236 printf("invalid port_id %d\n", res->port_id);
17239 printf("function not implemented\n");
17242 printf("programming error: (%s)\n", strerror(-ret));
17246 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17247 .f = cmd_pctype_mapping_reset_parsed,
17249 .help_str = "port config <port_id> pctype mapping reset",
17251 (void *)&cmd_pctype_mapping_reset_port,
17252 (void *)&cmd_pctype_mapping_reset_config,
17253 (void *)&cmd_pctype_mapping_reset_port_id,
17254 (void *)&cmd_pctype_mapping_reset_pctype,
17255 (void *)&cmd_pctype_mapping_reset_mapping,
17256 (void *)&cmd_pctype_mapping_reset_reset,
17261 /* show port pctype mapping */
17263 /* Common result structure for show port pctype mapping */
17264 struct cmd_pctype_mapping_get_result {
17265 cmdline_fixed_string_t show;
17266 cmdline_fixed_string_t port;
17268 cmdline_fixed_string_t pctype;
17269 cmdline_fixed_string_t mapping;
17272 /* Common CLI fields for pctype mapping get */
17273 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17274 TOKEN_STRING_INITIALIZER
17275 (struct cmd_pctype_mapping_get_result,
17277 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17278 TOKEN_STRING_INITIALIZER
17279 (struct cmd_pctype_mapping_get_result,
17281 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17282 TOKEN_NUM_INITIALIZER
17283 (struct cmd_pctype_mapping_get_result,
17285 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17286 TOKEN_STRING_INITIALIZER
17287 (struct cmd_pctype_mapping_get_result,
17289 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17290 TOKEN_STRING_INITIALIZER
17291 (struct cmd_pctype_mapping_get_result,
17292 mapping, "mapping");
17295 cmd_pctype_mapping_get_parsed(
17296 void *parsed_result,
17297 __attribute__((unused)) struct cmdline *cl,
17298 __attribute__((unused)) void *data)
17300 struct cmd_pctype_mapping_get_result *res = parsed_result;
17301 int ret = -ENOTSUP;
17302 #ifdef RTE_LIBRTE_I40E_PMD
17303 struct rte_pmd_i40e_flow_type_mapping
17304 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17305 int i, j, first_pctype;
17308 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17311 #ifdef RTE_LIBRTE_I40E_PMD
17312 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17319 printf("invalid port_id %d\n", res->port_id);
17322 printf("function not implemented\n");
17325 printf("programming error: (%s)\n", strerror(-ret));
17329 #ifdef RTE_LIBRTE_I40E_PMD
17330 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17331 if (mapping[i].pctype != 0ULL) {
17334 printf("pctype: ");
17335 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17336 if (mapping[i].pctype & (1ULL << j)) {
17337 printf(first_pctype ?
17338 "%02d" : ",%02d", j);
17342 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17348 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17349 .f = cmd_pctype_mapping_get_parsed,
17351 .help_str = "show port <port_id> pctype mapping",
17353 (void *)&cmd_pctype_mapping_get_show,
17354 (void *)&cmd_pctype_mapping_get_port,
17355 (void *)&cmd_pctype_mapping_get_port_id,
17356 (void *)&cmd_pctype_mapping_get_pctype,
17357 (void *)&cmd_pctype_mapping_get_mapping,
17362 /* port config pctype mapping update */
17364 /* Common result structure for port config pctype mapping update */
17365 struct cmd_pctype_mapping_update_result {
17366 cmdline_fixed_string_t port;
17367 cmdline_fixed_string_t config;
17369 cmdline_fixed_string_t pctype;
17370 cmdline_fixed_string_t mapping;
17371 cmdline_fixed_string_t update;
17372 cmdline_fixed_string_t pctype_list;
17373 uint16_t flow_type;
17376 /* Common CLI fields for pctype mapping update*/
17377 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17378 TOKEN_STRING_INITIALIZER
17379 (struct cmd_pctype_mapping_update_result,
17381 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17382 TOKEN_STRING_INITIALIZER
17383 (struct cmd_pctype_mapping_update_result,
17385 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17386 TOKEN_NUM_INITIALIZER
17387 (struct cmd_pctype_mapping_update_result,
17389 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17390 TOKEN_STRING_INITIALIZER
17391 (struct cmd_pctype_mapping_update_result,
17393 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17394 TOKEN_STRING_INITIALIZER
17395 (struct cmd_pctype_mapping_update_result,
17396 mapping, "mapping");
17397 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17398 TOKEN_STRING_INITIALIZER
17399 (struct cmd_pctype_mapping_update_result,
17401 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17402 TOKEN_STRING_INITIALIZER
17403 (struct cmd_pctype_mapping_update_result,
17404 pctype_list, NULL);
17405 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17406 TOKEN_NUM_INITIALIZER
17407 (struct cmd_pctype_mapping_update_result,
17408 flow_type, UINT16);
17411 cmd_pctype_mapping_update_parsed(
17412 void *parsed_result,
17413 __attribute__((unused)) struct cmdline *cl,
17414 __attribute__((unused)) void *data)
17416 struct cmd_pctype_mapping_update_result *res = parsed_result;
17417 int ret = -ENOTSUP;
17418 #ifdef RTE_LIBRTE_I40E_PMD
17419 struct rte_pmd_i40e_flow_type_mapping mapping;
17421 unsigned int nb_item;
17422 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17425 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17428 #ifdef RTE_LIBRTE_I40E_PMD
17429 nb_item = parse_item_list(res->pctype_list, "pctypes",
17430 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17431 mapping.flow_type = res->flow_type;
17432 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17433 mapping.pctype |= (1ULL << pctype_list[i]);
17434 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17444 printf("invalid pctype or flow type\n");
17447 printf("invalid port_id %d\n", res->port_id);
17450 printf("function not implemented\n");
17453 printf("programming error: (%s)\n", strerror(-ret));
17457 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17458 .f = cmd_pctype_mapping_update_parsed,
17460 .help_str = "port config <port_id> pctype mapping update"
17461 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17463 (void *)&cmd_pctype_mapping_update_port,
17464 (void *)&cmd_pctype_mapping_update_config,
17465 (void *)&cmd_pctype_mapping_update_port_id,
17466 (void *)&cmd_pctype_mapping_update_pctype,
17467 (void *)&cmd_pctype_mapping_update_mapping,
17468 (void *)&cmd_pctype_mapping_update_update,
17469 (void *)&cmd_pctype_mapping_update_pc_type,
17470 (void *)&cmd_pctype_mapping_update_flow_type,
17475 /* ptype mapping get */
17477 /* Common result structure for ptype mapping get */
17478 struct cmd_ptype_mapping_get_result {
17479 cmdline_fixed_string_t ptype;
17480 cmdline_fixed_string_t mapping;
17481 cmdline_fixed_string_t get;
17483 uint8_t valid_only;
17486 /* Common CLI fields for ptype mapping get */
17487 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17488 TOKEN_STRING_INITIALIZER
17489 (struct cmd_ptype_mapping_get_result,
17491 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17492 TOKEN_STRING_INITIALIZER
17493 (struct cmd_ptype_mapping_get_result,
17494 mapping, "mapping");
17495 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17496 TOKEN_STRING_INITIALIZER
17497 (struct cmd_ptype_mapping_get_result,
17499 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17500 TOKEN_NUM_INITIALIZER
17501 (struct cmd_ptype_mapping_get_result,
17503 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17504 TOKEN_NUM_INITIALIZER
17505 (struct cmd_ptype_mapping_get_result,
17506 valid_only, UINT8);
17509 cmd_ptype_mapping_get_parsed(
17510 void *parsed_result,
17511 __attribute__((unused)) struct cmdline *cl,
17512 __attribute__((unused)) void *data)
17514 struct cmd_ptype_mapping_get_result *res = parsed_result;
17515 int ret = -ENOTSUP;
17516 #ifdef RTE_LIBRTE_I40E_PMD
17517 int max_ptype_num = 256;
17518 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17523 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17526 #ifdef RTE_LIBRTE_I40E_PMD
17527 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17538 printf("invalid port_id %d\n", res->port_id);
17541 printf("function not implemented\n");
17544 printf("programming error: (%s)\n", strerror(-ret));
17547 #ifdef RTE_LIBRTE_I40E_PMD
17549 for (i = 0; i < count; i++)
17550 printf("%3d\t0x%08x\n",
17551 mapping[i].hw_ptype, mapping[i].sw_ptype);
17556 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17557 .f = cmd_ptype_mapping_get_parsed,
17559 .help_str = "ptype mapping get <port_id> <valid_only>",
17561 (void *)&cmd_ptype_mapping_get_ptype,
17562 (void *)&cmd_ptype_mapping_get_mapping,
17563 (void *)&cmd_ptype_mapping_get_get,
17564 (void *)&cmd_ptype_mapping_get_port_id,
17565 (void *)&cmd_ptype_mapping_get_valid_only,
17570 /* ptype mapping replace */
17572 /* Common result structure for ptype mapping replace */
17573 struct cmd_ptype_mapping_replace_result {
17574 cmdline_fixed_string_t ptype;
17575 cmdline_fixed_string_t mapping;
17576 cmdline_fixed_string_t replace;
17583 /* Common CLI fields for ptype mapping replace */
17584 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17585 TOKEN_STRING_INITIALIZER
17586 (struct cmd_ptype_mapping_replace_result,
17588 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17589 TOKEN_STRING_INITIALIZER
17590 (struct cmd_ptype_mapping_replace_result,
17591 mapping, "mapping");
17592 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17593 TOKEN_STRING_INITIALIZER
17594 (struct cmd_ptype_mapping_replace_result,
17595 replace, "replace");
17596 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17597 TOKEN_NUM_INITIALIZER
17598 (struct cmd_ptype_mapping_replace_result,
17600 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17601 TOKEN_NUM_INITIALIZER
17602 (struct cmd_ptype_mapping_replace_result,
17604 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17605 TOKEN_NUM_INITIALIZER
17606 (struct cmd_ptype_mapping_replace_result,
17608 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17609 TOKEN_NUM_INITIALIZER
17610 (struct cmd_ptype_mapping_replace_result,
17614 cmd_ptype_mapping_replace_parsed(
17615 void *parsed_result,
17616 __attribute__((unused)) struct cmdline *cl,
17617 __attribute__((unused)) void *data)
17619 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17620 int ret = -ENOTSUP;
17622 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17625 #ifdef RTE_LIBRTE_I40E_PMD
17626 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17636 printf("invalid ptype 0x%8x or 0x%8x\n",
17637 res->target, res->pkt_type);
17640 printf("invalid port_id %d\n", res->port_id);
17643 printf("function not implemented\n");
17646 printf("programming error: (%s)\n", strerror(-ret));
17650 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17651 .f = cmd_ptype_mapping_replace_parsed,
17654 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17656 (void *)&cmd_ptype_mapping_replace_ptype,
17657 (void *)&cmd_ptype_mapping_replace_mapping,
17658 (void *)&cmd_ptype_mapping_replace_replace,
17659 (void *)&cmd_ptype_mapping_replace_port_id,
17660 (void *)&cmd_ptype_mapping_replace_target,
17661 (void *)&cmd_ptype_mapping_replace_mask,
17662 (void *)&cmd_ptype_mapping_replace_pkt_type,
17667 /* ptype mapping reset */
17669 /* Common result structure for ptype mapping reset */
17670 struct cmd_ptype_mapping_reset_result {
17671 cmdline_fixed_string_t ptype;
17672 cmdline_fixed_string_t mapping;
17673 cmdline_fixed_string_t reset;
17677 /* Common CLI fields for ptype mapping reset*/
17678 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17679 TOKEN_STRING_INITIALIZER
17680 (struct cmd_ptype_mapping_reset_result,
17682 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17683 TOKEN_STRING_INITIALIZER
17684 (struct cmd_ptype_mapping_reset_result,
17685 mapping, "mapping");
17686 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17687 TOKEN_STRING_INITIALIZER
17688 (struct cmd_ptype_mapping_reset_result,
17690 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17691 TOKEN_NUM_INITIALIZER
17692 (struct cmd_ptype_mapping_reset_result,
17696 cmd_ptype_mapping_reset_parsed(
17697 void *parsed_result,
17698 __attribute__((unused)) struct cmdline *cl,
17699 __attribute__((unused)) void *data)
17701 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17702 int ret = -ENOTSUP;
17704 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17707 #ifdef RTE_LIBRTE_I40E_PMD
17708 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17715 printf("invalid port_id %d\n", res->port_id);
17718 printf("function not implemented\n");
17721 printf("programming error: (%s)\n", strerror(-ret));
17725 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17726 .f = cmd_ptype_mapping_reset_parsed,
17728 .help_str = "ptype mapping reset <port_id>",
17730 (void *)&cmd_ptype_mapping_reset_ptype,
17731 (void *)&cmd_ptype_mapping_reset_mapping,
17732 (void *)&cmd_ptype_mapping_reset_reset,
17733 (void *)&cmd_ptype_mapping_reset_port_id,
17738 /* ptype mapping update */
17740 /* Common result structure for ptype mapping update */
17741 struct cmd_ptype_mapping_update_result {
17742 cmdline_fixed_string_t ptype;
17743 cmdline_fixed_string_t mapping;
17744 cmdline_fixed_string_t reset;
17750 /* Common CLI fields for ptype mapping update*/
17751 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17752 TOKEN_STRING_INITIALIZER
17753 (struct cmd_ptype_mapping_update_result,
17755 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17756 TOKEN_STRING_INITIALIZER
17757 (struct cmd_ptype_mapping_update_result,
17758 mapping, "mapping");
17759 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17760 TOKEN_STRING_INITIALIZER
17761 (struct cmd_ptype_mapping_update_result,
17763 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17764 TOKEN_NUM_INITIALIZER
17765 (struct cmd_ptype_mapping_update_result,
17767 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17768 TOKEN_NUM_INITIALIZER
17769 (struct cmd_ptype_mapping_update_result,
17771 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17772 TOKEN_NUM_INITIALIZER
17773 (struct cmd_ptype_mapping_update_result,
17777 cmd_ptype_mapping_update_parsed(
17778 void *parsed_result,
17779 __attribute__((unused)) struct cmdline *cl,
17780 __attribute__((unused)) void *data)
17782 struct cmd_ptype_mapping_update_result *res = parsed_result;
17783 int ret = -ENOTSUP;
17784 #ifdef RTE_LIBRTE_I40E_PMD
17785 struct rte_pmd_i40e_ptype_mapping mapping;
17787 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17790 #ifdef RTE_LIBRTE_I40E_PMD
17791 mapping.hw_ptype = res->hw_ptype;
17792 mapping.sw_ptype = res->sw_ptype;
17793 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17803 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17806 printf("invalid port_id %d\n", res->port_id);
17809 printf("function not implemented\n");
17812 printf("programming error: (%s)\n", strerror(-ret));
17816 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17817 .f = cmd_ptype_mapping_update_parsed,
17819 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17821 (void *)&cmd_ptype_mapping_update_ptype,
17822 (void *)&cmd_ptype_mapping_update_mapping,
17823 (void *)&cmd_ptype_mapping_update_update,
17824 (void *)&cmd_ptype_mapping_update_port_id,
17825 (void *)&cmd_ptype_mapping_update_hw_ptype,
17826 (void *)&cmd_ptype_mapping_update_sw_ptype,
17831 /* Common result structure for file commands */
17832 struct cmd_cmdfile_result {
17833 cmdline_fixed_string_t load;
17834 cmdline_fixed_string_t filename;
17837 /* Common CLI fields for file commands */
17838 cmdline_parse_token_string_t cmd_load_cmdfile =
17839 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17840 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17841 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17844 cmd_load_from_file_parsed(
17845 void *parsed_result,
17846 __attribute__((unused)) struct cmdline *cl,
17847 __attribute__((unused)) void *data)
17849 struct cmd_cmdfile_result *res = parsed_result;
17851 cmdline_read_from_file(res->filename);
17854 cmdline_parse_inst_t cmd_load_from_file = {
17855 .f = cmd_load_from_file_parsed,
17857 .help_str = "load <filename>",
17859 (void *)&cmd_load_cmdfile,
17860 (void *)&cmd_load_cmdfile_filename,
17865 /* Get Rx offloads capabilities */
17866 struct cmd_rx_offload_get_capa_result {
17867 cmdline_fixed_string_t show;
17868 cmdline_fixed_string_t port;
17870 cmdline_fixed_string_t rx_offload;
17871 cmdline_fixed_string_t capabilities;
17874 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17875 TOKEN_STRING_INITIALIZER
17876 (struct cmd_rx_offload_get_capa_result,
17878 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17879 TOKEN_STRING_INITIALIZER
17880 (struct cmd_rx_offload_get_capa_result,
17882 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17883 TOKEN_NUM_INITIALIZER
17884 (struct cmd_rx_offload_get_capa_result,
17886 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17887 TOKEN_STRING_INITIALIZER
17888 (struct cmd_rx_offload_get_capa_result,
17889 rx_offload, "rx_offload");
17890 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17891 TOKEN_STRING_INITIALIZER
17892 (struct cmd_rx_offload_get_capa_result,
17893 capabilities, "capabilities");
17896 print_rx_offloads(uint64_t offloads)
17898 uint64_t single_offload;
17906 begin = __builtin_ctzll(offloads);
17907 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17909 single_offload = 1ULL << begin;
17910 for (bit = begin; bit < end; bit++) {
17911 if (offloads & single_offload)
17913 rte_eth_dev_rx_offload_name(single_offload));
17914 single_offload <<= 1;
17919 cmd_rx_offload_get_capa_parsed(
17920 void *parsed_result,
17921 __attribute__((unused)) struct cmdline *cl,
17922 __attribute__((unused)) void *data)
17924 struct cmd_rx_offload_get_capa_result *res = parsed_result;
17925 struct rte_eth_dev_info dev_info;
17926 portid_t port_id = res->port_id;
17927 uint64_t queue_offloads;
17928 uint64_t port_offloads;
17931 ret = eth_dev_info_get_print_err(port_id, &dev_info);
17935 queue_offloads = dev_info.rx_queue_offload_capa;
17936 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
17938 printf("Rx Offloading Capabilities of port %d :\n", port_id);
17939 printf(" Per Queue :");
17940 print_rx_offloads(queue_offloads);
17943 printf(" Per Port :");
17944 print_rx_offloads(port_offloads);
17948 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
17949 .f = cmd_rx_offload_get_capa_parsed,
17951 .help_str = "show port <port_id> rx_offload capabilities",
17953 (void *)&cmd_rx_offload_get_capa_show,
17954 (void *)&cmd_rx_offload_get_capa_port,
17955 (void *)&cmd_rx_offload_get_capa_port_id,
17956 (void *)&cmd_rx_offload_get_capa_rx_offload,
17957 (void *)&cmd_rx_offload_get_capa_capabilities,
17962 /* Get Rx offloads configuration */
17963 struct cmd_rx_offload_get_configuration_result {
17964 cmdline_fixed_string_t show;
17965 cmdline_fixed_string_t port;
17967 cmdline_fixed_string_t rx_offload;
17968 cmdline_fixed_string_t configuration;
17971 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
17972 TOKEN_STRING_INITIALIZER
17973 (struct cmd_rx_offload_get_configuration_result,
17975 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
17976 TOKEN_STRING_INITIALIZER
17977 (struct cmd_rx_offload_get_configuration_result,
17979 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
17980 TOKEN_NUM_INITIALIZER
17981 (struct cmd_rx_offload_get_configuration_result,
17983 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
17984 TOKEN_STRING_INITIALIZER
17985 (struct cmd_rx_offload_get_configuration_result,
17986 rx_offload, "rx_offload");
17987 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
17988 TOKEN_STRING_INITIALIZER
17989 (struct cmd_rx_offload_get_configuration_result,
17990 configuration, "configuration");
17993 cmd_rx_offload_get_configuration_parsed(
17994 void *parsed_result,
17995 __attribute__((unused)) struct cmdline *cl,
17996 __attribute__((unused)) void *data)
17998 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
17999 struct rte_eth_dev_info dev_info;
18000 portid_t port_id = res->port_id;
18001 struct rte_port *port = &ports[port_id];
18002 uint64_t port_offloads;
18003 uint64_t queue_offloads;
18004 uint16_t nb_rx_queues;
18008 printf("Rx Offloading Configuration of port %d :\n", port_id);
18010 port_offloads = port->dev_conf.rxmode.offloads;
18012 print_rx_offloads(port_offloads);
18015 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18019 nb_rx_queues = dev_info.nb_rx_queues;
18020 for (q = 0; q < nb_rx_queues; q++) {
18021 queue_offloads = port->rx_conf[q].offloads;
18022 printf(" Queue[%2d] :", q);
18023 print_rx_offloads(queue_offloads);
18029 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
18030 .f = cmd_rx_offload_get_configuration_parsed,
18032 .help_str = "show port <port_id> rx_offload configuration",
18034 (void *)&cmd_rx_offload_get_configuration_show,
18035 (void *)&cmd_rx_offload_get_configuration_port,
18036 (void *)&cmd_rx_offload_get_configuration_port_id,
18037 (void *)&cmd_rx_offload_get_configuration_rx_offload,
18038 (void *)&cmd_rx_offload_get_configuration_configuration,
18043 /* Enable/Disable a per port offloading */
18044 struct cmd_config_per_port_rx_offload_result {
18045 cmdline_fixed_string_t port;
18046 cmdline_fixed_string_t config;
18048 cmdline_fixed_string_t rx_offload;
18049 cmdline_fixed_string_t offload;
18050 cmdline_fixed_string_t on_off;
18053 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
18054 TOKEN_STRING_INITIALIZER
18055 (struct cmd_config_per_port_rx_offload_result,
18057 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18058 TOKEN_STRING_INITIALIZER
18059 (struct cmd_config_per_port_rx_offload_result,
18061 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18062 TOKEN_NUM_INITIALIZER
18063 (struct cmd_config_per_port_rx_offload_result,
18065 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18066 TOKEN_STRING_INITIALIZER
18067 (struct cmd_config_per_port_rx_offload_result,
18068 rx_offload, "rx_offload");
18069 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18070 TOKEN_STRING_INITIALIZER
18071 (struct cmd_config_per_port_rx_offload_result,
18072 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18073 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18074 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18075 "crc_strip#scatter#timestamp#security#keep_crc");
18076 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18077 TOKEN_STRING_INITIALIZER
18078 (struct cmd_config_per_port_rx_offload_result,
18082 search_rx_offload(const char *name)
18084 uint64_t single_offload;
18085 const char *single_name;
18089 single_offload = 1;
18090 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18091 single_name = rte_eth_dev_rx_offload_name(single_offload);
18092 if (!strcasecmp(single_name, name)) {
18096 single_offload <<= 1;
18100 return single_offload;
18106 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18107 __attribute__((unused)) struct cmdline *cl,
18108 __attribute__((unused)) void *data)
18110 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18111 portid_t port_id = res->port_id;
18112 struct rte_eth_dev_info dev_info;
18113 struct rte_port *port = &ports[port_id];
18114 uint64_t single_offload;
18115 uint16_t nb_rx_queues;
18119 if (port->port_status != RTE_PORT_STOPPED) {
18120 printf("Error: Can't config offload when Port %d "
18121 "is not stopped\n", port_id);
18125 single_offload = search_rx_offload(res->offload);
18126 if (single_offload == 0) {
18127 printf("Unknown offload name: %s\n", res->offload);
18131 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18135 nb_rx_queues = dev_info.nb_rx_queues;
18136 if (!strcmp(res->on_off, "on")) {
18137 port->dev_conf.rxmode.offloads |= single_offload;
18138 for (q = 0; q < nb_rx_queues; q++)
18139 port->rx_conf[q].offloads |= single_offload;
18141 port->dev_conf.rxmode.offloads &= ~single_offload;
18142 for (q = 0; q < nb_rx_queues; q++)
18143 port->rx_conf[q].offloads &= ~single_offload;
18146 cmd_reconfig_device_queue(port_id, 1, 1);
18149 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18150 .f = cmd_config_per_port_rx_offload_parsed,
18152 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18153 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18154 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18155 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
18158 (void *)&cmd_config_per_port_rx_offload_result_port,
18159 (void *)&cmd_config_per_port_rx_offload_result_config,
18160 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18161 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18162 (void *)&cmd_config_per_port_rx_offload_result_offload,
18163 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18168 /* Enable/Disable a per queue offloading */
18169 struct cmd_config_per_queue_rx_offload_result {
18170 cmdline_fixed_string_t port;
18172 cmdline_fixed_string_t rxq;
18174 cmdline_fixed_string_t rx_offload;
18175 cmdline_fixed_string_t offload;
18176 cmdline_fixed_string_t on_off;
18179 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18180 TOKEN_STRING_INITIALIZER
18181 (struct cmd_config_per_queue_rx_offload_result,
18183 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18184 TOKEN_NUM_INITIALIZER
18185 (struct cmd_config_per_queue_rx_offload_result,
18187 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18188 TOKEN_STRING_INITIALIZER
18189 (struct cmd_config_per_queue_rx_offload_result,
18191 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18192 TOKEN_NUM_INITIALIZER
18193 (struct cmd_config_per_queue_rx_offload_result,
18195 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18196 TOKEN_STRING_INITIALIZER
18197 (struct cmd_config_per_queue_rx_offload_result,
18198 rx_offload, "rx_offload");
18199 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18200 TOKEN_STRING_INITIALIZER
18201 (struct cmd_config_per_queue_rx_offload_result,
18202 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18203 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18204 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18205 "crc_strip#scatter#timestamp#security#keep_crc");
18206 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18207 TOKEN_STRING_INITIALIZER
18208 (struct cmd_config_per_queue_rx_offload_result,
18212 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18213 __attribute__((unused)) struct cmdline *cl,
18214 __attribute__((unused)) void *data)
18216 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18217 struct rte_eth_dev_info dev_info;
18218 portid_t port_id = res->port_id;
18219 uint16_t queue_id = res->queue_id;
18220 struct rte_port *port = &ports[port_id];
18221 uint64_t single_offload;
18224 if (port->port_status != RTE_PORT_STOPPED) {
18225 printf("Error: Can't config offload when Port %d "
18226 "is not stopped\n", port_id);
18230 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18234 if (queue_id >= dev_info.nb_rx_queues) {
18235 printf("Error: input queue_id should be 0 ... "
18236 "%d\n", dev_info.nb_rx_queues - 1);
18240 single_offload = search_rx_offload(res->offload);
18241 if (single_offload == 0) {
18242 printf("Unknown offload name: %s\n", res->offload);
18246 if (!strcmp(res->on_off, "on"))
18247 port->rx_conf[queue_id].offloads |= single_offload;
18249 port->rx_conf[queue_id].offloads &= ~single_offload;
18251 cmd_reconfig_device_queue(port_id, 1, 1);
18254 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18255 .f = cmd_config_per_queue_rx_offload_parsed,
18257 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18258 "vlan_strip|ipv4_cksum|"
18259 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18260 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18261 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
18264 (void *)&cmd_config_per_queue_rx_offload_result_port,
18265 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18266 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18267 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18268 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18269 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18270 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18275 /* Get Tx offloads capabilities */
18276 struct cmd_tx_offload_get_capa_result {
18277 cmdline_fixed_string_t show;
18278 cmdline_fixed_string_t port;
18280 cmdline_fixed_string_t tx_offload;
18281 cmdline_fixed_string_t capabilities;
18284 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18285 TOKEN_STRING_INITIALIZER
18286 (struct cmd_tx_offload_get_capa_result,
18288 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18289 TOKEN_STRING_INITIALIZER
18290 (struct cmd_tx_offload_get_capa_result,
18292 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18293 TOKEN_NUM_INITIALIZER
18294 (struct cmd_tx_offload_get_capa_result,
18296 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18297 TOKEN_STRING_INITIALIZER
18298 (struct cmd_tx_offload_get_capa_result,
18299 tx_offload, "tx_offload");
18300 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18301 TOKEN_STRING_INITIALIZER
18302 (struct cmd_tx_offload_get_capa_result,
18303 capabilities, "capabilities");
18306 print_tx_offloads(uint64_t offloads)
18308 uint64_t single_offload;
18316 begin = __builtin_ctzll(offloads);
18317 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18319 single_offload = 1ULL << begin;
18320 for (bit = begin; bit < end; bit++) {
18321 if (offloads & single_offload)
18323 rte_eth_dev_tx_offload_name(single_offload));
18324 single_offload <<= 1;
18329 cmd_tx_offload_get_capa_parsed(
18330 void *parsed_result,
18331 __attribute__((unused)) struct cmdline *cl,
18332 __attribute__((unused)) void *data)
18334 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18335 struct rte_eth_dev_info dev_info;
18336 portid_t port_id = res->port_id;
18337 uint64_t queue_offloads;
18338 uint64_t port_offloads;
18341 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18345 queue_offloads = dev_info.tx_queue_offload_capa;
18346 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18348 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18349 printf(" Per Queue :");
18350 print_tx_offloads(queue_offloads);
18353 printf(" Per Port :");
18354 print_tx_offloads(port_offloads);
18358 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18359 .f = cmd_tx_offload_get_capa_parsed,
18361 .help_str = "show port <port_id> tx_offload capabilities",
18363 (void *)&cmd_tx_offload_get_capa_show,
18364 (void *)&cmd_tx_offload_get_capa_port,
18365 (void *)&cmd_tx_offload_get_capa_port_id,
18366 (void *)&cmd_tx_offload_get_capa_tx_offload,
18367 (void *)&cmd_tx_offload_get_capa_capabilities,
18372 /* Get Tx offloads configuration */
18373 struct cmd_tx_offload_get_configuration_result {
18374 cmdline_fixed_string_t show;
18375 cmdline_fixed_string_t port;
18377 cmdline_fixed_string_t tx_offload;
18378 cmdline_fixed_string_t configuration;
18381 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18382 TOKEN_STRING_INITIALIZER
18383 (struct cmd_tx_offload_get_configuration_result,
18385 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18386 TOKEN_STRING_INITIALIZER
18387 (struct cmd_tx_offload_get_configuration_result,
18389 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18390 TOKEN_NUM_INITIALIZER
18391 (struct cmd_tx_offload_get_configuration_result,
18393 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18394 TOKEN_STRING_INITIALIZER
18395 (struct cmd_tx_offload_get_configuration_result,
18396 tx_offload, "tx_offload");
18397 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18398 TOKEN_STRING_INITIALIZER
18399 (struct cmd_tx_offload_get_configuration_result,
18400 configuration, "configuration");
18403 cmd_tx_offload_get_configuration_parsed(
18404 void *parsed_result,
18405 __attribute__((unused)) struct cmdline *cl,
18406 __attribute__((unused)) void *data)
18408 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18409 struct rte_eth_dev_info dev_info;
18410 portid_t port_id = res->port_id;
18411 struct rte_port *port = &ports[port_id];
18412 uint64_t port_offloads;
18413 uint64_t queue_offloads;
18414 uint16_t nb_tx_queues;
18418 printf("Tx Offloading Configuration of port %d :\n", port_id);
18420 port_offloads = port->dev_conf.txmode.offloads;
18422 print_tx_offloads(port_offloads);
18425 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18429 nb_tx_queues = dev_info.nb_tx_queues;
18430 for (q = 0; q < nb_tx_queues; q++) {
18431 queue_offloads = port->tx_conf[q].offloads;
18432 printf(" Queue[%2d] :", q);
18433 print_tx_offloads(queue_offloads);
18439 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18440 .f = cmd_tx_offload_get_configuration_parsed,
18442 .help_str = "show port <port_id> tx_offload configuration",
18444 (void *)&cmd_tx_offload_get_configuration_show,
18445 (void *)&cmd_tx_offload_get_configuration_port,
18446 (void *)&cmd_tx_offload_get_configuration_port_id,
18447 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18448 (void *)&cmd_tx_offload_get_configuration_configuration,
18453 /* Enable/Disable a per port offloading */
18454 struct cmd_config_per_port_tx_offload_result {
18455 cmdline_fixed_string_t port;
18456 cmdline_fixed_string_t config;
18458 cmdline_fixed_string_t tx_offload;
18459 cmdline_fixed_string_t offload;
18460 cmdline_fixed_string_t on_off;
18463 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18464 TOKEN_STRING_INITIALIZER
18465 (struct cmd_config_per_port_tx_offload_result,
18467 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18468 TOKEN_STRING_INITIALIZER
18469 (struct cmd_config_per_port_tx_offload_result,
18471 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18472 TOKEN_NUM_INITIALIZER
18473 (struct cmd_config_per_port_tx_offload_result,
18475 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18476 TOKEN_STRING_INITIALIZER
18477 (struct cmd_config_per_port_tx_offload_result,
18478 tx_offload, "tx_offload");
18479 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18480 TOKEN_STRING_INITIALIZER
18481 (struct cmd_config_per_port_tx_offload_result,
18482 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18483 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18484 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18485 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18486 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18488 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18489 TOKEN_STRING_INITIALIZER
18490 (struct cmd_config_per_port_tx_offload_result,
18494 search_tx_offload(const char *name)
18496 uint64_t single_offload;
18497 const char *single_name;
18501 single_offload = 1;
18502 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18503 single_name = rte_eth_dev_tx_offload_name(single_offload);
18504 if (single_name == NULL)
18506 if (!strcasecmp(single_name, name)) {
18509 } else if (!strcasecmp(single_name, "UNKNOWN"))
18511 single_offload <<= 1;
18515 return single_offload;
18521 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18522 __attribute__((unused)) struct cmdline *cl,
18523 __attribute__((unused)) void *data)
18525 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18526 portid_t port_id = res->port_id;
18527 struct rte_eth_dev_info dev_info;
18528 struct rte_port *port = &ports[port_id];
18529 uint64_t single_offload;
18530 uint16_t nb_tx_queues;
18534 if (port->port_status != RTE_PORT_STOPPED) {
18535 printf("Error: Can't config offload when Port %d "
18536 "is not stopped\n", port_id);
18540 single_offload = search_tx_offload(res->offload);
18541 if (single_offload == 0) {
18542 printf("Unknown offload name: %s\n", res->offload);
18546 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18550 nb_tx_queues = dev_info.nb_tx_queues;
18551 if (!strcmp(res->on_off, "on")) {
18552 port->dev_conf.txmode.offloads |= single_offload;
18553 for (q = 0; q < nb_tx_queues; q++)
18554 port->tx_conf[q].offloads |= single_offload;
18556 port->dev_conf.txmode.offloads &= ~single_offload;
18557 for (q = 0; q < nb_tx_queues; q++)
18558 port->tx_conf[q].offloads &= ~single_offload;
18561 cmd_reconfig_device_queue(port_id, 1, 1);
18564 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18565 .f = cmd_config_per_port_tx_offload_parsed,
18567 .help_str = "port config <port_id> tx_offload "
18568 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18569 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18570 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18571 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18572 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18573 "match_metadata on|off",
18575 (void *)&cmd_config_per_port_tx_offload_result_port,
18576 (void *)&cmd_config_per_port_tx_offload_result_config,
18577 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18578 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18579 (void *)&cmd_config_per_port_tx_offload_result_offload,
18580 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18585 /* Enable/Disable a per queue offloading */
18586 struct cmd_config_per_queue_tx_offload_result {
18587 cmdline_fixed_string_t port;
18589 cmdline_fixed_string_t txq;
18591 cmdline_fixed_string_t tx_offload;
18592 cmdline_fixed_string_t offload;
18593 cmdline_fixed_string_t on_off;
18596 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18597 TOKEN_STRING_INITIALIZER
18598 (struct cmd_config_per_queue_tx_offload_result,
18600 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18601 TOKEN_NUM_INITIALIZER
18602 (struct cmd_config_per_queue_tx_offload_result,
18604 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18605 TOKEN_STRING_INITIALIZER
18606 (struct cmd_config_per_queue_tx_offload_result,
18608 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18609 TOKEN_NUM_INITIALIZER
18610 (struct cmd_config_per_queue_tx_offload_result,
18612 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18613 TOKEN_STRING_INITIALIZER
18614 (struct cmd_config_per_queue_tx_offload_result,
18615 tx_offload, "tx_offload");
18616 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18617 TOKEN_STRING_INITIALIZER
18618 (struct cmd_config_per_queue_tx_offload_result,
18619 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18620 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18621 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18622 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18623 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18624 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18625 TOKEN_STRING_INITIALIZER
18626 (struct cmd_config_per_queue_tx_offload_result,
18630 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18631 __attribute__((unused)) struct cmdline *cl,
18632 __attribute__((unused)) void *data)
18634 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18635 struct rte_eth_dev_info dev_info;
18636 portid_t port_id = res->port_id;
18637 uint16_t queue_id = res->queue_id;
18638 struct rte_port *port = &ports[port_id];
18639 uint64_t single_offload;
18642 if (port->port_status != RTE_PORT_STOPPED) {
18643 printf("Error: Can't config offload when Port %d "
18644 "is not stopped\n", port_id);
18648 ret = eth_dev_info_get_print_err(port_id, &dev_info);
18652 if (queue_id >= dev_info.nb_tx_queues) {
18653 printf("Error: input queue_id should be 0 ... "
18654 "%d\n", dev_info.nb_tx_queues - 1);
18658 single_offload = search_tx_offload(res->offload);
18659 if (single_offload == 0) {
18660 printf("Unknown offload name: %s\n", res->offload);
18664 if (!strcmp(res->on_off, "on"))
18665 port->tx_conf[queue_id].offloads |= single_offload;
18667 port->tx_conf[queue_id].offloads &= ~single_offload;
18669 cmd_reconfig_device_queue(port_id, 1, 1);
18672 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18673 .f = cmd_config_per_queue_tx_offload_parsed,
18675 .help_str = "port <port_id> txq <queue_id> tx_offload "
18676 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18677 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18678 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18679 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18680 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18683 (void *)&cmd_config_per_queue_tx_offload_result_port,
18684 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18685 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18686 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18687 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18688 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18689 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18694 /* *** configure tx_metadata for specific port *** */
18695 struct cmd_config_tx_metadata_specific_result {
18696 cmdline_fixed_string_t port;
18697 cmdline_fixed_string_t keyword;
18699 cmdline_fixed_string_t item;
18704 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18705 __attribute__((unused)) struct cmdline *cl,
18706 __attribute__((unused)) void *data)
18708 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18710 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18712 ports[res->port_id].tx_metadata = rte_cpu_to_be_32(res->value);
18713 /* Add/remove callback to insert valid metadata in every Tx packet. */
18714 if (ports[res->port_id].tx_metadata)
18715 add_tx_md_callback(res->port_id);
18717 remove_tx_md_callback(res->port_id);
18720 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18721 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18723 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18724 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18725 keyword, "config");
18726 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18727 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18729 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18730 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18731 item, "tx_metadata");
18732 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18733 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18736 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18737 .f = cmd_config_tx_metadata_specific_parsed,
18739 .help_str = "port config <port_id> tx_metadata <value>",
18741 (void *)&cmd_config_tx_metadata_specific_port,
18742 (void *)&cmd_config_tx_metadata_specific_keyword,
18743 (void *)&cmd_config_tx_metadata_specific_id,
18744 (void *)&cmd_config_tx_metadata_specific_item,
18745 (void *)&cmd_config_tx_metadata_specific_value,
18750 /* *** display tx_metadata per port configuration *** */
18751 struct cmd_show_tx_metadata_result {
18752 cmdline_fixed_string_t cmd_show;
18753 cmdline_fixed_string_t cmd_port;
18754 cmdline_fixed_string_t cmd_keyword;
18759 cmd_show_tx_metadata_parsed(void *parsed_result,
18760 __attribute__((unused)) struct cmdline *cl,
18761 __attribute__((unused)) void *data)
18763 struct cmd_show_tx_metadata_result *res = parsed_result;
18765 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18766 printf("invalid port id %u\n", res->cmd_pid);
18769 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18770 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18771 rte_be_to_cpu_32(ports[res->cmd_pid].tx_metadata));
18775 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18776 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18778 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18779 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18781 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18782 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18784 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18785 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18786 cmd_keyword, "tx_metadata");
18788 cmdline_parse_inst_t cmd_show_tx_metadata = {
18789 .f = cmd_show_tx_metadata_parsed,
18791 .help_str = "show port <port_id> tx_metadata",
18793 (void *)&cmd_show_tx_metadata_show,
18794 (void *)&cmd_show_tx_metadata_port,
18795 (void *)&cmd_show_tx_metadata_pid,
18796 (void *)&cmd_show_tx_metadata_keyword,
18801 /* ******************************************************************************** */
18803 /* list of instructions */
18804 cmdline_parse_ctx_t main_ctx[] = {
18805 (cmdline_parse_inst_t *)&cmd_help_brief,
18806 (cmdline_parse_inst_t *)&cmd_help_long,
18807 (cmdline_parse_inst_t *)&cmd_quit,
18808 (cmdline_parse_inst_t *)&cmd_load_from_file,
18809 (cmdline_parse_inst_t *)&cmd_showport,
18810 (cmdline_parse_inst_t *)&cmd_showqueue,
18811 (cmdline_parse_inst_t *)&cmd_showportall,
18812 (cmdline_parse_inst_t *)&cmd_showdevice,
18813 (cmdline_parse_inst_t *)&cmd_showcfg,
18814 (cmdline_parse_inst_t *)&cmd_showfwdall,
18815 (cmdline_parse_inst_t *)&cmd_start,
18816 (cmdline_parse_inst_t *)&cmd_start_tx_first,
18817 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
18818 (cmdline_parse_inst_t *)&cmd_set_link_up,
18819 (cmdline_parse_inst_t *)&cmd_set_link_down,
18820 (cmdline_parse_inst_t *)&cmd_reset,
18821 (cmdline_parse_inst_t *)&cmd_set_numbers,
18822 (cmdline_parse_inst_t *)&cmd_set_log,
18823 (cmdline_parse_inst_t *)&cmd_set_txpkts,
18824 (cmdline_parse_inst_t *)&cmd_set_txsplit,
18825 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
18826 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
18827 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
18828 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
18829 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
18830 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
18831 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
18832 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
18833 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
18834 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
18835 (cmdline_parse_inst_t *)&cmd_set_link_check,
18836 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
18837 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
18838 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
18839 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
18840 #ifdef RTE_LIBRTE_PMD_BOND
18841 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
18842 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
18843 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
18844 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
18845 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
18846 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
18847 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
18848 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
18849 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
18850 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
18851 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
18853 (cmdline_parse_inst_t *)&cmd_vlan_offload,
18854 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
18855 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
18856 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
18857 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
18858 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
18859 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
18860 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
18861 (cmdline_parse_inst_t *)&cmd_csum_set,
18862 (cmdline_parse_inst_t *)&cmd_csum_show,
18863 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
18864 (cmdline_parse_inst_t *)&cmd_tso_set,
18865 (cmdline_parse_inst_t *)&cmd_tso_show,
18866 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
18867 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
18868 (cmdline_parse_inst_t *)&cmd_gro_enable,
18869 (cmdline_parse_inst_t *)&cmd_gro_flush,
18870 (cmdline_parse_inst_t *)&cmd_gro_show,
18871 (cmdline_parse_inst_t *)&cmd_gso_enable,
18872 (cmdline_parse_inst_t *)&cmd_gso_size,
18873 (cmdline_parse_inst_t *)&cmd_gso_show,
18874 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
18875 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
18876 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
18877 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
18878 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
18879 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
18880 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
18881 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
18882 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
18883 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
18884 (cmdline_parse_inst_t *)&cmd_config_dcb,
18885 (cmdline_parse_inst_t *)&cmd_read_reg,
18886 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
18887 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
18888 (cmdline_parse_inst_t *)&cmd_write_reg,
18889 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
18890 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
18891 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
18892 (cmdline_parse_inst_t *)&cmd_stop,
18893 (cmdline_parse_inst_t *)&cmd_mac_addr,
18894 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
18895 (cmdline_parse_inst_t *)&cmd_set_qmap,
18896 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
18897 (cmdline_parse_inst_t *)&cmd_operate_port,
18898 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
18899 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
18900 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
18901 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
18902 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
18903 (cmdline_parse_inst_t *)&cmd_config_speed_all,
18904 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
18905 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
18906 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
18907 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
18908 (cmdline_parse_inst_t *)&cmd_config_mtu,
18909 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
18910 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
18911 (cmdline_parse_inst_t *)&cmd_config_rss,
18912 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
18913 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
18914 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
18915 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
18916 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
18917 (cmdline_parse_inst_t *)&cmd_showport_reta,
18918 (cmdline_parse_inst_t *)&cmd_config_burst,
18919 (cmdline_parse_inst_t *)&cmd_config_thresh,
18920 (cmdline_parse_inst_t *)&cmd_config_threshold,
18921 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
18922 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
18923 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
18924 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
18925 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
18926 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
18927 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
18928 (cmdline_parse_inst_t *)&cmd_global_config,
18929 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
18930 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
18931 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
18932 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
18933 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
18934 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
18935 (cmdline_parse_inst_t *)&cmd_dump,
18936 (cmdline_parse_inst_t *)&cmd_dump_one,
18937 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
18938 (cmdline_parse_inst_t *)&cmd_syn_filter,
18939 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
18940 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
18941 (cmdline_parse_inst_t *)&cmd_flex_filter,
18942 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
18943 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
18944 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
18945 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
18946 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
18947 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
18948 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
18949 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
18950 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
18951 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
18952 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
18953 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
18954 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
18955 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
18956 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
18957 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
18958 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
18959 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
18960 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
18961 (cmdline_parse_inst_t *)&cmd_flow,
18962 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
18963 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
18964 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
18965 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
18966 (cmdline_parse_inst_t *)&cmd_create_port_meter,
18967 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
18968 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
18969 (cmdline_parse_inst_t *)&cmd_del_port_meter,
18970 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
18971 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
18972 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
18973 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
18974 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
18975 (cmdline_parse_inst_t *)&cmd_mcast_addr,
18976 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
18977 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
18978 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
18979 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
18980 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
18981 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
18982 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
18983 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
18984 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
18985 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
18986 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
18987 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
18988 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
18989 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
18990 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
18991 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
18992 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
18993 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
18994 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
18995 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
18996 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
18997 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
18998 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
18999 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
19000 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
19001 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
19002 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
19003 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
19004 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
19005 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
19006 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
19007 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
19008 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
19009 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
19010 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
19011 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
19012 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
19014 (cmdline_parse_inst_t *)&cmd_set_vxlan,
19015 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
19016 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
19017 (cmdline_parse_inst_t *)&cmd_set_nvgre,
19018 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
19019 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
19020 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
19021 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
19022 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
19023 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
19024 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
19025 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
19026 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
19027 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
19028 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
19029 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
19030 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
19031 (cmdline_parse_inst_t *)&cmd_ddp_add,
19032 (cmdline_parse_inst_t *)&cmd_ddp_del,
19033 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
19034 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
19035 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
19036 (cmdline_parse_inst_t *)&cmd_clear_input_set,
19037 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
19038 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
19039 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
19040 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
19041 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
19042 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
19044 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
19045 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
19046 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
19047 (cmdline_parse_inst_t *)&cmd_queue_region,
19048 (cmdline_parse_inst_t *)&cmd_region_flowtype,
19049 (cmdline_parse_inst_t *)&cmd_user_priority_region,
19050 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
19051 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
19052 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
19053 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
19054 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
19055 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
19056 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
19057 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
19058 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
19059 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
19060 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
19061 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
19062 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
19063 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
19064 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
19065 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
19066 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
19067 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
19068 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
19069 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
19070 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
19071 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
19072 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
19073 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
19074 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
19075 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
19076 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
19077 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
19078 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
19079 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
19080 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19081 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19082 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19083 #ifdef RTE_LIBRTE_BPF
19084 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19085 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19087 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19088 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19089 (cmdline_parse_inst_t *)&cmd_set_raw,
19093 /* read cmdline commands from file */
19095 cmdline_read_from_file(const char *filename)
19097 struct cmdline *cl;
19099 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19101 printf("Failed to create file based cmdline context: %s\n",
19106 cmdline_interact(cl);
19111 printf("Read CLI commands from %s\n", filename);
19114 /* prompt function, called from main on MASTER lcore */
19118 /* initialize non-constant commands */
19119 cmd_set_fwd_mode_init();
19120 cmd_set_fwd_retry_mode_init();
19122 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19123 if (testpmd_cl == NULL)
19125 cmdline_interact(testpmd_cl);
19126 cmdline_stdin_exit(testpmd_cl);
19132 if (testpmd_cl != NULL)
19133 cmdline_quit(testpmd_cl);
19137 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19139 if (id == (portid_t)RTE_PORT_ALL) {
19142 RTE_ETH_FOREACH_DEV(pid) {
19143 /* check if need_reconfig has been set to 1 */
19144 if (ports[pid].need_reconfig == 0)
19145 ports[pid].need_reconfig = dev;
19146 /* check if need_reconfig_queues has been set to 1 */
19147 if (ports[pid].need_reconfig_queues == 0)
19148 ports[pid].need_reconfig_queues = queue;
19150 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19151 /* check if need_reconfig has been set to 1 */
19152 if (ports[id].need_reconfig == 0)
19153 ports[id].need_reconfig = dev;
19154 /* check if need_reconfig_queues has been set to 1 */
19155 if (ports[id].need_reconfig_queues == 0)
19156 ports[id].need_reconfig_queues = queue;