1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
16 #include <net/socket.h>
18 #include <sys/socket.h>
21 #include <netinet/in.h>
23 #include <sys/queue.h>
25 #include <rte_common.h>
26 #include <rte_byteorder.h>
28 #include <rte_debug.h>
29 #include <rte_cycles.h>
30 #include <rte_memory.h>
31 #include <rte_memzone.h>
32 #include <rte_malloc.h>
33 #include <rte_launch.h>
35 #include <rte_per_lcore.h>
36 #include <rte_lcore.h>
37 #include <rte_atomic.h>
38 #include <rte_branch_prediction.h>
40 #include <rte_mempool.h>
41 #include <rte_interrupts.h>
43 #include <rte_ether.h>
44 #include <rte_ethdev.h>
45 #include <rte_string_fns.h>
46 #include <rte_devargs.h>
50 #include <cmdline_rdline.h>
51 #include <cmdline_parse.h>
52 #include <cmdline_parse_num.h>
53 #include <cmdline_parse_string.h>
54 #include <cmdline_parse_ipaddr.h>
55 #include <cmdline_parse_etheraddr.h>
56 #include <cmdline_socket.h>
58 #ifdef RTE_LIBRTE_PMD_BOND
59 #include <rte_eth_bond.h>
60 #include <rte_eth_bond_8023ad.h>
62 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
63 #include <rte_pmd_dpaa.h>
65 #ifdef RTE_LIBRTE_IXGBE_PMD
66 #include <rte_pmd_ixgbe.h>
68 #ifdef RTE_LIBRTE_I40E_PMD
69 #include <rte_pmd_i40e.h>
71 #ifdef RTE_LIBRTE_BNXT_PMD
72 #include <rte_pmd_bnxt.h>
75 #include "cmdline_mtr.h"
76 #include "cmdline_tm.h"
79 static struct cmdline *testpmd_cl;
81 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
83 /* *** Help command with introduction. *** */
84 struct cmd_help_brief_result {
85 cmdline_fixed_string_t help;
88 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
90 __attribute__((unused)) void *data)
95 "Help is available for the following sections:\n\n"
96 " help control : Start and stop forwarding.\n"
97 " help display : Displaying port, stats and config "
99 " help config : Configuration information.\n"
100 " help ports : Configuring ports.\n"
101 " help registers : Reading and setting port registers.\n"
102 " help filters : Filters configuration help.\n"
103 " help traffic_management : Traffic Management commmands.\n"
104 " help all : All of the above sections.\n\n"
109 cmdline_parse_token_string_t cmd_help_brief_help =
110 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
112 cmdline_parse_inst_t cmd_help_brief = {
113 .f = cmd_help_brief_parsed,
115 .help_str = "help: Show help",
117 (void *)&cmd_help_brief_help,
122 /* *** Help command with help sections. *** */
123 struct cmd_help_long_result {
124 cmdline_fixed_string_t help;
125 cmdline_fixed_string_t section;
128 static void cmd_help_long_parsed(void *parsed_result,
130 __attribute__((unused)) void *data)
133 struct cmd_help_long_result *res = parsed_result;
135 if (!strcmp(res->section, "all"))
138 if (show_all || !strcmp(res->section, "control")) {
143 "Control forwarding:\n"
144 "-------------------\n\n"
147 " Start packet forwarding with current configuration.\n\n"
150 " Start packet forwarding with current config"
151 " after sending one burst of packets.\n\n"
154 " Stop packet forwarding, and display accumulated"
158 " Quit to prompt.\n\n"
162 if (show_all || !strcmp(res->section, "display")) {
170 "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
171 " Display information for port_id, or all.\n\n"
173 "show port X rss reta (size) (mask0,mask1,...)\n"
174 " Display the rss redirection table entry indicated"
175 " by masks on port X. size is used to indicate the"
176 " hardware supported reta size\n\n"
178 "show port (port_id) rss-hash [key]\n"
179 " Display the RSS hash functions and RSS hash key of port\n\n"
181 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
182 " Clear information for port_id, or all.\n\n"
184 "show (rxq|txq) info (port_id) (queue_id)\n"
185 " Display information for configured RX/TX queue.\n\n"
187 "show config (rxtx|cores|fwd|txpkts)\n"
188 " Display the given configuration.\n\n"
190 "read rxd (port_id) (queue_id) (rxd_id)\n"
191 " Display an RX descriptor of a port RX queue.\n\n"
193 "read txd (port_id) (queue_id) (txd_id)\n"
194 " Display a TX descriptor of a port TX queue.\n\n"
196 "ddp get list (port_id)\n"
197 " Get ddp profile info list\n\n"
199 "ddp get info (profile_path)\n"
200 " Get ddp profile information.\n\n"
202 "show vf stats (port_id) (vf_id)\n"
203 " Display a VF's statistics.\n\n"
205 "clear vf stats (port_id) (vf_id)\n"
206 " Reset a VF's statistics.\n\n"
208 "show port (port_id) pctype mapping\n"
209 " Get flow ptype to pctype mapping on a port\n\n"
211 "show port meter stats (port_id) (meter_id) (clear)\n"
212 " Get meter stats on a port\n\n"
214 "show fwd stats all\n"
215 " Display statistics for all fwd engines.\n\n"
217 "clear fwd stats all\n"
218 " Clear statistics for all fwd engines.\n\n"
220 "show port (port_id) rx_offload capabilities\n"
221 " List all per queue and per port Rx offloading"
222 " capabilities of a port\n\n"
224 "show port (port_id) rx_offload configuration\n"
225 " List port level and all queue level"
226 " Rx offloading configuration\n\n"
228 "show port (port_id) tx_offload capabilities\n"
229 " List all per queue and per port"
230 " Tx offloading capabilities of a port\n\n"
232 "show port (port_id) tx_offload configuration\n"
233 " List port level and all queue level"
234 " Tx offloading configuration\n\n"
236 "show port (port_id) tx_metadata\n"
237 " Show Tx metadata value set"
238 " for a specific port\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 "vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
737 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
738 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
739 " Configure the VXLAN encapsulation for flows.\n\n"
741 "vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
742 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
743 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
744 " eth-dst (eth-dst)\n"
745 " Configure the VXLAN encapsulation for flows.\n\n"
747 "vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
748 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
749 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
750 " eth-dst (eth-dst)\n"
751 " Configure the VXLAN encapsulation for flows.\n\n"
753 "nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
754 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
756 " Configure the NVGRE encapsulation for flows.\n\n"
758 "nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
759 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
760 " eth-src (eth-src) eth-dst (eth-dst)\n"
761 " Configure the NVGRE encapsulation for flows.\n\n"
763 , list_pkt_forwarding_modes()
767 if (show_all || !strcmp(res->section, "ports")) {
773 "----------------\n\n"
775 "port start (port_id|all)\n"
776 " Start all ports or port_id.\n\n"
778 "port stop (port_id|all)\n"
779 " Stop all ports or port_id.\n\n"
781 "port close (port_id|all)\n"
782 " Close all ports or port_id.\n\n"
784 "port attach (ident)\n"
785 " Attach physical or virtual dev by pci address or virtual device name\n\n"
787 "port detach (port_id)\n"
788 " Detach physical or virtual dev by port_id\n\n"
790 "port config (port_id|all)"
791 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
792 " duplex (half|full|auto)\n"
793 " Set speed and duplex for all ports or port_id\n\n"
795 "port config (port_id|all) loopback (mode)\n"
796 " Set loopback mode for all ports or port_id\n\n"
798 "port config all (rxq|txq|rxd|txd) (value)\n"
799 " Set number for rxq/txq/rxd/txd.\n\n"
801 "port config all max-pkt-len (value)\n"
802 " Set the max packet length.\n\n"
804 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
805 "hw-vlan-strip|hw-vlan-extend|drop-en)"
807 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
810 "port config all rss (all|default|ip|tcp|udp|sctp|"
811 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n"
812 " Set the RSS mode.\n\n"
814 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
815 " Set the RSS redirection table.\n\n"
817 "port config (port_id) dcb vt (on|off) (traffic_class)"
819 " Set the DCB mode.\n\n"
821 "port config all burst (value)\n"
822 " Set the number of packets per burst.\n\n"
824 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
826 " Set the ring prefetch/host/writeback threshold"
827 " for tx/rx queue.\n\n"
829 "port config all (txfreet|txrst|rxfreet) (value)\n"
830 " Set free threshold for rx/tx, or set"
831 " tx rs bit threshold.\n\n"
832 "port config mtu X value\n"
833 " Set the MTU of port X to a given value\n\n"
835 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
836 " Set a rx/tx queue's ring size configuration, the new"
837 " value will take effect after command that (re-)start the port"
838 " or command that setup the specific queue\n\n"
840 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
841 " Start/stop a rx/tx queue of port X. Only take effect"
842 " when port X is started\n\n"
844 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
845 " Switch on/off a deferred start of port X rx/tx queue. Only"
846 " take effect when port X is stopped.\n\n"
848 "port (port_id) (rxq|txq) (queue_id) setup\n"
849 " Setup a rx/tx queue of port X.\n\n"
851 "port config (port_id|all) l2-tunnel E-tag ether-type"
853 " Set the value of E-tag ether-type.\n\n"
855 "port config (port_id|all) l2-tunnel E-tag"
856 " (enable|disable)\n"
857 " Enable/disable the E-tag support.\n\n"
859 "port config (port_id) pctype mapping reset\n"
860 " Reset flow type to pctype mapping on a port\n\n"
862 "port config (port_id) pctype mapping update"
863 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
864 " Update a flow type to pctype mapping item on a port\n\n"
866 "port config (port_id) pctype (pctype_id) hash_inset|"
867 "fdir_inset|fdir_flx_inset get|set|clear field\n"
869 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
871 "port config (port_id) pctype (pctype_id) hash_inset|"
872 "fdir_inset|fdir_flx_inset clear all"
873 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
875 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
876 " Add/remove UDP tunnel port for tunneling offload\n\n"
878 "port config <port_id> rx_offload vlan_strip|"
879 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
880 "outer_ipv4_cksum|macsec_strip|header_split|"
881 "vlan_filter|vlan_extend|jumbo_frame|crc_strip|"
882 "scatter|timestamp|security|keep_crc on|off\n"
883 " Enable or disable a per port Rx offloading"
884 " on all Rx queues of a port\n\n"
886 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
887 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
888 "outer_ipv4_cksum|macsec_strip|header_split|"
889 "vlan_filter|vlan_extend|jumbo_frame|crc_strip|"
890 "scatter|timestamp|security|keep_crc on|off\n"
891 " Enable or disable a per queue Rx offloading"
892 " only on a specific Rx queue\n\n"
894 "port config (port_id) tx_offload vlan_insert|"
895 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
896 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
897 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
898 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
899 "security|match_metadata on|off\n"
900 " Enable or disable a per port Tx offloading"
901 " on all Tx queues of a port\n\n"
903 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
904 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
905 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
906 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
907 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
909 " Enable or disable a per queue Tx offloading"
910 " only on a specific Tx queue\n\n"
912 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
913 " Load an eBPF program as a callback"
914 " for particular RX/TX queue\n\n"
916 "bpf-unload rx|tx (port) (queue)\n"
917 " Unload previously loaded eBPF program"
918 " for particular RX/TX queue\n\n"
920 "port config (port_id) tx_metadata (value)\n"
921 " Set Tx metadata value per port. Testpmd will add this value"
922 " to any Tx packet sent from this port\n\n"
926 if (show_all || !strcmp(res->section, "registers")) {
934 "read reg (port_id) (address)\n"
935 " Display value of a port register.\n\n"
937 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
938 " Display a port register bit field.\n\n"
940 "read regbit (port_id) (address) (bit_x)\n"
941 " Display a single port register bit.\n\n"
943 "write reg (port_id) (address) (value)\n"
944 " Set value of a port register.\n\n"
946 "write regfield (port_id) (address) (bit_x) (bit_y)"
948 " Set bit field of a port register.\n\n"
950 "write regbit (port_id) (address) (bit_x) (value)\n"
951 " Set single bit value of a port register.\n\n"
954 if (show_all || !strcmp(res->section, "filters")) {
962 "ethertype_filter (port_id) (add|del)"
963 " (mac_addr|mac_ignr) (mac_address) ethertype"
964 " (ether_type) (drop|fwd) queue (queue_id)\n"
965 " Add/Del an ethertype filter.\n\n"
967 "2tuple_filter (port_id) (add|del)"
968 " dst_port (dst_port_value) protocol (protocol_value)"
969 " mask (mask_value) tcp_flags (tcp_flags_value)"
970 " priority (prio_value) queue (queue_id)\n"
971 " Add/Del a 2tuple filter.\n\n"
973 "5tuple_filter (port_id) (add|del)"
974 " dst_ip (dst_address) src_ip (src_address)"
975 " dst_port (dst_port_value) src_port (src_port_value)"
976 " protocol (protocol_value)"
977 " mask (mask_value) tcp_flags (tcp_flags_value)"
978 " priority (prio_value) queue (queue_id)\n"
979 " Add/Del a 5tuple filter.\n\n"
981 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
982 " Add/Del syn filter.\n\n"
984 "flex_filter (port_id) (add|del) len (len_value)"
985 " bytes (bytes_value) mask (mask_value)"
986 " priority (prio_value) queue (queue_id)\n"
987 " Add/Del a flex filter.\n\n"
989 "flow_director_filter (port_id) mode IP (add|del|update)"
990 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
991 " src (src_ip_address) dst (dst_ip_address)"
992 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
993 " vlan (vlan_value) flexbytes (flexbytes_value)"
994 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
995 " fd_id (fd_id_value)\n"
996 " Add/Del an IP type flow director filter.\n\n"
998 "flow_director_filter (port_id) mode IP (add|del|update)"
999 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
1000 " src (src_ip_address) (src_port)"
1001 " dst (dst_ip_address) (dst_port)"
1002 " tos (tos_value) ttl (ttl_value)"
1003 " vlan (vlan_value) flexbytes (flexbytes_value)"
1004 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
1005 " fd_id (fd_id_value)\n"
1006 " Add/Del an UDP/TCP type flow director filter.\n\n"
1008 "flow_director_filter (port_id) mode IP (add|del|update)"
1009 " flow (ipv4-sctp|ipv6-sctp)"
1010 " src (src_ip_address) (src_port)"
1011 " dst (dst_ip_address) (dst_port)"
1012 " tag (verification_tag) "
1013 " tos (tos_value) ttl (ttl_value)"
1014 " vlan (vlan_value)"
1015 " flexbytes (flexbytes_value) (drop|fwd)"
1016 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1017 " Add/Del a SCTP type flow director filter.\n\n"
1019 "flow_director_filter (port_id) mode IP (add|del|update)"
1020 " flow l2_payload ether (ethertype)"
1021 " flexbytes (flexbytes_value) (drop|fwd)"
1022 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1023 " Add/Del a l2 payload type flow director filter.\n\n"
1025 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1026 " mac (mac_address) vlan (vlan_value)"
1027 " flexbytes (flexbytes_value) (drop|fwd)"
1028 " queue (queue_id) fd_id (fd_id_value)\n"
1029 " Add/Del a MAC-VLAN flow director filter.\n\n"
1031 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1032 " mac (mac_address) vlan (vlan_value)"
1033 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1034 " flexbytes (flexbytes_value) (drop|fwd)"
1035 " queue (queue_id) fd_id (fd_id_value)\n"
1036 " Add/Del a Tunnel flow director filter.\n\n"
1038 "flow_director_filter (port_id) mode raw (add|del|update)"
1039 " flow (flow_id) (drop|fwd) queue (queue_id)"
1040 " fd_id (fd_id_value) packet (packet file name)\n"
1041 " Add/Del a raw type flow director filter.\n\n"
1043 "flush_flow_director (port_id)\n"
1044 " Flush all flow director entries of a device.\n\n"
1046 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1047 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1048 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1049 " Set flow director IP mask.\n\n"
1051 "flow_director_mask (port_id) mode MAC-VLAN"
1052 " vlan (vlan_value)\n"
1053 " Set flow director MAC-VLAN mask.\n\n"
1055 "flow_director_mask (port_id) mode Tunnel"
1056 " vlan (vlan_value) mac (mac_value)"
1057 " tunnel-type (tunnel_type_value)"
1058 " tunnel-id (tunnel_id_value)\n"
1059 " Set flow director Tunnel mask.\n\n"
1061 "flow_director_flex_mask (port_id)"
1062 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1063 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1065 " Configure mask of flex payload.\n\n"
1067 "flow_director_flex_payload (port_id)"
1068 " (raw|l2|l3|l4) (config)\n"
1069 " Configure flex payload selection.\n\n"
1071 "get_sym_hash_ena_per_port (port_id)\n"
1072 " get symmetric hash enable configuration per port.\n\n"
1074 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1075 " set symmetric hash enable configuration per port"
1076 " to enable or disable.\n\n"
1078 "get_hash_global_config (port_id)\n"
1079 " Get the global configurations of hash filters.\n\n"
1081 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1082 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1083 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1084 " (enable|disable)\n"
1085 " Set the global configurations of hash filters.\n\n"
1087 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1088 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1089 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1090 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1091 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1092 "ipv6-next-header|udp-src-port|udp-dst-port|"
1093 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1094 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1095 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1096 "fld-8th|none) (select|add)\n"
1097 " Set the input set for hash.\n\n"
1099 "set_fdir_input_set (port_id) "
1100 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1101 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1102 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1103 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1104 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1105 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1106 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1108 " Set the input set for FDir.\n\n"
1110 "flow validate {port_id}"
1111 " [group {group_id}] [priority {level}]"
1112 " [ingress] [egress]"
1113 " pattern {item} [/ {item} [...]] / end"
1114 " actions {action} [/ {action} [...]] / end\n"
1115 " Check whether a flow rule can be created.\n\n"
1117 "flow create {port_id}"
1118 " [group {group_id}] [priority {level}]"
1119 " [ingress] [egress]"
1120 " pattern {item} [/ {item} [...]] / end"
1121 " actions {action} [/ {action} [...]] / end\n"
1122 " Create a flow rule.\n\n"
1124 "flow destroy {port_id} rule {rule_id} [...]\n"
1125 " Destroy specific flow rules.\n\n"
1127 "flow flush {port_id}\n"
1128 " Destroy all flow rules.\n\n"
1130 "flow query {port_id} {rule_id} {action}\n"
1131 " Query an existing flow rule.\n\n"
1133 "flow list {port_id} [group {group_id}] [...]\n"
1134 " List existing flow rules sorted by priority,"
1135 " filtered by group identifiers.\n\n"
1137 "flow isolate {port_id} {boolean}\n"
1138 " Restrict ingress traffic to the defined"
1143 if (show_all || !strcmp(res->section, "traffic_management")) {
1147 "Traffic Management:\n"
1149 "show port tm cap (port_id)\n"
1150 " Display the port TM capability.\n\n"
1152 "show port tm level cap (port_id) (level_id)\n"
1153 " Display the port TM hierarchical level capability.\n\n"
1155 "show port tm node cap (port_id) (node_id)\n"
1156 " Display the port TM node capability.\n\n"
1158 "show port tm node type (port_id) (node_id)\n"
1159 " Display the port TM node type.\n\n"
1161 "show port tm node stats (port_id) (node_id) (clear)\n"
1162 " Display the port TM node stats.\n\n"
1164 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
1165 "set port tm hierarchy default (port_id)\n"
1166 " Set default traffic Management hierarchy on a port\n\n"
1169 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1170 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1171 " (packet_length_adjust)\n"
1172 " Add port tm node private shaper profile.\n\n"
1174 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1175 " Delete port tm node private shaper profile.\n\n"
1177 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1178 " (shaper_profile_id)\n"
1179 " Add/update port tm node shared shaper.\n\n"
1181 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1182 " Delete port tm node shared shaper.\n\n"
1184 "set port tm node shaper profile (port_id) (node_id)"
1185 " (shaper_profile_id)\n"
1186 " Set port tm node shaper profile.\n\n"
1188 "add port tm node wred profile (port_id) (wred_profile_id)"
1189 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1190 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1191 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1192 " Add port tm node wred profile.\n\n"
1194 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1195 " Delete port tm node wred profile.\n\n"
1197 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1198 " (priority) (weight) (level_id) (shaper_profile_id)"
1199 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1200 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1201 " Add port tm nonleaf node.\n\n"
1203 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1204 " (priority) (weight) (level_id) (shaper_profile_id)"
1205 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1206 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1207 " Add port tm leaf node.\n\n"
1209 "del port tm node (port_id) (node_id)\n"
1210 " Delete port tm node.\n\n"
1212 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1213 " (priority) (weight)\n"
1214 " Set port tm node parent.\n\n"
1216 "suspend port tm node (port_id) (node_id)"
1217 " Suspend tm node.\n\n"
1219 "resume port tm node (port_id) (node_id)"
1220 " Resume tm node.\n\n"
1222 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1223 " Commit tm hierarchy.\n\n"
1225 "set port tm mark ip_ecn (port) (green) (yellow)"
1227 " Enables/Disables the traffic management marking"
1228 " for IP ECN (Explicit Congestion Notification)"
1229 " packets on a given port\n\n"
1231 "set port tm mark ip_dscp (port) (green) (yellow)"
1233 " Enables/Disables the traffic management marking"
1234 " on the port for IP dscp packets\n\n"
1236 "set port tm mark vlan_dei (port) (green) (yellow)"
1238 " Enables/Disables the traffic management marking"
1239 " on the port for VLAN packets with DEI enabled\n\n"
1245 cmdline_parse_token_string_t cmd_help_long_help =
1246 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1248 cmdline_parse_token_string_t cmd_help_long_section =
1249 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1250 "all#control#display#config#"
1251 "ports#registers#filters#traffic_management");
1253 cmdline_parse_inst_t cmd_help_long = {
1254 .f = cmd_help_long_parsed,
1256 .help_str = "help all|control|display|config|ports|register|"
1257 "filters|traffic_management: "
1260 (void *)&cmd_help_long_help,
1261 (void *)&cmd_help_long_section,
1267 /* *** start/stop/close all ports *** */
1268 struct cmd_operate_port_result {
1269 cmdline_fixed_string_t keyword;
1270 cmdline_fixed_string_t name;
1271 cmdline_fixed_string_t value;
1274 static void cmd_operate_port_parsed(void *parsed_result,
1275 __attribute__((unused)) struct cmdline *cl,
1276 __attribute__((unused)) void *data)
1278 struct cmd_operate_port_result *res = parsed_result;
1280 if (!strcmp(res->name, "start"))
1281 start_port(RTE_PORT_ALL);
1282 else if (!strcmp(res->name, "stop"))
1283 stop_port(RTE_PORT_ALL);
1284 else if (!strcmp(res->name, "close"))
1285 close_port(RTE_PORT_ALL);
1286 else if (!strcmp(res->name, "reset"))
1287 reset_port(RTE_PORT_ALL);
1289 printf("Unknown parameter\n");
1292 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1293 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1295 cmdline_parse_token_string_t cmd_operate_port_all_port =
1296 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1297 "start#stop#close#reset");
1298 cmdline_parse_token_string_t cmd_operate_port_all_all =
1299 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1301 cmdline_parse_inst_t cmd_operate_port = {
1302 .f = cmd_operate_port_parsed,
1304 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1306 (void *)&cmd_operate_port_all_cmd,
1307 (void *)&cmd_operate_port_all_port,
1308 (void *)&cmd_operate_port_all_all,
1313 /* *** start/stop/close specific port *** */
1314 struct cmd_operate_specific_port_result {
1315 cmdline_fixed_string_t keyword;
1316 cmdline_fixed_string_t name;
1320 static void cmd_operate_specific_port_parsed(void *parsed_result,
1321 __attribute__((unused)) struct cmdline *cl,
1322 __attribute__((unused)) void *data)
1324 struct cmd_operate_specific_port_result *res = parsed_result;
1326 if (!strcmp(res->name, "start"))
1327 start_port(res->value);
1328 else if (!strcmp(res->name, "stop"))
1329 stop_port(res->value);
1330 else if (!strcmp(res->name, "close"))
1331 close_port(res->value);
1332 else if (!strcmp(res->name, "reset"))
1333 reset_port(res->value);
1335 printf("Unknown parameter\n");
1338 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1339 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1341 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1342 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1343 name, "start#stop#close#reset");
1344 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1345 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1348 cmdline_parse_inst_t cmd_operate_specific_port = {
1349 .f = cmd_operate_specific_port_parsed,
1351 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1353 (void *)&cmd_operate_specific_port_cmd,
1354 (void *)&cmd_operate_specific_port_port,
1355 (void *)&cmd_operate_specific_port_id,
1360 /* *** enable port setup (after attach) via iterator or event *** */
1361 struct cmd_set_port_setup_on_result {
1362 cmdline_fixed_string_t set;
1363 cmdline_fixed_string_t port;
1364 cmdline_fixed_string_t setup;
1365 cmdline_fixed_string_t on;
1366 cmdline_fixed_string_t mode;
1369 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1370 __attribute__((unused)) struct cmdline *cl,
1371 __attribute__((unused)) void *data)
1373 struct cmd_set_port_setup_on_result *res = parsed_result;
1375 if (strcmp(res->mode, "event") == 0)
1376 setup_on_probe_event = true;
1377 else if (strcmp(res->mode, "iterator") == 0)
1378 setup_on_probe_event = false;
1380 printf("Unknown mode\n");
1383 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1384 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1386 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1387 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1389 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1390 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1392 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1393 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1395 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1396 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1397 mode, "iterator#event");
1399 cmdline_parse_inst_t cmd_set_port_setup_on = {
1400 .f = cmd_set_port_setup_on_parsed,
1402 .help_str = "set port setup on iterator|event",
1404 (void *)&cmd_set_port_setup_on_set,
1405 (void *)&cmd_set_port_setup_on_port,
1406 (void *)&cmd_set_port_setup_on_setup,
1407 (void *)&cmd_set_port_setup_on_on,
1408 (void *)&cmd_set_port_setup_on_mode,
1413 /* *** attach a specified port *** */
1414 struct cmd_operate_attach_port_result {
1415 cmdline_fixed_string_t port;
1416 cmdline_fixed_string_t keyword;
1417 cmdline_fixed_string_t identifier;
1420 static void cmd_operate_attach_port_parsed(void *parsed_result,
1421 __attribute__((unused)) struct cmdline *cl,
1422 __attribute__((unused)) void *data)
1424 struct cmd_operate_attach_port_result *res = parsed_result;
1426 if (!strcmp(res->keyword, "attach"))
1427 attach_port(res->identifier);
1429 printf("Unknown parameter\n");
1432 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1433 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1435 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1436 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1438 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1439 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1442 cmdline_parse_inst_t cmd_operate_attach_port = {
1443 .f = cmd_operate_attach_port_parsed,
1445 .help_str = "port attach <identifier>: "
1446 "(identifier: pci address or virtual dev name)",
1448 (void *)&cmd_operate_attach_port_port,
1449 (void *)&cmd_operate_attach_port_keyword,
1450 (void *)&cmd_operate_attach_port_identifier,
1455 /* *** detach a specified port *** */
1456 struct cmd_operate_detach_port_result {
1457 cmdline_fixed_string_t port;
1458 cmdline_fixed_string_t keyword;
1462 static void cmd_operate_detach_port_parsed(void *parsed_result,
1463 __attribute__((unused)) struct cmdline *cl,
1464 __attribute__((unused)) void *data)
1466 struct cmd_operate_detach_port_result *res = parsed_result;
1468 if (!strcmp(res->keyword, "detach"))
1469 detach_port_device(res->port_id);
1471 printf("Unknown parameter\n");
1474 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1475 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1477 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1478 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1480 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1481 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1484 cmdline_parse_inst_t cmd_operate_detach_port = {
1485 .f = cmd_operate_detach_port_parsed,
1487 .help_str = "port detach <port_id>",
1489 (void *)&cmd_operate_detach_port_port,
1490 (void *)&cmd_operate_detach_port_keyword,
1491 (void *)&cmd_operate_detach_port_port_id,
1496 /* *** configure speed for all ports *** */
1497 struct cmd_config_speed_all {
1498 cmdline_fixed_string_t port;
1499 cmdline_fixed_string_t keyword;
1500 cmdline_fixed_string_t all;
1501 cmdline_fixed_string_t item1;
1502 cmdline_fixed_string_t item2;
1503 cmdline_fixed_string_t value1;
1504 cmdline_fixed_string_t value2;
1508 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1513 if (!strcmp(duplexstr, "half")) {
1514 duplex = ETH_LINK_HALF_DUPLEX;
1515 } else if (!strcmp(duplexstr, "full")) {
1516 duplex = ETH_LINK_FULL_DUPLEX;
1517 } else if (!strcmp(duplexstr, "auto")) {
1518 duplex = ETH_LINK_FULL_DUPLEX;
1520 printf("Unknown duplex parameter\n");
1524 if (!strcmp(speedstr, "10")) {
1525 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1526 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1527 } else if (!strcmp(speedstr, "100")) {
1528 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1529 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1531 if (duplex != ETH_LINK_FULL_DUPLEX) {
1532 printf("Invalid speed/duplex parameters\n");
1535 if (!strcmp(speedstr, "1000")) {
1536 *speed = ETH_LINK_SPEED_1G;
1537 } else if (!strcmp(speedstr, "10000")) {
1538 *speed = ETH_LINK_SPEED_10G;
1539 } else if (!strcmp(speedstr, "25000")) {
1540 *speed = ETH_LINK_SPEED_25G;
1541 } else if (!strcmp(speedstr, "40000")) {
1542 *speed = ETH_LINK_SPEED_40G;
1543 } else if (!strcmp(speedstr, "50000")) {
1544 *speed = ETH_LINK_SPEED_50G;
1545 } else if (!strcmp(speedstr, "100000")) {
1546 *speed = ETH_LINK_SPEED_100G;
1547 } else if (!strcmp(speedstr, "auto")) {
1548 *speed = ETH_LINK_SPEED_AUTONEG;
1550 printf("Unknown speed parameter\n");
1559 cmd_config_speed_all_parsed(void *parsed_result,
1560 __attribute__((unused)) struct cmdline *cl,
1561 __attribute__((unused)) void *data)
1563 struct cmd_config_speed_all *res = parsed_result;
1564 uint32_t link_speed;
1567 if (!all_ports_stopped()) {
1568 printf("Please stop all ports first\n");
1572 if (parse_and_check_speed_duplex(res->value1, res->value2,
1576 RTE_ETH_FOREACH_DEV(pid) {
1577 ports[pid].dev_conf.link_speeds = link_speed;
1580 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1583 cmdline_parse_token_string_t cmd_config_speed_all_port =
1584 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1585 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1586 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1588 cmdline_parse_token_string_t cmd_config_speed_all_all =
1589 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1590 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1591 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1592 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1593 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1594 "10#100#1000#10000#25000#40000#50000#100000#auto");
1595 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1596 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1597 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1598 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1601 cmdline_parse_inst_t cmd_config_speed_all = {
1602 .f = cmd_config_speed_all_parsed,
1604 .help_str = "port config all speed "
1605 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1608 (void *)&cmd_config_speed_all_port,
1609 (void *)&cmd_config_speed_all_keyword,
1610 (void *)&cmd_config_speed_all_all,
1611 (void *)&cmd_config_speed_all_item1,
1612 (void *)&cmd_config_speed_all_value1,
1613 (void *)&cmd_config_speed_all_item2,
1614 (void *)&cmd_config_speed_all_value2,
1619 /* *** configure speed for specific port *** */
1620 struct cmd_config_speed_specific {
1621 cmdline_fixed_string_t port;
1622 cmdline_fixed_string_t keyword;
1624 cmdline_fixed_string_t item1;
1625 cmdline_fixed_string_t item2;
1626 cmdline_fixed_string_t value1;
1627 cmdline_fixed_string_t value2;
1631 cmd_config_speed_specific_parsed(void *parsed_result,
1632 __attribute__((unused)) struct cmdline *cl,
1633 __attribute__((unused)) void *data)
1635 struct cmd_config_speed_specific *res = parsed_result;
1636 uint32_t link_speed;
1638 if (!all_ports_stopped()) {
1639 printf("Please stop all ports first\n");
1643 if (port_id_is_invalid(res->id, ENABLED_WARN))
1646 if (parse_and_check_speed_duplex(res->value1, res->value2,
1650 ports[res->id].dev_conf.link_speeds = link_speed;
1652 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1656 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1657 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1659 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1660 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1662 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1663 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1664 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1665 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1667 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1668 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1669 "10#100#1000#10000#25000#40000#50000#100000#auto");
1670 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1671 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1673 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1674 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1677 cmdline_parse_inst_t cmd_config_speed_specific = {
1678 .f = cmd_config_speed_specific_parsed,
1680 .help_str = "port config <port_id> speed "
1681 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1684 (void *)&cmd_config_speed_specific_port,
1685 (void *)&cmd_config_speed_specific_keyword,
1686 (void *)&cmd_config_speed_specific_id,
1687 (void *)&cmd_config_speed_specific_item1,
1688 (void *)&cmd_config_speed_specific_value1,
1689 (void *)&cmd_config_speed_specific_item2,
1690 (void *)&cmd_config_speed_specific_value2,
1695 /* *** configure loopback for all ports *** */
1696 struct cmd_config_loopback_all {
1697 cmdline_fixed_string_t port;
1698 cmdline_fixed_string_t keyword;
1699 cmdline_fixed_string_t all;
1700 cmdline_fixed_string_t item;
1705 cmd_config_loopback_all_parsed(void *parsed_result,
1706 __attribute__((unused)) struct cmdline *cl,
1707 __attribute__((unused)) void *data)
1709 struct cmd_config_loopback_all *res = parsed_result;
1712 if (!all_ports_stopped()) {
1713 printf("Please stop all ports first\n");
1717 RTE_ETH_FOREACH_DEV(pid) {
1718 ports[pid].dev_conf.lpbk_mode = res->mode;
1721 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1724 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1725 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1726 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1727 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1729 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1730 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1731 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1732 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1734 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1735 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1737 cmdline_parse_inst_t cmd_config_loopback_all = {
1738 .f = cmd_config_loopback_all_parsed,
1740 .help_str = "port config all loopback <mode>",
1742 (void *)&cmd_config_loopback_all_port,
1743 (void *)&cmd_config_loopback_all_keyword,
1744 (void *)&cmd_config_loopback_all_all,
1745 (void *)&cmd_config_loopback_all_item,
1746 (void *)&cmd_config_loopback_all_mode,
1751 /* *** configure loopback for specific port *** */
1752 struct cmd_config_loopback_specific {
1753 cmdline_fixed_string_t port;
1754 cmdline_fixed_string_t keyword;
1756 cmdline_fixed_string_t item;
1761 cmd_config_loopback_specific_parsed(void *parsed_result,
1762 __attribute__((unused)) struct cmdline *cl,
1763 __attribute__((unused)) void *data)
1765 struct cmd_config_loopback_specific *res = parsed_result;
1767 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1770 if (!port_is_stopped(res->port_id)) {
1771 printf("Please stop port %u first\n", res->port_id);
1775 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1777 cmd_reconfig_device_queue(res->port_id, 1, 1);
1781 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1782 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1784 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1785 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1787 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1788 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1790 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1791 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1793 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1794 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1797 cmdline_parse_inst_t cmd_config_loopback_specific = {
1798 .f = cmd_config_loopback_specific_parsed,
1800 .help_str = "port config <port_id> loopback <mode>",
1802 (void *)&cmd_config_loopback_specific_port,
1803 (void *)&cmd_config_loopback_specific_keyword,
1804 (void *)&cmd_config_loopback_specific_id,
1805 (void *)&cmd_config_loopback_specific_item,
1806 (void *)&cmd_config_loopback_specific_mode,
1811 /* *** configure txq/rxq, txd/rxd *** */
1812 struct cmd_config_rx_tx {
1813 cmdline_fixed_string_t port;
1814 cmdline_fixed_string_t keyword;
1815 cmdline_fixed_string_t all;
1816 cmdline_fixed_string_t name;
1821 cmd_config_rx_tx_parsed(void *parsed_result,
1822 __attribute__((unused)) struct cmdline *cl,
1823 __attribute__((unused)) void *data)
1825 struct cmd_config_rx_tx *res = parsed_result;
1827 if (!all_ports_stopped()) {
1828 printf("Please stop all ports first\n");
1831 if (!strcmp(res->name, "rxq")) {
1832 if (!res->value && !nb_txq) {
1833 printf("Warning: Either rx or tx queues should be non zero\n");
1836 if (check_nb_rxq(res->value) != 0)
1838 nb_rxq = res->value;
1840 else if (!strcmp(res->name, "txq")) {
1841 if (!res->value && !nb_rxq) {
1842 printf("Warning: Either rx or tx queues should be non zero\n");
1845 if (check_nb_txq(res->value) != 0)
1847 nb_txq = res->value;
1849 else if (!strcmp(res->name, "rxd")) {
1850 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1851 printf("rxd %d invalid - must be > 0 && <= %d\n",
1852 res->value, RTE_TEST_RX_DESC_MAX);
1855 nb_rxd = res->value;
1856 } else if (!strcmp(res->name, "txd")) {
1857 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1858 printf("txd %d invalid - must be > 0 && <= %d\n",
1859 res->value, RTE_TEST_TX_DESC_MAX);
1862 nb_txd = res->value;
1864 printf("Unknown parameter\n");
1872 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1875 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1876 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1877 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1878 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1879 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1880 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1881 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1882 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1884 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1885 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1887 cmdline_parse_inst_t cmd_config_rx_tx = {
1888 .f = cmd_config_rx_tx_parsed,
1890 .help_str = "port config all rxq|txq|rxd|txd <value>",
1892 (void *)&cmd_config_rx_tx_port,
1893 (void *)&cmd_config_rx_tx_keyword,
1894 (void *)&cmd_config_rx_tx_all,
1895 (void *)&cmd_config_rx_tx_name,
1896 (void *)&cmd_config_rx_tx_value,
1901 /* *** config max packet length *** */
1902 struct cmd_config_max_pkt_len_result {
1903 cmdline_fixed_string_t port;
1904 cmdline_fixed_string_t keyword;
1905 cmdline_fixed_string_t all;
1906 cmdline_fixed_string_t name;
1911 cmd_config_max_pkt_len_parsed(void *parsed_result,
1912 __attribute__((unused)) struct cmdline *cl,
1913 __attribute__((unused)) void *data)
1915 struct cmd_config_max_pkt_len_result *res = parsed_result;
1918 if (!all_ports_stopped()) {
1919 printf("Please stop all ports first\n");
1923 RTE_ETH_FOREACH_DEV(pid) {
1924 struct rte_port *port = &ports[pid];
1925 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1927 if (!strcmp(res->name, "max-pkt-len")) {
1928 if (res->value < RTE_ETHER_MIN_LEN) {
1929 printf("max-pkt-len can not be less than %d\n",
1933 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1936 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1937 if (res->value > RTE_ETHER_MAX_LEN)
1938 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1940 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1941 port->dev_conf.rxmode.offloads = rx_offloads;
1943 printf("Unknown parameter\n");
1950 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1953 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1954 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1956 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1957 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1959 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1960 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1962 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1963 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1965 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1966 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1969 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1970 .f = cmd_config_max_pkt_len_parsed,
1972 .help_str = "port config all max-pkt-len <value>",
1974 (void *)&cmd_config_max_pkt_len_port,
1975 (void *)&cmd_config_max_pkt_len_keyword,
1976 (void *)&cmd_config_max_pkt_len_all,
1977 (void *)&cmd_config_max_pkt_len_name,
1978 (void *)&cmd_config_max_pkt_len_value,
1983 /* *** configure port MTU *** */
1984 struct cmd_config_mtu_result {
1985 cmdline_fixed_string_t port;
1986 cmdline_fixed_string_t keyword;
1987 cmdline_fixed_string_t mtu;
1993 cmd_config_mtu_parsed(void *parsed_result,
1994 __attribute__((unused)) struct cmdline *cl,
1995 __attribute__((unused)) void *data)
1997 struct cmd_config_mtu_result *res = parsed_result;
1999 if (res->value < RTE_ETHER_MIN_LEN) {
2000 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2003 port_mtu_set(res->port_id, res->value);
2006 cmdline_parse_token_string_t cmd_config_mtu_port =
2007 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2009 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2010 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2012 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2013 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2015 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2016 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2017 cmdline_parse_token_num_t cmd_config_mtu_value =
2018 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2020 cmdline_parse_inst_t cmd_config_mtu = {
2021 .f = cmd_config_mtu_parsed,
2023 .help_str = "port config mtu <port_id> <value>",
2025 (void *)&cmd_config_mtu_port,
2026 (void *)&cmd_config_mtu_keyword,
2027 (void *)&cmd_config_mtu_mtu,
2028 (void *)&cmd_config_mtu_port_id,
2029 (void *)&cmd_config_mtu_value,
2034 /* *** configure rx mode *** */
2035 struct cmd_config_rx_mode_flag {
2036 cmdline_fixed_string_t port;
2037 cmdline_fixed_string_t keyword;
2038 cmdline_fixed_string_t all;
2039 cmdline_fixed_string_t name;
2040 cmdline_fixed_string_t value;
2044 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2045 __attribute__((unused)) struct cmdline *cl,
2046 __attribute__((unused)) void *data)
2048 struct cmd_config_rx_mode_flag *res = parsed_result;
2052 if (!all_ports_stopped()) {
2053 printf("Please stop all ports first\n");
2057 RTE_ETH_FOREACH_DEV(pid) {
2058 struct rte_port *port;
2059 uint64_t rx_offloads;
2062 rx_offloads = port->dev_conf.rxmode.offloads;
2063 if (!strcmp(res->name, "crc-strip")) {
2064 if (!strcmp(res->value, "on")) {
2065 rx_offloads &= ~DEV_RX_OFFLOAD_KEEP_CRC;
2066 } else if (!strcmp(res->value, "off")) {
2067 rx_offloads |= DEV_RX_OFFLOAD_KEEP_CRC;
2069 printf("Unknown parameter\n");
2072 } else if (!strcmp(res->name, "scatter")) {
2073 if (!strcmp(res->value, "on")) {
2074 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
2075 } else if (!strcmp(res->value, "off")) {
2076 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
2078 printf("Unknown parameter\n");
2081 } else if (!strcmp(res->name, "rx-cksum")) {
2082 if (!strcmp(res->value, "on"))
2083 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
2084 else if (!strcmp(res->value, "off"))
2085 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
2087 printf("Unknown parameter\n");
2090 } else if (!strcmp(res->name, "rx-timestamp")) {
2091 if (!strcmp(res->value, "on"))
2092 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
2093 else if (!strcmp(res->value, "off"))
2094 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
2096 printf("Unknown parameter\n");
2099 } else if (!strcmp(res->name, "hw-vlan")) {
2100 if (!strcmp(res->value, "on")) {
2101 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
2102 DEV_RX_OFFLOAD_VLAN_STRIP);
2103 } else if (!strcmp(res->value, "off")) {
2104 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
2105 DEV_RX_OFFLOAD_VLAN_STRIP);
2107 printf("Unknown parameter\n");
2110 } else if (!strcmp(res->name, "hw-vlan-filter")) {
2111 if (!strcmp(res->value, "on"))
2112 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
2113 else if (!strcmp(res->value, "off"))
2114 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
2116 printf("Unknown parameter\n");
2119 } else if (!strcmp(res->name, "hw-vlan-strip")) {
2120 if (!strcmp(res->value, "on"))
2121 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
2122 else if (!strcmp(res->value, "off"))
2123 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
2125 printf("Unknown parameter\n");
2128 } else if (!strcmp(res->name, "hw-vlan-extend")) {
2129 if (!strcmp(res->value, "on"))
2130 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
2131 else if (!strcmp(res->value, "off"))
2132 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
2134 printf("Unknown parameter\n");
2137 } else if (!strcmp(res->name, "drop-en")) {
2138 if (!strcmp(res->value, "on"))
2140 else if (!strcmp(res->value, "off"))
2143 printf("Unknown parameter\n");
2147 printf("Unknown parameter\n");
2150 port->dev_conf.rxmode.offloads = rx_offloads;
2151 /* Apply Rx offloads configuration */
2152 for (k = 0; k < port->dev_info.max_rx_queues; k++)
2153 port->rx_conf[k].offloads =
2154 port->dev_conf.rxmode.offloads;
2159 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2162 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2163 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2164 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2165 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2167 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2168 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2169 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2170 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2171 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
2172 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
2173 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2174 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2177 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2178 .f = cmd_config_rx_mode_flag_parsed,
2180 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
2181 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
2183 (void *)&cmd_config_rx_mode_flag_port,
2184 (void *)&cmd_config_rx_mode_flag_keyword,
2185 (void *)&cmd_config_rx_mode_flag_all,
2186 (void *)&cmd_config_rx_mode_flag_name,
2187 (void *)&cmd_config_rx_mode_flag_value,
2192 /* *** configure rss *** */
2193 struct cmd_config_rss {
2194 cmdline_fixed_string_t port;
2195 cmdline_fixed_string_t keyword;
2196 cmdline_fixed_string_t all;
2197 cmdline_fixed_string_t name;
2198 cmdline_fixed_string_t value;
2202 cmd_config_rss_parsed(void *parsed_result,
2203 __attribute__((unused)) struct cmdline *cl,
2204 __attribute__((unused)) void *data)
2206 struct cmd_config_rss *res = parsed_result;
2207 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2208 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2209 int use_default = 0;
2210 int all_updated = 1;
2214 if (!strcmp(res->value, "all"))
2215 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2216 ETH_RSS_UDP | ETH_RSS_SCTP |
2218 else if (!strcmp(res->value, "ip"))
2219 rss_conf.rss_hf = ETH_RSS_IP;
2220 else if (!strcmp(res->value, "udp"))
2221 rss_conf.rss_hf = ETH_RSS_UDP;
2222 else if (!strcmp(res->value, "tcp"))
2223 rss_conf.rss_hf = ETH_RSS_TCP;
2224 else if (!strcmp(res->value, "sctp"))
2225 rss_conf.rss_hf = ETH_RSS_SCTP;
2226 else if (!strcmp(res->value, "ether"))
2227 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2228 else if (!strcmp(res->value, "port"))
2229 rss_conf.rss_hf = ETH_RSS_PORT;
2230 else if (!strcmp(res->value, "vxlan"))
2231 rss_conf.rss_hf = ETH_RSS_VXLAN;
2232 else if (!strcmp(res->value, "geneve"))
2233 rss_conf.rss_hf = ETH_RSS_GENEVE;
2234 else if (!strcmp(res->value, "nvgre"))
2235 rss_conf.rss_hf = ETH_RSS_NVGRE;
2236 else if (!strcmp(res->value, "none"))
2237 rss_conf.rss_hf = 0;
2238 else if (!strcmp(res->value, "default"))
2240 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2241 atoi(res->value) < 64)
2242 rss_conf.rss_hf = 1ULL << atoi(res->value);
2244 printf("Unknown parameter\n");
2247 rss_conf.rss_key = NULL;
2248 /* Update global configuration for RSS types. */
2249 RTE_ETH_FOREACH_DEV(i) {
2250 struct rte_eth_rss_conf local_rss_conf;
2252 rte_eth_dev_info_get(i, &dev_info);
2254 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2256 local_rss_conf = rss_conf;
2257 local_rss_conf.rss_hf = rss_conf.rss_hf &
2258 dev_info.flow_type_rss_offloads;
2259 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2260 printf("Port %u modified RSS hash function based on hardware support,"
2261 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2262 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2264 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2267 printf("Configuration of RSS hash at ethernet port %d "
2268 "failed with error (%d): %s.\n",
2269 i, -diag, strerror(-diag));
2272 if (all_updated && !use_default)
2273 rss_hf = rss_conf.rss_hf;
2276 cmdline_parse_token_string_t cmd_config_rss_port =
2277 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2278 cmdline_parse_token_string_t cmd_config_rss_keyword =
2279 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2280 cmdline_parse_token_string_t cmd_config_rss_all =
2281 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2282 cmdline_parse_token_string_t cmd_config_rss_name =
2283 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2284 cmdline_parse_token_string_t cmd_config_rss_value =
2285 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2287 cmdline_parse_inst_t cmd_config_rss = {
2288 .f = cmd_config_rss_parsed,
2290 .help_str = "port config all rss "
2291 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>",
2293 (void *)&cmd_config_rss_port,
2294 (void *)&cmd_config_rss_keyword,
2295 (void *)&cmd_config_rss_all,
2296 (void *)&cmd_config_rss_name,
2297 (void *)&cmd_config_rss_value,
2302 /* *** configure rss hash key *** */
2303 struct cmd_config_rss_hash_key {
2304 cmdline_fixed_string_t port;
2305 cmdline_fixed_string_t config;
2307 cmdline_fixed_string_t rss_hash_key;
2308 cmdline_fixed_string_t rss_type;
2309 cmdline_fixed_string_t key;
2313 hexa_digit_to_value(char hexa_digit)
2315 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2316 return (uint8_t) (hexa_digit - '0');
2317 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2318 return (uint8_t) ((hexa_digit - 'a') + 10);
2319 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2320 return (uint8_t) ((hexa_digit - 'A') + 10);
2321 /* Invalid hexa digit */
2326 parse_and_check_key_hexa_digit(char *key, int idx)
2330 hexa_v = hexa_digit_to_value(key[idx]);
2332 printf("invalid key: character %c at position %d is not a "
2333 "valid hexa digit\n", key[idx], idx);
2338 cmd_config_rss_hash_key_parsed(void *parsed_result,
2339 __attribute__((unused)) struct cmdline *cl,
2340 __attribute__((unused)) void *data)
2342 struct cmd_config_rss_hash_key *res = parsed_result;
2343 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2347 struct rte_eth_dev_info dev_info;
2348 uint8_t hash_key_size;
2351 memset(&dev_info, 0, sizeof(dev_info));
2352 rte_eth_dev_info_get(res->port_id, &dev_info);
2353 if (dev_info.hash_key_size > 0 &&
2354 dev_info.hash_key_size <= sizeof(hash_key))
2355 hash_key_size = dev_info.hash_key_size;
2357 printf("dev_info did not provide a valid hash key size\n");
2360 /* Check the length of the RSS hash key */
2361 key_len = strlen(res->key);
2362 if (key_len != (hash_key_size * 2)) {
2363 printf("key length: %d invalid - key must be a string of %d"
2364 " hexa-decimal numbers\n",
2365 (int) key_len, hash_key_size * 2);
2368 /* Translate RSS hash key into binary representation */
2369 for (i = 0; i < hash_key_size; i++) {
2370 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2373 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2376 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2378 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2382 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2383 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2384 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2385 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2387 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2388 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2389 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2390 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2391 rss_hash_key, "rss-hash-key");
2392 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2393 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2394 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2395 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2396 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2397 "ipv6-tcp-ex#ipv6-udp-ex");
2398 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2399 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2401 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2402 .f = cmd_config_rss_hash_key_parsed,
2404 .help_str = "port config <port_id> rss-hash-key "
2405 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2406 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2407 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2408 "<string of hex digits (variable length, NIC dependent)>",
2410 (void *)&cmd_config_rss_hash_key_port,
2411 (void *)&cmd_config_rss_hash_key_config,
2412 (void *)&cmd_config_rss_hash_key_port_id,
2413 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2414 (void *)&cmd_config_rss_hash_key_rss_type,
2415 (void *)&cmd_config_rss_hash_key_value,
2420 /* *** configure port rxq/txq ring size *** */
2421 struct cmd_config_rxtx_ring_size {
2422 cmdline_fixed_string_t port;
2423 cmdline_fixed_string_t config;
2425 cmdline_fixed_string_t rxtxq;
2427 cmdline_fixed_string_t rsize;
2432 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2433 __attribute__((unused)) struct cmdline *cl,
2434 __attribute__((unused)) void *data)
2436 struct cmd_config_rxtx_ring_size *res = parsed_result;
2437 struct rte_port *port;
2440 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2443 if (res->portid == (portid_t)RTE_PORT_ALL) {
2444 printf("Invalid port id\n");
2448 port = &ports[res->portid];
2450 if (!strcmp(res->rxtxq, "rxq"))
2452 else if (!strcmp(res->rxtxq, "txq"))
2455 printf("Unknown parameter\n");
2459 if (isrx && rx_queue_id_is_invalid(res->qid))
2461 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2464 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2465 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2471 port->nb_rx_desc[res->qid] = res->size;
2473 port->nb_tx_desc[res->qid] = res->size;
2475 cmd_reconfig_device_queue(res->portid, 0, 1);
2478 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2479 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2481 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2482 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2484 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2485 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2487 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2488 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2490 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2491 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2493 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2494 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2495 rsize, "ring_size");
2496 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2497 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2500 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2501 .f = cmd_config_rxtx_ring_size_parsed,
2503 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2505 (void *)&cmd_config_rxtx_ring_size_port,
2506 (void *)&cmd_config_rxtx_ring_size_config,
2507 (void *)&cmd_config_rxtx_ring_size_portid,
2508 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2509 (void *)&cmd_config_rxtx_ring_size_qid,
2510 (void *)&cmd_config_rxtx_ring_size_rsize,
2511 (void *)&cmd_config_rxtx_ring_size_size,
2516 /* *** configure port rxq/txq start/stop *** */
2517 struct cmd_config_rxtx_queue {
2518 cmdline_fixed_string_t port;
2520 cmdline_fixed_string_t rxtxq;
2522 cmdline_fixed_string_t opname;
2526 cmd_config_rxtx_queue_parsed(void *parsed_result,
2527 __attribute__((unused)) struct cmdline *cl,
2528 __attribute__((unused)) void *data)
2530 struct cmd_config_rxtx_queue *res = parsed_result;
2535 if (test_done == 0) {
2536 printf("Please stop forwarding first\n");
2540 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2543 if (port_is_started(res->portid) != 1) {
2544 printf("Please start port %u first\n", res->portid);
2548 if (!strcmp(res->rxtxq, "rxq"))
2550 else if (!strcmp(res->rxtxq, "txq"))
2553 printf("Unknown parameter\n");
2557 if (isrx && rx_queue_id_is_invalid(res->qid))
2559 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2562 if (!strcmp(res->opname, "start"))
2564 else if (!strcmp(res->opname, "stop"))
2567 printf("Unknown parameter\n");
2571 if (isstart && isrx)
2572 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2573 else if (!isstart && isrx)
2574 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2575 else if (isstart && !isrx)
2576 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2578 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2580 if (ret == -ENOTSUP)
2581 printf("Function not supported in PMD driver\n");
2584 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2585 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2586 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2587 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2588 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2589 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2590 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2591 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2592 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2593 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2596 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2597 .f = cmd_config_rxtx_queue_parsed,
2599 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2601 (void *)&cmd_config_rxtx_queue_port,
2602 (void *)&cmd_config_rxtx_queue_portid,
2603 (void *)&cmd_config_rxtx_queue_rxtxq,
2604 (void *)&cmd_config_rxtx_queue_qid,
2605 (void *)&cmd_config_rxtx_queue_opname,
2610 /* *** configure port rxq/txq deferred start on/off *** */
2611 struct cmd_config_deferred_start_rxtx_queue {
2612 cmdline_fixed_string_t port;
2614 cmdline_fixed_string_t rxtxq;
2616 cmdline_fixed_string_t opname;
2617 cmdline_fixed_string_t state;
2621 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2622 __attribute__((unused)) struct cmdline *cl,
2623 __attribute__((unused)) void *data)
2625 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2626 struct rte_port *port;
2629 uint8_t needreconfig = 0;
2631 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2634 if (port_is_started(res->port_id) != 0) {
2635 printf("Please stop port %u first\n", res->port_id);
2639 port = &ports[res->port_id];
2641 isrx = !strcmp(res->rxtxq, "rxq");
2643 if (isrx && rx_queue_id_is_invalid(res->qid))
2645 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2648 ison = !strcmp(res->state, "on");
2650 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2651 port->rx_conf[res->qid].rx_deferred_start = ison;
2653 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2654 port->tx_conf[res->qid].tx_deferred_start = ison;
2659 cmd_reconfig_device_queue(res->port_id, 0, 1);
2662 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2663 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2665 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2666 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2668 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2669 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2671 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2672 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2674 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2675 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2676 opname, "deferred_start");
2677 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2678 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2681 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2682 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2684 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2686 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2687 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2688 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2689 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2690 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2691 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2696 /* *** configure port rxq/txq setup *** */
2697 struct cmd_setup_rxtx_queue {
2698 cmdline_fixed_string_t port;
2700 cmdline_fixed_string_t rxtxq;
2702 cmdline_fixed_string_t setup;
2705 /* Common CLI fields for queue setup */
2706 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2707 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2708 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2709 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2710 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2711 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2712 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2713 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2714 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2715 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2718 cmd_setup_rxtx_queue_parsed(
2719 void *parsed_result,
2720 __attribute__((unused)) struct cmdline *cl,
2721 __attribute__((unused)) void *data)
2723 struct cmd_setup_rxtx_queue *res = parsed_result;
2724 struct rte_port *port;
2725 struct rte_mempool *mp;
2726 unsigned int socket_id;
2730 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2733 if (res->portid == (portid_t)RTE_PORT_ALL) {
2734 printf("Invalid port id\n");
2738 if (!strcmp(res->rxtxq, "rxq"))
2740 else if (!strcmp(res->rxtxq, "txq"))
2743 printf("Unknown parameter\n");
2747 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2748 printf("Invalid rx queue\n");
2750 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2751 printf("Invalid tx queue\n");
2755 port = &ports[res->portid];
2757 socket_id = rxring_numa[res->portid];
2758 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2759 socket_id = port->socket_id;
2761 mp = mbuf_pool_find(socket_id);
2763 printf("Failed to setup RX queue: "
2764 "No mempool allocation"
2765 " on the socket %d\n",
2766 rxring_numa[res->portid]);
2769 ret = rte_eth_rx_queue_setup(res->portid,
2771 port->nb_rx_desc[res->qid],
2773 &port->rx_conf[res->qid],
2776 printf("Failed to setup RX queue\n");
2778 socket_id = txring_numa[res->portid];
2779 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2780 socket_id = port->socket_id;
2782 ret = rte_eth_tx_queue_setup(res->portid,
2784 port->nb_tx_desc[res->qid],
2786 &port->tx_conf[res->qid]);
2788 printf("Failed to setup TX queue\n");
2792 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2793 .f = cmd_setup_rxtx_queue_parsed,
2795 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2797 (void *)&cmd_setup_rxtx_queue_port,
2798 (void *)&cmd_setup_rxtx_queue_portid,
2799 (void *)&cmd_setup_rxtx_queue_rxtxq,
2800 (void *)&cmd_setup_rxtx_queue_qid,
2801 (void *)&cmd_setup_rxtx_queue_setup,
2807 /* *** Configure RSS RETA *** */
2808 struct cmd_config_rss_reta {
2809 cmdline_fixed_string_t port;
2810 cmdline_fixed_string_t keyword;
2812 cmdline_fixed_string_t name;
2813 cmdline_fixed_string_t list_name;
2814 cmdline_fixed_string_t list_of_items;
2818 parse_reta_config(const char *str,
2819 struct rte_eth_rss_reta_entry64 *reta_conf,
2820 uint16_t nb_entries)
2824 uint16_t hash_index, idx, shift;
2827 const char *p, *p0 = str;
2834 unsigned long int_fld[_NUM_FLD];
2835 char *str_fld[_NUM_FLD];
2837 while ((p = strchr(p0,'(')) != NULL) {
2839 if((p0 = strchr(p,')')) == NULL)
2843 if(size >= sizeof(s))
2846 snprintf(s, sizeof(s), "%.*s", size, p);
2847 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2849 for (i = 0; i < _NUM_FLD; i++) {
2851 int_fld[i] = strtoul(str_fld[i], &end, 0);
2852 if (errno != 0 || end == str_fld[i] ||
2857 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2858 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2860 if (hash_index >= nb_entries) {
2861 printf("Invalid RETA hash index=%d\n", hash_index);
2865 idx = hash_index / RTE_RETA_GROUP_SIZE;
2866 shift = hash_index % RTE_RETA_GROUP_SIZE;
2867 reta_conf[idx].mask |= (1ULL << shift);
2868 reta_conf[idx].reta[shift] = nb_queue;
2875 cmd_set_rss_reta_parsed(void *parsed_result,
2876 __attribute__((unused)) struct cmdline *cl,
2877 __attribute__((unused)) void *data)
2880 struct rte_eth_dev_info dev_info;
2881 struct rte_eth_rss_reta_entry64 reta_conf[8];
2882 struct cmd_config_rss_reta *res = parsed_result;
2884 memset(&dev_info, 0, sizeof(dev_info));
2885 rte_eth_dev_info_get(res->port_id, &dev_info);
2886 if (dev_info.reta_size == 0) {
2887 printf("Redirection table size is 0 which is "
2888 "invalid for RSS\n");
2891 printf("The reta size of port %d is %u\n",
2892 res->port_id, dev_info.reta_size);
2893 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2894 printf("Currently do not support more than %u entries of "
2895 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2899 memset(reta_conf, 0, sizeof(reta_conf));
2900 if (!strcmp(res->list_name, "reta")) {
2901 if (parse_reta_config(res->list_of_items, reta_conf,
2902 dev_info.reta_size)) {
2903 printf("Invalid RSS Redirection Table "
2904 "config entered\n");
2907 ret = rte_eth_dev_rss_reta_update(res->port_id,
2908 reta_conf, dev_info.reta_size);
2910 printf("Bad redirection table parameter, "
2911 "return code = %d \n", ret);
2915 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2916 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2917 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2918 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2919 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2920 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2921 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2922 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2923 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2924 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2925 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2926 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2928 cmdline_parse_inst_t cmd_config_rss_reta = {
2929 .f = cmd_set_rss_reta_parsed,
2931 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2933 (void *)&cmd_config_rss_reta_port,
2934 (void *)&cmd_config_rss_reta_keyword,
2935 (void *)&cmd_config_rss_reta_port_id,
2936 (void *)&cmd_config_rss_reta_name,
2937 (void *)&cmd_config_rss_reta_list_name,
2938 (void *)&cmd_config_rss_reta_list_of_items,
2943 /* *** SHOW PORT RETA INFO *** */
2944 struct cmd_showport_reta {
2945 cmdline_fixed_string_t show;
2946 cmdline_fixed_string_t port;
2948 cmdline_fixed_string_t rss;
2949 cmdline_fixed_string_t reta;
2951 cmdline_fixed_string_t list_of_items;
2955 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2956 uint16_t nb_entries,
2960 const char *p, *p0 = str;
2965 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2966 RTE_RETA_GROUP_SIZE;
2969 p = strchr(p0, '(');
2973 p0 = strchr(p, ')');
2977 if (size >= sizeof(s)) {
2978 printf("The string size exceeds the internal buffer size\n");
2981 snprintf(s, sizeof(s), "%.*s", size, p);
2982 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2983 if (ret <= 0 || ret != num) {
2984 printf("The bits of masks do not match the number of "
2985 "reta entries: %u\n", num);
2988 for (i = 0; i < ret; i++)
2989 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2995 cmd_showport_reta_parsed(void *parsed_result,
2996 __attribute__((unused)) struct cmdline *cl,
2997 __attribute__((unused)) void *data)
2999 struct cmd_showport_reta *res = parsed_result;
3000 struct rte_eth_rss_reta_entry64 reta_conf[8];
3001 struct rte_eth_dev_info dev_info;
3002 uint16_t max_reta_size;
3004 memset(&dev_info, 0, sizeof(dev_info));
3005 rte_eth_dev_info_get(res->port_id, &dev_info);
3006 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3007 if (res->size == 0 || res->size > max_reta_size) {
3008 printf("Invalid redirection table size: %u (1-%u)\n",
3009 res->size, max_reta_size);
3013 memset(reta_conf, 0, sizeof(reta_conf));
3014 if (showport_parse_reta_config(reta_conf, res->size,
3015 res->list_of_items) < 0) {
3016 printf("Invalid string: %s for reta masks\n",
3017 res->list_of_items);
3020 port_rss_reta_info(res->port_id, reta_conf, res->size);
3023 cmdline_parse_token_string_t cmd_showport_reta_show =
3024 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3025 cmdline_parse_token_string_t cmd_showport_reta_port =
3026 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3027 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3028 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3029 cmdline_parse_token_string_t cmd_showport_reta_rss =
3030 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3031 cmdline_parse_token_string_t cmd_showport_reta_reta =
3032 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3033 cmdline_parse_token_num_t cmd_showport_reta_size =
3034 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3035 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3036 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3037 list_of_items, NULL);
3039 cmdline_parse_inst_t cmd_showport_reta = {
3040 .f = cmd_showport_reta_parsed,
3042 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3044 (void *)&cmd_showport_reta_show,
3045 (void *)&cmd_showport_reta_port,
3046 (void *)&cmd_showport_reta_port_id,
3047 (void *)&cmd_showport_reta_rss,
3048 (void *)&cmd_showport_reta_reta,
3049 (void *)&cmd_showport_reta_size,
3050 (void *)&cmd_showport_reta_list_of_items,
3055 /* *** Show RSS hash configuration *** */
3056 struct cmd_showport_rss_hash {
3057 cmdline_fixed_string_t show;
3058 cmdline_fixed_string_t port;
3060 cmdline_fixed_string_t rss_hash;
3061 cmdline_fixed_string_t rss_type;
3062 cmdline_fixed_string_t key; /* optional argument */
3065 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3066 __attribute__((unused)) struct cmdline *cl,
3069 struct cmd_showport_rss_hash *res = parsed_result;
3071 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3074 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3075 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3076 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3077 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3078 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3079 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3080 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3081 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3083 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3084 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3086 cmdline_parse_inst_t cmd_showport_rss_hash = {
3087 .f = cmd_showport_rss_hash_parsed,
3089 .help_str = "show port <port_id> rss-hash",
3091 (void *)&cmd_showport_rss_hash_show,
3092 (void *)&cmd_showport_rss_hash_port,
3093 (void *)&cmd_showport_rss_hash_port_id,
3094 (void *)&cmd_showport_rss_hash_rss_hash,
3099 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3100 .f = cmd_showport_rss_hash_parsed,
3102 .help_str = "show port <port_id> rss-hash key",
3104 (void *)&cmd_showport_rss_hash_show,
3105 (void *)&cmd_showport_rss_hash_port,
3106 (void *)&cmd_showport_rss_hash_port_id,
3107 (void *)&cmd_showport_rss_hash_rss_hash,
3108 (void *)&cmd_showport_rss_hash_rss_key,
3113 /* *** Configure DCB *** */
3114 struct cmd_config_dcb {
3115 cmdline_fixed_string_t port;
3116 cmdline_fixed_string_t config;
3118 cmdline_fixed_string_t dcb;
3119 cmdline_fixed_string_t vt;
3120 cmdline_fixed_string_t vt_en;
3122 cmdline_fixed_string_t pfc;
3123 cmdline_fixed_string_t pfc_en;
3127 cmd_config_dcb_parsed(void *parsed_result,
3128 __attribute__((unused)) struct cmdline *cl,
3129 __attribute__((unused)) void *data)
3131 struct cmd_config_dcb *res = parsed_result;
3132 portid_t port_id = res->port_id;
3133 struct rte_port *port;
3137 port = &ports[port_id];
3138 /** Check if the port is not started **/
3139 if (port->port_status != RTE_PORT_STOPPED) {
3140 printf("Please stop port %d first\n", port_id);
3144 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3145 printf("The invalid number of traffic class,"
3146 " only 4 or 8 allowed.\n");
3150 if (nb_fwd_lcores < res->num_tcs) {
3151 printf("nb_cores shouldn't be less than number of TCs.\n");
3154 if (!strncmp(res->pfc_en, "on", 2))
3159 /* DCB in VT mode */
3160 if (!strncmp(res->vt_en, "on", 2))
3161 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3162 (enum rte_eth_nb_tcs)res->num_tcs,
3165 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3166 (enum rte_eth_nb_tcs)res->num_tcs,
3171 printf("Cannot initialize network ports.\n");
3175 cmd_reconfig_device_queue(port_id, 1, 1);
3178 cmdline_parse_token_string_t cmd_config_dcb_port =
3179 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3180 cmdline_parse_token_string_t cmd_config_dcb_config =
3181 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3182 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3183 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3184 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3185 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3186 cmdline_parse_token_string_t cmd_config_dcb_vt =
3187 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3188 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3189 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3190 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3191 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3192 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3193 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3194 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3195 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3197 cmdline_parse_inst_t cmd_config_dcb = {
3198 .f = cmd_config_dcb_parsed,
3200 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3202 (void *)&cmd_config_dcb_port,
3203 (void *)&cmd_config_dcb_config,
3204 (void *)&cmd_config_dcb_port_id,
3205 (void *)&cmd_config_dcb_dcb,
3206 (void *)&cmd_config_dcb_vt,
3207 (void *)&cmd_config_dcb_vt_en,
3208 (void *)&cmd_config_dcb_num_tcs,
3209 (void *)&cmd_config_dcb_pfc,
3210 (void *)&cmd_config_dcb_pfc_en,
3215 /* *** configure number of packets per burst *** */
3216 struct cmd_config_burst {
3217 cmdline_fixed_string_t port;
3218 cmdline_fixed_string_t keyword;
3219 cmdline_fixed_string_t all;
3220 cmdline_fixed_string_t name;
3225 cmd_config_burst_parsed(void *parsed_result,
3226 __attribute__((unused)) struct cmdline *cl,
3227 __attribute__((unused)) void *data)
3229 struct cmd_config_burst *res = parsed_result;
3230 struct rte_eth_dev_info dev_info;
3231 uint16_t rec_nb_pkts;
3233 if (!all_ports_stopped()) {
3234 printf("Please stop all ports first\n");
3238 if (!strcmp(res->name, "burst")) {
3239 if (res->value == 0) {
3240 /* If user gives a value of zero, query the PMD for
3241 * its recommended Rx burst size. Testpmd uses a single
3242 * size for all ports, so assume all ports are the same
3243 * NIC model and use the values from Port 0.
3245 rte_eth_dev_info_get(0, &dev_info);
3246 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3248 if (rec_nb_pkts == 0) {
3249 printf("PMD does not recommend a burst size.\n"
3250 "User provided value must be between"
3251 " 1 and %d\n", MAX_PKT_BURST);
3253 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3254 printf("PMD recommended burst size of %d"
3255 " exceeds maximum value of %d\n",
3256 rec_nb_pkts, MAX_PKT_BURST);
3259 printf("Using PMD-provided burst value of %d\n",
3261 nb_pkt_per_burst = rec_nb_pkts;
3262 } else if (res->value > MAX_PKT_BURST) {
3263 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3266 nb_pkt_per_burst = res->value;
3268 printf("Unknown parameter\n");
3274 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3277 cmdline_parse_token_string_t cmd_config_burst_port =
3278 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3279 cmdline_parse_token_string_t cmd_config_burst_keyword =
3280 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3281 cmdline_parse_token_string_t cmd_config_burst_all =
3282 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3283 cmdline_parse_token_string_t cmd_config_burst_name =
3284 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3285 cmdline_parse_token_num_t cmd_config_burst_value =
3286 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3288 cmdline_parse_inst_t cmd_config_burst = {
3289 .f = cmd_config_burst_parsed,
3291 .help_str = "port config all burst <value>",
3293 (void *)&cmd_config_burst_port,
3294 (void *)&cmd_config_burst_keyword,
3295 (void *)&cmd_config_burst_all,
3296 (void *)&cmd_config_burst_name,
3297 (void *)&cmd_config_burst_value,
3302 /* *** configure rx/tx queues *** */
3303 struct cmd_config_thresh {
3304 cmdline_fixed_string_t port;
3305 cmdline_fixed_string_t keyword;
3306 cmdline_fixed_string_t all;
3307 cmdline_fixed_string_t name;
3312 cmd_config_thresh_parsed(void *parsed_result,
3313 __attribute__((unused)) struct cmdline *cl,
3314 __attribute__((unused)) void *data)
3316 struct cmd_config_thresh *res = parsed_result;
3318 if (!all_ports_stopped()) {
3319 printf("Please stop all ports first\n");
3323 if (!strcmp(res->name, "txpt"))
3324 tx_pthresh = res->value;
3325 else if(!strcmp(res->name, "txht"))
3326 tx_hthresh = res->value;
3327 else if(!strcmp(res->name, "txwt"))
3328 tx_wthresh = res->value;
3329 else if(!strcmp(res->name, "rxpt"))
3330 rx_pthresh = res->value;
3331 else if(!strcmp(res->name, "rxht"))
3332 rx_hthresh = res->value;
3333 else if(!strcmp(res->name, "rxwt"))
3334 rx_wthresh = res->value;
3336 printf("Unknown parameter\n");
3342 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3345 cmdline_parse_token_string_t cmd_config_thresh_port =
3346 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3347 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3348 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3349 cmdline_parse_token_string_t cmd_config_thresh_all =
3350 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3351 cmdline_parse_token_string_t cmd_config_thresh_name =
3352 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3353 "txpt#txht#txwt#rxpt#rxht#rxwt");
3354 cmdline_parse_token_num_t cmd_config_thresh_value =
3355 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3357 cmdline_parse_inst_t cmd_config_thresh = {
3358 .f = cmd_config_thresh_parsed,
3360 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3362 (void *)&cmd_config_thresh_port,
3363 (void *)&cmd_config_thresh_keyword,
3364 (void *)&cmd_config_thresh_all,
3365 (void *)&cmd_config_thresh_name,
3366 (void *)&cmd_config_thresh_value,
3371 /* *** configure free/rs threshold *** */
3372 struct cmd_config_threshold {
3373 cmdline_fixed_string_t port;
3374 cmdline_fixed_string_t keyword;
3375 cmdline_fixed_string_t all;
3376 cmdline_fixed_string_t name;
3381 cmd_config_threshold_parsed(void *parsed_result,
3382 __attribute__((unused)) struct cmdline *cl,
3383 __attribute__((unused)) void *data)
3385 struct cmd_config_threshold *res = parsed_result;
3387 if (!all_ports_stopped()) {
3388 printf("Please stop all ports first\n");
3392 if (!strcmp(res->name, "txfreet"))
3393 tx_free_thresh = res->value;
3394 else if (!strcmp(res->name, "txrst"))
3395 tx_rs_thresh = res->value;
3396 else if (!strcmp(res->name, "rxfreet"))
3397 rx_free_thresh = res->value;
3399 printf("Unknown parameter\n");
3405 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3408 cmdline_parse_token_string_t cmd_config_threshold_port =
3409 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3410 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3411 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3413 cmdline_parse_token_string_t cmd_config_threshold_all =
3414 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3415 cmdline_parse_token_string_t cmd_config_threshold_name =
3416 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3417 "txfreet#txrst#rxfreet");
3418 cmdline_parse_token_num_t cmd_config_threshold_value =
3419 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3421 cmdline_parse_inst_t cmd_config_threshold = {
3422 .f = cmd_config_threshold_parsed,
3424 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3426 (void *)&cmd_config_threshold_port,
3427 (void *)&cmd_config_threshold_keyword,
3428 (void *)&cmd_config_threshold_all,
3429 (void *)&cmd_config_threshold_name,
3430 (void *)&cmd_config_threshold_value,
3436 struct cmd_stop_result {
3437 cmdline_fixed_string_t stop;
3440 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3441 __attribute__((unused)) struct cmdline *cl,
3442 __attribute__((unused)) void *data)
3444 stop_packet_forwarding();
3447 cmdline_parse_token_string_t cmd_stop_stop =
3448 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3450 cmdline_parse_inst_t cmd_stop = {
3451 .f = cmd_stop_parsed,
3453 .help_str = "stop: Stop packet forwarding",
3455 (void *)&cmd_stop_stop,
3460 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3463 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3464 unsigned int *parsed_items, int check_unique_values)
3466 unsigned int nb_item;
3474 * First parse all items in the list and store their value.
3479 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3481 if ((c >= '0') && (c <= '9')) {
3482 value = (unsigned int) (value * 10 + (c - '0'));
3487 printf("character %c is not a decimal digit\n", c);
3491 printf("No valid value before comma\n");
3494 if (nb_item < max_items) {
3495 parsed_items[nb_item] = value;
3501 if (nb_item >= max_items) {
3502 printf("Number of %s = %u > %u (maximum items)\n",
3503 item_name, nb_item + 1, max_items);
3506 parsed_items[nb_item++] = value;
3507 if (! check_unique_values)
3511 * Then, check that all values in the list are differents.
3512 * No optimization here...
3514 for (i = 0; i < nb_item; i++) {
3515 for (j = i + 1; j < nb_item; j++) {
3516 if (parsed_items[j] == parsed_items[i]) {
3517 printf("duplicated %s %u at index %u and %u\n",
3518 item_name, parsed_items[i], i, j);
3526 struct cmd_set_list_result {
3527 cmdline_fixed_string_t cmd_keyword;
3528 cmdline_fixed_string_t list_name;
3529 cmdline_fixed_string_t list_of_items;
3532 static void cmd_set_list_parsed(void *parsed_result,
3533 __attribute__((unused)) struct cmdline *cl,
3534 __attribute__((unused)) void *data)
3536 struct cmd_set_list_result *res;
3538 unsigned int lcorelist[RTE_MAX_LCORE];
3539 unsigned int portlist[RTE_MAX_ETHPORTS];
3541 unsigned int nb_item;
3543 if (test_done == 0) {
3544 printf("Please stop forwarding first\n");
3548 res = parsed_result;
3549 if (!strcmp(res->list_name, "corelist")) {
3550 nb_item = parse_item_list(res->list_of_items, "core",
3552 parsed_items.lcorelist, 1);
3554 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3559 if (!strcmp(res->list_name, "portlist")) {
3560 nb_item = parse_item_list(res->list_of_items, "port",
3562 parsed_items.portlist, 1);
3564 set_fwd_ports_list(parsed_items.portlist, nb_item);
3570 cmdline_parse_token_string_t cmd_set_list_keyword =
3571 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3573 cmdline_parse_token_string_t cmd_set_list_name =
3574 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3575 "corelist#portlist");
3576 cmdline_parse_token_string_t cmd_set_list_of_items =
3577 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3580 cmdline_parse_inst_t cmd_set_fwd_list = {
3581 .f = cmd_set_list_parsed,
3583 .help_str = "set corelist|portlist <list0[,list1]*>",
3585 (void *)&cmd_set_list_keyword,
3586 (void *)&cmd_set_list_name,
3587 (void *)&cmd_set_list_of_items,
3592 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3594 struct cmd_setmask_result {
3595 cmdline_fixed_string_t set;
3596 cmdline_fixed_string_t mask;
3600 static void cmd_set_mask_parsed(void *parsed_result,
3601 __attribute__((unused)) struct cmdline *cl,
3602 __attribute__((unused)) void *data)
3604 struct cmd_setmask_result *res = parsed_result;
3606 if (test_done == 0) {
3607 printf("Please stop forwarding first\n");
3610 if (!strcmp(res->mask, "coremask")) {
3611 set_fwd_lcores_mask(res->hexavalue);
3613 } else if (!strcmp(res->mask, "portmask")) {
3614 set_fwd_ports_mask(res->hexavalue);
3619 cmdline_parse_token_string_t cmd_setmask_set =
3620 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3621 cmdline_parse_token_string_t cmd_setmask_mask =
3622 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3623 "coremask#portmask");
3624 cmdline_parse_token_num_t cmd_setmask_value =
3625 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3627 cmdline_parse_inst_t cmd_set_fwd_mask = {
3628 .f = cmd_set_mask_parsed,
3630 .help_str = "set coremask|portmask <hexadecimal value>",
3632 (void *)&cmd_setmask_set,
3633 (void *)&cmd_setmask_mask,
3634 (void *)&cmd_setmask_value,
3640 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3642 struct cmd_set_result {
3643 cmdline_fixed_string_t set;
3644 cmdline_fixed_string_t what;
3648 static void cmd_set_parsed(void *parsed_result,
3649 __attribute__((unused)) struct cmdline *cl,
3650 __attribute__((unused)) void *data)
3652 struct cmd_set_result *res = parsed_result;
3653 if (!strcmp(res->what, "nbport")) {
3654 set_fwd_ports_number(res->value);
3656 } else if (!strcmp(res->what, "nbcore")) {
3657 set_fwd_lcores_number(res->value);
3659 } else if (!strcmp(res->what, "burst"))
3660 set_nb_pkt_per_burst(res->value);
3661 else if (!strcmp(res->what, "verbose"))
3662 set_verbose_level(res->value);
3665 cmdline_parse_token_string_t cmd_set_set =
3666 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3667 cmdline_parse_token_string_t cmd_set_what =
3668 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3669 "nbport#nbcore#burst#verbose");
3670 cmdline_parse_token_num_t cmd_set_value =
3671 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3673 cmdline_parse_inst_t cmd_set_numbers = {
3674 .f = cmd_set_parsed,
3676 .help_str = "set nbport|nbcore|burst|verbose <value>",
3678 (void *)&cmd_set_set,
3679 (void *)&cmd_set_what,
3680 (void *)&cmd_set_value,
3685 /* *** SET LOG LEVEL CONFIGURATION *** */
3687 struct cmd_set_log_result {
3688 cmdline_fixed_string_t set;
3689 cmdline_fixed_string_t log;
3690 cmdline_fixed_string_t type;
3695 cmd_set_log_parsed(void *parsed_result,
3696 __attribute__((unused)) struct cmdline *cl,
3697 __attribute__((unused)) void *data)
3699 struct cmd_set_log_result *res;
3702 res = parsed_result;
3703 if (!strcmp(res->type, "global"))
3704 rte_log_set_global_level(res->level);
3706 ret = rte_log_set_level_regexp(res->type, res->level);
3708 printf("Unable to set log level\n");
3712 cmdline_parse_token_string_t cmd_set_log_set =
3713 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3714 cmdline_parse_token_string_t cmd_set_log_log =
3715 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3716 cmdline_parse_token_string_t cmd_set_log_type =
3717 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3718 cmdline_parse_token_num_t cmd_set_log_level =
3719 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3721 cmdline_parse_inst_t cmd_set_log = {
3722 .f = cmd_set_log_parsed,
3724 .help_str = "set log global|<type> <level>",
3726 (void *)&cmd_set_log_set,
3727 (void *)&cmd_set_log_log,
3728 (void *)&cmd_set_log_type,
3729 (void *)&cmd_set_log_level,
3734 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3736 struct cmd_set_txpkts_result {
3737 cmdline_fixed_string_t cmd_keyword;
3738 cmdline_fixed_string_t txpkts;
3739 cmdline_fixed_string_t seg_lengths;
3743 cmd_set_txpkts_parsed(void *parsed_result,
3744 __attribute__((unused)) struct cmdline *cl,
3745 __attribute__((unused)) void *data)
3747 struct cmd_set_txpkts_result *res;
3748 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3749 unsigned int nb_segs;
3751 res = parsed_result;
3752 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3753 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3755 set_tx_pkt_segments(seg_lengths, nb_segs);
3758 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3759 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3760 cmd_keyword, "set");
3761 cmdline_parse_token_string_t cmd_set_txpkts_name =
3762 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3764 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3765 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3768 cmdline_parse_inst_t cmd_set_txpkts = {
3769 .f = cmd_set_txpkts_parsed,
3771 .help_str = "set txpkts <len0[,len1]*>",
3773 (void *)&cmd_set_txpkts_keyword,
3774 (void *)&cmd_set_txpkts_name,
3775 (void *)&cmd_set_txpkts_lengths,
3780 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3782 struct cmd_set_txsplit_result {
3783 cmdline_fixed_string_t cmd_keyword;
3784 cmdline_fixed_string_t txsplit;
3785 cmdline_fixed_string_t mode;
3789 cmd_set_txsplit_parsed(void *parsed_result,
3790 __attribute__((unused)) struct cmdline *cl,
3791 __attribute__((unused)) void *data)
3793 struct cmd_set_txsplit_result *res;
3795 res = parsed_result;
3796 set_tx_pkt_split(res->mode);
3799 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3800 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3801 cmd_keyword, "set");
3802 cmdline_parse_token_string_t cmd_set_txsplit_name =
3803 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3804 txsplit, "txsplit");
3805 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3806 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3809 cmdline_parse_inst_t cmd_set_txsplit = {
3810 .f = cmd_set_txsplit_parsed,
3812 .help_str = "set txsplit on|off|rand",
3814 (void *)&cmd_set_txsplit_keyword,
3815 (void *)&cmd_set_txsplit_name,
3816 (void *)&cmd_set_txsplit_mode,
3821 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3822 struct cmd_rx_vlan_filter_all_result {
3823 cmdline_fixed_string_t rx_vlan;
3824 cmdline_fixed_string_t what;
3825 cmdline_fixed_string_t all;
3830 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3831 __attribute__((unused)) struct cmdline *cl,
3832 __attribute__((unused)) void *data)
3834 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3836 if (!strcmp(res->what, "add"))
3837 rx_vlan_all_filter_set(res->port_id, 1);
3839 rx_vlan_all_filter_set(res->port_id, 0);
3842 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3843 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3844 rx_vlan, "rx_vlan");
3845 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3846 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3848 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3849 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3851 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3852 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3855 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3856 .f = cmd_rx_vlan_filter_all_parsed,
3858 .help_str = "rx_vlan add|rm all <port_id>: "
3859 "Add/Remove all identifiers to/from the set of VLAN "
3860 "identifiers filtered by a port",
3862 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3863 (void *)&cmd_rx_vlan_filter_all_what,
3864 (void *)&cmd_rx_vlan_filter_all_all,
3865 (void *)&cmd_rx_vlan_filter_all_portid,
3870 /* *** VLAN OFFLOAD SET ON A PORT *** */
3871 struct cmd_vlan_offload_result {
3872 cmdline_fixed_string_t vlan;
3873 cmdline_fixed_string_t set;
3874 cmdline_fixed_string_t vlan_type;
3875 cmdline_fixed_string_t what;
3876 cmdline_fixed_string_t on;
3877 cmdline_fixed_string_t port_id;
3881 cmd_vlan_offload_parsed(void *parsed_result,
3882 __attribute__((unused)) struct cmdline *cl,
3883 __attribute__((unused)) void *data)
3886 struct cmd_vlan_offload_result *res = parsed_result;
3889 portid_t port_id = 0;
3893 len = strnlen(str, STR_TOKEN_SIZE);
3895 /* Get port_id first */
3903 tmp = strtoul(str, NULL, 0);
3904 /* If port_id greater that what portid_t can represent, return */
3905 if(tmp >= RTE_MAX_ETHPORTS)
3907 port_id = (portid_t)tmp;
3909 if (!strcmp(res->on, "on"))
3914 if (!strcmp(res->what, "strip"))
3915 rx_vlan_strip_set(port_id, on);
3916 else if(!strcmp(res->what, "stripq")){
3917 uint16_t queue_id = 0;
3919 /* No queue_id, return */
3921 printf("must specify (port,queue_id)\n");
3924 tmp = strtoul(str + i + 1, NULL, 0);
3925 /* If queue_id greater that what 16-bits can represent, return */
3929 queue_id = (uint16_t)tmp;
3930 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3932 else if (!strcmp(res->what, "filter"))
3933 rx_vlan_filter_set(port_id, on);
3935 vlan_extend_set(port_id, on);
3940 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3941 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3943 cmdline_parse_token_string_t cmd_vlan_offload_set =
3944 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3946 cmdline_parse_token_string_t cmd_vlan_offload_what =
3947 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3948 what, "strip#filter#qinq#stripq");
3949 cmdline_parse_token_string_t cmd_vlan_offload_on =
3950 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3952 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3953 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3956 cmdline_parse_inst_t cmd_vlan_offload = {
3957 .f = cmd_vlan_offload_parsed,
3959 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3960 "<port_id[,queue_id]>: "
3961 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3963 (void *)&cmd_vlan_offload_vlan,
3964 (void *)&cmd_vlan_offload_set,
3965 (void *)&cmd_vlan_offload_what,
3966 (void *)&cmd_vlan_offload_on,
3967 (void *)&cmd_vlan_offload_portid,
3972 /* *** VLAN TPID SET ON A PORT *** */
3973 struct cmd_vlan_tpid_result {
3974 cmdline_fixed_string_t vlan;
3975 cmdline_fixed_string_t set;
3976 cmdline_fixed_string_t vlan_type;
3977 cmdline_fixed_string_t what;
3983 cmd_vlan_tpid_parsed(void *parsed_result,
3984 __attribute__((unused)) struct cmdline *cl,
3985 __attribute__((unused)) void *data)
3987 struct cmd_vlan_tpid_result *res = parsed_result;
3988 enum rte_vlan_type vlan_type;
3990 if (!strcmp(res->vlan_type, "inner"))
3991 vlan_type = ETH_VLAN_TYPE_INNER;
3992 else if (!strcmp(res->vlan_type, "outer"))
3993 vlan_type = ETH_VLAN_TYPE_OUTER;
3995 printf("Unknown vlan type\n");
3998 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4001 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4002 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4004 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4005 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4007 cmdline_parse_token_string_t cmd_vlan_type =
4008 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4009 vlan_type, "inner#outer");
4010 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4011 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4013 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4014 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4016 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4017 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4020 cmdline_parse_inst_t cmd_vlan_tpid = {
4021 .f = cmd_vlan_tpid_parsed,
4023 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4024 "Set the VLAN Ether type",
4026 (void *)&cmd_vlan_tpid_vlan,
4027 (void *)&cmd_vlan_tpid_set,
4028 (void *)&cmd_vlan_type,
4029 (void *)&cmd_vlan_tpid_what,
4030 (void *)&cmd_vlan_tpid_tpid,
4031 (void *)&cmd_vlan_tpid_portid,
4036 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4037 struct cmd_rx_vlan_filter_result {
4038 cmdline_fixed_string_t rx_vlan;
4039 cmdline_fixed_string_t what;
4045 cmd_rx_vlan_filter_parsed(void *parsed_result,
4046 __attribute__((unused)) struct cmdline *cl,
4047 __attribute__((unused)) void *data)
4049 struct cmd_rx_vlan_filter_result *res = parsed_result;
4051 if (!strcmp(res->what, "add"))
4052 rx_vft_set(res->port_id, res->vlan_id, 1);
4054 rx_vft_set(res->port_id, res->vlan_id, 0);
4057 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4058 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4059 rx_vlan, "rx_vlan");
4060 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4061 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4063 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4064 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4066 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4067 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4070 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4071 .f = cmd_rx_vlan_filter_parsed,
4073 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4074 "Add/Remove a VLAN identifier to/from the set of VLAN "
4075 "identifiers filtered by a port",
4077 (void *)&cmd_rx_vlan_filter_rx_vlan,
4078 (void *)&cmd_rx_vlan_filter_what,
4079 (void *)&cmd_rx_vlan_filter_vlanid,
4080 (void *)&cmd_rx_vlan_filter_portid,
4085 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4086 struct cmd_tx_vlan_set_result {
4087 cmdline_fixed_string_t tx_vlan;
4088 cmdline_fixed_string_t set;
4094 cmd_tx_vlan_set_parsed(void *parsed_result,
4095 __attribute__((unused)) struct cmdline *cl,
4096 __attribute__((unused)) void *data)
4098 struct cmd_tx_vlan_set_result *res = parsed_result;
4100 if (!port_is_stopped(res->port_id)) {
4101 printf("Please stop port %d first\n", res->port_id);
4105 tx_vlan_set(res->port_id, res->vlan_id);
4107 cmd_reconfig_device_queue(res->port_id, 1, 1);
4110 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4111 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4112 tx_vlan, "tx_vlan");
4113 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4114 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4116 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4117 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4119 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4120 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4123 cmdline_parse_inst_t cmd_tx_vlan_set = {
4124 .f = cmd_tx_vlan_set_parsed,
4126 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4127 "Enable hardware insertion of a single VLAN header "
4128 "with a given TAG Identifier in packets sent on a port",
4130 (void *)&cmd_tx_vlan_set_tx_vlan,
4131 (void *)&cmd_tx_vlan_set_set,
4132 (void *)&cmd_tx_vlan_set_portid,
4133 (void *)&cmd_tx_vlan_set_vlanid,
4138 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4139 struct cmd_tx_vlan_set_qinq_result {
4140 cmdline_fixed_string_t tx_vlan;
4141 cmdline_fixed_string_t set;
4144 uint16_t vlan_id_outer;
4148 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4149 __attribute__((unused)) struct cmdline *cl,
4150 __attribute__((unused)) void *data)
4152 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4154 if (!port_is_stopped(res->port_id)) {
4155 printf("Please stop port %d first\n", res->port_id);
4159 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4161 cmd_reconfig_device_queue(res->port_id, 1, 1);
4164 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4165 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4166 tx_vlan, "tx_vlan");
4167 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4168 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4170 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4171 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4173 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4174 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4176 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4177 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4178 vlan_id_outer, UINT16);
4180 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4181 .f = cmd_tx_vlan_set_qinq_parsed,
4183 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4184 "Enable hardware insertion of double VLAN header "
4185 "with given TAG Identifiers in packets sent on a port",
4187 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4188 (void *)&cmd_tx_vlan_set_qinq_set,
4189 (void *)&cmd_tx_vlan_set_qinq_portid,
4190 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4191 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4196 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4197 struct cmd_tx_vlan_set_pvid_result {
4198 cmdline_fixed_string_t tx_vlan;
4199 cmdline_fixed_string_t set;
4200 cmdline_fixed_string_t pvid;
4203 cmdline_fixed_string_t mode;
4207 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4208 __attribute__((unused)) struct cmdline *cl,
4209 __attribute__((unused)) void *data)
4211 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4213 if (strcmp(res->mode, "on") == 0)
4214 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4216 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4219 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4220 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4221 tx_vlan, "tx_vlan");
4222 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4223 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4225 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4226 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4228 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4229 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4231 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4232 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4234 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4235 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4238 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4239 .f = cmd_tx_vlan_set_pvid_parsed,
4241 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4243 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4244 (void *)&cmd_tx_vlan_set_pvid_set,
4245 (void *)&cmd_tx_vlan_set_pvid_pvid,
4246 (void *)&cmd_tx_vlan_set_pvid_port_id,
4247 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4248 (void *)&cmd_tx_vlan_set_pvid_mode,
4253 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4254 struct cmd_tx_vlan_reset_result {
4255 cmdline_fixed_string_t tx_vlan;
4256 cmdline_fixed_string_t reset;
4261 cmd_tx_vlan_reset_parsed(void *parsed_result,
4262 __attribute__((unused)) struct cmdline *cl,
4263 __attribute__((unused)) void *data)
4265 struct cmd_tx_vlan_reset_result *res = parsed_result;
4267 if (!port_is_stopped(res->port_id)) {
4268 printf("Please stop port %d first\n", res->port_id);
4272 tx_vlan_reset(res->port_id);
4274 cmd_reconfig_device_queue(res->port_id, 1, 1);
4277 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4278 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4279 tx_vlan, "tx_vlan");
4280 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4281 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4283 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4284 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4287 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4288 .f = cmd_tx_vlan_reset_parsed,
4290 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4291 "VLAN header in packets sent on a port",
4293 (void *)&cmd_tx_vlan_reset_tx_vlan,
4294 (void *)&cmd_tx_vlan_reset_reset,
4295 (void *)&cmd_tx_vlan_reset_portid,
4301 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4302 struct cmd_csum_result {
4303 cmdline_fixed_string_t csum;
4304 cmdline_fixed_string_t mode;
4305 cmdline_fixed_string_t proto;
4306 cmdline_fixed_string_t hwsw;
4311 csum_show(int port_id)
4313 struct rte_eth_dev_info dev_info;
4314 uint64_t tx_offloads;
4316 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4317 printf("Parse tunnel is %s\n",
4318 (ports[port_id].parse_tunnel) ? "on" : "off");
4319 printf("IP checksum offload is %s\n",
4320 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4321 printf("UDP checksum offload is %s\n",
4322 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4323 printf("TCP checksum offload is %s\n",
4324 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4325 printf("SCTP checksum offload is %s\n",
4326 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4327 printf("Outer-Ip checksum offload is %s\n",
4328 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4329 printf("Outer-Udp checksum offload is %s\n",
4330 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4332 /* display warnings if configuration is not supported by the NIC */
4333 rte_eth_dev_info_get(port_id, &dev_info);
4334 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4335 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4336 printf("Warning: hardware IP checksum enabled but not "
4337 "supported by port %d\n", port_id);
4339 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4340 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4341 printf("Warning: hardware UDP checksum enabled but not "
4342 "supported by port %d\n", port_id);
4344 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4345 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4346 printf("Warning: hardware TCP checksum enabled but not "
4347 "supported by port %d\n", port_id);
4349 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4350 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4351 printf("Warning: hardware SCTP checksum enabled but not "
4352 "supported by port %d\n", port_id);
4354 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4355 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4356 printf("Warning: hardware outer IP checksum enabled but not "
4357 "supported by port %d\n", port_id);
4359 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4360 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4362 printf("Warning: hardware outer UDP checksum enabled but not "
4363 "supported by port %d\n", port_id);
4368 cmd_config_queue_tx_offloads(struct rte_port *port)
4372 /* Apply queue tx offloads configuration */
4373 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4374 port->tx_conf[k].offloads =
4375 port->dev_conf.txmode.offloads;
4379 cmd_csum_parsed(void *parsed_result,
4380 __attribute__((unused)) struct cmdline *cl,
4381 __attribute__((unused)) void *data)
4383 struct cmd_csum_result *res = parsed_result;
4385 uint64_t csum_offloads = 0;
4386 struct rte_eth_dev_info dev_info;
4388 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4389 printf("invalid port %d\n", res->port_id);
4392 if (!port_is_stopped(res->port_id)) {
4393 printf("Please stop port %d first\n", res->port_id);
4397 rte_eth_dev_info_get(res->port_id, &dev_info);
4398 if (!strcmp(res->mode, "set")) {
4400 if (!strcmp(res->hwsw, "hw"))
4403 if (!strcmp(res->proto, "ip")) {
4404 if (hw == 0 || (dev_info.tx_offload_capa &
4405 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4406 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4408 printf("IP checksum offload is not supported "
4409 "by port %u\n", res->port_id);
4411 } else if (!strcmp(res->proto, "udp")) {
4412 if (hw == 0 || (dev_info.tx_offload_capa &
4413 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4414 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4416 printf("UDP checksum offload is not supported "
4417 "by port %u\n", res->port_id);
4419 } else if (!strcmp(res->proto, "tcp")) {
4420 if (hw == 0 || (dev_info.tx_offload_capa &
4421 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4422 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4424 printf("TCP checksum offload is not supported "
4425 "by port %u\n", res->port_id);
4427 } else if (!strcmp(res->proto, "sctp")) {
4428 if (hw == 0 || (dev_info.tx_offload_capa &
4429 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4430 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4432 printf("SCTP checksum offload is not supported "
4433 "by port %u\n", res->port_id);
4435 } else if (!strcmp(res->proto, "outer-ip")) {
4436 if (hw == 0 || (dev_info.tx_offload_capa &
4437 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4439 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4441 printf("Outer IP checksum offload is not "
4442 "supported by port %u\n", res->port_id);
4444 } else if (!strcmp(res->proto, "outer-udp")) {
4445 if (hw == 0 || (dev_info.tx_offload_capa &
4446 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4448 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4450 printf("Outer UDP checksum offload is not "
4451 "supported by port %u\n", res->port_id);
4456 ports[res->port_id].dev_conf.txmode.offloads |=
4459 ports[res->port_id].dev_conf.txmode.offloads &=
4462 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4464 csum_show(res->port_id);
4466 cmd_reconfig_device_queue(res->port_id, 1, 1);
4469 cmdline_parse_token_string_t cmd_csum_csum =
4470 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4472 cmdline_parse_token_string_t cmd_csum_mode =
4473 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4475 cmdline_parse_token_string_t cmd_csum_proto =
4476 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4477 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4478 cmdline_parse_token_string_t cmd_csum_hwsw =
4479 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4481 cmdline_parse_token_num_t cmd_csum_portid =
4482 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4485 cmdline_parse_inst_t cmd_csum_set = {
4486 .f = cmd_csum_parsed,
4488 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4489 "Enable/Disable hardware calculation of L3/L4 checksum when "
4490 "using csum forward engine",
4492 (void *)&cmd_csum_csum,
4493 (void *)&cmd_csum_mode,
4494 (void *)&cmd_csum_proto,
4495 (void *)&cmd_csum_hwsw,
4496 (void *)&cmd_csum_portid,
4501 cmdline_parse_token_string_t cmd_csum_mode_show =
4502 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4505 cmdline_parse_inst_t cmd_csum_show = {
4506 .f = cmd_csum_parsed,
4508 .help_str = "csum show <port_id>: Show checksum offload configuration",
4510 (void *)&cmd_csum_csum,
4511 (void *)&cmd_csum_mode_show,
4512 (void *)&cmd_csum_portid,
4517 /* Enable/disable tunnel parsing */
4518 struct cmd_csum_tunnel_result {
4519 cmdline_fixed_string_t csum;
4520 cmdline_fixed_string_t parse;
4521 cmdline_fixed_string_t onoff;
4526 cmd_csum_tunnel_parsed(void *parsed_result,
4527 __attribute__((unused)) struct cmdline *cl,
4528 __attribute__((unused)) void *data)
4530 struct cmd_csum_tunnel_result *res = parsed_result;
4532 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4535 if (!strcmp(res->onoff, "on"))
4536 ports[res->port_id].parse_tunnel = 1;
4538 ports[res->port_id].parse_tunnel = 0;
4540 csum_show(res->port_id);
4543 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4544 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4546 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4547 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4548 parse, "parse-tunnel");
4549 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4550 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4552 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4553 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4556 cmdline_parse_inst_t cmd_csum_tunnel = {
4557 .f = cmd_csum_tunnel_parsed,
4559 .help_str = "csum parse-tunnel on|off <port_id>: "
4560 "Enable/Disable parsing of tunnels for csum engine",
4562 (void *)&cmd_csum_tunnel_csum,
4563 (void *)&cmd_csum_tunnel_parse,
4564 (void *)&cmd_csum_tunnel_onoff,
4565 (void *)&cmd_csum_tunnel_portid,
4570 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4571 struct cmd_tso_set_result {
4572 cmdline_fixed_string_t tso;
4573 cmdline_fixed_string_t mode;
4579 cmd_tso_set_parsed(void *parsed_result,
4580 __attribute__((unused)) struct cmdline *cl,
4581 __attribute__((unused)) void *data)
4583 struct cmd_tso_set_result *res = parsed_result;
4584 struct rte_eth_dev_info dev_info;
4586 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4588 if (!port_is_stopped(res->port_id)) {
4589 printf("Please stop port %d first\n", res->port_id);
4593 if (!strcmp(res->mode, "set"))
4594 ports[res->port_id].tso_segsz = res->tso_segsz;
4596 rte_eth_dev_info_get(res->port_id, &dev_info);
4597 if ((ports[res->port_id].tso_segsz != 0) &&
4598 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4599 printf("Error: TSO is not supported by port %d\n",
4604 if (ports[res->port_id].tso_segsz == 0) {
4605 ports[res->port_id].dev_conf.txmode.offloads &=
4606 ~DEV_TX_OFFLOAD_TCP_TSO;
4607 printf("TSO for non-tunneled packets is disabled\n");
4609 ports[res->port_id].dev_conf.txmode.offloads |=
4610 DEV_TX_OFFLOAD_TCP_TSO;
4611 printf("TSO segment size for non-tunneled packets is %d\n",
4612 ports[res->port_id].tso_segsz);
4614 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4616 /* display warnings if configuration is not supported by the NIC */
4617 rte_eth_dev_info_get(res->port_id, &dev_info);
4618 if ((ports[res->port_id].tso_segsz != 0) &&
4619 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4620 printf("Warning: TSO enabled but not "
4621 "supported by port %d\n", res->port_id);
4624 cmd_reconfig_device_queue(res->port_id, 1, 1);
4627 cmdline_parse_token_string_t cmd_tso_set_tso =
4628 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4630 cmdline_parse_token_string_t cmd_tso_set_mode =
4631 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4633 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4634 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4636 cmdline_parse_token_num_t cmd_tso_set_portid =
4637 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4640 cmdline_parse_inst_t cmd_tso_set = {
4641 .f = cmd_tso_set_parsed,
4643 .help_str = "tso set <tso_segsz> <port_id>: "
4644 "Set TSO segment size of non-tunneled packets for csum engine "
4647 (void *)&cmd_tso_set_tso,
4648 (void *)&cmd_tso_set_mode,
4649 (void *)&cmd_tso_set_tso_segsz,
4650 (void *)&cmd_tso_set_portid,
4655 cmdline_parse_token_string_t cmd_tso_show_mode =
4656 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4660 cmdline_parse_inst_t cmd_tso_show = {
4661 .f = cmd_tso_set_parsed,
4663 .help_str = "tso show <port_id>: "
4664 "Show TSO segment size of non-tunneled packets for csum engine",
4666 (void *)&cmd_tso_set_tso,
4667 (void *)&cmd_tso_show_mode,
4668 (void *)&cmd_tso_set_portid,
4673 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4674 struct cmd_tunnel_tso_set_result {
4675 cmdline_fixed_string_t tso;
4676 cmdline_fixed_string_t mode;
4681 static struct rte_eth_dev_info
4682 check_tunnel_tso_nic_support(portid_t port_id)
4684 struct rte_eth_dev_info dev_info;
4686 rte_eth_dev_info_get(port_id, &dev_info);
4687 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4688 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4689 "not enabled for port %d\n", port_id);
4690 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4691 printf("Warning: GRE TUNNEL TSO not supported therefore "
4692 "not enabled for port %d\n", port_id);
4693 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4694 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4695 "not enabled for port %d\n", port_id);
4696 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4697 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4698 "not enabled for port %d\n", port_id);
4699 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4700 printf("Warning: IP TUNNEL TSO not supported therefore "
4701 "not enabled for port %d\n", port_id);
4702 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4703 printf("Warning: UDP TUNNEL TSO not supported therefore "
4704 "not enabled for port %d\n", port_id);
4709 cmd_tunnel_tso_set_parsed(void *parsed_result,
4710 __attribute__((unused)) struct cmdline *cl,
4711 __attribute__((unused)) void *data)
4713 struct cmd_tunnel_tso_set_result *res = parsed_result;
4714 struct rte_eth_dev_info dev_info;
4716 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4718 if (!port_is_stopped(res->port_id)) {
4719 printf("Please stop port %d first\n", res->port_id);
4723 if (!strcmp(res->mode, "set"))
4724 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4726 dev_info = check_tunnel_tso_nic_support(res->port_id);
4727 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4728 ports[res->port_id].dev_conf.txmode.offloads &=
4729 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4730 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4731 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4732 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4733 DEV_TX_OFFLOAD_IP_TNL_TSO |
4734 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4735 printf("TSO for tunneled packets is disabled\n");
4737 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4738 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4739 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4740 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4741 DEV_TX_OFFLOAD_IP_TNL_TSO |
4742 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4744 ports[res->port_id].dev_conf.txmode.offloads |=
4745 (tso_offloads & dev_info.tx_offload_capa);
4746 printf("TSO segment size for tunneled packets is %d\n",
4747 ports[res->port_id].tunnel_tso_segsz);
4749 /* Below conditions are needed to make it work:
4750 * (1) tunnel TSO is supported by the NIC;
4751 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4753 * (3) for tunneled pkts with outer L3 of IPv4,
4754 * "csum set outer-ip" must be set to hw, because after tso,
4755 * total_len of outer IP header is changed, and the checksum
4756 * of outer IP header calculated by sw should be wrong; that
4757 * is not necessary for IPv6 tunneled pkts because there's no
4758 * checksum in IP header anymore.
4761 if (!ports[res->port_id].parse_tunnel)
4762 printf("Warning: csum parse_tunnel must be set "
4763 "so that tunneled packets are recognized\n");
4764 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4765 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4766 printf("Warning: csum set outer-ip must be set to hw "
4767 "if outer L3 is IPv4; not necessary for IPv6\n");
4770 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4771 cmd_reconfig_device_queue(res->port_id, 1, 1);
4774 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4775 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4777 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4778 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4780 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4781 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4783 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4784 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4787 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4788 .f = cmd_tunnel_tso_set_parsed,
4790 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4791 "Set TSO segment size of tunneled packets for csum engine "
4794 (void *)&cmd_tunnel_tso_set_tso,
4795 (void *)&cmd_tunnel_tso_set_mode,
4796 (void *)&cmd_tunnel_tso_set_tso_segsz,
4797 (void *)&cmd_tunnel_tso_set_portid,
4802 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4803 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4807 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4808 .f = cmd_tunnel_tso_set_parsed,
4810 .help_str = "tunnel_tso show <port_id> "
4811 "Show TSO segment size of tunneled packets for csum engine",
4813 (void *)&cmd_tunnel_tso_set_tso,
4814 (void *)&cmd_tunnel_tso_show_mode,
4815 (void *)&cmd_tunnel_tso_set_portid,
4820 /* *** SET GRO FOR A PORT *** */
4821 struct cmd_gro_enable_result {
4822 cmdline_fixed_string_t cmd_set;
4823 cmdline_fixed_string_t cmd_port;
4824 cmdline_fixed_string_t cmd_keyword;
4825 cmdline_fixed_string_t cmd_onoff;
4830 cmd_gro_enable_parsed(void *parsed_result,
4831 __attribute__((unused)) struct cmdline *cl,
4832 __attribute__((unused)) void *data)
4834 struct cmd_gro_enable_result *res;
4836 res = parsed_result;
4837 if (!strcmp(res->cmd_keyword, "gro"))
4838 setup_gro(res->cmd_onoff, res->cmd_pid);
4841 cmdline_parse_token_string_t cmd_gro_enable_set =
4842 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4844 cmdline_parse_token_string_t cmd_gro_enable_port =
4845 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4846 cmd_keyword, "port");
4847 cmdline_parse_token_num_t cmd_gro_enable_pid =
4848 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4850 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4851 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4852 cmd_keyword, "gro");
4853 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4854 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4855 cmd_onoff, "on#off");
4857 cmdline_parse_inst_t cmd_gro_enable = {
4858 .f = cmd_gro_enable_parsed,
4860 .help_str = "set port <port_id> gro on|off",
4862 (void *)&cmd_gro_enable_set,
4863 (void *)&cmd_gro_enable_port,
4864 (void *)&cmd_gro_enable_pid,
4865 (void *)&cmd_gro_enable_keyword,
4866 (void *)&cmd_gro_enable_onoff,
4871 /* *** DISPLAY GRO CONFIGURATION *** */
4872 struct cmd_gro_show_result {
4873 cmdline_fixed_string_t cmd_show;
4874 cmdline_fixed_string_t cmd_port;
4875 cmdline_fixed_string_t cmd_keyword;
4880 cmd_gro_show_parsed(void *parsed_result,
4881 __attribute__((unused)) struct cmdline *cl,
4882 __attribute__((unused)) void *data)
4884 struct cmd_gro_show_result *res;
4886 res = parsed_result;
4887 if (!strcmp(res->cmd_keyword, "gro"))
4888 show_gro(res->cmd_pid);
4891 cmdline_parse_token_string_t cmd_gro_show_show =
4892 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4894 cmdline_parse_token_string_t cmd_gro_show_port =
4895 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4897 cmdline_parse_token_num_t cmd_gro_show_pid =
4898 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4900 cmdline_parse_token_string_t cmd_gro_show_keyword =
4901 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4902 cmd_keyword, "gro");
4904 cmdline_parse_inst_t cmd_gro_show = {
4905 .f = cmd_gro_show_parsed,
4907 .help_str = "show port <port_id> gro",
4909 (void *)&cmd_gro_show_show,
4910 (void *)&cmd_gro_show_port,
4911 (void *)&cmd_gro_show_pid,
4912 (void *)&cmd_gro_show_keyword,
4917 /* *** SET FLUSH CYCLES FOR GRO *** */
4918 struct cmd_gro_flush_result {
4919 cmdline_fixed_string_t cmd_set;
4920 cmdline_fixed_string_t cmd_keyword;
4921 cmdline_fixed_string_t cmd_flush;
4926 cmd_gro_flush_parsed(void *parsed_result,
4927 __attribute__((unused)) struct cmdline *cl,
4928 __attribute__((unused)) void *data)
4930 struct cmd_gro_flush_result *res;
4932 res = parsed_result;
4933 if ((!strcmp(res->cmd_keyword, "gro")) &&
4934 (!strcmp(res->cmd_flush, "flush")))
4935 setup_gro_flush_cycles(res->cmd_cycles);
4938 cmdline_parse_token_string_t cmd_gro_flush_set =
4939 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4941 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4942 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4943 cmd_keyword, "gro");
4944 cmdline_parse_token_string_t cmd_gro_flush_flush =
4945 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4946 cmd_flush, "flush");
4947 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4948 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4951 cmdline_parse_inst_t cmd_gro_flush = {
4952 .f = cmd_gro_flush_parsed,
4954 .help_str = "set gro flush <cycles>",
4956 (void *)&cmd_gro_flush_set,
4957 (void *)&cmd_gro_flush_keyword,
4958 (void *)&cmd_gro_flush_flush,
4959 (void *)&cmd_gro_flush_cycles,
4964 /* *** ENABLE/DISABLE GSO *** */
4965 struct cmd_gso_enable_result {
4966 cmdline_fixed_string_t cmd_set;
4967 cmdline_fixed_string_t cmd_port;
4968 cmdline_fixed_string_t cmd_keyword;
4969 cmdline_fixed_string_t cmd_mode;
4974 cmd_gso_enable_parsed(void *parsed_result,
4975 __attribute__((unused)) struct cmdline *cl,
4976 __attribute__((unused)) void *data)
4978 struct cmd_gso_enable_result *res;
4980 res = parsed_result;
4981 if (!strcmp(res->cmd_keyword, "gso"))
4982 setup_gso(res->cmd_mode, res->cmd_pid);
4985 cmdline_parse_token_string_t cmd_gso_enable_set =
4986 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4988 cmdline_parse_token_string_t cmd_gso_enable_port =
4989 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4991 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4992 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4993 cmd_keyword, "gso");
4994 cmdline_parse_token_string_t cmd_gso_enable_mode =
4995 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4996 cmd_mode, "on#off");
4997 cmdline_parse_token_num_t cmd_gso_enable_pid =
4998 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5001 cmdline_parse_inst_t cmd_gso_enable = {
5002 .f = cmd_gso_enable_parsed,
5004 .help_str = "set port <port_id> gso on|off",
5006 (void *)&cmd_gso_enable_set,
5007 (void *)&cmd_gso_enable_port,
5008 (void *)&cmd_gso_enable_pid,
5009 (void *)&cmd_gso_enable_keyword,
5010 (void *)&cmd_gso_enable_mode,
5015 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5016 struct cmd_gso_size_result {
5017 cmdline_fixed_string_t cmd_set;
5018 cmdline_fixed_string_t cmd_keyword;
5019 cmdline_fixed_string_t cmd_segsz;
5024 cmd_gso_size_parsed(void *parsed_result,
5025 __attribute__((unused)) struct cmdline *cl,
5026 __attribute__((unused)) void *data)
5028 struct cmd_gso_size_result *res = parsed_result;
5030 if (test_done == 0) {
5031 printf("Before setting GSO segsz, please first"
5032 " stop fowarding\n");
5036 if (!strcmp(res->cmd_keyword, "gso") &&
5037 !strcmp(res->cmd_segsz, "segsz")) {
5038 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5039 printf("gso_size should be larger than %zu."
5040 " Please input a legal value\n",
5041 RTE_GSO_SEG_SIZE_MIN);
5043 gso_max_segment_size = res->cmd_size;
5047 cmdline_parse_token_string_t cmd_gso_size_set =
5048 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5050 cmdline_parse_token_string_t cmd_gso_size_keyword =
5051 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5052 cmd_keyword, "gso");
5053 cmdline_parse_token_string_t cmd_gso_size_segsz =
5054 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5055 cmd_segsz, "segsz");
5056 cmdline_parse_token_num_t cmd_gso_size_size =
5057 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5060 cmdline_parse_inst_t cmd_gso_size = {
5061 .f = cmd_gso_size_parsed,
5063 .help_str = "set gso segsz <length>",
5065 (void *)&cmd_gso_size_set,
5066 (void *)&cmd_gso_size_keyword,
5067 (void *)&cmd_gso_size_segsz,
5068 (void *)&cmd_gso_size_size,
5073 /* *** SHOW GSO CONFIGURATION *** */
5074 struct cmd_gso_show_result {
5075 cmdline_fixed_string_t cmd_show;
5076 cmdline_fixed_string_t cmd_port;
5077 cmdline_fixed_string_t cmd_keyword;
5082 cmd_gso_show_parsed(void *parsed_result,
5083 __attribute__((unused)) struct cmdline *cl,
5084 __attribute__((unused)) void *data)
5086 struct cmd_gso_show_result *res = parsed_result;
5088 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5089 printf("invalid port id %u\n", res->cmd_pid);
5092 if (!strcmp(res->cmd_keyword, "gso")) {
5093 if (gso_ports[res->cmd_pid].enable) {
5094 printf("Max GSO'd packet size: %uB\n"
5095 "Supported GSO types: TCP/IPv4, "
5096 "UDP/IPv4, VxLAN with inner "
5097 "TCP/IPv4 packet, GRE with inner "
5098 "TCP/IPv4 packet\n",
5099 gso_max_segment_size);
5101 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5105 cmdline_parse_token_string_t cmd_gso_show_show =
5106 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5108 cmdline_parse_token_string_t cmd_gso_show_port =
5109 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5111 cmdline_parse_token_string_t cmd_gso_show_keyword =
5112 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5113 cmd_keyword, "gso");
5114 cmdline_parse_token_num_t cmd_gso_show_pid =
5115 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5118 cmdline_parse_inst_t cmd_gso_show = {
5119 .f = cmd_gso_show_parsed,
5121 .help_str = "show port <port_id> gso",
5123 (void *)&cmd_gso_show_show,
5124 (void *)&cmd_gso_show_port,
5125 (void *)&cmd_gso_show_pid,
5126 (void *)&cmd_gso_show_keyword,
5131 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5132 struct cmd_set_flush_rx {
5133 cmdline_fixed_string_t set;
5134 cmdline_fixed_string_t flush_rx;
5135 cmdline_fixed_string_t mode;
5139 cmd_set_flush_rx_parsed(void *parsed_result,
5140 __attribute__((unused)) struct cmdline *cl,
5141 __attribute__((unused)) void *data)
5143 struct cmd_set_flush_rx *res = parsed_result;
5144 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5147 cmdline_parse_token_string_t cmd_setflushrx_set =
5148 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5150 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5151 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5152 flush_rx, "flush_rx");
5153 cmdline_parse_token_string_t cmd_setflushrx_mode =
5154 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5158 cmdline_parse_inst_t cmd_set_flush_rx = {
5159 .f = cmd_set_flush_rx_parsed,
5160 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5163 (void *)&cmd_setflushrx_set,
5164 (void *)&cmd_setflushrx_flush_rx,
5165 (void *)&cmd_setflushrx_mode,
5170 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5171 struct cmd_set_link_check {
5172 cmdline_fixed_string_t set;
5173 cmdline_fixed_string_t link_check;
5174 cmdline_fixed_string_t mode;
5178 cmd_set_link_check_parsed(void *parsed_result,
5179 __attribute__((unused)) struct cmdline *cl,
5180 __attribute__((unused)) void *data)
5182 struct cmd_set_link_check *res = parsed_result;
5183 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5186 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5187 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5189 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5190 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5191 link_check, "link_check");
5192 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5193 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5197 cmdline_parse_inst_t cmd_set_link_check = {
5198 .f = cmd_set_link_check_parsed,
5199 .help_str = "set link_check on|off: Enable/Disable link status check "
5200 "when starting/stopping a port",
5203 (void *)&cmd_setlinkcheck_set,
5204 (void *)&cmd_setlinkcheck_link_check,
5205 (void *)&cmd_setlinkcheck_mode,
5210 /* *** SET NIC BYPASS MODE *** */
5211 struct cmd_set_bypass_mode_result {
5212 cmdline_fixed_string_t set;
5213 cmdline_fixed_string_t bypass;
5214 cmdline_fixed_string_t mode;
5215 cmdline_fixed_string_t value;
5220 cmd_set_bypass_mode_parsed(void *parsed_result,
5221 __attribute__((unused)) struct cmdline *cl,
5222 __attribute__((unused)) void *data)
5224 struct cmd_set_bypass_mode_result *res = parsed_result;
5225 portid_t port_id = res->port_id;
5226 int32_t rc = -EINVAL;
5228 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5229 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5231 if (!strcmp(res->value, "bypass"))
5232 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5233 else if (!strcmp(res->value, "isolate"))
5234 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5236 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5238 /* Set the bypass mode for the relevant port. */
5239 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5242 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5245 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5246 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5248 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5249 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5251 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5252 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5254 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5255 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5256 value, "normal#bypass#isolate");
5257 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5258 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5261 cmdline_parse_inst_t cmd_set_bypass_mode = {
5262 .f = cmd_set_bypass_mode_parsed,
5263 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5264 "Set the NIC bypass mode for port_id",
5267 (void *)&cmd_setbypass_mode_set,
5268 (void *)&cmd_setbypass_mode_bypass,
5269 (void *)&cmd_setbypass_mode_mode,
5270 (void *)&cmd_setbypass_mode_value,
5271 (void *)&cmd_setbypass_mode_port,
5276 /* *** SET NIC BYPASS EVENT *** */
5277 struct cmd_set_bypass_event_result {
5278 cmdline_fixed_string_t set;
5279 cmdline_fixed_string_t bypass;
5280 cmdline_fixed_string_t event;
5281 cmdline_fixed_string_t event_value;
5282 cmdline_fixed_string_t mode;
5283 cmdline_fixed_string_t mode_value;
5288 cmd_set_bypass_event_parsed(void *parsed_result,
5289 __attribute__((unused)) struct cmdline *cl,
5290 __attribute__((unused)) void *data)
5292 int32_t rc = -EINVAL;
5293 struct cmd_set_bypass_event_result *res = parsed_result;
5294 portid_t port_id = res->port_id;
5296 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5297 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5298 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5300 if (!strcmp(res->event_value, "timeout"))
5301 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5302 else if (!strcmp(res->event_value, "os_on"))
5303 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5304 else if (!strcmp(res->event_value, "os_off"))
5305 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5306 else if (!strcmp(res->event_value, "power_on"))
5307 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5308 else if (!strcmp(res->event_value, "power_off"))
5309 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5311 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5313 if (!strcmp(res->mode_value, "bypass"))
5314 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5315 else if (!strcmp(res->mode_value, "isolate"))
5316 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5318 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5320 /* Set the watchdog timeout. */
5321 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5324 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5325 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5329 printf("Failed to set timeout value %u "
5330 "for port %d, errto code: %d.\n",
5331 bypass_timeout, port_id, rc);
5335 /* Set the bypass event to transition to bypass mode. */
5336 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5341 printf("\t Failed to set bypass event for port = %d.\n",
5345 cmdline_parse_token_string_t cmd_setbypass_event_set =
5346 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5348 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5349 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5351 cmdline_parse_token_string_t cmd_setbypass_event_event =
5352 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5354 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5355 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5356 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5357 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5358 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5360 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5361 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5362 mode_value, "normal#bypass#isolate");
5363 cmdline_parse_token_num_t cmd_setbypass_event_port =
5364 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5367 cmdline_parse_inst_t cmd_set_bypass_event = {
5368 .f = cmd_set_bypass_event_parsed,
5369 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5370 "power_off mode normal|bypass|isolate <port_id>: "
5371 "Set the NIC bypass event mode for port_id",
5374 (void *)&cmd_setbypass_event_set,
5375 (void *)&cmd_setbypass_event_bypass,
5376 (void *)&cmd_setbypass_event_event,
5377 (void *)&cmd_setbypass_event_event_value,
5378 (void *)&cmd_setbypass_event_mode,
5379 (void *)&cmd_setbypass_event_mode_value,
5380 (void *)&cmd_setbypass_event_port,
5386 /* *** SET NIC BYPASS TIMEOUT *** */
5387 struct cmd_set_bypass_timeout_result {
5388 cmdline_fixed_string_t set;
5389 cmdline_fixed_string_t bypass;
5390 cmdline_fixed_string_t timeout;
5391 cmdline_fixed_string_t value;
5395 cmd_set_bypass_timeout_parsed(void *parsed_result,
5396 __attribute__((unused)) struct cmdline *cl,
5397 __attribute__((unused)) void *data)
5399 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5401 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5402 if (!strcmp(res->value, "1.5"))
5403 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5404 else if (!strcmp(res->value, "2"))
5405 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5406 else if (!strcmp(res->value, "3"))
5407 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5408 else if (!strcmp(res->value, "4"))
5409 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5410 else if (!strcmp(res->value, "8"))
5411 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5412 else if (!strcmp(res->value, "16"))
5413 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5414 else if (!strcmp(res->value, "32"))
5415 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5417 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5421 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5422 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5424 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5425 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5427 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5428 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5429 timeout, "timeout");
5430 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5431 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5432 value, "0#1.5#2#3#4#8#16#32");
5434 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5435 .f = cmd_set_bypass_timeout_parsed,
5436 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5437 "Set the NIC bypass watchdog timeout in seconds",
5440 (void *)&cmd_setbypass_timeout_set,
5441 (void *)&cmd_setbypass_timeout_bypass,
5442 (void *)&cmd_setbypass_timeout_timeout,
5443 (void *)&cmd_setbypass_timeout_value,
5448 /* *** SHOW NIC BYPASS MODE *** */
5449 struct cmd_show_bypass_config_result {
5450 cmdline_fixed_string_t show;
5451 cmdline_fixed_string_t bypass;
5452 cmdline_fixed_string_t config;
5457 cmd_show_bypass_config_parsed(void *parsed_result,
5458 __attribute__((unused)) struct cmdline *cl,
5459 __attribute__((unused)) void *data)
5461 struct cmd_show_bypass_config_result *res = parsed_result;
5462 portid_t port_id = res->port_id;
5464 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5465 uint32_t event_mode;
5466 uint32_t bypass_mode;
5467 uint32_t timeout = bypass_timeout;
5470 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5471 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5472 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5473 {"UNKNOWN", "normal", "bypass", "isolate"};
5474 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5481 int num_events = (sizeof events) / (sizeof events[0]);
5483 /* Display the bypass mode.*/
5484 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5485 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5489 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5490 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5492 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5495 /* Display the bypass timeout.*/
5496 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5497 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5499 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5501 /* Display the bypass events and associated modes. */
5502 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5504 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5505 printf("\tFailed to get bypass mode for event = %s\n",
5508 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5509 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5511 printf("\tbypass event: %-16s = %s\n", events[i],
5517 printf("\tFailed to get bypass configuration for port = %d\n",
5521 cmdline_parse_token_string_t cmd_showbypass_config_show =
5522 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5524 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5525 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5527 cmdline_parse_token_string_t cmd_showbypass_config_config =
5528 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5530 cmdline_parse_token_num_t cmd_showbypass_config_port =
5531 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5534 cmdline_parse_inst_t cmd_show_bypass_config = {
5535 .f = cmd_show_bypass_config_parsed,
5536 .help_str = "show bypass config <port_id>: "
5537 "Show the NIC bypass config for port_id",
5540 (void *)&cmd_showbypass_config_show,
5541 (void *)&cmd_showbypass_config_bypass,
5542 (void *)&cmd_showbypass_config_config,
5543 (void *)&cmd_showbypass_config_port,
5548 #ifdef RTE_LIBRTE_PMD_BOND
5549 /* *** SET BONDING MODE *** */
5550 struct cmd_set_bonding_mode_result {
5551 cmdline_fixed_string_t set;
5552 cmdline_fixed_string_t bonding;
5553 cmdline_fixed_string_t mode;
5558 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5559 __attribute__((unused)) struct cmdline *cl,
5560 __attribute__((unused)) void *data)
5562 struct cmd_set_bonding_mode_result *res = parsed_result;
5563 portid_t port_id = res->port_id;
5565 /* Set the bonding mode for the relevant port. */
5566 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5567 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5570 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5571 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5573 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5574 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5575 bonding, "bonding");
5576 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5577 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5579 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5580 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5582 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5583 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5586 cmdline_parse_inst_t cmd_set_bonding_mode = {
5587 .f = cmd_set_bonding_mode_parsed,
5588 .help_str = "set bonding mode <mode_value> <port_id>: "
5589 "Set the bonding mode for port_id",
5592 (void *) &cmd_setbonding_mode_set,
5593 (void *) &cmd_setbonding_mode_bonding,
5594 (void *) &cmd_setbonding_mode_mode,
5595 (void *) &cmd_setbonding_mode_value,
5596 (void *) &cmd_setbonding_mode_port,
5601 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5602 struct cmd_set_bonding_lacp_dedicated_queues_result {
5603 cmdline_fixed_string_t set;
5604 cmdline_fixed_string_t bonding;
5605 cmdline_fixed_string_t lacp;
5606 cmdline_fixed_string_t dedicated_queues;
5608 cmdline_fixed_string_t mode;
5611 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5612 __attribute__((unused)) struct cmdline *cl,
5613 __attribute__((unused)) void *data)
5615 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5616 portid_t port_id = res->port_id;
5617 struct rte_port *port;
5619 port = &ports[port_id];
5621 /** Check if the port is not started **/
5622 if (port->port_status != RTE_PORT_STOPPED) {
5623 printf("Please stop port %d first\n", port_id);
5627 if (!strcmp(res->mode, "enable")) {
5628 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5629 printf("Dedicate queues for LACP control packets"
5632 printf("Enabling dedicate queues for LACP control "
5633 "packets on port %d failed\n", port_id);
5634 } else if (!strcmp(res->mode, "disable")) {
5635 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5636 printf("Dedicated queues for LACP control packets "
5639 printf("Disabling dedicated queues for LACP control "
5640 "traffic on port %d failed\n", port_id);
5644 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5645 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5647 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5648 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5649 bonding, "bonding");
5650 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5651 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5653 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5654 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5655 dedicated_queues, "dedicated_queues");
5656 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5657 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5659 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5660 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5661 mode, "enable#disable");
5663 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5664 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5665 .help_str = "set bonding lacp dedicated_queues <port_id> "
5667 "Enable/disable dedicated queues for LACP control traffic for port_id",
5670 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5671 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5672 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5673 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5674 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5675 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5680 /* *** SET BALANCE XMIT POLICY *** */
5681 struct cmd_set_bonding_balance_xmit_policy_result {
5682 cmdline_fixed_string_t set;
5683 cmdline_fixed_string_t bonding;
5684 cmdline_fixed_string_t balance_xmit_policy;
5686 cmdline_fixed_string_t policy;
5689 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5690 __attribute__((unused)) struct cmdline *cl,
5691 __attribute__((unused)) void *data)
5693 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5694 portid_t port_id = res->port_id;
5697 if (!strcmp(res->policy, "l2")) {
5698 policy = BALANCE_XMIT_POLICY_LAYER2;
5699 } else if (!strcmp(res->policy, "l23")) {
5700 policy = BALANCE_XMIT_POLICY_LAYER23;
5701 } else if (!strcmp(res->policy, "l34")) {
5702 policy = BALANCE_XMIT_POLICY_LAYER34;
5704 printf("\t Invalid xmit policy selection");
5708 /* Set the bonding mode for the relevant port. */
5709 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5710 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5715 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5716 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5718 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5719 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5720 bonding, "bonding");
5721 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5722 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5723 balance_xmit_policy, "balance_xmit_policy");
5724 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5725 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5727 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5728 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5729 policy, "l2#l23#l34");
5731 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5732 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5733 .help_str = "set bonding balance_xmit_policy <port_id> "
5735 "Set the bonding balance_xmit_policy for port_id",
5738 (void *)&cmd_setbonding_balance_xmit_policy_set,
5739 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5740 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5741 (void *)&cmd_setbonding_balance_xmit_policy_port,
5742 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5747 /* *** SHOW NIC BONDING CONFIGURATION *** */
5748 struct cmd_show_bonding_config_result {
5749 cmdline_fixed_string_t show;
5750 cmdline_fixed_string_t bonding;
5751 cmdline_fixed_string_t config;
5755 static void cmd_show_bonding_config_parsed(void *parsed_result,
5756 __attribute__((unused)) struct cmdline *cl,
5757 __attribute__((unused)) void *data)
5759 struct cmd_show_bonding_config_result *res = parsed_result;
5760 int bonding_mode, agg_mode;
5761 portid_t slaves[RTE_MAX_ETHPORTS];
5762 int num_slaves, num_active_slaves;
5765 portid_t port_id = res->port_id;
5767 /* Display the bonding mode.*/
5768 bonding_mode = rte_eth_bond_mode_get(port_id);
5769 if (bonding_mode < 0) {
5770 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5773 printf("\tBonding mode: %d\n", bonding_mode);
5775 if (bonding_mode == BONDING_MODE_BALANCE) {
5776 int balance_xmit_policy;
5778 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5779 if (balance_xmit_policy < 0) {
5780 printf("\tFailed to get balance xmit policy for port = %d\n",
5784 printf("\tBalance Xmit Policy: ");
5786 switch (balance_xmit_policy) {
5787 case BALANCE_XMIT_POLICY_LAYER2:
5788 printf("BALANCE_XMIT_POLICY_LAYER2");
5790 case BALANCE_XMIT_POLICY_LAYER23:
5791 printf("BALANCE_XMIT_POLICY_LAYER23");
5793 case BALANCE_XMIT_POLICY_LAYER34:
5794 printf("BALANCE_XMIT_POLICY_LAYER34");
5801 if (bonding_mode == BONDING_MODE_8023AD) {
5802 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5803 printf("\tIEEE802.3AD Aggregator Mode: ");
5806 printf("bandwidth");
5818 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5820 if (num_slaves < 0) {
5821 printf("\tFailed to get slave list for port = %d\n", port_id);
5824 if (num_slaves > 0) {
5825 printf("\tSlaves (%d): [", num_slaves);
5826 for (i = 0; i < num_slaves - 1; i++)
5827 printf("%d ", slaves[i]);
5829 printf("%d]\n", slaves[num_slaves - 1]);
5831 printf("\tSlaves: []\n");
5835 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5838 if (num_active_slaves < 0) {
5839 printf("\tFailed to get active slave list for port = %d\n", port_id);
5842 if (num_active_slaves > 0) {
5843 printf("\tActive Slaves (%d): [", num_active_slaves);
5844 for (i = 0; i < num_active_slaves - 1; i++)
5845 printf("%d ", slaves[i]);
5847 printf("%d]\n", slaves[num_active_slaves - 1]);
5850 printf("\tActive Slaves: []\n");
5854 primary_id = rte_eth_bond_primary_get(port_id);
5855 if (primary_id < 0) {
5856 printf("\tFailed to get primary slave for port = %d\n", port_id);
5859 printf("\tPrimary: [%d]\n", primary_id);
5863 cmdline_parse_token_string_t cmd_showbonding_config_show =
5864 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5866 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5867 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5868 bonding, "bonding");
5869 cmdline_parse_token_string_t cmd_showbonding_config_config =
5870 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5872 cmdline_parse_token_num_t cmd_showbonding_config_port =
5873 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5876 cmdline_parse_inst_t cmd_show_bonding_config = {
5877 .f = cmd_show_bonding_config_parsed,
5878 .help_str = "show bonding config <port_id>: "
5879 "Show the bonding config for port_id",
5882 (void *)&cmd_showbonding_config_show,
5883 (void *)&cmd_showbonding_config_bonding,
5884 (void *)&cmd_showbonding_config_config,
5885 (void *)&cmd_showbonding_config_port,
5890 /* *** SET BONDING PRIMARY *** */
5891 struct cmd_set_bonding_primary_result {
5892 cmdline_fixed_string_t set;
5893 cmdline_fixed_string_t bonding;
5894 cmdline_fixed_string_t primary;
5899 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5900 __attribute__((unused)) struct cmdline *cl,
5901 __attribute__((unused)) void *data)
5903 struct cmd_set_bonding_primary_result *res = parsed_result;
5904 portid_t master_port_id = res->port_id;
5905 portid_t slave_port_id = res->slave_id;
5907 /* Set the primary slave for a bonded device. */
5908 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5909 printf("\t Failed to set primary slave for port = %d.\n",
5916 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5917 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5919 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5920 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5921 bonding, "bonding");
5922 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5923 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5924 primary, "primary");
5925 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5926 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5928 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5929 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5932 cmdline_parse_inst_t cmd_set_bonding_primary = {
5933 .f = cmd_set_bonding_primary_parsed,
5934 .help_str = "set bonding primary <slave_id> <port_id>: "
5935 "Set the primary slave for port_id",
5938 (void *)&cmd_setbonding_primary_set,
5939 (void *)&cmd_setbonding_primary_bonding,
5940 (void *)&cmd_setbonding_primary_primary,
5941 (void *)&cmd_setbonding_primary_slave,
5942 (void *)&cmd_setbonding_primary_port,
5947 /* *** ADD SLAVE *** */
5948 struct cmd_add_bonding_slave_result {
5949 cmdline_fixed_string_t add;
5950 cmdline_fixed_string_t bonding;
5951 cmdline_fixed_string_t slave;
5956 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5957 __attribute__((unused)) struct cmdline *cl,
5958 __attribute__((unused)) void *data)
5960 struct cmd_add_bonding_slave_result *res = parsed_result;
5961 portid_t master_port_id = res->port_id;
5962 portid_t slave_port_id = res->slave_id;
5964 /* add the slave for a bonded device. */
5965 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5966 printf("\t Failed to add slave %d to master port = %d.\n",
5967 slave_port_id, master_port_id);
5971 set_port_slave_flag(slave_port_id);
5974 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5975 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5977 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5978 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5979 bonding, "bonding");
5980 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5981 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5983 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5984 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5986 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5987 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5990 cmdline_parse_inst_t cmd_add_bonding_slave = {
5991 .f = cmd_add_bonding_slave_parsed,
5992 .help_str = "add bonding slave <slave_id> <port_id>: "
5993 "Add a slave device to a bonded device",
5996 (void *)&cmd_addbonding_slave_add,
5997 (void *)&cmd_addbonding_slave_bonding,
5998 (void *)&cmd_addbonding_slave_slave,
5999 (void *)&cmd_addbonding_slave_slaveid,
6000 (void *)&cmd_addbonding_slave_port,
6005 /* *** REMOVE SLAVE *** */
6006 struct cmd_remove_bonding_slave_result {
6007 cmdline_fixed_string_t remove;
6008 cmdline_fixed_string_t bonding;
6009 cmdline_fixed_string_t slave;
6014 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6015 __attribute__((unused)) struct cmdline *cl,
6016 __attribute__((unused)) void *data)
6018 struct cmd_remove_bonding_slave_result *res = parsed_result;
6019 portid_t master_port_id = res->port_id;
6020 portid_t slave_port_id = res->slave_id;
6022 /* remove the slave from a bonded device. */
6023 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6024 printf("\t Failed to remove slave %d from master port = %d.\n",
6025 slave_port_id, master_port_id);
6029 clear_port_slave_flag(slave_port_id);
6032 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6033 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6035 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6036 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6037 bonding, "bonding");
6038 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6039 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6041 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6042 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6044 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6045 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6048 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6049 .f = cmd_remove_bonding_slave_parsed,
6050 .help_str = "remove bonding slave <slave_id> <port_id>: "
6051 "Remove a slave device from a bonded device",
6054 (void *)&cmd_removebonding_slave_remove,
6055 (void *)&cmd_removebonding_slave_bonding,
6056 (void *)&cmd_removebonding_slave_slave,
6057 (void *)&cmd_removebonding_slave_slaveid,
6058 (void *)&cmd_removebonding_slave_port,
6063 /* *** CREATE BONDED DEVICE *** */
6064 struct cmd_create_bonded_device_result {
6065 cmdline_fixed_string_t create;
6066 cmdline_fixed_string_t bonded;
6067 cmdline_fixed_string_t device;
6072 static int bond_dev_num = 0;
6074 static void cmd_create_bonded_device_parsed(void *parsed_result,
6075 __attribute__((unused)) struct cmdline *cl,
6076 __attribute__((unused)) void *data)
6078 struct cmd_create_bonded_device_result *res = parsed_result;
6079 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6082 if (test_done == 0) {
6083 printf("Please stop forwarding first\n");
6087 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6090 /* Create a new bonded device. */
6091 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6093 printf("\t Failed to create bonded device.\n");
6096 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6099 /* Update number of ports */
6100 nb_ports = rte_eth_dev_count_avail();
6101 reconfig(port_id, res->socket);
6102 rte_eth_promiscuous_enable(port_id);
6103 ports[port_id].need_setup = 0;
6104 ports[port_id].port_status = RTE_PORT_STOPPED;
6109 cmdline_parse_token_string_t cmd_createbonded_device_create =
6110 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6112 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6113 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6115 cmdline_parse_token_string_t cmd_createbonded_device_device =
6116 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6118 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6119 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6121 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6122 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6125 cmdline_parse_inst_t cmd_create_bonded_device = {
6126 .f = cmd_create_bonded_device_parsed,
6127 .help_str = "create bonded device <mode> <socket>: "
6128 "Create a new bonded device with specific bonding mode and socket",
6131 (void *)&cmd_createbonded_device_create,
6132 (void *)&cmd_createbonded_device_bonded,
6133 (void *)&cmd_createbonded_device_device,
6134 (void *)&cmd_createbonded_device_mode,
6135 (void *)&cmd_createbonded_device_socket,
6140 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6141 struct cmd_set_bond_mac_addr_result {
6142 cmdline_fixed_string_t set;
6143 cmdline_fixed_string_t bonding;
6144 cmdline_fixed_string_t mac_addr;
6146 struct rte_ether_addr address;
6149 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6150 __attribute__((unused)) struct cmdline *cl,
6151 __attribute__((unused)) void *data)
6153 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6156 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6159 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6161 /* check the return value and print it if is < 0 */
6163 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6166 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6167 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6168 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6169 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6171 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6172 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6174 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6175 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6177 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6178 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6180 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6181 .f = cmd_set_bond_mac_addr_parsed,
6183 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6185 (void *)&cmd_set_bond_mac_addr_set,
6186 (void *)&cmd_set_bond_mac_addr_bonding,
6187 (void *)&cmd_set_bond_mac_addr_mac,
6188 (void *)&cmd_set_bond_mac_addr_portnum,
6189 (void *)&cmd_set_bond_mac_addr_addr,
6195 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6196 struct cmd_set_bond_mon_period_result {
6197 cmdline_fixed_string_t set;
6198 cmdline_fixed_string_t bonding;
6199 cmdline_fixed_string_t mon_period;
6204 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6205 __attribute__((unused)) struct cmdline *cl,
6206 __attribute__((unused)) void *data)
6208 struct cmd_set_bond_mon_period_result *res = parsed_result;
6211 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6213 /* check the return value and print it if is < 0 */
6215 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6218 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6219 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6221 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6222 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6223 bonding, "bonding");
6224 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6225 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6226 mon_period, "mon_period");
6227 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6228 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6230 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6231 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6234 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6235 .f = cmd_set_bond_mon_period_parsed,
6237 .help_str = "set bonding mon_period <port_id> <period_ms>",
6239 (void *)&cmd_set_bond_mon_period_set,
6240 (void *)&cmd_set_bond_mon_period_bonding,
6241 (void *)&cmd_set_bond_mon_period_mon_period,
6242 (void *)&cmd_set_bond_mon_period_portnum,
6243 (void *)&cmd_set_bond_mon_period_period_ms,
6250 struct cmd_set_bonding_agg_mode_policy_result {
6251 cmdline_fixed_string_t set;
6252 cmdline_fixed_string_t bonding;
6253 cmdline_fixed_string_t agg_mode;
6255 cmdline_fixed_string_t policy;
6260 cmd_set_bonding_agg_mode(void *parsed_result,
6261 __attribute__((unused)) struct cmdline *cl,
6262 __attribute__((unused)) void *data)
6264 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6265 uint8_t policy = AGG_BANDWIDTH;
6267 if (!strcmp(res->policy, "bandwidth"))
6268 policy = AGG_BANDWIDTH;
6269 else if (!strcmp(res->policy, "stable"))
6270 policy = AGG_STABLE;
6271 else if (!strcmp(res->policy, "count"))
6274 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6278 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6279 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6281 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6282 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6283 bonding, "bonding");
6285 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6286 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6287 agg_mode, "agg_mode");
6289 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6290 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6293 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6294 TOKEN_STRING_INITIALIZER(
6295 struct cmd_set_bonding_balance_xmit_policy_result,
6296 policy, "stable#bandwidth#count");
6298 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6299 .f = cmd_set_bonding_agg_mode,
6301 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6303 (void *)&cmd_set_bonding_agg_mode_set,
6304 (void *)&cmd_set_bonding_agg_mode_bonding,
6305 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6306 (void *)&cmd_set_bonding_agg_mode_portnum,
6307 (void *)&cmd_set_bonding_agg_mode_policy_string,
6313 #endif /* RTE_LIBRTE_PMD_BOND */
6315 /* *** SET FORWARDING MODE *** */
6316 struct cmd_set_fwd_mode_result {
6317 cmdline_fixed_string_t set;
6318 cmdline_fixed_string_t fwd;
6319 cmdline_fixed_string_t mode;
6322 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6323 __attribute__((unused)) struct cmdline *cl,
6324 __attribute__((unused)) void *data)
6326 struct cmd_set_fwd_mode_result *res = parsed_result;
6329 set_pkt_forwarding_mode(res->mode);
6332 cmdline_parse_token_string_t cmd_setfwd_set =
6333 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6334 cmdline_parse_token_string_t cmd_setfwd_fwd =
6335 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6336 cmdline_parse_token_string_t cmd_setfwd_mode =
6337 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6338 "" /* defined at init */);
6340 cmdline_parse_inst_t cmd_set_fwd_mode = {
6341 .f = cmd_set_fwd_mode_parsed,
6343 .help_str = NULL, /* defined at init */
6345 (void *)&cmd_setfwd_set,
6346 (void *)&cmd_setfwd_fwd,
6347 (void *)&cmd_setfwd_mode,
6352 static void cmd_set_fwd_mode_init(void)
6355 static char token[128];
6356 static char help[256];
6357 cmdline_parse_token_string_t *token_struct;
6359 modes = list_pkt_forwarding_modes();
6360 snprintf(help, sizeof(help), "set fwd %s: "
6361 "Set packet forwarding mode", modes);
6362 cmd_set_fwd_mode.help_str = help;
6364 /* string token separator is # */
6365 for (c = token; *modes != '\0'; modes++)
6370 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6371 token_struct->string_data.str = token;
6374 /* *** SET RETRY FORWARDING MODE *** */
6375 struct cmd_set_fwd_retry_mode_result {
6376 cmdline_fixed_string_t set;
6377 cmdline_fixed_string_t fwd;
6378 cmdline_fixed_string_t mode;
6379 cmdline_fixed_string_t retry;
6382 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6383 __attribute__((unused)) struct cmdline *cl,
6384 __attribute__((unused)) void *data)
6386 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6389 set_pkt_forwarding_mode(res->mode);
6392 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6393 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6395 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6396 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6398 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6399 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6401 "" /* defined at init */);
6402 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6403 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6406 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6407 .f = cmd_set_fwd_retry_mode_parsed,
6409 .help_str = NULL, /* defined at init */
6411 (void *)&cmd_setfwd_retry_set,
6412 (void *)&cmd_setfwd_retry_fwd,
6413 (void *)&cmd_setfwd_retry_mode,
6414 (void *)&cmd_setfwd_retry_retry,
6419 static void cmd_set_fwd_retry_mode_init(void)
6422 static char token[128];
6423 static char help[256];
6424 cmdline_parse_token_string_t *token_struct;
6426 modes = list_pkt_forwarding_retry_modes();
6427 snprintf(help, sizeof(help), "set fwd %s retry: "
6428 "Set packet forwarding mode with retry", modes);
6429 cmd_set_fwd_retry_mode.help_str = help;
6431 /* string token separator is # */
6432 for (c = token; *modes != '\0'; modes++)
6437 token_struct = (cmdline_parse_token_string_t *)
6438 cmd_set_fwd_retry_mode.tokens[2];
6439 token_struct->string_data.str = token;
6442 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6443 struct cmd_set_burst_tx_retry_result {
6444 cmdline_fixed_string_t set;
6445 cmdline_fixed_string_t burst;
6446 cmdline_fixed_string_t tx;
6447 cmdline_fixed_string_t delay;
6449 cmdline_fixed_string_t retry;
6453 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6454 __attribute__((unused)) struct cmdline *cl,
6455 __attribute__((unused)) void *data)
6457 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6459 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6460 && !strcmp(res->tx, "tx")) {
6461 if (!strcmp(res->delay, "delay"))
6462 burst_tx_delay_time = res->time;
6463 if (!strcmp(res->retry, "retry"))
6464 burst_tx_retry_num = res->retry_num;
6469 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6470 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6471 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6472 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6474 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6475 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6476 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6477 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6478 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6479 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6480 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6481 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6482 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6483 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6485 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6486 .f = cmd_set_burst_tx_retry_parsed,
6487 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6489 (void *)&cmd_set_burst_tx_retry_set,
6490 (void *)&cmd_set_burst_tx_retry_burst,
6491 (void *)&cmd_set_burst_tx_retry_tx,
6492 (void *)&cmd_set_burst_tx_retry_delay,
6493 (void *)&cmd_set_burst_tx_retry_time,
6494 (void *)&cmd_set_burst_tx_retry_retry,
6495 (void *)&cmd_set_burst_tx_retry_retry_num,
6500 /* *** SET PROMISC MODE *** */
6501 struct cmd_set_promisc_mode_result {
6502 cmdline_fixed_string_t set;
6503 cmdline_fixed_string_t promisc;
6504 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6505 uint16_t port_num; /* valid if "allports" argument == 0 */
6506 cmdline_fixed_string_t mode;
6509 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6510 __attribute__((unused)) struct cmdline *cl,
6513 struct cmd_set_promisc_mode_result *res = parsed_result;
6517 if (!strcmp(res->mode, "on"))
6524 RTE_ETH_FOREACH_DEV(i) {
6526 rte_eth_promiscuous_enable(i);
6528 rte_eth_promiscuous_disable(i);
6533 rte_eth_promiscuous_enable(res->port_num);
6535 rte_eth_promiscuous_disable(res->port_num);
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) {
6606 rte_eth_allmulticast_enable(i);
6608 rte_eth_allmulticast_disable(i);
6613 rte_eth_allmulticast_enable(res->port_num);
6615 rte_eth_allmulticast_disable(res->port_num);
6619 cmdline_parse_token_string_t cmd_setallmulti_set =
6620 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6621 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6622 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6624 cmdline_parse_token_string_t cmd_setallmulti_portall =
6625 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6627 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6628 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6630 cmdline_parse_token_string_t cmd_setallmulti_mode =
6631 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6634 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6635 .f = cmd_set_allmulti_mode_parsed,
6637 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6639 (void *)&cmd_setallmulti_set,
6640 (void *)&cmd_setallmulti_allmulti,
6641 (void *)&cmd_setallmulti_portall,
6642 (void *)&cmd_setallmulti_mode,
6647 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6648 .f = cmd_set_allmulti_mode_parsed,
6650 .help_str = "set allmulti <port_id> on|off: "
6651 "Set allmulti mode on port_id",
6653 (void *)&cmd_setallmulti_set,
6654 (void *)&cmd_setallmulti_allmulti,
6655 (void *)&cmd_setallmulti_portnum,
6656 (void *)&cmd_setallmulti_mode,
6661 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6662 struct cmd_link_flow_ctrl_set_result {
6663 cmdline_fixed_string_t set;
6664 cmdline_fixed_string_t flow_ctrl;
6665 cmdline_fixed_string_t rx;
6666 cmdline_fixed_string_t rx_lfc_mode;
6667 cmdline_fixed_string_t tx;
6668 cmdline_fixed_string_t tx_lfc_mode;
6669 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6670 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6671 cmdline_fixed_string_t autoneg_str;
6672 cmdline_fixed_string_t autoneg;
6673 cmdline_fixed_string_t hw_str;
6674 uint32_t high_water;
6675 cmdline_fixed_string_t lw_str;
6677 cmdline_fixed_string_t pt_str;
6678 uint16_t pause_time;
6679 cmdline_fixed_string_t xon_str;
6684 cmdline_parse_token_string_t cmd_lfc_set_set =
6685 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6687 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6688 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6689 flow_ctrl, "flow_ctrl");
6690 cmdline_parse_token_string_t cmd_lfc_set_rx =
6691 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6693 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6694 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6695 rx_lfc_mode, "on#off");
6696 cmdline_parse_token_string_t cmd_lfc_set_tx =
6697 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6699 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6700 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6701 tx_lfc_mode, "on#off");
6702 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6703 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6704 hw_str, "high_water");
6705 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6706 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6707 high_water, UINT32);
6708 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6709 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6710 lw_str, "low_water");
6711 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6712 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6714 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6715 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6716 pt_str, "pause_time");
6717 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6718 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6719 pause_time, UINT16);
6720 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6721 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6722 xon_str, "send_xon");
6723 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6724 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6726 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6727 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6728 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6729 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6730 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6731 mac_ctrl_frame_fwd_mode, "on#off");
6732 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6733 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6734 autoneg_str, "autoneg");
6735 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6736 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6738 cmdline_parse_token_num_t cmd_lfc_set_portid =
6739 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6742 /* forward declaration */
6744 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6747 cmdline_parse_inst_t cmd_link_flow_control_set = {
6748 .f = cmd_link_flow_ctrl_set_parsed,
6750 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6751 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6752 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6754 (void *)&cmd_lfc_set_set,
6755 (void *)&cmd_lfc_set_flow_ctrl,
6756 (void *)&cmd_lfc_set_rx,
6757 (void *)&cmd_lfc_set_rx_mode,
6758 (void *)&cmd_lfc_set_tx,
6759 (void *)&cmd_lfc_set_tx_mode,
6760 (void *)&cmd_lfc_set_high_water,
6761 (void *)&cmd_lfc_set_low_water,
6762 (void *)&cmd_lfc_set_pause_time,
6763 (void *)&cmd_lfc_set_send_xon,
6764 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6765 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6766 (void *)&cmd_lfc_set_autoneg_str,
6767 (void *)&cmd_lfc_set_autoneg,
6768 (void *)&cmd_lfc_set_portid,
6773 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6774 .f = cmd_link_flow_ctrl_set_parsed,
6775 .data = (void *)&cmd_link_flow_control_set_rx,
6776 .help_str = "set flow_ctrl rx on|off <port_id>: "
6777 "Change rx flow control parameter",
6779 (void *)&cmd_lfc_set_set,
6780 (void *)&cmd_lfc_set_flow_ctrl,
6781 (void *)&cmd_lfc_set_rx,
6782 (void *)&cmd_lfc_set_rx_mode,
6783 (void *)&cmd_lfc_set_portid,
6788 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6789 .f = cmd_link_flow_ctrl_set_parsed,
6790 .data = (void *)&cmd_link_flow_control_set_tx,
6791 .help_str = "set flow_ctrl tx on|off <port_id>: "
6792 "Change tx flow control parameter",
6794 (void *)&cmd_lfc_set_set,
6795 (void *)&cmd_lfc_set_flow_ctrl,
6796 (void *)&cmd_lfc_set_tx,
6797 (void *)&cmd_lfc_set_tx_mode,
6798 (void *)&cmd_lfc_set_portid,
6803 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6804 .f = cmd_link_flow_ctrl_set_parsed,
6805 .data = (void *)&cmd_link_flow_control_set_hw,
6806 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6807 "Change high water flow control parameter",
6809 (void *)&cmd_lfc_set_set,
6810 (void *)&cmd_lfc_set_flow_ctrl,
6811 (void *)&cmd_lfc_set_high_water_str,
6812 (void *)&cmd_lfc_set_high_water,
6813 (void *)&cmd_lfc_set_portid,
6818 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6819 .f = cmd_link_flow_ctrl_set_parsed,
6820 .data = (void *)&cmd_link_flow_control_set_lw,
6821 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6822 "Change low water flow control parameter",
6824 (void *)&cmd_lfc_set_set,
6825 (void *)&cmd_lfc_set_flow_ctrl,
6826 (void *)&cmd_lfc_set_low_water_str,
6827 (void *)&cmd_lfc_set_low_water,
6828 (void *)&cmd_lfc_set_portid,
6833 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6834 .f = cmd_link_flow_ctrl_set_parsed,
6835 .data = (void *)&cmd_link_flow_control_set_pt,
6836 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6837 "Change pause time flow control parameter",
6839 (void *)&cmd_lfc_set_set,
6840 (void *)&cmd_lfc_set_flow_ctrl,
6841 (void *)&cmd_lfc_set_pause_time_str,
6842 (void *)&cmd_lfc_set_pause_time,
6843 (void *)&cmd_lfc_set_portid,
6848 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6849 .f = cmd_link_flow_ctrl_set_parsed,
6850 .data = (void *)&cmd_link_flow_control_set_xon,
6851 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6852 "Change send_xon flow control parameter",
6854 (void *)&cmd_lfc_set_set,
6855 (void *)&cmd_lfc_set_flow_ctrl,
6856 (void *)&cmd_lfc_set_send_xon_str,
6857 (void *)&cmd_lfc_set_send_xon,
6858 (void *)&cmd_lfc_set_portid,
6863 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6864 .f = cmd_link_flow_ctrl_set_parsed,
6865 .data = (void *)&cmd_link_flow_control_set_macfwd,
6866 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6867 "Change mac ctrl fwd flow control parameter",
6869 (void *)&cmd_lfc_set_set,
6870 (void *)&cmd_lfc_set_flow_ctrl,
6871 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6872 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6873 (void *)&cmd_lfc_set_portid,
6878 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6879 .f = cmd_link_flow_ctrl_set_parsed,
6880 .data = (void *)&cmd_link_flow_control_set_autoneg,
6881 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6882 "Change autoneg flow control parameter",
6884 (void *)&cmd_lfc_set_set,
6885 (void *)&cmd_lfc_set_flow_ctrl,
6886 (void *)&cmd_lfc_set_autoneg_str,
6887 (void *)&cmd_lfc_set_autoneg,
6888 (void *)&cmd_lfc_set_portid,
6894 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6895 __attribute__((unused)) struct cmdline *cl,
6898 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6899 cmdline_parse_inst_t *cmd = data;
6900 struct rte_eth_fc_conf fc_conf;
6906 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6907 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6908 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6909 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6911 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6912 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6915 /* Partial command line, retrieve current configuration */
6917 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6919 printf("cannot get current flow ctrl parameters, return"
6920 "code = %d\n", ret);
6924 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6925 (fc_conf.mode == RTE_FC_FULL))
6927 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6928 (fc_conf.mode == RTE_FC_FULL))
6932 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6933 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6935 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6936 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6938 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6940 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6941 fc_conf.high_water = res->high_water;
6943 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6944 fc_conf.low_water = res->low_water;
6946 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6947 fc_conf.pause_time = res->pause_time;
6949 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6950 fc_conf.send_xon = res->send_xon;
6952 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6953 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6954 fc_conf.mac_ctrl_frame_fwd = 1;
6956 fc_conf.mac_ctrl_frame_fwd = 0;
6959 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6960 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6962 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6964 printf("bad flow contrl parameter, return code = %d \n", ret);
6967 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6968 struct cmd_priority_flow_ctrl_set_result {
6969 cmdline_fixed_string_t set;
6970 cmdline_fixed_string_t pfc_ctrl;
6971 cmdline_fixed_string_t rx;
6972 cmdline_fixed_string_t rx_pfc_mode;
6973 cmdline_fixed_string_t tx;
6974 cmdline_fixed_string_t tx_pfc_mode;
6975 uint32_t high_water;
6977 uint16_t pause_time;
6983 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6984 __attribute__((unused)) struct cmdline *cl,
6985 __attribute__((unused)) void *data)
6987 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6988 struct rte_eth_pfc_conf pfc_conf;
6989 int rx_fc_enable, tx_fc_enable;
6993 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6994 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6995 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6996 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6998 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6999 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
7002 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7003 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7004 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7005 pfc_conf.fc.high_water = res->high_water;
7006 pfc_conf.fc.low_water = res->low_water;
7007 pfc_conf.fc.pause_time = res->pause_time;
7008 pfc_conf.priority = res->priority;
7010 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7012 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7015 cmdline_parse_token_string_t cmd_pfc_set_set =
7016 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7018 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7019 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7020 pfc_ctrl, "pfc_ctrl");
7021 cmdline_parse_token_string_t cmd_pfc_set_rx =
7022 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7024 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7025 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7026 rx_pfc_mode, "on#off");
7027 cmdline_parse_token_string_t cmd_pfc_set_tx =
7028 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7030 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7031 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7032 tx_pfc_mode, "on#off");
7033 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7034 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7035 high_water, UINT32);
7036 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7037 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7039 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7040 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7041 pause_time, UINT16);
7042 cmdline_parse_token_num_t cmd_pfc_set_priority =
7043 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7045 cmdline_parse_token_num_t cmd_pfc_set_portid =
7046 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7049 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7050 .f = cmd_priority_flow_ctrl_set_parsed,
7052 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7053 "<pause_time> <priority> <port_id>: "
7054 "Configure the Ethernet priority flow control",
7056 (void *)&cmd_pfc_set_set,
7057 (void *)&cmd_pfc_set_flow_ctrl,
7058 (void *)&cmd_pfc_set_rx,
7059 (void *)&cmd_pfc_set_rx_mode,
7060 (void *)&cmd_pfc_set_tx,
7061 (void *)&cmd_pfc_set_tx_mode,
7062 (void *)&cmd_pfc_set_high_water,
7063 (void *)&cmd_pfc_set_low_water,
7064 (void *)&cmd_pfc_set_pause_time,
7065 (void *)&cmd_pfc_set_priority,
7066 (void *)&cmd_pfc_set_portid,
7071 /* *** RESET CONFIGURATION *** */
7072 struct cmd_reset_result {
7073 cmdline_fixed_string_t reset;
7074 cmdline_fixed_string_t def;
7077 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
7079 __attribute__((unused)) void *data)
7081 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7082 set_def_fwd_config();
7085 cmdline_parse_token_string_t cmd_reset_set =
7086 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7087 cmdline_parse_token_string_t cmd_reset_def =
7088 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7091 cmdline_parse_inst_t cmd_reset = {
7092 .f = cmd_reset_parsed,
7094 .help_str = "set default: Reset default forwarding configuration",
7096 (void *)&cmd_reset_set,
7097 (void *)&cmd_reset_def,
7102 /* *** START FORWARDING *** */
7103 struct cmd_start_result {
7104 cmdline_fixed_string_t start;
7107 cmdline_parse_token_string_t cmd_start_start =
7108 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7110 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
7111 __attribute__((unused)) struct cmdline *cl,
7112 __attribute__((unused)) void *data)
7114 start_packet_forwarding(0);
7117 cmdline_parse_inst_t cmd_start = {
7118 .f = cmd_start_parsed,
7120 .help_str = "start: Start packet forwarding",
7122 (void *)&cmd_start_start,
7127 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7128 struct cmd_start_tx_first_result {
7129 cmdline_fixed_string_t start;
7130 cmdline_fixed_string_t tx_first;
7134 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
7135 __attribute__((unused)) struct cmdline *cl,
7136 __attribute__((unused)) void *data)
7138 start_packet_forwarding(1);
7141 cmdline_parse_token_string_t cmd_start_tx_first_start =
7142 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7144 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7145 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7146 tx_first, "tx_first");
7148 cmdline_parse_inst_t cmd_start_tx_first = {
7149 .f = cmd_start_tx_first_parsed,
7151 .help_str = "start tx_first: Start packet forwarding, "
7152 "after sending 1 burst of packets",
7154 (void *)&cmd_start_tx_first_start,
7155 (void *)&cmd_start_tx_first_tx_first,
7160 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7161 struct cmd_start_tx_first_n_result {
7162 cmdline_fixed_string_t start;
7163 cmdline_fixed_string_t tx_first;
7168 cmd_start_tx_first_n_parsed(void *parsed_result,
7169 __attribute__((unused)) struct cmdline *cl,
7170 __attribute__((unused)) void *data)
7172 struct cmd_start_tx_first_n_result *res = parsed_result;
7174 start_packet_forwarding(res->tx_num);
7177 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7178 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7180 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7181 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7182 tx_first, "tx_first");
7183 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7184 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7187 cmdline_parse_inst_t cmd_start_tx_first_n = {
7188 .f = cmd_start_tx_first_n_parsed,
7190 .help_str = "start tx_first <num>: "
7191 "packet forwarding, after sending <num> bursts of packets",
7193 (void *)&cmd_start_tx_first_n_start,
7194 (void *)&cmd_start_tx_first_n_tx_first,
7195 (void *)&cmd_start_tx_first_n_tx_num,
7200 /* *** SET LINK UP *** */
7201 struct cmd_set_link_up_result {
7202 cmdline_fixed_string_t set;
7203 cmdline_fixed_string_t link_up;
7204 cmdline_fixed_string_t port;
7208 cmdline_parse_token_string_t cmd_set_link_up_set =
7209 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7210 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7211 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7213 cmdline_parse_token_string_t cmd_set_link_up_port =
7214 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7215 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7216 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7218 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
7219 __attribute__((unused)) struct cmdline *cl,
7220 __attribute__((unused)) void *data)
7222 struct cmd_set_link_up_result *res = parsed_result;
7223 dev_set_link_up(res->port_id);
7226 cmdline_parse_inst_t cmd_set_link_up = {
7227 .f = cmd_set_link_up_parsed,
7229 .help_str = "set link-up port <port id>",
7231 (void *)&cmd_set_link_up_set,
7232 (void *)&cmd_set_link_up_link_up,
7233 (void *)&cmd_set_link_up_port,
7234 (void *)&cmd_set_link_up_port_id,
7239 /* *** SET LINK DOWN *** */
7240 struct cmd_set_link_down_result {
7241 cmdline_fixed_string_t set;
7242 cmdline_fixed_string_t link_down;
7243 cmdline_fixed_string_t port;
7247 cmdline_parse_token_string_t cmd_set_link_down_set =
7248 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7249 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7250 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7252 cmdline_parse_token_string_t cmd_set_link_down_port =
7253 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7254 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7255 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7257 static void cmd_set_link_down_parsed(
7258 __attribute__((unused)) void *parsed_result,
7259 __attribute__((unused)) struct cmdline *cl,
7260 __attribute__((unused)) void *data)
7262 struct cmd_set_link_down_result *res = parsed_result;
7263 dev_set_link_down(res->port_id);
7266 cmdline_parse_inst_t cmd_set_link_down = {
7267 .f = cmd_set_link_down_parsed,
7269 .help_str = "set link-down port <port id>",
7271 (void *)&cmd_set_link_down_set,
7272 (void *)&cmd_set_link_down_link_down,
7273 (void *)&cmd_set_link_down_port,
7274 (void *)&cmd_set_link_down_port_id,
7279 /* *** SHOW CFG *** */
7280 struct cmd_showcfg_result {
7281 cmdline_fixed_string_t show;
7282 cmdline_fixed_string_t cfg;
7283 cmdline_fixed_string_t what;
7286 static void cmd_showcfg_parsed(void *parsed_result,
7287 __attribute__((unused)) struct cmdline *cl,
7288 __attribute__((unused)) void *data)
7290 struct cmd_showcfg_result *res = parsed_result;
7291 if (!strcmp(res->what, "rxtx"))
7292 rxtx_config_display();
7293 else if (!strcmp(res->what, "cores"))
7294 fwd_lcores_config_display();
7295 else if (!strcmp(res->what, "fwd"))
7296 pkt_fwd_config_display(&cur_fwd_config);
7297 else if (!strcmp(res->what, "txpkts"))
7298 show_tx_pkt_segments();
7301 cmdline_parse_token_string_t cmd_showcfg_show =
7302 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7303 cmdline_parse_token_string_t cmd_showcfg_port =
7304 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7305 cmdline_parse_token_string_t cmd_showcfg_what =
7306 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7307 "rxtx#cores#fwd#txpkts");
7309 cmdline_parse_inst_t cmd_showcfg = {
7310 .f = cmd_showcfg_parsed,
7312 .help_str = "show config rxtx|cores|fwd|txpkts",
7314 (void *)&cmd_showcfg_show,
7315 (void *)&cmd_showcfg_port,
7316 (void *)&cmd_showcfg_what,
7321 /* *** SHOW ALL PORT INFO *** */
7322 struct cmd_showportall_result {
7323 cmdline_fixed_string_t show;
7324 cmdline_fixed_string_t port;
7325 cmdline_fixed_string_t what;
7326 cmdline_fixed_string_t all;
7329 static void cmd_showportall_parsed(void *parsed_result,
7330 __attribute__((unused)) struct cmdline *cl,
7331 __attribute__((unused)) void *data)
7335 struct cmd_showportall_result *res = parsed_result;
7336 if (!strcmp(res->show, "clear")) {
7337 if (!strcmp(res->what, "stats"))
7338 RTE_ETH_FOREACH_DEV(i)
7340 else if (!strcmp(res->what, "xstats"))
7341 RTE_ETH_FOREACH_DEV(i)
7342 nic_xstats_clear(i);
7343 } else if (!strcmp(res->what, "info"))
7344 RTE_ETH_FOREACH_DEV(i)
7345 port_infos_display(i);
7346 else if (!strcmp(res->what, "summary")) {
7347 port_summary_header_display();
7348 RTE_ETH_FOREACH_DEV(i)
7349 port_summary_display(i);
7351 else if (!strcmp(res->what, "stats"))
7352 RTE_ETH_FOREACH_DEV(i)
7353 nic_stats_display(i);
7354 else if (!strcmp(res->what, "xstats"))
7355 RTE_ETH_FOREACH_DEV(i)
7356 nic_xstats_display(i);
7357 else if (!strcmp(res->what, "fdir"))
7358 RTE_ETH_FOREACH_DEV(i)
7360 else if (!strcmp(res->what, "stat_qmap"))
7361 RTE_ETH_FOREACH_DEV(i)
7362 nic_stats_mapping_display(i);
7363 else if (!strcmp(res->what, "dcb_tc"))
7364 RTE_ETH_FOREACH_DEV(i)
7365 port_dcb_info_display(i);
7366 else if (!strcmp(res->what, "cap"))
7367 RTE_ETH_FOREACH_DEV(i)
7368 port_offload_cap_display(i);
7371 cmdline_parse_token_string_t cmd_showportall_show =
7372 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7374 cmdline_parse_token_string_t cmd_showportall_port =
7375 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7376 cmdline_parse_token_string_t cmd_showportall_what =
7377 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7378 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7379 cmdline_parse_token_string_t cmd_showportall_all =
7380 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7381 cmdline_parse_inst_t cmd_showportall = {
7382 .f = cmd_showportall_parsed,
7384 .help_str = "show|clear port "
7385 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7387 (void *)&cmd_showportall_show,
7388 (void *)&cmd_showportall_port,
7389 (void *)&cmd_showportall_what,
7390 (void *)&cmd_showportall_all,
7395 /* *** SHOW PORT INFO *** */
7396 struct cmd_showport_result {
7397 cmdline_fixed_string_t show;
7398 cmdline_fixed_string_t port;
7399 cmdline_fixed_string_t what;
7403 static void cmd_showport_parsed(void *parsed_result,
7404 __attribute__((unused)) struct cmdline *cl,
7405 __attribute__((unused)) void *data)
7407 struct cmd_showport_result *res = parsed_result;
7408 if (!strcmp(res->show, "clear")) {
7409 if (!strcmp(res->what, "stats"))
7410 nic_stats_clear(res->portnum);
7411 else if (!strcmp(res->what, "xstats"))
7412 nic_xstats_clear(res->portnum);
7413 } else if (!strcmp(res->what, "info"))
7414 port_infos_display(res->portnum);
7415 else if (!strcmp(res->what, "summary")) {
7416 port_summary_header_display();
7417 port_summary_display(res->portnum);
7419 else if (!strcmp(res->what, "stats"))
7420 nic_stats_display(res->portnum);
7421 else if (!strcmp(res->what, "xstats"))
7422 nic_xstats_display(res->portnum);
7423 else if (!strcmp(res->what, "fdir"))
7424 fdir_get_infos(res->portnum);
7425 else if (!strcmp(res->what, "stat_qmap"))
7426 nic_stats_mapping_display(res->portnum);
7427 else if (!strcmp(res->what, "dcb_tc"))
7428 port_dcb_info_display(res->portnum);
7429 else if (!strcmp(res->what, "cap"))
7430 port_offload_cap_display(res->portnum);
7433 cmdline_parse_token_string_t cmd_showport_show =
7434 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7436 cmdline_parse_token_string_t cmd_showport_port =
7437 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7438 cmdline_parse_token_string_t cmd_showport_what =
7439 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7440 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7441 cmdline_parse_token_num_t cmd_showport_portnum =
7442 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7444 cmdline_parse_inst_t cmd_showport = {
7445 .f = cmd_showport_parsed,
7447 .help_str = "show|clear port "
7448 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7451 (void *)&cmd_showport_show,
7452 (void *)&cmd_showport_port,
7453 (void *)&cmd_showport_what,
7454 (void *)&cmd_showport_portnum,
7459 /* *** SHOW QUEUE INFO *** */
7460 struct cmd_showqueue_result {
7461 cmdline_fixed_string_t show;
7462 cmdline_fixed_string_t type;
7463 cmdline_fixed_string_t what;
7469 cmd_showqueue_parsed(void *parsed_result,
7470 __attribute__((unused)) struct cmdline *cl,
7471 __attribute__((unused)) void *data)
7473 struct cmd_showqueue_result *res = parsed_result;
7475 if (!strcmp(res->type, "rxq"))
7476 rx_queue_infos_display(res->portnum, res->queuenum);
7477 else if (!strcmp(res->type, "txq"))
7478 tx_queue_infos_display(res->portnum, res->queuenum);
7481 cmdline_parse_token_string_t cmd_showqueue_show =
7482 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7483 cmdline_parse_token_string_t cmd_showqueue_type =
7484 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7485 cmdline_parse_token_string_t cmd_showqueue_what =
7486 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7487 cmdline_parse_token_num_t cmd_showqueue_portnum =
7488 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7489 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7490 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7492 cmdline_parse_inst_t cmd_showqueue = {
7493 .f = cmd_showqueue_parsed,
7495 .help_str = "show rxq|txq info <port_id> <queue_id>",
7497 (void *)&cmd_showqueue_show,
7498 (void *)&cmd_showqueue_type,
7499 (void *)&cmd_showqueue_what,
7500 (void *)&cmd_showqueue_portnum,
7501 (void *)&cmd_showqueue_queuenum,
7506 /* show/clear fwd engine statistics */
7508 cmdline_fixed_string_t action;
7509 cmdline_fixed_string_t fwd;
7510 cmdline_fixed_string_t stats;
7511 cmdline_fixed_string_t all;
7514 cmdline_parse_token_string_t cmd_fwd_action =
7515 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7516 cmdline_parse_token_string_t cmd_fwd_fwd =
7517 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7518 cmdline_parse_token_string_t cmd_fwd_stats =
7519 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7520 cmdline_parse_token_string_t cmd_fwd_all =
7521 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7524 cmd_showfwdall_parsed(void *parsed_result,
7525 __rte_unused struct cmdline *cl,
7526 __rte_unused void *data)
7528 struct fwd_result *res = parsed_result;
7530 if (!strcmp(res->action, "show"))
7531 fwd_stats_display();
7536 static cmdline_parse_inst_t cmd_showfwdall = {
7537 .f = cmd_showfwdall_parsed,
7539 .help_str = "show|clear fwd stats all",
7541 (void *)&cmd_fwd_action,
7542 (void *)&cmd_fwd_fwd,
7543 (void *)&cmd_fwd_stats,
7544 (void *)&cmd_fwd_all,
7549 /* *** READ PORT REGISTER *** */
7550 struct cmd_read_reg_result {
7551 cmdline_fixed_string_t read;
7552 cmdline_fixed_string_t reg;
7558 cmd_read_reg_parsed(void *parsed_result,
7559 __attribute__((unused)) struct cmdline *cl,
7560 __attribute__((unused)) void *data)
7562 struct cmd_read_reg_result *res = parsed_result;
7563 port_reg_display(res->port_id, res->reg_off);
7566 cmdline_parse_token_string_t cmd_read_reg_read =
7567 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7568 cmdline_parse_token_string_t cmd_read_reg_reg =
7569 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7570 cmdline_parse_token_num_t cmd_read_reg_port_id =
7571 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7572 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7573 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7575 cmdline_parse_inst_t cmd_read_reg = {
7576 .f = cmd_read_reg_parsed,
7578 .help_str = "read reg <port_id> <reg_off>",
7580 (void *)&cmd_read_reg_read,
7581 (void *)&cmd_read_reg_reg,
7582 (void *)&cmd_read_reg_port_id,
7583 (void *)&cmd_read_reg_reg_off,
7588 /* *** READ PORT REGISTER BIT FIELD *** */
7589 struct cmd_read_reg_bit_field_result {
7590 cmdline_fixed_string_t read;
7591 cmdline_fixed_string_t regfield;
7599 cmd_read_reg_bit_field_parsed(void *parsed_result,
7600 __attribute__((unused)) struct cmdline *cl,
7601 __attribute__((unused)) void *data)
7603 struct cmd_read_reg_bit_field_result *res = parsed_result;
7604 port_reg_bit_field_display(res->port_id, res->reg_off,
7605 res->bit1_pos, res->bit2_pos);
7608 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7609 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7611 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7612 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7613 regfield, "regfield");
7614 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7615 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7617 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7618 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7620 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7621 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7623 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7624 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7627 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7628 .f = cmd_read_reg_bit_field_parsed,
7630 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7631 "Read register bit field between bit_x and bit_y included",
7633 (void *)&cmd_read_reg_bit_field_read,
7634 (void *)&cmd_read_reg_bit_field_regfield,
7635 (void *)&cmd_read_reg_bit_field_port_id,
7636 (void *)&cmd_read_reg_bit_field_reg_off,
7637 (void *)&cmd_read_reg_bit_field_bit1_pos,
7638 (void *)&cmd_read_reg_bit_field_bit2_pos,
7643 /* *** READ PORT REGISTER BIT *** */
7644 struct cmd_read_reg_bit_result {
7645 cmdline_fixed_string_t read;
7646 cmdline_fixed_string_t regbit;
7653 cmd_read_reg_bit_parsed(void *parsed_result,
7654 __attribute__((unused)) struct cmdline *cl,
7655 __attribute__((unused)) void *data)
7657 struct cmd_read_reg_bit_result *res = parsed_result;
7658 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7661 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7662 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7663 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7664 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7666 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7667 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7668 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7669 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7670 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7671 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7673 cmdline_parse_inst_t cmd_read_reg_bit = {
7674 .f = cmd_read_reg_bit_parsed,
7676 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7678 (void *)&cmd_read_reg_bit_read,
7679 (void *)&cmd_read_reg_bit_regbit,
7680 (void *)&cmd_read_reg_bit_port_id,
7681 (void *)&cmd_read_reg_bit_reg_off,
7682 (void *)&cmd_read_reg_bit_bit_pos,
7687 /* *** WRITE PORT REGISTER *** */
7688 struct cmd_write_reg_result {
7689 cmdline_fixed_string_t write;
7690 cmdline_fixed_string_t reg;
7697 cmd_write_reg_parsed(void *parsed_result,
7698 __attribute__((unused)) struct cmdline *cl,
7699 __attribute__((unused)) void *data)
7701 struct cmd_write_reg_result *res = parsed_result;
7702 port_reg_set(res->port_id, res->reg_off, res->value);
7705 cmdline_parse_token_string_t cmd_write_reg_write =
7706 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7707 cmdline_parse_token_string_t cmd_write_reg_reg =
7708 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7709 cmdline_parse_token_num_t cmd_write_reg_port_id =
7710 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7711 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7712 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7713 cmdline_parse_token_num_t cmd_write_reg_value =
7714 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7716 cmdline_parse_inst_t cmd_write_reg = {
7717 .f = cmd_write_reg_parsed,
7719 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7721 (void *)&cmd_write_reg_write,
7722 (void *)&cmd_write_reg_reg,
7723 (void *)&cmd_write_reg_port_id,
7724 (void *)&cmd_write_reg_reg_off,
7725 (void *)&cmd_write_reg_value,
7730 /* *** WRITE PORT REGISTER BIT FIELD *** */
7731 struct cmd_write_reg_bit_field_result {
7732 cmdline_fixed_string_t write;
7733 cmdline_fixed_string_t regfield;
7742 cmd_write_reg_bit_field_parsed(void *parsed_result,
7743 __attribute__((unused)) struct cmdline *cl,
7744 __attribute__((unused)) void *data)
7746 struct cmd_write_reg_bit_field_result *res = parsed_result;
7747 port_reg_bit_field_set(res->port_id, res->reg_off,
7748 res->bit1_pos, res->bit2_pos, res->value);
7751 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7752 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7754 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7755 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7756 regfield, "regfield");
7757 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7758 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7760 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7761 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7763 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7764 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7766 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7767 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7769 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7770 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7773 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7774 .f = cmd_write_reg_bit_field_parsed,
7776 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7778 "Set register bit field between bit_x and bit_y included",
7780 (void *)&cmd_write_reg_bit_field_write,
7781 (void *)&cmd_write_reg_bit_field_regfield,
7782 (void *)&cmd_write_reg_bit_field_port_id,
7783 (void *)&cmd_write_reg_bit_field_reg_off,
7784 (void *)&cmd_write_reg_bit_field_bit1_pos,
7785 (void *)&cmd_write_reg_bit_field_bit2_pos,
7786 (void *)&cmd_write_reg_bit_field_value,
7791 /* *** WRITE PORT REGISTER BIT *** */
7792 struct cmd_write_reg_bit_result {
7793 cmdline_fixed_string_t write;
7794 cmdline_fixed_string_t regbit;
7802 cmd_write_reg_bit_parsed(void *parsed_result,
7803 __attribute__((unused)) struct cmdline *cl,
7804 __attribute__((unused)) void *data)
7806 struct cmd_write_reg_bit_result *res = parsed_result;
7807 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7810 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7811 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7813 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7814 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7816 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7817 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7818 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7819 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7820 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7821 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7822 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7823 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7825 cmdline_parse_inst_t cmd_write_reg_bit = {
7826 .f = cmd_write_reg_bit_parsed,
7828 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7831 (void *)&cmd_write_reg_bit_write,
7832 (void *)&cmd_write_reg_bit_regbit,
7833 (void *)&cmd_write_reg_bit_port_id,
7834 (void *)&cmd_write_reg_bit_reg_off,
7835 (void *)&cmd_write_reg_bit_bit_pos,
7836 (void *)&cmd_write_reg_bit_value,
7841 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7842 struct cmd_read_rxd_txd_result {
7843 cmdline_fixed_string_t read;
7844 cmdline_fixed_string_t rxd_txd;
7851 cmd_read_rxd_txd_parsed(void *parsed_result,
7852 __attribute__((unused)) struct cmdline *cl,
7853 __attribute__((unused)) void *data)
7855 struct cmd_read_rxd_txd_result *res = parsed_result;
7857 if (!strcmp(res->rxd_txd, "rxd"))
7858 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7859 else if (!strcmp(res->rxd_txd, "txd"))
7860 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7863 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7864 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7865 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7866 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7868 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7869 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7870 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7871 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7872 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7873 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7875 cmdline_parse_inst_t cmd_read_rxd_txd = {
7876 .f = cmd_read_rxd_txd_parsed,
7878 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7880 (void *)&cmd_read_rxd_txd_read,
7881 (void *)&cmd_read_rxd_txd_rxd_txd,
7882 (void *)&cmd_read_rxd_txd_port_id,
7883 (void *)&cmd_read_rxd_txd_queue_id,
7884 (void *)&cmd_read_rxd_txd_desc_id,
7890 struct cmd_quit_result {
7891 cmdline_fixed_string_t quit;
7894 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7896 __attribute__((unused)) void *data)
7901 cmdline_parse_token_string_t cmd_quit_quit =
7902 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7904 cmdline_parse_inst_t cmd_quit = {
7905 .f = cmd_quit_parsed,
7907 .help_str = "quit: Exit application",
7909 (void *)&cmd_quit_quit,
7914 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7915 struct cmd_mac_addr_result {
7916 cmdline_fixed_string_t mac_addr_cmd;
7917 cmdline_fixed_string_t what;
7919 struct rte_ether_addr address;
7922 static void cmd_mac_addr_parsed(void *parsed_result,
7923 __attribute__((unused)) struct cmdline *cl,
7924 __attribute__((unused)) void *data)
7926 struct cmd_mac_addr_result *res = parsed_result;
7929 if (strcmp(res->what, "add") == 0)
7930 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7931 else if (strcmp(res->what, "set") == 0)
7932 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7935 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7937 /* check the return value and print it if is < 0 */
7939 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7943 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7944 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7946 cmdline_parse_token_string_t cmd_mac_addr_what =
7947 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7949 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7950 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7952 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7953 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7955 cmdline_parse_inst_t cmd_mac_addr = {
7956 .f = cmd_mac_addr_parsed,
7958 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7959 "Add/Remove/Set MAC address on port_id",
7961 (void *)&cmd_mac_addr_cmd,
7962 (void *)&cmd_mac_addr_what,
7963 (void *)&cmd_mac_addr_portnum,
7964 (void *)&cmd_mac_addr_addr,
7969 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7970 struct cmd_eth_peer_result {
7971 cmdline_fixed_string_t set;
7972 cmdline_fixed_string_t eth_peer;
7974 cmdline_fixed_string_t peer_addr;
7977 static void cmd_set_eth_peer_parsed(void *parsed_result,
7978 __attribute__((unused)) struct cmdline *cl,
7979 __attribute__((unused)) void *data)
7981 struct cmd_eth_peer_result *res = parsed_result;
7983 if (test_done == 0) {
7984 printf("Please stop forwarding first\n");
7987 if (!strcmp(res->eth_peer, "eth-peer")) {
7988 set_fwd_eth_peer(res->port_id, res->peer_addr);
7992 cmdline_parse_token_string_t cmd_eth_peer_set =
7993 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7994 cmdline_parse_token_string_t cmd_eth_peer =
7995 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7996 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7997 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7998 cmdline_parse_token_string_t cmd_eth_peer_addr =
7999 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8001 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8002 .f = cmd_set_eth_peer_parsed,
8004 .help_str = "set eth-peer <port_id> <peer_mac>",
8006 (void *)&cmd_eth_peer_set,
8007 (void *)&cmd_eth_peer,
8008 (void *)&cmd_eth_peer_port_id,
8009 (void *)&cmd_eth_peer_addr,
8014 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8015 struct cmd_set_qmap_result {
8016 cmdline_fixed_string_t set;
8017 cmdline_fixed_string_t qmap;
8018 cmdline_fixed_string_t what;
8025 cmd_set_qmap_parsed(void *parsed_result,
8026 __attribute__((unused)) struct cmdline *cl,
8027 __attribute__((unused)) void *data)
8029 struct cmd_set_qmap_result *res = parsed_result;
8030 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8032 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8035 cmdline_parse_token_string_t cmd_setqmap_set =
8036 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8038 cmdline_parse_token_string_t cmd_setqmap_qmap =
8039 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8041 cmdline_parse_token_string_t cmd_setqmap_what =
8042 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8044 cmdline_parse_token_num_t cmd_setqmap_portid =
8045 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8047 cmdline_parse_token_num_t cmd_setqmap_queueid =
8048 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8050 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8051 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8054 cmdline_parse_inst_t cmd_set_qmap = {
8055 .f = cmd_set_qmap_parsed,
8057 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8058 "Set statistics mapping value on tx|rx queue_id of port_id",
8060 (void *)&cmd_setqmap_set,
8061 (void *)&cmd_setqmap_qmap,
8062 (void *)&cmd_setqmap_what,
8063 (void *)&cmd_setqmap_portid,
8064 (void *)&cmd_setqmap_queueid,
8065 (void *)&cmd_setqmap_mapvalue,
8070 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8071 struct cmd_set_xstats_hide_zero_result {
8072 cmdline_fixed_string_t keyword;
8073 cmdline_fixed_string_t name;
8074 cmdline_fixed_string_t on_off;
8078 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8079 __attribute__((unused)) struct cmdline *cl,
8080 __attribute__((unused)) void *data)
8082 struct cmd_set_xstats_hide_zero_result *res;
8083 uint16_t on_off = 0;
8085 res = parsed_result;
8086 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8087 set_xstats_hide_zero(on_off);
8090 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8091 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8093 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8094 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8095 name, "xstats-hide-zero");
8096 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8097 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8100 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8101 .f = cmd_set_xstats_hide_zero_parsed,
8103 .help_str = "set xstats-hide-zero on|off",
8105 (void *)&cmd_set_xstats_hide_zero_keyword,
8106 (void *)&cmd_set_xstats_hide_zero_name,
8107 (void *)&cmd_set_xstats_hide_zero_on_off,
8112 /* *** CONFIGURE UNICAST HASH TABLE *** */
8113 struct cmd_set_uc_hash_table {
8114 cmdline_fixed_string_t set;
8115 cmdline_fixed_string_t port;
8117 cmdline_fixed_string_t what;
8118 struct rte_ether_addr address;
8119 cmdline_fixed_string_t mode;
8123 cmd_set_uc_hash_parsed(void *parsed_result,
8124 __attribute__((unused)) struct cmdline *cl,
8125 __attribute__((unused)) void *data)
8128 struct cmd_set_uc_hash_table *res = parsed_result;
8130 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8132 if (strcmp(res->what, "uta") == 0)
8133 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8134 &res->address,(uint8_t)is_on);
8136 printf("bad unicast hash table parameter, return code = %d \n", ret);
8140 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8141 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8143 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8144 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8146 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8147 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8149 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8150 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8152 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8153 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8155 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8156 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8159 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8160 .f = cmd_set_uc_hash_parsed,
8162 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8164 (void *)&cmd_set_uc_hash_set,
8165 (void *)&cmd_set_uc_hash_port,
8166 (void *)&cmd_set_uc_hash_portid,
8167 (void *)&cmd_set_uc_hash_what,
8168 (void *)&cmd_set_uc_hash_mac,
8169 (void *)&cmd_set_uc_hash_mode,
8174 struct cmd_set_uc_all_hash_table {
8175 cmdline_fixed_string_t set;
8176 cmdline_fixed_string_t port;
8178 cmdline_fixed_string_t what;
8179 cmdline_fixed_string_t value;
8180 cmdline_fixed_string_t mode;
8184 cmd_set_uc_all_hash_parsed(void *parsed_result,
8185 __attribute__((unused)) struct cmdline *cl,
8186 __attribute__((unused)) void *data)
8189 struct cmd_set_uc_all_hash_table *res = parsed_result;
8191 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8193 if ((strcmp(res->what, "uta") == 0) &&
8194 (strcmp(res->value, "all") == 0))
8195 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8197 printf("bad unicast hash table parameter,"
8198 "return code = %d \n", ret);
8201 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8202 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8204 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8205 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8207 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8208 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8210 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8211 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8213 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8214 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8216 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8217 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8220 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8221 .f = cmd_set_uc_all_hash_parsed,
8223 .help_str = "set port <port_id> uta all on|off",
8225 (void *)&cmd_set_uc_all_hash_set,
8226 (void *)&cmd_set_uc_all_hash_port,
8227 (void *)&cmd_set_uc_all_hash_portid,
8228 (void *)&cmd_set_uc_all_hash_what,
8229 (void *)&cmd_set_uc_all_hash_value,
8230 (void *)&cmd_set_uc_all_hash_mode,
8235 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8236 struct cmd_set_vf_macvlan_filter {
8237 cmdline_fixed_string_t set;
8238 cmdline_fixed_string_t port;
8240 cmdline_fixed_string_t vf;
8242 struct rte_ether_addr address;
8243 cmdline_fixed_string_t filter_type;
8244 cmdline_fixed_string_t mode;
8248 cmd_set_vf_macvlan_parsed(void *parsed_result,
8249 __attribute__((unused)) struct cmdline *cl,
8250 __attribute__((unused)) void *data)
8253 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8254 struct rte_eth_mac_filter filter;
8256 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8258 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8260 /* set VF MAC filter */
8264 filter.dst_id = res->vf_id;
8266 if (!strcmp(res->filter_type, "exact-mac"))
8267 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8268 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8269 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8270 else if (!strcmp(res->filter_type, "hashmac"))
8271 filter.filter_type = RTE_MAC_HASH_MATCH;
8272 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8273 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8275 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8278 ret = rte_eth_dev_filter_ctrl(res->port_id,
8279 RTE_ETH_FILTER_MACVLAN,
8283 ret = rte_eth_dev_filter_ctrl(res->port_id,
8284 RTE_ETH_FILTER_MACVLAN,
8285 RTE_ETH_FILTER_DELETE,
8289 printf("bad set MAC hash parameter, return code = %d\n", ret);
8293 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8294 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8296 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8297 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8299 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8300 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8302 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8303 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8305 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8306 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8308 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8309 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8311 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8312 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8313 filter_type, "exact-mac#exact-mac-vlan"
8314 "#hashmac#hashmac-vlan");
8315 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8316 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8319 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8320 .f = cmd_set_vf_macvlan_parsed,
8322 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8323 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8324 "Exact match rule: exact match of MAC or MAC and VLAN; "
8325 "hash match rule: hash match of MAC and exact match of VLAN",
8327 (void *)&cmd_set_vf_macvlan_set,
8328 (void *)&cmd_set_vf_macvlan_port,
8329 (void *)&cmd_set_vf_macvlan_portid,
8330 (void *)&cmd_set_vf_macvlan_vf,
8331 (void *)&cmd_set_vf_macvlan_vf_id,
8332 (void *)&cmd_set_vf_macvlan_mac,
8333 (void *)&cmd_set_vf_macvlan_filter_type,
8334 (void *)&cmd_set_vf_macvlan_mode,
8339 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8340 struct cmd_set_vf_traffic {
8341 cmdline_fixed_string_t set;
8342 cmdline_fixed_string_t port;
8344 cmdline_fixed_string_t vf;
8346 cmdline_fixed_string_t what;
8347 cmdline_fixed_string_t mode;
8351 cmd_set_vf_traffic_parsed(void *parsed_result,
8352 __attribute__((unused)) struct cmdline *cl,
8353 __attribute__((unused)) void *data)
8355 struct cmd_set_vf_traffic *res = parsed_result;
8356 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8357 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8359 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8362 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8363 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8365 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8366 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8368 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8369 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8371 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8372 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8374 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8375 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8377 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8378 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8380 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8381 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8384 cmdline_parse_inst_t cmd_set_vf_traffic = {
8385 .f = cmd_set_vf_traffic_parsed,
8387 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8389 (void *)&cmd_setvf_traffic_set,
8390 (void *)&cmd_setvf_traffic_port,
8391 (void *)&cmd_setvf_traffic_portid,
8392 (void *)&cmd_setvf_traffic_vf,
8393 (void *)&cmd_setvf_traffic_vfid,
8394 (void *)&cmd_setvf_traffic_what,
8395 (void *)&cmd_setvf_traffic_mode,
8400 /* *** CONFIGURE VF RECEIVE MODE *** */
8401 struct cmd_set_vf_rxmode {
8402 cmdline_fixed_string_t set;
8403 cmdline_fixed_string_t port;
8405 cmdline_fixed_string_t vf;
8407 cmdline_fixed_string_t what;
8408 cmdline_fixed_string_t mode;
8409 cmdline_fixed_string_t on;
8413 cmd_set_vf_rxmode_parsed(void *parsed_result,
8414 __attribute__((unused)) struct cmdline *cl,
8415 __attribute__((unused)) void *data)
8418 uint16_t rx_mode = 0;
8419 struct cmd_set_vf_rxmode *res = parsed_result;
8421 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8422 if (!strcmp(res->what,"rxmode")) {
8423 if (!strcmp(res->mode, "AUPE"))
8424 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
8425 else if (!strcmp(res->mode, "ROPE"))
8426 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
8427 else if (!strcmp(res->mode, "BAM"))
8428 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
8429 else if (!strncmp(res->mode, "MPE",3))
8430 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
8433 RTE_SET_USED(is_on);
8435 #ifdef RTE_LIBRTE_IXGBE_PMD
8436 if (ret == -ENOTSUP)
8437 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8438 rx_mode, (uint8_t)is_on);
8440 #ifdef RTE_LIBRTE_BNXT_PMD
8441 if (ret == -ENOTSUP)
8442 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8443 rx_mode, (uint8_t)is_on);
8446 printf("bad VF receive mode parameter, return code = %d \n",
8450 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8451 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8453 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8454 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8456 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8457 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8459 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8460 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8462 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8463 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8465 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8466 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8468 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8469 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8470 mode, "AUPE#ROPE#BAM#MPE");
8471 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8472 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8475 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8476 .f = cmd_set_vf_rxmode_parsed,
8478 .help_str = "set port <port_id> vf <vf_id> rxmode "
8479 "AUPE|ROPE|BAM|MPE on|off",
8481 (void *)&cmd_set_vf_rxmode_set,
8482 (void *)&cmd_set_vf_rxmode_port,
8483 (void *)&cmd_set_vf_rxmode_portid,
8484 (void *)&cmd_set_vf_rxmode_vf,
8485 (void *)&cmd_set_vf_rxmode_vfid,
8486 (void *)&cmd_set_vf_rxmode_what,
8487 (void *)&cmd_set_vf_rxmode_mode,
8488 (void *)&cmd_set_vf_rxmode_on,
8493 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8494 struct cmd_vf_mac_addr_result {
8495 cmdline_fixed_string_t mac_addr_cmd;
8496 cmdline_fixed_string_t what;
8497 cmdline_fixed_string_t port;
8499 cmdline_fixed_string_t vf;
8501 struct rte_ether_addr address;
8504 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8505 __attribute__((unused)) struct cmdline *cl,
8506 __attribute__((unused)) void *data)
8508 struct cmd_vf_mac_addr_result *res = parsed_result;
8511 if (strcmp(res->what, "add") != 0)
8514 #ifdef RTE_LIBRTE_I40E_PMD
8515 if (ret == -ENOTSUP)
8516 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8519 #ifdef RTE_LIBRTE_BNXT_PMD
8520 if (ret == -ENOTSUP)
8521 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8526 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8530 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8531 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8532 mac_addr_cmd,"mac_addr");
8533 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8534 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8536 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8537 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8539 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8540 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8542 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8543 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8545 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8546 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8548 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8549 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8552 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8553 .f = cmd_vf_mac_addr_parsed,
8555 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8556 "Add MAC address filtering for a VF on port_id",
8558 (void *)&cmd_vf_mac_addr_cmd,
8559 (void *)&cmd_vf_mac_addr_what,
8560 (void *)&cmd_vf_mac_addr_port,
8561 (void *)&cmd_vf_mac_addr_portnum,
8562 (void *)&cmd_vf_mac_addr_vf,
8563 (void *)&cmd_vf_mac_addr_vfnum,
8564 (void *)&cmd_vf_mac_addr_addr,
8569 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8570 struct cmd_vf_rx_vlan_filter {
8571 cmdline_fixed_string_t rx_vlan;
8572 cmdline_fixed_string_t what;
8574 cmdline_fixed_string_t port;
8576 cmdline_fixed_string_t vf;
8581 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8582 __attribute__((unused)) struct cmdline *cl,
8583 __attribute__((unused)) void *data)
8585 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8588 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8590 #ifdef RTE_LIBRTE_IXGBE_PMD
8591 if (ret == -ENOTSUP)
8592 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8593 res->vlan_id, res->vf_mask, is_add);
8595 #ifdef RTE_LIBRTE_I40E_PMD
8596 if (ret == -ENOTSUP)
8597 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8598 res->vlan_id, res->vf_mask, is_add);
8600 #ifdef RTE_LIBRTE_BNXT_PMD
8601 if (ret == -ENOTSUP)
8602 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8603 res->vlan_id, res->vf_mask, is_add);
8610 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8611 res->vlan_id, res->vf_mask);
8614 printf("invalid port_id %d\n", res->port_id);
8617 printf("function not implemented or supported\n");
8620 printf("programming error: (%s)\n", strerror(-ret));
8624 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8625 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8626 rx_vlan, "rx_vlan");
8627 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8628 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8630 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8631 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8633 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8634 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8636 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8637 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8639 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8640 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8642 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8643 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8646 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8647 .f = cmd_vf_rx_vlan_filter_parsed,
8649 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8650 "(vf_mask = hexadecimal VF mask)",
8652 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8653 (void *)&cmd_vf_rx_vlan_filter_what,
8654 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8655 (void *)&cmd_vf_rx_vlan_filter_port,
8656 (void *)&cmd_vf_rx_vlan_filter_portid,
8657 (void *)&cmd_vf_rx_vlan_filter_vf,
8658 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8663 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8664 struct cmd_queue_rate_limit_result {
8665 cmdline_fixed_string_t set;
8666 cmdline_fixed_string_t port;
8668 cmdline_fixed_string_t queue;
8670 cmdline_fixed_string_t rate;
8674 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8675 __attribute__((unused)) struct cmdline *cl,
8676 __attribute__((unused)) void *data)
8678 struct cmd_queue_rate_limit_result *res = parsed_result;
8681 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8682 && (strcmp(res->queue, "queue") == 0)
8683 && (strcmp(res->rate, "rate") == 0))
8684 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8687 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8691 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8692 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8694 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8695 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8697 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8698 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8700 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8701 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8703 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8704 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8706 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8707 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8709 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8710 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8713 cmdline_parse_inst_t cmd_queue_rate_limit = {
8714 .f = cmd_queue_rate_limit_parsed,
8716 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8717 "Set rate limit for a queue on port_id",
8719 (void *)&cmd_queue_rate_limit_set,
8720 (void *)&cmd_queue_rate_limit_port,
8721 (void *)&cmd_queue_rate_limit_portnum,
8722 (void *)&cmd_queue_rate_limit_queue,
8723 (void *)&cmd_queue_rate_limit_queuenum,
8724 (void *)&cmd_queue_rate_limit_rate,
8725 (void *)&cmd_queue_rate_limit_ratenum,
8730 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8731 struct cmd_vf_rate_limit_result {
8732 cmdline_fixed_string_t set;
8733 cmdline_fixed_string_t port;
8735 cmdline_fixed_string_t vf;
8737 cmdline_fixed_string_t rate;
8739 cmdline_fixed_string_t q_msk;
8743 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8744 __attribute__((unused)) struct cmdline *cl,
8745 __attribute__((unused)) void *data)
8747 struct cmd_vf_rate_limit_result *res = parsed_result;
8750 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8751 && (strcmp(res->vf, "vf") == 0)
8752 && (strcmp(res->rate, "rate") == 0)
8753 && (strcmp(res->q_msk, "queue_mask") == 0))
8754 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8755 res->rate_num, res->q_msk_val);
8757 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8761 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8762 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8764 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8765 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8767 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8768 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8770 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8771 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8773 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8774 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8776 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8777 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8779 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8780 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8782 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8783 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8784 q_msk, "queue_mask");
8785 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8786 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8789 cmdline_parse_inst_t cmd_vf_rate_limit = {
8790 .f = cmd_vf_rate_limit_parsed,
8792 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8793 "queue_mask <queue_mask_value>: "
8794 "Set rate limit for queues of VF on port_id",
8796 (void *)&cmd_vf_rate_limit_set,
8797 (void *)&cmd_vf_rate_limit_port,
8798 (void *)&cmd_vf_rate_limit_portnum,
8799 (void *)&cmd_vf_rate_limit_vf,
8800 (void *)&cmd_vf_rate_limit_vfnum,
8801 (void *)&cmd_vf_rate_limit_rate,
8802 (void *)&cmd_vf_rate_limit_ratenum,
8803 (void *)&cmd_vf_rate_limit_q_msk,
8804 (void *)&cmd_vf_rate_limit_q_msk_val,
8809 /* *** ADD TUNNEL FILTER OF A PORT *** */
8810 struct cmd_tunnel_filter_result {
8811 cmdline_fixed_string_t cmd;
8812 cmdline_fixed_string_t what;
8814 struct rte_ether_addr outer_mac;
8815 struct rte_ether_addr inner_mac;
8816 cmdline_ipaddr_t ip_value;
8817 uint16_t inner_vlan;
8818 cmdline_fixed_string_t tunnel_type;
8819 cmdline_fixed_string_t filter_type;
8825 cmd_tunnel_filter_parsed(void *parsed_result,
8826 __attribute__((unused)) struct cmdline *cl,
8827 __attribute__((unused)) void *data)
8829 struct cmd_tunnel_filter_result *res = parsed_result;
8830 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8833 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8835 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8836 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8837 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8839 if (res->ip_value.family == AF_INET) {
8840 tunnel_filter_conf.ip_addr.ipv4_addr =
8841 res->ip_value.addr.ipv4.s_addr;
8842 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8844 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8845 &(res->ip_value.addr.ipv6),
8846 sizeof(struct in6_addr));
8847 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8850 if (!strcmp(res->filter_type, "imac-ivlan"))
8851 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8852 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8853 tunnel_filter_conf.filter_type =
8854 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8855 else if (!strcmp(res->filter_type, "imac-tenid"))
8856 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8857 else if (!strcmp(res->filter_type, "imac"))
8858 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8859 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8860 tunnel_filter_conf.filter_type =
8861 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8862 else if (!strcmp(res->filter_type, "oip"))
8863 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8864 else if (!strcmp(res->filter_type, "iip"))
8865 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8867 printf("The filter type is not supported");
8871 if (!strcmp(res->tunnel_type, "vxlan"))
8872 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8873 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
8874 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
8875 else if (!strcmp(res->tunnel_type, "nvgre"))
8876 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8877 else if (!strcmp(res->tunnel_type, "ipingre"))
8878 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8880 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8884 tunnel_filter_conf.tenant_id = res->tenant_id;
8885 tunnel_filter_conf.queue_id = res->queue_num;
8886 if (!strcmp(res->what, "add"))
8887 ret = rte_eth_dev_filter_ctrl(res->port_id,
8888 RTE_ETH_FILTER_TUNNEL,
8890 &tunnel_filter_conf);
8892 ret = rte_eth_dev_filter_ctrl(res->port_id,
8893 RTE_ETH_FILTER_TUNNEL,
8894 RTE_ETH_FILTER_DELETE,
8895 &tunnel_filter_conf);
8897 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8901 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8902 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8903 cmd, "tunnel_filter");
8904 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8905 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8907 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8908 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8910 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8911 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8913 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8914 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8916 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8917 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8918 inner_vlan, UINT16);
8919 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8920 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8922 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8923 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8924 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
8926 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8927 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8928 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8929 "imac#omac-imac-tenid");
8930 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8931 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8933 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8934 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8937 cmdline_parse_inst_t cmd_tunnel_filter = {
8938 .f = cmd_tunnel_filter_parsed,
8940 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8941 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8942 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8943 "<queue_id>: Add/Rm tunnel filter of a port",
8945 (void *)&cmd_tunnel_filter_cmd,
8946 (void *)&cmd_tunnel_filter_what,
8947 (void *)&cmd_tunnel_filter_port_id,
8948 (void *)&cmd_tunnel_filter_outer_mac,
8949 (void *)&cmd_tunnel_filter_inner_mac,
8950 (void *)&cmd_tunnel_filter_ip_value,
8951 (void *)&cmd_tunnel_filter_innner_vlan,
8952 (void *)&cmd_tunnel_filter_tunnel_type,
8953 (void *)&cmd_tunnel_filter_filter_type,
8954 (void *)&cmd_tunnel_filter_tenant_id,
8955 (void *)&cmd_tunnel_filter_queue_num,
8960 /* *** CONFIGURE TUNNEL UDP PORT *** */
8961 struct cmd_tunnel_udp_config {
8962 cmdline_fixed_string_t cmd;
8963 cmdline_fixed_string_t what;
8969 cmd_tunnel_udp_config_parsed(void *parsed_result,
8970 __attribute__((unused)) struct cmdline *cl,
8971 __attribute__((unused)) void *data)
8973 struct cmd_tunnel_udp_config *res = parsed_result;
8974 struct rte_eth_udp_tunnel tunnel_udp;
8977 tunnel_udp.udp_port = res->udp_port;
8979 if (!strcmp(res->cmd, "rx_vxlan_port"))
8980 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8982 if (!strcmp(res->what, "add"))
8983 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8986 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8990 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8993 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8994 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8995 cmd, "rx_vxlan_port");
8996 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8997 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8999 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9000 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9002 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9003 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9006 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9007 .f = cmd_tunnel_udp_config_parsed,
9009 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9010 "Add/Remove a tunneling UDP port filter",
9012 (void *)&cmd_tunnel_udp_config_cmd,
9013 (void *)&cmd_tunnel_udp_config_what,
9014 (void *)&cmd_tunnel_udp_config_udp_port,
9015 (void *)&cmd_tunnel_udp_config_port_id,
9020 struct cmd_config_tunnel_udp_port {
9021 cmdline_fixed_string_t port;
9022 cmdline_fixed_string_t config;
9024 cmdline_fixed_string_t udp_tunnel_port;
9025 cmdline_fixed_string_t action;
9026 cmdline_fixed_string_t tunnel_type;
9031 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9032 __attribute__((unused)) struct cmdline *cl,
9033 __attribute__((unused)) void *data)
9035 struct cmd_config_tunnel_udp_port *res = parsed_result;
9036 struct rte_eth_udp_tunnel tunnel_udp;
9039 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9042 tunnel_udp.udp_port = res->udp_port;
9044 if (!strcmp(res->tunnel_type, "vxlan")) {
9045 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9046 } else if (!strcmp(res->tunnel_type, "geneve")) {
9047 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9048 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9049 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9051 printf("Invalid tunnel type\n");
9055 if (!strcmp(res->action, "add"))
9056 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9059 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9063 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9066 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9067 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9069 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9070 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9072 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9073 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9075 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9076 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9079 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9080 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9082 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9083 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9084 "vxlan#geneve#vxlan-gpe");
9085 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9086 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9089 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9090 .f = cmd_cfg_tunnel_udp_port_parsed,
9092 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9094 (void *)&cmd_config_tunnel_udp_port_port,
9095 (void *)&cmd_config_tunnel_udp_port_config,
9096 (void *)&cmd_config_tunnel_udp_port_port_id,
9097 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9098 (void *)&cmd_config_tunnel_udp_port_action,
9099 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9100 (void *)&cmd_config_tunnel_udp_port_value,
9105 /* *** GLOBAL CONFIG *** */
9106 struct cmd_global_config_result {
9107 cmdline_fixed_string_t cmd;
9109 cmdline_fixed_string_t cfg_type;
9114 cmd_global_config_parsed(void *parsed_result,
9115 __attribute__((unused)) struct cmdline *cl,
9116 __attribute__((unused)) void *data)
9118 struct cmd_global_config_result *res = parsed_result;
9119 struct rte_eth_global_cfg conf;
9122 memset(&conf, 0, sizeof(conf));
9123 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9124 conf.cfg.gre_key_len = res->len;
9125 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9126 RTE_ETH_FILTER_SET, &conf);
9128 printf("Global config error\n");
9131 cmdline_parse_token_string_t cmd_global_config_cmd =
9132 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9134 cmdline_parse_token_num_t cmd_global_config_port_id =
9135 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9137 cmdline_parse_token_string_t cmd_global_config_type =
9138 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9139 cfg_type, "gre-key-len");
9140 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9141 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9144 cmdline_parse_inst_t cmd_global_config = {
9145 .f = cmd_global_config_parsed,
9146 .data = (void *)NULL,
9147 .help_str = "global_config <port_id> gre-key-len <key_len>",
9149 (void *)&cmd_global_config_cmd,
9150 (void *)&cmd_global_config_port_id,
9151 (void *)&cmd_global_config_type,
9152 (void *)&cmd_global_config_gre_key_len,
9157 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9158 struct cmd_set_mirror_mask_result {
9159 cmdline_fixed_string_t set;
9160 cmdline_fixed_string_t port;
9162 cmdline_fixed_string_t mirror;
9164 cmdline_fixed_string_t what;
9165 cmdline_fixed_string_t value;
9166 cmdline_fixed_string_t dstpool;
9168 cmdline_fixed_string_t on;
9171 cmdline_parse_token_string_t cmd_mirror_mask_set =
9172 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9174 cmdline_parse_token_string_t cmd_mirror_mask_port =
9175 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9177 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9178 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9180 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9181 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9182 mirror, "mirror-rule");
9183 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9184 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9186 cmdline_parse_token_string_t cmd_mirror_mask_what =
9187 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9188 what, "pool-mirror-up#pool-mirror-down"
9190 cmdline_parse_token_string_t cmd_mirror_mask_value =
9191 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9193 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9194 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9195 dstpool, "dst-pool");
9196 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9197 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9199 cmdline_parse_token_string_t cmd_mirror_mask_on =
9200 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9204 cmd_set_mirror_mask_parsed(void *parsed_result,
9205 __attribute__((unused)) struct cmdline *cl,
9206 __attribute__((unused)) void *data)
9209 struct cmd_set_mirror_mask_result *res = parsed_result;
9210 struct rte_eth_mirror_conf mr_conf;
9212 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9214 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9216 mr_conf.dst_pool = res->dstpool_id;
9218 if (!strcmp(res->what, "pool-mirror-up")) {
9219 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9220 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9221 } else if (!strcmp(res->what, "pool-mirror-down")) {
9222 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9223 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9224 } else if (!strcmp(res->what, "vlan-mirror")) {
9225 mr_conf.rule_type = ETH_MIRROR_VLAN;
9226 nb_item = parse_item_list(res->value, "vlan",
9227 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9231 for (i = 0; i < nb_item; i++) {
9232 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9233 printf("Invalid vlan_id: must be < 4096\n");
9237 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9238 mr_conf.vlan.vlan_mask |= 1ULL << i;
9242 if (!strcmp(res->on, "on"))
9243 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9246 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9249 printf("mirror rule add error: (%s)\n", strerror(-ret));
9252 cmdline_parse_inst_t cmd_set_mirror_mask = {
9253 .f = cmd_set_mirror_mask_parsed,
9255 .help_str = "set port <port_id> mirror-rule <rule_id> "
9256 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9257 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9259 (void *)&cmd_mirror_mask_set,
9260 (void *)&cmd_mirror_mask_port,
9261 (void *)&cmd_mirror_mask_portid,
9262 (void *)&cmd_mirror_mask_mirror,
9263 (void *)&cmd_mirror_mask_ruleid,
9264 (void *)&cmd_mirror_mask_what,
9265 (void *)&cmd_mirror_mask_value,
9266 (void *)&cmd_mirror_mask_dstpool,
9267 (void *)&cmd_mirror_mask_poolid,
9268 (void *)&cmd_mirror_mask_on,
9273 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9274 struct cmd_set_mirror_link_result {
9275 cmdline_fixed_string_t set;
9276 cmdline_fixed_string_t port;
9278 cmdline_fixed_string_t mirror;
9280 cmdline_fixed_string_t what;
9281 cmdline_fixed_string_t dstpool;
9283 cmdline_fixed_string_t on;
9286 cmdline_parse_token_string_t cmd_mirror_link_set =
9287 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9289 cmdline_parse_token_string_t cmd_mirror_link_port =
9290 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9292 cmdline_parse_token_num_t cmd_mirror_link_portid =
9293 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9295 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9296 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9297 mirror, "mirror-rule");
9298 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9299 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9301 cmdline_parse_token_string_t cmd_mirror_link_what =
9302 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9303 what, "uplink-mirror#downlink-mirror");
9304 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9305 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9306 dstpool, "dst-pool");
9307 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9308 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9310 cmdline_parse_token_string_t cmd_mirror_link_on =
9311 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9315 cmd_set_mirror_link_parsed(void *parsed_result,
9316 __attribute__((unused)) struct cmdline *cl,
9317 __attribute__((unused)) void *data)
9320 struct cmd_set_mirror_link_result *res = parsed_result;
9321 struct rte_eth_mirror_conf mr_conf;
9323 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9324 if (!strcmp(res->what, "uplink-mirror"))
9325 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9327 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9329 mr_conf.dst_pool = res->dstpool_id;
9331 if (!strcmp(res->on, "on"))
9332 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9335 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9338 /* check the return value and print it if is < 0 */
9340 printf("mirror rule add error: (%s)\n", strerror(-ret));
9344 cmdline_parse_inst_t cmd_set_mirror_link = {
9345 .f = cmd_set_mirror_link_parsed,
9347 .help_str = "set port <port_id> mirror-rule <rule_id> "
9348 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9350 (void *)&cmd_mirror_link_set,
9351 (void *)&cmd_mirror_link_port,
9352 (void *)&cmd_mirror_link_portid,
9353 (void *)&cmd_mirror_link_mirror,
9354 (void *)&cmd_mirror_link_ruleid,
9355 (void *)&cmd_mirror_link_what,
9356 (void *)&cmd_mirror_link_dstpool,
9357 (void *)&cmd_mirror_link_poolid,
9358 (void *)&cmd_mirror_link_on,
9363 /* *** RESET VM MIRROR RULE *** */
9364 struct cmd_rm_mirror_rule_result {
9365 cmdline_fixed_string_t reset;
9366 cmdline_fixed_string_t port;
9368 cmdline_fixed_string_t mirror;
9372 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9373 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9375 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9376 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9378 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9379 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9381 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9382 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9383 mirror, "mirror-rule");
9384 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9385 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9389 cmd_reset_mirror_rule_parsed(void *parsed_result,
9390 __attribute__((unused)) struct cmdline *cl,
9391 __attribute__((unused)) void *data)
9394 struct cmd_set_mirror_link_result *res = parsed_result;
9396 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9398 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9401 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9402 .f = cmd_reset_mirror_rule_parsed,
9404 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9406 (void *)&cmd_rm_mirror_rule_reset,
9407 (void *)&cmd_rm_mirror_rule_port,
9408 (void *)&cmd_rm_mirror_rule_portid,
9409 (void *)&cmd_rm_mirror_rule_mirror,
9410 (void *)&cmd_rm_mirror_rule_ruleid,
9415 /* ******************************************************************************** */
9417 struct cmd_dump_result {
9418 cmdline_fixed_string_t dump;
9422 dump_struct_sizes(void)
9424 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9425 DUMP_SIZE(struct rte_mbuf);
9426 DUMP_SIZE(struct rte_mempool);
9427 DUMP_SIZE(struct rte_ring);
9431 static void cmd_dump_parsed(void *parsed_result,
9432 __attribute__((unused)) struct cmdline *cl,
9433 __attribute__((unused)) void *data)
9435 struct cmd_dump_result *res = parsed_result;
9437 if (!strcmp(res->dump, "dump_physmem"))
9438 rte_dump_physmem_layout(stdout);
9439 else if (!strcmp(res->dump, "dump_memzone"))
9440 rte_memzone_dump(stdout);
9441 else if (!strcmp(res->dump, "dump_struct_sizes"))
9442 dump_struct_sizes();
9443 else if (!strcmp(res->dump, "dump_ring"))
9444 rte_ring_list_dump(stdout);
9445 else if (!strcmp(res->dump, "dump_mempool"))
9446 rte_mempool_list_dump(stdout);
9447 else if (!strcmp(res->dump, "dump_devargs"))
9448 rte_devargs_dump(stdout);
9449 else if (!strcmp(res->dump, "dump_log_types"))
9450 rte_log_dump(stdout);
9453 cmdline_parse_token_string_t cmd_dump_dump =
9454 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9457 "dump_struct_sizes#"
9463 cmdline_parse_inst_t cmd_dump = {
9464 .f = cmd_dump_parsed, /* function to call */
9465 .data = NULL, /* 2nd arg of func */
9466 .help_str = "Dump status",
9467 .tokens = { /* token list, NULL terminated */
9468 (void *)&cmd_dump_dump,
9473 /* ******************************************************************************** */
9475 struct cmd_dump_one_result {
9476 cmdline_fixed_string_t dump;
9477 cmdline_fixed_string_t name;
9480 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9481 __attribute__((unused)) void *data)
9483 struct cmd_dump_one_result *res = parsed_result;
9485 if (!strcmp(res->dump, "dump_ring")) {
9487 r = rte_ring_lookup(res->name);
9489 cmdline_printf(cl, "Cannot find ring\n");
9492 rte_ring_dump(stdout, r);
9493 } else if (!strcmp(res->dump, "dump_mempool")) {
9494 struct rte_mempool *mp;
9495 mp = rte_mempool_lookup(res->name);
9497 cmdline_printf(cl, "Cannot find mempool\n");
9500 rte_mempool_dump(stdout, mp);
9504 cmdline_parse_token_string_t cmd_dump_one_dump =
9505 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9506 "dump_ring#dump_mempool");
9508 cmdline_parse_token_string_t cmd_dump_one_name =
9509 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9511 cmdline_parse_inst_t cmd_dump_one = {
9512 .f = cmd_dump_one_parsed, /* function to call */
9513 .data = NULL, /* 2nd arg of func */
9514 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9515 .tokens = { /* token list, NULL terminated */
9516 (void *)&cmd_dump_one_dump,
9517 (void *)&cmd_dump_one_name,
9522 /* *** Add/Del syn filter *** */
9523 struct cmd_syn_filter_result {
9524 cmdline_fixed_string_t filter;
9526 cmdline_fixed_string_t ops;
9527 cmdline_fixed_string_t priority;
9528 cmdline_fixed_string_t high;
9529 cmdline_fixed_string_t queue;
9534 cmd_syn_filter_parsed(void *parsed_result,
9535 __attribute__((unused)) struct cmdline *cl,
9536 __attribute__((unused)) void *data)
9538 struct cmd_syn_filter_result *res = parsed_result;
9539 struct rte_eth_syn_filter syn_filter;
9542 ret = rte_eth_dev_filter_supported(res->port_id,
9543 RTE_ETH_FILTER_SYN);
9545 printf("syn filter is not supported on port %u.\n",
9550 memset(&syn_filter, 0, sizeof(syn_filter));
9552 if (!strcmp(res->ops, "add")) {
9553 if (!strcmp(res->high, "high"))
9554 syn_filter.hig_pri = 1;
9556 syn_filter.hig_pri = 0;
9558 syn_filter.queue = res->queue_id;
9559 ret = rte_eth_dev_filter_ctrl(res->port_id,
9564 ret = rte_eth_dev_filter_ctrl(res->port_id,
9566 RTE_ETH_FILTER_DELETE,
9570 printf("syn filter programming error: (%s)\n",
9574 cmdline_parse_token_string_t cmd_syn_filter_filter =
9575 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9576 filter, "syn_filter");
9577 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9578 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9580 cmdline_parse_token_string_t cmd_syn_filter_ops =
9581 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9583 cmdline_parse_token_string_t cmd_syn_filter_priority =
9584 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9585 priority, "priority");
9586 cmdline_parse_token_string_t cmd_syn_filter_high =
9587 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9589 cmdline_parse_token_string_t cmd_syn_filter_queue =
9590 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9592 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9593 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9596 cmdline_parse_inst_t cmd_syn_filter = {
9597 .f = cmd_syn_filter_parsed,
9599 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9600 "<queue_id>: Add/Delete syn filter",
9602 (void *)&cmd_syn_filter_filter,
9603 (void *)&cmd_syn_filter_port_id,
9604 (void *)&cmd_syn_filter_ops,
9605 (void *)&cmd_syn_filter_priority,
9606 (void *)&cmd_syn_filter_high,
9607 (void *)&cmd_syn_filter_queue,
9608 (void *)&cmd_syn_filter_queue_id,
9613 /* *** queue region set *** */
9614 struct cmd_queue_region_result {
9615 cmdline_fixed_string_t set;
9616 cmdline_fixed_string_t port;
9618 cmdline_fixed_string_t cmd;
9619 cmdline_fixed_string_t region;
9621 cmdline_fixed_string_t queue_start_index;
9623 cmdline_fixed_string_t queue_num;
9624 uint8_t queue_num_value;
9628 cmd_queue_region_parsed(void *parsed_result,
9629 __attribute__((unused)) struct cmdline *cl,
9630 __attribute__((unused)) void *data)
9632 struct cmd_queue_region_result *res = parsed_result;
9634 #ifdef RTE_LIBRTE_I40E_PMD
9635 struct rte_pmd_i40e_queue_region_conf region_conf;
9636 enum rte_pmd_i40e_queue_region_op op_type;
9639 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9642 #ifdef RTE_LIBRTE_I40E_PMD
9643 memset(®ion_conf, 0, sizeof(region_conf));
9644 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9645 region_conf.region_id = res->region_id;
9646 region_conf.queue_num = res->queue_num_value;
9647 region_conf.queue_start_index = res->queue_id;
9649 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9650 op_type, ®ion_conf);
9657 printf("function not implemented or supported\n");
9660 printf("queue region config error: (%s)\n", strerror(-ret));
9664 cmdline_parse_token_string_t cmd_queue_region_set =
9665 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9667 cmdline_parse_token_string_t cmd_queue_region_port =
9668 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9669 cmdline_parse_token_num_t cmd_queue_region_port_id =
9670 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9672 cmdline_parse_token_string_t cmd_queue_region_cmd =
9673 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9674 cmd, "queue-region");
9675 cmdline_parse_token_string_t cmd_queue_region_id =
9676 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9677 region, "region_id");
9678 cmdline_parse_token_num_t cmd_queue_region_index =
9679 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9681 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9682 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9683 queue_start_index, "queue_start_index");
9684 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9685 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9687 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9688 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9689 queue_num, "queue_num");
9690 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9691 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9692 queue_num_value, UINT8);
9694 cmdline_parse_inst_t cmd_queue_region = {
9695 .f = cmd_queue_region_parsed,
9697 .help_str = "set port <port_id> queue-region region_id <value> "
9698 "queue_start_index <value> queue_num <value>: Set a queue region",
9700 (void *)&cmd_queue_region_set,
9701 (void *)&cmd_queue_region_port,
9702 (void *)&cmd_queue_region_port_id,
9703 (void *)&cmd_queue_region_cmd,
9704 (void *)&cmd_queue_region_id,
9705 (void *)&cmd_queue_region_index,
9706 (void *)&cmd_queue_region_queue_start_index,
9707 (void *)&cmd_queue_region_queue_id,
9708 (void *)&cmd_queue_region_queue_num,
9709 (void *)&cmd_queue_region_queue_num_value,
9714 /* *** queue region and flowtype set *** */
9715 struct cmd_region_flowtype_result {
9716 cmdline_fixed_string_t set;
9717 cmdline_fixed_string_t port;
9719 cmdline_fixed_string_t cmd;
9720 cmdline_fixed_string_t region;
9722 cmdline_fixed_string_t flowtype;
9723 uint8_t flowtype_id;
9727 cmd_region_flowtype_parsed(void *parsed_result,
9728 __attribute__((unused)) struct cmdline *cl,
9729 __attribute__((unused)) void *data)
9731 struct cmd_region_flowtype_result *res = parsed_result;
9733 #ifdef RTE_LIBRTE_I40E_PMD
9734 struct rte_pmd_i40e_queue_region_conf region_conf;
9735 enum rte_pmd_i40e_queue_region_op op_type;
9738 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9741 #ifdef RTE_LIBRTE_I40E_PMD
9742 memset(®ion_conf, 0, sizeof(region_conf));
9744 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9745 region_conf.region_id = res->region_id;
9746 region_conf.hw_flowtype = res->flowtype_id;
9748 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9749 op_type, ®ion_conf);
9756 printf("function not implemented or supported\n");
9759 printf("region flowtype config error: (%s)\n", strerror(-ret));
9763 cmdline_parse_token_string_t cmd_region_flowtype_set =
9764 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9766 cmdline_parse_token_string_t cmd_region_flowtype_port =
9767 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9769 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9770 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9772 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9773 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9774 cmd, "queue-region");
9775 cmdline_parse_token_string_t cmd_region_flowtype_index =
9776 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9777 region, "region_id");
9778 cmdline_parse_token_num_t cmd_region_flowtype_id =
9779 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9781 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9782 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9783 flowtype, "flowtype");
9784 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9785 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9786 flowtype_id, UINT8);
9787 cmdline_parse_inst_t cmd_region_flowtype = {
9788 .f = cmd_region_flowtype_parsed,
9790 .help_str = "set port <port_id> queue-region region_id <value> "
9791 "flowtype <value>: Set a flowtype region index",
9793 (void *)&cmd_region_flowtype_set,
9794 (void *)&cmd_region_flowtype_port,
9795 (void *)&cmd_region_flowtype_port_index,
9796 (void *)&cmd_region_flowtype_cmd,
9797 (void *)&cmd_region_flowtype_index,
9798 (void *)&cmd_region_flowtype_id,
9799 (void *)&cmd_region_flowtype_flow_index,
9800 (void *)&cmd_region_flowtype_flow_id,
9805 /* *** User Priority (UP) to queue region (region_id) set *** */
9806 struct cmd_user_priority_region_result {
9807 cmdline_fixed_string_t set;
9808 cmdline_fixed_string_t port;
9810 cmdline_fixed_string_t cmd;
9811 cmdline_fixed_string_t user_priority;
9812 uint8_t user_priority_id;
9813 cmdline_fixed_string_t region;
9818 cmd_user_priority_region_parsed(void *parsed_result,
9819 __attribute__((unused)) struct cmdline *cl,
9820 __attribute__((unused)) void *data)
9822 struct cmd_user_priority_region_result *res = parsed_result;
9824 #ifdef RTE_LIBRTE_I40E_PMD
9825 struct rte_pmd_i40e_queue_region_conf region_conf;
9826 enum rte_pmd_i40e_queue_region_op op_type;
9829 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9832 #ifdef RTE_LIBRTE_I40E_PMD
9833 memset(®ion_conf, 0, sizeof(region_conf));
9834 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9835 region_conf.user_priority = res->user_priority_id;
9836 region_conf.region_id = res->region_id;
9838 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9839 op_type, ®ion_conf);
9846 printf("function not implemented or supported\n");
9849 printf("user_priority region config error: (%s)\n",
9854 cmdline_parse_token_string_t cmd_user_priority_region_set =
9855 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9857 cmdline_parse_token_string_t cmd_user_priority_region_port =
9858 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9860 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9861 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9863 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9864 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9865 cmd, "queue-region");
9866 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9867 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9868 user_priority, "UP");
9869 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9870 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9871 user_priority_id, UINT8);
9872 cmdline_parse_token_string_t cmd_user_priority_region_region =
9873 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9874 region, "region_id");
9875 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9876 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9879 cmdline_parse_inst_t cmd_user_priority_region = {
9880 .f = cmd_user_priority_region_parsed,
9882 .help_str = "set port <port_id> queue-region UP <value> "
9883 "region_id <value>: Set the mapping of User Priority (UP) "
9884 "to queue region (region_id) ",
9886 (void *)&cmd_user_priority_region_set,
9887 (void *)&cmd_user_priority_region_port,
9888 (void *)&cmd_user_priority_region_port_index,
9889 (void *)&cmd_user_priority_region_cmd,
9890 (void *)&cmd_user_priority_region_UP,
9891 (void *)&cmd_user_priority_region_UP_id,
9892 (void *)&cmd_user_priority_region_region,
9893 (void *)&cmd_user_priority_region_region_id,
9898 /* *** flush all queue region related configuration *** */
9899 struct cmd_flush_queue_region_result {
9900 cmdline_fixed_string_t set;
9901 cmdline_fixed_string_t port;
9903 cmdline_fixed_string_t cmd;
9904 cmdline_fixed_string_t flush;
9905 cmdline_fixed_string_t what;
9909 cmd_flush_queue_region_parsed(void *parsed_result,
9910 __attribute__((unused)) struct cmdline *cl,
9911 __attribute__((unused)) void *data)
9913 struct cmd_flush_queue_region_result *res = parsed_result;
9915 #ifdef RTE_LIBRTE_I40E_PMD
9916 struct rte_pmd_i40e_queue_region_conf region_conf;
9917 enum rte_pmd_i40e_queue_region_op op_type;
9920 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9923 #ifdef RTE_LIBRTE_I40E_PMD
9924 memset(®ion_conf, 0, sizeof(region_conf));
9926 if (strcmp(res->what, "on") == 0)
9927 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9929 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9931 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9932 op_type, ®ion_conf);
9939 printf("function not implemented or supported\n");
9942 printf("queue region config flush error: (%s)\n",
9947 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9948 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9950 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9951 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9953 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9954 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9956 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9957 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9958 cmd, "queue-region");
9959 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9960 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9962 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9963 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9966 cmdline_parse_inst_t cmd_flush_queue_region = {
9967 .f = cmd_flush_queue_region_parsed,
9969 .help_str = "set port <port_id> queue-region flush on|off"
9970 ": flush all queue region related configuration",
9972 (void *)&cmd_flush_queue_region_set,
9973 (void *)&cmd_flush_queue_region_port,
9974 (void *)&cmd_flush_queue_region_port_index,
9975 (void *)&cmd_flush_queue_region_cmd,
9976 (void *)&cmd_flush_queue_region_flush,
9977 (void *)&cmd_flush_queue_region_what,
9982 /* *** get all queue region related configuration info *** */
9983 struct cmd_show_queue_region_info {
9984 cmdline_fixed_string_t show;
9985 cmdline_fixed_string_t port;
9987 cmdline_fixed_string_t cmd;
9991 cmd_show_queue_region_info_parsed(void *parsed_result,
9992 __attribute__((unused)) struct cmdline *cl,
9993 __attribute__((unused)) void *data)
9995 struct cmd_show_queue_region_info *res = parsed_result;
9997 #ifdef RTE_LIBRTE_I40E_PMD
9998 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9999 enum rte_pmd_i40e_queue_region_op op_type;
10002 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10005 #ifdef RTE_LIBRTE_I40E_PMD
10006 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10008 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10010 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10011 op_type, &rte_pmd_regions);
10013 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10020 printf("function not implemented or supported\n");
10023 printf("queue region config info show error: (%s)\n",
10028 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10029 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10031 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10032 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10034 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10035 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10037 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10038 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10039 cmd, "queue-region");
10041 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10042 .f = cmd_show_queue_region_info_parsed,
10044 .help_str = "show port <port_id> queue-region"
10045 ": show all queue region related configuration info",
10047 (void *)&cmd_show_queue_region_info_get,
10048 (void *)&cmd_show_queue_region_info_port,
10049 (void *)&cmd_show_queue_region_info_port_index,
10050 (void *)&cmd_show_queue_region_info_cmd,
10055 /* *** ADD/REMOVE A 2tuple FILTER *** */
10056 struct cmd_2tuple_filter_result {
10057 cmdline_fixed_string_t filter;
10059 cmdline_fixed_string_t ops;
10060 cmdline_fixed_string_t dst_port;
10061 uint16_t dst_port_value;
10062 cmdline_fixed_string_t protocol;
10063 uint8_t protocol_value;
10064 cmdline_fixed_string_t mask;
10065 uint8_t mask_value;
10066 cmdline_fixed_string_t tcp_flags;
10067 uint8_t tcp_flags_value;
10068 cmdline_fixed_string_t priority;
10069 uint8_t priority_value;
10070 cmdline_fixed_string_t queue;
10075 cmd_2tuple_filter_parsed(void *parsed_result,
10076 __attribute__((unused)) struct cmdline *cl,
10077 __attribute__((unused)) void *data)
10079 struct rte_eth_ntuple_filter filter;
10080 struct cmd_2tuple_filter_result *res = parsed_result;
10083 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10085 printf("ntuple filter is not supported on port %u.\n",
10090 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10092 filter.flags = RTE_2TUPLE_FLAGS;
10093 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10094 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10095 filter.proto = res->protocol_value;
10096 filter.priority = res->priority_value;
10097 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10098 printf("nonzero tcp_flags is only meaningful"
10099 " when protocol is TCP.\n");
10102 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10103 printf("invalid TCP flags.\n");
10107 if (res->tcp_flags_value != 0) {
10108 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10109 filter.tcp_flags = res->tcp_flags_value;
10112 /* need convert to big endian. */
10113 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10114 filter.queue = res->queue_id;
10116 if (!strcmp(res->ops, "add"))
10117 ret = rte_eth_dev_filter_ctrl(res->port_id,
10118 RTE_ETH_FILTER_NTUPLE,
10119 RTE_ETH_FILTER_ADD,
10122 ret = rte_eth_dev_filter_ctrl(res->port_id,
10123 RTE_ETH_FILTER_NTUPLE,
10124 RTE_ETH_FILTER_DELETE,
10127 printf("2tuple filter programming error: (%s)\n",
10132 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10133 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10134 filter, "2tuple_filter");
10135 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10136 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10138 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10139 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10141 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10142 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10143 dst_port, "dst_port");
10144 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10145 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10146 dst_port_value, UINT16);
10147 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10148 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10149 protocol, "protocol");
10150 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10151 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10152 protocol_value, UINT8);
10153 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10154 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10156 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10157 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10159 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10160 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10161 tcp_flags, "tcp_flags");
10162 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10163 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10164 tcp_flags_value, UINT8);
10165 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10166 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10167 priority, "priority");
10168 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10169 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10170 priority_value, UINT8);
10171 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10172 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10174 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10175 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10178 cmdline_parse_inst_t cmd_2tuple_filter = {
10179 .f = cmd_2tuple_filter_parsed,
10181 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10182 "<value> mask <value> tcp_flags <value> priority <value> queue "
10183 "<queue_id>: Add a 2tuple filter",
10185 (void *)&cmd_2tuple_filter_filter,
10186 (void *)&cmd_2tuple_filter_port_id,
10187 (void *)&cmd_2tuple_filter_ops,
10188 (void *)&cmd_2tuple_filter_dst_port,
10189 (void *)&cmd_2tuple_filter_dst_port_value,
10190 (void *)&cmd_2tuple_filter_protocol,
10191 (void *)&cmd_2tuple_filter_protocol_value,
10192 (void *)&cmd_2tuple_filter_mask,
10193 (void *)&cmd_2tuple_filter_mask_value,
10194 (void *)&cmd_2tuple_filter_tcp_flags,
10195 (void *)&cmd_2tuple_filter_tcp_flags_value,
10196 (void *)&cmd_2tuple_filter_priority,
10197 (void *)&cmd_2tuple_filter_priority_value,
10198 (void *)&cmd_2tuple_filter_queue,
10199 (void *)&cmd_2tuple_filter_queue_id,
10204 /* *** ADD/REMOVE A 5tuple FILTER *** */
10205 struct cmd_5tuple_filter_result {
10206 cmdline_fixed_string_t filter;
10208 cmdline_fixed_string_t ops;
10209 cmdline_fixed_string_t dst_ip;
10210 cmdline_ipaddr_t dst_ip_value;
10211 cmdline_fixed_string_t src_ip;
10212 cmdline_ipaddr_t src_ip_value;
10213 cmdline_fixed_string_t dst_port;
10214 uint16_t dst_port_value;
10215 cmdline_fixed_string_t src_port;
10216 uint16_t src_port_value;
10217 cmdline_fixed_string_t protocol;
10218 uint8_t protocol_value;
10219 cmdline_fixed_string_t mask;
10220 uint8_t mask_value;
10221 cmdline_fixed_string_t tcp_flags;
10222 uint8_t tcp_flags_value;
10223 cmdline_fixed_string_t priority;
10224 uint8_t priority_value;
10225 cmdline_fixed_string_t queue;
10230 cmd_5tuple_filter_parsed(void *parsed_result,
10231 __attribute__((unused)) struct cmdline *cl,
10232 __attribute__((unused)) void *data)
10234 struct rte_eth_ntuple_filter filter;
10235 struct cmd_5tuple_filter_result *res = parsed_result;
10238 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10240 printf("ntuple filter is not supported on port %u.\n",
10245 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10247 filter.flags = RTE_5TUPLE_FLAGS;
10248 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10249 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10250 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10251 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10252 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10253 filter.proto = res->protocol_value;
10254 filter.priority = res->priority_value;
10255 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10256 printf("nonzero tcp_flags is only meaningful"
10257 " when protocol is TCP.\n");
10260 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10261 printf("invalid TCP flags.\n");
10265 if (res->tcp_flags_value != 0) {
10266 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10267 filter.tcp_flags = res->tcp_flags_value;
10270 if (res->dst_ip_value.family == AF_INET)
10271 /* no need to convert, already big endian. */
10272 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10274 if (filter.dst_ip_mask == 0) {
10275 printf("can not support ipv6 involved compare.\n");
10281 if (res->src_ip_value.family == AF_INET)
10282 /* no need to convert, already big endian. */
10283 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10285 if (filter.src_ip_mask == 0) {
10286 printf("can not support ipv6 involved compare.\n");
10291 /* need convert to big endian. */
10292 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10293 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10294 filter.queue = res->queue_id;
10296 if (!strcmp(res->ops, "add"))
10297 ret = rte_eth_dev_filter_ctrl(res->port_id,
10298 RTE_ETH_FILTER_NTUPLE,
10299 RTE_ETH_FILTER_ADD,
10302 ret = rte_eth_dev_filter_ctrl(res->port_id,
10303 RTE_ETH_FILTER_NTUPLE,
10304 RTE_ETH_FILTER_DELETE,
10307 printf("5tuple filter programming error: (%s)\n",
10311 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10312 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10313 filter, "5tuple_filter");
10314 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10315 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10317 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10318 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10320 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10321 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10323 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10324 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10326 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10327 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10329 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10330 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10332 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10333 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10334 dst_port, "dst_port");
10335 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10336 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10337 dst_port_value, UINT16);
10338 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10339 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10340 src_port, "src_port");
10341 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10342 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10343 src_port_value, UINT16);
10344 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10345 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10346 protocol, "protocol");
10347 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10348 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10349 protocol_value, UINT8);
10350 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10351 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10353 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10354 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10356 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10357 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10358 tcp_flags, "tcp_flags");
10359 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10360 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10361 tcp_flags_value, UINT8);
10362 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10363 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10364 priority, "priority");
10365 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10366 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10367 priority_value, UINT8);
10368 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10369 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10371 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10372 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10375 cmdline_parse_inst_t cmd_5tuple_filter = {
10376 .f = cmd_5tuple_filter_parsed,
10378 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10379 "src_ip <value> dst_port <value> src_port <value> "
10380 "protocol <value> mask <value> tcp_flags <value> "
10381 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10383 (void *)&cmd_5tuple_filter_filter,
10384 (void *)&cmd_5tuple_filter_port_id,
10385 (void *)&cmd_5tuple_filter_ops,
10386 (void *)&cmd_5tuple_filter_dst_ip,
10387 (void *)&cmd_5tuple_filter_dst_ip_value,
10388 (void *)&cmd_5tuple_filter_src_ip,
10389 (void *)&cmd_5tuple_filter_src_ip_value,
10390 (void *)&cmd_5tuple_filter_dst_port,
10391 (void *)&cmd_5tuple_filter_dst_port_value,
10392 (void *)&cmd_5tuple_filter_src_port,
10393 (void *)&cmd_5tuple_filter_src_port_value,
10394 (void *)&cmd_5tuple_filter_protocol,
10395 (void *)&cmd_5tuple_filter_protocol_value,
10396 (void *)&cmd_5tuple_filter_mask,
10397 (void *)&cmd_5tuple_filter_mask_value,
10398 (void *)&cmd_5tuple_filter_tcp_flags,
10399 (void *)&cmd_5tuple_filter_tcp_flags_value,
10400 (void *)&cmd_5tuple_filter_priority,
10401 (void *)&cmd_5tuple_filter_priority_value,
10402 (void *)&cmd_5tuple_filter_queue,
10403 (void *)&cmd_5tuple_filter_queue_id,
10408 /* *** ADD/REMOVE A flex FILTER *** */
10409 struct cmd_flex_filter_result {
10410 cmdline_fixed_string_t filter;
10411 cmdline_fixed_string_t ops;
10413 cmdline_fixed_string_t len;
10415 cmdline_fixed_string_t bytes;
10416 cmdline_fixed_string_t bytes_value;
10417 cmdline_fixed_string_t mask;
10418 cmdline_fixed_string_t mask_value;
10419 cmdline_fixed_string_t priority;
10420 uint8_t priority_value;
10421 cmdline_fixed_string_t queue;
10425 static int xdigit2val(unsigned char c)
10430 else if (isupper(c))
10431 val = c - 'A' + 10;
10433 val = c - 'a' + 10;
10438 cmd_flex_filter_parsed(void *parsed_result,
10439 __attribute__((unused)) struct cmdline *cl,
10440 __attribute__((unused)) void *data)
10443 struct rte_eth_flex_filter filter;
10444 struct cmd_flex_filter_result *res = parsed_result;
10445 char *bytes_ptr, *mask_ptr;
10446 uint16_t len, i, j = 0;
10451 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10452 printf("the len exceed the max length 128\n");
10455 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10456 filter.len = res->len_value;
10457 filter.priority = res->priority_value;
10458 filter.queue = res->queue_id;
10459 bytes_ptr = res->bytes_value;
10460 mask_ptr = res->mask_value;
10462 /* translate bytes string to array. */
10463 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10464 (bytes_ptr[1] == 'X')))
10466 len = strnlen(bytes_ptr, res->len_value * 2);
10467 if (len == 0 || (len % 8 != 0)) {
10468 printf("please check len and bytes input\n");
10471 for (i = 0; i < len; i++) {
10473 if (isxdigit(c) == 0) {
10474 /* invalid characters. */
10475 printf("invalid input\n");
10478 val = xdigit2val(c);
10481 filter.bytes[j] = byte;
10482 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10489 /* translate mask string to uint8_t array. */
10490 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10491 (mask_ptr[1] == 'X')))
10493 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10495 printf("invalid input\n");
10500 for (i = 0; i < len; i++) {
10502 if (isxdigit(c) == 0) {
10503 /* invalid characters. */
10504 printf("invalid input\n");
10507 val = xdigit2val(c);
10510 filter.mask[j] = byte;
10511 printf("mask[%d]:%02x ", j, filter.mask[j]);
10519 if (!strcmp(res->ops, "add"))
10520 ret = rte_eth_dev_filter_ctrl(res->port_id,
10521 RTE_ETH_FILTER_FLEXIBLE,
10522 RTE_ETH_FILTER_ADD,
10525 ret = rte_eth_dev_filter_ctrl(res->port_id,
10526 RTE_ETH_FILTER_FLEXIBLE,
10527 RTE_ETH_FILTER_DELETE,
10531 printf("flex filter setting error: (%s)\n", strerror(-ret));
10534 cmdline_parse_token_string_t cmd_flex_filter_filter =
10535 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10536 filter, "flex_filter");
10537 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10538 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10540 cmdline_parse_token_string_t cmd_flex_filter_ops =
10541 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10543 cmdline_parse_token_string_t cmd_flex_filter_len =
10544 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10546 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10547 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10549 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10550 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10552 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10553 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10554 bytes_value, NULL);
10555 cmdline_parse_token_string_t cmd_flex_filter_mask =
10556 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10558 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10559 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10561 cmdline_parse_token_string_t cmd_flex_filter_priority =
10562 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10563 priority, "priority");
10564 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10565 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10566 priority_value, UINT8);
10567 cmdline_parse_token_string_t cmd_flex_filter_queue =
10568 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10570 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10571 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10573 cmdline_parse_inst_t cmd_flex_filter = {
10574 .f = cmd_flex_filter_parsed,
10576 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10577 "<value> mask <value> priority <value> queue <queue_id>: "
10578 "Add/Del a flex filter",
10580 (void *)&cmd_flex_filter_filter,
10581 (void *)&cmd_flex_filter_port_id,
10582 (void *)&cmd_flex_filter_ops,
10583 (void *)&cmd_flex_filter_len,
10584 (void *)&cmd_flex_filter_len_value,
10585 (void *)&cmd_flex_filter_bytes,
10586 (void *)&cmd_flex_filter_bytes_value,
10587 (void *)&cmd_flex_filter_mask,
10588 (void *)&cmd_flex_filter_mask_value,
10589 (void *)&cmd_flex_filter_priority,
10590 (void *)&cmd_flex_filter_priority_value,
10591 (void *)&cmd_flex_filter_queue,
10592 (void *)&cmd_flex_filter_queue_id,
10597 /* *** Filters Control *** */
10599 /* *** deal with ethertype filter *** */
10600 struct cmd_ethertype_filter_result {
10601 cmdline_fixed_string_t filter;
10603 cmdline_fixed_string_t ops;
10604 cmdline_fixed_string_t mac;
10605 struct rte_ether_addr mac_addr;
10606 cmdline_fixed_string_t ethertype;
10607 uint16_t ethertype_value;
10608 cmdline_fixed_string_t drop;
10609 cmdline_fixed_string_t queue;
10613 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10614 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10615 filter, "ethertype_filter");
10616 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10617 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10619 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10620 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10622 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10623 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10624 mac, "mac_addr#mac_ignr");
10625 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10626 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10628 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10629 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10630 ethertype, "ethertype");
10631 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10632 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10633 ethertype_value, UINT16);
10634 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10635 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10637 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10638 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10640 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10641 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10645 cmd_ethertype_filter_parsed(void *parsed_result,
10646 __attribute__((unused)) struct cmdline *cl,
10647 __attribute__((unused)) void *data)
10649 struct cmd_ethertype_filter_result *res = parsed_result;
10650 struct rte_eth_ethertype_filter filter;
10653 ret = rte_eth_dev_filter_supported(res->port_id,
10654 RTE_ETH_FILTER_ETHERTYPE);
10656 printf("ethertype filter is not supported on port %u.\n",
10661 memset(&filter, 0, sizeof(filter));
10662 if (!strcmp(res->mac, "mac_addr")) {
10663 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10664 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10665 sizeof(struct rte_ether_addr));
10667 if (!strcmp(res->drop, "drop"))
10668 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10669 filter.ether_type = res->ethertype_value;
10670 filter.queue = res->queue_id;
10672 if (!strcmp(res->ops, "add"))
10673 ret = rte_eth_dev_filter_ctrl(res->port_id,
10674 RTE_ETH_FILTER_ETHERTYPE,
10675 RTE_ETH_FILTER_ADD,
10678 ret = rte_eth_dev_filter_ctrl(res->port_id,
10679 RTE_ETH_FILTER_ETHERTYPE,
10680 RTE_ETH_FILTER_DELETE,
10683 printf("ethertype filter programming error: (%s)\n",
10687 cmdline_parse_inst_t cmd_ethertype_filter = {
10688 .f = cmd_ethertype_filter_parsed,
10690 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10691 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10692 "Add or delete an ethertype filter entry",
10694 (void *)&cmd_ethertype_filter_filter,
10695 (void *)&cmd_ethertype_filter_port_id,
10696 (void *)&cmd_ethertype_filter_ops,
10697 (void *)&cmd_ethertype_filter_mac,
10698 (void *)&cmd_ethertype_filter_mac_addr,
10699 (void *)&cmd_ethertype_filter_ethertype,
10700 (void *)&cmd_ethertype_filter_ethertype_value,
10701 (void *)&cmd_ethertype_filter_drop,
10702 (void *)&cmd_ethertype_filter_queue,
10703 (void *)&cmd_ethertype_filter_queue_id,
10708 /* *** deal with flow director filter *** */
10709 struct cmd_flow_director_result {
10710 cmdline_fixed_string_t flow_director_filter;
10712 cmdline_fixed_string_t mode;
10713 cmdline_fixed_string_t mode_value;
10714 cmdline_fixed_string_t ops;
10715 cmdline_fixed_string_t flow;
10716 cmdline_fixed_string_t flow_type;
10717 cmdline_fixed_string_t ether;
10718 uint16_t ether_type;
10719 cmdline_fixed_string_t src;
10720 cmdline_ipaddr_t ip_src;
10722 cmdline_fixed_string_t dst;
10723 cmdline_ipaddr_t ip_dst;
10725 cmdline_fixed_string_t verify_tag;
10726 uint32_t verify_tag_value;
10727 cmdline_fixed_string_t tos;
10729 cmdline_fixed_string_t proto;
10730 uint8_t proto_value;
10731 cmdline_fixed_string_t ttl;
10733 cmdline_fixed_string_t vlan;
10734 uint16_t vlan_value;
10735 cmdline_fixed_string_t flexbytes;
10736 cmdline_fixed_string_t flexbytes_value;
10737 cmdline_fixed_string_t pf_vf;
10738 cmdline_fixed_string_t drop;
10739 cmdline_fixed_string_t queue;
10741 cmdline_fixed_string_t fd_id;
10742 uint32_t fd_id_value;
10743 cmdline_fixed_string_t mac;
10744 struct rte_ether_addr mac_addr;
10745 cmdline_fixed_string_t tunnel;
10746 cmdline_fixed_string_t tunnel_type;
10747 cmdline_fixed_string_t tunnel_id;
10748 uint32_t tunnel_id_value;
10749 cmdline_fixed_string_t packet;
10754 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10757 const char *p, *p0 = q_arg;
10759 unsigned long int_fld;
10760 char *str_fld[max_num];
10765 p = strchr(p0, '(');
10769 p0 = strchr(p, ')');
10774 if (size >= sizeof(s))
10777 snprintf(s, sizeof(s), "%.*s", size, p);
10778 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10779 if (ret < 0 || ret > max_num)
10781 for (i = 0; i < ret; i++) {
10783 int_fld = strtoul(str_fld[i], &end, 0);
10784 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10786 flexbytes[i] = (uint8_t)int_fld;
10792 str2flowtype(char *string)
10795 static const struct {
10798 } flowtype_str[] = {
10799 {"raw", RTE_ETH_FLOW_RAW},
10800 {"ipv4", RTE_ETH_FLOW_IPV4},
10801 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10802 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10803 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10804 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10805 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10806 {"ipv6", RTE_ETH_FLOW_IPV6},
10807 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10808 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10809 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10810 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10811 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10812 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10815 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10816 if (!strcmp(flowtype_str[i].str, string))
10817 return flowtype_str[i].type;
10820 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10821 return (uint16_t)atoi(string);
10823 return RTE_ETH_FLOW_UNKNOWN;
10826 static enum rte_eth_fdir_tunnel_type
10827 str2fdir_tunneltype(char *string)
10831 static const struct {
10833 enum rte_eth_fdir_tunnel_type type;
10834 } tunneltype_str[] = {
10835 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10836 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10839 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10840 if (!strcmp(tunneltype_str[i].str, string))
10841 return tunneltype_str[i].type;
10843 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10846 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10848 if ((ip_addr).family == AF_INET) \
10849 (ip) = (ip_addr).addr.ipv4.s_addr; \
10851 printf("invalid parameter.\n"); \
10856 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10858 if ((ip_addr).family == AF_INET6) \
10859 rte_memcpy(&(ip), \
10860 &((ip_addr).addr.ipv6), \
10861 sizeof(struct in6_addr)); \
10863 printf("invalid parameter.\n"); \
10869 cmd_flow_director_filter_parsed(void *parsed_result,
10870 __attribute__((unused)) struct cmdline *cl,
10871 __attribute__((unused)) void *data)
10873 struct cmd_flow_director_result *res = parsed_result;
10874 struct rte_eth_fdir_filter entry;
10875 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10877 unsigned long vf_id;
10880 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10882 printf("flow director is not supported on port %u.\n",
10886 memset(flexbytes, 0, sizeof(flexbytes));
10887 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10889 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10890 if (strcmp(res->mode_value, "MAC-VLAN")) {
10891 printf("Please set mode to MAC-VLAN.\n");
10894 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10895 if (strcmp(res->mode_value, "Tunnel")) {
10896 printf("Please set mode to Tunnel.\n");
10900 if (!strcmp(res->mode_value, "raw")) {
10901 #ifdef RTE_LIBRTE_I40E_PMD
10902 struct rte_pmd_i40e_flow_type_mapping
10903 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10904 struct rte_pmd_i40e_pkt_template_conf conf;
10905 uint16_t flow_type = str2flowtype(res->flow_type);
10906 uint16_t i, port = res->port_id;
10909 memset(&conf, 0, sizeof(conf));
10911 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10912 printf("Invalid flow type specified.\n");
10915 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10919 if (mapping[flow_type].pctype == 0ULL) {
10920 printf("Invalid flow type specified.\n");
10923 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10924 if (mapping[flow_type].pctype & (1ULL << i)) {
10925 conf.input.pctype = i;
10930 conf.input.packet = open_file(res->filepath,
10931 &conf.input.length);
10932 if (!conf.input.packet)
10934 if (!strcmp(res->drop, "drop"))
10935 conf.action.behavior =
10936 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10938 conf.action.behavior =
10939 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10940 conf.action.report_status =
10941 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10942 conf.action.rx_queue = res->queue_id;
10943 conf.soft_id = res->fd_id_value;
10944 add = strcmp(res->ops, "del") ? 1 : 0;
10945 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10949 printf("flow director config error: (%s)\n",
10951 close_file(conf.input.packet);
10954 } else if (strcmp(res->mode_value, "IP")) {
10955 printf("Please set mode to IP or raw.\n");
10958 entry.input.flow_type = str2flowtype(res->flow_type);
10961 ret = parse_flexbytes(res->flexbytes_value,
10963 RTE_ETH_FDIR_MAX_FLEXLEN);
10965 printf("error: Cannot parse flexbytes input.\n");
10969 switch (entry.input.flow_type) {
10970 case RTE_ETH_FLOW_FRAG_IPV4:
10971 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10972 entry.input.flow.ip4_flow.proto = res->proto_value;
10974 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10975 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10976 IPV4_ADDR_TO_UINT(res->ip_dst,
10977 entry.input.flow.ip4_flow.dst_ip);
10978 IPV4_ADDR_TO_UINT(res->ip_src,
10979 entry.input.flow.ip4_flow.src_ip);
10980 entry.input.flow.ip4_flow.tos = res->tos_value;
10981 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10982 /* need convert to big endian. */
10983 entry.input.flow.udp4_flow.dst_port =
10984 rte_cpu_to_be_16(res->port_dst);
10985 entry.input.flow.udp4_flow.src_port =
10986 rte_cpu_to_be_16(res->port_src);
10988 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10989 IPV4_ADDR_TO_UINT(res->ip_dst,
10990 entry.input.flow.sctp4_flow.ip.dst_ip);
10991 IPV4_ADDR_TO_UINT(res->ip_src,
10992 entry.input.flow.sctp4_flow.ip.src_ip);
10993 entry.input.flow.ip4_flow.tos = res->tos_value;
10994 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10995 /* need convert to big endian. */
10996 entry.input.flow.sctp4_flow.dst_port =
10997 rte_cpu_to_be_16(res->port_dst);
10998 entry.input.flow.sctp4_flow.src_port =
10999 rte_cpu_to_be_16(res->port_src);
11000 entry.input.flow.sctp4_flow.verify_tag =
11001 rte_cpu_to_be_32(res->verify_tag_value);
11003 case RTE_ETH_FLOW_FRAG_IPV6:
11004 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11005 entry.input.flow.ipv6_flow.proto = res->proto_value;
11007 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11008 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11009 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11010 entry.input.flow.ipv6_flow.dst_ip);
11011 IPV6_ADDR_TO_ARRAY(res->ip_src,
11012 entry.input.flow.ipv6_flow.src_ip);
11013 entry.input.flow.ipv6_flow.tc = res->tos_value;
11014 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11015 /* need convert to big endian. */
11016 entry.input.flow.udp6_flow.dst_port =
11017 rte_cpu_to_be_16(res->port_dst);
11018 entry.input.flow.udp6_flow.src_port =
11019 rte_cpu_to_be_16(res->port_src);
11021 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11022 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11023 entry.input.flow.sctp6_flow.ip.dst_ip);
11024 IPV6_ADDR_TO_ARRAY(res->ip_src,
11025 entry.input.flow.sctp6_flow.ip.src_ip);
11026 entry.input.flow.ipv6_flow.tc = res->tos_value;
11027 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11028 /* need convert to big endian. */
11029 entry.input.flow.sctp6_flow.dst_port =
11030 rte_cpu_to_be_16(res->port_dst);
11031 entry.input.flow.sctp6_flow.src_port =
11032 rte_cpu_to_be_16(res->port_src);
11033 entry.input.flow.sctp6_flow.verify_tag =
11034 rte_cpu_to_be_32(res->verify_tag_value);
11036 case RTE_ETH_FLOW_L2_PAYLOAD:
11037 entry.input.flow.l2_flow.ether_type =
11038 rte_cpu_to_be_16(res->ether_type);
11044 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11045 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11047 sizeof(struct rte_ether_addr));
11049 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11050 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11052 sizeof(struct rte_ether_addr));
11053 entry.input.flow.tunnel_flow.tunnel_type =
11054 str2fdir_tunneltype(res->tunnel_type);
11055 entry.input.flow.tunnel_flow.tunnel_id =
11056 rte_cpu_to_be_32(res->tunnel_id_value);
11059 rte_memcpy(entry.input.flow_ext.flexbytes,
11061 RTE_ETH_FDIR_MAX_FLEXLEN);
11063 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11065 entry.action.flex_off = 0; /*use 0 by default */
11066 if (!strcmp(res->drop, "drop"))
11067 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11069 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11071 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11072 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11073 if (!strcmp(res->pf_vf, "pf"))
11074 entry.input.flow_ext.is_vf = 0;
11075 else if (!strncmp(res->pf_vf, "vf", 2)) {
11076 struct rte_eth_dev_info dev_info;
11078 memset(&dev_info, 0, sizeof(dev_info));
11079 rte_eth_dev_info_get(res->port_id, &dev_info);
11081 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11082 if (errno != 0 || *end != '\0' ||
11083 vf_id >= dev_info.max_vfs) {
11084 printf("invalid parameter %s.\n", res->pf_vf);
11087 entry.input.flow_ext.is_vf = 1;
11088 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11090 printf("invalid parameter %s.\n", res->pf_vf);
11095 /* set to report FD ID by default */
11096 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11097 entry.action.rx_queue = res->queue_id;
11098 entry.soft_id = res->fd_id_value;
11099 if (!strcmp(res->ops, "add"))
11100 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11101 RTE_ETH_FILTER_ADD, &entry);
11102 else if (!strcmp(res->ops, "del"))
11103 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11104 RTE_ETH_FILTER_DELETE, &entry);
11106 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11107 RTE_ETH_FILTER_UPDATE, &entry);
11109 printf("flow director programming error: (%s)\n",
11113 cmdline_parse_token_string_t cmd_flow_director_filter =
11114 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11115 flow_director_filter, "flow_director_filter");
11116 cmdline_parse_token_num_t cmd_flow_director_port_id =
11117 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11119 cmdline_parse_token_string_t cmd_flow_director_ops =
11120 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11121 ops, "add#del#update");
11122 cmdline_parse_token_string_t cmd_flow_director_flow =
11123 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11125 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11126 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11128 cmdline_parse_token_string_t cmd_flow_director_ether =
11129 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11131 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11132 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11133 ether_type, UINT16);
11134 cmdline_parse_token_string_t cmd_flow_director_src =
11135 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11137 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11138 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11140 cmdline_parse_token_num_t cmd_flow_director_port_src =
11141 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11143 cmdline_parse_token_string_t cmd_flow_director_dst =
11144 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11146 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11147 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11149 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11150 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11152 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11153 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11154 verify_tag, "verify_tag");
11155 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11156 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11157 verify_tag_value, UINT32);
11158 cmdline_parse_token_string_t cmd_flow_director_tos =
11159 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11161 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11162 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11164 cmdline_parse_token_string_t cmd_flow_director_proto =
11165 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11167 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11168 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11169 proto_value, UINT8);
11170 cmdline_parse_token_string_t cmd_flow_director_ttl =
11171 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11173 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11174 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11176 cmdline_parse_token_string_t cmd_flow_director_vlan =
11177 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11179 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11180 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11181 vlan_value, UINT16);
11182 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11183 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11184 flexbytes, "flexbytes");
11185 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11186 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11187 flexbytes_value, NULL);
11188 cmdline_parse_token_string_t cmd_flow_director_drop =
11189 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11191 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11192 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11194 cmdline_parse_token_string_t cmd_flow_director_queue =
11195 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11197 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11198 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11200 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11201 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11203 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11204 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11205 fd_id_value, UINT32);
11207 cmdline_parse_token_string_t cmd_flow_director_mode =
11208 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11210 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11211 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11213 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11214 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11215 mode_value, "MAC-VLAN");
11216 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11217 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11218 mode_value, "Tunnel");
11219 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11220 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11221 mode_value, "raw");
11222 cmdline_parse_token_string_t cmd_flow_director_mac =
11223 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11225 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11226 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11228 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11229 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11231 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11232 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11233 tunnel_type, "NVGRE#VxLAN");
11234 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11235 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11236 tunnel_id, "tunnel-id");
11237 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11238 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11239 tunnel_id_value, UINT32);
11240 cmdline_parse_token_string_t cmd_flow_director_packet =
11241 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11243 cmdline_parse_token_string_t cmd_flow_director_filepath =
11244 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11247 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11248 .f = cmd_flow_director_filter_parsed,
11250 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11251 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11252 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11253 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11254 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11255 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11256 "fd_id <fd_id_value>: "
11257 "Add or delete an ip flow director entry on NIC",
11259 (void *)&cmd_flow_director_filter,
11260 (void *)&cmd_flow_director_port_id,
11261 (void *)&cmd_flow_director_mode,
11262 (void *)&cmd_flow_director_mode_ip,
11263 (void *)&cmd_flow_director_ops,
11264 (void *)&cmd_flow_director_flow,
11265 (void *)&cmd_flow_director_flow_type,
11266 (void *)&cmd_flow_director_src,
11267 (void *)&cmd_flow_director_ip_src,
11268 (void *)&cmd_flow_director_dst,
11269 (void *)&cmd_flow_director_ip_dst,
11270 (void *)&cmd_flow_director_tos,
11271 (void *)&cmd_flow_director_tos_value,
11272 (void *)&cmd_flow_director_proto,
11273 (void *)&cmd_flow_director_proto_value,
11274 (void *)&cmd_flow_director_ttl,
11275 (void *)&cmd_flow_director_ttl_value,
11276 (void *)&cmd_flow_director_vlan,
11277 (void *)&cmd_flow_director_vlan_value,
11278 (void *)&cmd_flow_director_flexbytes,
11279 (void *)&cmd_flow_director_flexbytes_value,
11280 (void *)&cmd_flow_director_drop,
11281 (void *)&cmd_flow_director_pf_vf,
11282 (void *)&cmd_flow_director_queue,
11283 (void *)&cmd_flow_director_queue_id,
11284 (void *)&cmd_flow_director_fd_id,
11285 (void *)&cmd_flow_director_fd_id_value,
11290 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11291 .f = cmd_flow_director_filter_parsed,
11293 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11294 "director entry on NIC",
11296 (void *)&cmd_flow_director_filter,
11297 (void *)&cmd_flow_director_port_id,
11298 (void *)&cmd_flow_director_mode,
11299 (void *)&cmd_flow_director_mode_ip,
11300 (void *)&cmd_flow_director_ops,
11301 (void *)&cmd_flow_director_flow,
11302 (void *)&cmd_flow_director_flow_type,
11303 (void *)&cmd_flow_director_src,
11304 (void *)&cmd_flow_director_ip_src,
11305 (void *)&cmd_flow_director_port_src,
11306 (void *)&cmd_flow_director_dst,
11307 (void *)&cmd_flow_director_ip_dst,
11308 (void *)&cmd_flow_director_port_dst,
11309 (void *)&cmd_flow_director_tos,
11310 (void *)&cmd_flow_director_tos_value,
11311 (void *)&cmd_flow_director_ttl,
11312 (void *)&cmd_flow_director_ttl_value,
11313 (void *)&cmd_flow_director_vlan,
11314 (void *)&cmd_flow_director_vlan_value,
11315 (void *)&cmd_flow_director_flexbytes,
11316 (void *)&cmd_flow_director_flexbytes_value,
11317 (void *)&cmd_flow_director_drop,
11318 (void *)&cmd_flow_director_pf_vf,
11319 (void *)&cmd_flow_director_queue,
11320 (void *)&cmd_flow_director_queue_id,
11321 (void *)&cmd_flow_director_fd_id,
11322 (void *)&cmd_flow_director_fd_id_value,
11327 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11328 .f = cmd_flow_director_filter_parsed,
11330 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11331 "director entry on NIC",
11333 (void *)&cmd_flow_director_filter,
11334 (void *)&cmd_flow_director_port_id,
11335 (void *)&cmd_flow_director_mode,
11336 (void *)&cmd_flow_director_mode_ip,
11337 (void *)&cmd_flow_director_ops,
11338 (void *)&cmd_flow_director_flow,
11339 (void *)&cmd_flow_director_flow_type,
11340 (void *)&cmd_flow_director_src,
11341 (void *)&cmd_flow_director_ip_src,
11342 (void *)&cmd_flow_director_port_src,
11343 (void *)&cmd_flow_director_dst,
11344 (void *)&cmd_flow_director_ip_dst,
11345 (void *)&cmd_flow_director_port_dst,
11346 (void *)&cmd_flow_director_verify_tag,
11347 (void *)&cmd_flow_director_verify_tag_value,
11348 (void *)&cmd_flow_director_tos,
11349 (void *)&cmd_flow_director_tos_value,
11350 (void *)&cmd_flow_director_ttl,
11351 (void *)&cmd_flow_director_ttl_value,
11352 (void *)&cmd_flow_director_vlan,
11353 (void *)&cmd_flow_director_vlan_value,
11354 (void *)&cmd_flow_director_flexbytes,
11355 (void *)&cmd_flow_director_flexbytes_value,
11356 (void *)&cmd_flow_director_drop,
11357 (void *)&cmd_flow_director_pf_vf,
11358 (void *)&cmd_flow_director_queue,
11359 (void *)&cmd_flow_director_queue_id,
11360 (void *)&cmd_flow_director_fd_id,
11361 (void *)&cmd_flow_director_fd_id_value,
11366 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11367 .f = cmd_flow_director_filter_parsed,
11369 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11370 "director entry on NIC",
11372 (void *)&cmd_flow_director_filter,
11373 (void *)&cmd_flow_director_port_id,
11374 (void *)&cmd_flow_director_mode,
11375 (void *)&cmd_flow_director_mode_ip,
11376 (void *)&cmd_flow_director_ops,
11377 (void *)&cmd_flow_director_flow,
11378 (void *)&cmd_flow_director_flow_type,
11379 (void *)&cmd_flow_director_ether,
11380 (void *)&cmd_flow_director_ether_type,
11381 (void *)&cmd_flow_director_flexbytes,
11382 (void *)&cmd_flow_director_flexbytes_value,
11383 (void *)&cmd_flow_director_drop,
11384 (void *)&cmd_flow_director_pf_vf,
11385 (void *)&cmd_flow_director_queue,
11386 (void *)&cmd_flow_director_queue_id,
11387 (void *)&cmd_flow_director_fd_id,
11388 (void *)&cmd_flow_director_fd_id_value,
11393 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11394 .f = cmd_flow_director_filter_parsed,
11396 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11397 "director entry on NIC",
11399 (void *)&cmd_flow_director_filter,
11400 (void *)&cmd_flow_director_port_id,
11401 (void *)&cmd_flow_director_mode,
11402 (void *)&cmd_flow_director_mode_mac_vlan,
11403 (void *)&cmd_flow_director_ops,
11404 (void *)&cmd_flow_director_mac,
11405 (void *)&cmd_flow_director_mac_addr,
11406 (void *)&cmd_flow_director_vlan,
11407 (void *)&cmd_flow_director_vlan_value,
11408 (void *)&cmd_flow_director_flexbytes,
11409 (void *)&cmd_flow_director_flexbytes_value,
11410 (void *)&cmd_flow_director_drop,
11411 (void *)&cmd_flow_director_queue,
11412 (void *)&cmd_flow_director_queue_id,
11413 (void *)&cmd_flow_director_fd_id,
11414 (void *)&cmd_flow_director_fd_id_value,
11419 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11420 .f = cmd_flow_director_filter_parsed,
11422 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11423 "director entry on NIC",
11425 (void *)&cmd_flow_director_filter,
11426 (void *)&cmd_flow_director_port_id,
11427 (void *)&cmd_flow_director_mode,
11428 (void *)&cmd_flow_director_mode_tunnel,
11429 (void *)&cmd_flow_director_ops,
11430 (void *)&cmd_flow_director_mac,
11431 (void *)&cmd_flow_director_mac_addr,
11432 (void *)&cmd_flow_director_vlan,
11433 (void *)&cmd_flow_director_vlan_value,
11434 (void *)&cmd_flow_director_tunnel,
11435 (void *)&cmd_flow_director_tunnel_type,
11436 (void *)&cmd_flow_director_tunnel_id,
11437 (void *)&cmd_flow_director_tunnel_id_value,
11438 (void *)&cmd_flow_director_flexbytes,
11439 (void *)&cmd_flow_director_flexbytes_value,
11440 (void *)&cmd_flow_director_drop,
11441 (void *)&cmd_flow_director_queue,
11442 (void *)&cmd_flow_director_queue_id,
11443 (void *)&cmd_flow_director_fd_id,
11444 (void *)&cmd_flow_director_fd_id_value,
11449 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11450 .f = cmd_flow_director_filter_parsed,
11452 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11453 "director entry on NIC",
11455 (void *)&cmd_flow_director_filter,
11456 (void *)&cmd_flow_director_port_id,
11457 (void *)&cmd_flow_director_mode,
11458 (void *)&cmd_flow_director_mode_raw,
11459 (void *)&cmd_flow_director_ops,
11460 (void *)&cmd_flow_director_flow,
11461 (void *)&cmd_flow_director_flow_type,
11462 (void *)&cmd_flow_director_drop,
11463 (void *)&cmd_flow_director_queue,
11464 (void *)&cmd_flow_director_queue_id,
11465 (void *)&cmd_flow_director_fd_id,
11466 (void *)&cmd_flow_director_fd_id_value,
11467 (void *)&cmd_flow_director_packet,
11468 (void *)&cmd_flow_director_filepath,
11473 struct cmd_flush_flow_director_result {
11474 cmdline_fixed_string_t flush_flow_director;
11478 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11479 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11480 flush_flow_director, "flush_flow_director");
11481 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11482 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11486 cmd_flush_flow_director_parsed(void *parsed_result,
11487 __attribute__((unused)) struct cmdline *cl,
11488 __attribute__((unused)) void *data)
11490 struct cmd_flow_director_result *res = parsed_result;
11493 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11495 printf("flow director is not supported on port %u.\n",
11500 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11501 RTE_ETH_FILTER_FLUSH, NULL);
11503 printf("flow director table flushing error: (%s)\n",
11507 cmdline_parse_inst_t cmd_flush_flow_director = {
11508 .f = cmd_flush_flow_director_parsed,
11510 .help_str = "flush_flow_director <port_id>: "
11511 "Flush all flow director entries of a device on NIC",
11513 (void *)&cmd_flush_flow_director_flush,
11514 (void *)&cmd_flush_flow_director_port_id,
11519 /* *** deal with flow director mask *** */
11520 struct cmd_flow_director_mask_result {
11521 cmdline_fixed_string_t flow_director_mask;
11523 cmdline_fixed_string_t mode;
11524 cmdline_fixed_string_t mode_value;
11525 cmdline_fixed_string_t vlan;
11526 uint16_t vlan_mask;
11527 cmdline_fixed_string_t src_mask;
11528 cmdline_ipaddr_t ipv4_src;
11529 cmdline_ipaddr_t ipv6_src;
11531 cmdline_fixed_string_t dst_mask;
11532 cmdline_ipaddr_t ipv4_dst;
11533 cmdline_ipaddr_t ipv6_dst;
11535 cmdline_fixed_string_t mac;
11536 uint8_t mac_addr_byte_mask;
11537 cmdline_fixed_string_t tunnel_id;
11538 uint32_t tunnel_id_mask;
11539 cmdline_fixed_string_t tunnel_type;
11540 uint8_t tunnel_type_mask;
11544 cmd_flow_director_mask_parsed(void *parsed_result,
11545 __attribute__((unused)) struct cmdline *cl,
11546 __attribute__((unused)) void *data)
11548 struct cmd_flow_director_mask_result *res = parsed_result;
11549 struct rte_eth_fdir_masks *mask;
11550 struct rte_port *port;
11552 port = &ports[res->port_id];
11553 /** Check if the port is not started **/
11554 if (port->port_status != RTE_PORT_STOPPED) {
11555 printf("Please stop port %d first\n", res->port_id);
11559 mask = &port->dev_conf.fdir_conf.mask;
11561 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11562 if (strcmp(res->mode_value, "MAC-VLAN")) {
11563 printf("Please set mode to MAC-VLAN.\n");
11567 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11568 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11569 if (strcmp(res->mode_value, "Tunnel")) {
11570 printf("Please set mode to Tunnel.\n");
11574 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11575 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11576 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11577 mask->tunnel_type_mask = res->tunnel_type_mask;
11579 if (strcmp(res->mode_value, "IP")) {
11580 printf("Please set mode to IP.\n");
11584 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11585 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11586 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11587 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11588 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11589 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11590 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11593 cmd_reconfig_device_queue(res->port_id, 1, 1);
11596 cmdline_parse_token_string_t cmd_flow_director_mask =
11597 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11598 flow_director_mask, "flow_director_mask");
11599 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11600 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11602 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11603 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11605 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11606 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11607 vlan_mask, UINT16);
11608 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11609 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11610 src_mask, "src_mask");
11611 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11612 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11614 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11615 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11617 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11618 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11620 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11621 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11622 dst_mask, "dst_mask");
11623 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11624 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11626 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11627 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11629 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11630 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11633 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11634 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11636 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11637 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11639 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11640 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11641 mode_value, "MAC-VLAN");
11642 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11643 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11644 mode_value, "Tunnel");
11645 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11646 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11648 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11649 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11650 mac_addr_byte_mask, UINT8);
11651 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11652 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11653 tunnel_type, "tunnel-type");
11654 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11655 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11656 tunnel_type_mask, UINT8);
11657 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11658 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11659 tunnel_id, "tunnel-id");
11660 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11661 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11662 tunnel_id_mask, UINT32);
11664 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11665 .f = cmd_flow_director_mask_parsed,
11667 .help_str = "flow_director_mask ... : "
11668 "Set IP mode flow director's mask on NIC",
11670 (void *)&cmd_flow_director_mask,
11671 (void *)&cmd_flow_director_mask_port_id,
11672 (void *)&cmd_flow_director_mask_mode,
11673 (void *)&cmd_flow_director_mask_mode_ip,
11674 (void *)&cmd_flow_director_mask_vlan,
11675 (void *)&cmd_flow_director_mask_vlan_value,
11676 (void *)&cmd_flow_director_mask_src,
11677 (void *)&cmd_flow_director_mask_ipv4_src,
11678 (void *)&cmd_flow_director_mask_ipv6_src,
11679 (void *)&cmd_flow_director_mask_port_src,
11680 (void *)&cmd_flow_director_mask_dst,
11681 (void *)&cmd_flow_director_mask_ipv4_dst,
11682 (void *)&cmd_flow_director_mask_ipv6_dst,
11683 (void *)&cmd_flow_director_mask_port_dst,
11688 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11689 .f = cmd_flow_director_mask_parsed,
11691 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11692 "flow director's mask on NIC",
11694 (void *)&cmd_flow_director_mask,
11695 (void *)&cmd_flow_director_mask_port_id,
11696 (void *)&cmd_flow_director_mask_mode,
11697 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11698 (void *)&cmd_flow_director_mask_vlan,
11699 (void *)&cmd_flow_director_mask_vlan_value,
11704 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11705 .f = cmd_flow_director_mask_parsed,
11707 .help_str = "flow_director_mask ... : Set tunnel mode "
11708 "flow director's mask on NIC",
11710 (void *)&cmd_flow_director_mask,
11711 (void *)&cmd_flow_director_mask_port_id,
11712 (void *)&cmd_flow_director_mask_mode,
11713 (void *)&cmd_flow_director_mask_mode_tunnel,
11714 (void *)&cmd_flow_director_mask_vlan,
11715 (void *)&cmd_flow_director_mask_vlan_value,
11716 (void *)&cmd_flow_director_mask_mac,
11717 (void *)&cmd_flow_director_mask_mac_value,
11718 (void *)&cmd_flow_director_mask_tunnel_type,
11719 (void *)&cmd_flow_director_mask_tunnel_type_value,
11720 (void *)&cmd_flow_director_mask_tunnel_id,
11721 (void *)&cmd_flow_director_mask_tunnel_id_value,
11726 /* *** deal with flow director mask on flexible payload *** */
11727 struct cmd_flow_director_flex_mask_result {
11728 cmdline_fixed_string_t flow_director_flexmask;
11730 cmdline_fixed_string_t flow;
11731 cmdline_fixed_string_t flow_type;
11732 cmdline_fixed_string_t mask;
11736 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11737 __attribute__((unused)) struct cmdline *cl,
11738 __attribute__((unused)) void *data)
11740 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11741 struct rte_eth_fdir_info fdir_info;
11742 struct rte_eth_fdir_flex_mask flex_mask;
11743 struct rte_port *port;
11744 uint64_t flow_type_mask;
11748 port = &ports[res->port_id];
11749 /** Check if the port is not started **/
11750 if (port->port_status != RTE_PORT_STOPPED) {
11751 printf("Please stop port %d first\n", res->port_id);
11755 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11756 ret = parse_flexbytes(res->mask,
11758 RTE_ETH_FDIR_MAX_FLEXLEN);
11760 printf("error: Cannot parse mask input.\n");
11764 memset(&fdir_info, 0, sizeof(fdir_info));
11765 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11766 RTE_ETH_FILTER_INFO, &fdir_info);
11768 printf("Cannot get FDir filter info\n");
11772 if (!strcmp(res->flow_type, "none")) {
11773 /* means don't specify the flow type */
11774 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11775 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11776 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11777 0, sizeof(struct rte_eth_fdir_flex_mask));
11778 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11779 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11781 sizeof(struct rte_eth_fdir_flex_mask));
11782 cmd_reconfig_device_queue(res->port_id, 1, 1);
11785 flow_type_mask = fdir_info.flow_types_mask[0];
11786 if (!strcmp(res->flow_type, "all")) {
11787 if (!flow_type_mask) {
11788 printf("No flow type supported\n");
11791 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11792 if (flow_type_mask & (1ULL << i)) {
11793 flex_mask.flow_type = i;
11794 fdir_set_flex_mask(res->port_id, &flex_mask);
11797 cmd_reconfig_device_queue(res->port_id, 1, 1);
11800 flex_mask.flow_type = str2flowtype(res->flow_type);
11801 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11802 printf("Flow type %s not supported on port %d\n",
11803 res->flow_type, res->port_id);
11806 fdir_set_flex_mask(res->port_id, &flex_mask);
11807 cmd_reconfig_device_queue(res->port_id, 1, 1);
11810 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11811 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11812 flow_director_flexmask,
11813 "flow_director_flex_mask");
11814 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11815 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11817 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11818 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11820 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11821 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11822 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11823 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11824 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11825 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11828 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11829 .f = cmd_flow_director_flex_mask_parsed,
11831 .help_str = "flow_director_flex_mask ... : "
11832 "Set flow director's flex mask on NIC",
11834 (void *)&cmd_flow_director_flexmask,
11835 (void *)&cmd_flow_director_flexmask_port_id,
11836 (void *)&cmd_flow_director_flexmask_flow,
11837 (void *)&cmd_flow_director_flexmask_flow_type,
11838 (void *)&cmd_flow_director_flexmask_mask,
11843 /* *** deal with flow director flexible payload configuration *** */
11844 struct cmd_flow_director_flexpayload_result {
11845 cmdline_fixed_string_t flow_director_flexpayload;
11847 cmdline_fixed_string_t payload_layer;
11848 cmdline_fixed_string_t payload_cfg;
11852 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11855 const char *p, *p0 = q_arg;
11857 unsigned long int_fld;
11858 char *str_fld[max_num];
11863 p = strchr(p0, '(');
11867 p0 = strchr(p, ')');
11872 if (size >= sizeof(s))
11875 snprintf(s, sizeof(s), "%.*s", size, p);
11876 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11877 if (ret < 0 || ret > max_num)
11879 for (i = 0; i < ret; i++) {
11881 int_fld = strtoul(str_fld[i], &end, 0);
11882 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11884 offsets[i] = (uint16_t)int_fld;
11890 cmd_flow_director_flxpld_parsed(void *parsed_result,
11891 __attribute__((unused)) struct cmdline *cl,
11892 __attribute__((unused)) void *data)
11894 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11895 struct rte_eth_flex_payload_cfg flex_cfg;
11896 struct rte_port *port;
11899 port = &ports[res->port_id];
11900 /** Check if the port is not started **/
11901 if (port->port_status != RTE_PORT_STOPPED) {
11902 printf("Please stop port %d first\n", res->port_id);
11906 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11908 if (!strcmp(res->payload_layer, "raw"))
11909 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11910 else if (!strcmp(res->payload_layer, "l2"))
11911 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11912 else if (!strcmp(res->payload_layer, "l3"))
11913 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11914 else if (!strcmp(res->payload_layer, "l4"))
11915 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11917 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11918 RTE_ETH_FDIR_MAX_FLEXLEN);
11920 printf("error: Cannot parse flex payload input.\n");
11924 fdir_set_flex_payload(res->port_id, &flex_cfg);
11925 cmd_reconfig_device_queue(res->port_id, 1, 1);
11928 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11929 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11930 flow_director_flexpayload,
11931 "flow_director_flex_payload");
11932 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11933 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11935 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11936 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11937 payload_layer, "raw#l2#l3#l4");
11938 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11939 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11940 payload_cfg, NULL);
11942 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11943 .f = cmd_flow_director_flxpld_parsed,
11945 .help_str = "flow_director_flexpayload ... : "
11946 "Set flow director's flex payload on NIC",
11948 (void *)&cmd_flow_director_flexpayload,
11949 (void *)&cmd_flow_director_flexpayload_port_id,
11950 (void *)&cmd_flow_director_flexpayload_payload_layer,
11951 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11956 /* Generic flow interface command. */
11957 extern cmdline_parse_inst_t cmd_flow;
11959 /* *** Classification Filters Control *** */
11960 /* *** Get symmetric hash enable per port *** */
11961 struct cmd_get_sym_hash_ena_per_port_result {
11962 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11967 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11968 __rte_unused struct cmdline *cl,
11969 __rte_unused void *data)
11971 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11972 struct rte_eth_hash_filter_info info;
11975 if (rte_eth_dev_filter_supported(res->port_id,
11976 RTE_ETH_FILTER_HASH) < 0) {
11977 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11982 memset(&info, 0, sizeof(info));
11983 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11984 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11985 RTE_ETH_FILTER_GET, &info);
11988 printf("Cannot get symmetric hash enable per port "
11989 "on port %u\n", res->port_id);
11993 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11994 "enabled" : "disabled", res->port_id);
11997 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11998 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11999 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12000 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12001 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12004 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12005 .f = cmd_get_sym_hash_per_port_parsed,
12007 .help_str = "get_sym_hash_ena_per_port <port_id>",
12009 (void *)&cmd_get_sym_hash_ena_per_port_all,
12010 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12015 /* *** Set symmetric hash enable per port *** */
12016 struct cmd_set_sym_hash_ena_per_port_result {
12017 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12018 cmdline_fixed_string_t enable;
12023 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12024 __rte_unused struct cmdline *cl,
12025 __rte_unused void *data)
12027 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12028 struct rte_eth_hash_filter_info info;
12031 if (rte_eth_dev_filter_supported(res->port_id,
12032 RTE_ETH_FILTER_HASH) < 0) {
12033 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12038 memset(&info, 0, sizeof(info));
12039 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12040 if (!strcmp(res->enable, "enable"))
12041 info.info.enable = 1;
12042 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12043 RTE_ETH_FILTER_SET, &info);
12045 printf("Cannot set symmetric hash enable per port on "
12046 "port %u\n", res->port_id);
12049 printf("Symmetric hash has been set to %s on port %u\n",
12050 res->enable, res->port_id);
12053 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12054 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12055 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12056 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12057 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12059 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12060 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12061 enable, "enable#disable");
12063 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12064 .f = cmd_set_sym_hash_per_port_parsed,
12066 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12068 (void *)&cmd_set_sym_hash_ena_per_port_all,
12069 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12070 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12075 /* Get global config of hash function */
12076 struct cmd_get_hash_global_config_result {
12077 cmdline_fixed_string_t get_hash_global_config;
12082 flowtype_to_str(uint16_t ftype)
12088 } ftype_table[] = {
12089 {"ipv4", RTE_ETH_FLOW_IPV4},
12090 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12091 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12092 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12093 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12094 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12095 {"ipv6", RTE_ETH_FLOW_IPV6},
12096 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12097 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12098 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12099 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12100 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12101 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12102 {"port", RTE_ETH_FLOW_PORT},
12103 {"vxlan", RTE_ETH_FLOW_VXLAN},
12104 {"geneve", RTE_ETH_FLOW_GENEVE},
12105 {"nvgre", RTE_ETH_FLOW_NVGRE},
12106 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12109 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12110 if (ftype_table[i].ftype == ftype)
12111 return ftype_table[i].str;
12118 cmd_get_hash_global_config_parsed(void *parsed_result,
12119 __rte_unused struct cmdline *cl,
12120 __rte_unused void *data)
12122 struct cmd_get_hash_global_config_result *res = parsed_result;
12123 struct rte_eth_hash_filter_info info;
12124 uint32_t idx, offset;
12129 if (rte_eth_dev_filter_supported(res->port_id,
12130 RTE_ETH_FILTER_HASH) < 0) {
12131 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12136 memset(&info, 0, sizeof(info));
12137 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12138 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12139 RTE_ETH_FILTER_GET, &info);
12141 printf("Cannot get hash global configurations by port %d\n",
12146 switch (info.info.global_conf.hash_func) {
12147 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12148 printf("Hash function is Toeplitz\n");
12150 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12151 printf("Hash function is Simple XOR\n");
12154 printf("Unknown hash function\n");
12158 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12159 idx = i / UINT64_BIT;
12160 offset = i % UINT64_BIT;
12161 if (!(info.info.global_conf.valid_bit_mask[idx] &
12164 str = flowtype_to_str(i);
12167 printf("Symmetric hash is %s globally for flow type %s "
12169 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12170 (1ULL << offset)) ? "enabled" : "disabled"), str,
12175 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12176 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12177 get_hash_global_config, "get_hash_global_config");
12178 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12179 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12182 cmdline_parse_inst_t cmd_get_hash_global_config = {
12183 .f = cmd_get_hash_global_config_parsed,
12185 .help_str = "get_hash_global_config <port_id>",
12187 (void *)&cmd_get_hash_global_config_all,
12188 (void *)&cmd_get_hash_global_config_port_id,
12193 /* Set global config of hash function */
12194 struct cmd_set_hash_global_config_result {
12195 cmdline_fixed_string_t set_hash_global_config;
12197 cmdline_fixed_string_t hash_func;
12198 cmdline_fixed_string_t flow_type;
12199 cmdline_fixed_string_t enable;
12203 cmd_set_hash_global_config_parsed(void *parsed_result,
12204 __rte_unused struct cmdline *cl,
12205 __rte_unused void *data)
12207 struct cmd_set_hash_global_config_result *res = parsed_result;
12208 struct rte_eth_hash_filter_info info;
12209 uint32_t ftype, idx, offset;
12212 if (rte_eth_dev_filter_supported(res->port_id,
12213 RTE_ETH_FILTER_HASH) < 0) {
12214 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12218 memset(&info, 0, sizeof(info));
12219 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12220 if (!strcmp(res->hash_func, "toeplitz"))
12221 info.info.global_conf.hash_func =
12222 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12223 else if (!strcmp(res->hash_func, "simple_xor"))
12224 info.info.global_conf.hash_func =
12225 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12226 else if (!strcmp(res->hash_func, "default"))
12227 info.info.global_conf.hash_func =
12228 RTE_ETH_HASH_FUNCTION_DEFAULT;
12230 ftype = str2flowtype(res->flow_type);
12231 idx = ftype / UINT64_BIT;
12232 offset = ftype % UINT64_BIT;
12233 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12234 if (!strcmp(res->enable, "enable"))
12235 info.info.global_conf.sym_hash_enable_mask[idx] |=
12237 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12238 RTE_ETH_FILTER_SET, &info);
12240 printf("Cannot set global hash configurations by port %d\n",
12243 printf("Global hash configurations have been set "
12244 "successfully by port %d\n", res->port_id);
12247 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12248 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12249 set_hash_global_config, "set_hash_global_config");
12250 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12251 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12253 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12254 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12255 hash_func, "toeplitz#simple_xor#default");
12256 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12257 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12259 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12260 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12261 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12262 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12263 enable, "enable#disable");
12265 cmdline_parse_inst_t cmd_set_hash_global_config = {
12266 .f = cmd_set_hash_global_config_parsed,
12268 .help_str = "set_hash_global_config <port_id> "
12269 "toeplitz|simple_xor|default "
12270 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12271 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12272 "l2_payload enable|disable",
12274 (void *)&cmd_set_hash_global_config_all,
12275 (void *)&cmd_set_hash_global_config_port_id,
12276 (void *)&cmd_set_hash_global_config_hash_func,
12277 (void *)&cmd_set_hash_global_config_flow_type,
12278 (void *)&cmd_set_hash_global_config_enable,
12283 /* Set hash input set */
12284 struct cmd_set_hash_input_set_result {
12285 cmdline_fixed_string_t set_hash_input_set;
12287 cmdline_fixed_string_t flow_type;
12288 cmdline_fixed_string_t inset_field;
12289 cmdline_fixed_string_t select;
12292 static enum rte_eth_input_set_field
12293 str2inset(char *string)
12297 static const struct {
12299 enum rte_eth_input_set_field inset;
12300 } inset_table[] = {
12301 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12302 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12303 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12304 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12305 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12306 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12307 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12308 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12309 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12310 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12311 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12312 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12313 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12314 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12315 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12316 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12317 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12318 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12319 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12320 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12321 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12322 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12323 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12324 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12325 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12326 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12327 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12328 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12329 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12330 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12331 {"none", RTE_ETH_INPUT_SET_NONE},
12334 for (i = 0; i < RTE_DIM(inset_table); i++) {
12335 if (!strcmp(string, inset_table[i].str))
12336 return inset_table[i].inset;
12339 return RTE_ETH_INPUT_SET_UNKNOWN;
12343 cmd_set_hash_input_set_parsed(void *parsed_result,
12344 __rte_unused struct cmdline *cl,
12345 __rte_unused void *data)
12347 struct cmd_set_hash_input_set_result *res = parsed_result;
12348 struct rte_eth_hash_filter_info info;
12350 memset(&info, 0, sizeof(info));
12351 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12352 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12353 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12354 info.info.input_set_conf.inset_size = 1;
12355 if (!strcmp(res->select, "select"))
12356 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12357 else if (!strcmp(res->select, "add"))
12358 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12359 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12360 RTE_ETH_FILTER_SET, &info);
12363 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12364 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12365 set_hash_input_set, "set_hash_input_set");
12366 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12367 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12369 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12370 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12372 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12373 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12375 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12376 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12377 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12378 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12379 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12381 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12382 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12383 select, "select#add");
12385 cmdline_parse_inst_t cmd_set_hash_input_set = {
12386 .f = cmd_set_hash_input_set_parsed,
12388 .help_str = "set_hash_input_set <port_id> "
12389 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12390 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12391 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12392 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12393 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12394 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12395 "fld-7th|fld-8th|none select|add",
12397 (void *)&cmd_set_hash_input_set_cmd,
12398 (void *)&cmd_set_hash_input_set_port_id,
12399 (void *)&cmd_set_hash_input_set_flow_type,
12400 (void *)&cmd_set_hash_input_set_field,
12401 (void *)&cmd_set_hash_input_set_select,
12406 /* Set flow director input set */
12407 struct cmd_set_fdir_input_set_result {
12408 cmdline_fixed_string_t set_fdir_input_set;
12410 cmdline_fixed_string_t flow_type;
12411 cmdline_fixed_string_t inset_field;
12412 cmdline_fixed_string_t select;
12416 cmd_set_fdir_input_set_parsed(void *parsed_result,
12417 __rte_unused struct cmdline *cl,
12418 __rte_unused void *data)
12420 struct cmd_set_fdir_input_set_result *res = parsed_result;
12421 struct rte_eth_fdir_filter_info info;
12423 memset(&info, 0, sizeof(info));
12424 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12425 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12426 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12427 info.info.input_set_conf.inset_size = 1;
12428 if (!strcmp(res->select, "select"))
12429 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12430 else if (!strcmp(res->select, "add"))
12431 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12432 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12433 RTE_ETH_FILTER_SET, &info);
12436 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12437 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12438 set_fdir_input_set, "set_fdir_input_set");
12439 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12440 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12442 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12443 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12445 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12446 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12447 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12448 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12450 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12451 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12452 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12453 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12454 "sctp-veri-tag#none");
12455 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12456 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12457 select, "select#add");
12459 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12460 .f = cmd_set_fdir_input_set_parsed,
12462 .help_str = "set_fdir_input_set <port_id> "
12463 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12464 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12465 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12466 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12467 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12468 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12469 "sctp-veri-tag|none select|add",
12471 (void *)&cmd_set_fdir_input_set_cmd,
12472 (void *)&cmd_set_fdir_input_set_port_id,
12473 (void *)&cmd_set_fdir_input_set_flow_type,
12474 (void *)&cmd_set_fdir_input_set_field,
12475 (void *)&cmd_set_fdir_input_set_select,
12480 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12481 struct cmd_mcast_addr_result {
12482 cmdline_fixed_string_t mcast_addr_cmd;
12483 cmdline_fixed_string_t what;
12485 struct rte_ether_addr mc_addr;
12488 static void cmd_mcast_addr_parsed(void *parsed_result,
12489 __attribute__((unused)) struct cmdline *cl,
12490 __attribute__((unused)) void *data)
12492 struct cmd_mcast_addr_result *res = parsed_result;
12494 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12495 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12496 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12497 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12498 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12501 if (strcmp(res->what, "add") == 0)
12502 mcast_addr_add(res->port_num, &res->mc_addr);
12504 mcast_addr_remove(res->port_num, &res->mc_addr);
12507 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12508 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12509 mcast_addr_cmd, "mcast_addr");
12510 cmdline_parse_token_string_t cmd_mcast_addr_what =
12511 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12513 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12514 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12515 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12516 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12518 cmdline_parse_inst_t cmd_mcast_addr = {
12519 .f = cmd_mcast_addr_parsed,
12521 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12522 "Add/Remove multicast MAC address on port_id",
12524 (void *)&cmd_mcast_addr_cmd,
12525 (void *)&cmd_mcast_addr_what,
12526 (void *)&cmd_mcast_addr_portnum,
12527 (void *)&cmd_mcast_addr_addr,
12532 /* l2 tunnel config
12533 * only support E-tag now.
12536 /* Ether type config */
12537 struct cmd_config_l2_tunnel_eth_type_result {
12538 cmdline_fixed_string_t port;
12539 cmdline_fixed_string_t config;
12540 cmdline_fixed_string_t all;
12542 cmdline_fixed_string_t l2_tunnel;
12543 cmdline_fixed_string_t l2_tunnel_type;
12544 cmdline_fixed_string_t eth_type;
12545 uint16_t eth_type_val;
12548 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12549 TOKEN_STRING_INITIALIZER
12550 (struct cmd_config_l2_tunnel_eth_type_result,
12552 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12553 TOKEN_STRING_INITIALIZER
12554 (struct cmd_config_l2_tunnel_eth_type_result,
12556 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12557 TOKEN_STRING_INITIALIZER
12558 (struct cmd_config_l2_tunnel_eth_type_result,
12560 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12561 TOKEN_NUM_INITIALIZER
12562 (struct cmd_config_l2_tunnel_eth_type_result,
12564 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12565 TOKEN_STRING_INITIALIZER
12566 (struct cmd_config_l2_tunnel_eth_type_result,
12567 l2_tunnel, "l2-tunnel");
12568 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12569 TOKEN_STRING_INITIALIZER
12570 (struct cmd_config_l2_tunnel_eth_type_result,
12571 l2_tunnel_type, "E-tag");
12572 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12573 TOKEN_STRING_INITIALIZER
12574 (struct cmd_config_l2_tunnel_eth_type_result,
12575 eth_type, "ether-type");
12576 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12577 TOKEN_NUM_INITIALIZER
12578 (struct cmd_config_l2_tunnel_eth_type_result,
12579 eth_type_val, UINT16);
12581 static enum rte_eth_tunnel_type
12582 str2fdir_l2_tunnel_type(char *string)
12586 static const struct {
12588 enum rte_eth_tunnel_type type;
12589 } l2_tunnel_type_str[] = {
12590 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12593 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12594 if (!strcmp(l2_tunnel_type_str[i].str, string))
12595 return l2_tunnel_type_str[i].type;
12597 return RTE_TUNNEL_TYPE_NONE;
12600 /* ether type config for all ports */
12602 cmd_config_l2_tunnel_eth_type_all_parsed
12603 (void *parsed_result,
12604 __attribute__((unused)) struct cmdline *cl,
12605 __attribute__((unused)) void *data)
12607 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12608 struct rte_eth_l2_tunnel_conf entry;
12611 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12612 entry.ether_type = res->eth_type_val;
12614 RTE_ETH_FOREACH_DEV(pid) {
12615 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12619 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12620 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12622 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12624 (void *)&cmd_config_l2_tunnel_eth_type_port,
12625 (void *)&cmd_config_l2_tunnel_eth_type_config,
12626 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12627 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12628 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12629 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12630 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12635 /* ether type config for a specific port */
12637 cmd_config_l2_tunnel_eth_type_specific_parsed(
12638 void *parsed_result,
12639 __attribute__((unused)) struct cmdline *cl,
12640 __attribute__((unused)) void *data)
12642 struct cmd_config_l2_tunnel_eth_type_result *res =
12644 struct rte_eth_l2_tunnel_conf entry;
12646 if (port_id_is_invalid(res->id, ENABLED_WARN))
12649 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12650 entry.ether_type = res->eth_type_val;
12652 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12655 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12656 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12658 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12660 (void *)&cmd_config_l2_tunnel_eth_type_port,
12661 (void *)&cmd_config_l2_tunnel_eth_type_config,
12662 (void *)&cmd_config_l2_tunnel_eth_type_id,
12663 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12664 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12665 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12666 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12671 /* Enable/disable l2 tunnel */
12672 struct cmd_config_l2_tunnel_en_dis_result {
12673 cmdline_fixed_string_t port;
12674 cmdline_fixed_string_t config;
12675 cmdline_fixed_string_t all;
12677 cmdline_fixed_string_t l2_tunnel;
12678 cmdline_fixed_string_t l2_tunnel_type;
12679 cmdline_fixed_string_t en_dis;
12682 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12683 TOKEN_STRING_INITIALIZER
12684 (struct cmd_config_l2_tunnel_en_dis_result,
12686 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12687 TOKEN_STRING_INITIALIZER
12688 (struct cmd_config_l2_tunnel_en_dis_result,
12690 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12691 TOKEN_STRING_INITIALIZER
12692 (struct cmd_config_l2_tunnel_en_dis_result,
12694 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12695 TOKEN_NUM_INITIALIZER
12696 (struct cmd_config_l2_tunnel_en_dis_result,
12698 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12699 TOKEN_STRING_INITIALIZER
12700 (struct cmd_config_l2_tunnel_en_dis_result,
12701 l2_tunnel, "l2-tunnel");
12702 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12703 TOKEN_STRING_INITIALIZER
12704 (struct cmd_config_l2_tunnel_en_dis_result,
12705 l2_tunnel_type, "E-tag");
12706 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12707 TOKEN_STRING_INITIALIZER
12708 (struct cmd_config_l2_tunnel_en_dis_result,
12709 en_dis, "enable#disable");
12711 /* enable/disable l2 tunnel for all ports */
12713 cmd_config_l2_tunnel_en_dis_all_parsed(
12714 void *parsed_result,
12715 __attribute__((unused)) struct cmdline *cl,
12716 __attribute__((unused)) void *data)
12718 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12719 struct rte_eth_l2_tunnel_conf entry;
12723 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12725 if (!strcmp("enable", res->en_dis))
12730 RTE_ETH_FOREACH_DEV(pid) {
12731 rte_eth_dev_l2_tunnel_offload_set(pid,
12733 ETH_L2_TUNNEL_ENABLE_MASK,
12738 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12739 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12741 .help_str = "port config all l2-tunnel E-tag enable|disable",
12743 (void *)&cmd_config_l2_tunnel_en_dis_port,
12744 (void *)&cmd_config_l2_tunnel_en_dis_config,
12745 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12746 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12747 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12748 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12753 /* enable/disable l2 tunnel for a port */
12755 cmd_config_l2_tunnel_en_dis_specific_parsed(
12756 void *parsed_result,
12757 __attribute__((unused)) struct cmdline *cl,
12758 __attribute__((unused)) void *data)
12760 struct cmd_config_l2_tunnel_en_dis_result *res =
12762 struct rte_eth_l2_tunnel_conf entry;
12764 if (port_id_is_invalid(res->id, ENABLED_WARN))
12767 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12769 if (!strcmp("enable", res->en_dis))
12770 rte_eth_dev_l2_tunnel_offload_set(res->id,
12772 ETH_L2_TUNNEL_ENABLE_MASK,
12775 rte_eth_dev_l2_tunnel_offload_set(res->id,
12777 ETH_L2_TUNNEL_ENABLE_MASK,
12781 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12782 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12784 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12786 (void *)&cmd_config_l2_tunnel_en_dis_port,
12787 (void *)&cmd_config_l2_tunnel_en_dis_config,
12788 (void *)&cmd_config_l2_tunnel_en_dis_id,
12789 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12790 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12791 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12796 /* E-tag configuration */
12798 /* Common result structure for all E-tag configuration */
12799 struct cmd_config_e_tag_result {
12800 cmdline_fixed_string_t e_tag;
12801 cmdline_fixed_string_t set;
12802 cmdline_fixed_string_t insertion;
12803 cmdline_fixed_string_t stripping;
12804 cmdline_fixed_string_t forwarding;
12805 cmdline_fixed_string_t filter;
12806 cmdline_fixed_string_t add;
12807 cmdline_fixed_string_t del;
12808 cmdline_fixed_string_t on;
12809 cmdline_fixed_string_t off;
12810 cmdline_fixed_string_t on_off;
12811 cmdline_fixed_string_t port_tag_id;
12812 uint32_t port_tag_id_val;
12813 cmdline_fixed_string_t e_tag_id;
12814 uint16_t e_tag_id_val;
12815 cmdline_fixed_string_t dst_pool;
12816 uint8_t dst_pool_val;
12817 cmdline_fixed_string_t port;
12819 cmdline_fixed_string_t vf;
12823 /* Common CLI fields for all E-tag configuration */
12824 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12825 TOKEN_STRING_INITIALIZER
12826 (struct cmd_config_e_tag_result,
12828 cmdline_parse_token_string_t cmd_config_e_tag_set =
12829 TOKEN_STRING_INITIALIZER
12830 (struct cmd_config_e_tag_result,
12832 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12833 TOKEN_STRING_INITIALIZER
12834 (struct cmd_config_e_tag_result,
12835 insertion, "insertion");
12836 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12837 TOKEN_STRING_INITIALIZER
12838 (struct cmd_config_e_tag_result,
12839 stripping, "stripping");
12840 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12841 TOKEN_STRING_INITIALIZER
12842 (struct cmd_config_e_tag_result,
12843 forwarding, "forwarding");
12844 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12845 TOKEN_STRING_INITIALIZER
12846 (struct cmd_config_e_tag_result,
12848 cmdline_parse_token_string_t cmd_config_e_tag_add =
12849 TOKEN_STRING_INITIALIZER
12850 (struct cmd_config_e_tag_result,
12852 cmdline_parse_token_string_t cmd_config_e_tag_del =
12853 TOKEN_STRING_INITIALIZER
12854 (struct cmd_config_e_tag_result,
12856 cmdline_parse_token_string_t cmd_config_e_tag_on =
12857 TOKEN_STRING_INITIALIZER
12858 (struct cmd_config_e_tag_result,
12860 cmdline_parse_token_string_t cmd_config_e_tag_off =
12861 TOKEN_STRING_INITIALIZER
12862 (struct cmd_config_e_tag_result,
12864 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12865 TOKEN_STRING_INITIALIZER
12866 (struct cmd_config_e_tag_result,
12868 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12869 TOKEN_STRING_INITIALIZER
12870 (struct cmd_config_e_tag_result,
12871 port_tag_id, "port-tag-id");
12872 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12873 TOKEN_NUM_INITIALIZER
12874 (struct cmd_config_e_tag_result,
12875 port_tag_id_val, UINT32);
12876 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12877 TOKEN_STRING_INITIALIZER
12878 (struct cmd_config_e_tag_result,
12879 e_tag_id, "e-tag-id");
12880 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12881 TOKEN_NUM_INITIALIZER
12882 (struct cmd_config_e_tag_result,
12883 e_tag_id_val, UINT16);
12884 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12885 TOKEN_STRING_INITIALIZER
12886 (struct cmd_config_e_tag_result,
12887 dst_pool, "dst-pool");
12888 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12889 TOKEN_NUM_INITIALIZER
12890 (struct cmd_config_e_tag_result,
12891 dst_pool_val, UINT8);
12892 cmdline_parse_token_string_t cmd_config_e_tag_port =
12893 TOKEN_STRING_INITIALIZER
12894 (struct cmd_config_e_tag_result,
12896 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12897 TOKEN_NUM_INITIALIZER
12898 (struct cmd_config_e_tag_result,
12900 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12901 TOKEN_STRING_INITIALIZER
12902 (struct cmd_config_e_tag_result,
12904 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12905 TOKEN_NUM_INITIALIZER
12906 (struct cmd_config_e_tag_result,
12909 /* E-tag insertion configuration */
12911 cmd_config_e_tag_insertion_en_parsed(
12912 void *parsed_result,
12913 __attribute__((unused)) struct cmdline *cl,
12914 __attribute__((unused)) void *data)
12916 struct cmd_config_e_tag_result *res =
12918 struct rte_eth_l2_tunnel_conf entry;
12920 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12923 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12924 entry.tunnel_id = res->port_tag_id_val;
12925 entry.vf_id = res->vf_id;
12926 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12928 ETH_L2_TUNNEL_INSERTION_MASK,
12933 cmd_config_e_tag_insertion_dis_parsed(
12934 void *parsed_result,
12935 __attribute__((unused)) struct cmdline *cl,
12936 __attribute__((unused)) void *data)
12938 struct cmd_config_e_tag_result *res =
12940 struct rte_eth_l2_tunnel_conf entry;
12942 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12945 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12946 entry.vf_id = res->vf_id;
12948 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12950 ETH_L2_TUNNEL_INSERTION_MASK,
12954 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12955 .f = cmd_config_e_tag_insertion_en_parsed,
12957 .help_str = "E-tag ... : E-tag insertion enable",
12959 (void *)&cmd_config_e_tag_e_tag,
12960 (void *)&cmd_config_e_tag_set,
12961 (void *)&cmd_config_e_tag_insertion,
12962 (void *)&cmd_config_e_tag_on,
12963 (void *)&cmd_config_e_tag_port_tag_id,
12964 (void *)&cmd_config_e_tag_port_tag_id_val,
12965 (void *)&cmd_config_e_tag_port,
12966 (void *)&cmd_config_e_tag_port_id,
12967 (void *)&cmd_config_e_tag_vf,
12968 (void *)&cmd_config_e_tag_vf_id,
12973 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12974 .f = cmd_config_e_tag_insertion_dis_parsed,
12976 .help_str = "E-tag ... : E-tag insertion disable",
12978 (void *)&cmd_config_e_tag_e_tag,
12979 (void *)&cmd_config_e_tag_set,
12980 (void *)&cmd_config_e_tag_insertion,
12981 (void *)&cmd_config_e_tag_off,
12982 (void *)&cmd_config_e_tag_port,
12983 (void *)&cmd_config_e_tag_port_id,
12984 (void *)&cmd_config_e_tag_vf,
12985 (void *)&cmd_config_e_tag_vf_id,
12990 /* E-tag stripping configuration */
12992 cmd_config_e_tag_stripping_parsed(
12993 void *parsed_result,
12994 __attribute__((unused)) struct cmdline *cl,
12995 __attribute__((unused)) void *data)
12997 struct cmd_config_e_tag_result *res =
12999 struct rte_eth_l2_tunnel_conf entry;
13001 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13004 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13006 if (!strcmp(res->on_off, "on"))
13007 rte_eth_dev_l2_tunnel_offload_set
13010 ETH_L2_TUNNEL_STRIPPING_MASK,
13013 rte_eth_dev_l2_tunnel_offload_set
13016 ETH_L2_TUNNEL_STRIPPING_MASK,
13020 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13021 .f = cmd_config_e_tag_stripping_parsed,
13023 .help_str = "E-tag ... : E-tag stripping enable/disable",
13025 (void *)&cmd_config_e_tag_e_tag,
13026 (void *)&cmd_config_e_tag_set,
13027 (void *)&cmd_config_e_tag_stripping,
13028 (void *)&cmd_config_e_tag_on_off,
13029 (void *)&cmd_config_e_tag_port,
13030 (void *)&cmd_config_e_tag_port_id,
13035 /* E-tag forwarding configuration */
13037 cmd_config_e_tag_forwarding_parsed(
13038 void *parsed_result,
13039 __attribute__((unused)) struct cmdline *cl,
13040 __attribute__((unused)) void *data)
13042 struct cmd_config_e_tag_result *res = parsed_result;
13043 struct rte_eth_l2_tunnel_conf entry;
13045 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13048 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13050 if (!strcmp(res->on_off, "on"))
13051 rte_eth_dev_l2_tunnel_offload_set
13054 ETH_L2_TUNNEL_FORWARDING_MASK,
13057 rte_eth_dev_l2_tunnel_offload_set
13060 ETH_L2_TUNNEL_FORWARDING_MASK,
13064 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13065 .f = cmd_config_e_tag_forwarding_parsed,
13067 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13069 (void *)&cmd_config_e_tag_e_tag,
13070 (void *)&cmd_config_e_tag_set,
13071 (void *)&cmd_config_e_tag_forwarding,
13072 (void *)&cmd_config_e_tag_on_off,
13073 (void *)&cmd_config_e_tag_port,
13074 (void *)&cmd_config_e_tag_port_id,
13079 /* E-tag filter configuration */
13081 cmd_config_e_tag_filter_add_parsed(
13082 void *parsed_result,
13083 __attribute__((unused)) struct cmdline *cl,
13084 __attribute__((unused)) void *data)
13086 struct cmd_config_e_tag_result *res = parsed_result;
13087 struct rte_eth_l2_tunnel_conf entry;
13090 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13093 if (res->e_tag_id_val > 0x3fff) {
13094 printf("e-tag-id must be equal or less than 0x3fff.\n");
13098 ret = rte_eth_dev_filter_supported(res->port_id,
13099 RTE_ETH_FILTER_L2_TUNNEL);
13101 printf("E-tag filter is not supported on port %u.\n",
13106 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13107 entry.tunnel_id = res->e_tag_id_val;
13108 entry.pool = res->dst_pool_val;
13110 ret = rte_eth_dev_filter_ctrl(res->port_id,
13111 RTE_ETH_FILTER_L2_TUNNEL,
13112 RTE_ETH_FILTER_ADD,
13115 printf("E-tag filter programming error: (%s)\n",
13119 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13120 .f = cmd_config_e_tag_filter_add_parsed,
13122 .help_str = "E-tag ... : E-tag filter add",
13124 (void *)&cmd_config_e_tag_e_tag,
13125 (void *)&cmd_config_e_tag_set,
13126 (void *)&cmd_config_e_tag_filter,
13127 (void *)&cmd_config_e_tag_add,
13128 (void *)&cmd_config_e_tag_e_tag_id,
13129 (void *)&cmd_config_e_tag_e_tag_id_val,
13130 (void *)&cmd_config_e_tag_dst_pool,
13131 (void *)&cmd_config_e_tag_dst_pool_val,
13132 (void *)&cmd_config_e_tag_port,
13133 (void *)&cmd_config_e_tag_port_id,
13139 cmd_config_e_tag_filter_del_parsed(
13140 void *parsed_result,
13141 __attribute__((unused)) struct cmdline *cl,
13142 __attribute__((unused)) void *data)
13144 struct cmd_config_e_tag_result *res = parsed_result;
13145 struct rte_eth_l2_tunnel_conf entry;
13148 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13151 if (res->e_tag_id_val > 0x3fff) {
13152 printf("e-tag-id must be less than 0x3fff.\n");
13156 ret = rte_eth_dev_filter_supported(res->port_id,
13157 RTE_ETH_FILTER_L2_TUNNEL);
13159 printf("E-tag filter is not supported on port %u.\n",
13164 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13165 entry.tunnel_id = res->e_tag_id_val;
13167 ret = rte_eth_dev_filter_ctrl(res->port_id,
13168 RTE_ETH_FILTER_L2_TUNNEL,
13169 RTE_ETH_FILTER_DELETE,
13172 printf("E-tag filter programming error: (%s)\n",
13176 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13177 .f = cmd_config_e_tag_filter_del_parsed,
13179 .help_str = "E-tag ... : E-tag filter delete",
13181 (void *)&cmd_config_e_tag_e_tag,
13182 (void *)&cmd_config_e_tag_set,
13183 (void *)&cmd_config_e_tag_filter,
13184 (void *)&cmd_config_e_tag_del,
13185 (void *)&cmd_config_e_tag_e_tag_id,
13186 (void *)&cmd_config_e_tag_e_tag_id_val,
13187 (void *)&cmd_config_e_tag_port,
13188 (void *)&cmd_config_e_tag_port_id,
13193 /* vf vlan anti spoof configuration */
13195 /* Common result structure for vf vlan anti spoof */
13196 struct cmd_vf_vlan_anti_spoof_result {
13197 cmdline_fixed_string_t set;
13198 cmdline_fixed_string_t vf;
13199 cmdline_fixed_string_t vlan;
13200 cmdline_fixed_string_t antispoof;
13203 cmdline_fixed_string_t on_off;
13206 /* Common CLI fields for vf vlan anti spoof enable disable */
13207 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13208 TOKEN_STRING_INITIALIZER
13209 (struct cmd_vf_vlan_anti_spoof_result,
13211 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13212 TOKEN_STRING_INITIALIZER
13213 (struct cmd_vf_vlan_anti_spoof_result,
13215 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13216 TOKEN_STRING_INITIALIZER
13217 (struct cmd_vf_vlan_anti_spoof_result,
13219 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13220 TOKEN_STRING_INITIALIZER
13221 (struct cmd_vf_vlan_anti_spoof_result,
13222 antispoof, "antispoof");
13223 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13224 TOKEN_NUM_INITIALIZER
13225 (struct cmd_vf_vlan_anti_spoof_result,
13227 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13228 TOKEN_NUM_INITIALIZER
13229 (struct cmd_vf_vlan_anti_spoof_result,
13231 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13232 TOKEN_STRING_INITIALIZER
13233 (struct cmd_vf_vlan_anti_spoof_result,
13237 cmd_set_vf_vlan_anti_spoof_parsed(
13238 void *parsed_result,
13239 __attribute__((unused)) struct cmdline *cl,
13240 __attribute__((unused)) void *data)
13242 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13243 int ret = -ENOTSUP;
13245 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13247 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13250 #ifdef RTE_LIBRTE_IXGBE_PMD
13251 if (ret == -ENOTSUP)
13252 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13253 res->vf_id, is_on);
13255 #ifdef RTE_LIBRTE_I40E_PMD
13256 if (ret == -ENOTSUP)
13257 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13258 res->vf_id, is_on);
13260 #ifdef RTE_LIBRTE_BNXT_PMD
13261 if (ret == -ENOTSUP)
13262 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13263 res->vf_id, is_on);
13270 printf("invalid vf_id %d\n", res->vf_id);
13273 printf("invalid port_id %d\n", res->port_id);
13276 printf("function not implemented\n");
13279 printf("programming error: (%s)\n", strerror(-ret));
13283 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13284 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13286 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13288 (void *)&cmd_vf_vlan_anti_spoof_set,
13289 (void *)&cmd_vf_vlan_anti_spoof_vf,
13290 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13291 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13292 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13293 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13294 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13299 /* vf mac anti spoof configuration */
13301 /* Common result structure for vf mac anti spoof */
13302 struct cmd_vf_mac_anti_spoof_result {
13303 cmdline_fixed_string_t set;
13304 cmdline_fixed_string_t vf;
13305 cmdline_fixed_string_t mac;
13306 cmdline_fixed_string_t antispoof;
13309 cmdline_fixed_string_t on_off;
13312 /* Common CLI fields for vf mac anti spoof enable disable */
13313 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13314 TOKEN_STRING_INITIALIZER
13315 (struct cmd_vf_mac_anti_spoof_result,
13317 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13318 TOKEN_STRING_INITIALIZER
13319 (struct cmd_vf_mac_anti_spoof_result,
13321 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13322 TOKEN_STRING_INITIALIZER
13323 (struct cmd_vf_mac_anti_spoof_result,
13325 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13326 TOKEN_STRING_INITIALIZER
13327 (struct cmd_vf_mac_anti_spoof_result,
13328 antispoof, "antispoof");
13329 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13330 TOKEN_NUM_INITIALIZER
13331 (struct cmd_vf_mac_anti_spoof_result,
13333 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13334 TOKEN_NUM_INITIALIZER
13335 (struct cmd_vf_mac_anti_spoof_result,
13337 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13338 TOKEN_STRING_INITIALIZER
13339 (struct cmd_vf_mac_anti_spoof_result,
13343 cmd_set_vf_mac_anti_spoof_parsed(
13344 void *parsed_result,
13345 __attribute__((unused)) struct cmdline *cl,
13346 __attribute__((unused)) void *data)
13348 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13349 int ret = -ENOTSUP;
13351 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13353 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13356 #ifdef RTE_LIBRTE_IXGBE_PMD
13357 if (ret == -ENOTSUP)
13358 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13359 res->vf_id, is_on);
13361 #ifdef RTE_LIBRTE_I40E_PMD
13362 if (ret == -ENOTSUP)
13363 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13364 res->vf_id, is_on);
13366 #ifdef RTE_LIBRTE_BNXT_PMD
13367 if (ret == -ENOTSUP)
13368 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13369 res->vf_id, is_on);
13376 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13379 printf("invalid port_id %d\n", res->port_id);
13382 printf("function not implemented\n");
13385 printf("programming error: (%s)\n", strerror(-ret));
13389 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13390 .f = cmd_set_vf_mac_anti_spoof_parsed,
13392 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13394 (void *)&cmd_vf_mac_anti_spoof_set,
13395 (void *)&cmd_vf_mac_anti_spoof_vf,
13396 (void *)&cmd_vf_mac_anti_spoof_mac,
13397 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13398 (void *)&cmd_vf_mac_anti_spoof_port_id,
13399 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13400 (void *)&cmd_vf_mac_anti_spoof_on_off,
13405 /* vf vlan strip queue configuration */
13407 /* Common result structure for vf mac anti spoof */
13408 struct cmd_vf_vlan_stripq_result {
13409 cmdline_fixed_string_t set;
13410 cmdline_fixed_string_t vf;
13411 cmdline_fixed_string_t vlan;
13412 cmdline_fixed_string_t stripq;
13415 cmdline_fixed_string_t on_off;
13418 /* Common CLI fields for vf vlan strip enable disable */
13419 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13420 TOKEN_STRING_INITIALIZER
13421 (struct cmd_vf_vlan_stripq_result,
13423 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13424 TOKEN_STRING_INITIALIZER
13425 (struct cmd_vf_vlan_stripq_result,
13427 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13428 TOKEN_STRING_INITIALIZER
13429 (struct cmd_vf_vlan_stripq_result,
13431 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13432 TOKEN_STRING_INITIALIZER
13433 (struct cmd_vf_vlan_stripq_result,
13435 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13436 TOKEN_NUM_INITIALIZER
13437 (struct cmd_vf_vlan_stripq_result,
13439 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13440 TOKEN_NUM_INITIALIZER
13441 (struct cmd_vf_vlan_stripq_result,
13443 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13444 TOKEN_STRING_INITIALIZER
13445 (struct cmd_vf_vlan_stripq_result,
13449 cmd_set_vf_vlan_stripq_parsed(
13450 void *parsed_result,
13451 __attribute__((unused)) struct cmdline *cl,
13452 __attribute__((unused)) void *data)
13454 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13455 int ret = -ENOTSUP;
13457 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13459 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13462 #ifdef RTE_LIBRTE_IXGBE_PMD
13463 if (ret == -ENOTSUP)
13464 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13465 res->vf_id, is_on);
13467 #ifdef RTE_LIBRTE_I40E_PMD
13468 if (ret == -ENOTSUP)
13469 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13470 res->vf_id, is_on);
13472 #ifdef RTE_LIBRTE_BNXT_PMD
13473 if (ret == -ENOTSUP)
13474 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13475 res->vf_id, is_on);
13482 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13485 printf("invalid port_id %d\n", res->port_id);
13488 printf("function not implemented\n");
13491 printf("programming error: (%s)\n", strerror(-ret));
13495 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13496 .f = cmd_set_vf_vlan_stripq_parsed,
13498 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13500 (void *)&cmd_vf_vlan_stripq_set,
13501 (void *)&cmd_vf_vlan_stripq_vf,
13502 (void *)&cmd_vf_vlan_stripq_vlan,
13503 (void *)&cmd_vf_vlan_stripq_stripq,
13504 (void *)&cmd_vf_vlan_stripq_port_id,
13505 (void *)&cmd_vf_vlan_stripq_vf_id,
13506 (void *)&cmd_vf_vlan_stripq_on_off,
13511 /* vf vlan insert configuration */
13513 /* Common result structure for vf vlan insert */
13514 struct cmd_vf_vlan_insert_result {
13515 cmdline_fixed_string_t set;
13516 cmdline_fixed_string_t vf;
13517 cmdline_fixed_string_t vlan;
13518 cmdline_fixed_string_t insert;
13524 /* Common CLI fields for vf vlan insert enable disable */
13525 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13526 TOKEN_STRING_INITIALIZER
13527 (struct cmd_vf_vlan_insert_result,
13529 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13530 TOKEN_STRING_INITIALIZER
13531 (struct cmd_vf_vlan_insert_result,
13533 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13534 TOKEN_STRING_INITIALIZER
13535 (struct cmd_vf_vlan_insert_result,
13537 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13538 TOKEN_STRING_INITIALIZER
13539 (struct cmd_vf_vlan_insert_result,
13541 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13542 TOKEN_NUM_INITIALIZER
13543 (struct cmd_vf_vlan_insert_result,
13545 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13546 TOKEN_NUM_INITIALIZER
13547 (struct cmd_vf_vlan_insert_result,
13549 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13550 TOKEN_NUM_INITIALIZER
13551 (struct cmd_vf_vlan_insert_result,
13555 cmd_set_vf_vlan_insert_parsed(
13556 void *parsed_result,
13557 __attribute__((unused)) struct cmdline *cl,
13558 __attribute__((unused)) void *data)
13560 struct cmd_vf_vlan_insert_result *res = parsed_result;
13561 int ret = -ENOTSUP;
13563 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13566 #ifdef RTE_LIBRTE_IXGBE_PMD
13567 if (ret == -ENOTSUP)
13568 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13571 #ifdef RTE_LIBRTE_I40E_PMD
13572 if (ret == -ENOTSUP)
13573 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13576 #ifdef RTE_LIBRTE_BNXT_PMD
13577 if (ret == -ENOTSUP)
13578 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13586 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13589 printf("invalid port_id %d\n", res->port_id);
13592 printf("function not implemented\n");
13595 printf("programming error: (%s)\n", strerror(-ret));
13599 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13600 .f = cmd_set_vf_vlan_insert_parsed,
13602 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13604 (void *)&cmd_vf_vlan_insert_set,
13605 (void *)&cmd_vf_vlan_insert_vf,
13606 (void *)&cmd_vf_vlan_insert_vlan,
13607 (void *)&cmd_vf_vlan_insert_insert,
13608 (void *)&cmd_vf_vlan_insert_port_id,
13609 (void *)&cmd_vf_vlan_insert_vf_id,
13610 (void *)&cmd_vf_vlan_insert_vlan_id,
13615 /* tx loopback configuration */
13617 /* Common result structure for tx loopback */
13618 struct cmd_tx_loopback_result {
13619 cmdline_fixed_string_t set;
13620 cmdline_fixed_string_t tx;
13621 cmdline_fixed_string_t loopback;
13623 cmdline_fixed_string_t on_off;
13626 /* Common CLI fields for tx loopback enable disable */
13627 cmdline_parse_token_string_t cmd_tx_loopback_set =
13628 TOKEN_STRING_INITIALIZER
13629 (struct cmd_tx_loopback_result,
13631 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13632 TOKEN_STRING_INITIALIZER
13633 (struct cmd_tx_loopback_result,
13635 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13636 TOKEN_STRING_INITIALIZER
13637 (struct cmd_tx_loopback_result,
13638 loopback, "loopback");
13639 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13640 TOKEN_NUM_INITIALIZER
13641 (struct cmd_tx_loopback_result,
13643 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13644 TOKEN_STRING_INITIALIZER
13645 (struct cmd_tx_loopback_result,
13649 cmd_set_tx_loopback_parsed(
13650 void *parsed_result,
13651 __attribute__((unused)) struct cmdline *cl,
13652 __attribute__((unused)) void *data)
13654 struct cmd_tx_loopback_result *res = parsed_result;
13655 int ret = -ENOTSUP;
13657 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13659 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13662 #ifdef RTE_LIBRTE_IXGBE_PMD
13663 if (ret == -ENOTSUP)
13664 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13666 #ifdef RTE_LIBRTE_I40E_PMD
13667 if (ret == -ENOTSUP)
13668 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13670 #ifdef RTE_LIBRTE_BNXT_PMD
13671 if (ret == -ENOTSUP)
13672 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13674 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13675 if (ret == -ENOTSUP)
13676 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13683 printf("invalid is_on %d\n", is_on);
13686 printf("invalid port_id %d\n", res->port_id);
13689 printf("function not implemented\n");
13692 printf("programming error: (%s)\n", strerror(-ret));
13696 cmdline_parse_inst_t cmd_set_tx_loopback = {
13697 .f = cmd_set_tx_loopback_parsed,
13699 .help_str = "set tx loopback <port_id> on|off",
13701 (void *)&cmd_tx_loopback_set,
13702 (void *)&cmd_tx_loopback_tx,
13703 (void *)&cmd_tx_loopback_loopback,
13704 (void *)&cmd_tx_loopback_port_id,
13705 (void *)&cmd_tx_loopback_on_off,
13710 /* all queues drop enable configuration */
13712 /* Common result structure for all queues drop enable */
13713 struct cmd_all_queues_drop_en_result {
13714 cmdline_fixed_string_t set;
13715 cmdline_fixed_string_t all;
13716 cmdline_fixed_string_t queues;
13717 cmdline_fixed_string_t drop;
13719 cmdline_fixed_string_t on_off;
13722 /* Common CLI fields for tx loopback enable disable */
13723 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13724 TOKEN_STRING_INITIALIZER
13725 (struct cmd_all_queues_drop_en_result,
13727 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13728 TOKEN_STRING_INITIALIZER
13729 (struct cmd_all_queues_drop_en_result,
13731 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13732 TOKEN_STRING_INITIALIZER
13733 (struct cmd_all_queues_drop_en_result,
13735 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13736 TOKEN_STRING_INITIALIZER
13737 (struct cmd_all_queues_drop_en_result,
13739 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13740 TOKEN_NUM_INITIALIZER
13741 (struct cmd_all_queues_drop_en_result,
13743 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13744 TOKEN_STRING_INITIALIZER
13745 (struct cmd_all_queues_drop_en_result,
13749 cmd_set_all_queues_drop_en_parsed(
13750 void *parsed_result,
13751 __attribute__((unused)) struct cmdline *cl,
13752 __attribute__((unused)) void *data)
13754 struct cmd_all_queues_drop_en_result *res = parsed_result;
13755 int ret = -ENOTSUP;
13756 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13758 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13761 #ifdef RTE_LIBRTE_IXGBE_PMD
13762 if (ret == -ENOTSUP)
13763 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13765 #ifdef RTE_LIBRTE_BNXT_PMD
13766 if (ret == -ENOTSUP)
13767 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13773 printf("invalid is_on %d\n", is_on);
13776 printf("invalid port_id %d\n", res->port_id);
13779 printf("function not implemented\n");
13782 printf("programming error: (%s)\n", strerror(-ret));
13786 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13787 .f = cmd_set_all_queues_drop_en_parsed,
13789 .help_str = "set all queues drop <port_id> on|off",
13791 (void *)&cmd_all_queues_drop_en_set,
13792 (void *)&cmd_all_queues_drop_en_all,
13793 (void *)&cmd_all_queues_drop_en_queues,
13794 (void *)&cmd_all_queues_drop_en_drop,
13795 (void *)&cmd_all_queues_drop_en_port_id,
13796 (void *)&cmd_all_queues_drop_en_on_off,
13801 /* vf split drop enable configuration */
13803 /* Common result structure for vf split drop enable */
13804 struct cmd_vf_split_drop_en_result {
13805 cmdline_fixed_string_t set;
13806 cmdline_fixed_string_t vf;
13807 cmdline_fixed_string_t split;
13808 cmdline_fixed_string_t drop;
13811 cmdline_fixed_string_t on_off;
13814 /* Common CLI fields for vf split drop enable disable */
13815 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13816 TOKEN_STRING_INITIALIZER
13817 (struct cmd_vf_split_drop_en_result,
13819 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13820 TOKEN_STRING_INITIALIZER
13821 (struct cmd_vf_split_drop_en_result,
13823 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13824 TOKEN_STRING_INITIALIZER
13825 (struct cmd_vf_split_drop_en_result,
13827 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13828 TOKEN_STRING_INITIALIZER
13829 (struct cmd_vf_split_drop_en_result,
13831 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13832 TOKEN_NUM_INITIALIZER
13833 (struct cmd_vf_split_drop_en_result,
13835 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13836 TOKEN_NUM_INITIALIZER
13837 (struct cmd_vf_split_drop_en_result,
13839 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13840 TOKEN_STRING_INITIALIZER
13841 (struct cmd_vf_split_drop_en_result,
13845 cmd_set_vf_split_drop_en_parsed(
13846 void *parsed_result,
13847 __attribute__((unused)) struct cmdline *cl,
13848 __attribute__((unused)) void *data)
13850 struct cmd_vf_split_drop_en_result *res = parsed_result;
13851 int ret = -ENOTSUP;
13852 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13854 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13857 #ifdef RTE_LIBRTE_IXGBE_PMD
13858 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13865 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13868 printf("invalid port_id %d\n", res->port_id);
13871 printf("not supported on port %d\n", res->port_id);
13874 printf("programming error: (%s)\n", strerror(-ret));
13878 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13879 .f = cmd_set_vf_split_drop_en_parsed,
13881 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13883 (void *)&cmd_vf_split_drop_en_set,
13884 (void *)&cmd_vf_split_drop_en_vf,
13885 (void *)&cmd_vf_split_drop_en_split,
13886 (void *)&cmd_vf_split_drop_en_drop,
13887 (void *)&cmd_vf_split_drop_en_port_id,
13888 (void *)&cmd_vf_split_drop_en_vf_id,
13889 (void *)&cmd_vf_split_drop_en_on_off,
13894 /* vf mac address configuration */
13896 /* Common result structure for vf mac address */
13897 struct cmd_set_vf_mac_addr_result {
13898 cmdline_fixed_string_t set;
13899 cmdline_fixed_string_t vf;
13900 cmdline_fixed_string_t mac;
13901 cmdline_fixed_string_t addr;
13904 struct rte_ether_addr mac_addr;
13908 /* Common CLI fields for vf split drop enable disable */
13909 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13910 TOKEN_STRING_INITIALIZER
13911 (struct cmd_set_vf_mac_addr_result,
13913 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13914 TOKEN_STRING_INITIALIZER
13915 (struct cmd_set_vf_mac_addr_result,
13917 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13918 TOKEN_STRING_INITIALIZER
13919 (struct cmd_set_vf_mac_addr_result,
13921 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13922 TOKEN_STRING_INITIALIZER
13923 (struct cmd_set_vf_mac_addr_result,
13925 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13926 TOKEN_NUM_INITIALIZER
13927 (struct cmd_set_vf_mac_addr_result,
13929 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13930 TOKEN_NUM_INITIALIZER
13931 (struct cmd_set_vf_mac_addr_result,
13933 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13934 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13938 cmd_set_vf_mac_addr_parsed(
13939 void *parsed_result,
13940 __attribute__((unused)) struct cmdline *cl,
13941 __attribute__((unused)) void *data)
13943 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13944 int ret = -ENOTSUP;
13946 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13949 #ifdef RTE_LIBRTE_IXGBE_PMD
13950 if (ret == -ENOTSUP)
13951 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13954 #ifdef RTE_LIBRTE_I40E_PMD
13955 if (ret == -ENOTSUP)
13956 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13959 #ifdef RTE_LIBRTE_BNXT_PMD
13960 if (ret == -ENOTSUP)
13961 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13969 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13972 printf("invalid port_id %d\n", res->port_id);
13975 printf("function not implemented\n");
13978 printf("programming error: (%s)\n", strerror(-ret));
13982 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13983 .f = cmd_set_vf_mac_addr_parsed,
13985 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13987 (void *)&cmd_set_vf_mac_addr_set,
13988 (void *)&cmd_set_vf_mac_addr_vf,
13989 (void *)&cmd_set_vf_mac_addr_mac,
13990 (void *)&cmd_set_vf_mac_addr_addr,
13991 (void *)&cmd_set_vf_mac_addr_port_id,
13992 (void *)&cmd_set_vf_mac_addr_vf_id,
13993 (void *)&cmd_set_vf_mac_addr_mac_addr,
13998 /* MACsec configuration */
14000 /* Common result structure for MACsec offload enable */
14001 struct cmd_macsec_offload_on_result {
14002 cmdline_fixed_string_t set;
14003 cmdline_fixed_string_t macsec;
14004 cmdline_fixed_string_t offload;
14006 cmdline_fixed_string_t on;
14007 cmdline_fixed_string_t encrypt;
14008 cmdline_fixed_string_t en_on_off;
14009 cmdline_fixed_string_t replay_protect;
14010 cmdline_fixed_string_t rp_on_off;
14013 /* Common CLI fields for MACsec offload disable */
14014 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14015 TOKEN_STRING_INITIALIZER
14016 (struct cmd_macsec_offload_on_result,
14018 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14019 TOKEN_STRING_INITIALIZER
14020 (struct cmd_macsec_offload_on_result,
14022 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14023 TOKEN_STRING_INITIALIZER
14024 (struct cmd_macsec_offload_on_result,
14025 offload, "offload");
14026 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14027 TOKEN_NUM_INITIALIZER
14028 (struct cmd_macsec_offload_on_result,
14030 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14031 TOKEN_STRING_INITIALIZER
14032 (struct cmd_macsec_offload_on_result,
14034 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14035 TOKEN_STRING_INITIALIZER
14036 (struct cmd_macsec_offload_on_result,
14037 encrypt, "encrypt");
14038 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14039 TOKEN_STRING_INITIALIZER
14040 (struct cmd_macsec_offload_on_result,
14041 en_on_off, "on#off");
14042 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14043 TOKEN_STRING_INITIALIZER
14044 (struct cmd_macsec_offload_on_result,
14045 replay_protect, "replay-protect");
14046 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14047 TOKEN_STRING_INITIALIZER
14048 (struct cmd_macsec_offload_on_result,
14049 rp_on_off, "on#off");
14052 cmd_set_macsec_offload_on_parsed(
14053 void *parsed_result,
14054 __attribute__((unused)) struct cmdline *cl,
14055 __attribute__((unused)) void *data)
14057 struct cmd_macsec_offload_on_result *res = parsed_result;
14058 int ret = -ENOTSUP;
14059 portid_t port_id = res->port_id;
14060 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14061 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14062 struct rte_eth_dev_info dev_info;
14064 if (port_id_is_invalid(port_id, ENABLED_WARN))
14066 if (!port_is_stopped(port_id)) {
14067 printf("Please stop port %d first\n", port_id);
14071 rte_eth_dev_info_get(port_id, &dev_info);
14072 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14073 #ifdef RTE_LIBRTE_IXGBE_PMD
14074 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14082 ports[port_id].dev_conf.txmode.offloads |=
14083 DEV_TX_OFFLOAD_MACSEC_INSERT;
14084 cmd_reconfig_device_queue(port_id, 1, 1);
14087 printf("invalid port_id %d\n", port_id);
14090 printf("not supported on port %d\n", port_id);
14093 printf("programming error: (%s)\n", strerror(-ret));
14097 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14098 .f = cmd_set_macsec_offload_on_parsed,
14100 .help_str = "set macsec offload <port_id> on "
14101 "encrypt on|off replay-protect on|off",
14103 (void *)&cmd_macsec_offload_on_set,
14104 (void *)&cmd_macsec_offload_on_macsec,
14105 (void *)&cmd_macsec_offload_on_offload,
14106 (void *)&cmd_macsec_offload_on_port_id,
14107 (void *)&cmd_macsec_offload_on_on,
14108 (void *)&cmd_macsec_offload_on_encrypt,
14109 (void *)&cmd_macsec_offload_on_en_on_off,
14110 (void *)&cmd_macsec_offload_on_replay_protect,
14111 (void *)&cmd_macsec_offload_on_rp_on_off,
14116 /* Common result structure for MACsec offload disable */
14117 struct cmd_macsec_offload_off_result {
14118 cmdline_fixed_string_t set;
14119 cmdline_fixed_string_t macsec;
14120 cmdline_fixed_string_t offload;
14122 cmdline_fixed_string_t off;
14125 /* Common CLI fields for MACsec offload disable */
14126 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14127 TOKEN_STRING_INITIALIZER
14128 (struct cmd_macsec_offload_off_result,
14130 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14131 TOKEN_STRING_INITIALIZER
14132 (struct cmd_macsec_offload_off_result,
14134 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14135 TOKEN_STRING_INITIALIZER
14136 (struct cmd_macsec_offload_off_result,
14137 offload, "offload");
14138 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14139 TOKEN_NUM_INITIALIZER
14140 (struct cmd_macsec_offload_off_result,
14142 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14143 TOKEN_STRING_INITIALIZER
14144 (struct cmd_macsec_offload_off_result,
14148 cmd_set_macsec_offload_off_parsed(
14149 void *parsed_result,
14150 __attribute__((unused)) struct cmdline *cl,
14151 __attribute__((unused)) void *data)
14153 struct cmd_macsec_offload_off_result *res = parsed_result;
14154 int ret = -ENOTSUP;
14155 struct rte_eth_dev_info dev_info;
14156 portid_t port_id = res->port_id;
14158 if (port_id_is_invalid(port_id, ENABLED_WARN))
14160 if (!port_is_stopped(port_id)) {
14161 printf("Please stop port %d first\n", port_id);
14165 rte_eth_dev_info_get(port_id, &dev_info);
14166 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14167 #ifdef RTE_LIBRTE_IXGBE_PMD
14168 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14173 ports[port_id].dev_conf.txmode.offloads &=
14174 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14175 cmd_reconfig_device_queue(port_id, 1, 1);
14178 printf("invalid port_id %d\n", port_id);
14181 printf("not supported on port %d\n", port_id);
14184 printf("programming error: (%s)\n", strerror(-ret));
14188 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14189 .f = cmd_set_macsec_offload_off_parsed,
14191 .help_str = "set macsec offload <port_id> off",
14193 (void *)&cmd_macsec_offload_off_set,
14194 (void *)&cmd_macsec_offload_off_macsec,
14195 (void *)&cmd_macsec_offload_off_offload,
14196 (void *)&cmd_macsec_offload_off_port_id,
14197 (void *)&cmd_macsec_offload_off_off,
14202 /* Common result structure for MACsec secure connection configure */
14203 struct cmd_macsec_sc_result {
14204 cmdline_fixed_string_t set;
14205 cmdline_fixed_string_t macsec;
14206 cmdline_fixed_string_t sc;
14207 cmdline_fixed_string_t tx_rx;
14209 struct rte_ether_addr mac;
14213 /* Common CLI fields for MACsec secure connection configure */
14214 cmdline_parse_token_string_t cmd_macsec_sc_set =
14215 TOKEN_STRING_INITIALIZER
14216 (struct cmd_macsec_sc_result,
14218 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14219 TOKEN_STRING_INITIALIZER
14220 (struct cmd_macsec_sc_result,
14222 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14223 TOKEN_STRING_INITIALIZER
14224 (struct cmd_macsec_sc_result,
14226 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14227 TOKEN_STRING_INITIALIZER
14228 (struct cmd_macsec_sc_result,
14230 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14231 TOKEN_NUM_INITIALIZER
14232 (struct cmd_macsec_sc_result,
14234 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14235 TOKEN_ETHERADDR_INITIALIZER
14236 (struct cmd_macsec_sc_result,
14238 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14239 TOKEN_NUM_INITIALIZER
14240 (struct cmd_macsec_sc_result,
14244 cmd_set_macsec_sc_parsed(
14245 void *parsed_result,
14246 __attribute__((unused)) struct cmdline *cl,
14247 __attribute__((unused)) void *data)
14249 struct cmd_macsec_sc_result *res = parsed_result;
14250 int ret = -ENOTSUP;
14251 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14253 #ifdef RTE_LIBRTE_IXGBE_PMD
14255 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14256 res->mac.addr_bytes) :
14257 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14258 res->mac.addr_bytes, res->pi);
14260 RTE_SET_USED(is_tx);
14266 printf("invalid port_id %d\n", res->port_id);
14269 printf("not supported on port %d\n", res->port_id);
14272 printf("programming error: (%s)\n", strerror(-ret));
14276 cmdline_parse_inst_t cmd_set_macsec_sc = {
14277 .f = cmd_set_macsec_sc_parsed,
14279 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14281 (void *)&cmd_macsec_sc_set,
14282 (void *)&cmd_macsec_sc_macsec,
14283 (void *)&cmd_macsec_sc_sc,
14284 (void *)&cmd_macsec_sc_tx_rx,
14285 (void *)&cmd_macsec_sc_port_id,
14286 (void *)&cmd_macsec_sc_mac,
14287 (void *)&cmd_macsec_sc_pi,
14292 /* Common result structure for MACsec secure connection configure */
14293 struct cmd_macsec_sa_result {
14294 cmdline_fixed_string_t set;
14295 cmdline_fixed_string_t macsec;
14296 cmdline_fixed_string_t sa;
14297 cmdline_fixed_string_t tx_rx;
14302 cmdline_fixed_string_t key;
14305 /* Common CLI fields for MACsec secure connection configure */
14306 cmdline_parse_token_string_t cmd_macsec_sa_set =
14307 TOKEN_STRING_INITIALIZER
14308 (struct cmd_macsec_sa_result,
14310 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14311 TOKEN_STRING_INITIALIZER
14312 (struct cmd_macsec_sa_result,
14314 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14315 TOKEN_STRING_INITIALIZER
14316 (struct cmd_macsec_sa_result,
14318 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14319 TOKEN_STRING_INITIALIZER
14320 (struct cmd_macsec_sa_result,
14322 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14323 TOKEN_NUM_INITIALIZER
14324 (struct cmd_macsec_sa_result,
14326 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14327 TOKEN_NUM_INITIALIZER
14328 (struct cmd_macsec_sa_result,
14330 cmdline_parse_token_num_t cmd_macsec_sa_an =
14331 TOKEN_NUM_INITIALIZER
14332 (struct cmd_macsec_sa_result,
14334 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14335 TOKEN_NUM_INITIALIZER
14336 (struct cmd_macsec_sa_result,
14338 cmdline_parse_token_string_t cmd_macsec_sa_key =
14339 TOKEN_STRING_INITIALIZER
14340 (struct cmd_macsec_sa_result,
14344 cmd_set_macsec_sa_parsed(
14345 void *parsed_result,
14346 __attribute__((unused)) struct cmdline *cl,
14347 __attribute__((unused)) void *data)
14349 struct cmd_macsec_sa_result *res = parsed_result;
14350 int ret = -ENOTSUP;
14351 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14352 uint8_t key[16] = { 0 };
14358 key_len = strlen(res->key) / 2;
14362 for (i = 0; i < key_len; i++) {
14363 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14366 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14369 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14372 #ifdef RTE_LIBRTE_IXGBE_PMD
14374 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14375 res->idx, res->an, res->pn, key) :
14376 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14377 res->idx, res->an, res->pn, key);
14379 RTE_SET_USED(is_tx);
14386 printf("invalid idx %d or an %d\n", res->idx, res->an);
14389 printf("invalid port_id %d\n", res->port_id);
14392 printf("not supported on port %d\n", res->port_id);
14395 printf("programming error: (%s)\n", strerror(-ret));
14399 cmdline_parse_inst_t cmd_set_macsec_sa = {
14400 .f = cmd_set_macsec_sa_parsed,
14402 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14404 (void *)&cmd_macsec_sa_set,
14405 (void *)&cmd_macsec_sa_macsec,
14406 (void *)&cmd_macsec_sa_sa,
14407 (void *)&cmd_macsec_sa_tx_rx,
14408 (void *)&cmd_macsec_sa_port_id,
14409 (void *)&cmd_macsec_sa_idx,
14410 (void *)&cmd_macsec_sa_an,
14411 (void *)&cmd_macsec_sa_pn,
14412 (void *)&cmd_macsec_sa_key,
14417 /* VF unicast promiscuous mode configuration */
14419 /* Common result structure for VF unicast promiscuous mode */
14420 struct cmd_vf_promisc_result {
14421 cmdline_fixed_string_t set;
14422 cmdline_fixed_string_t vf;
14423 cmdline_fixed_string_t promisc;
14426 cmdline_fixed_string_t on_off;
14429 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14430 cmdline_parse_token_string_t cmd_vf_promisc_set =
14431 TOKEN_STRING_INITIALIZER
14432 (struct cmd_vf_promisc_result,
14434 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14435 TOKEN_STRING_INITIALIZER
14436 (struct cmd_vf_promisc_result,
14438 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14439 TOKEN_STRING_INITIALIZER
14440 (struct cmd_vf_promisc_result,
14441 promisc, "promisc");
14442 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14443 TOKEN_NUM_INITIALIZER
14444 (struct cmd_vf_promisc_result,
14446 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14447 TOKEN_NUM_INITIALIZER
14448 (struct cmd_vf_promisc_result,
14450 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14451 TOKEN_STRING_INITIALIZER
14452 (struct cmd_vf_promisc_result,
14456 cmd_set_vf_promisc_parsed(
14457 void *parsed_result,
14458 __attribute__((unused)) struct cmdline *cl,
14459 __attribute__((unused)) void *data)
14461 struct cmd_vf_promisc_result *res = parsed_result;
14462 int ret = -ENOTSUP;
14464 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14466 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14469 #ifdef RTE_LIBRTE_I40E_PMD
14470 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14471 res->vf_id, is_on);
14478 printf("invalid vf_id %d\n", res->vf_id);
14481 printf("invalid port_id %d\n", res->port_id);
14484 printf("function not implemented\n");
14487 printf("programming error: (%s)\n", strerror(-ret));
14491 cmdline_parse_inst_t cmd_set_vf_promisc = {
14492 .f = cmd_set_vf_promisc_parsed,
14494 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14495 "Set unicast promiscuous mode for a VF from the PF",
14497 (void *)&cmd_vf_promisc_set,
14498 (void *)&cmd_vf_promisc_vf,
14499 (void *)&cmd_vf_promisc_promisc,
14500 (void *)&cmd_vf_promisc_port_id,
14501 (void *)&cmd_vf_promisc_vf_id,
14502 (void *)&cmd_vf_promisc_on_off,
14507 /* VF multicast promiscuous mode configuration */
14509 /* Common result structure for VF multicast promiscuous mode */
14510 struct cmd_vf_allmulti_result {
14511 cmdline_fixed_string_t set;
14512 cmdline_fixed_string_t vf;
14513 cmdline_fixed_string_t allmulti;
14516 cmdline_fixed_string_t on_off;
14519 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14520 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14521 TOKEN_STRING_INITIALIZER
14522 (struct cmd_vf_allmulti_result,
14524 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14525 TOKEN_STRING_INITIALIZER
14526 (struct cmd_vf_allmulti_result,
14528 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14529 TOKEN_STRING_INITIALIZER
14530 (struct cmd_vf_allmulti_result,
14531 allmulti, "allmulti");
14532 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14533 TOKEN_NUM_INITIALIZER
14534 (struct cmd_vf_allmulti_result,
14536 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14537 TOKEN_NUM_INITIALIZER
14538 (struct cmd_vf_allmulti_result,
14540 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14541 TOKEN_STRING_INITIALIZER
14542 (struct cmd_vf_allmulti_result,
14546 cmd_set_vf_allmulti_parsed(
14547 void *parsed_result,
14548 __attribute__((unused)) struct cmdline *cl,
14549 __attribute__((unused)) void *data)
14551 struct cmd_vf_allmulti_result *res = parsed_result;
14552 int ret = -ENOTSUP;
14554 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14556 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14559 #ifdef RTE_LIBRTE_I40E_PMD
14560 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14561 res->vf_id, is_on);
14568 printf("invalid vf_id %d\n", res->vf_id);
14571 printf("invalid port_id %d\n", res->port_id);
14574 printf("function not implemented\n");
14577 printf("programming error: (%s)\n", strerror(-ret));
14581 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14582 .f = cmd_set_vf_allmulti_parsed,
14584 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14585 "Set multicast promiscuous mode for a VF from the PF",
14587 (void *)&cmd_vf_allmulti_set,
14588 (void *)&cmd_vf_allmulti_vf,
14589 (void *)&cmd_vf_allmulti_allmulti,
14590 (void *)&cmd_vf_allmulti_port_id,
14591 (void *)&cmd_vf_allmulti_vf_id,
14592 (void *)&cmd_vf_allmulti_on_off,
14597 /* vf broadcast mode configuration */
14599 /* Common result structure for vf broadcast */
14600 struct cmd_set_vf_broadcast_result {
14601 cmdline_fixed_string_t set;
14602 cmdline_fixed_string_t vf;
14603 cmdline_fixed_string_t broadcast;
14606 cmdline_fixed_string_t on_off;
14609 /* Common CLI fields for vf broadcast enable disable */
14610 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14611 TOKEN_STRING_INITIALIZER
14612 (struct cmd_set_vf_broadcast_result,
14614 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14615 TOKEN_STRING_INITIALIZER
14616 (struct cmd_set_vf_broadcast_result,
14618 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14619 TOKEN_STRING_INITIALIZER
14620 (struct cmd_set_vf_broadcast_result,
14621 broadcast, "broadcast");
14622 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14623 TOKEN_NUM_INITIALIZER
14624 (struct cmd_set_vf_broadcast_result,
14626 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14627 TOKEN_NUM_INITIALIZER
14628 (struct cmd_set_vf_broadcast_result,
14630 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14631 TOKEN_STRING_INITIALIZER
14632 (struct cmd_set_vf_broadcast_result,
14636 cmd_set_vf_broadcast_parsed(
14637 void *parsed_result,
14638 __attribute__((unused)) struct cmdline *cl,
14639 __attribute__((unused)) void *data)
14641 struct cmd_set_vf_broadcast_result *res = parsed_result;
14642 int ret = -ENOTSUP;
14644 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14646 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14649 #ifdef RTE_LIBRTE_I40E_PMD
14650 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14651 res->vf_id, is_on);
14658 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14661 printf("invalid port_id %d\n", res->port_id);
14664 printf("function not implemented\n");
14667 printf("programming error: (%s)\n", strerror(-ret));
14671 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14672 .f = cmd_set_vf_broadcast_parsed,
14674 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14676 (void *)&cmd_set_vf_broadcast_set,
14677 (void *)&cmd_set_vf_broadcast_vf,
14678 (void *)&cmd_set_vf_broadcast_broadcast,
14679 (void *)&cmd_set_vf_broadcast_port_id,
14680 (void *)&cmd_set_vf_broadcast_vf_id,
14681 (void *)&cmd_set_vf_broadcast_on_off,
14686 /* vf vlan tag configuration */
14688 /* Common result structure for vf vlan tag */
14689 struct cmd_set_vf_vlan_tag_result {
14690 cmdline_fixed_string_t set;
14691 cmdline_fixed_string_t vf;
14692 cmdline_fixed_string_t vlan;
14693 cmdline_fixed_string_t tag;
14696 cmdline_fixed_string_t on_off;
14699 /* Common CLI fields for vf vlan tag enable disable */
14700 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14701 TOKEN_STRING_INITIALIZER
14702 (struct cmd_set_vf_vlan_tag_result,
14704 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14705 TOKEN_STRING_INITIALIZER
14706 (struct cmd_set_vf_vlan_tag_result,
14708 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14709 TOKEN_STRING_INITIALIZER
14710 (struct cmd_set_vf_vlan_tag_result,
14712 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14713 TOKEN_STRING_INITIALIZER
14714 (struct cmd_set_vf_vlan_tag_result,
14716 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14717 TOKEN_NUM_INITIALIZER
14718 (struct cmd_set_vf_vlan_tag_result,
14720 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14721 TOKEN_NUM_INITIALIZER
14722 (struct cmd_set_vf_vlan_tag_result,
14724 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14725 TOKEN_STRING_INITIALIZER
14726 (struct cmd_set_vf_vlan_tag_result,
14730 cmd_set_vf_vlan_tag_parsed(
14731 void *parsed_result,
14732 __attribute__((unused)) struct cmdline *cl,
14733 __attribute__((unused)) void *data)
14735 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14736 int ret = -ENOTSUP;
14738 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14740 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14743 #ifdef RTE_LIBRTE_I40E_PMD
14744 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14745 res->vf_id, is_on);
14752 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14755 printf("invalid port_id %d\n", res->port_id);
14758 printf("function not implemented\n");
14761 printf("programming error: (%s)\n", strerror(-ret));
14765 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14766 .f = cmd_set_vf_vlan_tag_parsed,
14768 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14770 (void *)&cmd_set_vf_vlan_tag_set,
14771 (void *)&cmd_set_vf_vlan_tag_vf,
14772 (void *)&cmd_set_vf_vlan_tag_vlan,
14773 (void *)&cmd_set_vf_vlan_tag_tag,
14774 (void *)&cmd_set_vf_vlan_tag_port_id,
14775 (void *)&cmd_set_vf_vlan_tag_vf_id,
14776 (void *)&cmd_set_vf_vlan_tag_on_off,
14781 /* Common definition of VF and TC TX bandwidth configuration */
14782 struct cmd_vf_tc_bw_result {
14783 cmdline_fixed_string_t set;
14784 cmdline_fixed_string_t vf;
14785 cmdline_fixed_string_t tc;
14786 cmdline_fixed_string_t tx;
14787 cmdline_fixed_string_t min_bw;
14788 cmdline_fixed_string_t max_bw;
14789 cmdline_fixed_string_t strict_link_prio;
14794 cmdline_fixed_string_t bw_list;
14798 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14799 TOKEN_STRING_INITIALIZER
14800 (struct cmd_vf_tc_bw_result,
14802 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14803 TOKEN_STRING_INITIALIZER
14804 (struct cmd_vf_tc_bw_result,
14806 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14807 TOKEN_STRING_INITIALIZER
14808 (struct cmd_vf_tc_bw_result,
14810 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14811 TOKEN_STRING_INITIALIZER
14812 (struct cmd_vf_tc_bw_result,
14814 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14815 TOKEN_STRING_INITIALIZER
14816 (struct cmd_vf_tc_bw_result,
14817 strict_link_prio, "strict-link-priority");
14818 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14819 TOKEN_STRING_INITIALIZER
14820 (struct cmd_vf_tc_bw_result,
14821 min_bw, "min-bandwidth");
14822 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14823 TOKEN_STRING_INITIALIZER
14824 (struct cmd_vf_tc_bw_result,
14825 max_bw, "max-bandwidth");
14826 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14827 TOKEN_NUM_INITIALIZER
14828 (struct cmd_vf_tc_bw_result,
14830 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14831 TOKEN_NUM_INITIALIZER
14832 (struct cmd_vf_tc_bw_result,
14834 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14835 TOKEN_NUM_INITIALIZER
14836 (struct cmd_vf_tc_bw_result,
14838 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14839 TOKEN_NUM_INITIALIZER
14840 (struct cmd_vf_tc_bw_result,
14842 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14843 TOKEN_STRING_INITIALIZER
14844 (struct cmd_vf_tc_bw_result,
14846 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14847 TOKEN_NUM_INITIALIZER
14848 (struct cmd_vf_tc_bw_result,
14851 /* VF max bandwidth setting */
14853 cmd_vf_max_bw_parsed(
14854 void *parsed_result,
14855 __attribute__((unused)) struct cmdline *cl,
14856 __attribute__((unused)) void *data)
14858 struct cmd_vf_tc_bw_result *res = parsed_result;
14859 int ret = -ENOTSUP;
14861 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14864 #ifdef RTE_LIBRTE_I40E_PMD
14865 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14866 res->vf_id, res->bw);
14873 printf("invalid vf_id %d or bandwidth %d\n",
14874 res->vf_id, res->bw);
14877 printf("invalid port_id %d\n", res->port_id);
14880 printf("function not implemented\n");
14883 printf("programming error: (%s)\n", strerror(-ret));
14887 cmdline_parse_inst_t cmd_vf_max_bw = {
14888 .f = cmd_vf_max_bw_parsed,
14890 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14892 (void *)&cmd_vf_tc_bw_set,
14893 (void *)&cmd_vf_tc_bw_vf,
14894 (void *)&cmd_vf_tc_bw_tx,
14895 (void *)&cmd_vf_tc_bw_max_bw,
14896 (void *)&cmd_vf_tc_bw_port_id,
14897 (void *)&cmd_vf_tc_bw_vf_id,
14898 (void *)&cmd_vf_tc_bw_bw,
14904 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14909 const char *p, *p0 = str;
14916 p = strchr(p0, '(');
14918 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14922 p0 = strchr(p, ')');
14924 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14928 if (size >= sizeof(s)) {
14929 printf("The string size exceeds the internal buffer size\n");
14932 snprintf(s, sizeof(s), "%.*s", size, p);
14933 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14935 printf("Failed to get the bandwidth list. ");
14939 for (i = 0; i < ret; i++)
14940 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14945 /* TC min bandwidth setting */
14947 cmd_vf_tc_min_bw_parsed(
14948 void *parsed_result,
14949 __attribute__((unused)) struct cmdline *cl,
14950 __attribute__((unused)) void *data)
14952 struct cmd_vf_tc_bw_result *res = parsed_result;
14955 int ret = -ENOTSUP;
14957 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14960 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14964 #ifdef RTE_LIBRTE_I40E_PMD
14965 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14973 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14976 printf("invalid port_id %d\n", res->port_id);
14979 printf("function not implemented\n");
14982 printf("programming error: (%s)\n", strerror(-ret));
14986 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14987 .f = cmd_vf_tc_min_bw_parsed,
14989 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14990 " <bw1, bw2, ...>",
14992 (void *)&cmd_vf_tc_bw_set,
14993 (void *)&cmd_vf_tc_bw_vf,
14994 (void *)&cmd_vf_tc_bw_tc,
14995 (void *)&cmd_vf_tc_bw_tx,
14996 (void *)&cmd_vf_tc_bw_min_bw,
14997 (void *)&cmd_vf_tc_bw_port_id,
14998 (void *)&cmd_vf_tc_bw_vf_id,
14999 (void *)&cmd_vf_tc_bw_bw_list,
15005 cmd_tc_min_bw_parsed(
15006 void *parsed_result,
15007 __attribute__((unused)) struct cmdline *cl,
15008 __attribute__((unused)) void *data)
15010 struct cmd_vf_tc_bw_result *res = parsed_result;
15011 struct rte_port *port;
15014 int ret = -ENOTSUP;
15016 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15019 port = &ports[res->port_id];
15020 /** Check if the port is not started **/
15021 if (port->port_status != RTE_PORT_STOPPED) {
15022 printf("Please stop port %d first\n", res->port_id);
15026 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15030 #ifdef RTE_LIBRTE_IXGBE_PMD
15031 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15038 printf("invalid bandwidth\n");
15041 printf("invalid port_id %d\n", res->port_id);
15044 printf("function not implemented\n");
15047 printf("programming error: (%s)\n", strerror(-ret));
15051 cmdline_parse_inst_t cmd_tc_min_bw = {
15052 .f = cmd_tc_min_bw_parsed,
15054 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15056 (void *)&cmd_vf_tc_bw_set,
15057 (void *)&cmd_vf_tc_bw_tc,
15058 (void *)&cmd_vf_tc_bw_tx,
15059 (void *)&cmd_vf_tc_bw_min_bw,
15060 (void *)&cmd_vf_tc_bw_port_id,
15061 (void *)&cmd_vf_tc_bw_bw_list,
15066 /* TC max bandwidth setting */
15068 cmd_vf_tc_max_bw_parsed(
15069 void *parsed_result,
15070 __attribute__((unused)) struct cmdline *cl,
15071 __attribute__((unused)) void *data)
15073 struct cmd_vf_tc_bw_result *res = parsed_result;
15074 int ret = -ENOTSUP;
15076 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15079 #ifdef RTE_LIBRTE_I40E_PMD
15080 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15081 res->tc_no, res->bw);
15088 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15089 res->vf_id, res->tc_no, res->bw);
15092 printf("invalid port_id %d\n", res->port_id);
15095 printf("function not implemented\n");
15098 printf("programming error: (%s)\n", strerror(-ret));
15102 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15103 .f = cmd_vf_tc_max_bw_parsed,
15105 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15108 (void *)&cmd_vf_tc_bw_set,
15109 (void *)&cmd_vf_tc_bw_vf,
15110 (void *)&cmd_vf_tc_bw_tc,
15111 (void *)&cmd_vf_tc_bw_tx,
15112 (void *)&cmd_vf_tc_bw_max_bw,
15113 (void *)&cmd_vf_tc_bw_port_id,
15114 (void *)&cmd_vf_tc_bw_vf_id,
15115 (void *)&cmd_vf_tc_bw_tc_no,
15116 (void *)&cmd_vf_tc_bw_bw,
15122 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15124 /* *** Set Port default Traffic Management Hierarchy *** */
15125 struct cmd_set_port_tm_hierarchy_default_result {
15126 cmdline_fixed_string_t set;
15127 cmdline_fixed_string_t port;
15128 cmdline_fixed_string_t tm;
15129 cmdline_fixed_string_t hierarchy;
15130 cmdline_fixed_string_t def;
15134 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15135 TOKEN_STRING_INITIALIZER(
15136 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15137 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15138 TOKEN_STRING_INITIALIZER(
15139 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15140 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15141 TOKEN_STRING_INITIALIZER(
15142 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15143 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15144 TOKEN_STRING_INITIALIZER(
15145 struct cmd_set_port_tm_hierarchy_default_result,
15146 hierarchy, "hierarchy");
15147 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15148 TOKEN_STRING_INITIALIZER(
15149 struct cmd_set_port_tm_hierarchy_default_result,
15151 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15152 TOKEN_NUM_INITIALIZER(
15153 struct cmd_set_port_tm_hierarchy_default_result,
15156 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15157 __attribute__((unused)) struct cmdline *cl,
15158 __attribute__((unused)) void *data)
15160 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15161 struct rte_port *p;
15162 portid_t port_id = res->port_id;
15164 if (port_id_is_invalid(port_id, ENABLED_WARN))
15167 p = &ports[port_id];
15169 /* Forward mode: tm */
15170 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15171 printf(" softnicfwd mode not enabled(error)\n");
15175 /* Set the default tm hierarchy */
15176 p->softport.default_tm_hierarchy_enable = 1;
15179 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15180 .f = cmd_set_port_tm_hierarchy_default_parsed,
15182 .help_str = "set port tm hierarchy default <port_id>",
15184 (void *)&cmd_set_port_tm_hierarchy_default_set,
15185 (void *)&cmd_set_port_tm_hierarchy_default_port,
15186 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15187 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15188 (void *)&cmd_set_port_tm_hierarchy_default_default,
15189 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15195 /** Set VXLAN encapsulation details */
15196 struct cmd_set_vxlan_result {
15197 cmdline_fixed_string_t set;
15198 cmdline_fixed_string_t vxlan;
15199 cmdline_fixed_string_t pos_token;
15200 cmdline_fixed_string_t ip_version;
15201 uint32_t vlan_present:1;
15205 cmdline_ipaddr_t ip_src;
15206 cmdline_ipaddr_t ip_dst;
15210 struct rte_ether_addr eth_src;
15211 struct rte_ether_addr eth_dst;
15214 cmdline_parse_token_string_t cmd_set_vxlan_set =
15215 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15216 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15217 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15218 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15219 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15221 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15222 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15223 "vxlan-with-vlan");
15224 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15225 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15227 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15228 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15230 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15231 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15233 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15234 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15235 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15236 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15238 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15239 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15240 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15241 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15243 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15244 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15245 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15246 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15248 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15249 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15250 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15251 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15253 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15254 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15255 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15256 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15258 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15259 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15260 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15261 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15263 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15264 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15265 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15266 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15268 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15269 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15270 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15271 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15273 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15274 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15275 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15276 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15278 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15279 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15281 static void cmd_set_vxlan_parsed(void *parsed_result,
15282 __attribute__((unused)) struct cmdline *cl,
15283 __attribute__((unused)) void *data)
15285 struct cmd_set_vxlan_result *res = parsed_result;
15290 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15293 vxlan_encap_conf.select_tos_ttl = 0;
15294 if (strcmp(res->vxlan, "vxlan") == 0)
15295 vxlan_encap_conf.select_vlan = 0;
15296 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15297 vxlan_encap_conf.select_vlan = 1;
15298 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15299 vxlan_encap_conf.select_vlan = 0;
15300 vxlan_encap_conf.select_tos_ttl = 1;
15302 if (strcmp(res->ip_version, "ipv4") == 0)
15303 vxlan_encap_conf.select_ipv4 = 1;
15304 else if (strcmp(res->ip_version, "ipv6") == 0)
15305 vxlan_encap_conf.select_ipv4 = 0;
15308 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15309 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15310 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15311 vxlan_encap_conf.ip_tos = res->tos;
15312 vxlan_encap_conf.ip_ttl = res->ttl;
15313 if (vxlan_encap_conf.select_ipv4) {
15314 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15315 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15317 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15318 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15320 if (vxlan_encap_conf.select_vlan)
15321 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15322 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15323 RTE_ETHER_ADDR_LEN);
15324 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15325 RTE_ETHER_ADDR_LEN);
15328 cmdline_parse_inst_t cmd_set_vxlan = {
15329 .f = cmd_set_vxlan_parsed,
15331 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15332 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15333 " eth-src <eth-src> eth-dst <eth-dst>",
15335 (void *)&cmd_set_vxlan_set,
15336 (void *)&cmd_set_vxlan_vxlan,
15337 (void *)&cmd_set_vxlan_ip_version,
15338 (void *)&cmd_set_vxlan_ip_version_value,
15339 (void *)&cmd_set_vxlan_vni,
15340 (void *)&cmd_set_vxlan_vni_value,
15341 (void *)&cmd_set_vxlan_udp_src,
15342 (void *)&cmd_set_vxlan_udp_src_value,
15343 (void *)&cmd_set_vxlan_udp_dst,
15344 (void *)&cmd_set_vxlan_udp_dst_value,
15345 (void *)&cmd_set_vxlan_ip_src,
15346 (void *)&cmd_set_vxlan_ip_src_value,
15347 (void *)&cmd_set_vxlan_ip_dst,
15348 (void *)&cmd_set_vxlan_ip_dst_value,
15349 (void *)&cmd_set_vxlan_eth_src,
15350 (void *)&cmd_set_vxlan_eth_src_value,
15351 (void *)&cmd_set_vxlan_eth_dst,
15352 (void *)&cmd_set_vxlan_eth_dst_value,
15357 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15358 .f = cmd_set_vxlan_parsed,
15360 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15361 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15362 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15363 " eth-dst <eth-dst>",
15365 (void *)&cmd_set_vxlan_set,
15366 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15367 (void *)&cmd_set_vxlan_ip_version,
15368 (void *)&cmd_set_vxlan_ip_version_value,
15369 (void *)&cmd_set_vxlan_vni,
15370 (void *)&cmd_set_vxlan_vni_value,
15371 (void *)&cmd_set_vxlan_udp_src,
15372 (void *)&cmd_set_vxlan_udp_src_value,
15373 (void *)&cmd_set_vxlan_udp_dst,
15374 (void *)&cmd_set_vxlan_udp_dst_value,
15375 (void *)&cmd_set_vxlan_ip_tos,
15376 (void *)&cmd_set_vxlan_ip_tos_value,
15377 (void *)&cmd_set_vxlan_ip_ttl,
15378 (void *)&cmd_set_vxlan_ip_ttl_value,
15379 (void *)&cmd_set_vxlan_ip_src,
15380 (void *)&cmd_set_vxlan_ip_src_value,
15381 (void *)&cmd_set_vxlan_ip_dst,
15382 (void *)&cmd_set_vxlan_ip_dst_value,
15383 (void *)&cmd_set_vxlan_eth_src,
15384 (void *)&cmd_set_vxlan_eth_src_value,
15385 (void *)&cmd_set_vxlan_eth_dst,
15386 (void *)&cmd_set_vxlan_eth_dst_value,
15391 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15392 .f = cmd_set_vxlan_parsed,
15394 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15395 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15396 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15399 (void *)&cmd_set_vxlan_set,
15400 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15401 (void *)&cmd_set_vxlan_ip_version,
15402 (void *)&cmd_set_vxlan_ip_version_value,
15403 (void *)&cmd_set_vxlan_vni,
15404 (void *)&cmd_set_vxlan_vni_value,
15405 (void *)&cmd_set_vxlan_udp_src,
15406 (void *)&cmd_set_vxlan_udp_src_value,
15407 (void *)&cmd_set_vxlan_udp_dst,
15408 (void *)&cmd_set_vxlan_udp_dst_value,
15409 (void *)&cmd_set_vxlan_ip_src,
15410 (void *)&cmd_set_vxlan_ip_src_value,
15411 (void *)&cmd_set_vxlan_ip_dst,
15412 (void *)&cmd_set_vxlan_ip_dst_value,
15413 (void *)&cmd_set_vxlan_vlan,
15414 (void *)&cmd_set_vxlan_vlan_value,
15415 (void *)&cmd_set_vxlan_eth_src,
15416 (void *)&cmd_set_vxlan_eth_src_value,
15417 (void *)&cmd_set_vxlan_eth_dst,
15418 (void *)&cmd_set_vxlan_eth_dst_value,
15423 /** Set NVGRE encapsulation details */
15424 struct cmd_set_nvgre_result {
15425 cmdline_fixed_string_t set;
15426 cmdline_fixed_string_t nvgre;
15427 cmdline_fixed_string_t pos_token;
15428 cmdline_fixed_string_t ip_version;
15430 cmdline_ipaddr_t ip_src;
15431 cmdline_ipaddr_t ip_dst;
15433 struct rte_ether_addr eth_src;
15434 struct rte_ether_addr eth_dst;
15437 cmdline_parse_token_string_t cmd_set_nvgre_set =
15438 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15439 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15440 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15441 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15442 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15443 "nvgre-with-vlan");
15444 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15445 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15447 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15448 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15450 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15451 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15453 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15454 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15455 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15456 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15458 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15459 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15460 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15461 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15463 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15464 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15465 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15466 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15468 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15469 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15470 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15471 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15473 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15474 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15475 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15476 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15478 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15479 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15481 static void cmd_set_nvgre_parsed(void *parsed_result,
15482 __attribute__((unused)) struct cmdline *cl,
15483 __attribute__((unused)) void *data)
15485 struct cmd_set_nvgre_result *res = parsed_result;
15487 uint32_t nvgre_tni;
15490 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15493 if (strcmp(res->nvgre, "nvgre") == 0)
15494 nvgre_encap_conf.select_vlan = 0;
15495 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15496 nvgre_encap_conf.select_vlan = 1;
15497 if (strcmp(res->ip_version, "ipv4") == 0)
15498 nvgre_encap_conf.select_ipv4 = 1;
15499 else if (strcmp(res->ip_version, "ipv6") == 0)
15500 nvgre_encap_conf.select_ipv4 = 0;
15503 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15504 if (nvgre_encap_conf.select_ipv4) {
15505 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15506 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15508 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15509 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15511 if (nvgre_encap_conf.select_vlan)
15512 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15513 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15514 RTE_ETHER_ADDR_LEN);
15515 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15516 RTE_ETHER_ADDR_LEN);
15519 cmdline_parse_inst_t cmd_set_nvgre = {
15520 .f = cmd_set_nvgre_parsed,
15522 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15523 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15524 " eth-dst <eth-dst>",
15526 (void *)&cmd_set_nvgre_set,
15527 (void *)&cmd_set_nvgre_nvgre,
15528 (void *)&cmd_set_nvgre_ip_version,
15529 (void *)&cmd_set_nvgre_ip_version_value,
15530 (void *)&cmd_set_nvgre_tni,
15531 (void *)&cmd_set_nvgre_tni_value,
15532 (void *)&cmd_set_nvgre_ip_src,
15533 (void *)&cmd_set_nvgre_ip_src_value,
15534 (void *)&cmd_set_nvgre_ip_dst,
15535 (void *)&cmd_set_nvgre_ip_dst_value,
15536 (void *)&cmd_set_nvgre_eth_src,
15537 (void *)&cmd_set_nvgre_eth_src_value,
15538 (void *)&cmd_set_nvgre_eth_dst,
15539 (void *)&cmd_set_nvgre_eth_dst_value,
15544 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15545 .f = cmd_set_nvgre_parsed,
15547 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15548 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15549 " eth-src <eth-src> eth-dst <eth-dst>",
15551 (void *)&cmd_set_nvgre_set,
15552 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15553 (void *)&cmd_set_nvgre_ip_version,
15554 (void *)&cmd_set_nvgre_ip_version_value,
15555 (void *)&cmd_set_nvgre_tni,
15556 (void *)&cmd_set_nvgre_tni_value,
15557 (void *)&cmd_set_nvgre_ip_src,
15558 (void *)&cmd_set_nvgre_ip_src_value,
15559 (void *)&cmd_set_nvgre_ip_dst,
15560 (void *)&cmd_set_nvgre_ip_dst_value,
15561 (void *)&cmd_set_nvgre_vlan,
15562 (void *)&cmd_set_nvgre_vlan_value,
15563 (void *)&cmd_set_nvgre_eth_src,
15564 (void *)&cmd_set_nvgre_eth_src_value,
15565 (void *)&cmd_set_nvgre_eth_dst,
15566 (void *)&cmd_set_nvgre_eth_dst_value,
15571 /** Set L2 encapsulation details */
15572 struct cmd_set_l2_encap_result {
15573 cmdline_fixed_string_t set;
15574 cmdline_fixed_string_t l2_encap;
15575 cmdline_fixed_string_t pos_token;
15576 cmdline_fixed_string_t ip_version;
15577 uint32_t vlan_present:1;
15579 struct rte_ether_addr eth_src;
15580 struct rte_ether_addr eth_dst;
15583 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15584 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15585 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15586 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15587 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15588 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15589 "l2_encap-with-vlan");
15590 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15591 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15593 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15594 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15596 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15597 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15599 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15600 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15601 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15602 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15604 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15605 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15606 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15607 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15609 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15610 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15612 static void cmd_set_l2_encap_parsed(void *parsed_result,
15613 __attribute__((unused)) struct cmdline *cl,
15614 __attribute__((unused)) void *data)
15616 struct cmd_set_l2_encap_result *res = parsed_result;
15618 if (strcmp(res->l2_encap, "l2_encap") == 0)
15619 l2_encap_conf.select_vlan = 0;
15620 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15621 l2_encap_conf.select_vlan = 1;
15622 if (strcmp(res->ip_version, "ipv4") == 0)
15623 l2_encap_conf.select_ipv4 = 1;
15624 else if (strcmp(res->ip_version, "ipv6") == 0)
15625 l2_encap_conf.select_ipv4 = 0;
15628 if (l2_encap_conf.select_vlan)
15629 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15630 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15631 RTE_ETHER_ADDR_LEN);
15632 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15633 RTE_ETHER_ADDR_LEN);
15636 cmdline_parse_inst_t cmd_set_l2_encap = {
15637 .f = cmd_set_l2_encap_parsed,
15639 .help_str = "set l2_encap ip-version ipv4|ipv6"
15640 " eth-src <eth-src> eth-dst <eth-dst>",
15642 (void *)&cmd_set_l2_encap_set,
15643 (void *)&cmd_set_l2_encap_l2_encap,
15644 (void *)&cmd_set_l2_encap_ip_version,
15645 (void *)&cmd_set_l2_encap_ip_version_value,
15646 (void *)&cmd_set_l2_encap_eth_src,
15647 (void *)&cmd_set_l2_encap_eth_src_value,
15648 (void *)&cmd_set_l2_encap_eth_dst,
15649 (void *)&cmd_set_l2_encap_eth_dst_value,
15654 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15655 .f = cmd_set_l2_encap_parsed,
15657 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15658 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15660 (void *)&cmd_set_l2_encap_set,
15661 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15662 (void *)&cmd_set_l2_encap_ip_version,
15663 (void *)&cmd_set_l2_encap_ip_version_value,
15664 (void *)&cmd_set_l2_encap_vlan,
15665 (void *)&cmd_set_l2_encap_vlan_value,
15666 (void *)&cmd_set_l2_encap_eth_src,
15667 (void *)&cmd_set_l2_encap_eth_src_value,
15668 (void *)&cmd_set_l2_encap_eth_dst,
15669 (void *)&cmd_set_l2_encap_eth_dst_value,
15674 /** Set L2 decapsulation details */
15675 struct cmd_set_l2_decap_result {
15676 cmdline_fixed_string_t set;
15677 cmdline_fixed_string_t l2_decap;
15678 cmdline_fixed_string_t pos_token;
15679 uint32_t vlan_present:1;
15682 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15683 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15684 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15685 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15687 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15688 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15689 "l2_decap-with-vlan");
15691 static void cmd_set_l2_decap_parsed(void *parsed_result,
15692 __attribute__((unused)) struct cmdline *cl,
15693 __attribute__((unused)) void *data)
15695 struct cmd_set_l2_decap_result *res = parsed_result;
15697 if (strcmp(res->l2_decap, "l2_decap") == 0)
15698 l2_decap_conf.select_vlan = 0;
15699 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15700 l2_decap_conf.select_vlan = 1;
15703 cmdline_parse_inst_t cmd_set_l2_decap = {
15704 .f = cmd_set_l2_decap_parsed,
15706 .help_str = "set l2_decap",
15708 (void *)&cmd_set_l2_decap_set,
15709 (void *)&cmd_set_l2_decap_l2_decap,
15714 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15715 .f = cmd_set_l2_decap_parsed,
15717 .help_str = "set l2_decap-with-vlan",
15719 (void *)&cmd_set_l2_decap_set,
15720 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15725 /** Set MPLSoGRE encapsulation details */
15726 struct cmd_set_mplsogre_encap_result {
15727 cmdline_fixed_string_t set;
15728 cmdline_fixed_string_t mplsogre;
15729 cmdline_fixed_string_t pos_token;
15730 cmdline_fixed_string_t ip_version;
15731 uint32_t vlan_present:1;
15733 cmdline_ipaddr_t ip_src;
15734 cmdline_ipaddr_t ip_dst;
15736 struct rte_ether_addr eth_src;
15737 struct rte_ether_addr eth_dst;
15740 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15741 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15743 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15744 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15746 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15747 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15748 mplsogre, "mplsogre_encap-with-vlan");
15749 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15750 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15751 pos_token, "ip-version");
15752 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15753 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15754 ip_version, "ipv4#ipv6");
15755 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15756 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15757 pos_token, "label");
15758 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15759 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15761 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15762 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15763 pos_token, "ip-src");
15764 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15765 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15766 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15767 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15768 pos_token, "ip-dst");
15769 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15770 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15771 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15772 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15773 pos_token, "vlan-tci");
15774 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15775 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15777 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15778 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15779 pos_token, "eth-src");
15780 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15781 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15783 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15784 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15785 pos_token, "eth-dst");
15786 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15787 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15790 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15791 __attribute__((unused)) struct cmdline *cl,
15792 __attribute__((unused)) void *data)
15794 struct cmd_set_mplsogre_encap_result *res = parsed_result;
15796 uint32_t mplsogre_label;
15799 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15802 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15803 mplsogre_encap_conf.select_vlan = 0;
15804 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15805 mplsogre_encap_conf.select_vlan = 1;
15806 if (strcmp(res->ip_version, "ipv4") == 0)
15807 mplsogre_encap_conf.select_ipv4 = 1;
15808 else if (strcmp(res->ip_version, "ipv6") == 0)
15809 mplsogre_encap_conf.select_ipv4 = 0;
15812 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15813 if (mplsogre_encap_conf.select_ipv4) {
15814 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15815 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15817 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15818 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15820 if (mplsogre_encap_conf.select_vlan)
15821 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15822 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15823 RTE_ETHER_ADDR_LEN);
15824 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15825 RTE_ETHER_ADDR_LEN);
15828 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15829 .f = cmd_set_mplsogre_encap_parsed,
15831 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15832 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15833 " eth-dst <eth-dst>",
15835 (void *)&cmd_set_mplsogre_encap_set,
15836 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15837 (void *)&cmd_set_mplsogre_encap_ip_version,
15838 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15839 (void *)&cmd_set_mplsogre_encap_label,
15840 (void *)&cmd_set_mplsogre_encap_label_value,
15841 (void *)&cmd_set_mplsogre_encap_ip_src,
15842 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15843 (void *)&cmd_set_mplsogre_encap_ip_dst,
15844 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15845 (void *)&cmd_set_mplsogre_encap_eth_src,
15846 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15847 (void *)&cmd_set_mplsogre_encap_eth_dst,
15848 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15853 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
15854 .f = cmd_set_mplsogre_encap_parsed,
15856 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
15857 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
15858 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15860 (void *)&cmd_set_mplsogre_encap_set,
15861 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
15862 (void *)&cmd_set_mplsogre_encap_ip_version,
15863 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15864 (void *)&cmd_set_mplsogre_encap_label,
15865 (void *)&cmd_set_mplsogre_encap_label_value,
15866 (void *)&cmd_set_mplsogre_encap_ip_src,
15867 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15868 (void *)&cmd_set_mplsogre_encap_ip_dst,
15869 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15870 (void *)&cmd_set_mplsogre_encap_vlan,
15871 (void *)&cmd_set_mplsogre_encap_vlan_value,
15872 (void *)&cmd_set_mplsogre_encap_eth_src,
15873 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15874 (void *)&cmd_set_mplsogre_encap_eth_dst,
15875 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15880 /** Set MPLSoGRE decapsulation details */
15881 struct cmd_set_mplsogre_decap_result {
15882 cmdline_fixed_string_t set;
15883 cmdline_fixed_string_t mplsogre;
15884 cmdline_fixed_string_t pos_token;
15885 cmdline_fixed_string_t ip_version;
15886 uint32_t vlan_present:1;
15889 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
15890 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
15892 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
15893 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
15895 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
15896 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15897 mplsogre, "mplsogre_decap-with-vlan");
15898 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
15899 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15900 pos_token, "ip-version");
15901 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
15902 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15903 ip_version, "ipv4#ipv6");
15905 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
15906 __attribute__((unused)) struct cmdline *cl,
15907 __attribute__((unused)) void *data)
15909 struct cmd_set_mplsogre_decap_result *res = parsed_result;
15911 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
15912 mplsogre_decap_conf.select_vlan = 0;
15913 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
15914 mplsogre_decap_conf.select_vlan = 1;
15915 if (strcmp(res->ip_version, "ipv4") == 0)
15916 mplsogre_decap_conf.select_ipv4 = 1;
15917 else if (strcmp(res->ip_version, "ipv6") == 0)
15918 mplsogre_decap_conf.select_ipv4 = 0;
15921 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
15922 .f = cmd_set_mplsogre_decap_parsed,
15924 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
15926 (void *)&cmd_set_mplsogre_decap_set,
15927 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
15928 (void *)&cmd_set_mplsogre_decap_ip_version,
15929 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15934 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
15935 .f = cmd_set_mplsogre_decap_parsed,
15937 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
15939 (void *)&cmd_set_mplsogre_decap_set,
15940 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
15941 (void *)&cmd_set_mplsogre_decap_ip_version,
15942 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15947 /** Set MPLSoUDP encapsulation details */
15948 struct cmd_set_mplsoudp_encap_result {
15949 cmdline_fixed_string_t set;
15950 cmdline_fixed_string_t mplsoudp;
15951 cmdline_fixed_string_t pos_token;
15952 cmdline_fixed_string_t ip_version;
15953 uint32_t vlan_present:1;
15957 cmdline_ipaddr_t ip_src;
15958 cmdline_ipaddr_t ip_dst;
15960 struct rte_ether_addr eth_src;
15961 struct rte_ether_addr eth_dst;
15964 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
15965 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
15967 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
15968 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
15970 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
15971 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15972 mplsoudp, "mplsoudp_encap-with-vlan");
15973 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
15974 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15975 pos_token, "ip-version");
15976 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
15977 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15978 ip_version, "ipv4#ipv6");
15979 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
15980 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15981 pos_token, "label");
15982 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
15983 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
15985 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
15986 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15987 pos_token, "udp-src");
15988 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
15989 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
15991 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
15992 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15993 pos_token, "udp-dst");
15994 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
15995 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
15997 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
15998 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15999 pos_token, "ip-src");
16000 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16001 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16002 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16003 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16004 pos_token, "ip-dst");
16005 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16006 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16007 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16008 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16009 pos_token, "vlan-tci");
16010 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16011 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16013 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16014 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16015 pos_token, "eth-src");
16016 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16017 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16019 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16020 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16021 pos_token, "eth-dst");
16022 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16023 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16026 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16027 __attribute__((unused)) struct cmdline *cl,
16028 __attribute__((unused)) void *data)
16030 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16032 uint32_t mplsoudp_label;
16035 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16038 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16039 mplsoudp_encap_conf.select_vlan = 0;
16040 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16041 mplsoudp_encap_conf.select_vlan = 1;
16042 if (strcmp(res->ip_version, "ipv4") == 0)
16043 mplsoudp_encap_conf.select_ipv4 = 1;
16044 else if (strcmp(res->ip_version, "ipv6") == 0)
16045 mplsoudp_encap_conf.select_ipv4 = 0;
16048 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16049 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16050 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16051 if (mplsoudp_encap_conf.select_ipv4) {
16052 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16053 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16055 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16056 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16058 if (mplsoudp_encap_conf.select_vlan)
16059 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16060 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16061 RTE_ETHER_ADDR_LEN);
16062 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16063 RTE_ETHER_ADDR_LEN);
16066 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16067 .f = cmd_set_mplsoudp_encap_parsed,
16069 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16070 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16071 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16073 (void *)&cmd_set_mplsoudp_encap_set,
16074 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16075 (void *)&cmd_set_mplsoudp_encap_ip_version,
16076 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16077 (void *)&cmd_set_mplsoudp_encap_label,
16078 (void *)&cmd_set_mplsoudp_encap_label_value,
16079 (void *)&cmd_set_mplsoudp_encap_udp_src,
16080 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16081 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16082 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16083 (void *)&cmd_set_mplsoudp_encap_ip_src,
16084 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16085 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16086 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16087 (void *)&cmd_set_mplsoudp_encap_eth_src,
16088 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16089 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16090 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16095 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16096 .f = cmd_set_mplsoudp_encap_parsed,
16098 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16099 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16100 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16101 " eth-src <eth-src> eth-dst <eth-dst>",
16103 (void *)&cmd_set_mplsoudp_encap_set,
16104 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16105 (void *)&cmd_set_mplsoudp_encap_ip_version,
16106 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16107 (void *)&cmd_set_mplsoudp_encap_label,
16108 (void *)&cmd_set_mplsoudp_encap_label_value,
16109 (void *)&cmd_set_mplsoudp_encap_udp_src,
16110 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16111 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16112 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16113 (void *)&cmd_set_mplsoudp_encap_ip_src,
16114 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16115 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16116 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16117 (void *)&cmd_set_mplsoudp_encap_vlan,
16118 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16119 (void *)&cmd_set_mplsoudp_encap_eth_src,
16120 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16121 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16122 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16127 /** Set MPLSoUDP decapsulation details */
16128 struct cmd_set_mplsoudp_decap_result {
16129 cmdline_fixed_string_t set;
16130 cmdline_fixed_string_t mplsoudp;
16131 cmdline_fixed_string_t pos_token;
16132 cmdline_fixed_string_t ip_version;
16133 uint32_t vlan_present:1;
16136 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16137 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16139 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16140 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16142 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16143 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16144 mplsoudp, "mplsoudp_decap-with-vlan");
16145 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16146 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16147 pos_token, "ip-version");
16148 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16149 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16150 ip_version, "ipv4#ipv6");
16152 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16153 __attribute__((unused)) struct cmdline *cl,
16154 __attribute__((unused)) void *data)
16156 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16158 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16159 mplsoudp_decap_conf.select_vlan = 0;
16160 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16161 mplsoudp_decap_conf.select_vlan = 1;
16162 if (strcmp(res->ip_version, "ipv4") == 0)
16163 mplsoudp_decap_conf.select_ipv4 = 1;
16164 else if (strcmp(res->ip_version, "ipv6") == 0)
16165 mplsoudp_decap_conf.select_ipv4 = 0;
16168 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16169 .f = cmd_set_mplsoudp_decap_parsed,
16171 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16173 (void *)&cmd_set_mplsoudp_decap_set,
16174 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16175 (void *)&cmd_set_mplsoudp_decap_ip_version,
16176 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16181 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16182 .f = cmd_set_mplsoudp_decap_parsed,
16184 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16186 (void *)&cmd_set_mplsoudp_decap_set,
16187 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16188 (void *)&cmd_set_mplsoudp_decap_ip_version,
16189 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16194 /* Strict link priority scheduling mode setting */
16196 cmd_strict_link_prio_parsed(
16197 void *parsed_result,
16198 __attribute__((unused)) struct cmdline *cl,
16199 __attribute__((unused)) void *data)
16201 struct cmd_vf_tc_bw_result *res = parsed_result;
16202 int ret = -ENOTSUP;
16204 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16207 #ifdef RTE_LIBRTE_I40E_PMD
16208 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16215 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16218 printf("invalid port_id %d\n", res->port_id);
16221 printf("function not implemented\n");
16224 printf("programming error: (%s)\n", strerror(-ret));
16228 cmdline_parse_inst_t cmd_strict_link_prio = {
16229 .f = cmd_strict_link_prio_parsed,
16231 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16233 (void *)&cmd_vf_tc_bw_set,
16234 (void *)&cmd_vf_tc_bw_tx,
16235 (void *)&cmd_vf_tc_bw_strict_link_prio,
16236 (void *)&cmd_vf_tc_bw_port_id,
16237 (void *)&cmd_vf_tc_bw_tc_map,
16242 /* Load dynamic device personalization*/
16243 struct cmd_ddp_add_result {
16244 cmdline_fixed_string_t ddp;
16245 cmdline_fixed_string_t add;
16250 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16251 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16252 cmdline_parse_token_string_t cmd_ddp_add_add =
16253 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16254 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16255 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16256 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16257 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16260 cmd_ddp_add_parsed(
16261 void *parsed_result,
16262 __attribute__((unused)) struct cmdline *cl,
16263 __attribute__((unused)) void *data)
16265 struct cmd_ddp_add_result *res = parsed_result;
16271 int ret = -ENOTSUP;
16273 if (!all_ports_stopped()) {
16274 printf("Please stop all ports first\n");
16278 filepath = strdup(res->filepath);
16279 if (filepath == NULL) {
16280 printf("Failed to allocate memory\n");
16283 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16285 buff = open_file(file_fld[0], &size);
16287 free((void *)filepath);
16291 #ifdef RTE_LIBRTE_I40E_PMD
16292 if (ret == -ENOTSUP)
16293 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16295 RTE_PMD_I40E_PKG_OP_WR_ADD);
16298 if (ret == -EEXIST)
16299 printf("Profile has already existed.\n");
16301 printf("Failed to load profile.\n");
16302 else if (file_num == 2)
16303 save_file(file_fld[1], buff, size);
16306 free((void *)filepath);
16309 cmdline_parse_inst_t cmd_ddp_add = {
16310 .f = cmd_ddp_add_parsed,
16312 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16314 (void *)&cmd_ddp_add_ddp,
16315 (void *)&cmd_ddp_add_add,
16316 (void *)&cmd_ddp_add_port_id,
16317 (void *)&cmd_ddp_add_filepath,
16322 /* Delete dynamic device personalization*/
16323 struct cmd_ddp_del_result {
16324 cmdline_fixed_string_t ddp;
16325 cmdline_fixed_string_t del;
16330 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16331 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16332 cmdline_parse_token_string_t cmd_ddp_del_del =
16333 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16334 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16335 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16336 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16337 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16340 cmd_ddp_del_parsed(
16341 void *parsed_result,
16342 __attribute__((unused)) struct cmdline *cl,
16343 __attribute__((unused)) void *data)
16345 struct cmd_ddp_del_result *res = parsed_result;
16348 int ret = -ENOTSUP;
16350 if (!all_ports_stopped()) {
16351 printf("Please stop all ports first\n");
16355 buff = open_file(res->filepath, &size);
16359 #ifdef RTE_LIBRTE_I40E_PMD
16360 if (ret == -ENOTSUP)
16361 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16363 RTE_PMD_I40E_PKG_OP_WR_DEL);
16366 if (ret == -EACCES)
16367 printf("Profile does not exist.\n");
16369 printf("Failed to delete profile.\n");
16374 cmdline_parse_inst_t cmd_ddp_del = {
16375 .f = cmd_ddp_del_parsed,
16377 .help_str = "ddp del <port_id> <backup_profile_path>",
16379 (void *)&cmd_ddp_del_ddp,
16380 (void *)&cmd_ddp_del_del,
16381 (void *)&cmd_ddp_del_port_id,
16382 (void *)&cmd_ddp_del_filepath,
16387 /* Get dynamic device personalization profile info */
16388 struct cmd_ddp_info_result {
16389 cmdline_fixed_string_t ddp;
16390 cmdline_fixed_string_t get;
16391 cmdline_fixed_string_t info;
16395 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16396 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16397 cmdline_parse_token_string_t cmd_ddp_info_get =
16398 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16399 cmdline_parse_token_string_t cmd_ddp_info_info =
16400 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16401 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16402 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16405 cmd_ddp_info_parsed(
16406 void *parsed_result,
16407 __attribute__((unused)) struct cmdline *cl,
16408 __attribute__((unused)) void *data)
16410 struct cmd_ddp_info_result *res = parsed_result;
16413 int ret = -ENOTSUP;
16414 #ifdef RTE_LIBRTE_I40E_PMD
16417 uint32_t buff_size = 0;
16418 struct rte_pmd_i40e_profile_info info;
16419 uint32_t dev_num = 0;
16420 struct rte_pmd_i40e_ddp_device_id *devs;
16421 uint32_t proto_num = 0;
16422 struct rte_pmd_i40e_proto_info *proto = NULL;
16423 uint32_t pctype_num = 0;
16424 struct rte_pmd_i40e_ptype_info *pctype;
16425 uint32_t ptype_num = 0;
16426 struct rte_pmd_i40e_ptype_info *ptype;
16431 pkg = open_file(res->filepath, &pkg_size);
16435 #ifdef RTE_LIBRTE_I40E_PMD
16436 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16437 (uint8_t *)&info, sizeof(info),
16438 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16440 printf("Global Track id: 0x%x\n", info.track_id);
16441 printf("Global Version: %d.%d.%d.%d\n",
16442 info.version.major,
16443 info.version.minor,
16444 info.version.update,
16445 info.version.draft);
16446 printf("Global Package name: %s\n\n", info.name);
16449 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16450 (uint8_t *)&info, sizeof(info),
16451 RTE_PMD_I40E_PKG_INFO_HEADER);
16453 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16454 printf("i40e Profile Version: %d.%d.%d.%d\n",
16455 info.version.major,
16456 info.version.minor,
16457 info.version.update,
16458 info.version.draft);
16459 printf("i40e Profile name: %s\n\n", info.name);
16462 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16463 (uint8_t *)&buff_size, sizeof(buff_size),
16464 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16465 if (!ret && buff_size) {
16466 buff = (uint8_t *)malloc(buff_size);
16468 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16470 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16472 printf("Package Notes:\n%s\n\n", buff);
16477 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16478 (uint8_t *)&dev_num, sizeof(dev_num),
16479 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16480 if (!ret && dev_num) {
16481 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16482 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16484 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16485 (uint8_t *)devs, buff_size,
16486 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16488 printf("List of supported devices:\n");
16489 for (i = 0; i < dev_num; i++) {
16490 printf(" %04X:%04X %04X:%04X\n",
16491 devs[i].vendor_dev_id >> 16,
16492 devs[i].vendor_dev_id & 0xFFFF,
16493 devs[i].sub_vendor_dev_id >> 16,
16494 devs[i].sub_vendor_dev_id & 0xFFFF);
16502 /* get information about protocols and packet types */
16503 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16504 (uint8_t *)&proto_num, sizeof(proto_num),
16505 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16506 if (ret || !proto_num)
16507 goto no_print_return;
16509 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16510 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16512 goto no_print_return;
16514 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16516 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16518 printf("List of used protocols:\n");
16519 for (i = 0; i < proto_num; i++)
16520 printf(" %2u: %s\n", proto[i].proto_id,
16524 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16525 (uint8_t *)&pctype_num, sizeof(pctype_num),
16526 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16527 if (ret || !pctype_num)
16528 goto no_print_pctypes;
16530 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16531 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16533 goto no_print_pctypes;
16535 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16537 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16540 goto no_print_pctypes;
16543 printf("List of defined packet classification types:\n");
16544 for (i = 0; i < pctype_num; i++) {
16545 printf(" %2u:", pctype[i].ptype_id);
16546 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16547 proto_id = pctype[i].protocols[j];
16548 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16549 for (n = 0; n < proto_num; n++) {
16550 if (proto[n].proto_id == proto_id) {
16551 printf(" %s", proto[n].name);
16564 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16566 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16567 if (ret || !ptype_num)
16568 goto no_print_return;
16570 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16571 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16573 goto no_print_return;
16575 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16577 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16580 goto no_print_return;
16582 printf("List of defined packet types:\n");
16583 for (i = 0; i < ptype_num; i++) {
16584 printf(" %2u:", ptype[i].ptype_id);
16585 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16586 proto_id = ptype[i].protocols[j];
16587 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16588 for (n = 0; n < proto_num; n++) {
16589 if (proto[n].proto_id == proto_id) {
16590 printf(" %s", proto[n].name);
16606 if (ret == -ENOTSUP)
16607 printf("Function not supported in PMD driver\n");
16611 cmdline_parse_inst_t cmd_ddp_get_info = {
16612 .f = cmd_ddp_info_parsed,
16614 .help_str = "ddp get info <profile_path>",
16616 (void *)&cmd_ddp_info_ddp,
16617 (void *)&cmd_ddp_info_get,
16618 (void *)&cmd_ddp_info_info,
16619 (void *)&cmd_ddp_info_filepath,
16624 /* Get dynamic device personalization profile info list*/
16625 #define PROFILE_INFO_SIZE 48
16626 #define MAX_PROFILE_NUM 16
16628 struct cmd_ddp_get_list_result {
16629 cmdline_fixed_string_t ddp;
16630 cmdline_fixed_string_t get;
16631 cmdline_fixed_string_t list;
16635 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16636 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16637 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16638 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16639 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16640 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16641 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16642 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16645 cmd_ddp_get_list_parsed(
16646 __attribute__((unused)) void *parsed_result,
16647 __attribute__((unused)) struct cmdline *cl,
16648 __attribute__((unused)) void *data)
16650 #ifdef RTE_LIBRTE_I40E_PMD
16651 struct cmd_ddp_get_list_result *res = parsed_result;
16652 struct rte_pmd_i40e_profile_list *p_list;
16653 struct rte_pmd_i40e_profile_info *p_info;
16658 int ret = -ENOTSUP;
16660 #ifdef RTE_LIBRTE_I40E_PMD
16661 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16662 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16664 printf("%s: Failed to malloc buffer\n", __func__);
16666 if (ret == -ENOTSUP)
16667 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16668 (uint8_t *)p_list, size);
16671 p_num = p_list->p_count;
16672 printf("Profile number is: %d\n\n", p_num);
16674 for (i = 0; i < p_num; i++) {
16675 p_info = &p_list->p_info[i];
16676 printf("Profile %d:\n", i);
16677 printf("Track id: 0x%x\n", p_info->track_id);
16678 printf("Version: %d.%d.%d.%d\n",
16679 p_info->version.major,
16680 p_info->version.minor,
16681 p_info->version.update,
16682 p_info->version.draft);
16683 printf("Profile name: %s\n\n", p_info->name);
16691 printf("Failed to get ddp list\n");
16694 cmdline_parse_inst_t cmd_ddp_get_list = {
16695 .f = cmd_ddp_get_list_parsed,
16697 .help_str = "ddp get list <port_id>",
16699 (void *)&cmd_ddp_get_list_ddp,
16700 (void *)&cmd_ddp_get_list_get,
16701 (void *)&cmd_ddp_get_list_list,
16702 (void *)&cmd_ddp_get_list_port_id,
16707 /* Configure input set */
16708 struct cmd_cfg_input_set_result {
16709 cmdline_fixed_string_t port;
16710 cmdline_fixed_string_t cfg;
16712 cmdline_fixed_string_t pctype;
16714 cmdline_fixed_string_t inset_type;
16715 cmdline_fixed_string_t opt;
16716 cmdline_fixed_string_t field;
16721 cmd_cfg_input_set_parsed(
16722 __attribute__((unused)) void *parsed_result,
16723 __attribute__((unused)) struct cmdline *cl,
16724 __attribute__((unused)) void *data)
16726 #ifdef RTE_LIBRTE_I40E_PMD
16727 struct cmd_cfg_input_set_result *res = parsed_result;
16728 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16729 struct rte_pmd_i40e_inset inset;
16731 int ret = -ENOTSUP;
16733 if (!all_ports_stopped()) {
16734 printf("Please stop all ports first\n");
16738 #ifdef RTE_LIBRTE_I40E_PMD
16739 if (!strcmp(res->inset_type, "hash_inset"))
16740 inset_type = INSET_HASH;
16741 else if (!strcmp(res->inset_type, "fdir_inset"))
16742 inset_type = INSET_FDIR;
16743 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16744 inset_type = INSET_FDIR_FLX;
16745 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16746 &inset, inset_type);
16748 printf("Failed to get input set.\n");
16752 if (!strcmp(res->opt, "get")) {
16753 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16756 printf("Field index %d is enabled.\n", res->field_idx);
16758 printf("Field index %d is disabled.\n", res->field_idx);
16760 } else if (!strcmp(res->opt, "set"))
16761 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16763 else if (!strcmp(res->opt, "clear"))
16764 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16767 printf("Failed to configure input set field.\n");
16771 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16772 &inset, inset_type);
16774 printf("Failed to set input set.\n");
16779 if (ret == -ENOTSUP)
16780 printf("Function not supported\n");
16783 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16784 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16786 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16787 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16789 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16790 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16792 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16793 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16795 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16796 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16798 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16799 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16801 "hash_inset#fdir_inset#fdir_flx_inset");
16802 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16803 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16804 opt, "get#set#clear");
16805 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16806 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16808 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16809 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16812 cmdline_parse_inst_t cmd_cfg_input_set = {
16813 .f = cmd_cfg_input_set_parsed,
16815 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16816 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16818 (void *)&cmd_cfg_input_set_port,
16819 (void *)&cmd_cfg_input_set_cfg,
16820 (void *)&cmd_cfg_input_set_port_id,
16821 (void *)&cmd_cfg_input_set_pctype,
16822 (void *)&cmd_cfg_input_set_pctype_id,
16823 (void *)&cmd_cfg_input_set_inset_type,
16824 (void *)&cmd_cfg_input_set_opt,
16825 (void *)&cmd_cfg_input_set_field,
16826 (void *)&cmd_cfg_input_set_field_idx,
16831 /* Clear input set */
16832 struct cmd_clear_input_set_result {
16833 cmdline_fixed_string_t port;
16834 cmdline_fixed_string_t cfg;
16836 cmdline_fixed_string_t pctype;
16838 cmdline_fixed_string_t inset_type;
16839 cmdline_fixed_string_t clear;
16840 cmdline_fixed_string_t all;
16844 cmd_clear_input_set_parsed(
16845 __attribute__((unused)) void *parsed_result,
16846 __attribute__((unused)) struct cmdline *cl,
16847 __attribute__((unused)) void *data)
16849 #ifdef RTE_LIBRTE_I40E_PMD
16850 struct cmd_clear_input_set_result *res = parsed_result;
16851 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16852 struct rte_pmd_i40e_inset inset;
16854 int ret = -ENOTSUP;
16856 if (!all_ports_stopped()) {
16857 printf("Please stop all ports first\n");
16861 #ifdef RTE_LIBRTE_I40E_PMD
16862 if (!strcmp(res->inset_type, "hash_inset"))
16863 inset_type = INSET_HASH;
16864 else if (!strcmp(res->inset_type, "fdir_inset"))
16865 inset_type = INSET_FDIR;
16866 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16867 inset_type = INSET_FDIR_FLX;
16869 memset(&inset, 0, sizeof(inset));
16871 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16872 &inset, inset_type);
16874 printf("Failed to clear input set.\n");
16880 if (ret == -ENOTSUP)
16881 printf("Function not supported\n");
16884 cmdline_parse_token_string_t cmd_clear_input_set_port =
16885 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16887 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
16888 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16890 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
16891 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16893 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
16894 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16896 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
16897 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16899 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
16900 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16902 "hash_inset#fdir_inset#fdir_flx_inset");
16903 cmdline_parse_token_string_t cmd_clear_input_set_clear =
16904 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16906 cmdline_parse_token_string_t cmd_clear_input_set_all =
16907 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16910 cmdline_parse_inst_t cmd_clear_input_set = {
16911 .f = cmd_clear_input_set_parsed,
16913 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16914 "fdir_inset|fdir_flx_inset clear all",
16916 (void *)&cmd_clear_input_set_port,
16917 (void *)&cmd_clear_input_set_cfg,
16918 (void *)&cmd_clear_input_set_port_id,
16919 (void *)&cmd_clear_input_set_pctype,
16920 (void *)&cmd_clear_input_set_pctype_id,
16921 (void *)&cmd_clear_input_set_inset_type,
16922 (void *)&cmd_clear_input_set_clear,
16923 (void *)&cmd_clear_input_set_all,
16928 /* show vf stats */
16930 /* Common result structure for show vf stats */
16931 struct cmd_show_vf_stats_result {
16932 cmdline_fixed_string_t show;
16933 cmdline_fixed_string_t vf;
16934 cmdline_fixed_string_t stats;
16939 /* Common CLI fields show vf stats*/
16940 cmdline_parse_token_string_t cmd_show_vf_stats_show =
16941 TOKEN_STRING_INITIALIZER
16942 (struct cmd_show_vf_stats_result,
16944 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
16945 TOKEN_STRING_INITIALIZER
16946 (struct cmd_show_vf_stats_result,
16948 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
16949 TOKEN_STRING_INITIALIZER
16950 (struct cmd_show_vf_stats_result,
16952 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
16953 TOKEN_NUM_INITIALIZER
16954 (struct cmd_show_vf_stats_result,
16956 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
16957 TOKEN_NUM_INITIALIZER
16958 (struct cmd_show_vf_stats_result,
16962 cmd_show_vf_stats_parsed(
16963 void *parsed_result,
16964 __attribute__((unused)) struct cmdline *cl,
16965 __attribute__((unused)) void *data)
16967 struct cmd_show_vf_stats_result *res = parsed_result;
16968 struct rte_eth_stats stats;
16969 int ret = -ENOTSUP;
16970 static const char *nic_stats_border = "########################";
16972 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16975 memset(&stats, 0, sizeof(stats));
16977 #ifdef RTE_LIBRTE_I40E_PMD
16978 if (ret == -ENOTSUP)
16979 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
16983 #ifdef RTE_LIBRTE_BNXT_PMD
16984 if (ret == -ENOTSUP)
16985 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
16994 printf("invalid vf_id %d\n", res->vf_id);
16997 printf("invalid port_id %d\n", res->port_id);
17000 printf("function not implemented\n");
17003 printf("programming error: (%s)\n", strerror(-ret));
17006 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17007 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17009 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17011 stats.ipackets, stats.imissed, stats.ibytes);
17012 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17013 printf(" RX-nombuf: %-10"PRIu64"\n",
17015 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17017 stats.opackets, stats.oerrors, stats.obytes);
17019 printf(" %s############################%s\n",
17020 nic_stats_border, nic_stats_border);
17023 cmdline_parse_inst_t cmd_show_vf_stats = {
17024 .f = cmd_show_vf_stats_parsed,
17026 .help_str = "show vf stats <port_id> <vf_id>",
17028 (void *)&cmd_show_vf_stats_show,
17029 (void *)&cmd_show_vf_stats_vf,
17030 (void *)&cmd_show_vf_stats_stats,
17031 (void *)&cmd_show_vf_stats_port_id,
17032 (void *)&cmd_show_vf_stats_vf_id,
17037 /* clear vf stats */
17039 /* Common result structure for clear vf stats */
17040 struct cmd_clear_vf_stats_result {
17041 cmdline_fixed_string_t clear;
17042 cmdline_fixed_string_t vf;
17043 cmdline_fixed_string_t stats;
17048 /* Common CLI fields clear vf stats*/
17049 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17050 TOKEN_STRING_INITIALIZER
17051 (struct cmd_clear_vf_stats_result,
17053 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17054 TOKEN_STRING_INITIALIZER
17055 (struct cmd_clear_vf_stats_result,
17057 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17058 TOKEN_STRING_INITIALIZER
17059 (struct cmd_clear_vf_stats_result,
17061 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17062 TOKEN_NUM_INITIALIZER
17063 (struct cmd_clear_vf_stats_result,
17065 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17066 TOKEN_NUM_INITIALIZER
17067 (struct cmd_clear_vf_stats_result,
17071 cmd_clear_vf_stats_parsed(
17072 void *parsed_result,
17073 __attribute__((unused)) struct cmdline *cl,
17074 __attribute__((unused)) void *data)
17076 struct cmd_clear_vf_stats_result *res = parsed_result;
17077 int ret = -ENOTSUP;
17079 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17082 #ifdef RTE_LIBRTE_I40E_PMD
17083 if (ret == -ENOTSUP)
17084 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17087 #ifdef RTE_LIBRTE_BNXT_PMD
17088 if (ret == -ENOTSUP)
17089 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17097 printf("invalid vf_id %d\n", res->vf_id);
17100 printf("invalid port_id %d\n", res->port_id);
17103 printf("function not implemented\n");
17106 printf("programming error: (%s)\n", strerror(-ret));
17110 cmdline_parse_inst_t cmd_clear_vf_stats = {
17111 .f = cmd_clear_vf_stats_parsed,
17113 .help_str = "clear vf stats <port_id> <vf_id>",
17115 (void *)&cmd_clear_vf_stats_clear,
17116 (void *)&cmd_clear_vf_stats_vf,
17117 (void *)&cmd_clear_vf_stats_stats,
17118 (void *)&cmd_clear_vf_stats_port_id,
17119 (void *)&cmd_clear_vf_stats_vf_id,
17124 /* port config pctype mapping reset */
17126 /* Common result structure for port config pctype mapping reset */
17127 struct cmd_pctype_mapping_reset_result {
17128 cmdline_fixed_string_t port;
17129 cmdline_fixed_string_t config;
17131 cmdline_fixed_string_t pctype;
17132 cmdline_fixed_string_t mapping;
17133 cmdline_fixed_string_t reset;
17136 /* Common CLI fields for port config pctype mapping reset*/
17137 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17138 TOKEN_STRING_INITIALIZER
17139 (struct cmd_pctype_mapping_reset_result,
17141 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17142 TOKEN_STRING_INITIALIZER
17143 (struct cmd_pctype_mapping_reset_result,
17145 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17146 TOKEN_NUM_INITIALIZER
17147 (struct cmd_pctype_mapping_reset_result,
17149 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17150 TOKEN_STRING_INITIALIZER
17151 (struct cmd_pctype_mapping_reset_result,
17153 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17154 TOKEN_STRING_INITIALIZER
17155 (struct cmd_pctype_mapping_reset_result,
17156 mapping, "mapping");
17157 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17158 TOKEN_STRING_INITIALIZER
17159 (struct cmd_pctype_mapping_reset_result,
17163 cmd_pctype_mapping_reset_parsed(
17164 void *parsed_result,
17165 __attribute__((unused)) struct cmdline *cl,
17166 __attribute__((unused)) void *data)
17168 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17169 int ret = -ENOTSUP;
17171 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17174 #ifdef RTE_LIBRTE_I40E_PMD
17175 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17182 printf("invalid port_id %d\n", res->port_id);
17185 printf("function not implemented\n");
17188 printf("programming error: (%s)\n", strerror(-ret));
17192 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17193 .f = cmd_pctype_mapping_reset_parsed,
17195 .help_str = "port config <port_id> pctype mapping reset",
17197 (void *)&cmd_pctype_mapping_reset_port,
17198 (void *)&cmd_pctype_mapping_reset_config,
17199 (void *)&cmd_pctype_mapping_reset_port_id,
17200 (void *)&cmd_pctype_mapping_reset_pctype,
17201 (void *)&cmd_pctype_mapping_reset_mapping,
17202 (void *)&cmd_pctype_mapping_reset_reset,
17207 /* show port pctype mapping */
17209 /* Common result structure for show port pctype mapping */
17210 struct cmd_pctype_mapping_get_result {
17211 cmdline_fixed_string_t show;
17212 cmdline_fixed_string_t port;
17214 cmdline_fixed_string_t pctype;
17215 cmdline_fixed_string_t mapping;
17218 /* Common CLI fields for pctype mapping get */
17219 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17220 TOKEN_STRING_INITIALIZER
17221 (struct cmd_pctype_mapping_get_result,
17223 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17224 TOKEN_STRING_INITIALIZER
17225 (struct cmd_pctype_mapping_get_result,
17227 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17228 TOKEN_NUM_INITIALIZER
17229 (struct cmd_pctype_mapping_get_result,
17231 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17232 TOKEN_STRING_INITIALIZER
17233 (struct cmd_pctype_mapping_get_result,
17235 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17236 TOKEN_STRING_INITIALIZER
17237 (struct cmd_pctype_mapping_get_result,
17238 mapping, "mapping");
17241 cmd_pctype_mapping_get_parsed(
17242 void *parsed_result,
17243 __attribute__((unused)) struct cmdline *cl,
17244 __attribute__((unused)) void *data)
17246 struct cmd_pctype_mapping_get_result *res = parsed_result;
17247 int ret = -ENOTSUP;
17248 #ifdef RTE_LIBRTE_I40E_PMD
17249 struct rte_pmd_i40e_flow_type_mapping
17250 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17251 int i, j, first_pctype;
17254 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17257 #ifdef RTE_LIBRTE_I40E_PMD
17258 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17265 printf("invalid port_id %d\n", res->port_id);
17268 printf("function not implemented\n");
17271 printf("programming error: (%s)\n", strerror(-ret));
17275 #ifdef RTE_LIBRTE_I40E_PMD
17276 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17277 if (mapping[i].pctype != 0ULL) {
17280 printf("pctype: ");
17281 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17282 if (mapping[i].pctype & (1ULL << j)) {
17283 printf(first_pctype ?
17284 "%02d" : ",%02d", j);
17288 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17294 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17295 .f = cmd_pctype_mapping_get_parsed,
17297 .help_str = "show port <port_id> pctype mapping",
17299 (void *)&cmd_pctype_mapping_get_show,
17300 (void *)&cmd_pctype_mapping_get_port,
17301 (void *)&cmd_pctype_mapping_get_port_id,
17302 (void *)&cmd_pctype_mapping_get_pctype,
17303 (void *)&cmd_pctype_mapping_get_mapping,
17308 /* port config pctype mapping update */
17310 /* Common result structure for port config pctype mapping update */
17311 struct cmd_pctype_mapping_update_result {
17312 cmdline_fixed_string_t port;
17313 cmdline_fixed_string_t config;
17315 cmdline_fixed_string_t pctype;
17316 cmdline_fixed_string_t mapping;
17317 cmdline_fixed_string_t update;
17318 cmdline_fixed_string_t pctype_list;
17319 uint16_t flow_type;
17322 /* Common CLI fields for pctype mapping update*/
17323 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17324 TOKEN_STRING_INITIALIZER
17325 (struct cmd_pctype_mapping_update_result,
17327 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17328 TOKEN_STRING_INITIALIZER
17329 (struct cmd_pctype_mapping_update_result,
17331 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17332 TOKEN_NUM_INITIALIZER
17333 (struct cmd_pctype_mapping_update_result,
17335 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17336 TOKEN_STRING_INITIALIZER
17337 (struct cmd_pctype_mapping_update_result,
17339 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17340 TOKEN_STRING_INITIALIZER
17341 (struct cmd_pctype_mapping_update_result,
17342 mapping, "mapping");
17343 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17344 TOKEN_STRING_INITIALIZER
17345 (struct cmd_pctype_mapping_update_result,
17347 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17348 TOKEN_STRING_INITIALIZER
17349 (struct cmd_pctype_mapping_update_result,
17350 pctype_list, NULL);
17351 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17352 TOKEN_NUM_INITIALIZER
17353 (struct cmd_pctype_mapping_update_result,
17354 flow_type, UINT16);
17357 cmd_pctype_mapping_update_parsed(
17358 void *parsed_result,
17359 __attribute__((unused)) struct cmdline *cl,
17360 __attribute__((unused)) void *data)
17362 struct cmd_pctype_mapping_update_result *res = parsed_result;
17363 int ret = -ENOTSUP;
17364 #ifdef RTE_LIBRTE_I40E_PMD
17365 struct rte_pmd_i40e_flow_type_mapping mapping;
17367 unsigned int nb_item;
17368 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17371 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17374 #ifdef RTE_LIBRTE_I40E_PMD
17375 nb_item = parse_item_list(res->pctype_list, "pctypes",
17376 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17377 mapping.flow_type = res->flow_type;
17378 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17379 mapping.pctype |= (1ULL << pctype_list[i]);
17380 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17390 printf("invalid pctype or flow type\n");
17393 printf("invalid port_id %d\n", res->port_id);
17396 printf("function not implemented\n");
17399 printf("programming error: (%s)\n", strerror(-ret));
17403 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17404 .f = cmd_pctype_mapping_update_parsed,
17406 .help_str = "port config <port_id> pctype mapping update"
17407 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17409 (void *)&cmd_pctype_mapping_update_port,
17410 (void *)&cmd_pctype_mapping_update_config,
17411 (void *)&cmd_pctype_mapping_update_port_id,
17412 (void *)&cmd_pctype_mapping_update_pctype,
17413 (void *)&cmd_pctype_mapping_update_mapping,
17414 (void *)&cmd_pctype_mapping_update_update,
17415 (void *)&cmd_pctype_mapping_update_pc_type,
17416 (void *)&cmd_pctype_mapping_update_flow_type,
17421 /* ptype mapping get */
17423 /* Common result structure for ptype mapping get */
17424 struct cmd_ptype_mapping_get_result {
17425 cmdline_fixed_string_t ptype;
17426 cmdline_fixed_string_t mapping;
17427 cmdline_fixed_string_t get;
17429 uint8_t valid_only;
17432 /* Common CLI fields for ptype mapping get */
17433 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17434 TOKEN_STRING_INITIALIZER
17435 (struct cmd_ptype_mapping_get_result,
17437 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17438 TOKEN_STRING_INITIALIZER
17439 (struct cmd_ptype_mapping_get_result,
17440 mapping, "mapping");
17441 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17442 TOKEN_STRING_INITIALIZER
17443 (struct cmd_ptype_mapping_get_result,
17445 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17446 TOKEN_NUM_INITIALIZER
17447 (struct cmd_ptype_mapping_get_result,
17449 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17450 TOKEN_NUM_INITIALIZER
17451 (struct cmd_ptype_mapping_get_result,
17452 valid_only, UINT8);
17455 cmd_ptype_mapping_get_parsed(
17456 void *parsed_result,
17457 __attribute__((unused)) struct cmdline *cl,
17458 __attribute__((unused)) void *data)
17460 struct cmd_ptype_mapping_get_result *res = parsed_result;
17461 int ret = -ENOTSUP;
17462 #ifdef RTE_LIBRTE_I40E_PMD
17463 int max_ptype_num = 256;
17464 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17469 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17472 #ifdef RTE_LIBRTE_I40E_PMD
17473 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17484 printf("invalid port_id %d\n", res->port_id);
17487 printf("function not implemented\n");
17490 printf("programming error: (%s)\n", strerror(-ret));
17493 #ifdef RTE_LIBRTE_I40E_PMD
17495 for (i = 0; i < count; i++)
17496 printf("%3d\t0x%08x\n",
17497 mapping[i].hw_ptype, mapping[i].sw_ptype);
17502 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17503 .f = cmd_ptype_mapping_get_parsed,
17505 .help_str = "ptype mapping get <port_id> <valid_only>",
17507 (void *)&cmd_ptype_mapping_get_ptype,
17508 (void *)&cmd_ptype_mapping_get_mapping,
17509 (void *)&cmd_ptype_mapping_get_get,
17510 (void *)&cmd_ptype_mapping_get_port_id,
17511 (void *)&cmd_ptype_mapping_get_valid_only,
17516 /* ptype mapping replace */
17518 /* Common result structure for ptype mapping replace */
17519 struct cmd_ptype_mapping_replace_result {
17520 cmdline_fixed_string_t ptype;
17521 cmdline_fixed_string_t mapping;
17522 cmdline_fixed_string_t replace;
17529 /* Common CLI fields for ptype mapping replace */
17530 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17531 TOKEN_STRING_INITIALIZER
17532 (struct cmd_ptype_mapping_replace_result,
17534 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17535 TOKEN_STRING_INITIALIZER
17536 (struct cmd_ptype_mapping_replace_result,
17537 mapping, "mapping");
17538 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17539 TOKEN_STRING_INITIALIZER
17540 (struct cmd_ptype_mapping_replace_result,
17541 replace, "replace");
17542 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17543 TOKEN_NUM_INITIALIZER
17544 (struct cmd_ptype_mapping_replace_result,
17546 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17547 TOKEN_NUM_INITIALIZER
17548 (struct cmd_ptype_mapping_replace_result,
17550 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17551 TOKEN_NUM_INITIALIZER
17552 (struct cmd_ptype_mapping_replace_result,
17554 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17555 TOKEN_NUM_INITIALIZER
17556 (struct cmd_ptype_mapping_replace_result,
17560 cmd_ptype_mapping_replace_parsed(
17561 void *parsed_result,
17562 __attribute__((unused)) struct cmdline *cl,
17563 __attribute__((unused)) void *data)
17565 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17566 int ret = -ENOTSUP;
17568 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17571 #ifdef RTE_LIBRTE_I40E_PMD
17572 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17582 printf("invalid ptype 0x%8x or 0x%8x\n",
17583 res->target, res->pkt_type);
17586 printf("invalid port_id %d\n", res->port_id);
17589 printf("function not implemented\n");
17592 printf("programming error: (%s)\n", strerror(-ret));
17596 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17597 .f = cmd_ptype_mapping_replace_parsed,
17600 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17602 (void *)&cmd_ptype_mapping_replace_ptype,
17603 (void *)&cmd_ptype_mapping_replace_mapping,
17604 (void *)&cmd_ptype_mapping_replace_replace,
17605 (void *)&cmd_ptype_mapping_replace_port_id,
17606 (void *)&cmd_ptype_mapping_replace_target,
17607 (void *)&cmd_ptype_mapping_replace_mask,
17608 (void *)&cmd_ptype_mapping_replace_pkt_type,
17613 /* ptype mapping reset */
17615 /* Common result structure for ptype mapping reset */
17616 struct cmd_ptype_mapping_reset_result {
17617 cmdline_fixed_string_t ptype;
17618 cmdline_fixed_string_t mapping;
17619 cmdline_fixed_string_t reset;
17623 /* Common CLI fields for ptype mapping reset*/
17624 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17625 TOKEN_STRING_INITIALIZER
17626 (struct cmd_ptype_mapping_reset_result,
17628 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17629 TOKEN_STRING_INITIALIZER
17630 (struct cmd_ptype_mapping_reset_result,
17631 mapping, "mapping");
17632 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17633 TOKEN_STRING_INITIALIZER
17634 (struct cmd_ptype_mapping_reset_result,
17636 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17637 TOKEN_NUM_INITIALIZER
17638 (struct cmd_ptype_mapping_reset_result,
17642 cmd_ptype_mapping_reset_parsed(
17643 void *parsed_result,
17644 __attribute__((unused)) struct cmdline *cl,
17645 __attribute__((unused)) void *data)
17647 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17648 int ret = -ENOTSUP;
17650 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17653 #ifdef RTE_LIBRTE_I40E_PMD
17654 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17661 printf("invalid port_id %d\n", res->port_id);
17664 printf("function not implemented\n");
17667 printf("programming error: (%s)\n", strerror(-ret));
17671 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17672 .f = cmd_ptype_mapping_reset_parsed,
17674 .help_str = "ptype mapping reset <port_id>",
17676 (void *)&cmd_ptype_mapping_reset_ptype,
17677 (void *)&cmd_ptype_mapping_reset_mapping,
17678 (void *)&cmd_ptype_mapping_reset_reset,
17679 (void *)&cmd_ptype_mapping_reset_port_id,
17684 /* ptype mapping update */
17686 /* Common result structure for ptype mapping update */
17687 struct cmd_ptype_mapping_update_result {
17688 cmdline_fixed_string_t ptype;
17689 cmdline_fixed_string_t mapping;
17690 cmdline_fixed_string_t reset;
17696 /* Common CLI fields for ptype mapping update*/
17697 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17698 TOKEN_STRING_INITIALIZER
17699 (struct cmd_ptype_mapping_update_result,
17701 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17702 TOKEN_STRING_INITIALIZER
17703 (struct cmd_ptype_mapping_update_result,
17704 mapping, "mapping");
17705 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17706 TOKEN_STRING_INITIALIZER
17707 (struct cmd_ptype_mapping_update_result,
17709 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17710 TOKEN_NUM_INITIALIZER
17711 (struct cmd_ptype_mapping_update_result,
17713 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17714 TOKEN_NUM_INITIALIZER
17715 (struct cmd_ptype_mapping_update_result,
17717 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17718 TOKEN_NUM_INITIALIZER
17719 (struct cmd_ptype_mapping_update_result,
17723 cmd_ptype_mapping_update_parsed(
17724 void *parsed_result,
17725 __attribute__((unused)) struct cmdline *cl,
17726 __attribute__((unused)) void *data)
17728 struct cmd_ptype_mapping_update_result *res = parsed_result;
17729 int ret = -ENOTSUP;
17730 #ifdef RTE_LIBRTE_I40E_PMD
17731 struct rte_pmd_i40e_ptype_mapping mapping;
17733 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17736 #ifdef RTE_LIBRTE_I40E_PMD
17737 mapping.hw_ptype = res->hw_ptype;
17738 mapping.sw_ptype = res->sw_ptype;
17739 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17749 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17752 printf("invalid port_id %d\n", res->port_id);
17755 printf("function not implemented\n");
17758 printf("programming error: (%s)\n", strerror(-ret));
17762 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17763 .f = cmd_ptype_mapping_update_parsed,
17765 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17767 (void *)&cmd_ptype_mapping_update_ptype,
17768 (void *)&cmd_ptype_mapping_update_mapping,
17769 (void *)&cmd_ptype_mapping_update_update,
17770 (void *)&cmd_ptype_mapping_update_port_id,
17771 (void *)&cmd_ptype_mapping_update_hw_ptype,
17772 (void *)&cmd_ptype_mapping_update_sw_ptype,
17777 /* Common result structure for file commands */
17778 struct cmd_cmdfile_result {
17779 cmdline_fixed_string_t load;
17780 cmdline_fixed_string_t filename;
17783 /* Common CLI fields for file commands */
17784 cmdline_parse_token_string_t cmd_load_cmdfile =
17785 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17786 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17787 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17790 cmd_load_from_file_parsed(
17791 void *parsed_result,
17792 __attribute__((unused)) struct cmdline *cl,
17793 __attribute__((unused)) void *data)
17795 struct cmd_cmdfile_result *res = parsed_result;
17797 cmdline_read_from_file(res->filename);
17800 cmdline_parse_inst_t cmd_load_from_file = {
17801 .f = cmd_load_from_file_parsed,
17803 .help_str = "load <filename>",
17805 (void *)&cmd_load_cmdfile,
17806 (void *)&cmd_load_cmdfile_filename,
17811 /* Get Rx offloads capabilities */
17812 struct cmd_rx_offload_get_capa_result {
17813 cmdline_fixed_string_t show;
17814 cmdline_fixed_string_t port;
17816 cmdline_fixed_string_t rx_offload;
17817 cmdline_fixed_string_t capabilities;
17820 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17821 TOKEN_STRING_INITIALIZER
17822 (struct cmd_rx_offload_get_capa_result,
17824 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17825 TOKEN_STRING_INITIALIZER
17826 (struct cmd_rx_offload_get_capa_result,
17828 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17829 TOKEN_NUM_INITIALIZER
17830 (struct cmd_rx_offload_get_capa_result,
17832 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17833 TOKEN_STRING_INITIALIZER
17834 (struct cmd_rx_offload_get_capa_result,
17835 rx_offload, "rx_offload");
17836 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17837 TOKEN_STRING_INITIALIZER
17838 (struct cmd_rx_offload_get_capa_result,
17839 capabilities, "capabilities");
17842 print_rx_offloads(uint64_t offloads)
17844 uint64_t single_offload;
17852 begin = __builtin_ctzll(offloads);
17853 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17855 single_offload = 1ULL << begin;
17856 for (bit = begin; bit < end; bit++) {
17857 if (offloads & single_offload)
17859 rte_eth_dev_rx_offload_name(single_offload));
17860 single_offload <<= 1;
17865 cmd_rx_offload_get_capa_parsed(
17866 void *parsed_result,
17867 __attribute__((unused)) struct cmdline *cl,
17868 __attribute__((unused)) void *data)
17870 struct cmd_rx_offload_get_capa_result *res = parsed_result;
17871 struct rte_eth_dev_info dev_info;
17872 portid_t port_id = res->port_id;
17873 uint64_t queue_offloads;
17874 uint64_t port_offloads;
17876 rte_eth_dev_info_get(port_id, &dev_info);
17877 queue_offloads = dev_info.rx_queue_offload_capa;
17878 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
17880 printf("Rx Offloading Capabilities of port %d :\n", port_id);
17881 printf(" Per Queue :");
17882 print_rx_offloads(queue_offloads);
17885 printf(" Per Port :");
17886 print_rx_offloads(port_offloads);
17890 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
17891 .f = cmd_rx_offload_get_capa_parsed,
17893 .help_str = "show port <port_id> rx_offload capabilities",
17895 (void *)&cmd_rx_offload_get_capa_show,
17896 (void *)&cmd_rx_offload_get_capa_port,
17897 (void *)&cmd_rx_offload_get_capa_port_id,
17898 (void *)&cmd_rx_offload_get_capa_rx_offload,
17899 (void *)&cmd_rx_offload_get_capa_capabilities,
17904 /* Get Rx offloads configuration */
17905 struct cmd_rx_offload_get_configuration_result {
17906 cmdline_fixed_string_t show;
17907 cmdline_fixed_string_t port;
17909 cmdline_fixed_string_t rx_offload;
17910 cmdline_fixed_string_t configuration;
17913 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
17914 TOKEN_STRING_INITIALIZER
17915 (struct cmd_rx_offload_get_configuration_result,
17917 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
17918 TOKEN_STRING_INITIALIZER
17919 (struct cmd_rx_offload_get_configuration_result,
17921 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
17922 TOKEN_NUM_INITIALIZER
17923 (struct cmd_rx_offload_get_configuration_result,
17925 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
17926 TOKEN_STRING_INITIALIZER
17927 (struct cmd_rx_offload_get_configuration_result,
17928 rx_offload, "rx_offload");
17929 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
17930 TOKEN_STRING_INITIALIZER
17931 (struct cmd_rx_offload_get_configuration_result,
17932 configuration, "configuration");
17935 cmd_rx_offload_get_configuration_parsed(
17936 void *parsed_result,
17937 __attribute__((unused)) struct cmdline *cl,
17938 __attribute__((unused)) void *data)
17940 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
17941 struct rte_eth_dev_info dev_info;
17942 portid_t port_id = res->port_id;
17943 struct rte_port *port = &ports[port_id];
17944 uint64_t port_offloads;
17945 uint64_t queue_offloads;
17946 uint16_t nb_rx_queues;
17949 printf("Rx Offloading Configuration of port %d :\n", port_id);
17951 port_offloads = port->dev_conf.rxmode.offloads;
17953 print_rx_offloads(port_offloads);
17956 rte_eth_dev_info_get(port_id, &dev_info);
17957 nb_rx_queues = dev_info.nb_rx_queues;
17958 for (q = 0; q < nb_rx_queues; q++) {
17959 queue_offloads = port->rx_conf[q].offloads;
17960 printf(" Queue[%2d] :", q);
17961 print_rx_offloads(queue_offloads);
17967 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
17968 .f = cmd_rx_offload_get_configuration_parsed,
17970 .help_str = "show port <port_id> rx_offload configuration",
17972 (void *)&cmd_rx_offload_get_configuration_show,
17973 (void *)&cmd_rx_offload_get_configuration_port,
17974 (void *)&cmd_rx_offload_get_configuration_port_id,
17975 (void *)&cmd_rx_offload_get_configuration_rx_offload,
17976 (void *)&cmd_rx_offload_get_configuration_configuration,
17981 /* Enable/Disable a per port offloading */
17982 struct cmd_config_per_port_rx_offload_result {
17983 cmdline_fixed_string_t port;
17984 cmdline_fixed_string_t config;
17986 cmdline_fixed_string_t rx_offload;
17987 cmdline_fixed_string_t offload;
17988 cmdline_fixed_string_t on_off;
17991 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
17992 TOKEN_STRING_INITIALIZER
17993 (struct cmd_config_per_port_rx_offload_result,
17995 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
17996 TOKEN_STRING_INITIALIZER
17997 (struct cmd_config_per_port_rx_offload_result,
17999 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18000 TOKEN_NUM_INITIALIZER
18001 (struct cmd_config_per_port_rx_offload_result,
18003 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18004 TOKEN_STRING_INITIALIZER
18005 (struct cmd_config_per_port_rx_offload_result,
18006 rx_offload, "rx_offload");
18007 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18008 TOKEN_STRING_INITIALIZER
18009 (struct cmd_config_per_port_rx_offload_result,
18010 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18011 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18012 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18013 "crc_strip#scatter#timestamp#security#keep_crc");
18014 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18015 TOKEN_STRING_INITIALIZER
18016 (struct cmd_config_per_port_rx_offload_result,
18020 search_rx_offload(const char *name)
18022 uint64_t single_offload;
18023 const char *single_name;
18027 single_offload = 1;
18028 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18029 single_name = rte_eth_dev_rx_offload_name(single_offload);
18030 if (!strcasecmp(single_name, name)) {
18034 single_offload <<= 1;
18038 return single_offload;
18044 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18045 __attribute__((unused)) struct cmdline *cl,
18046 __attribute__((unused)) void *data)
18048 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18049 portid_t port_id = res->port_id;
18050 struct rte_eth_dev_info dev_info;
18051 struct rte_port *port = &ports[port_id];
18052 uint64_t single_offload;
18053 uint16_t nb_rx_queues;
18056 if (port->port_status != RTE_PORT_STOPPED) {
18057 printf("Error: Can't config offload when Port %d "
18058 "is not stopped\n", port_id);
18062 single_offload = search_rx_offload(res->offload);
18063 if (single_offload == 0) {
18064 printf("Unknown offload name: %s\n", res->offload);
18068 rte_eth_dev_info_get(port_id, &dev_info);
18069 nb_rx_queues = dev_info.nb_rx_queues;
18070 if (!strcmp(res->on_off, "on")) {
18071 port->dev_conf.rxmode.offloads |= single_offload;
18072 for (q = 0; q < nb_rx_queues; q++)
18073 port->rx_conf[q].offloads |= single_offload;
18075 port->dev_conf.rxmode.offloads &= ~single_offload;
18076 for (q = 0; q < nb_rx_queues; q++)
18077 port->rx_conf[q].offloads &= ~single_offload;
18080 cmd_reconfig_device_queue(port_id, 1, 1);
18083 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18084 .f = cmd_config_per_port_rx_offload_parsed,
18086 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18087 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18088 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18089 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
18092 (void *)&cmd_config_per_port_rx_offload_result_port,
18093 (void *)&cmd_config_per_port_rx_offload_result_config,
18094 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18095 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18096 (void *)&cmd_config_per_port_rx_offload_result_offload,
18097 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18102 /* Enable/Disable a per queue offloading */
18103 struct cmd_config_per_queue_rx_offload_result {
18104 cmdline_fixed_string_t port;
18106 cmdline_fixed_string_t rxq;
18108 cmdline_fixed_string_t rx_offload;
18109 cmdline_fixed_string_t offload;
18110 cmdline_fixed_string_t on_off;
18113 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18114 TOKEN_STRING_INITIALIZER
18115 (struct cmd_config_per_queue_rx_offload_result,
18117 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18118 TOKEN_NUM_INITIALIZER
18119 (struct cmd_config_per_queue_rx_offload_result,
18121 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18122 TOKEN_STRING_INITIALIZER
18123 (struct cmd_config_per_queue_rx_offload_result,
18125 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18126 TOKEN_NUM_INITIALIZER
18127 (struct cmd_config_per_queue_rx_offload_result,
18129 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18130 TOKEN_STRING_INITIALIZER
18131 (struct cmd_config_per_queue_rx_offload_result,
18132 rx_offload, "rx_offload");
18133 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18134 TOKEN_STRING_INITIALIZER
18135 (struct cmd_config_per_queue_rx_offload_result,
18136 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18137 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18138 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18139 "crc_strip#scatter#timestamp#security#keep_crc");
18140 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18141 TOKEN_STRING_INITIALIZER
18142 (struct cmd_config_per_queue_rx_offload_result,
18146 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18147 __attribute__((unused)) struct cmdline *cl,
18148 __attribute__((unused)) void *data)
18150 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18151 struct rte_eth_dev_info dev_info;
18152 portid_t port_id = res->port_id;
18153 uint16_t queue_id = res->queue_id;
18154 struct rte_port *port = &ports[port_id];
18155 uint64_t single_offload;
18157 if (port->port_status != RTE_PORT_STOPPED) {
18158 printf("Error: Can't config offload when Port %d "
18159 "is not stopped\n", port_id);
18163 rte_eth_dev_info_get(port_id, &dev_info);
18164 if (queue_id >= dev_info.nb_rx_queues) {
18165 printf("Error: input queue_id should be 0 ... "
18166 "%d\n", dev_info.nb_rx_queues - 1);
18170 single_offload = search_rx_offload(res->offload);
18171 if (single_offload == 0) {
18172 printf("Unknown offload name: %s\n", res->offload);
18176 if (!strcmp(res->on_off, "on"))
18177 port->rx_conf[queue_id].offloads |= single_offload;
18179 port->rx_conf[queue_id].offloads &= ~single_offload;
18181 cmd_reconfig_device_queue(port_id, 1, 1);
18184 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18185 .f = cmd_config_per_queue_rx_offload_parsed,
18187 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18188 "vlan_strip|ipv4_cksum|"
18189 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18190 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18191 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
18194 (void *)&cmd_config_per_queue_rx_offload_result_port,
18195 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18196 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18197 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18198 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18199 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18200 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18205 /* Get Tx offloads capabilities */
18206 struct cmd_tx_offload_get_capa_result {
18207 cmdline_fixed_string_t show;
18208 cmdline_fixed_string_t port;
18210 cmdline_fixed_string_t tx_offload;
18211 cmdline_fixed_string_t capabilities;
18214 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18215 TOKEN_STRING_INITIALIZER
18216 (struct cmd_tx_offload_get_capa_result,
18218 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18219 TOKEN_STRING_INITIALIZER
18220 (struct cmd_tx_offload_get_capa_result,
18222 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18223 TOKEN_NUM_INITIALIZER
18224 (struct cmd_tx_offload_get_capa_result,
18226 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18227 TOKEN_STRING_INITIALIZER
18228 (struct cmd_tx_offload_get_capa_result,
18229 tx_offload, "tx_offload");
18230 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18231 TOKEN_STRING_INITIALIZER
18232 (struct cmd_tx_offload_get_capa_result,
18233 capabilities, "capabilities");
18236 print_tx_offloads(uint64_t offloads)
18238 uint64_t single_offload;
18246 begin = __builtin_ctzll(offloads);
18247 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18249 single_offload = 1ULL << begin;
18250 for (bit = begin; bit < end; bit++) {
18251 if (offloads & single_offload)
18253 rte_eth_dev_tx_offload_name(single_offload));
18254 single_offload <<= 1;
18259 cmd_tx_offload_get_capa_parsed(
18260 void *parsed_result,
18261 __attribute__((unused)) struct cmdline *cl,
18262 __attribute__((unused)) void *data)
18264 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18265 struct rte_eth_dev_info dev_info;
18266 portid_t port_id = res->port_id;
18267 uint64_t queue_offloads;
18268 uint64_t port_offloads;
18270 rte_eth_dev_info_get(port_id, &dev_info);
18271 queue_offloads = dev_info.tx_queue_offload_capa;
18272 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18274 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18275 printf(" Per Queue :");
18276 print_tx_offloads(queue_offloads);
18279 printf(" Per Port :");
18280 print_tx_offloads(port_offloads);
18284 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18285 .f = cmd_tx_offload_get_capa_parsed,
18287 .help_str = "show port <port_id> tx_offload capabilities",
18289 (void *)&cmd_tx_offload_get_capa_show,
18290 (void *)&cmd_tx_offload_get_capa_port,
18291 (void *)&cmd_tx_offload_get_capa_port_id,
18292 (void *)&cmd_tx_offload_get_capa_tx_offload,
18293 (void *)&cmd_tx_offload_get_capa_capabilities,
18298 /* Get Tx offloads configuration */
18299 struct cmd_tx_offload_get_configuration_result {
18300 cmdline_fixed_string_t show;
18301 cmdline_fixed_string_t port;
18303 cmdline_fixed_string_t tx_offload;
18304 cmdline_fixed_string_t configuration;
18307 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18308 TOKEN_STRING_INITIALIZER
18309 (struct cmd_tx_offload_get_configuration_result,
18311 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18312 TOKEN_STRING_INITIALIZER
18313 (struct cmd_tx_offload_get_configuration_result,
18315 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18316 TOKEN_NUM_INITIALIZER
18317 (struct cmd_tx_offload_get_configuration_result,
18319 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18320 TOKEN_STRING_INITIALIZER
18321 (struct cmd_tx_offload_get_configuration_result,
18322 tx_offload, "tx_offload");
18323 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18324 TOKEN_STRING_INITIALIZER
18325 (struct cmd_tx_offload_get_configuration_result,
18326 configuration, "configuration");
18329 cmd_tx_offload_get_configuration_parsed(
18330 void *parsed_result,
18331 __attribute__((unused)) struct cmdline *cl,
18332 __attribute__((unused)) void *data)
18334 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18335 struct rte_eth_dev_info dev_info;
18336 portid_t port_id = res->port_id;
18337 struct rte_port *port = &ports[port_id];
18338 uint64_t port_offloads;
18339 uint64_t queue_offloads;
18340 uint16_t nb_tx_queues;
18343 printf("Tx Offloading Configuration of port %d :\n", port_id);
18345 port_offloads = port->dev_conf.txmode.offloads;
18347 print_tx_offloads(port_offloads);
18350 rte_eth_dev_info_get(port_id, &dev_info);
18351 nb_tx_queues = dev_info.nb_tx_queues;
18352 for (q = 0; q < nb_tx_queues; q++) {
18353 queue_offloads = port->tx_conf[q].offloads;
18354 printf(" Queue[%2d] :", q);
18355 print_tx_offloads(queue_offloads);
18361 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18362 .f = cmd_tx_offload_get_configuration_parsed,
18364 .help_str = "show port <port_id> tx_offload configuration",
18366 (void *)&cmd_tx_offload_get_configuration_show,
18367 (void *)&cmd_tx_offload_get_configuration_port,
18368 (void *)&cmd_tx_offload_get_configuration_port_id,
18369 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18370 (void *)&cmd_tx_offload_get_configuration_configuration,
18375 /* Enable/Disable a per port offloading */
18376 struct cmd_config_per_port_tx_offload_result {
18377 cmdline_fixed_string_t port;
18378 cmdline_fixed_string_t config;
18380 cmdline_fixed_string_t tx_offload;
18381 cmdline_fixed_string_t offload;
18382 cmdline_fixed_string_t on_off;
18385 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18386 TOKEN_STRING_INITIALIZER
18387 (struct cmd_config_per_port_tx_offload_result,
18389 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18390 TOKEN_STRING_INITIALIZER
18391 (struct cmd_config_per_port_tx_offload_result,
18393 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18394 TOKEN_NUM_INITIALIZER
18395 (struct cmd_config_per_port_tx_offload_result,
18397 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18398 TOKEN_STRING_INITIALIZER
18399 (struct cmd_config_per_port_tx_offload_result,
18400 tx_offload, "tx_offload");
18401 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18402 TOKEN_STRING_INITIALIZER
18403 (struct cmd_config_per_port_tx_offload_result,
18404 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18405 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18406 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18407 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18408 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18410 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18411 TOKEN_STRING_INITIALIZER
18412 (struct cmd_config_per_port_tx_offload_result,
18416 search_tx_offload(const char *name)
18418 uint64_t single_offload;
18419 const char *single_name;
18423 single_offload = 1;
18424 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18425 single_name = rte_eth_dev_tx_offload_name(single_offload);
18426 if (single_name == NULL)
18428 if (!strcasecmp(single_name, name)) {
18431 } else if (!strcasecmp(single_name, "UNKNOWN"))
18433 single_offload <<= 1;
18437 return single_offload;
18443 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18444 __attribute__((unused)) struct cmdline *cl,
18445 __attribute__((unused)) void *data)
18447 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18448 portid_t port_id = res->port_id;
18449 struct rte_eth_dev_info dev_info;
18450 struct rte_port *port = &ports[port_id];
18451 uint64_t single_offload;
18452 uint16_t nb_tx_queues;
18455 if (port->port_status != RTE_PORT_STOPPED) {
18456 printf("Error: Can't config offload when Port %d "
18457 "is not stopped\n", port_id);
18461 single_offload = search_tx_offload(res->offload);
18462 if (single_offload == 0) {
18463 printf("Unknown offload name: %s\n", res->offload);
18467 rte_eth_dev_info_get(port_id, &dev_info);
18468 nb_tx_queues = dev_info.nb_tx_queues;
18469 if (!strcmp(res->on_off, "on")) {
18470 port->dev_conf.txmode.offloads |= single_offload;
18471 for (q = 0; q < nb_tx_queues; q++)
18472 port->tx_conf[q].offloads |= single_offload;
18474 port->dev_conf.txmode.offloads &= ~single_offload;
18475 for (q = 0; q < nb_tx_queues; q++)
18476 port->tx_conf[q].offloads &= ~single_offload;
18479 cmd_reconfig_device_queue(port_id, 1, 1);
18482 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18483 .f = cmd_config_per_port_tx_offload_parsed,
18485 .help_str = "port config <port_id> tx_offload "
18486 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18487 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18488 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18489 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18490 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18491 "match_metadata on|off",
18493 (void *)&cmd_config_per_port_tx_offload_result_port,
18494 (void *)&cmd_config_per_port_tx_offload_result_config,
18495 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18496 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18497 (void *)&cmd_config_per_port_tx_offload_result_offload,
18498 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18503 /* Enable/Disable a per queue offloading */
18504 struct cmd_config_per_queue_tx_offload_result {
18505 cmdline_fixed_string_t port;
18507 cmdline_fixed_string_t txq;
18509 cmdline_fixed_string_t tx_offload;
18510 cmdline_fixed_string_t offload;
18511 cmdline_fixed_string_t on_off;
18514 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18515 TOKEN_STRING_INITIALIZER
18516 (struct cmd_config_per_queue_tx_offload_result,
18518 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18519 TOKEN_NUM_INITIALIZER
18520 (struct cmd_config_per_queue_tx_offload_result,
18522 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18523 TOKEN_STRING_INITIALIZER
18524 (struct cmd_config_per_queue_tx_offload_result,
18526 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18527 TOKEN_NUM_INITIALIZER
18528 (struct cmd_config_per_queue_tx_offload_result,
18530 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18531 TOKEN_STRING_INITIALIZER
18532 (struct cmd_config_per_queue_tx_offload_result,
18533 tx_offload, "tx_offload");
18534 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18535 TOKEN_STRING_INITIALIZER
18536 (struct cmd_config_per_queue_tx_offload_result,
18537 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18538 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18539 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18540 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18541 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18542 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18543 TOKEN_STRING_INITIALIZER
18544 (struct cmd_config_per_queue_tx_offload_result,
18548 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18549 __attribute__((unused)) struct cmdline *cl,
18550 __attribute__((unused)) void *data)
18552 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18553 struct rte_eth_dev_info dev_info;
18554 portid_t port_id = res->port_id;
18555 uint16_t queue_id = res->queue_id;
18556 struct rte_port *port = &ports[port_id];
18557 uint64_t single_offload;
18559 if (port->port_status != RTE_PORT_STOPPED) {
18560 printf("Error: Can't config offload when Port %d "
18561 "is not stopped\n", port_id);
18565 rte_eth_dev_info_get(port_id, &dev_info);
18566 if (queue_id >= dev_info.nb_tx_queues) {
18567 printf("Error: input queue_id should be 0 ... "
18568 "%d\n", dev_info.nb_tx_queues - 1);
18572 single_offload = search_tx_offload(res->offload);
18573 if (single_offload == 0) {
18574 printf("Unknown offload name: %s\n", res->offload);
18578 if (!strcmp(res->on_off, "on"))
18579 port->tx_conf[queue_id].offloads |= single_offload;
18581 port->tx_conf[queue_id].offloads &= ~single_offload;
18583 cmd_reconfig_device_queue(port_id, 1, 1);
18586 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18587 .f = cmd_config_per_queue_tx_offload_parsed,
18589 .help_str = "port <port_id> txq <queue_id> tx_offload "
18590 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18591 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18592 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18593 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18594 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18597 (void *)&cmd_config_per_queue_tx_offload_result_port,
18598 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18599 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18600 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18601 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18602 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18603 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18608 /* *** configure tx_metadata for specific port *** */
18609 struct cmd_config_tx_metadata_specific_result {
18610 cmdline_fixed_string_t port;
18611 cmdline_fixed_string_t keyword;
18613 cmdline_fixed_string_t item;
18618 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18619 __attribute__((unused)) struct cmdline *cl,
18620 __attribute__((unused)) void *data)
18622 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18624 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18626 ports[res->port_id].tx_metadata = rte_cpu_to_be_32(res->value);
18627 /* Add/remove callback to insert valid metadata in every Tx packet. */
18628 if (ports[res->port_id].tx_metadata)
18629 add_tx_md_callback(res->port_id);
18631 remove_tx_md_callback(res->port_id);
18634 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18635 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18637 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18638 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18639 keyword, "config");
18640 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18641 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18643 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18644 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18645 item, "tx_metadata");
18646 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18647 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18650 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18651 .f = cmd_config_tx_metadata_specific_parsed,
18653 .help_str = "port config <port_id> tx_metadata <value>",
18655 (void *)&cmd_config_tx_metadata_specific_port,
18656 (void *)&cmd_config_tx_metadata_specific_keyword,
18657 (void *)&cmd_config_tx_metadata_specific_id,
18658 (void *)&cmd_config_tx_metadata_specific_item,
18659 (void *)&cmd_config_tx_metadata_specific_value,
18664 /* *** display tx_metadata per port configuration *** */
18665 struct cmd_show_tx_metadata_result {
18666 cmdline_fixed_string_t cmd_show;
18667 cmdline_fixed_string_t cmd_port;
18668 cmdline_fixed_string_t cmd_keyword;
18673 cmd_show_tx_metadata_parsed(void *parsed_result,
18674 __attribute__((unused)) struct cmdline *cl,
18675 __attribute__((unused)) void *data)
18677 struct cmd_show_tx_metadata_result *res = parsed_result;
18679 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18680 printf("invalid port id %u\n", res->cmd_pid);
18683 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18684 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18685 rte_be_to_cpu_32(ports[res->cmd_pid].tx_metadata));
18689 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18690 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18692 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18693 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18695 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18696 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18698 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18699 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18700 cmd_keyword, "tx_metadata");
18702 cmdline_parse_inst_t cmd_show_tx_metadata = {
18703 .f = cmd_show_tx_metadata_parsed,
18705 .help_str = "show port <port_id> tx_metadata",
18707 (void *)&cmd_show_tx_metadata_show,
18708 (void *)&cmd_show_tx_metadata_port,
18709 (void *)&cmd_show_tx_metadata_pid,
18710 (void *)&cmd_show_tx_metadata_keyword,
18715 /* ******************************************************************************** */
18717 /* list of instructions */
18718 cmdline_parse_ctx_t main_ctx[] = {
18719 (cmdline_parse_inst_t *)&cmd_help_brief,
18720 (cmdline_parse_inst_t *)&cmd_help_long,
18721 (cmdline_parse_inst_t *)&cmd_quit,
18722 (cmdline_parse_inst_t *)&cmd_load_from_file,
18723 (cmdline_parse_inst_t *)&cmd_showport,
18724 (cmdline_parse_inst_t *)&cmd_showqueue,
18725 (cmdline_parse_inst_t *)&cmd_showportall,
18726 (cmdline_parse_inst_t *)&cmd_showcfg,
18727 (cmdline_parse_inst_t *)&cmd_showfwdall,
18728 (cmdline_parse_inst_t *)&cmd_start,
18729 (cmdline_parse_inst_t *)&cmd_start_tx_first,
18730 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
18731 (cmdline_parse_inst_t *)&cmd_set_link_up,
18732 (cmdline_parse_inst_t *)&cmd_set_link_down,
18733 (cmdline_parse_inst_t *)&cmd_reset,
18734 (cmdline_parse_inst_t *)&cmd_set_numbers,
18735 (cmdline_parse_inst_t *)&cmd_set_log,
18736 (cmdline_parse_inst_t *)&cmd_set_txpkts,
18737 (cmdline_parse_inst_t *)&cmd_set_txsplit,
18738 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
18739 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
18740 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
18741 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
18742 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
18743 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
18744 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
18745 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
18746 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
18747 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
18748 (cmdline_parse_inst_t *)&cmd_set_link_check,
18749 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
18750 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
18751 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
18752 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
18753 #ifdef RTE_LIBRTE_PMD_BOND
18754 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
18755 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
18756 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
18757 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
18758 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
18759 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
18760 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
18761 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
18762 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
18763 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
18764 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
18766 (cmdline_parse_inst_t *)&cmd_vlan_offload,
18767 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
18768 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
18769 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
18770 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
18771 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
18772 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
18773 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
18774 (cmdline_parse_inst_t *)&cmd_csum_set,
18775 (cmdline_parse_inst_t *)&cmd_csum_show,
18776 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
18777 (cmdline_parse_inst_t *)&cmd_tso_set,
18778 (cmdline_parse_inst_t *)&cmd_tso_show,
18779 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
18780 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
18781 (cmdline_parse_inst_t *)&cmd_gro_enable,
18782 (cmdline_parse_inst_t *)&cmd_gro_flush,
18783 (cmdline_parse_inst_t *)&cmd_gro_show,
18784 (cmdline_parse_inst_t *)&cmd_gso_enable,
18785 (cmdline_parse_inst_t *)&cmd_gso_size,
18786 (cmdline_parse_inst_t *)&cmd_gso_show,
18787 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
18788 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
18789 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
18790 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
18791 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
18792 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
18793 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
18794 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
18795 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
18796 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
18797 (cmdline_parse_inst_t *)&cmd_config_dcb,
18798 (cmdline_parse_inst_t *)&cmd_read_reg,
18799 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
18800 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
18801 (cmdline_parse_inst_t *)&cmd_write_reg,
18802 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
18803 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
18804 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
18805 (cmdline_parse_inst_t *)&cmd_stop,
18806 (cmdline_parse_inst_t *)&cmd_mac_addr,
18807 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
18808 (cmdline_parse_inst_t *)&cmd_set_qmap,
18809 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
18810 (cmdline_parse_inst_t *)&cmd_operate_port,
18811 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
18812 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
18813 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
18814 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
18815 (cmdline_parse_inst_t *)&cmd_config_speed_all,
18816 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
18817 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
18818 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
18819 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
18820 (cmdline_parse_inst_t *)&cmd_config_mtu,
18821 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
18822 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
18823 (cmdline_parse_inst_t *)&cmd_config_rss,
18824 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
18825 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
18826 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
18827 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
18828 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
18829 (cmdline_parse_inst_t *)&cmd_showport_reta,
18830 (cmdline_parse_inst_t *)&cmd_config_burst,
18831 (cmdline_parse_inst_t *)&cmd_config_thresh,
18832 (cmdline_parse_inst_t *)&cmd_config_threshold,
18833 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
18834 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
18835 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
18836 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
18837 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
18838 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
18839 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
18840 (cmdline_parse_inst_t *)&cmd_global_config,
18841 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
18842 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
18843 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
18844 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
18845 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
18846 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
18847 (cmdline_parse_inst_t *)&cmd_dump,
18848 (cmdline_parse_inst_t *)&cmd_dump_one,
18849 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
18850 (cmdline_parse_inst_t *)&cmd_syn_filter,
18851 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
18852 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
18853 (cmdline_parse_inst_t *)&cmd_flex_filter,
18854 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
18855 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
18856 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
18857 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
18858 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
18859 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
18860 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
18861 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
18862 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
18863 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
18864 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
18865 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
18866 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
18867 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
18868 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
18869 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
18870 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
18871 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
18872 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
18873 (cmdline_parse_inst_t *)&cmd_flow,
18874 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
18875 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
18876 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
18877 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
18878 (cmdline_parse_inst_t *)&cmd_create_port_meter,
18879 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
18880 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
18881 (cmdline_parse_inst_t *)&cmd_del_port_meter,
18882 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
18883 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
18884 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
18885 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
18886 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
18887 (cmdline_parse_inst_t *)&cmd_mcast_addr,
18888 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
18889 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
18890 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
18891 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
18892 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
18893 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
18894 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
18895 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
18896 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
18897 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
18898 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
18899 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
18900 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
18901 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
18902 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
18903 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
18904 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
18905 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
18906 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
18907 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
18908 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
18909 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
18910 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
18911 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
18912 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
18913 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
18914 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
18915 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
18916 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
18917 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
18918 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
18919 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
18920 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
18921 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
18922 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
18923 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
18924 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
18926 (cmdline_parse_inst_t *)&cmd_set_vxlan,
18927 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
18928 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
18929 (cmdline_parse_inst_t *)&cmd_set_nvgre,
18930 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
18931 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
18932 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
18933 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
18934 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
18935 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
18936 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
18937 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
18938 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
18939 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
18940 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
18941 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
18942 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
18943 (cmdline_parse_inst_t *)&cmd_ddp_add,
18944 (cmdline_parse_inst_t *)&cmd_ddp_del,
18945 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
18946 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
18947 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
18948 (cmdline_parse_inst_t *)&cmd_clear_input_set,
18949 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
18950 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
18951 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
18952 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
18953 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
18954 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
18956 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
18957 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
18958 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
18959 (cmdline_parse_inst_t *)&cmd_queue_region,
18960 (cmdline_parse_inst_t *)&cmd_region_flowtype,
18961 (cmdline_parse_inst_t *)&cmd_user_priority_region,
18962 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
18963 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
18964 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
18965 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
18966 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
18967 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
18968 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
18969 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
18970 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
18971 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
18972 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
18973 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
18974 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
18975 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
18976 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
18977 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
18978 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
18979 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
18980 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
18981 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
18982 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
18983 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
18984 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
18985 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
18986 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
18987 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
18988 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
18989 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
18990 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
18991 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
18992 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
18993 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
18994 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
18995 #ifdef RTE_LIBRTE_BPF
18996 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
18997 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
18999 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19000 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19004 /* read cmdline commands from file */
19006 cmdline_read_from_file(const char *filename)
19008 struct cmdline *cl;
19010 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19012 printf("Failed to create file based cmdline context: %s\n",
19017 cmdline_interact(cl);
19022 printf("Read CLI commands from %s\n", filename);
19025 /* prompt function, called from main on MASTER lcore */
19029 /* initialize non-constant commands */
19030 cmd_set_fwd_mode_init();
19031 cmd_set_fwd_retry_mode_init();
19033 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19034 if (testpmd_cl == NULL)
19036 cmdline_interact(testpmd_cl);
19037 cmdline_stdin_exit(testpmd_cl);
19043 if (testpmd_cl != NULL)
19044 cmdline_quit(testpmd_cl);
19048 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19050 if (id == (portid_t)RTE_PORT_ALL) {
19053 RTE_ETH_FOREACH_DEV(pid) {
19054 /* check if need_reconfig has been set to 1 */
19055 if (ports[pid].need_reconfig == 0)
19056 ports[pid].need_reconfig = dev;
19057 /* check if need_reconfig_queues has been set to 1 */
19058 if (ports[pid].need_reconfig_queues == 0)
19059 ports[pid].need_reconfig_queues = queue;
19061 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19062 /* check if need_reconfig has been set to 1 */
19063 if (ports[id].need_reconfig == 0)
19064 ports[id].need_reconfig = dev;
19065 /* check if need_reconfig_queues has been set to 1 */
19066 if (ports[id].need_reconfig_queues == 0)
19067 ports[id].need_reconfig_queues = queue;