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 , list_pkt_forwarding_modes()
740 if (show_all || !strcmp(res->section, "ports")) {
746 "----------------\n\n"
748 "port start (port_id|all)\n"
749 " Start all ports or port_id.\n\n"
751 "port stop (port_id|all)\n"
752 " Stop all ports or port_id.\n\n"
754 "port close (port_id|all)\n"
755 " Close all ports or port_id.\n\n"
757 "port attach (ident)\n"
758 " Attach physical or virtual dev by pci address or virtual device name\n\n"
760 "port detach (port_id)\n"
761 " Detach physical or virtual dev by port_id\n\n"
763 "port config (port_id|all)"
764 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
765 " duplex (half|full|auto)\n"
766 " Set speed and duplex for all ports or port_id\n\n"
768 "port config (port_id|all) loopback (mode)\n"
769 " Set loopback mode for all ports or port_id\n\n"
771 "port config all (rxq|txq|rxd|txd) (value)\n"
772 " Set number for rxq/txq/rxd/txd.\n\n"
774 "port config all max-pkt-len (value)\n"
775 " Set the max packet length.\n\n"
777 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
778 "hw-vlan-strip|hw-vlan-extend|drop-en)"
780 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
783 "port config all rss (all|default|ip|tcp|udp|sctp|"
784 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>)\n"
785 " Set the RSS mode.\n\n"
787 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
788 " Set the RSS redirection table.\n\n"
790 "port config (port_id) dcb vt (on|off) (traffic_class)"
792 " Set the DCB mode.\n\n"
794 "port config all burst (value)\n"
795 " Set the number of packets per burst.\n\n"
797 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
799 " Set the ring prefetch/host/writeback threshold"
800 " for tx/rx queue.\n\n"
802 "port config all (txfreet|txrst|rxfreet) (value)\n"
803 " Set free threshold for rx/tx, or set"
804 " tx rs bit threshold.\n\n"
805 "port config mtu X value\n"
806 " Set the MTU of port X to a given value\n\n"
808 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
809 " Set a rx/tx queue's ring size configuration, the new"
810 " value will take effect after command that (re-)start the port"
811 " or command that setup the specific queue\n\n"
813 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
814 " Start/stop a rx/tx queue of port X. Only take effect"
815 " when port X is started\n\n"
817 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
818 " Switch on/off a deferred start of port X rx/tx queue. Only"
819 " take effect when port X is stopped.\n\n"
821 "port (port_id) (rxq|txq) (queue_id) setup\n"
822 " Setup a rx/tx queue of port X.\n\n"
824 "port config (port_id|all) l2-tunnel E-tag ether-type"
826 " Set the value of E-tag ether-type.\n\n"
828 "port config (port_id|all) l2-tunnel E-tag"
829 " (enable|disable)\n"
830 " Enable/disable the E-tag support.\n\n"
832 "port config (port_id) pctype mapping reset\n"
833 " Reset flow type to pctype mapping on a port\n\n"
835 "port config (port_id) pctype mapping update"
836 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
837 " Update a flow type to pctype mapping item on a port\n\n"
839 "port config (port_id) pctype (pctype_id) hash_inset|"
840 "fdir_inset|fdir_flx_inset get|set|clear field\n"
842 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
844 "port config (port_id) pctype (pctype_id) hash_inset|"
845 "fdir_inset|fdir_flx_inset clear all"
846 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
848 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
849 " Add/remove UDP tunnel port for tunneling offload\n\n"
851 "port config <port_id> rx_offload vlan_strip|"
852 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
853 "outer_ipv4_cksum|macsec_strip|header_split|"
854 "vlan_filter|vlan_extend|jumbo_frame|crc_strip|"
855 "scatter|timestamp|security|keep_crc on|off\n"
856 " Enable or disable a per port Rx offloading"
857 " on all Rx queues of a port\n\n"
859 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
860 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
861 "outer_ipv4_cksum|macsec_strip|header_split|"
862 "vlan_filter|vlan_extend|jumbo_frame|crc_strip|"
863 "scatter|timestamp|security|keep_crc on|off\n"
864 " Enable or disable a per queue Rx offloading"
865 " only on a specific Rx queue\n\n"
867 "port config (port_id) tx_offload vlan_insert|"
868 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
869 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
870 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
871 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
872 "security|match_metadata on|off\n"
873 " Enable or disable a per port Tx offloading"
874 " on all Tx queues of a port\n\n"
876 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
877 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
878 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
879 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
880 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
882 " Enable or disable a per queue Tx offloading"
883 " only on a specific Tx queue\n\n"
885 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
886 " Load an eBPF program as a callback"
887 " for particular RX/TX queue\n\n"
889 "bpf-unload rx|tx (port) (queue)\n"
890 " Unload previously loaded eBPF program"
891 " for particular RX/TX queue\n\n"
893 "port config (port_id) tx_metadata (value)\n"
894 " Set Tx metadata value per port. Testpmd will add this value"
895 " to any Tx packet sent from this port\n\n"
899 if (show_all || !strcmp(res->section, "registers")) {
907 "read reg (port_id) (address)\n"
908 " Display value of a port register.\n\n"
910 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
911 " Display a port register bit field.\n\n"
913 "read regbit (port_id) (address) (bit_x)\n"
914 " Display a single port register bit.\n\n"
916 "write reg (port_id) (address) (value)\n"
917 " Set value of a port register.\n\n"
919 "write regfield (port_id) (address) (bit_x) (bit_y)"
921 " Set bit field of a port register.\n\n"
923 "write regbit (port_id) (address) (bit_x) (value)\n"
924 " Set single bit value of a port register.\n\n"
927 if (show_all || !strcmp(res->section, "filters")) {
935 "ethertype_filter (port_id) (add|del)"
936 " (mac_addr|mac_ignr) (mac_address) ethertype"
937 " (ether_type) (drop|fwd) queue (queue_id)\n"
938 " Add/Del an ethertype filter.\n\n"
940 "2tuple_filter (port_id) (add|del)"
941 " dst_port (dst_port_value) protocol (protocol_value)"
942 " mask (mask_value) tcp_flags (tcp_flags_value)"
943 " priority (prio_value) queue (queue_id)\n"
944 " Add/Del a 2tuple filter.\n\n"
946 "5tuple_filter (port_id) (add|del)"
947 " dst_ip (dst_address) src_ip (src_address)"
948 " dst_port (dst_port_value) src_port (src_port_value)"
949 " protocol (protocol_value)"
950 " mask (mask_value) tcp_flags (tcp_flags_value)"
951 " priority (prio_value) queue (queue_id)\n"
952 " Add/Del a 5tuple filter.\n\n"
954 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
955 " Add/Del syn filter.\n\n"
957 "flex_filter (port_id) (add|del) len (len_value)"
958 " bytes (bytes_value) mask (mask_value)"
959 " priority (prio_value) queue (queue_id)\n"
960 " Add/Del a flex filter.\n\n"
962 "flow_director_filter (port_id) mode IP (add|del|update)"
963 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
964 " src (src_ip_address) dst (dst_ip_address)"
965 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
966 " vlan (vlan_value) flexbytes (flexbytes_value)"
967 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
968 " fd_id (fd_id_value)\n"
969 " Add/Del an IP type flow director filter.\n\n"
971 "flow_director_filter (port_id) mode IP (add|del|update)"
972 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
973 " src (src_ip_address) (src_port)"
974 " dst (dst_ip_address) (dst_port)"
975 " tos (tos_value) ttl (ttl_value)"
976 " vlan (vlan_value) flexbytes (flexbytes_value)"
977 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
978 " fd_id (fd_id_value)\n"
979 " Add/Del an UDP/TCP type flow director filter.\n\n"
981 "flow_director_filter (port_id) mode IP (add|del|update)"
982 " flow (ipv4-sctp|ipv6-sctp)"
983 " src (src_ip_address) (src_port)"
984 " dst (dst_ip_address) (dst_port)"
985 " tag (verification_tag) "
986 " tos (tos_value) ttl (ttl_value)"
988 " flexbytes (flexbytes_value) (drop|fwd)"
989 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
990 " Add/Del a SCTP type flow director filter.\n\n"
992 "flow_director_filter (port_id) mode IP (add|del|update)"
993 " flow l2_payload ether (ethertype)"
994 " flexbytes (flexbytes_value) (drop|fwd)"
995 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
996 " Add/Del a l2 payload type flow director filter.\n\n"
998 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
999 " mac (mac_address) vlan (vlan_value)"
1000 " flexbytes (flexbytes_value) (drop|fwd)"
1001 " queue (queue_id) fd_id (fd_id_value)\n"
1002 " Add/Del a MAC-VLAN flow director filter.\n\n"
1004 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1005 " mac (mac_address) vlan (vlan_value)"
1006 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1007 " flexbytes (flexbytes_value) (drop|fwd)"
1008 " queue (queue_id) fd_id (fd_id_value)\n"
1009 " Add/Del a Tunnel flow director filter.\n\n"
1011 "flow_director_filter (port_id) mode raw (add|del|update)"
1012 " flow (flow_id) (drop|fwd) queue (queue_id)"
1013 " fd_id (fd_id_value) packet (packet file name)\n"
1014 " Add/Del a raw type flow director filter.\n\n"
1016 "flush_flow_director (port_id)\n"
1017 " Flush all flow director entries of a device.\n\n"
1019 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1020 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1021 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1022 " Set flow director IP mask.\n\n"
1024 "flow_director_mask (port_id) mode MAC-VLAN"
1025 " vlan (vlan_value)\n"
1026 " Set flow director MAC-VLAN mask.\n\n"
1028 "flow_director_mask (port_id) mode Tunnel"
1029 " vlan (vlan_value) mac (mac_value)"
1030 " tunnel-type (tunnel_type_value)"
1031 " tunnel-id (tunnel_id_value)\n"
1032 " Set flow director Tunnel mask.\n\n"
1034 "flow_director_flex_mask (port_id)"
1035 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1036 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1038 " Configure mask of flex payload.\n\n"
1040 "flow_director_flex_payload (port_id)"
1041 " (raw|l2|l3|l4) (config)\n"
1042 " Configure flex payload selection.\n\n"
1044 "get_sym_hash_ena_per_port (port_id)\n"
1045 " get symmetric hash enable configuration per port.\n\n"
1047 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1048 " set symmetric hash enable configuration per port"
1049 " to enable or disable.\n\n"
1051 "get_hash_global_config (port_id)\n"
1052 " Get the global configurations of hash filters.\n\n"
1054 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1055 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1056 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1057 " (enable|disable)\n"
1058 " Set the global configurations of hash filters.\n\n"
1060 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1061 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1062 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1063 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1064 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1065 "ipv6-next-header|udp-src-port|udp-dst-port|"
1066 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1067 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1068 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1069 "fld-8th|none) (select|add)\n"
1070 " Set the input set for hash.\n\n"
1072 "set_fdir_input_set (port_id) "
1073 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1074 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1075 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1076 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1077 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1078 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1079 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1081 " Set the input set for FDir.\n\n"
1083 "flow validate {port_id}"
1084 " [group {group_id}] [priority {level}]"
1085 " [ingress] [egress]"
1086 " pattern {item} [/ {item} [...]] / end"
1087 " actions {action} [/ {action} [...]] / end\n"
1088 " Check whether a flow rule can be created.\n\n"
1090 "flow create {port_id}"
1091 " [group {group_id}] [priority {level}]"
1092 " [ingress] [egress]"
1093 " pattern {item} [/ {item} [...]] / end"
1094 " actions {action} [/ {action} [...]] / end\n"
1095 " Create a flow rule.\n\n"
1097 "flow destroy {port_id} rule {rule_id} [...]\n"
1098 " Destroy specific flow rules.\n\n"
1100 "flow flush {port_id}\n"
1101 " Destroy all flow rules.\n\n"
1103 "flow query {port_id} {rule_id} {action}\n"
1104 " Query an existing flow rule.\n\n"
1106 "flow list {port_id} [group {group_id}] [...]\n"
1107 " List existing flow rules sorted by priority,"
1108 " filtered by group identifiers.\n\n"
1110 "flow isolate {port_id} {boolean}\n"
1111 " Restrict ingress traffic to the defined"
1114 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1115 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1116 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1117 " Configure the VXLAN encapsulation for flows.\n\n"
1119 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1120 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1121 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1122 " eth-dst (eth-dst)\n"
1123 " Configure the VXLAN encapsulation for flows.\n\n"
1125 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1126 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1127 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1128 " eth-dst (eth-dst)\n"
1129 " Configure the VXLAN encapsulation for flows.\n\n"
1131 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1132 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1134 " Configure the NVGRE encapsulation for flows.\n\n"
1136 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1137 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1138 " eth-src (eth-src) eth-dst (eth-dst)\n"
1139 " Configure the NVGRE encapsulation for flows.\n\n"
1144 if (show_all || !strcmp(res->section, "traffic_management")) {
1148 "Traffic Management:\n"
1150 "show port tm cap (port_id)\n"
1151 " Display the port TM capability.\n\n"
1153 "show port tm level cap (port_id) (level_id)\n"
1154 " Display the port TM hierarchical level capability.\n\n"
1156 "show port tm node cap (port_id) (node_id)\n"
1157 " Display the port TM node capability.\n\n"
1159 "show port tm node type (port_id) (node_id)\n"
1160 " Display the port TM node type.\n\n"
1162 "show port tm node stats (port_id) (node_id) (clear)\n"
1163 " Display the port TM node stats.\n\n"
1165 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
1166 "set port tm hierarchy default (port_id)\n"
1167 " Set default traffic Management hierarchy on a port\n\n"
1170 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1171 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1172 " (packet_length_adjust)\n"
1173 " Add port tm node private shaper profile.\n\n"
1175 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1176 " Delete port tm node private shaper profile.\n\n"
1178 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1179 " (shaper_profile_id)\n"
1180 " Add/update port tm node shared shaper.\n\n"
1182 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1183 " Delete port tm node shared shaper.\n\n"
1185 "set port tm node shaper profile (port_id) (node_id)"
1186 " (shaper_profile_id)\n"
1187 " Set port tm node shaper profile.\n\n"
1189 "add port tm node wred profile (port_id) (wred_profile_id)"
1190 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1191 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1192 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1193 " Add port tm node wred profile.\n\n"
1195 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1196 " Delete port tm node wred profile.\n\n"
1198 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1199 " (priority) (weight) (level_id) (shaper_profile_id)"
1200 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1201 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1202 " Add port tm nonleaf node.\n\n"
1204 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1205 " (priority) (weight) (level_id) (shaper_profile_id)"
1206 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1207 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1208 " Add port tm leaf node.\n\n"
1210 "del port tm node (port_id) (node_id)\n"
1211 " Delete port tm node.\n\n"
1213 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1214 " (priority) (weight)\n"
1215 " Set port tm node parent.\n\n"
1217 "suspend port tm node (port_id) (node_id)"
1218 " Suspend tm node.\n\n"
1220 "resume port tm node (port_id) (node_id)"
1221 " Resume tm node.\n\n"
1223 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1224 " Commit tm hierarchy.\n\n"
1226 "set port tm mark ip_ecn (port) (green) (yellow)"
1228 " Enables/Disables the traffic management marking"
1229 " for IP ECN (Explicit Congestion Notification)"
1230 " packets on a given port\n\n"
1232 "set port tm mark ip_dscp (port) (green) (yellow)"
1234 " Enables/Disables the traffic management marking"
1235 " on the port for IP dscp packets\n\n"
1237 "set port tm mark vlan_dei (port) (green) (yellow)"
1239 " Enables/Disables the traffic management marking"
1240 " on the port for VLAN packets with DEI enabled\n\n"
1246 cmdline_parse_token_string_t cmd_help_long_help =
1247 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1249 cmdline_parse_token_string_t cmd_help_long_section =
1250 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1251 "all#control#display#config#"
1252 "ports#registers#filters#traffic_management");
1254 cmdline_parse_inst_t cmd_help_long = {
1255 .f = cmd_help_long_parsed,
1257 .help_str = "help all|control|display|config|ports|register|"
1258 "filters|traffic_management: "
1261 (void *)&cmd_help_long_help,
1262 (void *)&cmd_help_long_section,
1268 /* *** start/stop/close all ports *** */
1269 struct cmd_operate_port_result {
1270 cmdline_fixed_string_t keyword;
1271 cmdline_fixed_string_t name;
1272 cmdline_fixed_string_t value;
1275 static void cmd_operate_port_parsed(void *parsed_result,
1276 __attribute__((unused)) struct cmdline *cl,
1277 __attribute__((unused)) void *data)
1279 struct cmd_operate_port_result *res = parsed_result;
1281 if (!strcmp(res->name, "start"))
1282 start_port(RTE_PORT_ALL);
1283 else if (!strcmp(res->name, "stop"))
1284 stop_port(RTE_PORT_ALL);
1285 else if (!strcmp(res->name, "close"))
1286 close_port(RTE_PORT_ALL);
1287 else if (!strcmp(res->name, "reset"))
1288 reset_port(RTE_PORT_ALL);
1290 printf("Unknown parameter\n");
1293 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1294 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1296 cmdline_parse_token_string_t cmd_operate_port_all_port =
1297 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1298 "start#stop#close#reset");
1299 cmdline_parse_token_string_t cmd_operate_port_all_all =
1300 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1302 cmdline_parse_inst_t cmd_operate_port = {
1303 .f = cmd_operate_port_parsed,
1305 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1307 (void *)&cmd_operate_port_all_cmd,
1308 (void *)&cmd_operate_port_all_port,
1309 (void *)&cmd_operate_port_all_all,
1314 /* *** start/stop/close specific port *** */
1315 struct cmd_operate_specific_port_result {
1316 cmdline_fixed_string_t keyword;
1317 cmdline_fixed_string_t name;
1321 static void cmd_operate_specific_port_parsed(void *parsed_result,
1322 __attribute__((unused)) struct cmdline *cl,
1323 __attribute__((unused)) void *data)
1325 struct cmd_operate_specific_port_result *res = parsed_result;
1327 if (!strcmp(res->name, "start"))
1328 start_port(res->value);
1329 else if (!strcmp(res->name, "stop"))
1330 stop_port(res->value);
1331 else if (!strcmp(res->name, "close"))
1332 close_port(res->value);
1333 else if (!strcmp(res->name, "reset"))
1334 reset_port(res->value);
1336 printf("Unknown parameter\n");
1339 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1340 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1342 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1343 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1344 name, "start#stop#close#reset");
1345 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1346 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1349 cmdline_parse_inst_t cmd_operate_specific_port = {
1350 .f = cmd_operate_specific_port_parsed,
1352 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1354 (void *)&cmd_operate_specific_port_cmd,
1355 (void *)&cmd_operate_specific_port_port,
1356 (void *)&cmd_operate_specific_port_id,
1361 /* *** enable port setup (after attach) via iterator or event *** */
1362 struct cmd_set_port_setup_on_result {
1363 cmdline_fixed_string_t set;
1364 cmdline_fixed_string_t port;
1365 cmdline_fixed_string_t setup;
1366 cmdline_fixed_string_t on;
1367 cmdline_fixed_string_t mode;
1370 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1371 __attribute__((unused)) struct cmdline *cl,
1372 __attribute__((unused)) void *data)
1374 struct cmd_set_port_setup_on_result *res = parsed_result;
1376 if (strcmp(res->mode, "event") == 0)
1377 setup_on_probe_event = true;
1378 else if (strcmp(res->mode, "iterator") == 0)
1379 setup_on_probe_event = false;
1381 printf("Unknown mode\n");
1384 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1385 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1387 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1388 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1390 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1391 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1393 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1394 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1396 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1397 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1398 mode, "iterator#event");
1400 cmdline_parse_inst_t cmd_set_port_setup_on = {
1401 .f = cmd_set_port_setup_on_parsed,
1403 .help_str = "set port setup on iterator|event",
1405 (void *)&cmd_set_port_setup_on_set,
1406 (void *)&cmd_set_port_setup_on_port,
1407 (void *)&cmd_set_port_setup_on_setup,
1408 (void *)&cmd_set_port_setup_on_on,
1409 (void *)&cmd_set_port_setup_on_mode,
1414 /* *** attach a specified port *** */
1415 struct cmd_operate_attach_port_result {
1416 cmdline_fixed_string_t port;
1417 cmdline_fixed_string_t keyword;
1418 cmdline_fixed_string_t identifier;
1421 static void cmd_operate_attach_port_parsed(void *parsed_result,
1422 __attribute__((unused)) struct cmdline *cl,
1423 __attribute__((unused)) void *data)
1425 struct cmd_operate_attach_port_result *res = parsed_result;
1427 if (!strcmp(res->keyword, "attach"))
1428 attach_port(res->identifier);
1430 printf("Unknown parameter\n");
1433 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1434 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1436 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1437 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1439 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1440 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1443 cmdline_parse_inst_t cmd_operate_attach_port = {
1444 .f = cmd_operate_attach_port_parsed,
1446 .help_str = "port attach <identifier>: "
1447 "(identifier: pci address or virtual dev name)",
1449 (void *)&cmd_operate_attach_port_port,
1450 (void *)&cmd_operate_attach_port_keyword,
1451 (void *)&cmd_operate_attach_port_identifier,
1456 /* *** detach a specified port *** */
1457 struct cmd_operate_detach_port_result {
1458 cmdline_fixed_string_t port;
1459 cmdline_fixed_string_t keyword;
1463 static void cmd_operate_detach_port_parsed(void *parsed_result,
1464 __attribute__((unused)) struct cmdline *cl,
1465 __attribute__((unused)) void *data)
1467 struct cmd_operate_detach_port_result *res = parsed_result;
1469 if (!strcmp(res->keyword, "detach"))
1470 detach_port_device(res->port_id);
1472 printf("Unknown parameter\n");
1475 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1476 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1478 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1479 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1481 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1482 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1485 cmdline_parse_inst_t cmd_operate_detach_port = {
1486 .f = cmd_operate_detach_port_parsed,
1488 .help_str = "port detach <port_id>",
1490 (void *)&cmd_operate_detach_port_port,
1491 (void *)&cmd_operate_detach_port_keyword,
1492 (void *)&cmd_operate_detach_port_port_id,
1497 /* *** configure speed for all ports *** */
1498 struct cmd_config_speed_all {
1499 cmdline_fixed_string_t port;
1500 cmdline_fixed_string_t keyword;
1501 cmdline_fixed_string_t all;
1502 cmdline_fixed_string_t item1;
1503 cmdline_fixed_string_t item2;
1504 cmdline_fixed_string_t value1;
1505 cmdline_fixed_string_t value2;
1509 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1514 if (!strcmp(duplexstr, "half")) {
1515 duplex = ETH_LINK_HALF_DUPLEX;
1516 } else if (!strcmp(duplexstr, "full")) {
1517 duplex = ETH_LINK_FULL_DUPLEX;
1518 } else if (!strcmp(duplexstr, "auto")) {
1519 duplex = ETH_LINK_FULL_DUPLEX;
1521 printf("Unknown duplex parameter\n");
1525 if (!strcmp(speedstr, "10")) {
1526 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1527 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1528 } else if (!strcmp(speedstr, "100")) {
1529 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1530 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1532 if (duplex != ETH_LINK_FULL_DUPLEX) {
1533 printf("Invalid speed/duplex parameters\n");
1536 if (!strcmp(speedstr, "1000")) {
1537 *speed = ETH_LINK_SPEED_1G;
1538 } else if (!strcmp(speedstr, "10000")) {
1539 *speed = ETH_LINK_SPEED_10G;
1540 } else if (!strcmp(speedstr, "25000")) {
1541 *speed = ETH_LINK_SPEED_25G;
1542 } else if (!strcmp(speedstr, "40000")) {
1543 *speed = ETH_LINK_SPEED_40G;
1544 } else if (!strcmp(speedstr, "50000")) {
1545 *speed = ETH_LINK_SPEED_50G;
1546 } else if (!strcmp(speedstr, "100000")) {
1547 *speed = ETH_LINK_SPEED_100G;
1548 } else if (!strcmp(speedstr, "auto")) {
1549 *speed = ETH_LINK_SPEED_AUTONEG;
1551 printf("Unknown speed parameter\n");
1560 cmd_config_speed_all_parsed(void *parsed_result,
1561 __attribute__((unused)) struct cmdline *cl,
1562 __attribute__((unused)) void *data)
1564 struct cmd_config_speed_all *res = parsed_result;
1565 uint32_t link_speed;
1568 if (!all_ports_stopped()) {
1569 printf("Please stop all ports first\n");
1573 if (parse_and_check_speed_duplex(res->value1, res->value2,
1577 RTE_ETH_FOREACH_DEV(pid) {
1578 ports[pid].dev_conf.link_speeds = link_speed;
1581 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1584 cmdline_parse_token_string_t cmd_config_speed_all_port =
1585 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1586 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1587 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1589 cmdline_parse_token_string_t cmd_config_speed_all_all =
1590 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1591 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1592 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1593 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1594 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1595 "10#100#1000#10000#25000#40000#50000#100000#auto");
1596 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1597 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1598 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1599 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1602 cmdline_parse_inst_t cmd_config_speed_all = {
1603 .f = cmd_config_speed_all_parsed,
1605 .help_str = "port config all speed "
1606 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1609 (void *)&cmd_config_speed_all_port,
1610 (void *)&cmd_config_speed_all_keyword,
1611 (void *)&cmd_config_speed_all_all,
1612 (void *)&cmd_config_speed_all_item1,
1613 (void *)&cmd_config_speed_all_value1,
1614 (void *)&cmd_config_speed_all_item2,
1615 (void *)&cmd_config_speed_all_value2,
1620 /* *** configure speed for specific port *** */
1621 struct cmd_config_speed_specific {
1622 cmdline_fixed_string_t port;
1623 cmdline_fixed_string_t keyword;
1625 cmdline_fixed_string_t item1;
1626 cmdline_fixed_string_t item2;
1627 cmdline_fixed_string_t value1;
1628 cmdline_fixed_string_t value2;
1632 cmd_config_speed_specific_parsed(void *parsed_result,
1633 __attribute__((unused)) struct cmdline *cl,
1634 __attribute__((unused)) void *data)
1636 struct cmd_config_speed_specific *res = parsed_result;
1637 uint32_t link_speed;
1639 if (!all_ports_stopped()) {
1640 printf("Please stop all ports first\n");
1644 if (port_id_is_invalid(res->id, ENABLED_WARN))
1647 if (parse_and_check_speed_duplex(res->value1, res->value2,
1651 ports[res->id].dev_conf.link_speeds = link_speed;
1653 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1657 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1658 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1660 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1661 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1663 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1664 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1665 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1666 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1668 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1669 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1670 "10#100#1000#10000#25000#40000#50000#100000#auto");
1671 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1672 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1674 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1675 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1678 cmdline_parse_inst_t cmd_config_speed_specific = {
1679 .f = cmd_config_speed_specific_parsed,
1681 .help_str = "port config <port_id> speed "
1682 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1685 (void *)&cmd_config_speed_specific_port,
1686 (void *)&cmd_config_speed_specific_keyword,
1687 (void *)&cmd_config_speed_specific_id,
1688 (void *)&cmd_config_speed_specific_item1,
1689 (void *)&cmd_config_speed_specific_value1,
1690 (void *)&cmd_config_speed_specific_item2,
1691 (void *)&cmd_config_speed_specific_value2,
1696 /* *** configure loopback for all ports *** */
1697 struct cmd_config_loopback_all {
1698 cmdline_fixed_string_t port;
1699 cmdline_fixed_string_t keyword;
1700 cmdline_fixed_string_t all;
1701 cmdline_fixed_string_t item;
1706 cmd_config_loopback_all_parsed(void *parsed_result,
1707 __attribute__((unused)) struct cmdline *cl,
1708 __attribute__((unused)) void *data)
1710 struct cmd_config_loopback_all *res = parsed_result;
1713 if (!all_ports_stopped()) {
1714 printf("Please stop all ports first\n");
1718 RTE_ETH_FOREACH_DEV(pid) {
1719 ports[pid].dev_conf.lpbk_mode = res->mode;
1722 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1725 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1726 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1727 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1728 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1730 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1731 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1732 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1733 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1735 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1736 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1738 cmdline_parse_inst_t cmd_config_loopback_all = {
1739 .f = cmd_config_loopback_all_parsed,
1741 .help_str = "port config all loopback <mode>",
1743 (void *)&cmd_config_loopback_all_port,
1744 (void *)&cmd_config_loopback_all_keyword,
1745 (void *)&cmd_config_loopback_all_all,
1746 (void *)&cmd_config_loopback_all_item,
1747 (void *)&cmd_config_loopback_all_mode,
1752 /* *** configure loopback for specific port *** */
1753 struct cmd_config_loopback_specific {
1754 cmdline_fixed_string_t port;
1755 cmdline_fixed_string_t keyword;
1757 cmdline_fixed_string_t item;
1762 cmd_config_loopback_specific_parsed(void *parsed_result,
1763 __attribute__((unused)) struct cmdline *cl,
1764 __attribute__((unused)) void *data)
1766 struct cmd_config_loopback_specific *res = parsed_result;
1768 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1771 if (!port_is_stopped(res->port_id)) {
1772 printf("Please stop port %u first\n", res->port_id);
1776 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1778 cmd_reconfig_device_queue(res->port_id, 1, 1);
1782 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1783 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1785 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1786 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1788 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1789 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1791 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1792 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1794 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1795 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1798 cmdline_parse_inst_t cmd_config_loopback_specific = {
1799 .f = cmd_config_loopback_specific_parsed,
1801 .help_str = "port config <port_id> loopback <mode>",
1803 (void *)&cmd_config_loopback_specific_port,
1804 (void *)&cmd_config_loopback_specific_keyword,
1805 (void *)&cmd_config_loopback_specific_id,
1806 (void *)&cmd_config_loopback_specific_item,
1807 (void *)&cmd_config_loopback_specific_mode,
1812 /* *** configure txq/rxq, txd/rxd *** */
1813 struct cmd_config_rx_tx {
1814 cmdline_fixed_string_t port;
1815 cmdline_fixed_string_t keyword;
1816 cmdline_fixed_string_t all;
1817 cmdline_fixed_string_t name;
1822 cmd_config_rx_tx_parsed(void *parsed_result,
1823 __attribute__((unused)) struct cmdline *cl,
1824 __attribute__((unused)) void *data)
1826 struct cmd_config_rx_tx *res = parsed_result;
1828 if (!all_ports_stopped()) {
1829 printf("Please stop all ports first\n");
1832 if (!strcmp(res->name, "rxq")) {
1833 if (!res->value && !nb_txq) {
1834 printf("Warning: Either rx or tx queues should be non zero\n");
1837 if (check_nb_rxq(res->value) != 0)
1839 nb_rxq = res->value;
1841 else if (!strcmp(res->name, "txq")) {
1842 if (!res->value && !nb_rxq) {
1843 printf("Warning: Either rx or tx queues should be non zero\n");
1846 if (check_nb_txq(res->value) != 0)
1848 nb_txq = res->value;
1850 else if (!strcmp(res->name, "rxd")) {
1851 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1852 printf("rxd %d invalid - must be > 0 && <= %d\n",
1853 res->value, RTE_TEST_RX_DESC_MAX);
1856 nb_rxd = res->value;
1857 } else if (!strcmp(res->name, "txd")) {
1858 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1859 printf("txd %d invalid - must be > 0 && <= %d\n",
1860 res->value, RTE_TEST_TX_DESC_MAX);
1863 nb_txd = res->value;
1865 printf("Unknown parameter\n");
1873 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1876 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1877 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1878 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1879 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1880 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1881 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1882 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1883 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1885 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1886 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1888 cmdline_parse_inst_t cmd_config_rx_tx = {
1889 .f = cmd_config_rx_tx_parsed,
1891 .help_str = "port config all rxq|txq|rxd|txd <value>",
1893 (void *)&cmd_config_rx_tx_port,
1894 (void *)&cmd_config_rx_tx_keyword,
1895 (void *)&cmd_config_rx_tx_all,
1896 (void *)&cmd_config_rx_tx_name,
1897 (void *)&cmd_config_rx_tx_value,
1902 /* *** config max packet length *** */
1903 struct cmd_config_max_pkt_len_result {
1904 cmdline_fixed_string_t port;
1905 cmdline_fixed_string_t keyword;
1906 cmdline_fixed_string_t all;
1907 cmdline_fixed_string_t name;
1912 cmd_config_max_pkt_len_parsed(void *parsed_result,
1913 __attribute__((unused)) struct cmdline *cl,
1914 __attribute__((unused)) void *data)
1916 struct cmd_config_max_pkt_len_result *res = parsed_result;
1919 if (!all_ports_stopped()) {
1920 printf("Please stop all ports first\n");
1924 RTE_ETH_FOREACH_DEV(pid) {
1925 struct rte_port *port = &ports[pid];
1926 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1928 if (!strcmp(res->name, "max-pkt-len")) {
1929 if (res->value < RTE_ETHER_MIN_LEN) {
1930 printf("max-pkt-len can not be less than %d\n",
1934 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1937 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1938 if (res->value > RTE_ETHER_MAX_LEN)
1939 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1941 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1942 port->dev_conf.rxmode.offloads = rx_offloads;
1944 printf("Unknown parameter\n");
1951 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1954 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1955 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1957 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1958 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1960 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1961 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1963 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1964 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1966 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1967 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1970 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1971 .f = cmd_config_max_pkt_len_parsed,
1973 .help_str = "port config all max-pkt-len <value>",
1975 (void *)&cmd_config_max_pkt_len_port,
1976 (void *)&cmd_config_max_pkt_len_keyword,
1977 (void *)&cmd_config_max_pkt_len_all,
1978 (void *)&cmd_config_max_pkt_len_name,
1979 (void *)&cmd_config_max_pkt_len_value,
1984 /* *** configure port MTU *** */
1985 struct cmd_config_mtu_result {
1986 cmdline_fixed_string_t port;
1987 cmdline_fixed_string_t keyword;
1988 cmdline_fixed_string_t mtu;
1994 cmd_config_mtu_parsed(void *parsed_result,
1995 __attribute__((unused)) struct cmdline *cl,
1996 __attribute__((unused)) void *data)
1998 struct cmd_config_mtu_result *res = parsed_result;
2000 if (res->value < RTE_ETHER_MIN_LEN) {
2001 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2004 port_mtu_set(res->port_id, res->value);
2007 cmdline_parse_token_string_t cmd_config_mtu_port =
2008 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2010 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2011 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2013 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2014 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2016 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2017 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2018 cmdline_parse_token_num_t cmd_config_mtu_value =
2019 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2021 cmdline_parse_inst_t cmd_config_mtu = {
2022 .f = cmd_config_mtu_parsed,
2024 .help_str = "port config mtu <port_id> <value>",
2026 (void *)&cmd_config_mtu_port,
2027 (void *)&cmd_config_mtu_keyword,
2028 (void *)&cmd_config_mtu_mtu,
2029 (void *)&cmd_config_mtu_port_id,
2030 (void *)&cmd_config_mtu_value,
2035 /* *** configure rx mode *** */
2036 struct cmd_config_rx_mode_flag {
2037 cmdline_fixed_string_t port;
2038 cmdline_fixed_string_t keyword;
2039 cmdline_fixed_string_t all;
2040 cmdline_fixed_string_t name;
2041 cmdline_fixed_string_t value;
2045 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2046 __attribute__((unused)) struct cmdline *cl,
2047 __attribute__((unused)) void *data)
2049 struct cmd_config_rx_mode_flag *res = parsed_result;
2053 if (!all_ports_stopped()) {
2054 printf("Please stop all ports first\n");
2058 RTE_ETH_FOREACH_DEV(pid) {
2059 struct rte_port *port;
2060 uint64_t rx_offloads;
2063 rx_offloads = port->dev_conf.rxmode.offloads;
2064 if (!strcmp(res->name, "crc-strip")) {
2065 if (!strcmp(res->value, "on")) {
2066 rx_offloads &= ~DEV_RX_OFFLOAD_KEEP_CRC;
2067 } else if (!strcmp(res->value, "off")) {
2068 rx_offloads |= DEV_RX_OFFLOAD_KEEP_CRC;
2070 printf("Unknown parameter\n");
2073 } else if (!strcmp(res->name, "scatter")) {
2074 if (!strcmp(res->value, "on")) {
2075 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
2076 } else if (!strcmp(res->value, "off")) {
2077 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
2079 printf("Unknown parameter\n");
2082 } else if (!strcmp(res->name, "rx-cksum")) {
2083 if (!strcmp(res->value, "on"))
2084 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
2085 else if (!strcmp(res->value, "off"))
2086 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
2088 printf("Unknown parameter\n");
2091 } else if (!strcmp(res->name, "rx-timestamp")) {
2092 if (!strcmp(res->value, "on"))
2093 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
2094 else if (!strcmp(res->value, "off"))
2095 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
2097 printf("Unknown parameter\n");
2100 } else if (!strcmp(res->name, "hw-vlan")) {
2101 if (!strcmp(res->value, "on")) {
2102 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
2103 DEV_RX_OFFLOAD_VLAN_STRIP);
2104 } else if (!strcmp(res->value, "off")) {
2105 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
2106 DEV_RX_OFFLOAD_VLAN_STRIP);
2108 printf("Unknown parameter\n");
2111 } else if (!strcmp(res->name, "hw-vlan-filter")) {
2112 if (!strcmp(res->value, "on"))
2113 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
2114 else if (!strcmp(res->value, "off"))
2115 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
2117 printf("Unknown parameter\n");
2120 } else if (!strcmp(res->name, "hw-vlan-strip")) {
2121 if (!strcmp(res->value, "on"))
2122 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
2123 else if (!strcmp(res->value, "off"))
2124 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
2126 printf("Unknown parameter\n");
2129 } else if (!strcmp(res->name, "hw-vlan-extend")) {
2130 if (!strcmp(res->value, "on"))
2131 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
2132 else if (!strcmp(res->value, "off"))
2133 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
2135 printf("Unknown parameter\n");
2138 } else if (!strcmp(res->name, "drop-en")) {
2139 if (!strcmp(res->value, "on"))
2141 else if (!strcmp(res->value, "off"))
2144 printf("Unknown parameter\n");
2148 printf("Unknown parameter\n");
2151 port->dev_conf.rxmode.offloads = rx_offloads;
2152 /* Apply Rx offloads configuration */
2153 for (k = 0; k < port->dev_info.max_rx_queues; k++)
2154 port->rx_conf[k].offloads =
2155 port->dev_conf.rxmode.offloads;
2160 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2163 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2164 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2165 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2166 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2168 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2169 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2170 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2171 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2172 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
2173 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
2174 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2175 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2178 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2179 .f = cmd_config_rx_mode_flag_parsed,
2181 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
2182 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
2184 (void *)&cmd_config_rx_mode_flag_port,
2185 (void *)&cmd_config_rx_mode_flag_keyword,
2186 (void *)&cmd_config_rx_mode_flag_all,
2187 (void *)&cmd_config_rx_mode_flag_name,
2188 (void *)&cmd_config_rx_mode_flag_value,
2193 /* *** configure rss *** */
2194 struct cmd_config_rss {
2195 cmdline_fixed_string_t port;
2196 cmdline_fixed_string_t keyword;
2197 cmdline_fixed_string_t all;
2198 cmdline_fixed_string_t name;
2199 cmdline_fixed_string_t value;
2203 cmd_config_rss_parsed(void *parsed_result,
2204 __attribute__((unused)) struct cmdline *cl,
2205 __attribute__((unused)) void *data)
2207 struct cmd_config_rss *res = parsed_result;
2208 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2209 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2210 int use_default = 0;
2211 int all_updated = 1;
2215 if (!strcmp(res->value, "all"))
2216 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2217 ETH_RSS_UDP | ETH_RSS_SCTP |
2219 else if (!strcmp(res->value, "ip"))
2220 rss_conf.rss_hf = ETH_RSS_IP;
2221 else if (!strcmp(res->value, "udp"))
2222 rss_conf.rss_hf = ETH_RSS_UDP;
2223 else if (!strcmp(res->value, "tcp"))
2224 rss_conf.rss_hf = ETH_RSS_TCP;
2225 else if (!strcmp(res->value, "sctp"))
2226 rss_conf.rss_hf = ETH_RSS_SCTP;
2227 else if (!strcmp(res->value, "ether"))
2228 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2229 else if (!strcmp(res->value, "port"))
2230 rss_conf.rss_hf = ETH_RSS_PORT;
2231 else if (!strcmp(res->value, "vxlan"))
2232 rss_conf.rss_hf = ETH_RSS_VXLAN;
2233 else if (!strcmp(res->value, "geneve"))
2234 rss_conf.rss_hf = ETH_RSS_GENEVE;
2235 else if (!strcmp(res->value, "nvgre"))
2236 rss_conf.rss_hf = ETH_RSS_NVGRE;
2237 else if (!strcmp(res->value, "none"))
2238 rss_conf.rss_hf = 0;
2239 else if (!strcmp(res->value, "default"))
2241 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2242 atoi(res->value) < 64)
2243 rss_conf.rss_hf = 1ULL << atoi(res->value);
2245 printf("Unknown parameter\n");
2248 rss_conf.rss_key = NULL;
2249 /* Update global configuration for RSS types. */
2250 RTE_ETH_FOREACH_DEV(i) {
2251 struct rte_eth_rss_conf local_rss_conf;
2253 rte_eth_dev_info_get(i, &dev_info);
2255 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2257 local_rss_conf = rss_conf;
2258 local_rss_conf.rss_hf = rss_conf.rss_hf &
2259 dev_info.flow_type_rss_offloads;
2260 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2261 printf("Port %u modified RSS hash function based on hardware support,"
2262 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2263 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2265 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2268 printf("Configuration of RSS hash at ethernet port %d "
2269 "failed with error (%d): %s.\n",
2270 i, -diag, strerror(-diag));
2273 if (all_updated && !use_default)
2274 rss_hf = rss_conf.rss_hf;
2277 cmdline_parse_token_string_t cmd_config_rss_port =
2278 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2279 cmdline_parse_token_string_t cmd_config_rss_keyword =
2280 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2281 cmdline_parse_token_string_t cmd_config_rss_all =
2282 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2283 cmdline_parse_token_string_t cmd_config_rss_name =
2284 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2285 cmdline_parse_token_string_t cmd_config_rss_value =
2286 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2288 cmdline_parse_inst_t cmd_config_rss = {
2289 .f = cmd_config_rss_parsed,
2291 .help_str = "port config all rss "
2292 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>",
2294 (void *)&cmd_config_rss_port,
2295 (void *)&cmd_config_rss_keyword,
2296 (void *)&cmd_config_rss_all,
2297 (void *)&cmd_config_rss_name,
2298 (void *)&cmd_config_rss_value,
2303 /* *** configure rss hash key *** */
2304 struct cmd_config_rss_hash_key {
2305 cmdline_fixed_string_t port;
2306 cmdline_fixed_string_t config;
2308 cmdline_fixed_string_t rss_hash_key;
2309 cmdline_fixed_string_t rss_type;
2310 cmdline_fixed_string_t key;
2314 hexa_digit_to_value(char hexa_digit)
2316 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2317 return (uint8_t) (hexa_digit - '0');
2318 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2319 return (uint8_t) ((hexa_digit - 'a') + 10);
2320 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2321 return (uint8_t) ((hexa_digit - 'A') + 10);
2322 /* Invalid hexa digit */
2327 parse_and_check_key_hexa_digit(char *key, int idx)
2331 hexa_v = hexa_digit_to_value(key[idx]);
2333 printf("invalid key: character %c at position %d is not a "
2334 "valid hexa digit\n", key[idx], idx);
2339 cmd_config_rss_hash_key_parsed(void *parsed_result,
2340 __attribute__((unused)) struct cmdline *cl,
2341 __attribute__((unused)) void *data)
2343 struct cmd_config_rss_hash_key *res = parsed_result;
2344 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2348 struct rte_eth_dev_info dev_info;
2349 uint8_t hash_key_size;
2352 memset(&dev_info, 0, sizeof(dev_info));
2353 rte_eth_dev_info_get(res->port_id, &dev_info);
2354 if (dev_info.hash_key_size > 0 &&
2355 dev_info.hash_key_size <= sizeof(hash_key))
2356 hash_key_size = dev_info.hash_key_size;
2358 printf("dev_info did not provide a valid hash key size\n");
2361 /* Check the length of the RSS hash key */
2362 key_len = strlen(res->key);
2363 if (key_len != (hash_key_size * 2)) {
2364 printf("key length: %d invalid - key must be a string of %d"
2365 " hexa-decimal numbers\n",
2366 (int) key_len, hash_key_size * 2);
2369 /* Translate RSS hash key into binary representation */
2370 for (i = 0; i < hash_key_size; i++) {
2371 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2374 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2377 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2379 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2383 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2384 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2385 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2386 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2388 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2389 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2390 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2391 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2392 rss_hash_key, "rss-hash-key");
2393 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2394 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2395 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2396 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2397 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2398 "ipv6-tcp-ex#ipv6-udp-ex");
2399 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2400 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2402 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2403 .f = cmd_config_rss_hash_key_parsed,
2405 .help_str = "port config <port_id> rss-hash-key "
2406 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2407 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2408 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2409 "<string of hex digits (variable length, NIC dependent)>",
2411 (void *)&cmd_config_rss_hash_key_port,
2412 (void *)&cmd_config_rss_hash_key_config,
2413 (void *)&cmd_config_rss_hash_key_port_id,
2414 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2415 (void *)&cmd_config_rss_hash_key_rss_type,
2416 (void *)&cmd_config_rss_hash_key_value,
2421 /* *** configure port rxq/txq ring size *** */
2422 struct cmd_config_rxtx_ring_size {
2423 cmdline_fixed_string_t port;
2424 cmdline_fixed_string_t config;
2426 cmdline_fixed_string_t rxtxq;
2428 cmdline_fixed_string_t rsize;
2433 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2434 __attribute__((unused)) struct cmdline *cl,
2435 __attribute__((unused)) void *data)
2437 struct cmd_config_rxtx_ring_size *res = parsed_result;
2438 struct rte_port *port;
2441 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2444 if (res->portid == (portid_t)RTE_PORT_ALL) {
2445 printf("Invalid port id\n");
2449 port = &ports[res->portid];
2451 if (!strcmp(res->rxtxq, "rxq"))
2453 else if (!strcmp(res->rxtxq, "txq"))
2456 printf("Unknown parameter\n");
2460 if (isrx && rx_queue_id_is_invalid(res->qid))
2462 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2465 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2466 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2472 port->nb_rx_desc[res->qid] = res->size;
2474 port->nb_tx_desc[res->qid] = res->size;
2476 cmd_reconfig_device_queue(res->portid, 0, 1);
2479 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2480 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2482 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2483 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2485 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2486 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2488 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2489 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2491 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2492 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2494 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2495 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2496 rsize, "ring_size");
2497 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2498 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2501 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2502 .f = cmd_config_rxtx_ring_size_parsed,
2504 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2506 (void *)&cmd_config_rxtx_ring_size_port,
2507 (void *)&cmd_config_rxtx_ring_size_config,
2508 (void *)&cmd_config_rxtx_ring_size_portid,
2509 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2510 (void *)&cmd_config_rxtx_ring_size_qid,
2511 (void *)&cmd_config_rxtx_ring_size_rsize,
2512 (void *)&cmd_config_rxtx_ring_size_size,
2517 /* *** configure port rxq/txq start/stop *** */
2518 struct cmd_config_rxtx_queue {
2519 cmdline_fixed_string_t port;
2521 cmdline_fixed_string_t rxtxq;
2523 cmdline_fixed_string_t opname;
2527 cmd_config_rxtx_queue_parsed(void *parsed_result,
2528 __attribute__((unused)) struct cmdline *cl,
2529 __attribute__((unused)) void *data)
2531 struct cmd_config_rxtx_queue *res = parsed_result;
2536 if (test_done == 0) {
2537 printf("Please stop forwarding first\n");
2541 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2544 if (port_is_started(res->portid) != 1) {
2545 printf("Please start port %u first\n", res->portid);
2549 if (!strcmp(res->rxtxq, "rxq"))
2551 else if (!strcmp(res->rxtxq, "txq"))
2554 printf("Unknown parameter\n");
2558 if (isrx && rx_queue_id_is_invalid(res->qid))
2560 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2563 if (!strcmp(res->opname, "start"))
2565 else if (!strcmp(res->opname, "stop"))
2568 printf("Unknown parameter\n");
2572 if (isstart && isrx)
2573 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2574 else if (!isstart && isrx)
2575 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2576 else if (isstart && !isrx)
2577 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2579 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2581 if (ret == -ENOTSUP)
2582 printf("Function not supported in PMD driver\n");
2585 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2586 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2587 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2588 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2589 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2590 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2591 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2592 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2593 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2594 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2597 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2598 .f = cmd_config_rxtx_queue_parsed,
2600 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2602 (void *)&cmd_config_rxtx_queue_port,
2603 (void *)&cmd_config_rxtx_queue_portid,
2604 (void *)&cmd_config_rxtx_queue_rxtxq,
2605 (void *)&cmd_config_rxtx_queue_qid,
2606 (void *)&cmd_config_rxtx_queue_opname,
2611 /* *** configure port rxq/txq deferred start on/off *** */
2612 struct cmd_config_deferred_start_rxtx_queue {
2613 cmdline_fixed_string_t port;
2615 cmdline_fixed_string_t rxtxq;
2617 cmdline_fixed_string_t opname;
2618 cmdline_fixed_string_t state;
2622 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2623 __attribute__((unused)) struct cmdline *cl,
2624 __attribute__((unused)) void *data)
2626 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2627 struct rte_port *port;
2630 uint8_t needreconfig = 0;
2632 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2635 if (port_is_started(res->port_id) != 0) {
2636 printf("Please stop port %u first\n", res->port_id);
2640 port = &ports[res->port_id];
2642 isrx = !strcmp(res->rxtxq, "rxq");
2644 if (isrx && rx_queue_id_is_invalid(res->qid))
2646 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2649 ison = !strcmp(res->state, "on");
2651 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2652 port->rx_conf[res->qid].rx_deferred_start = ison;
2654 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2655 port->tx_conf[res->qid].tx_deferred_start = ison;
2660 cmd_reconfig_device_queue(res->port_id, 0, 1);
2663 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2664 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2666 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2667 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2669 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2670 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2672 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2673 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2675 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2676 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2677 opname, "deferred_start");
2678 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2679 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2682 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2683 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2685 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2687 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2688 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2689 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2690 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2691 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2692 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2697 /* *** configure port rxq/txq setup *** */
2698 struct cmd_setup_rxtx_queue {
2699 cmdline_fixed_string_t port;
2701 cmdline_fixed_string_t rxtxq;
2703 cmdline_fixed_string_t setup;
2706 /* Common CLI fields for queue setup */
2707 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2708 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2709 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2710 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2711 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2712 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2713 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2714 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2715 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2716 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2719 cmd_setup_rxtx_queue_parsed(
2720 void *parsed_result,
2721 __attribute__((unused)) struct cmdline *cl,
2722 __attribute__((unused)) void *data)
2724 struct cmd_setup_rxtx_queue *res = parsed_result;
2725 struct rte_port *port;
2726 struct rte_mempool *mp;
2727 unsigned int socket_id;
2731 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2734 if (res->portid == (portid_t)RTE_PORT_ALL) {
2735 printf("Invalid port id\n");
2739 if (!strcmp(res->rxtxq, "rxq"))
2741 else if (!strcmp(res->rxtxq, "txq"))
2744 printf("Unknown parameter\n");
2748 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2749 printf("Invalid rx queue\n");
2751 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2752 printf("Invalid tx queue\n");
2756 port = &ports[res->portid];
2758 socket_id = rxring_numa[res->portid];
2759 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2760 socket_id = port->socket_id;
2762 mp = mbuf_pool_find(socket_id);
2764 printf("Failed to setup RX queue: "
2765 "No mempool allocation"
2766 " on the socket %d\n",
2767 rxring_numa[res->portid]);
2770 ret = rte_eth_rx_queue_setup(res->portid,
2772 port->nb_rx_desc[res->qid],
2774 &port->rx_conf[res->qid],
2777 printf("Failed to setup RX queue\n");
2779 socket_id = txring_numa[res->portid];
2780 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2781 socket_id = port->socket_id;
2783 ret = rte_eth_tx_queue_setup(res->portid,
2785 port->nb_tx_desc[res->qid],
2787 &port->tx_conf[res->qid]);
2789 printf("Failed to setup TX queue\n");
2793 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2794 .f = cmd_setup_rxtx_queue_parsed,
2796 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2798 (void *)&cmd_setup_rxtx_queue_port,
2799 (void *)&cmd_setup_rxtx_queue_portid,
2800 (void *)&cmd_setup_rxtx_queue_rxtxq,
2801 (void *)&cmd_setup_rxtx_queue_qid,
2802 (void *)&cmd_setup_rxtx_queue_setup,
2808 /* *** Configure RSS RETA *** */
2809 struct cmd_config_rss_reta {
2810 cmdline_fixed_string_t port;
2811 cmdline_fixed_string_t keyword;
2813 cmdline_fixed_string_t name;
2814 cmdline_fixed_string_t list_name;
2815 cmdline_fixed_string_t list_of_items;
2819 parse_reta_config(const char *str,
2820 struct rte_eth_rss_reta_entry64 *reta_conf,
2821 uint16_t nb_entries)
2825 uint16_t hash_index, idx, shift;
2828 const char *p, *p0 = str;
2835 unsigned long int_fld[_NUM_FLD];
2836 char *str_fld[_NUM_FLD];
2838 while ((p = strchr(p0,'(')) != NULL) {
2840 if((p0 = strchr(p,')')) == NULL)
2844 if(size >= sizeof(s))
2847 snprintf(s, sizeof(s), "%.*s", size, p);
2848 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2850 for (i = 0; i < _NUM_FLD; i++) {
2852 int_fld[i] = strtoul(str_fld[i], &end, 0);
2853 if (errno != 0 || end == str_fld[i] ||
2858 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2859 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2861 if (hash_index >= nb_entries) {
2862 printf("Invalid RETA hash index=%d\n", hash_index);
2866 idx = hash_index / RTE_RETA_GROUP_SIZE;
2867 shift = hash_index % RTE_RETA_GROUP_SIZE;
2868 reta_conf[idx].mask |= (1ULL << shift);
2869 reta_conf[idx].reta[shift] = nb_queue;
2876 cmd_set_rss_reta_parsed(void *parsed_result,
2877 __attribute__((unused)) struct cmdline *cl,
2878 __attribute__((unused)) void *data)
2881 struct rte_eth_dev_info dev_info;
2882 struct rte_eth_rss_reta_entry64 reta_conf[8];
2883 struct cmd_config_rss_reta *res = parsed_result;
2885 memset(&dev_info, 0, sizeof(dev_info));
2886 rte_eth_dev_info_get(res->port_id, &dev_info);
2887 if (dev_info.reta_size == 0) {
2888 printf("Redirection table size is 0 which is "
2889 "invalid for RSS\n");
2892 printf("The reta size of port %d is %u\n",
2893 res->port_id, dev_info.reta_size);
2894 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2895 printf("Currently do not support more than %u entries of "
2896 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2900 memset(reta_conf, 0, sizeof(reta_conf));
2901 if (!strcmp(res->list_name, "reta")) {
2902 if (parse_reta_config(res->list_of_items, reta_conf,
2903 dev_info.reta_size)) {
2904 printf("Invalid RSS Redirection Table "
2905 "config entered\n");
2908 ret = rte_eth_dev_rss_reta_update(res->port_id,
2909 reta_conf, dev_info.reta_size);
2911 printf("Bad redirection table parameter, "
2912 "return code = %d \n", ret);
2916 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2917 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2918 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2919 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2920 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2921 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2922 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2923 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2924 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2925 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2926 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2927 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2929 cmdline_parse_inst_t cmd_config_rss_reta = {
2930 .f = cmd_set_rss_reta_parsed,
2932 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2934 (void *)&cmd_config_rss_reta_port,
2935 (void *)&cmd_config_rss_reta_keyword,
2936 (void *)&cmd_config_rss_reta_port_id,
2937 (void *)&cmd_config_rss_reta_name,
2938 (void *)&cmd_config_rss_reta_list_name,
2939 (void *)&cmd_config_rss_reta_list_of_items,
2944 /* *** SHOW PORT RETA INFO *** */
2945 struct cmd_showport_reta {
2946 cmdline_fixed_string_t show;
2947 cmdline_fixed_string_t port;
2949 cmdline_fixed_string_t rss;
2950 cmdline_fixed_string_t reta;
2952 cmdline_fixed_string_t list_of_items;
2956 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2957 uint16_t nb_entries,
2961 const char *p, *p0 = str;
2966 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2967 RTE_RETA_GROUP_SIZE;
2970 p = strchr(p0, '(');
2974 p0 = strchr(p, ')');
2978 if (size >= sizeof(s)) {
2979 printf("The string size exceeds the internal buffer size\n");
2982 snprintf(s, sizeof(s), "%.*s", size, p);
2983 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2984 if (ret <= 0 || ret != num) {
2985 printf("The bits of masks do not match the number of "
2986 "reta entries: %u\n", num);
2989 for (i = 0; i < ret; i++)
2990 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2996 cmd_showport_reta_parsed(void *parsed_result,
2997 __attribute__((unused)) struct cmdline *cl,
2998 __attribute__((unused)) void *data)
3000 struct cmd_showport_reta *res = parsed_result;
3001 struct rte_eth_rss_reta_entry64 reta_conf[8];
3002 struct rte_eth_dev_info dev_info;
3003 uint16_t max_reta_size;
3005 memset(&dev_info, 0, sizeof(dev_info));
3006 rte_eth_dev_info_get(res->port_id, &dev_info);
3007 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3008 if (res->size == 0 || res->size > max_reta_size) {
3009 printf("Invalid redirection table size: %u (1-%u)\n",
3010 res->size, max_reta_size);
3014 memset(reta_conf, 0, sizeof(reta_conf));
3015 if (showport_parse_reta_config(reta_conf, res->size,
3016 res->list_of_items) < 0) {
3017 printf("Invalid string: %s for reta masks\n",
3018 res->list_of_items);
3021 port_rss_reta_info(res->port_id, reta_conf, res->size);
3024 cmdline_parse_token_string_t cmd_showport_reta_show =
3025 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3026 cmdline_parse_token_string_t cmd_showport_reta_port =
3027 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3028 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3029 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3030 cmdline_parse_token_string_t cmd_showport_reta_rss =
3031 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3032 cmdline_parse_token_string_t cmd_showport_reta_reta =
3033 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3034 cmdline_parse_token_num_t cmd_showport_reta_size =
3035 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3036 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3037 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3038 list_of_items, NULL);
3040 cmdline_parse_inst_t cmd_showport_reta = {
3041 .f = cmd_showport_reta_parsed,
3043 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3045 (void *)&cmd_showport_reta_show,
3046 (void *)&cmd_showport_reta_port,
3047 (void *)&cmd_showport_reta_port_id,
3048 (void *)&cmd_showport_reta_rss,
3049 (void *)&cmd_showport_reta_reta,
3050 (void *)&cmd_showport_reta_size,
3051 (void *)&cmd_showport_reta_list_of_items,
3056 /* *** Show RSS hash configuration *** */
3057 struct cmd_showport_rss_hash {
3058 cmdline_fixed_string_t show;
3059 cmdline_fixed_string_t port;
3061 cmdline_fixed_string_t rss_hash;
3062 cmdline_fixed_string_t rss_type;
3063 cmdline_fixed_string_t key; /* optional argument */
3066 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3067 __attribute__((unused)) struct cmdline *cl,
3070 struct cmd_showport_rss_hash *res = parsed_result;
3072 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3075 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3076 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3077 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3078 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3079 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3080 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3081 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3082 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3084 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3085 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3087 cmdline_parse_inst_t cmd_showport_rss_hash = {
3088 .f = cmd_showport_rss_hash_parsed,
3090 .help_str = "show port <port_id> rss-hash",
3092 (void *)&cmd_showport_rss_hash_show,
3093 (void *)&cmd_showport_rss_hash_port,
3094 (void *)&cmd_showport_rss_hash_port_id,
3095 (void *)&cmd_showport_rss_hash_rss_hash,
3100 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3101 .f = cmd_showport_rss_hash_parsed,
3103 .help_str = "show port <port_id> rss-hash key",
3105 (void *)&cmd_showport_rss_hash_show,
3106 (void *)&cmd_showport_rss_hash_port,
3107 (void *)&cmd_showport_rss_hash_port_id,
3108 (void *)&cmd_showport_rss_hash_rss_hash,
3109 (void *)&cmd_showport_rss_hash_rss_key,
3114 /* *** Configure DCB *** */
3115 struct cmd_config_dcb {
3116 cmdline_fixed_string_t port;
3117 cmdline_fixed_string_t config;
3119 cmdline_fixed_string_t dcb;
3120 cmdline_fixed_string_t vt;
3121 cmdline_fixed_string_t vt_en;
3123 cmdline_fixed_string_t pfc;
3124 cmdline_fixed_string_t pfc_en;
3128 cmd_config_dcb_parsed(void *parsed_result,
3129 __attribute__((unused)) struct cmdline *cl,
3130 __attribute__((unused)) void *data)
3132 struct cmd_config_dcb *res = parsed_result;
3133 portid_t port_id = res->port_id;
3134 struct rte_port *port;
3138 port = &ports[port_id];
3139 /** Check if the port is not started **/
3140 if (port->port_status != RTE_PORT_STOPPED) {
3141 printf("Please stop port %d first\n", port_id);
3145 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3146 printf("The invalid number of traffic class,"
3147 " only 4 or 8 allowed.\n");
3151 if (nb_fwd_lcores < res->num_tcs) {
3152 printf("nb_cores shouldn't be less than number of TCs.\n");
3155 if (!strncmp(res->pfc_en, "on", 2))
3160 /* DCB in VT mode */
3161 if (!strncmp(res->vt_en, "on", 2))
3162 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3163 (enum rte_eth_nb_tcs)res->num_tcs,
3166 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3167 (enum rte_eth_nb_tcs)res->num_tcs,
3172 printf("Cannot initialize network ports.\n");
3176 cmd_reconfig_device_queue(port_id, 1, 1);
3179 cmdline_parse_token_string_t cmd_config_dcb_port =
3180 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3181 cmdline_parse_token_string_t cmd_config_dcb_config =
3182 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3183 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3184 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3185 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3186 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3187 cmdline_parse_token_string_t cmd_config_dcb_vt =
3188 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3189 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3190 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3191 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3192 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3193 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3194 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3195 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3196 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3198 cmdline_parse_inst_t cmd_config_dcb = {
3199 .f = cmd_config_dcb_parsed,
3201 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3203 (void *)&cmd_config_dcb_port,
3204 (void *)&cmd_config_dcb_config,
3205 (void *)&cmd_config_dcb_port_id,
3206 (void *)&cmd_config_dcb_dcb,
3207 (void *)&cmd_config_dcb_vt,
3208 (void *)&cmd_config_dcb_vt_en,
3209 (void *)&cmd_config_dcb_num_tcs,
3210 (void *)&cmd_config_dcb_pfc,
3211 (void *)&cmd_config_dcb_pfc_en,
3216 /* *** configure number of packets per burst *** */
3217 struct cmd_config_burst {
3218 cmdline_fixed_string_t port;
3219 cmdline_fixed_string_t keyword;
3220 cmdline_fixed_string_t all;
3221 cmdline_fixed_string_t name;
3226 cmd_config_burst_parsed(void *parsed_result,
3227 __attribute__((unused)) struct cmdline *cl,
3228 __attribute__((unused)) void *data)
3230 struct cmd_config_burst *res = parsed_result;
3231 struct rte_eth_dev_info dev_info;
3232 uint16_t rec_nb_pkts;
3234 if (!all_ports_stopped()) {
3235 printf("Please stop all ports first\n");
3239 if (!strcmp(res->name, "burst")) {
3240 if (res->value == 0) {
3241 /* If user gives a value of zero, query the PMD for
3242 * its recommended Rx burst size. Testpmd uses a single
3243 * size for all ports, so assume all ports are the same
3244 * NIC model and use the values from Port 0.
3246 rte_eth_dev_info_get(0, &dev_info);
3247 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3249 if (rec_nb_pkts == 0) {
3250 printf("PMD does not recommend a burst size.\n"
3251 "User provided value must be between"
3252 " 1 and %d\n", MAX_PKT_BURST);
3254 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3255 printf("PMD recommended burst size of %d"
3256 " exceeds maximum value of %d\n",
3257 rec_nb_pkts, MAX_PKT_BURST);
3260 printf("Using PMD-provided burst value of %d\n",
3262 nb_pkt_per_burst = rec_nb_pkts;
3263 } else if (res->value > MAX_PKT_BURST) {
3264 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3267 nb_pkt_per_burst = res->value;
3269 printf("Unknown parameter\n");
3275 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3278 cmdline_parse_token_string_t cmd_config_burst_port =
3279 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3280 cmdline_parse_token_string_t cmd_config_burst_keyword =
3281 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3282 cmdline_parse_token_string_t cmd_config_burst_all =
3283 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3284 cmdline_parse_token_string_t cmd_config_burst_name =
3285 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3286 cmdline_parse_token_num_t cmd_config_burst_value =
3287 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3289 cmdline_parse_inst_t cmd_config_burst = {
3290 .f = cmd_config_burst_parsed,
3292 .help_str = "port config all burst <value>",
3294 (void *)&cmd_config_burst_port,
3295 (void *)&cmd_config_burst_keyword,
3296 (void *)&cmd_config_burst_all,
3297 (void *)&cmd_config_burst_name,
3298 (void *)&cmd_config_burst_value,
3303 /* *** configure rx/tx queues *** */
3304 struct cmd_config_thresh {
3305 cmdline_fixed_string_t port;
3306 cmdline_fixed_string_t keyword;
3307 cmdline_fixed_string_t all;
3308 cmdline_fixed_string_t name;
3313 cmd_config_thresh_parsed(void *parsed_result,
3314 __attribute__((unused)) struct cmdline *cl,
3315 __attribute__((unused)) void *data)
3317 struct cmd_config_thresh *res = parsed_result;
3319 if (!all_ports_stopped()) {
3320 printf("Please stop all ports first\n");
3324 if (!strcmp(res->name, "txpt"))
3325 tx_pthresh = res->value;
3326 else if(!strcmp(res->name, "txht"))
3327 tx_hthresh = res->value;
3328 else if(!strcmp(res->name, "txwt"))
3329 tx_wthresh = res->value;
3330 else if(!strcmp(res->name, "rxpt"))
3331 rx_pthresh = res->value;
3332 else if(!strcmp(res->name, "rxht"))
3333 rx_hthresh = res->value;
3334 else if(!strcmp(res->name, "rxwt"))
3335 rx_wthresh = res->value;
3337 printf("Unknown parameter\n");
3343 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3346 cmdline_parse_token_string_t cmd_config_thresh_port =
3347 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3348 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3349 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3350 cmdline_parse_token_string_t cmd_config_thresh_all =
3351 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3352 cmdline_parse_token_string_t cmd_config_thresh_name =
3353 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3354 "txpt#txht#txwt#rxpt#rxht#rxwt");
3355 cmdline_parse_token_num_t cmd_config_thresh_value =
3356 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3358 cmdline_parse_inst_t cmd_config_thresh = {
3359 .f = cmd_config_thresh_parsed,
3361 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3363 (void *)&cmd_config_thresh_port,
3364 (void *)&cmd_config_thresh_keyword,
3365 (void *)&cmd_config_thresh_all,
3366 (void *)&cmd_config_thresh_name,
3367 (void *)&cmd_config_thresh_value,
3372 /* *** configure free/rs threshold *** */
3373 struct cmd_config_threshold {
3374 cmdline_fixed_string_t port;
3375 cmdline_fixed_string_t keyword;
3376 cmdline_fixed_string_t all;
3377 cmdline_fixed_string_t name;
3382 cmd_config_threshold_parsed(void *parsed_result,
3383 __attribute__((unused)) struct cmdline *cl,
3384 __attribute__((unused)) void *data)
3386 struct cmd_config_threshold *res = parsed_result;
3388 if (!all_ports_stopped()) {
3389 printf("Please stop all ports first\n");
3393 if (!strcmp(res->name, "txfreet"))
3394 tx_free_thresh = res->value;
3395 else if (!strcmp(res->name, "txrst"))
3396 tx_rs_thresh = res->value;
3397 else if (!strcmp(res->name, "rxfreet"))
3398 rx_free_thresh = res->value;
3400 printf("Unknown parameter\n");
3406 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3409 cmdline_parse_token_string_t cmd_config_threshold_port =
3410 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3411 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3412 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3414 cmdline_parse_token_string_t cmd_config_threshold_all =
3415 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3416 cmdline_parse_token_string_t cmd_config_threshold_name =
3417 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3418 "txfreet#txrst#rxfreet");
3419 cmdline_parse_token_num_t cmd_config_threshold_value =
3420 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3422 cmdline_parse_inst_t cmd_config_threshold = {
3423 .f = cmd_config_threshold_parsed,
3425 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3427 (void *)&cmd_config_threshold_port,
3428 (void *)&cmd_config_threshold_keyword,
3429 (void *)&cmd_config_threshold_all,
3430 (void *)&cmd_config_threshold_name,
3431 (void *)&cmd_config_threshold_value,
3437 struct cmd_stop_result {
3438 cmdline_fixed_string_t stop;
3441 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3442 __attribute__((unused)) struct cmdline *cl,
3443 __attribute__((unused)) void *data)
3445 stop_packet_forwarding();
3448 cmdline_parse_token_string_t cmd_stop_stop =
3449 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3451 cmdline_parse_inst_t cmd_stop = {
3452 .f = cmd_stop_parsed,
3454 .help_str = "stop: Stop packet forwarding",
3456 (void *)&cmd_stop_stop,
3461 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3464 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3465 unsigned int *parsed_items, int check_unique_values)
3467 unsigned int nb_item;
3475 * First parse all items in the list and store their value.
3480 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3482 if ((c >= '0') && (c <= '9')) {
3483 value = (unsigned int) (value * 10 + (c - '0'));
3488 printf("character %c is not a decimal digit\n", c);
3492 printf("No valid value before comma\n");
3495 if (nb_item < max_items) {
3496 parsed_items[nb_item] = value;
3502 if (nb_item >= max_items) {
3503 printf("Number of %s = %u > %u (maximum items)\n",
3504 item_name, nb_item + 1, max_items);
3507 parsed_items[nb_item++] = value;
3508 if (! check_unique_values)
3512 * Then, check that all values in the list are differents.
3513 * No optimization here...
3515 for (i = 0; i < nb_item; i++) {
3516 for (j = i + 1; j < nb_item; j++) {
3517 if (parsed_items[j] == parsed_items[i]) {
3518 printf("duplicated %s %u at index %u and %u\n",
3519 item_name, parsed_items[i], i, j);
3527 struct cmd_set_list_result {
3528 cmdline_fixed_string_t cmd_keyword;
3529 cmdline_fixed_string_t list_name;
3530 cmdline_fixed_string_t list_of_items;
3533 static void cmd_set_list_parsed(void *parsed_result,
3534 __attribute__((unused)) struct cmdline *cl,
3535 __attribute__((unused)) void *data)
3537 struct cmd_set_list_result *res;
3539 unsigned int lcorelist[RTE_MAX_LCORE];
3540 unsigned int portlist[RTE_MAX_ETHPORTS];
3542 unsigned int nb_item;
3544 if (test_done == 0) {
3545 printf("Please stop forwarding first\n");
3549 res = parsed_result;
3550 if (!strcmp(res->list_name, "corelist")) {
3551 nb_item = parse_item_list(res->list_of_items, "core",
3553 parsed_items.lcorelist, 1);
3555 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3560 if (!strcmp(res->list_name, "portlist")) {
3561 nb_item = parse_item_list(res->list_of_items, "port",
3563 parsed_items.portlist, 1);
3565 set_fwd_ports_list(parsed_items.portlist, nb_item);
3571 cmdline_parse_token_string_t cmd_set_list_keyword =
3572 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3574 cmdline_parse_token_string_t cmd_set_list_name =
3575 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3576 "corelist#portlist");
3577 cmdline_parse_token_string_t cmd_set_list_of_items =
3578 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3581 cmdline_parse_inst_t cmd_set_fwd_list = {
3582 .f = cmd_set_list_parsed,
3584 .help_str = "set corelist|portlist <list0[,list1]*>",
3586 (void *)&cmd_set_list_keyword,
3587 (void *)&cmd_set_list_name,
3588 (void *)&cmd_set_list_of_items,
3593 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3595 struct cmd_setmask_result {
3596 cmdline_fixed_string_t set;
3597 cmdline_fixed_string_t mask;
3601 static void cmd_set_mask_parsed(void *parsed_result,
3602 __attribute__((unused)) struct cmdline *cl,
3603 __attribute__((unused)) void *data)
3605 struct cmd_setmask_result *res = parsed_result;
3607 if (test_done == 0) {
3608 printf("Please stop forwarding first\n");
3611 if (!strcmp(res->mask, "coremask")) {
3612 set_fwd_lcores_mask(res->hexavalue);
3614 } else if (!strcmp(res->mask, "portmask")) {
3615 set_fwd_ports_mask(res->hexavalue);
3620 cmdline_parse_token_string_t cmd_setmask_set =
3621 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3622 cmdline_parse_token_string_t cmd_setmask_mask =
3623 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3624 "coremask#portmask");
3625 cmdline_parse_token_num_t cmd_setmask_value =
3626 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3628 cmdline_parse_inst_t cmd_set_fwd_mask = {
3629 .f = cmd_set_mask_parsed,
3631 .help_str = "set coremask|portmask <hexadecimal value>",
3633 (void *)&cmd_setmask_set,
3634 (void *)&cmd_setmask_mask,
3635 (void *)&cmd_setmask_value,
3641 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3643 struct cmd_set_result {
3644 cmdline_fixed_string_t set;
3645 cmdline_fixed_string_t what;
3649 static void cmd_set_parsed(void *parsed_result,
3650 __attribute__((unused)) struct cmdline *cl,
3651 __attribute__((unused)) void *data)
3653 struct cmd_set_result *res = parsed_result;
3654 if (!strcmp(res->what, "nbport")) {
3655 set_fwd_ports_number(res->value);
3657 } else if (!strcmp(res->what, "nbcore")) {
3658 set_fwd_lcores_number(res->value);
3660 } else if (!strcmp(res->what, "burst"))
3661 set_nb_pkt_per_burst(res->value);
3662 else if (!strcmp(res->what, "verbose"))
3663 set_verbose_level(res->value);
3666 cmdline_parse_token_string_t cmd_set_set =
3667 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3668 cmdline_parse_token_string_t cmd_set_what =
3669 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3670 "nbport#nbcore#burst#verbose");
3671 cmdline_parse_token_num_t cmd_set_value =
3672 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3674 cmdline_parse_inst_t cmd_set_numbers = {
3675 .f = cmd_set_parsed,
3677 .help_str = "set nbport|nbcore|burst|verbose <value>",
3679 (void *)&cmd_set_set,
3680 (void *)&cmd_set_what,
3681 (void *)&cmd_set_value,
3686 /* *** SET LOG LEVEL CONFIGURATION *** */
3688 struct cmd_set_log_result {
3689 cmdline_fixed_string_t set;
3690 cmdline_fixed_string_t log;
3691 cmdline_fixed_string_t type;
3696 cmd_set_log_parsed(void *parsed_result,
3697 __attribute__((unused)) struct cmdline *cl,
3698 __attribute__((unused)) void *data)
3700 struct cmd_set_log_result *res;
3703 res = parsed_result;
3704 if (!strcmp(res->type, "global"))
3705 rte_log_set_global_level(res->level);
3707 ret = rte_log_set_level_regexp(res->type, res->level);
3709 printf("Unable to set log level\n");
3713 cmdline_parse_token_string_t cmd_set_log_set =
3714 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3715 cmdline_parse_token_string_t cmd_set_log_log =
3716 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3717 cmdline_parse_token_string_t cmd_set_log_type =
3718 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3719 cmdline_parse_token_num_t cmd_set_log_level =
3720 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3722 cmdline_parse_inst_t cmd_set_log = {
3723 .f = cmd_set_log_parsed,
3725 .help_str = "set log global|<type> <level>",
3727 (void *)&cmd_set_log_set,
3728 (void *)&cmd_set_log_log,
3729 (void *)&cmd_set_log_type,
3730 (void *)&cmd_set_log_level,
3735 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3737 struct cmd_set_txpkts_result {
3738 cmdline_fixed_string_t cmd_keyword;
3739 cmdline_fixed_string_t txpkts;
3740 cmdline_fixed_string_t seg_lengths;
3744 cmd_set_txpkts_parsed(void *parsed_result,
3745 __attribute__((unused)) struct cmdline *cl,
3746 __attribute__((unused)) void *data)
3748 struct cmd_set_txpkts_result *res;
3749 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3750 unsigned int nb_segs;
3752 res = parsed_result;
3753 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3754 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3756 set_tx_pkt_segments(seg_lengths, nb_segs);
3759 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3760 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3761 cmd_keyword, "set");
3762 cmdline_parse_token_string_t cmd_set_txpkts_name =
3763 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3765 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3766 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3769 cmdline_parse_inst_t cmd_set_txpkts = {
3770 .f = cmd_set_txpkts_parsed,
3772 .help_str = "set txpkts <len0[,len1]*>",
3774 (void *)&cmd_set_txpkts_keyword,
3775 (void *)&cmd_set_txpkts_name,
3776 (void *)&cmd_set_txpkts_lengths,
3781 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3783 struct cmd_set_txsplit_result {
3784 cmdline_fixed_string_t cmd_keyword;
3785 cmdline_fixed_string_t txsplit;
3786 cmdline_fixed_string_t mode;
3790 cmd_set_txsplit_parsed(void *parsed_result,
3791 __attribute__((unused)) struct cmdline *cl,
3792 __attribute__((unused)) void *data)
3794 struct cmd_set_txsplit_result *res;
3796 res = parsed_result;
3797 set_tx_pkt_split(res->mode);
3800 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3801 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3802 cmd_keyword, "set");
3803 cmdline_parse_token_string_t cmd_set_txsplit_name =
3804 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3805 txsplit, "txsplit");
3806 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3807 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3810 cmdline_parse_inst_t cmd_set_txsplit = {
3811 .f = cmd_set_txsplit_parsed,
3813 .help_str = "set txsplit on|off|rand",
3815 (void *)&cmd_set_txsplit_keyword,
3816 (void *)&cmd_set_txsplit_name,
3817 (void *)&cmd_set_txsplit_mode,
3822 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3823 struct cmd_rx_vlan_filter_all_result {
3824 cmdline_fixed_string_t rx_vlan;
3825 cmdline_fixed_string_t what;
3826 cmdline_fixed_string_t all;
3831 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3832 __attribute__((unused)) struct cmdline *cl,
3833 __attribute__((unused)) void *data)
3835 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3837 if (!strcmp(res->what, "add"))
3838 rx_vlan_all_filter_set(res->port_id, 1);
3840 rx_vlan_all_filter_set(res->port_id, 0);
3843 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3844 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3845 rx_vlan, "rx_vlan");
3846 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3847 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3849 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3850 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3852 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3853 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3856 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3857 .f = cmd_rx_vlan_filter_all_parsed,
3859 .help_str = "rx_vlan add|rm all <port_id>: "
3860 "Add/Remove all identifiers to/from the set of VLAN "
3861 "identifiers filtered by a port",
3863 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3864 (void *)&cmd_rx_vlan_filter_all_what,
3865 (void *)&cmd_rx_vlan_filter_all_all,
3866 (void *)&cmd_rx_vlan_filter_all_portid,
3871 /* *** VLAN OFFLOAD SET ON A PORT *** */
3872 struct cmd_vlan_offload_result {
3873 cmdline_fixed_string_t vlan;
3874 cmdline_fixed_string_t set;
3875 cmdline_fixed_string_t vlan_type;
3876 cmdline_fixed_string_t what;
3877 cmdline_fixed_string_t on;
3878 cmdline_fixed_string_t port_id;
3882 cmd_vlan_offload_parsed(void *parsed_result,
3883 __attribute__((unused)) struct cmdline *cl,
3884 __attribute__((unused)) void *data)
3887 struct cmd_vlan_offload_result *res = parsed_result;
3890 portid_t port_id = 0;
3894 len = strnlen(str, STR_TOKEN_SIZE);
3896 /* Get port_id first */
3904 tmp = strtoul(str, NULL, 0);
3905 /* If port_id greater that what portid_t can represent, return */
3906 if(tmp >= RTE_MAX_ETHPORTS)
3908 port_id = (portid_t)tmp;
3910 if (!strcmp(res->on, "on"))
3915 if (!strcmp(res->what, "strip"))
3916 rx_vlan_strip_set(port_id, on);
3917 else if(!strcmp(res->what, "stripq")){
3918 uint16_t queue_id = 0;
3920 /* No queue_id, return */
3922 printf("must specify (port,queue_id)\n");
3925 tmp = strtoul(str + i + 1, NULL, 0);
3926 /* If queue_id greater that what 16-bits can represent, return */
3930 queue_id = (uint16_t)tmp;
3931 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3933 else if (!strcmp(res->what, "filter"))
3934 rx_vlan_filter_set(port_id, on);
3936 vlan_extend_set(port_id, on);
3941 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3942 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3944 cmdline_parse_token_string_t cmd_vlan_offload_set =
3945 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3947 cmdline_parse_token_string_t cmd_vlan_offload_what =
3948 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3949 what, "strip#filter#qinq#stripq");
3950 cmdline_parse_token_string_t cmd_vlan_offload_on =
3951 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3953 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3954 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3957 cmdline_parse_inst_t cmd_vlan_offload = {
3958 .f = cmd_vlan_offload_parsed,
3960 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3961 "<port_id[,queue_id]>: "
3962 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3964 (void *)&cmd_vlan_offload_vlan,
3965 (void *)&cmd_vlan_offload_set,
3966 (void *)&cmd_vlan_offload_what,
3967 (void *)&cmd_vlan_offload_on,
3968 (void *)&cmd_vlan_offload_portid,
3973 /* *** VLAN TPID SET ON A PORT *** */
3974 struct cmd_vlan_tpid_result {
3975 cmdline_fixed_string_t vlan;
3976 cmdline_fixed_string_t set;
3977 cmdline_fixed_string_t vlan_type;
3978 cmdline_fixed_string_t what;
3984 cmd_vlan_tpid_parsed(void *parsed_result,
3985 __attribute__((unused)) struct cmdline *cl,
3986 __attribute__((unused)) void *data)
3988 struct cmd_vlan_tpid_result *res = parsed_result;
3989 enum rte_vlan_type vlan_type;
3991 if (!strcmp(res->vlan_type, "inner"))
3992 vlan_type = ETH_VLAN_TYPE_INNER;
3993 else if (!strcmp(res->vlan_type, "outer"))
3994 vlan_type = ETH_VLAN_TYPE_OUTER;
3996 printf("Unknown vlan type\n");
3999 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4002 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4003 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4005 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4006 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4008 cmdline_parse_token_string_t cmd_vlan_type =
4009 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4010 vlan_type, "inner#outer");
4011 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4012 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4014 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4015 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4017 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4018 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4021 cmdline_parse_inst_t cmd_vlan_tpid = {
4022 .f = cmd_vlan_tpid_parsed,
4024 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4025 "Set the VLAN Ether type",
4027 (void *)&cmd_vlan_tpid_vlan,
4028 (void *)&cmd_vlan_tpid_set,
4029 (void *)&cmd_vlan_type,
4030 (void *)&cmd_vlan_tpid_what,
4031 (void *)&cmd_vlan_tpid_tpid,
4032 (void *)&cmd_vlan_tpid_portid,
4037 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4038 struct cmd_rx_vlan_filter_result {
4039 cmdline_fixed_string_t rx_vlan;
4040 cmdline_fixed_string_t what;
4046 cmd_rx_vlan_filter_parsed(void *parsed_result,
4047 __attribute__((unused)) struct cmdline *cl,
4048 __attribute__((unused)) void *data)
4050 struct cmd_rx_vlan_filter_result *res = parsed_result;
4052 if (!strcmp(res->what, "add"))
4053 rx_vft_set(res->port_id, res->vlan_id, 1);
4055 rx_vft_set(res->port_id, res->vlan_id, 0);
4058 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4059 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4060 rx_vlan, "rx_vlan");
4061 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4062 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4064 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4065 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4067 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4068 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4071 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4072 .f = cmd_rx_vlan_filter_parsed,
4074 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4075 "Add/Remove a VLAN identifier to/from the set of VLAN "
4076 "identifiers filtered by a port",
4078 (void *)&cmd_rx_vlan_filter_rx_vlan,
4079 (void *)&cmd_rx_vlan_filter_what,
4080 (void *)&cmd_rx_vlan_filter_vlanid,
4081 (void *)&cmd_rx_vlan_filter_portid,
4086 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4087 struct cmd_tx_vlan_set_result {
4088 cmdline_fixed_string_t tx_vlan;
4089 cmdline_fixed_string_t set;
4095 cmd_tx_vlan_set_parsed(void *parsed_result,
4096 __attribute__((unused)) struct cmdline *cl,
4097 __attribute__((unused)) void *data)
4099 struct cmd_tx_vlan_set_result *res = parsed_result;
4101 if (!port_is_stopped(res->port_id)) {
4102 printf("Please stop port %d first\n", res->port_id);
4106 tx_vlan_set(res->port_id, res->vlan_id);
4108 cmd_reconfig_device_queue(res->port_id, 1, 1);
4111 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4112 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4113 tx_vlan, "tx_vlan");
4114 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4115 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4117 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4118 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4120 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4121 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4124 cmdline_parse_inst_t cmd_tx_vlan_set = {
4125 .f = cmd_tx_vlan_set_parsed,
4127 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4128 "Enable hardware insertion of a single VLAN header "
4129 "with a given TAG Identifier in packets sent on a port",
4131 (void *)&cmd_tx_vlan_set_tx_vlan,
4132 (void *)&cmd_tx_vlan_set_set,
4133 (void *)&cmd_tx_vlan_set_portid,
4134 (void *)&cmd_tx_vlan_set_vlanid,
4139 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4140 struct cmd_tx_vlan_set_qinq_result {
4141 cmdline_fixed_string_t tx_vlan;
4142 cmdline_fixed_string_t set;
4145 uint16_t vlan_id_outer;
4149 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4150 __attribute__((unused)) struct cmdline *cl,
4151 __attribute__((unused)) void *data)
4153 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4155 if (!port_is_stopped(res->port_id)) {
4156 printf("Please stop port %d first\n", res->port_id);
4160 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4162 cmd_reconfig_device_queue(res->port_id, 1, 1);
4165 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4166 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4167 tx_vlan, "tx_vlan");
4168 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4169 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4171 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4172 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4174 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4175 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4177 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4178 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4179 vlan_id_outer, UINT16);
4181 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4182 .f = cmd_tx_vlan_set_qinq_parsed,
4184 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4185 "Enable hardware insertion of double VLAN header "
4186 "with given TAG Identifiers in packets sent on a port",
4188 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4189 (void *)&cmd_tx_vlan_set_qinq_set,
4190 (void *)&cmd_tx_vlan_set_qinq_portid,
4191 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4192 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4197 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4198 struct cmd_tx_vlan_set_pvid_result {
4199 cmdline_fixed_string_t tx_vlan;
4200 cmdline_fixed_string_t set;
4201 cmdline_fixed_string_t pvid;
4204 cmdline_fixed_string_t mode;
4208 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4209 __attribute__((unused)) struct cmdline *cl,
4210 __attribute__((unused)) void *data)
4212 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4214 if (strcmp(res->mode, "on") == 0)
4215 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4217 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4220 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4221 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4222 tx_vlan, "tx_vlan");
4223 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4224 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4226 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4227 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4229 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4230 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4232 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4233 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4235 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4236 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4239 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4240 .f = cmd_tx_vlan_set_pvid_parsed,
4242 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4244 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4245 (void *)&cmd_tx_vlan_set_pvid_set,
4246 (void *)&cmd_tx_vlan_set_pvid_pvid,
4247 (void *)&cmd_tx_vlan_set_pvid_port_id,
4248 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4249 (void *)&cmd_tx_vlan_set_pvid_mode,
4254 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4255 struct cmd_tx_vlan_reset_result {
4256 cmdline_fixed_string_t tx_vlan;
4257 cmdline_fixed_string_t reset;
4262 cmd_tx_vlan_reset_parsed(void *parsed_result,
4263 __attribute__((unused)) struct cmdline *cl,
4264 __attribute__((unused)) void *data)
4266 struct cmd_tx_vlan_reset_result *res = parsed_result;
4268 if (!port_is_stopped(res->port_id)) {
4269 printf("Please stop port %d first\n", res->port_id);
4273 tx_vlan_reset(res->port_id);
4275 cmd_reconfig_device_queue(res->port_id, 1, 1);
4278 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4279 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4280 tx_vlan, "tx_vlan");
4281 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4282 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4284 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4285 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4288 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4289 .f = cmd_tx_vlan_reset_parsed,
4291 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4292 "VLAN header in packets sent on a port",
4294 (void *)&cmd_tx_vlan_reset_tx_vlan,
4295 (void *)&cmd_tx_vlan_reset_reset,
4296 (void *)&cmd_tx_vlan_reset_portid,
4302 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4303 struct cmd_csum_result {
4304 cmdline_fixed_string_t csum;
4305 cmdline_fixed_string_t mode;
4306 cmdline_fixed_string_t proto;
4307 cmdline_fixed_string_t hwsw;
4312 csum_show(int port_id)
4314 struct rte_eth_dev_info dev_info;
4315 uint64_t tx_offloads;
4317 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4318 printf("Parse tunnel is %s\n",
4319 (ports[port_id].parse_tunnel) ? "on" : "off");
4320 printf("IP checksum offload is %s\n",
4321 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4322 printf("UDP checksum offload is %s\n",
4323 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4324 printf("TCP checksum offload is %s\n",
4325 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4326 printf("SCTP checksum offload is %s\n",
4327 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4328 printf("Outer-Ip checksum offload is %s\n",
4329 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4330 printf("Outer-Udp checksum offload is %s\n",
4331 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4333 /* display warnings if configuration is not supported by the NIC */
4334 rte_eth_dev_info_get(port_id, &dev_info);
4335 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4336 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4337 printf("Warning: hardware IP checksum enabled but not "
4338 "supported by port %d\n", port_id);
4340 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4341 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4342 printf("Warning: hardware UDP checksum enabled but not "
4343 "supported by port %d\n", port_id);
4345 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4346 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4347 printf("Warning: hardware TCP checksum enabled but not "
4348 "supported by port %d\n", port_id);
4350 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4351 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4352 printf("Warning: hardware SCTP checksum enabled but not "
4353 "supported by port %d\n", port_id);
4355 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4356 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4357 printf("Warning: hardware outer IP checksum enabled but not "
4358 "supported by port %d\n", port_id);
4360 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4361 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4363 printf("Warning: hardware outer UDP checksum enabled but not "
4364 "supported by port %d\n", port_id);
4369 cmd_config_queue_tx_offloads(struct rte_port *port)
4373 /* Apply queue tx offloads configuration */
4374 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4375 port->tx_conf[k].offloads =
4376 port->dev_conf.txmode.offloads;
4380 cmd_csum_parsed(void *parsed_result,
4381 __attribute__((unused)) struct cmdline *cl,
4382 __attribute__((unused)) void *data)
4384 struct cmd_csum_result *res = parsed_result;
4386 uint64_t csum_offloads = 0;
4387 struct rte_eth_dev_info dev_info;
4389 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4390 printf("invalid port %d\n", res->port_id);
4393 if (!port_is_stopped(res->port_id)) {
4394 printf("Please stop port %d first\n", res->port_id);
4398 rte_eth_dev_info_get(res->port_id, &dev_info);
4399 if (!strcmp(res->mode, "set")) {
4401 if (!strcmp(res->hwsw, "hw"))
4404 if (!strcmp(res->proto, "ip")) {
4405 if (hw == 0 || (dev_info.tx_offload_capa &
4406 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4407 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4409 printf("IP checksum offload is not supported "
4410 "by port %u\n", res->port_id);
4412 } else if (!strcmp(res->proto, "udp")) {
4413 if (hw == 0 || (dev_info.tx_offload_capa &
4414 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4415 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4417 printf("UDP checksum offload is not supported "
4418 "by port %u\n", res->port_id);
4420 } else if (!strcmp(res->proto, "tcp")) {
4421 if (hw == 0 || (dev_info.tx_offload_capa &
4422 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4423 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4425 printf("TCP checksum offload is not supported "
4426 "by port %u\n", res->port_id);
4428 } else if (!strcmp(res->proto, "sctp")) {
4429 if (hw == 0 || (dev_info.tx_offload_capa &
4430 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4431 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4433 printf("SCTP checksum offload is not supported "
4434 "by port %u\n", res->port_id);
4436 } else if (!strcmp(res->proto, "outer-ip")) {
4437 if (hw == 0 || (dev_info.tx_offload_capa &
4438 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4440 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4442 printf("Outer IP checksum offload is not "
4443 "supported by port %u\n", res->port_id);
4445 } else if (!strcmp(res->proto, "outer-udp")) {
4446 if (hw == 0 || (dev_info.tx_offload_capa &
4447 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4449 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4451 printf("Outer UDP checksum offload is not "
4452 "supported by port %u\n", res->port_id);
4457 ports[res->port_id].dev_conf.txmode.offloads |=
4460 ports[res->port_id].dev_conf.txmode.offloads &=
4463 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4465 csum_show(res->port_id);
4467 cmd_reconfig_device_queue(res->port_id, 1, 1);
4470 cmdline_parse_token_string_t cmd_csum_csum =
4471 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4473 cmdline_parse_token_string_t cmd_csum_mode =
4474 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4476 cmdline_parse_token_string_t cmd_csum_proto =
4477 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4478 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4479 cmdline_parse_token_string_t cmd_csum_hwsw =
4480 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4482 cmdline_parse_token_num_t cmd_csum_portid =
4483 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4486 cmdline_parse_inst_t cmd_csum_set = {
4487 .f = cmd_csum_parsed,
4489 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4490 "Enable/Disable hardware calculation of L3/L4 checksum when "
4491 "using csum forward engine",
4493 (void *)&cmd_csum_csum,
4494 (void *)&cmd_csum_mode,
4495 (void *)&cmd_csum_proto,
4496 (void *)&cmd_csum_hwsw,
4497 (void *)&cmd_csum_portid,
4502 cmdline_parse_token_string_t cmd_csum_mode_show =
4503 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4506 cmdline_parse_inst_t cmd_csum_show = {
4507 .f = cmd_csum_parsed,
4509 .help_str = "csum show <port_id>: Show checksum offload configuration",
4511 (void *)&cmd_csum_csum,
4512 (void *)&cmd_csum_mode_show,
4513 (void *)&cmd_csum_portid,
4518 /* Enable/disable tunnel parsing */
4519 struct cmd_csum_tunnel_result {
4520 cmdline_fixed_string_t csum;
4521 cmdline_fixed_string_t parse;
4522 cmdline_fixed_string_t onoff;
4527 cmd_csum_tunnel_parsed(void *parsed_result,
4528 __attribute__((unused)) struct cmdline *cl,
4529 __attribute__((unused)) void *data)
4531 struct cmd_csum_tunnel_result *res = parsed_result;
4533 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4536 if (!strcmp(res->onoff, "on"))
4537 ports[res->port_id].parse_tunnel = 1;
4539 ports[res->port_id].parse_tunnel = 0;
4541 csum_show(res->port_id);
4544 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4545 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4547 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4548 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4549 parse, "parse-tunnel");
4550 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4551 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4553 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4554 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4557 cmdline_parse_inst_t cmd_csum_tunnel = {
4558 .f = cmd_csum_tunnel_parsed,
4560 .help_str = "csum parse-tunnel on|off <port_id>: "
4561 "Enable/Disable parsing of tunnels for csum engine",
4563 (void *)&cmd_csum_tunnel_csum,
4564 (void *)&cmd_csum_tunnel_parse,
4565 (void *)&cmd_csum_tunnel_onoff,
4566 (void *)&cmd_csum_tunnel_portid,
4571 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4572 struct cmd_tso_set_result {
4573 cmdline_fixed_string_t tso;
4574 cmdline_fixed_string_t mode;
4580 cmd_tso_set_parsed(void *parsed_result,
4581 __attribute__((unused)) struct cmdline *cl,
4582 __attribute__((unused)) void *data)
4584 struct cmd_tso_set_result *res = parsed_result;
4585 struct rte_eth_dev_info dev_info;
4587 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4589 if (!port_is_stopped(res->port_id)) {
4590 printf("Please stop port %d first\n", res->port_id);
4594 if (!strcmp(res->mode, "set"))
4595 ports[res->port_id].tso_segsz = res->tso_segsz;
4597 rte_eth_dev_info_get(res->port_id, &dev_info);
4598 if ((ports[res->port_id].tso_segsz != 0) &&
4599 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4600 printf("Error: TSO is not supported by port %d\n",
4605 if (ports[res->port_id].tso_segsz == 0) {
4606 ports[res->port_id].dev_conf.txmode.offloads &=
4607 ~DEV_TX_OFFLOAD_TCP_TSO;
4608 printf("TSO for non-tunneled packets is disabled\n");
4610 ports[res->port_id].dev_conf.txmode.offloads |=
4611 DEV_TX_OFFLOAD_TCP_TSO;
4612 printf("TSO segment size for non-tunneled packets is %d\n",
4613 ports[res->port_id].tso_segsz);
4615 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4617 /* display warnings if configuration is not supported by the NIC */
4618 rte_eth_dev_info_get(res->port_id, &dev_info);
4619 if ((ports[res->port_id].tso_segsz != 0) &&
4620 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4621 printf("Warning: TSO enabled but not "
4622 "supported by port %d\n", res->port_id);
4625 cmd_reconfig_device_queue(res->port_id, 1, 1);
4628 cmdline_parse_token_string_t cmd_tso_set_tso =
4629 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4631 cmdline_parse_token_string_t cmd_tso_set_mode =
4632 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4634 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4635 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4637 cmdline_parse_token_num_t cmd_tso_set_portid =
4638 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4641 cmdline_parse_inst_t cmd_tso_set = {
4642 .f = cmd_tso_set_parsed,
4644 .help_str = "tso set <tso_segsz> <port_id>: "
4645 "Set TSO segment size of non-tunneled packets for csum engine "
4648 (void *)&cmd_tso_set_tso,
4649 (void *)&cmd_tso_set_mode,
4650 (void *)&cmd_tso_set_tso_segsz,
4651 (void *)&cmd_tso_set_portid,
4656 cmdline_parse_token_string_t cmd_tso_show_mode =
4657 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4661 cmdline_parse_inst_t cmd_tso_show = {
4662 .f = cmd_tso_set_parsed,
4664 .help_str = "tso show <port_id>: "
4665 "Show TSO segment size of non-tunneled packets for csum engine",
4667 (void *)&cmd_tso_set_tso,
4668 (void *)&cmd_tso_show_mode,
4669 (void *)&cmd_tso_set_portid,
4674 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4675 struct cmd_tunnel_tso_set_result {
4676 cmdline_fixed_string_t tso;
4677 cmdline_fixed_string_t mode;
4682 static struct rte_eth_dev_info
4683 check_tunnel_tso_nic_support(portid_t port_id)
4685 struct rte_eth_dev_info dev_info;
4687 rte_eth_dev_info_get(port_id, &dev_info);
4688 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4689 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4690 "not enabled for port %d\n", port_id);
4691 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4692 printf("Warning: GRE TUNNEL TSO not supported therefore "
4693 "not enabled for port %d\n", port_id);
4694 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4695 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4696 "not enabled for port %d\n", port_id);
4697 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4698 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4699 "not enabled for port %d\n", port_id);
4700 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4701 printf("Warning: IP TUNNEL TSO not supported therefore "
4702 "not enabled for port %d\n", port_id);
4703 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4704 printf("Warning: UDP TUNNEL TSO not supported therefore "
4705 "not enabled for port %d\n", port_id);
4710 cmd_tunnel_tso_set_parsed(void *parsed_result,
4711 __attribute__((unused)) struct cmdline *cl,
4712 __attribute__((unused)) void *data)
4714 struct cmd_tunnel_tso_set_result *res = parsed_result;
4715 struct rte_eth_dev_info dev_info;
4717 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4719 if (!port_is_stopped(res->port_id)) {
4720 printf("Please stop port %d first\n", res->port_id);
4724 if (!strcmp(res->mode, "set"))
4725 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4727 dev_info = check_tunnel_tso_nic_support(res->port_id);
4728 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4729 ports[res->port_id].dev_conf.txmode.offloads &=
4730 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4731 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4732 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4733 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4734 DEV_TX_OFFLOAD_IP_TNL_TSO |
4735 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4736 printf("TSO for tunneled packets is disabled\n");
4738 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4739 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4740 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4741 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4742 DEV_TX_OFFLOAD_IP_TNL_TSO |
4743 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4745 ports[res->port_id].dev_conf.txmode.offloads |=
4746 (tso_offloads & dev_info.tx_offload_capa);
4747 printf("TSO segment size for tunneled packets is %d\n",
4748 ports[res->port_id].tunnel_tso_segsz);
4750 /* Below conditions are needed to make it work:
4751 * (1) tunnel TSO is supported by the NIC;
4752 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4754 * (3) for tunneled pkts with outer L3 of IPv4,
4755 * "csum set outer-ip" must be set to hw, because after tso,
4756 * total_len of outer IP header is changed, and the checksum
4757 * of outer IP header calculated by sw should be wrong; that
4758 * is not necessary for IPv6 tunneled pkts because there's no
4759 * checksum in IP header anymore.
4762 if (!ports[res->port_id].parse_tunnel)
4763 printf("Warning: csum parse_tunnel must be set "
4764 "so that tunneled packets are recognized\n");
4765 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4766 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4767 printf("Warning: csum set outer-ip must be set to hw "
4768 "if outer L3 is IPv4; not necessary for IPv6\n");
4771 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4772 cmd_reconfig_device_queue(res->port_id, 1, 1);
4775 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4776 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4778 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4779 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4781 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4782 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4784 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4785 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4788 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4789 .f = cmd_tunnel_tso_set_parsed,
4791 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4792 "Set TSO segment size of tunneled packets for csum engine "
4795 (void *)&cmd_tunnel_tso_set_tso,
4796 (void *)&cmd_tunnel_tso_set_mode,
4797 (void *)&cmd_tunnel_tso_set_tso_segsz,
4798 (void *)&cmd_tunnel_tso_set_portid,
4803 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4804 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4808 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4809 .f = cmd_tunnel_tso_set_parsed,
4811 .help_str = "tunnel_tso show <port_id> "
4812 "Show TSO segment size of tunneled packets for csum engine",
4814 (void *)&cmd_tunnel_tso_set_tso,
4815 (void *)&cmd_tunnel_tso_show_mode,
4816 (void *)&cmd_tunnel_tso_set_portid,
4821 /* *** SET GRO FOR A PORT *** */
4822 struct cmd_gro_enable_result {
4823 cmdline_fixed_string_t cmd_set;
4824 cmdline_fixed_string_t cmd_port;
4825 cmdline_fixed_string_t cmd_keyword;
4826 cmdline_fixed_string_t cmd_onoff;
4831 cmd_gro_enable_parsed(void *parsed_result,
4832 __attribute__((unused)) struct cmdline *cl,
4833 __attribute__((unused)) void *data)
4835 struct cmd_gro_enable_result *res;
4837 res = parsed_result;
4838 if (!strcmp(res->cmd_keyword, "gro"))
4839 setup_gro(res->cmd_onoff, res->cmd_pid);
4842 cmdline_parse_token_string_t cmd_gro_enable_set =
4843 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4845 cmdline_parse_token_string_t cmd_gro_enable_port =
4846 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4847 cmd_keyword, "port");
4848 cmdline_parse_token_num_t cmd_gro_enable_pid =
4849 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4851 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4852 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4853 cmd_keyword, "gro");
4854 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4855 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4856 cmd_onoff, "on#off");
4858 cmdline_parse_inst_t cmd_gro_enable = {
4859 .f = cmd_gro_enable_parsed,
4861 .help_str = "set port <port_id> gro on|off",
4863 (void *)&cmd_gro_enable_set,
4864 (void *)&cmd_gro_enable_port,
4865 (void *)&cmd_gro_enable_pid,
4866 (void *)&cmd_gro_enable_keyword,
4867 (void *)&cmd_gro_enable_onoff,
4872 /* *** DISPLAY GRO CONFIGURATION *** */
4873 struct cmd_gro_show_result {
4874 cmdline_fixed_string_t cmd_show;
4875 cmdline_fixed_string_t cmd_port;
4876 cmdline_fixed_string_t cmd_keyword;
4881 cmd_gro_show_parsed(void *parsed_result,
4882 __attribute__((unused)) struct cmdline *cl,
4883 __attribute__((unused)) void *data)
4885 struct cmd_gro_show_result *res;
4887 res = parsed_result;
4888 if (!strcmp(res->cmd_keyword, "gro"))
4889 show_gro(res->cmd_pid);
4892 cmdline_parse_token_string_t cmd_gro_show_show =
4893 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4895 cmdline_parse_token_string_t cmd_gro_show_port =
4896 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4898 cmdline_parse_token_num_t cmd_gro_show_pid =
4899 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4901 cmdline_parse_token_string_t cmd_gro_show_keyword =
4902 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4903 cmd_keyword, "gro");
4905 cmdline_parse_inst_t cmd_gro_show = {
4906 .f = cmd_gro_show_parsed,
4908 .help_str = "show port <port_id> gro",
4910 (void *)&cmd_gro_show_show,
4911 (void *)&cmd_gro_show_port,
4912 (void *)&cmd_gro_show_pid,
4913 (void *)&cmd_gro_show_keyword,
4918 /* *** SET FLUSH CYCLES FOR GRO *** */
4919 struct cmd_gro_flush_result {
4920 cmdline_fixed_string_t cmd_set;
4921 cmdline_fixed_string_t cmd_keyword;
4922 cmdline_fixed_string_t cmd_flush;
4927 cmd_gro_flush_parsed(void *parsed_result,
4928 __attribute__((unused)) struct cmdline *cl,
4929 __attribute__((unused)) void *data)
4931 struct cmd_gro_flush_result *res;
4933 res = parsed_result;
4934 if ((!strcmp(res->cmd_keyword, "gro")) &&
4935 (!strcmp(res->cmd_flush, "flush")))
4936 setup_gro_flush_cycles(res->cmd_cycles);
4939 cmdline_parse_token_string_t cmd_gro_flush_set =
4940 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4942 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4943 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4944 cmd_keyword, "gro");
4945 cmdline_parse_token_string_t cmd_gro_flush_flush =
4946 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4947 cmd_flush, "flush");
4948 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4949 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4952 cmdline_parse_inst_t cmd_gro_flush = {
4953 .f = cmd_gro_flush_parsed,
4955 .help_str = "set gro flush <cycles>",
4957 (void *)&cmd_gro_flush_set,
4958 (void *)&cmd_gro_flush_keyword,
4959 (void *)&cmd_gro_flush_flush,
4960 (void *)&cmd_gro_flush_cycles,
4965 /* *** ENABLE/DISABLE GSO *** */
4966 struct cmd_gso_enable_result {
4967 cmdline_fixed_string_t cmd_set;
4968 cmdline_fixed_string_t cmd_port;
4969 cmdline_fixed_string_t cmd_keyword;
4970 cmdline_fixed_string_t cmd_mode;
4975 cmd_gso_enable_parsed(void *parsed_result,
4976 __attribute__((unused)) struct cmdline *cl,
4977 __attribute__((unused)) void *data)
4979 struct cmd_gso_enable_result *res;
4981 res = parsed_result;
4982 if (!strcmp(res->cmd_keyword, "gso"))
4983 setup_gso(res->cmd_mode, res->cmd_pid);
4986 cmdline_parse_token_string_t cmd_gso_enable_set =
4987 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4989 cmdline_parse_token_string_t cmd_gso_enable_port =
4990 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4992 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4993 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4994 cmd_keyword, "gso");
4995 cmdline_parse_token_string_t cmd_gso_enable_mode =
4996 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4997 cmd_mode, "on#off");
4998 cmdline_parse_token_num_t cmd_gso_enable_pid =
4999 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5002 cmdline_parse_inst_t cmd_gso_enable = {
5003 .f = cmd_gso_enable_parsed,
5005 .help_str = "set port <port_id> gso on|off",
5007 (void *)&cmd_gso_enable_set,
5008 (void *)&cmd_gso_enable_port,
5009 (void *)&cmd_gso_enable_pid,
5010 (void *)&cmd_gso_enable_keyword,
5011 (void *)&cmd_gso_enable_mode,
5016 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5017 struct cmd_gso_size_result {
5018 cmdline_fixed_string_t cmd_set;
5019 cmdline_fixed_string_t cmd_keyword;
5020 cmdline_fixed_string_t cmd_segsz;
5025 cmd_gso_size_parsed(void *parsed_result,
5026 __attribute__((unused)) struct cmdline *cl,
5027 __attribute__((unused)) void *data)
5029 struct cmd_gso_size_result *res = parsed_result;
5031 if (test_done == 0) {
5032 printf("Before setting GSO segsz, please first"
5033 " stop fowarding\n");
5037 if (!strcmp(res->cmd_keyword, "gso") &&
5038 !strcmp(res->cmd_segsz, "segsz")) {
5039 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5040 printf("gso_size should be larger than %zu."
5041 " Please input a legal value\n",
5042 RTE_GSO_SEG_SIZE_MIN);
5044 gso_max_segment_size = res->cmd_size;
5048 cmdline_parse_token_string_t cmd_gso_size_set =
5049 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5051 cmdline_parse_token_string_t cmd_gso_size_keyword =
5052 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5053 cmd_keyword, "gso");
5054 cmdline_parse_token_string_t cmd_gso_size_segsz =
5055 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5056 cmd_segsz, "segsz");
5057 cmdline_parse_token_num_t cmd_gso_size_size =
5058 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5061 cmdline_parse_inst_t cmd_gso_size = {
5062 .f = cmd_gso_size_parsed,
5064 .help_str = "set gso segsz <length>",
5066 (void *)&cmd_gso_size_set,
5067 (void *)&cmd_gso_size_keyword,
5068 (void *)&cmd_gso_size_segsz,
5069 (void *)&cmd_gso_size_size,
5074 /* *** SHOW GSO CONFIGURATION *** */
5075 struct cmd_gso_show_result {
5076 cmdline_fixed_string_t cmd_show;
5077 cmdline_fixed_string_t cmd_port;
5078 cmdline_fixed_string_t cmd_keyword;
5083 cmd_gso_show_parsed(void *parsed_result,
5084 __attribute__((unused)) struct cmdline *cl,
5085 __attribute__((unused)) void *data)
5087 struct cmd_gso_show_result *res = parsed_result;
5089 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5090 printf("invalid port id %u\n", res->cmd_pid);
5093 if (!strcmp(res->cmd_keyword, "gso")) {
5094 if (gso_ports[res->cmd_pid].enable) {
5095 printf("Max GSO'd packet size: %uB\n"
5096 "Supported GSO types: TCP/IPv4, "
5097 "UDP/IPv4, VxLAN with inner "
5098 "TCP/IPv4 packet, GRE with inner "
5099 "TCP/IPv4 packet\n",
5100 gso_max_segment_size);
5102 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5106 cmdline_parse_token_string_t cmd_gso_show_show =
5107 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5109 cmdline_parse_token_string_t cmd_gso_show_port =
5110 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5112 cmdline_parse_token_string_t cmd_gso_show_keyword =
5113 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5114 cmd_keyword, "gso");
5115 cmdline_parse_token_num_t cmd_gso_show_pid =
5116 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5119 cmdline_parse_inst_t cmd_gso_show = {
5120 .f = cmd_gso_show_parsed,
5122 .help_str = "show port <port_id> gso",
5124 (void *)&cmd_gso_show_show,
5125 (void *)&cmd_gso_show_port,
5126 (void *)&cmd_gso_show_pid,
5127 (void *)&cmd_gso_show_keyword,
5132 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5133 struct cmd_set_flush_rx {
5134 cmdline_fixed_string_t set;
5135 cmdline_fixed_string_t flush_rx;
5136 cmdline_fixed_string_t mode;
5140 cmd_set_flush_rx_parsed(void *parsed_result,
5141 __attribute__((unused)) struct cmdline *cl,
5142 __attribute__((unused)) void *data)
5144 struct cmd_set_flush_rx *res = parsed_result;
5145 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5148 cmdline_parse_token_string_t cmd_setflushrx_set =
5149 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5151 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5152 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5153 flush_rx, "flush_rx");
5154 cmdline_parse_token_string_t cmd_setflushrx_mode =
5155 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5159 cmdline_parse_inst_t cmd_set_flush_rx = {
5160 .f = cmd_set_flush_rx_parsed,
5161 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5164 (void *)&cmd_setflushrx_set,
5165 (void *)&cmd_setflushrx_flush_rx,
5166 (void *)&cmd_setflushrx_mode,
5171 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5172 struct cmd_set_link_check {
5173 cmdline_fixed_string_t set;
5174 cmdline_fixed_string_t link_check;
5175 cmdline_fixed_string_t mode;
5179 cmd_set_link_check_parsed(void *parsed_result,
5180 __attribute__((unused)) struct cmdline *cl,
5181 __attribute__((unused)) void *data)
5183 struct cmd_set_link_check *res = parsed_result;
5184 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5187 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5188 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5190 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5191 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5192 link_check, "link_check");
5193 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5194 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5198 cmdline_parse_inst_t cmd_set_link_check = {
5199 .f = cmd_set_link_check_parsed,
5200 .help_str = "set link_check on|off: Enable/Disable link status check "
5201 "when starting/stopping a port",
5204 (void *)&cmd_setlinkcheck_set,
5205 (void *)&cmd_setlinkcheck_link_check,
5206 (void *)&cmd_setlinkcheck_mode,
5211 /* *** SET NIC BYPASS MODE *** */
5212 struct cmd_set_bypass_mode_result {
5213 cmdline_fixed_string_t set;
5214 cmdline_fixed_string_t bypass;
5215 cmdline_fixed_string_t mode;
5216 cmdline_fixed_string_t value;
5221 cmd_set_bypass_mode_parsed(void *parsed_result,
5222 __attribute__((unused)) struct cmdline *cl,
5223 __attribute__((unused)) void *data)
5225 struct cmd_set_bypass_mode_result *res = parsed_result;
5226 portid_t port_id = res->port_id;
5227 int32_t rc = -EINVAL;
5229 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5230 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5232 if (!strcmp(res->value, "bypass"))
5233 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5234 else if (!strcmp(res->value, "isolate"))
5235 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5237 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5239 /* Set the bypass mode for the relevant port. */
5240 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5243 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5246 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5247 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5249 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5250 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5252 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5253 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5255 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5256 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5257 value, "normal#bypass#isolate");
5258 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5259 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5262 cmdline_parse_inst_t cmd_set_bypass_mode = {
5263 .f = cmd_set_bypass_mode_parsed,
5264 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5265 "Set the NIC bypass mode for port_id",
5268 (void *)&cmd_setbypass_mode_set,
5269 (void *)&cmd_setbypass_mode_bypass,
5270 (void *)&cmd_setbypass_mode_mode,
5271 (void *)&cmd_setbypass_mode_value,
5272 (void *)&cmd_setbypass_mode_port,
5277 /* *** SET NIC BYPASS EVENT *** */
5278 struct cmd_set_bypass_event_result {
5279 cmdline_fixed_string_t set;
5280 cmdline_fixed_string_t bypass;
5281 cmdline_fixed_string_t event;
5282 cmdline_fixed_string_t event_value;
5283 cmdline_fixed_string_t mode;
5284 cmdline_fixed_string_t mode_value;
5289 cmd_set_bypass_event_parsed(void *parsed_result,
5290 __attribute__((unused)) struct cmdline *cl,
5291 __attribute__((unused)) void *data)
5293 int32_t rc = -EINVAL;
5294 struct cmd_set_bypass_event_result *res = parsed_result;
5295 portid_t port_id = res->port_id;
5297 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5298 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5299 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5301 if (!strcmp(res->event_value, "timeout"))
5302 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5303 else if (!strcmp(res->event_value, "os_on"))
5304 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5305 else if (!strcmp(res->event_value, "os_off"))
5306 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5307 else if (!strcmp(res->event_value, "power_on"))
5308 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5309 else if (!strcmp(res->event_value, "power_off"))
5310 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5312 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5314 if (!strcmp(res->mode_value, "bypass"))
5315 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5316 else if (!strcmp(res->mode_value, "isolate"))
5317 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5319 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5321 /* Set the watchdog timeout. */
5322 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5325 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5326 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5330 printf("Failed to set timeout value %u "
5331 "for port %d, errto code: %d.\n",
5332 bypass_timeout, port_id, rc);
5336 /* Set the bypass event to transition to bypass mode. */
5337 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5342 printf("\t Failed to set bypass event for port = %d.\n",
5346 cmdline_parse_token_string_t cmd_setbypass_event_set =
5347 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5349 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5350 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5352 cmdline_parse_token_string_t cmd_setbypass_event_event =
5353 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5355 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5356 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5357 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5358 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5359 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5361 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5362 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5363 mode_value, "normal#bypass#isolate");
5364 cmdline_parse_token_num_t cmd_setbypass_event_port =
5365 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5368 cmdline_parse_inst_t cmd_set_bypass_event = {
5369 .f = cmd_set_bypass_event_parsed,
5370 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5371 "power_off mode normal|bypass|isolate <port_id>: "
5372 "Set the NIC bypass event mode for port_id",
5375 (void *)&cmd_setbypass_event_set,
5376 (void *)&cmd_setbypass_event_bypass,
5377 (void *)&cmd_setbypass_event_event,
5378 (void *)&cmd_setbypass_event_event_value,
5379 (void *)&cmd_setbypass_event_mode,
5380 (void *)&cmd_setbypass_event_mode_value,
5381 (void *)&cmd_setbypass_event_port,
5387 /* *** SET NIC BYPASS TIMEOUT *** */
5388 struct cmd_set_bypass_timeout_result {
5389 cmdline_fixed_string_t set;
5390 cmdline_fixed_string_t bypass;
5391 cmdline_fixed_string_t timeout;
5392 cmdline_fixed_string_t value;
5396 cmd_set_bypass_timeout_parsed(void *parsed_result,
5397 __attribute__((unused)) struct cmdline *cl,
5398 __attribute__((unused)) void *data)
5400 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5402 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5403 if (!strcmp(res->value, "1.5"))
5404 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5405 else if (!strcmp(res->value, "2"))
5406 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5407 else if (!strcmp(res->value, "3"))
5408 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5409 else if (!strcmp(res->value, "4"))
5410 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5411 else if (!strcmp(res->value, "8"))
5412 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5413 else if (!strcmp(res->value, "16"))
5414 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5415 else if (!strcmp(res->value, "32"))
5416 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5418 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5422 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5423 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5425 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5426 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5428 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5429 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5430 timeout, "timeout");
5431 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5432 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5433 value, "0#1.5#2#3#4#8#16#32");
5435 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5436 .f = cmd_set_bypass_timeout_parsed,
5437 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5438 "Set the NIC bypass watchdog timeout in seconds",
5441 (void *)&cmd_setbypass_timeout_set,
5442 (void *)&cmd_setbypass_timeout_bypass,
5443 (void *)&cmd_setbypass_timeout_timeout,
5444 (void *)&cmd_setbypass_timeout_value,
5449 /* *** SHOW NIC BYPASS MODE *** */
5450 struct cmd_show_bypass_config_result {
5451 cmdline_fixed_string_t show;
5452 cmdline_fixed_string_t bypass;
5453 cmdline_fixed_string_t config;
5458 cmd_show_bypass_config_parsed(void *parsed_result,
5459 __attribute__((unused)) struct cmdline *cl,
5460 __attribute__((unused)) void *data)
5462 struct cmd_show_bypass_config_result *res = parsed_result;
5463 portid_t port_id = res->port_id;
5465 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5466 uint32_t event_mode;
5467 uint32_t bypass_mode;
5468 uint32_t timeout = bypass_timeout;
5471 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5472 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5473 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5474 {"UNKNOWN", "normal", "bypass", "isolate"};
5475 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5482 int num_events = (sizeof events) / (sizeof events[0]);
5484 /* Display the bypass mode.*/
5485 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5486 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5490 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5491 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5493 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5496 /* Display the bypass timeout.*/
5497 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5498 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5500 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5502 /* Display the bypass events and associated modes. */
5503 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5505 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5506 printf("\tFailed to get bypass mode for event = %s\n",
5509 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5510 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5512 printf("\tbypass event: %-16s = %s\n", events[i],
5518 printf("\tFailed to get bypass configuration for port = %d\n",
5522 cmdline_parse_token_string_t cmd_showbypass_config_show =
5523 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5525 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5526 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5528 cmdline_parse_token_string_t cmd_showbypass_config_config =
5529 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5531 cmdline_parse_token_num_t cmd_showbypass_config_port =
5532 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5535 cmdline_parse_inst_t cmd_show_bypass_config = {
5536 .f = cmd_show_bypass_config_parsed,
5537 .help_str = "show bypass config <port_id>: "
5538 "Show the NIC bypass config for port_id",
5541 (void *)&cmd_showbypass_config_show,
5542 (void *)&cmd_showbypass_config_bypass,
5543 (void *)&cmd_showbypass_config_config,
5544 (void *)&cmd_showbypass_config_port,
5549 #ifdef RTE_LIBRTE_PMD_BOND
5550 /* *** SET BONDING MODE *** */
5551 struct cmd_set_bonding_mode_result {
5552 cmdline_fixed_string_t set;
5553 cmdline_fixed_string_t bonding;
5554 cmdline_fixed_string_t mode;
5559 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5560 __attribute__((unused)) struct cmdline *cl,
5561 __attribute__((unused)) void *data)
5563 struct cmd_set_bonding_mode_result *res = parsed_result;
5564 portid_t port_id = res->port_id;
5566 /* Set the bonding mode for the relevant port. */
5567 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5568 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5571 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5572 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5574 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5575 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5576 bonding, "bonding");
5577 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5578 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5580 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5581 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5583 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5584 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5587 cmdline_parse_inst_t cmd_set_bonding_mode = {
5588 .f = cmd_set_bonding_mode_parsed,
5589 .help_str = "set bonding mode <mode_value> <port_id>: "
5590 "Set the bonding mode for port_id",
5593 (void *) &cmd_setbonding_mode_set,
5594 (void *) &cmd_setbonding_mode_bonding,
5595 (void *) &cmd_setbonding_mode_mode,
5596 (void *) &cmd_setbonding_mode_value,
5597 (void *) &cmd_setbonding_mode_port,
5602 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5603 struct cmd_set_bonding_lacp_dedicated_queues_result {
5604 cmdline_fixed_string_t set;
5605 cmdline_fixed_string_t bonding;
5606 cmdline_fixed_string_t lacp;
5607 cmdline_fixed_string_t dedicated_queues;
5609 cmdline_fixed_string_t mode;
5612 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5613 __attribute__((unused)) struct cmdline *cl,
5614 __attribute__((unused)) void *data)
5616 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5617 portid_t port_id = res->port_id;
5618 struct rte_port *port;
5620 port = &ports[port_id];
5622 /** Check if the port is not started **/
5623 if (port->port_status != RTE_PORT_STOPPED) {
5624 printf("Please stop port %d first\n", port_id);
5628 if (!strcmp(res->mode, "enable")) {
5629 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5630 printf("Dedicate queues for LACP control packets"
5633 printf("Enabling dedicate queues for LACP control "
5634 "packets on port %d failed\n", port_id);
5635 } else if (!strcmp(res->mode, "disable")) {
5636 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5637 printf("Dedicated queues for LACP control packets "
5640 printf("Disabling dedicated queues for LACP control "
5641 "traffic on port %d failed\n", port_id);
5645 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5646 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5648 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5649 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5650 bonding, "bonding");
5651 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5652 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5654 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5655 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5656 dedicated_queues, "dedicated_queues");
5657 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5658 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5660 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5661 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5662 mode, "enable#disable");
5664 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5665 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5666 .help_str = "set bonding lacp dedicated_queues <port_id> "
5668 "Enable/disable dedicated queues for LACP control traffic for port_id",
5671 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5672 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5673 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5674 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5675 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5676 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5681 /* *** SET BALANCE XMIT POLICY *** */
5682 struct cmd_set_bonding_balance_xmit_policy_result {
5683 cmdline_fixed_string_t set;
5684 cmdline_fixed_string_t bonding;
5685 cmdline_fixed_string_t balance_xmit_policy;
5687 cmdline_fixed_string_t policy;
5690 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5691 __attribute__((unused)) struct cmdline *cl,
5692 __attribute__((unused)) void *data)
5694 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5695 portid_t port_id = res->port_id;
5698 if (!strcmp(res->policy, "l2")) {
5699 policy = BALANCE_XMIT_POLICY_LAYER2;
5700 } else if (!strcmp(res->policy, "l23")) {
5701 policy = BALANCE_XMIT_POLICY_LAYER23;
5702 } else if (!strcmp(res->policy, "l34")) {
5703 policy = BALANCE_XMIT_POLICY_LAYER34;
5705 printf("\t Invalid xmit policy selection");
5709 /* Set the bonding mode for the relevant port. */
5710 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5711 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5716 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5717 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5719 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5720 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5721 bonding, "bonding");
5722 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5723 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5724 balance_xmit_policy, "balance_xmit_policy");
5725 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5726 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5728 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5729 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5730 policy, "l2#l23#l34");
5732 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5733 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5734 .help_str = "set bonding balance_xmit_policy <port_id> "
5736 "Set the bonding balance_xmit_policy for port_id",
5739 (void *)&cmd_setbonding_balance_xmit_policy_set,
5740 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5741 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5742 (void *)&cmd_setbonding_balance_xmit_policy_port,
5743 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5748 /* *** SHOW NIC BONDING CONFIGURATION *** */
5749 struct cmd_show_bonding_config_result {
5750 cmdline_fixed_string_t show;
5751 cmdline_fixed_string_t bonding;
5752 cmdline_fixed_string_t config;
5756 static void cmd_show_bonding_config_parsed(void *parsed_result,
5757 __attribute__((unused)) struct cmdline *cl,
5758 __attribute__((unused)) void *data)
5760 struct cmd_show_bonding_config_result *res = parsed_result;
5761 int bonding_mode, agg_mode;
5762 portid_t slaves[RTE_MAX_ETHPORTS];
5763 int num_slaves, num_active_slaves;
5766 portid_t port_id = res->port_id;
5768 /* Display the bonding mode.*/
5769 bonding_mode = rte_eth_bond_mode_get(port_id);
5770 if (bonding_mode < 0) {
5771 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5774 printf("\tBonding mode: %d\n", bonding_mode);
5776 if (bonding_mode == BONDING_MODE_BALANCE) {
5777 int balance_xmit_policy;
5779 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5780 if (balance_xmit_policy < 0) {
5781 printf("\tFailed to get balance xmit policy for port = %d\n",
5785 printf("\tBalance Xmit Policy: ");
5787 switch (balance_xmit_policy) {
5788 case BALANCE_XMIT_POLICY_LAYER2:
5789 printf("BALANCE_XMIT_POLICY_LAYER2");
5791 case BALANCE_XMIT_POLICY_LAYER23:
5792 printf("BALANCE_XMIT_POLICY_LAYER23");
5794 case BALANCE_XMIT_POLICY_LAYER34:
5795 printf("BALANCE_XMIT_POLICY_LAYER34");
5802 if (bonding_mode == BONDING_MODE_8023AD) {
5803 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5804 printf("\tIEEE802.3AD Aggregator Mode: ");
5807 printf("bandwidth");
5819 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5821 if (num_slaves < 0) {
5822 printf("\tFailed to get slave list for port = %d\n", port_id);
5825 if (num_slaves > 0) {
5826 printf("\tSlaves (%d): [", num_slaves);
5827 for (i = 0; i < num_slaves - 1; i++)
5828 printf("%d ", slaves[i]);
5830 printf("%d]\n", slaves[num_slaves - 1]);
5832 printf("\tSlaves: []\n");
5836 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5839 if (num_active_slaves < 0) {
5840 printf("\tFailed to get active slave list for port = %d\n", port_id);
5843 if (num_active_slaves > 0) {
5844 printf("\tActive Slaves (%d): [", num_active_slaves);
5845 for (i = 0; i < num_active_slaves - 1; i++)
5846 printf("%d ", slaves[i]);
5848 printf("%d]\n", slaves[num_active_slaves - 1]);
5851 printf("\tActive Slaves: []\n");
5855 primary_id = rte_eth_bond_primary_get(port_id);
5856 if (primary_id < 0) {
5857 printf("\tFailed to get primary slave for port = %d\n", port_id);
5860 printf("\tPrimary: [%d]\n", primary_id);
5864 cmdline_parse_token_string_t cmd_showbonding_config_show =
5865 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5867 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5868 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5869 bonding, "bonding");
5870 cmdline_parse_token_string_t cmd_showbonding_config_config =
5871 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5873 cmdline_parse_token_num_t cmd_showbonding_config_port =
5874 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5877 cmdline_parse_inst_t cmd_show_bonding_config = {
5878 .f = cmd_show_bonding_config_parsed,
5879 .help_str = "show bonding config <port_id>: "
5880 "Show the bonding config for port_id",
5883 (void *)&cmd_showbonding_config_show,
5884 (void *)&cmd_showbonding_config_bonding,
5885 (void *)&cmd_showbonding_config_config,
5886 (void *)&cmd_showbonding_config_port,
5891 /* *** SET BONDING PRIMARY *** */
5892 struct cmd_set_bonding_primary_result {
5893 cmdline_fixed_string_t set;
5894 cmdline_fixed_string_t bonding;
5895 cmdline_fixed_string_t primary;
5900 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5901 __attribute__((unused)) struct cmdline *cl,
5902 __attribute__((unused)) void *data)
5904 struct cmd_set_bonding_primary_result *res = parsed_result;
5905 portid_t master_port_id = res->port_id;
5906 portid_t slave_port_id = res->slave_id;
5908 /* Set the primary slave for a bonded device. */
5909 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5910 printf("\t Failed to set primary slave for port = %d.\n",
5917 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5918 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5920 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5921 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5922 bonding, "bonding");
5923 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5924 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5925 primary, "primary");
5926 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5927 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5929 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5930 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5933 cmdline_parse_inst_t cmd_set_bonding_primary = {
5934 .f = cmd_set_bonding_primary_parsed,
5935 .help_str = "set bonding primary <slave_id> <port_id>: "
5936 "Set the primary slave for port_id",
5939 (void *)&cmd_setbonding_primary_set,
5940 (void *)&cmd_setbonding_primary_bonding,
5941 (void *)&cmd_setbonding_primary_primary,
5942 (void *)&cmd_setbonding_primary_slave,
5943 (void *)&cmd_setbonding_primary_port,
5948 /* *** ADD SLAVE *** */
5949 struct cmd_add_bonding_slave_result {
5950 cmdline_fixed_string_t add;
5951 cmdline_fixed_string_t bonding;
5952 cmdline_fixed_string_t slave;
5957 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5958 __attribute__((unused)) struct cmdline *cl,
5959 __attribute__((unused)) void *data)
5961 struct cmd_add_bonding_slave_result *res = parsed_result;
5962 portid_t master_port_id = res->port_id;
5963 portid_t slave_port_id = res->slave_id;
5965 /* add the slave for a bonded device. */
5966 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5967 printf("\t Failed to add slave %d to master port = %d.\n",
5968 slave_port_id, master_port_id);
5972 set_port_slave_flag(slave_port_id);
5975 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5976 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5978 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5979 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5980 bonding, "bonding");
5981 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5982 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5984 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5985 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5987 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5988 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5991 cmdline_parse_inst_t cmd_add_bonding_slave = {
5992 .f = cmd_add_bonding_slave_parsed,
5993 .help_str = "add bonding slave <slave_id> <port_id>: "
5994 "Add a slave device to a bonded device",
5997 (void *)&cmd_addbonding_slave_add,
5998 (void *)&cmd_addbonding_slave_bonding,
5999 (void *)&cmd_addbonding_slave_slave,
6000 (void *)&cmd_addbonding_slave_slaveid,
6001 (void *)&cmd_addbonding_slave_port,
6006 /* *** REMOVE SLAVE *** */
6007 struct cmd_remove_bonding_slave_result {
6008 cmdline_fixed_string_t remove;
6009 cmdline_fixed_string_t bonding;
6010 cmdline_fixed_string_t slave;
6015 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6016 __attribute__((unused)) struct cmdline *cl,
6017 __attribute__((unused)) void *data)
6019 struct cmd_remove_bonding_slave_result *res = parsed_result;
6020 portid_t master_port_id = res->port_id;
6021 portid_t slave_port_id = res->slave_id;
6023 /* remove the slave from a bonded device. */
6024 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6025 printf("\t Failed to remove slave %d from master port = %d.\n",
6026 slave_port_id, master_port_id);
6030 clear_port_slave_flag(slave_port_id);
6033 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6034 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6036 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6037 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6038 bonding, "bonding");
6039 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6040 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6042 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6043 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6045 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6046 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6049 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6050 .f = cmd_remove_bonding_slave_parsed,
6051 .help_str = "remove bonding slave <slave_id> <port_id>: "
6052 "Remove a slave device from a bonded device",
6055 (void *)&cmd_removebonding_slave_remove,
6056 (void *)&cmd_removebonding_slave_bonding,
6057 (void *)&cmd_removebonding_slave_slave,
6058 (void *)&cmd_removebonding_slave_slaveid,
6059 (void *)&cmd_removebonding_slave_port,
6064 /* *** CREATE BONDED DEVICE *** */
6065 struct cmd_create_bonded_device_result {
6066 cmdline_fixed_string_t create;
6067 cmdline_fixed_string_t bonded;
6068 cmdline_fixed_string_t device;
6073 static int bond_dev_num = 0;
6075 static void cmd_create_bonded_device_parsed(void *parsed_result,
6076 __attribute__((unused)) struct cmdline *cl,
6077 __attribute__((unused)) void *data)
6079 struct cmd_create_bonded_device_result *res = parsed_result;
6080 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6083 if (test_done == 0) {
6084 printf("Please stop forwarding first\n");
6088 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6091 /* Create a new bonded device. */
6092 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6094 printf("\t Failed to create bonded device.\n");
6097 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6100 /* Update number of ports */
6101 nb_ports = rte_eth_dev_count_avail();
6102 reconfig(port_id, res->socket);
6103 rte_eth_promiscuous_enable(port_id);
6104 ports[port_id].need_setup = 0;
6105 ports[port_id].port_status = RTE_PORT_STOPPED;
6110 cmdline_parse_token_string_t cmd_createbonded_device_create =
6111 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6113 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6114 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6116 cmdline_parse_token_string_t cmd_createbonded_device_device =
6117 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6119 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6120 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6122 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6123 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6126 cmdline_parse_inst_t cmd_create_bonded_device = {
6127 .f = cmd_create_bonded_device_parsed,
6128 .help_str = "create bonded device <mode> <socket>: "
6129 "Create a new bonded device with specific bonding mode and socket",
6132 (void *)&cmd_createbonded_device_create,
6133 (void *)&cmd_createbonded_device_bonded,
6134 (void *)&cmd_createbonded_device_device,
6135 (void *)&cmd_createbonded_device_mode,
6136 (void *)&cmd_createbonded_device_socket,
6141 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6142 struct cmd_set_bond_mac_addr_result {
6143 cmdline_fixed_string_t set;
6144 cmdline_fixed_string_t bonding;
6145 cmdline_fixed_string_t mac_addr;
6147 struct rte_ether_addr address;
6150 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6151 __attribute__((unused)) struct cmdline *cl,
6152 __attribute__((unused)) void *data)
6154 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6157 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6160 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6162 /* check the return value and print it if is < 0 */
6164 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6167 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6168 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6169 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6170 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6172 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6173 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6175 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6176 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6178 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6179 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6181 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6182 .f = cmd_set_bond_mac_addr_parsed,
6184 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6186 (void *)&cmd_set_bond_mac_addr_set,
6187 (void *)&cmd_set_bond_mac_addr_bonding,
6188 (void *)&cmd_set_bond_mac_addr_mac,
6189 (void *)&cmd_set_bond_mac_addr_portnum,
6190 (void *)&cmd_set_bond_mac_addr_addr,
6196 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6197 struct cmd_set_bond_mon_period_result {
6198 cmdline_fixed_string_t set;
6199 cmdline_fixed_string_t bonding;
6200 cmdline_fixed_string_t mon_period;
6205 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6206 __attribute__((unused)) struct cmdline *cl,
6207 __attribute__((unused)) void *data)
6209 struct cmd_set_bond_mon_period_result *res = parsed_result;
6212 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6214 /* check the return value and print it if is < 0 */
6216 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6219 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6220 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6222 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6223 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6224 bonding, "bonding");
6225 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6226 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6227 mon_period, "mon_period");
6228 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6229 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6231 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6232 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6235 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6236 .f = cmd_set_bond_mon_period_parsed,
6238 .help_str = "set bonding mon_period <port_id> <period_ms>",
6240 (void *)&cmd_set_bond_mon_period_set,
6241 (void *)&cmd_set_bond_mon_period_bonding,
6242 (void *)&cmd_set_bond_mon_period_mon_period,
6243 (void *)&cmd_set_bond_mon_period_portnum,
6244 (void *)&cmd_set_bond_mon_period_period_ms,
6251 struct cmd_set_bonding_agg_mode_policy_result {
6252 cmdline_fixed_string_t set;
6253 cmdline_fixed_string_t bonding;
6254 cmdline_fixed_string_t agg_mode;
6256 cmdline_fixed_string_t policy;
6261 cmd_set_bonding_agg_mode(void *parsed_result,
6262 __attribute__((unused)) struct cmdline *cl,
6263 __attribute__((unused)) void *data)
6265 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6266 uint8_t policy = AGG_BANDWIDTH;
6268 if (!strcmp(res->policy, "bandwidth"))
6269 policy = AGG_BANDWIDTH;
6270 else if (!strcmp(res->policy, "stable"))
6271 policy = AGG_STABLE;
6272 else if (!strcmp(res->policy, "count"))
6275 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6279 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6280 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6282 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6283 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6284 bonding, "bonding");
6286 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6287 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6288 agg_mode, "agg_mode");
6290 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6291 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6294 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6295 TOKEN_STRING_INITIALIZER(
6296 struct cmd_set_bonding_balance_xmit_policy_result,
6297 policy, "stable#bandwidth#count");
6299 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6300 .f = cmd_set_bonding_agg_mode,
6302 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6304 (void *)&cmd_set_bonding_agg_mode_set,
6305 (void *)&cmd_set_bonding_agg_mode_bonding,
6306 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6307 (void *)&cmd_set_bonding_agg_mode_portnum,
6308 (void *)&cmd_set_bonding_agg_mode_policy_string,
6314 #endif /* RTE_LIBRTE_PMD_BOND */
6316 /* *** SET FORWARDING MODE *** */
6317 struct cmd_set_fwd_mode_result {
6318 cmdline_fixed_string_t set;
6319 cmdline_fixed_string_t fwd;
6320 cmdline_fixed_string_t mode;
6323 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6324 __attribute__((unused)) struct cmdline *cl,
6325 __attribute__((unused)) void *data)
6327 struct cmd_set_fwd_mode_result *res = parsed_result;
6330 set_pkt_forwarding_mode(res->mode);
6333 cmdline_parse_token_string_t cmd_setfwd_set =
6334 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6335 cmdline_parse_token_string_t cmd_setfwd_fwd =
6336 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6337 cmdline_parse_token_string_t cmd_setfwd_mode =
6338 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6339 "" /* defined at init */);
6341 cmdline_parse_inst_t cmd_set_fwd_mode = {
6342 .f = cmd_set_fwd_mode_parsed,
6344 .help_str = NULL, /* defined at init */
6346 (void *)&cmd_setfwd_set,
6347 (void *)&cmd_setfwd_fwd,
6348 (void *)&cmd_setfwd_mode,
6353 static void cmd_set_fwd_mode_init(void)
6356 static char token[128];
6357 static char help[256];
6358 cmdline_parse_token_string_t *token_struct;
6360 modes = list_pkt_forwarding_modes();
6361 snprintf(help, sizeof(help), "set fwd %s: "
6362 "Set packet forwarding mode", modes);
6363 cmd_set_fwd_mode.help_str = help;
6365 /* string token separator is # */
6366 for (c = token; *modes != '\0'; modes++)
6371 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6372 token_struct->string_data.str = token;
6375 /* *** SET RETRY FORWARDING MODE *** */
6376 struct cmd_set_fwd_retry_mode_result {
6377 cmdline_fixed_string_t set;
6378 cmdline_fixed_string_t fwd;
6379 cmdline_fixed_string_t mode;
6380 cmdline_fixed_string_t retry;
6383 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6384 __attribute__((unused)) struct cmdline *cl,
6385 __attribute__((unused)) void *data)
6387 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6390 set_pkt_forwarding_mode(res->mode);
6393 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6394 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6396 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6397 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6399 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6400 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6402 "" /* defined at init */);
6403 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6404 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6407 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6408 .f = cmd_set_fwd_retry_mode_parsed,
6410 .help_str = NULL, /* defined at init */
6412 (void *)&cmd_setfwd_retry_set,
6413 (void *)&cmd_setfwd_retry_fwd,
6414 (void *)&cmd_setfwd_retry_mode,
6415 (void *)&cmd_setfwd_retry_retry,
6420 static void cmd_set_fwd_retry_mode_init(void)
6423 static char token[128];
6424 static char help[256];
6425 cmdline_parse_token_string_t *token_struct;
6427 modes = list_pkt_forwarding_retry_modes();
6428 snprintf(help, sizeof(help), "set fwd %s retry: "
6429 "Set packet forwarding mode with retry", modes);
6430 cmd_set_fwd_retry_mode.help_str = help;
6432 /* string token separator is # */
6433 for (c = token; *modes != '\0'; modes++)
6438 token_struct = (cmdline_parse_token_string_t *)
6439 cmd_set_fwd_retry_mode.tokens[2];
6440 token_struct->string_data.str = token;
6443 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6444 struct cmd_set_burst_tx_retry_result {
6445 cmdline_fixed_string_t set;
6446 cmdline_fixed_string_t burst;
6447 cmdline_fixed_string_t tx;
6448 cmdline_fixed_string_t delay;
6450 cmdline_fixed_string_t retry;
6454 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6455 __attribute__((unused)) struct cmdline *cl,
6456 __attribute__((unused)) void *data)
6458 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6460 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6461 && !strcmp(res->tx, "tx")) {
6462 if (!strcmp(res->delay, "delay"))
6463 burst_tx_delay_time = res->time;
6464 if (!strcmp(res->retry, "retry"))
6465 burst_tx_retry_num = res->retry_num;
6470 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6471 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6472 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6473 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6475 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6476 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6477 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6478 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6479 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6480 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6481 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6482 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6483 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6484 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6486 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6487 .f = cmd_set_burst_tx_retry_parsed,
6488 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6490 (void *)&cmd_set_burst_tx_retry_set,
6491 (void *)&cmd_set_burst_tx_retry_burst,
6492 (void *)&cmd_set_burst_tx_retry_tx,
6493 (void *)&cmd_set_burst_tx_retry_delay,
6494 (void *)&cmd_set_burst_tx_retry_time,
6495 (void *)&cmd_set_burst_tx_retry_retry,
6496 (void *)&cmd_set_burst_tx_retry_retry_num,
6501 /* *** SET PROMISC MODE *** */
6502 struct cmd_set_promisc_mode_result {
6503 cmdline_fixed_string_t set;
6504 cmdline_fixed_string_t promisc;
6505 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6506 uint16_t port_num; /* valid if "allports" argument == 0 */
6507 cmdline_fixed_string_t mode;
6510 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6511 __attribute__((unused)) struct cmdline *cl,
6514 struct cmd_set_promisc_mode_result *res = parsed_result;
6518 if (!strcmp(res->mode, "on"))
6525 RTE_ETH_FOREACH_DEV(i) {
6527 rte_eth_promiscuous_enable(i);
6529 rte_eth_promiscuous_disable(i);
6534 rte_eth_promiscuous_enable(res->port_num);
6536 rte_eth_promiscuous_disable(res->port_num);
6540 cmdline_parse_token_string_t cmd_setpromisc_set =
6541 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6542 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6543 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6545 cmdline_parse_token_string_t cmd_setpromisc_portall =
6546 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6548 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6549 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6551 cmdline_parse_token_string_t cmd_setpromisc_mode =
6552 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6555 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6556 .f = cmd_set_promisc_mode_parsed,
6558 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6560 (void *)&cmd_setpromisc_set,
6561 (void *)&cmd_setpromisc_promisc,
6562 (void *)&cmd_setpromisc_portall,
6563 (void *)&cmd_setpromisc_mode,
6568 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6569 .f = cmd_set_promisc_mode_parsed,
6571 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6573 (void *)&cmd_setpromisc_set,
6574 (void *)&cmd_setpromisc_promisc,
6575 (void *)&cmd_setpromisc_portnum,
6576 (void *)&cmd_setpromisc_mode,
6581 /* *** SET ALLMULTI MODE *** */
6582 struct cmd_set_allmulti_mode_result {
6583 cmdline_fixed_string_t set;
6584 cmdline_fixed_string_t allmulti;
6585 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6586 uint16_t port_num; /* valid if "allports" argument == 0 */
6587 cmdline_fixed_string_t mode;
6590 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6591 __attribute__((unused)) struct cmdline *cl,
6594 struct cmd_set_allmulti_mode_result *res = parsed_result;
6598 if (!strcmp(res->mode, "on"))
6605 RTE_ETH_FOREACH_DEV(i) {
6607 rte_eth_allmulticast_enable(i);
6609 rte_eth_allmulticast_disable(i);
6614 rte_eth_allmulticast_enable(res->port_num);
6616 rte_eth_allmulticast_disable(res->port_num);
6620 cmdline_parse_token_string_t cmd_setallmulti_set =
6621 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6622 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6623 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6625 cmdline_parse_token_string_t cmd_setallmulti_portall =
6626 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6628 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6629 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6631 cmdline_parse_token_string_t cmd_setallmulti_mode =
6632 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6635 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6636 .f = cmd_set_allmulti_mode_parsed,
6638 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6640 (void *)&cmd_setallmulti_set,
6641 (void *)&cmd_setallmulti_allmulti,
6642 (void *)&cmd_setallmulti_portall,
6643 (void *)&cmd_setallmulti_mode,
6648 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6649 .f = cmd_set_allmulti_mode_parsed,
6651 .help_str = "set allmulti <port_id> on|off: "
6652 "Set allmulti mode on port_id",
6654 (void *)&cmd_setallmulti_set,
6655 (void *)&cmd_setallmulti_allmulti,
6656 (void *)&cmd_setallmulti_portnum,
6657 (void *)&cmd_setallmulti_mode,
6662 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6663 struct cmd_link_flow_ctrl_set_result {
6664 cmdline_fixed_string_t set;
6665 cmdline_fixed_string_t flow_ctrl;
6666 cmdline_fixed_string_t rx;
6667 cmdline_fixed_string_t rx_lfc_mode;
6668 cmdline_fixed_string_t tx;
6669 cmdline_fixed_string_t tx_lfc_mode;
6670 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6671 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6672 cmdline_fixed_string_t autoneg_str;
6673 cmdline_fixed_string_t autoneg;
6674 cmdline_fixed_string_t hw_str;
6675 uint32_t high_water;
6676 cmdline_fixed_string_t lw_str;
6678 cmdline_fixed_string_t pt_str;
6679 uint16_t pause_time;
6680 cmdline_fixed_string_t xon_str;
6685 cmdline_parse_token_string_t cmd_lfc_set_set =
6686 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6688 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6689 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6690 flow_ctrl, "flow_ctrl");
6691 cmdline_parse_token_string_t cmd_lfc_set_rx =
6692 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6694 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6695 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6696 rx_lfc_mode, "on#off");
6697 cmdline_parse_token_string_t cmd_lfc_set_tx =
6698 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6700 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6701 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6702 tx_lfc_mode, "on#off");
6703 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6704 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6705 hw_str, "high_water");
6706 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6707 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6708 high_water, UINT32);
6709 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6710 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6711 lw_str, "low_water");
6712 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6713 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6715 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6716 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6717 pt_str, "pause_time");
6718 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6719 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6720 pause_time, UINT16);
6721 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6722 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6723 xon_str, "send_xon");
6724 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6725 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6727 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6728 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6729 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6730 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6731 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6732 mac_ctrl_frame_fwd_mode, "on#off");
6733 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6734 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6735 autoneg_str, "autoneg");
6736 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6737 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6739 cmdline_parse_token_num_t cmd_lfc_set_portid =
6740 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6743 /* forward declaration */
6745 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6748 cmdline_parse_inst_t cmd_link_flow_control_set = {
6749 .f = cmd_link_flow_ctrl_set_parsed,
6751 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6752 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6753 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6755 (void *)&cmd_lfc_set_set,
6756 (void *)&cmd_lfc_set_flow_ctrl,
6757 (void *)&cmd_lfc_set_rx,
6758 (void *)&cmd_lfc_set_rx_mode,
6759 (void *)&cmd_lfc_set_tx,
6760 (void *)&cmd_lfc_set_tx_mode,
6761 (void *)&cmd_lfc_set_high_water,
6762 (void *)&cmd_lfc_set_low_water,
6763 (void *)&cmd_lfc_set_pause_time,
6764 (void *)&cmd_lfc_set_send_xon,
6765 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6766 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6767 (void *)&cmd_lfc_set_autoneg_str,
6768 (void *)&cmd_lfc_set_autoneg,
6769 (void *)&cmd_lfc_set_portid,
6774 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6775 .f = cmd_link_flow_ctrl_set_parsed,
6776 .data = (void *)&cmd_link_flow_control_set_rx,
6777 .help_str = "set flow_ctrl rx on|off <port_id>: "
6778 "Change rx flow control parameter",
6780 (void *)&cmd_lfc_set_set,
6781 (void *)&cmd_lfc_set_flow_ctrl,
6782 (void *)&cmd_lfc_set_rx,
6783 (void *)&cmd_lfc_set_rx_mode,
6784 (void *)&cmd_lfc_set_portid,
6789 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6790 .f = cmd_link_flow_ctrl_set_parsed,
6791 .data = (void *)&cmd_link_flow_control_set_tx,
6792 .help_str = "set flow_ctrl tx on|off <port_id>: "
6793 "Change tx flow control parameter",
6795 (void *)&cmd_lfc_set_set,
6796 (void *)&cmd_lfc_set_flow_ctrl,
6797 (void *)&cmd_lfc_set_tx,
6798 (void *)&cmd_lfc_set_tx_mode,
6799 (void *)&cmd_lfc_set_portid,
6804 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6805 .f = cmd_link_flow_ctrl_set_parsed,
6806 .data = (void *)&cmd_link_flow_control_set_hw,
6807 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6808 "Change high water flow control parameter",
6810 (void *)&cmd_lfc_set_set,
6811 (void *)&cmd_lfc_set_flow_ctrl,
6812 (void *)&cmd_lfc_set_high_water_str,
6813 (void *)&cmd_lfc_set_high_water,
6814 (void *)&cmd_lfc_set_portid,
6819 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6820 .f = cmd_link_flow_ctrl_set_parsed,
6821 .data = (void *)&cmd_link_flow_control_set_lw,
6822 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6823 "Change low water flow control parameter",
6825 (void *)&cmd_lfc_set_set,
6826 (void *)&cmd_lfc_set_flow_ctrl,
6827 (void *)&cmd_lfc_set_low_water_str,
6828 (void *)&cmd_lfc_set_low_water,
6829 (void *)&cmd_lfc_set_portid,
6834 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6835 .f = cmd_link_flow_ctrl_set_parsed,
6836 .data = (void *)&cmd_link_flow_control_set_pt,
6837 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6838 "Change pause time flow control parameter",
6840 (void *)&cmd_lfc_set_set,
6841 (void *)&cmd_lfc_set_flow_ctrl,
6842 (void *)&cmd_lfc_set_pause_time_str,
6843 (void *)&cmd_lfc_set_pause_time,
6844 (void *)&cmd_lfc_set_portid,
6849 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6850 .f = cmd_link_flow_ctrl_set_parsed,
6851 .data = (void *)&cmd_link_flow_control_set_xon,
6852 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6853 "Change send_xon flow control parameter",
6855 (void *)&cmd_lfc_set_set,
6856 (void *)&cmd_lfc_set_flow_ctrl,
6857 (void *)&cmd_lfc_set_send_xon_str,
6858 (void *)&cmd_lfc_set_send_xon,
6859 (void *)&cmd_lfc_set_portid,
6864 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6865 .f = cmd_link_flow_ctrl_set_parsed,
6866 .data = (void *)&cmd_link_flow_control_set_macfwd,
6867 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6868 "Change mac ctrl fwd flow control parameter",
6870 (void *)&cmd_lfc_set_set,
6871 (void *)&cmd_lfc_set_flow_ctrl,
6872 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6873 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6874 (void *)&cmd_lfc_set_portid,
6879 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6880 .f = cmd_link_flow_ctrl_set_parsed,
6881 .data = (void *)&cmd_link_flow_control_set_autoneg,
6882 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6883 "Change autoneg flow control parameter",
6885 (void *)&cmd_lfc_set_set,
6886 (void *)&cmd_lfc_set_flow_ctrl,
6887 (void *)&cmd_lfc_set_autoneg_str,
6888 (void *)&cmd_lfc_set_autoneg,
6889 (void *)&cmd_lfc_set_portid,
6895 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6896 __attribute__((unused)) struct cmdline *cl,
6899 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6900 cmdline_parse_inst_t *cmd = data;
6901 struct rte_eth_fc_conf fc_conf;
6907 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6908 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6909 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6910 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6912 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6913 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6916 /* Partial command line, retrieve current configuration */
6918 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6920 printf("cannot get current flow ctrl parameters, return"
6921 "code = %d\n", ret);
6925 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6926 (fc_conf.mode == RTE_FC_FULL))
6928 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6929 (fc_conf.mode == RTE_FC_FULL))
6933 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6934 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6936 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6937 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6939 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6941 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6942 fc_conf.high_water = res->high_water;
6944 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6945 fc_conf.low_water = res->low_water;
6947 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6948 fc_conf.pause_time = res->pause_time;
6950 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6951 fc_conf.send_xon = res->send_xon;
6953 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6954 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6955 fc_conf.mac_ctrl_frame_fwd = 1;
6957 fc_conf.mac_ctrl_frame_fwd = 0;
6960 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6961 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6963 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6965 printf("bad flow contrl parameter, return code = %d \n", ret);
6968 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6969 struct cmd_priority_flow_ctrl_set_result {
6970 cmdline_fixed_string_t set;
6971 cmdline_fixed_string_t pfc_ctrl;
6972 cmdline_fixed_string_t rx;
6973 cmdline_fixed_string_t rx_pfc_mode;
6974 cmdline_fixed_string_t tx;
6975 cmdline_fixed_string_t tx_pfc_mode;
6976 uint32_t high_water;
6978 uint16_t pause_time;
6984 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6985 __attribute__((unused)) struct cmdline *cl,
6986 __attribute__((unused)) void *data)
6988 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6989 struct rte_eth_pfc_conf pfc_conf;
6990 int rx_fc_enable, tx_fc_enable;
6994 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6995 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6996 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6997 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6999 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7000 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
7003 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7004 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7005 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7006 pfc_conf.fc.high_water = res->high_water;
7007 pfc_conf.fc.low_water = res->low_water;
7008 pfc_conf.fc.pause_time = res->pause_time;
7009 pfc_conf.priority = res->priority;
7011 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7013 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7016 cmdline_parse_token_string_t cmd_pfc_set_set =
7017 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7019 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7020 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7021 pfc_ctrl, "pfc_ctrl");
7022 cmdline_parse_token_string_t cmd_pfc_set_rx =
7023 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7025 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7026 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7027 rx_pfc_mode, "on#off");
7028 cmdline_parse_token_string_t cmd_pfc_set_tx =
7029 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7031 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7032 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7033 tx_pfc_mode, "on#off");
7034 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7035 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7036 high_water, UINT32);
7037 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7038 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7040 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7041 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7042 pause_time, UINT16);
7043 cmdline_parse_token_num_t cmd_pfc_set_priority =
7044 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7046 cmdline_parse_token_num_t cmd_pfc_set_portid =
7047 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7050 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7051 .f = cmd_priority_flow_ctrl_set_parsed,
7053 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7054 "<pause_time> <priority> <port_id>: "
7055 "Configure the Ethernet priority flow control",
7057 (void *)&cmd_pfc_set_set,
7058 (void *)&cmd_pfc_set_flow_ctrl,
7059 (void *)&cmd_pfc_set_rx,
7060 (void *)&cmd_pfc_set_rx_mode,
7061 (void *)&cmd_pfc_set_tx,
7062 (void *)&cmd_pfc_set_tx_mode,
7063 (void *)&cmd_pfc_set_high_water,
7064 (void *)&cmd_pfc_set_low_water,
7065 (void *)&cmd_pfc_set_pause_time,
7066 (void *)&cmd_pfc_set_priority,
7067 (void *)&cmd_pfc_set_portid,
7072 /* *** RESET CONFIGURATION *** */
7073 struct cmd_reset_result {
7074 cmdline_fixed_string_t reset;
7075 cmdline_fixed_string_t def;
7078 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
7080 __attribute__((unused)) void *data)
7082 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7083 set_def_fwd_config();
7086 cmdline_parse_token_string_t cmd_reset_set =
7087 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7088 cmdline_parse_token_string_t cmd_reset_def =
7089 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7092 cmdline_parse_inst_t cmd_reset = {
7093 .f = cmd_reset_parsed,
7095 .help_str = "set default: Reset default forwarding configuration",
7097 (void *)&cmd_reset_set,
7098 (void *)&cmd_reset_def,
7103 /* *** START FORWARDING *** */
7104 struct cmd_start_result {
7105 cmdline_fixed_string_t start;
7108 cmdline_parse_token_string_t cmd_start_start =
7109 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7111 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
7112 __attribute__((unused)) struct cmdline *cl,
7113 __attribute__((unused)) void *data)
7115 start_packet_forwarding(0);
7118 cmdline_parse_inst_t cmd_start = {
7119 .f = cmd_start_parsed,
7121 .help_str = "start: Start packet forwarding",
7123 (void *)&cmd_start_start,
7128 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7129 struct cmd_start_tx_first_result {
7130 cmdline_fixed_string_t start;
7131 cmdline_fixed_string_t tx_first;
7135 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
7136 __attribute__((unused)) struct cmdline *cl,
7137 __attribute__((unused)) void *data)
7139 start_packet_forwarding(1);
7142 cmdline_parse_token_string_t cmd_start_tx_first_start =
7143 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7145 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7146 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7147 tx_first, "tx_first");
7149 cmdline_parse_inst_t cmd_start_tx_first = {
7150 .f = cmd_start_tx_first_parsed,
7152 .help_str = "start tx_first: Start packet forwarding, "
7153 "after sending 1 burst of packets",
7155 (void *)&cmd_start_tx_first_start,
7156 (void *)&cmd_start_tx_first_tx_first,
7161 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7162 struct cmd_start_tx_first_n_result {
7163 cmdline_fixed_string_t start;
7164 cmdline_fixed_string_t tx_first;
7169 cmd_start_tx_first_n_parsed(void *parsed_result,
7170 __attribute__((unused)) struct cmdline *cl,
7171 __attribute__((unused)) void *data)
7173 struct cmd_start_tx_first_n_result *res = parsed_result;
7175 start_packet_forwarding(res->tx_num);
7178 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7179 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7181 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7182 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7183 tx_first, "tx_first");
7184 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7185 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7188 cmdline_parse_inst_t cmd_start_tx_first_n = {
7189 .f = cmd_start_tx_first_n_parsed,
7191 .help_str = "start tx_first <num>: "
7192 "packet forwarding, after sending <num> bursts of packets",
7194 (void *)&cmd_start_tx_first_n_start,
7195 (void *)&cmd_start_tx_first_n_tx_first,
7196 (void *)&cmd_start_tx_first_n_tx_num,
7201 /* *** SET LINK UP *** */
7202 struct cmd_set_link_up_result {
7203 cmdline_fixed_string_t set;
7204 cmdline_fixed_string_t link_up;
7205 cmdline_fixed_string_t port;
7209 cmdline_parse_token_string_t cmd_set_link_up_set =
7210 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7211 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7212 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7214 cmdline_parse_token_string_t cmd_set_link_up_port =
7215 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7216 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7217 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7219 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
7220 __attribute__((unused)) struct cmdline *cl,
7221 __attribute__((unused)) void *data)
7223 struct cmd_set_link_up_result *res = parsed_result;
7224 dev_set_link_up(res->port_id);
7227 cmdline_parse_inst_t cmd_set_link_up = {
7228 .f = cmd_set_link_up_parsed,
7230 .help_str = "set link-up port <port id>",
7232 (void *)&cmd_set_link_up_set,
7233 (void *)&cmd_set_link_up_link_up,
7234 (void *)&cmd_set_link_up_port,
7235 (void *)&cmd_set_link_up_port_id,
7240 /* *** SET LINK DOWN *** */
7241 struct cmd_set_link_down_result {
7242 cmdline_fixed_string_t set;
7243 cmdline_fixed_string_t link_down;
7244 cmdline_fixed_string_t port;
7248 cmdline_parse_token_string_t cmd_set_link_down_set =
7249 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7250 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7251 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7253 cmdline_parse_token_string_t cmd_set_link_down_port =
7254 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7255 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7256 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7258 static void cmd_set_link_down_parsed(
7259 __attribute__((unused)) void *parsed_result,
7260 __attribute__((unused)) struct cmdline *cl,
7261 __attribute__((unused)) void *data)
7263 struct cmd_set_link_down_result *res = parsed_result;
7264 dev_set_link_down(res->port_id);
7267 cmdline_parse_inst_t cmd_set_link_down = {
7268 .f = cmd_set_link_down_parsed,
7270 .help_str = "set link-down port <port id>",
7272 (void *)&cmd_set_link_down_set,
7273 (void *)&cmd_set_link_down_link_down,
7274 (void *)&cmd_set_link_down_port,
7275 (void *)&cmd_set_link_down_port_id,
7280 /* *** SHOW CFG *** */
7281 struct cmd_showcfg_result {
7282 cmdline_fixed_string_t show;
7283 cmdline_fixed_string_t cfg;
7284 cmdline_fixed_string_t what;
7287 static void cmd_showcfg_parsed(void *parsed_result,
7288 __attribute__((unused)) struct cmdline *cl,
7289 __attribute__((unused)) void *data)
7291 struct cmd_showcfg_result *res = parsed_result;
7292 if (!strcmp(res->what, "rxtx"))
7293 rxtx_config_display();
7294 else if (!strcmp(res->what, "cores"))
7295 fwd_lcores_config_display();
7296 else if (!strcmp(res->what, "fwd"))
7297 pkt_fwd_config_display(&cur_fwd_config);
7298 else if (!strcmp(res->what, "txpkts"))
7299 show_tx_pkt_segments();
7302 cmdline_parse_token_string_t cmd_showcfg_show =
7303 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7304 cmdline_parse_token_string_t cmd_showcfg_port =
7305 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7306 cmdline_parse_token_string_t cmd_showcfg_what =
7307 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7308 "rxtx#cores#fwd#txpkts");
7310 cmdline_parse_inst_t cmd_showcfg = {
7311 .f = cmd_showcfg_parsed,
7313 .help_str = "show config rxtx|cores|fwd|txpkts",
7315 (void *)&cmd_showcfg_show,
7316 (void *)&cmd_showcfg_port,
7317 (void *)&cmd_showcfg_what,
7322 /* *** SHOW ALL PORT INFO *** */
7323 struct cmd_showportall_result {
7324 cmdline_fixed_string_t show;
7325 cmdline_fixed_string_t port;
7326 cmdline_fixed_string_t what;
7327 cmdline_fixed_string_t all;
7330 static void cmd_showportall_parsed(void *parsed_result,
7331 __attribute__((unused)) struct cmdline *cl,
7332 __attribute__((unused)) void *data)
7336 struct cmd_showportall_result *res = parsed_result;
7337 if (!strcmp(res->show, "clear")) {
7338 if (!strcmp(res->what, "stats"))
7339 RTE_ETH_FOREACH_DEV(i)
7341 else if (!strcmp(res->what, "xstats"))
7342 RTE_ETH_FOREACH_DEV(i)
7343 nic_xstats_clear(i);
7344 } else if (!strcmp(res->what, "info"))
7345 RTE_ETH_FOREACH_DEV(i)
7346 port_infos_display(i);
7347 else if (!strcmp(res->what, "summary")) {
7348 port_summary_header_display();
7349 RTE_ETH_FOREACH_DEV(i)
7350 port_summary_display(i);
7352 else if (!strcmp(res->what, "stats"))
7353 RTE_ETH_FOREACH_DEV(i)
7354 nic_stats_display(i);
7355 else if (!strcmp(res->what, "xstats"))
7356 RTE_ETH_FOREACH_DEV(i)
7357 nic_xstats_display(i);
7358 else if (!strcmp(res->what, "fdir"))
7359 RTE_ETH_FOREACH_DEV(i)
7361 else if (!strcmp(res->what, "stat_qmap"))
7362 RTE_ETH_FOREACH_DEV(i)
7363 nic_stats_mapping_display(i);
7364 else if (!strcmp(res->what, "dcb_tc"))
7365 RTE_ETH_FOREACH_DEV(i)
7366 port_dcb_info_display(i);
7367 else if (!strcmp(res->what, "cap"))
7368 RTE_ETH_FOREACH_DEV(i)
7369 port_offload_cap_display(i);
7372 cmdline_parse_token_string_t cmd_showportall_show =
7373 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7375 cmdline_parse_token_string_t cmd_showportall_port =
7376 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7377 cmdline_parse_token_string_t cmd_showportall_what =
7378 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7379 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7380 cmdline_parse_token_string_t cmd_showportall_all =
7381 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7382 cmdline_parse_inst_t cmd_showportall = {
7383 .f = cmd_showportall_parsed,
7385 .help_str = "show|clear port "
7386 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7388 (void *)&cmd_showportall_show,
7389 (void *)&cmd_showportall_port,
7390 (void *)&cmd_showportall_what,
7391 (void *)&cmd_showportall_all,
7396 /* *** SHOW PORT INFO *** */
7397 struct cmd_showport_result {
7398 cmdline_fixed_string_t show;
7399 cmdline_fixed_string_t port;
7400 cmdline_fixed_string_t what;
7404 static void cmd_showport_parsed(void *parsed_result,
7405 __attribute__((unused)) struct cmdline *cl,
7406 __attribute__((unused)) void *data)
7408 struct cmd_showport_result *res = parsed_result;
7409 if (!strcmp(res->show, "clear")) {
7410 if (!strcmp(res->what, "stats"))
7411 nic_stats_clear(res->portnum);
7412 else if (!strcmp(res->what, "xstats"))
7413 nic_xstats_clear(res->portnum);
7414 } else if (!strcmp(res->what, "info"))
7415 port_infos_display(res->portnum);
7416 else if (!strcmp(res->what, "summary")) {
7417 port_summary_header_display();
7418 port_summary_display(res->portnum);
7420 else if (!strcmp(res->what, "stats"))
7421 nic_stats_display(res->portnum);
7422 else if (!strcmp(res->what, "xstats"))
7423 nic_xstats_display(res->portnum);
7424 else if (!strcmp(res->what, "fdir"))
7425 fdir_get_infos(res->portnum);
7426 else if (!strcmp(res->what, "stat_qmap"))
7427 nic_stats_mapping_display(res->portnum);
7428 else if (!strcmp(res->what, "dcb_tc"))
7429 port_dcb_info_display(res->portnum);
7430 else if (!strcmp(res->what, "cap"))
7431 port_offload_cap_display(res->portnum);
7434 cmdline_parse_token_string_t cmd_showport_show =
7435 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7437 cmdline_parse_token_string_t cmd_showport_port =
7438 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7439 cmdline_parse_token_string_t cmd_showport_what =
7440 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7441 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7442 cmdline_parse_token_num_t cmd_showport_portnum =
7443 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7445 cmdline_parse_inst_t cmd_showport = {
7446 .f = cmd_showport_parsed,
7448 .help_str = "show|clear port "
7449 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7452 (void *)&cmd_showport_show,
7453 (void *)&cmd_showport_port,
7454 (void *)&cmd_showport_what,
7455 (void *)&cmd_showport_portnum,
7460 /* *** SHOW QUEUE INFO *** */
7461 struct cmd_showqueue_result {
7462 cmdline_fixed_string_t show;
7463 cmdline_fixed_string_t type;
7464 cmdline_fixed_string_t what;
7470 cmd_showqueue_parsed(void *parsed_result,
7471 __attribute__((unused)) struct cmdline *cl,
7472 __attribute__((unused)) void *data)
7474 struct cmd_showqueue_result *res = parsed_result;
7476 if (!strcmp(res->type, "rxq"))
7477 rx_queue_infos_display(res->portnum, res->queuenum);
7478 else if (!strcmp(res->type, "txq"))
7479 tx_queue_infos_display(res->portnum, res->queuenum);
7482 cmdline_parse_token_string_t cmd_showqueue_show =
7483 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7484 cmdline_parse_token_string_t cmd_showqueue_type =
7485 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7486 cmdline_parse_token_string_t cmd_showqueue_what =
7487 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7488 cmdline_parse_token_num_t cmd_showqueue_portnum =
7489 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7490 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7491 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7493 cmdline_parse_inst_t cmd_showqueue = {
7494 .f = cmd_showqueue_parsed,
7496 .help_str = "show rxq|txq info <port_id> <queue_id>",
7498 (void *)&cmd_showqueue_show,
7499 (void *)&cmd_showqueue_type,
7500 (void *)&cmd_showqueue_what,
7501 (void *)&cmd_showqueue_portnum,
7502 (void *)&cmd_showqueue_queuenum,
7507 /* show/clear fwd engine statistics */
7509 cmdline_fixed_string_t action;
7510 cmdline_fixed_string_t fwd;
7511 cmdline_fixed_string_t stats;
7512 cmdline_fixed_string_t all;
7515 cmdline_parse_token_string_t cmd_fwd_action =
7516 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7517 cmdline_parse_token_string_t cmd_fwd_fwd =
7518 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7519 cmdline_parse_token_string_t cmd_fwd_stats =
7520 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7521 cmdline_parse_token_string_t cmd_fwd_all =
7522 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7525 cmd_showfwdall_parsed(void *parsed_result,
7526 __rte_unused struct cmdline *cl,
7527 __rte_unused void *data)
7529 struct fwd_result *res = parsed_result;
7531 if (!strcmp(res->action, "show"))
7532 fwd_stats_display();
7537 static cmdline_parse_inst_t cmd_showfwdall = {
7538 .f = cmd_showfwdall_parsed,
7540 .help_str = "show|clear fwd stats all",
7542 (void *)&cmd_fwd_action,
7543 (void *)&cmd_fwd_fwd,
7544 (void *)&cmd_fwd_stats,
7545 (void *)&cmd_fwd_all,
7550 /* *** READ PORT REGISTER *** */
7551 struct cmd_read_reg_result {
7552 cmdline_fixed_string_t read;
7553 cmdline_fixed_string_t reg;
7559 cmd_read_reg_parsed(void *parsed_result,
7560 __attribute__((unused)) struct cmdline *cl,
7561 __attribute__((unused)) void *data)
7563 struct cmd_read_reg_result *res = parsed_result;
7564 port_reg_display(res->port_id, res->reg_off);
7567 cmdline_parse_token_string_t cmd_read_reg_read =
7568 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7569 cmdline_parse_token_string_t cmd_read_reg_reg =
7570 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7571 cmdline_parse_token_num_t cmd_read_reg_port_id =
7572 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7573 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7574 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7576 cmdline_parse_inst_t cmd_read_reg = {
7577 .f = cmd_read_reg_parsed,
7579 .help_str = "read reg <port_id> <reg_off>",
7581 (void *)&cmd_read_reg_read,
7582 (void *)&cmd_read_reg_reg,
7583 (void *)&cmd_read_reg_port_id,
7584 (void *)&cmd_read_reg_reg_off,
7589 /* *** READ PORT REGISTER BIT FIELD *** */
7590 struct cmd_read_reg_bit_field_result {
7591 cmdline_fixed_string_t read;
7592 cmdline_fixed_string_t regfield;
7600 cmd_read_reg_bit_field_parsed(void *parsed_result,
7601 __attribute__((unused)) struct cmdline *cl,
7602 __attribute__((unused)) void *data)
7604 struct cmd_read_reg_bit_field_result *res = parsed_result;
7605 port_reg_bit_field_display(res->port_id, res->reg_off,
7606 res->bit1_pos, res->bit2_pos);
7609 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7610 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7612 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7613 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7614 regfield, "regfield");
7615 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7616 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7618 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7619 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7621 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7622 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7624 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7625 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7628 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7629 .f = cmd_read_reg_bit_field_parsed,
7631 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7632 "Read register bit field between bit_x and bit_y included",
7634 (void *)&cmd_read_reg_bit_field_read,
7635 (void *)&cmd_read_reg_bit_field_regfield,
7636 (void *)&cmd_read_reg_bit_field_port_id,
7637 (void *)&cmd_read_reg_bit_field_reg_off,
7638 (void *)&cmd_read_reg_bit_field_bit1_pos,
7639 (void *)&cmd_read_reg_bit_field_bit2_pos,
7644 /* *** READ PORT REGISTER BIT *** */
7645 struct cmd_read_reg_bit_result {
7646 cmdline_fixed_string_t read;
7647 cmdline_fixed_string_t regbit;
7654 cmd_read_reg_bit_parsed(void *parsed_result,
7655 __attribute__((unused)) struct cmdline *cl,
7656 __attribute__((unused)) void *data)
7658 struct cmd_read_reg_bit_result *res = parsed_result;
7659 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7662 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7663 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7664 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7665 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7667 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7668 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7669 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7670 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7671 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7672 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7674 cmdline_parse_inst_t cmd_read_reg_bit = {
7675 .f = cmd_read_reg_bit_parsed,
7677 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7679 (void *)&cmd_read_reg_bit_read,
7680 (void *)&cmd_read_reg_bit_regbit,
7681 (void *)&cmd_read_reg_bit_port_id,
7682 (void *)&cmd_read_reg_bit_reg_off,
7683 (void *)&cmd_read_reg_bit_bit_pos,
7688 /* *** WRITE PORT REGISTER *** */
7689 struct cmd_write_reg_result {
7690 cmdline_fixed_string_t write;
7691 cmdline_fixed_string_t reg;
7698 cmd_write_reg_parsed(void *parsed_result,
7699 __attribute__((unused)) struct cmdline *cl,
7700 __attribute__((unused)) void *data)
7702 struct cmd_write_reg_result *res = parsed_result;
7703 port_reg_set(res->port_id, res->reg_off, res->value);
7706 cmdline_parse_token_string_t cmd_write_reg_write =
7707 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7708 cmdline_parse_token_string_t cmd_write_reg_reg =
7709 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7710 cmdline_parse_token_num_t cmd_write_reg_port_id =
7711 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7712 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7713 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7714 cmdline_parse_token_num_t cmd_write_reg_value =
7715 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7717 cmdline_parse_inst_t cmd_write_reg = {
7718 .f = cmd_write_reg_parsed,
7720 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7722 (void *)&cmd_write_reg_write,
7723 (void *)&cmd_write_reg_reg,
7724 (void *)&cmd_write_reg_port_id,
7725 (void *)&cmd_write_reg_reg_off,
7726 (void *)&cmd_write_reg_value,
7731 /* *** WRITE PORT REGISTER BIT FIELD *** */
7732 struct cmd_write_reg_bit_field_result {
7733 cmdline_fixed_string_t write;
7734 cmdline_fixed_string_t regfield;
7743 cmd_write_reg_bit_field_parsed(void *parsed_result,
7744 __attribute__((unused)) struct cmdline *cl,
7745 __attribute__((unused)) void *data)
7747 struct cmd_write_reg_bit_field_result *res = parsed_result;
7748 port_reg_bit_field_set(res->port_id, res->reg_off,
7749 res->bit1_pos, res->bit2_pos, res->value);
7752 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7753 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7755 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7756 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7757 regfield, "regfield");
7758 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7759 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7761 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7762 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7764 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7765 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7767 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7768 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7770 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7771 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7774 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7775 .f = cmd_write_reg_bit_field_parsed,
7777 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7779 "Set register bit field between bit_x and bit_y included",
7781 (void *)&cmd_write_reg_bit_field_write,
7782 (void *)&cmd_write_reg_bit_field_regfield,
7783 (void *)&cmd_write_reg_bit_field_port_id,
7784 (void *)&cmd_write_reg_bit_field_reg_off,
7785 (void *)&cmd_write_reg_bit_field_bit1_pos,
7786 (void *)&cmd_write_reg_bit_field_bit2_pos,
7787 (void *)&cmd_write_reg_bit_field_value,
7792 /* *** WRITE PORT REGISTER BIT *** */
7793 struct cmd_write_reg_bit_result {
7794 cmdline_fixed_string_t write;
7795 cmdline_fixed_string_t regbit;
7803 cmd_write_reg_bit_parsed(void *parsed_result,
7804 __attribute__((unused)) struct cmdline *cl,
7805 __attribute__((unused)) void *data)
7807 struct cmd_write_reg_bit_result *res = parsed_result;
7808 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7811 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7812 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7814 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7815 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7817 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7818 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7819 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7820 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7821 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7822 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7823 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7824 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7826 cmdline_parse_inst_t cmd_write_reg_bit = {
7827 .f = cmd_write_reg_bit_parsed,
7829 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7832 (void *)&cmd_write_reg_bit_write,
7833 (void *)&cmd_write_reg_bit_regbit,
7834 (void *)&cmd_write_reg_bit_port_id,
7835 (void *)&cmd_write_reg_bit_reg_off,
7836 (void *)&cmd_write_reg_bit_bit_pos,
7837 (void *)&cmd_write_reg_bit_value,
7842 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7843 struct cmd_read_rxd_txd_result {
7844 cmdline_fixed_string_t read;
7845 cmdline_fixed_string_t rxd_txd;
7852 cmd_read_rxd_txd_parsed(void *parsed_result,
7853 __attribute__((unused)) struct cmdline *cl,
7854 __attribute__((unused)) void *data)
7856 struct cmd_read_rxd_txd_result *res = parsed_result;
7858 if (!strcmp(res->rxd_txd, "rxd"))
7859 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7860 else if (!strcmp(res->rxd_txd, "txd"))
7861 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7864 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7865 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7866 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7867 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7869 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7870 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7871 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7872 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7873 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7874 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7876 cmdline_parse_inst_t cmd_read_rxd_txd = {
7877 .f = cmd_read_rxd_txd_parsed,
7879 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7881 (void *)&cmd_read_rxd_txd_read,
7882 (void *)&cmd_read_rxd_txd_rxd_txd,
7883 (void *)&cmd_read_rxd_txd_port_id,
7884 (void *)&cmd_read_rxd_txd_queue_id,
7885 (void *)&cmd_read_rxd_txd_desc_id,
7891 struct cmd_quit_result {
7892 cmdline_fixed_string_t quit;
7895 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7897 __attribute__((unused)) void *data)
7902 cmdline_parse_token_string_t cmd_quit_quit =
7903 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7905 cmdline_parse_inst_t cmd_quit = {
7906 .f = cmd_quit_parsed,
7908 .help_str = "quit: Exit application",
7910 (void *)&cmd_quit_quit,
7915 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7916 struct cmd_mac_addr_result {
7917 cmdline_fixed_string_t mac_addr_cmd;
7918 cmdline_fixed_string_t what;
7920 struct rte_ether_addr address;
7923 static void cmd_mac_addr_parsed(void *parsed_result,
7924 __attribute__((unused)) struct cmdline *cl,
7925 __attribute__((unused)) void *data)
7927 struct cmd_mac_addr_result *res = parsed_result;
7930 if (strcmp(res->what, "add") == 0)
7931 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7932 else if (strcmp(res->what, "set") == 0)
7933 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7936 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7938 /* check the return value and print it if is < 0 */
7940 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7944 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7945 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7947 cmdline_parse_token_string_t cmd_mac_addr_what =
7948 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7950 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7951 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7953 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7954 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7956 cmdline_parse_inst_t cmd_mac_addr = {
7957 .f = cmd_mac_addr_parsed,
7959 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7960 "Add/Remove/Set MAC address on port_id",
7962 (void *)&cmd_mac_addr_cmd,
7963 (void *)&cmd_mac_addr_what,
7964 (void *)&cmd_mac_addr_portnum,
7965 (void *)&cmd_mac_addr_addr,
7970 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7971 struct cmd_eth_peer_result {
7972 cmdline_fixed_string_t set;
7973 cmdline_fixed_string_t eth_peer;
7975 cmdline_fixed_string_t peer_addr;
7978 static void cmd_set_eth_peer_parsed(void *parsed_result,
7979 __attribute__((unused)) struct cmdline *cl,
7980 __attribute__((unused)) void *data)
7982 struct cmd_eth_peer_result *res = parsed_result;
7984 if (test_done == 0) {
7985 printf("Please stop forwarding first\n");
7988 if (!strcmp(res->eth_peer, "eth-peer")) {
7989 set_fwd_eth_peer(res->port_id, res->peer_addr);
7993 cmdline_parse_token_string_t cmd_eth_peer_set =
7994 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7995 cmdline_parse_token_string_t cmd_eth_peer =
7996 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7997 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7998 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7999 cmdline_parse_token_string_t cmd_eth_peer_addr =
8000 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8002 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8003 .f = cmd_set_eth_peer_parsed,
8005 .help_str = "set eth-peer <port_id> <peer_mac>",
8007 (void *)&cmd_eth_peer_set,
8008 (void *)&cmd_eth_peer,
8009 (void *)&cmd_eth_peer_port_id,
8010 (void *)&cmd_eth_peer_addr,
8015 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8016 struct cmd_set_qmap_result {
8017 cmdline_fixed_string_t set;
8018 cmdline_fixed_string_t qmap;
8019 cmdline_fixed_string_t what;
8026 cmd_set_qmap_parsed(void *parsed_result,
8027 __attribute__((unused)) struct cmdline *cl,
8028 __attribute__((unused)) void *data)
8030 struct cmd_set_qmap_result *res = parsed_result;
8031 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8033 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8036 cmdline_parse_token_string_t cmd_setqmap_set =
8037 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8039 cmdline_parse_token_string_t cmd_setqmap_qmap =
8040 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8042 cmdline_parse_token_string_t cmd_setqmap_what =
8043 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8045 cmdline_parse_token_num_t cmd_setqmap_portid =
8046 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8048 cmdline_parse_token_num_t cmd_setqmap_queueid =
8049 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8051 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8052 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8055 cmdline_parse_inst_t cmd_set_qmap = {
8056 .f = cmd_set_qmap_parsed,
8058 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8059 "Set statistics mapping value on tx|rx queue_id of port_id",
8061 (void *)&cmd_setqmap_set,
8062 (void *)&cmd_setqmap_qmap,
8063 (void *)&cmd_setqmap_what,
8064 (void *)&cmd_setqmap_portid,
8065 (void *)&cmd_setqmap_queueid,
8066 (void *)&cmd_setqmap_mapvalue,
8071 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8072 struct cmd_set_xstats_hide_zero_result {
8073 cmdline_fixed_string_t keyword;
8074 cmdline_fixed_string_t name;
8075 cmdline_fixed_string_t on_off;
8079 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8080 __attribute__((unused)) struct cmdline *cl,
8081 __attribute__((unused)) void *data)
8083 struct cmd_set_xstats_hide_zero_result *res;
8084 uint16_t on_off = 0;
8086 res = parsed_result;
8087 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8088 set_xstats_hide_zero(on_off);
8091 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8092 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8094 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8095 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8096 name, "xstats-hide-zero");
8097 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8098 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8101 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8102 .f = cmd_set_xstats_hide_zero_parsed,
8104 .help_str = "set xstats-hide-zero on|off",
8106 (void *)&cmd_set_xstats_hide_zero_keyword,
8107 (void *)&cmd_set_xstats_hide_zero_name,
8108 (void *)&cmd_set_xstats_hide_zero_on_off,
8113 /* *** CONFIGURE UNICAST HASH TABLE *** */
8114 struct cmd_set_uc_hash_table {
8115 cmdline_fixed_string_t set;
8116 cmdline_fixed_string_t port;
8118 cmdline_fixed_string_t what;
8119 struct rte_ether_addr address;
8120 cmdline_fixed_string_t mode;
8124 cmd_set_uc_hash_parsed(void *parsed_result,
8125 __attribute__((unused)) struct cmdline *cl,
8126 __attribute__((unused)) void *data)
8129 struct cmd_set_uc_hash_table *res = parsed_result;
8131 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8133 if (strcmp(res->what, "uta") == 0)
8134 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8135 &res->address,(uint8_t)is_on);
8137 printf("bad unicast hash table parameter, return code = %d \n", ret);
8141 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8142 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8144 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8145 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8147 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8148 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8150 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8151 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8153 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8154 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8156 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8157 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8160 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8161 .f = cmd_set_uc_hash_parsed,
8163 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8165 (void *)&cmd_set_uc_hash_set,
8166 (void *)&cmd_set_uc_hash_port,
8167 (void *)&cmd_set_uc_hash_portid,
8168 (void *)&cmd_set_uc_hash_what,
8169 (void *)&cmd_set_uc_hash_mac,
8170 (void *)&cmd_set_uc_hash_mode,
8175 struct cmd_set_uc_all_hash_table {
8176 cmdline_fixed_string_t set;
8177 cmdline_fixed_string_t port;
8179 cmdline_fixed_string_t what;
8180 cmdline_fixed_string_t value;
8181 cmdline_fixed_string_t mode;
8185 cmd_set_uc_all_hash_parsed(void *parsed_result,
8186 __attribute__((unused)) struct cmdline *cl,
8187 __attribute__((unused)) void *data)
8190 struct cmd_set_uc_all_hash_table *res = parsed_result;
8192 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8194 if ((strcmp(res->what, "uta") == 0) &&
8195 (strcmp(res->value, "all") == 0))
8196 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8198 printf("bad unicast hash table parameter,"
8199 "return code = %d \n", ret);
8202 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8203 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8205 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8206 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8208 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8209 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8211 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8212 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8214 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8215 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8217 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8218 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8221 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8222 .f = cmd_set_uc_all_hash_parsed,
8224 .help_str = "set port <port_id> uta all on|off",
8226 (void *)&cmd_set_uc_all_hash_set,
8227 (void *)&cmd_set_uc_all_hash_port,
8228 (void *)&cmd_set_uc_all_hash_portid,
8229 (void *)&cmd_set_uc_all_hash_what,
8230 (void *)&cmd_set_uc_all_hash_value,
8231 (void *)&cmd_set_uc_all_hash_mode,
8236 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8237 struct cmd_set_vf_macvlan_filter {
8238 cmdline_fixed_string_t set;
8239 cmdline_fixed_string_t port;
8241 cmdline_fixed_string_t vf;
8243 struct rte_ether_addr address;
8244 cmdline_fixed_string_t filter_type;
8245 cmdline_fixed_string_t mode;
8249 cmd_set_vf_macvlan_parsed(void *parsed_result,
8250 __attribute__((unused)) struct cmdline *cl,
8251 __attribute__((unused)) void *data)
8254 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8255 struct rte_eth_mac_filter filter;
8257 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8259 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8261 /* set VF MAC filter */
8265 filter.dst_id = res->vf_id;
8267 if (!strcmp(res->filter_type, "exact-mac"))
8268 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8269 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8270 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8271 else if (!strcmp(res->filter_type, "hashmac"))
8272 filter.filter_type = RTE_MAC_HASH_MATCH;
8273 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8274 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8276 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8279 ret = rte_eth_dev_filter_ctrl(res->port_id,
8280 RTE_ETH_FILTER_MACVLAN,
8284 ret = rte_eth_dev_filter_ctrl(res->port_id,
8285 RTE_ETH_FILTER_MACVLAN,
8286 RTE_ETH_FILTER_DELETE,
8290 printf("bad set MAC hash parameter, return code = %d\n", ret);
8294 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8295 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8297 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8298 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8300 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8301 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8303 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8304 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8306 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8307 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8309 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8310 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8312 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8313 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8314 filter_type, "exact-mac#exact-mac-vlan"
8315 "#hashmac#hashmac-vlan");
8316 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8317 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8320 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8321 .f = cmd_set_vf_macvlan_parsed,
8323 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8324 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8325 "Exact match rule: exact match of MAC or MAC and VLAN; "
8326 "hash match rule: hash match of MAC and exact match of VLAN",
8328 (void *)&cmd_set_vf_macvlan_set,
8329 (void *)&cmd_set_vf_macvlan_port,
8330 (void *)&cmd_set_vf_macvlan_portid,
8331 (void *)&cmd_set_vf_macvlan_vf,
8332 (void *)&cmd_set_vf_macvlan_vf_id,
8333 (void *)&cmd_set_vf_macvlan_mac,
8334 (void *)&cmd_set_vf_macvlan_filter_type,
8335 (void *)&cmd_set_vf_macvlan_mode,
8340 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8341 struct cmd_set_vf_traffic {
8342 cmdline_fixed_string_t set;
8343 cmdline_fixed_string_t port;
8345 cmdline_fixed_string_t vf;
8347 cmdline_fixed_string_t what;
8348 cmdline_fixed_string_t mode;
8352 cmd_set_vf_traffic_parsed(void *parsed_result,
8353 __attribute__((unused)) struct cmdline *cl,
8354 __attribute__((unused)) void *data)
8356 struct cmd_set_vf_traffic *res = parsed_result;
8357 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8358 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8360 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8363 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8364 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8366 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8367 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8369 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8370 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8372 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8373 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8375 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8376 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8378 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8379 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8381 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8382 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8385 cmdline_parse_inst_t cmd_set_vf_traffic = {
8386 .f = cmd_set_vf_traffic_parsed,
8388 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8390 (void *)&cmd_setvf_traffic_set,
8391 (void *)&cmd_setvf_traffic_port,
8392 (void *)&cmd_setvf_traffic_portid,
8393 (void *)&cmd_setvf_traffic_vf,
8394 (void *)&cmd_setvf_traffic_vfid,
8395 (void *)&cmd_setvf_traffic_what,
8396 (void *)&cmd_setvf_traffic_mode,
8401 /* *** CONFIGURE VF RECEIVE MODE *** */
8402 struct cmd_set_vf_rxmode {
8403 cmdline_fixed_string_t set;
8404 cmdline_fixed_string_t port;
8406 cmdline_fixed_string_t vf;
8408 cmdline_fixed_string_t what;
8409 cmdline_fixed_string_t mode;
8410 cmdline_fixed_string_t on;
8414 cmd_set_vf_rxmode_parsed(void *parsed_result,
8415 __attribute__((unused)) struct cmdline *cl,
8416 __attribute__((unused)) void *data)
8419 uint16_t rx_mode = 0;
8420 struct cmd_set_vf_rxmode *res = parsed_result;
8422 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8423 if (!strcmp(res->what,"rxmode")) {
8424 if (!strcmp(res->mode, "AUPE"))
8425 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
8426 else if (!strcmp(res->mode, "ROPE"))
8427 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
8428 else if (!strcmp(res->mode, "BAM"))
8429 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
8430 else if (!strncmp(res->mode, "MPE",3))
8431 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
8434 RTE_SET_USED(is_on);
8436 #ifdef RTE_LIBRTE_IXGBE_PMD
8437 if (ret == -ENOTSUP)
8438 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8439 rx_mode, (uint8_t)is_on);
8441 #ifdef RTE_LIBRTE_BNXT_PMD
8442 if (ret == -ENOTSUP)
8443 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8444 rx_mode, (uint8_t)is_on);
8447 printf("bad VF receive mode parameter, return code = %d \n",
8451 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8452 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8454 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8455 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8457 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8458 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8460 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8461 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8463 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8464 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8466 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8467 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8469 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8470 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8471 mode, "AUPE#ROPE#BAM#MPE");
8472 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8473 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8476 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8477 .f = cmd_set_vf_rxmode_parsed,
8479 .help_str = "set port <port_id> vf <vf_id> rxmode "
8480 "AUPE|ROPE|BAM|MPE on|off",
8482 (void *)&cmd_set_vf_rxmode_set,
8483 (void *)&cmd_set_vf_rxmode_port,
8484 (void *)&cmd_set_vf_rxmode_portid,
8485 (void *)&cmd_set_vf_rxmode_vf,
8486 (void *)&cmd_set_vf_rxmode_vfid,
8487 (void *)&cmd_set_vf_rxmode_what,
8488 (void *)&cmd_set_vf_rxmode_mode,
8489 (void *)&cmd_set_vf_rxmode_on,
8494 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8495 struct cmd_vf_mac_addr_result {
8496 cmdline_fixed_string_t mac_addr_cmd;
8497 cmdline_fixed_string_t what;
8498 cmdline_fixed_string_t port;
8500 cmdline_fixed_string_t vf;
8502 struct rte_ether_addr address;
8505 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8506 __attribute__((unused)) struct cmdline *cl,
8507 __attribute__((unused)) void *data)
8509 struct cmd_vf_mac_addr_result *res = parsed_result;
8512 if (strcmp(res->what, "add") != 0)
8515 #ifdef RTE_LIBRTE_I40E_PMD
8516 if (ret == -ENOTSUP)
8517 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8520 #ifdef RTE_LIBRTE_BNXT_PMD
8521 if (ret == -ENOTSUP)
8522 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8527 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8531 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8532 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8533 mac_addr_cmd,"mac_addr");
8534 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8535 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8537 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8538 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8540 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8541 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8543 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8544 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8546 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8547 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8549 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8550 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8553 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8554 .f = cmd_vf_mac_addr_parsed,
8556 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8557 "Add MAC address filtering for a VF on port_id",
8559 (void *)&cmd_vf_mac_addr_cmd,
8560 (void *)&cmd_vf_mac_addr_what,
8561 (void *)&cmd_vf_mac_addr_port,
8562 (void *)&cmd_vf_mac_addr_portnum,
8563 (void *)&cmd_vf_mac_addr_vf,
8564 (void *)&cmd_vf_mac_addr_vfnum,
8565 (void *)&cmd_vf_mac_addr_addr,
8570 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8571 struct cmd_vf_rx_vlan_filter {
8572 cmdline_fixed_string_t rx_vlan;
8573 cmdline_fixed_string_t what;
8575 cmdline_fixed_string_t port;
8577 cmdline_fixed_string_t vf;
8582 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8583 __attribute__((unused)) struct cmdline *cl,
8584 __attribute__((unused)) void *data)
8586 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8589 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8591 #ifdef RTE_LIBRTE_IXGBE_PMD
8592 if (ret == -ENOTSUP)
8593 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8594 res->vlan_id, res->vf_mask, is_add);
8596 #ifdef RTE_LIBRTE_I40E_PMD
8597 if (ret == -ENOTSUP)
8598 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8599 res->vlan_id, res->vf_mask, is_add);
8601 #ifdef RTE_LIBRTE_BNXT_PMD
8602 if (ret == -ENOTSUP)
8603 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8604 res->vlan_id, res->vf_mask, is_add);
8611 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8612 res->vlan_id, res->vf_mask);
8615 printf("invalid port_id %d\n", res->port_id);
8618 printf("function not implemented or supported\n");
8621 printf("programming error: (%s)\n", strerror(-ret));
8625 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8626 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8627 rx_vlan, "rx_vlan");
8628 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8629 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8631 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8632 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8634 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8635 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8637 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8638 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8640 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8641 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8643 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8644 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8647 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8648 .f = cmd_vf_rx_vlan_filter_parsed,
8650 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8651 "(vf_mask = hexadecimal VF mask)",
8653 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8654 (void *)&cmd_vf_rx_vlan_filter_what,
8655 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8656 (void *)&cmd_vf_rx_vlan_filter_port,
8657 (void *)&cmd_vf_rx_vlan_filter_portid,
8658 (void *)&cmd_vf_rx_vlan_filter_vf,
8659 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8664 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8665 struct cmd_queue_rate_limit_result {
8666 cmdline_fixed_string_t set;
8667 cmdline_fixed_string_t port;
8669 cmdline_fixed_string_t queue;
8671 cmdline_fixed_string_t rate;
8675 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8676 __attribute__((unused)) struct cmdline *cl,
8677 __attribute__((unused)) void *data)
8679 struct cmd_queue_rate_limit_result *res = parsed_result;
8682 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8683 && (strcmp(res->queue, "queue") == 0)
8684 && (strcmp(res->rate, "rate") == 0))
8685 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8688 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8692 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8693 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8695 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8696 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8698 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8699 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8701 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8702 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8704 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8705 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8707 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8708 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8710 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8711 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8714 cmdline_parse_inst_t cmd_queue_rate_limit = {
8715 .f = cmd_queue_rate_limit_parsed,
8717 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8718 "Set rate limit for a queue on port_id",
8720 (void *)&cmd_queue_rate_limit_set,
8721 (void *)&cmd_queue_rate_limit_port,
8722 (void *)&cmd_queue_rate_limit_portnum,
8723 (void *)&cmd_queue_rate_limit_queue,
8724 (void *)&cmd_queue_rate_limit_queuenum,
8725 (void *)&cmd_queue_rate_limit_rate,
8726 (void *)&cmd_queue_rate_limit_ratenum,
8731 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8732 struct cmd_vf_rate_limit_result {
8733 cmdline_fixed_string_t set;
8734 cmdline_fixed_string_t port;
8736 cmdline_fixed_string_t vf;
8738 cmdline_fixed_string_t rate;
8740 cmdline_fixed_string_t q_msk;
8744 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8745 __attribute__((unused)) struct cmdline *cl,
8746 __attribute__((unused)) void *data)
8748 struct cmd_vf_rate_limit_result *res = parsed_result;
8751 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8752 && (strcmp(res->vf, "vf") == 0)
8753 && (strcmp(res->rate, "rate") == 0)
8754 && (strcmp(res->q_msk, "queue_mask") == 0))
8755 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8756 res->rate_num, res->q_msk_val);
8758 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8762 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8763 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8765 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8766 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8768 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8769 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8771 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8772 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8774 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8775 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8777 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8778 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8780 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8781 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8783 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8784 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8785 q_msk, "queue_mask");
8786 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8787 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8790 cmdline_parse_inst_t cmd_vf_rate_limit = {
8791 .f = cmd_vf_rate_limit_parsed,
8793 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8794 "queue_mask <queue_mask_value>: "
8795 "Set rate limit for queues of VF on port_id",
8797 (void *)&cmd_vf_rate_limit_set,
8798 (void *)&cmd_vf_rate_limit_port,
8799 (void *)&cmd_vf_rate_limit_portnum,
8800 (void *)&cmd_vf_rate_limit_vf,
8801 (void *)&cmd_vf_rate_limit_vfnum,
8802 (void *)&cmd_vf_rate_limit_rate,
8803 (void *)&cmd_vf_rate_limit_ratenum,
8804 (void *)&cmd_vf_rate_limit_q_msk,
8805 (void *)&cmd_vf_rate_limit_q_msk_val,
8810 /* *** ADD TUNNEL FILTER OF A PORT *** */
8811 struct cmd_tunnel_filter_result {
8812 cmdline_fixed_string_t cmd;
8813 cmdline_fixed_string_t what;
8815 struct rte_ether_addr outer_mac;
8816 struct rte_ether_addr inner_mac;
8817 cmdline_ipaddr_t ip_value;
8818 uint16_t inner_vlan;
8819 cmdline_fixed_string_t tunnel_type;
8820 cmdline_fixed_string_t filter_type;
8826 cmd_tunnel_filter_parsed(void *parsed_result,
8827 __attribute__((unused)) struct cmdline *cl,
8828 __attribute__((unused)) void *data)
8830 struct cmd_tunnel_filter_result *res = parsed_result;
8831 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8834 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8836 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8837 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8838 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8840 if (res->ip_value.family == AF_INET) {
8841 tunnel_filter_conf.ip_addr.ipv4_addr =
8842 res->ip_value.addr.ipv4.s_addr;
8843 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8845 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8846 &(res->ip_value.addr.ipv6),
8847 sizeof(struct in6_addr));
8848 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8851 if (!strcmp(res->filter_type, "imac-ivlan"))
8852 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8853 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8854 tunnel_filter_conf.filter_type =
8855 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8856 else if (!strcmp(res->filter_type, "imac-tenid"))
8857 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8858 else if (!strcmp(res->filter_type, "imac"))
8859 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8860 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8861 tunnel_filter_conf.filter_type =
8862 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8863 else if (!strcmp(res->filter_type, "oip"))
8864 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8865 else if (!strcmp(res->filter_type, "iip"))
8866 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8868 printf("The filter type is not supported");
8872 if (!strcmp(res->tunnel_type, "vxlan"))
8873 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8874 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
8875 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
8876 else if (!strcmp(res->tunnel_type, "nvgre"))
8877 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8878 else if (!strcmp(res->tunnel_type, "ipingre"))
8879 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8881 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8885 tunnel_filter_conf.tenant_id = res->tenant_id;
8886 tunnel_filter_conf.queue_id = res->queue_num;
8887 if (!strcmp(res->what, "add"))
8888 ret = rte_eth_dev_filter_ctrl(res->port_id,
8889 RTE_ETH_FILTER_TUNNEL,
8891 &tunnel_filter_conf);
8893 ret = rte_eth_dev_filter_ctrl(res->port_id,
8894 RTE_ETH_FILTER_TUNNEL,
8895 RTE_ETH_FILTER_DELETE,
8896 &tunnel_filter_conf);
8898 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8902 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8903 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8904 cmd, "tunnel_filter");
8905 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8906 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8908 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8909 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8911 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8912 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8914 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8915 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8917 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8918 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8919 inner_vlan, UINT16);
8920 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8921 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8923 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8924 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8925 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
8927 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8928 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8929 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8930 "imac#omac-imac-tenid");
8931 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8932 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8934 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8935 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8938 cmdline_parse_inst_t cmd_tunnel_filter = {
8939 .f = cmd_tunnel_filter_parsed,
8941 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8942 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8943 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8944 "<queue_id>: Add/Rm tunnel filter of a port",
8946 (void *)&cmd_tunnel_filter_cmd,
8947 (void *)&cmd_tunnel_filter_what,
8948 (void *)&cmd_tunnel_filter_port_id,
8949 (void *)&cmd_tunnel_filter_outer_mac,
8950 (void *)&cmd_tunnel_filter_inner_mac,
8951 (void *)&cmd_tunnel_filter_ip_value,
8952 (void *)&cmd_tunnel_filter_innner_vlan,
8953 (void *)&cmd_tunnel_filter_tunnel_type,
8954 (void *)&cmd_tunnel_filter_filter_type,
8955 (void *)&cmd_tunnel_filter_tenant_id,
8956 (void *)&cmd_tunnel_filter_queue_num,
8961 /* *** CONFIGURE TUNNEL UDP PORT *** */
8962 struct cmd_tunnel_udp_config {
8963 cmdline_fixed_string_t cmd;
8964 cmdline_fixed_string_t what;
8970 cmd_tunnel_udp_config_parsed(void *parsed_result,
8971 __attribute__((unused)) struct cmdline *cl,
8972 __attribute__((unused)) void *data)
8974 struct cmd_tunnel_udp_config *res = parsed_result;
8975 struct rte_eth_udp_tunnel tunnel_udp;
8978 tunnel_udp.udp_port = res->udp_port;
8980 if (!strcmp(res->cmd, "rx_vxlan_port"))
8981 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8983 if (!strcmp(res->what, "add"))
8984 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8987 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8991 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8994 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8995 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8996 cmd, "rx_vxlan_port");
8997 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8998 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9000 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9001 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9003 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9004 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9007 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9008 .f = cmd_tunnel_udp_config_parsed,
9010 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9011 "Add/Remove a tunneling UDP port filter",
9013 (void *)&cmd_tunnel_udp_config_cmd,
9014 (void *)&cmd_tunnel_udp_config_what,
9015 (void *)&cmd_tunnel_udp_config_udp_port,
9016 (void *)&cmd_tunnel_udp_config_port_id,
9021 struct cmd_config_tunnel_udp_port {
9022 cmdline_fixed_string_t port;
9023 cmdline_fixed_string_t config;
9025 cmdline_fixed_string_t udp_tunnel_port;
9026 cmdline_fixed_string_t action;
9027 cmdline_fixed_string_t tunnel_type;
9032 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9033 __attribute__((unused)) struct cmdline *cl,
9034 __attribute__((unused)) void *data)
9036 struct cmd_config_tunnel_udp_port *res = parsed_result;
9037 struct rte_eth_udp_tunnel tunnel_udp;
9040 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9043 tunnel_udp.udp_port = res->udp_port;
9045 if (!strcmp(res->tunnel_type, "vxlan")) {
9046 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9047 } else if (!strcmp(res->tunnel_type, "geneve")) {
9048 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9049 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9050 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9052 printf("Invalid tunnel type\n");
9056 if (!strcmp(res->action, "add"))
9057 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9060 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9064 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9067 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9068 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9070 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9071 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9073 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9074 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9076 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9077 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9080 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9081 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9083 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9084 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9085 "vxlan#geneve#vxlan-gpe");
9086 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9087 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9090 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9091 .f = cmd_cfg_tunnel_udp_port_parsed,
9093 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9095 (void *)&cmd_config_tunnel_udp_port_port,
9096 (void *)&cmd_config_tunnel_udp_port_config,
9097 (void *)&cmd_config_tunnel_udp_port_port_id,
9098 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9099 (void *)&cmd_config_tunnel_udp_port_action,
9100 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9101 (void *)&cmd_config_tunnel_udp_port_value,
9106 /* *** GLOBAL CONFIG *** */
9107 struct cmd_global_config_result {
9108 cmdline_fixed_string_t cmd;
9110 cmdline_fixed_string_t cfg_type;
9115 cmd_global_config_parsed(void *parsed_result,
9116 __attribute__((unused)) struct cmdline *cl,
9117 __attribute__((unused)) void *data)
9119 struct cmd_global_config_result *res = parsed_result;
9120 struct rte_eth_global_cfg conf;
9123 memset(&conf, 0, sizeof(conf));
9124 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9125 conf.cfg.gre_key_len = res->len;
9126 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9127 RTE_ETH_FILTER_SET, &conf);
9129 printf("Global config error\n");
9132 cmdline_parse_token_string_t cmd_global_config_cmd =
9133 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9135 cmdline_parse_token_num_t cmd_global_config_port_id =
9136 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9138 cmdline_parse_token_string_t cmd_global_config_type =
9139 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9140 cfg_type, "gre-key-len");
9141 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9142 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9145 cmdline_parse_inst_t cmd_global_config = {
9146 .f = cmd_global_config_parsed,
9147 .data = (void *)NULL,
9148 .help_str = "global_config <port_id> gre-key-len <key_len>",
9150 (void *)&cmd_global_config_cmd,
9151 (void *)&cmd_global_config_port_id,
9152 (void *)&cmd_global_config_type,
9153 (void *)&cmd_global_config_gre_key_len,
9158 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9159 struct cmd_set_mirror_mask_result {
9160 cmdline_fixed_string_t set;
9161 cmdline_fixed_string_t port;
9163 cmdline_fixed_string_t mirror;
9165 cmdline_fixed_string_t what;
9166 cmdline_fixed_string_t value;
9167 cmdline_fixed_string_t dstpool;
9169 cmdline_fixed_string_t on;
9172 cmdline_parse_token_string_t cmd_mirror_mask_set =
9173 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9175 cmdline_parse_token_string_t cmd_mirror_mask_port =
9176 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9178 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9179 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9181 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9182 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9183 mirror, "mirror-rule");
9184 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9185 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9187 cmdline_parse_token_string_t cmd_mirror_mask_what =
9188 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9189 what, "pool-mirror-up#pool-mirror-down"
9191 cmdline_parse_token_string_t cmd_mirror_mask_value =
9192 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9194 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9195 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9196 dstpool, "dst-pool");
9197 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9198 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9200 cmdline_parse_token_string_t cmd_mirror_mask_on =
9201 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9205 cmd_set_mirror_mask_parsed(void *parsed_result,
9206 __attribute__((unused)) struct cmdline *cl,
9207 __attribute__((unused)) void *data)
9210 struct cmd_set_mirror_mask_result *res = parsed_result;
9211 struct rte_eth_mirror_conf mr_conf;
9213 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9215 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9217 mr_conf.dst_pool = res->dstpool_id;
9219 if (!strcmp(res->what, "pool-mirror-up")) {
9220 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9221 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9222 } else if (!strcmp(res->what, "pool-mirror-down")) {
9223 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9224 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9225 } else if (!strcmp(res->what, "vlan-mirror")) {
9226 mr_conf.rule_type = ETH_MIRROR_VLAN;
9227 nb_item = parse_item_list(res->value, "vlan",
9228 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9232 for (i = 0; i < nb_item; i++) {
9233 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9234 printf("Invalid vlan_id: must be < 4096\n");
9238 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9239 mr_conf.vlan.vlan_mask |= 1ULL << i;
9243 if (!strcmp(res->on, "on"))
9244 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9247 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9250 printf("mirror rule add error: (%s)\n", strerror(-ret));
9253 cmdline_parse_inst_t cmd_set_mirror_mask = {
9254 .f = cmd_set_mirror_mask_parsed,
9256 .help_str = "set port <port_id> mirror-rule <rule_id> "
9257 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9258 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9260 (void *)&cmd_mirror_mask_set,
9261 (void *)&cmd_mirror_mask_port,
9262 (void *)&cmd_mirror_mask_portid,
9263 (void *)&cmd_mirror_mask_mirror,
9264 (void *)&cmd_mirror_mask_ruleid,
9265 (void *)&cmd_mirror_mask_what,
9266 (void *)&cmd_mirror_mask_value,
9267 (void *)&cmd_mirror_mask_dstpool,
9268 (void *)&cmd_mirror_mask_poolid,
9269 (void *)&cmd_mirror_mask_on,
9274 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9275 struct cmd_set_mirror_link_result {
9276 cmdline_fixed_string_t set;
9277 cmdline_fixed_string_t port;
9279 cmdline_fixed_string_t mirror;
9281 cmdline_fixed_string_t what;
9282 cmdline_fixed_string_t dstpool;
9284 cmdline_fixed_string_t on;
9287 cmdline_parse_token_string_t cmd_mirror_link_set =
9288 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9290 cmdline_parse_token_string_t cmd_mirror_link_port =
9291 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9293 cmdline_parse_token_num_t cmd_mirror_link_portid =
9294 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9296 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9297 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9298 mirror, "mirror-rule");
9299 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9300 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9302 cmdline_parse_token_string_t cmd_mirror_link_what =
9303 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9304 what, "uplink-mirror#downlink-mirror");
9305 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9306 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9307 dstpool, "dst-pool");
9308 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9309 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9311 cmdline_parse_token_string_t cmd_mirror_link_on =
9312 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9316 cmd_set_mirror_link_parsed(void *parsed_result,
9317 __attribute__((unused)) struct cmdline *cl,
9318 __attribute__((unused)) void *data)
9321 struct cmd_set_mirror_link_result *res = parsed_result;
9322 struct rte_eth_mirror_conf mr_conf;
9324 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9325 if (!strcmp(res->what, "uplink-mirror"))
9326 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9328 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9330 mr_conf.dst_pool = res->dstpool_id;
9332 if (!strcmp(res->on, "on"))
9333 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9336 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9339 /* check the return value and print it if is < 0 */
9341 printf("mirror rule add error: (%s)\n", strerror(-ret));
9345 cmdline_parse_inst_t cmd_set_mirror_link = {
9346 .f = cmd_set_mirror_link_parsed,
9348 .help_str = "set port <port_id> mirror-rule <rule_id> "
9349 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9351 (void *)&cmd_mirror_link_set,
9352 (void *)&cmd_mirror_link_port,
9353 (void *)&cmd_mirror_link_portid,
9354 (void *)&cmd_mirror_link_mirror,
9355 (void *)&cmd_mirror_link_ruleid,
9356 (void *)&cmd_mirror_link_what,
9357 (void *)&cmd_mirror_link_dstpool,
9358 (void *)&cmd_mirror_link_poolid,
9359 (void *)&cmd_mirror_link_on,
9364 /* *** RESET VM MIRROR RULE *** */
9365 struct cmd_rm_mirror_rule_result {
9366 cmdline_fixed_string_t reset;
9367 cmdline_fixed_string_t port;
9369 cmdline_fixed_string_t mirror;
9373 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9374 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9376 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9377 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9379 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9380 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9382 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9383 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9384 mirror, "mirror-rule");
9385 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9386 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9390 cmd_reset_mirror_rule_parsed(void *parsed_result,
9391 __attribute__((unused)) struct cmdline *cl,
9392 __attribute__((unused)) void *data)
9395 struct cmd_set_mirror_link_result *res = parsed_result;
9397 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9399 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9402 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9403 .f = cmd_reset_mirror_rule_parsed,
9405 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9407 (void *)&cmd_rm_mirror_rule_reset,
9408 (void *)&cmd_rm_mirror_rule_port,
9409 (void *)&cmd_rm_mirror_rule_portid,
9410 (void *)&cmd_rm_mirror_rule_mirror,
9411 (void *)&cmd_rm_mirror_rule_ruleid,
9416 /* ******************************************************************************** */
9418 struct cmd_dump_result {
9419 cmdline_fixed_string_t dump;
9423 dump_struct_sizes(void)
9425 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9426 DUMP_SIZE(struct rte_mbuf);
9427 DUMP_SIZE(struct rte_mempool);
9428 DUMP_SIZE(struct rte_ring);
9432 static void cmd_dump_parsed(void *parsed_result,
9433 __attribute__((unused)) struct cmdline *cl,
9434 __attribute__((unused)) void *data)
9436 struct cmd_dump_result *res = parsed_result;
9438 if (!strcmp(res->dump, "dump_physmem"))
9439 rte_dump_physmem_layout(stdout);
9440 else if (!strcmp(res->dump, "dump_memzone"))
9441 rte_memzone_dump(stdout);
9442 else if (!strcmp(res->dump, "dump_struct_sizes"))
9443 dump_struct_sizes();
9444 else if (!strcmp(res->dump, "dump_ring"))
9445 rte_ring_list_dump(stdout);
9446 else if (!strcmp(res->dump, "dump_mempool"))
9447 rte_mempool_list_dump(stdout);
9448 else if (!strcmp(res->dump, "dump_devargs"))
9449 rte_devargs_dump(stdout);
9450 else if (!strcmp(res->dump, "dump_log_types"))
9451 rte_log_dump(stdout);
9454 cmdline_parse_token_string_t cmd_dump_dump =
9455 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9458 "dump_struct_sizes#"
9464 cmdline_parse_inst_t cmd_dump = {
9465 .f = cmd_dump_parsed, /* function to call */
9466 .data = NULL, /* 2nd arg of func */
9467 .help_str = "Dump status",
9468 .tokens = { /* token list, NULL terminated */
9469 (void *)&cmd_dump_dump,
9474 /* ******************************************************************************** */
9476 struct cmd_dump_one_result {
9477 cmdline_fixed_string_t dump;
9478 cmdline_fixed_string_t name;
9481 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9482 __attribute__((unused)) void *data)
9484 struct cmd_dump_one_result *res = parsed_result;
9486 if (!strcmp(res->dump, "dump_ring")) {
9488 r = rte_ring_lookup(res->name);
9490 cmdline_printf(cl, "Cannot find ring\n");
9493 rte_ring_dump(stdout, r);
9494 } else if (!strcmp(res->dump, "dump_mempool")) {
9495 struct rte_mempool *mp;
9496 mp = rte_mempool_lookup(res->name);
9498 cmdline_printf(cl, "Cannot find mempool\n");
9501 rte_mempool_dump(stdout, mp);
9505 cmdline_parse_token_string_t cmd_dump_one_dump =
9506 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9507 "dump_ring#dump_mempool");
9509 cmdline_parse_token_string_t cmd_dump_one_name =
9510 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9512 cmdline_parse_inst_t cmd_dump_one = {
9513 .f = cmd_dump_one_parsed, /* function to call */
9514 .data = NULL, /* 2nd arg of func */
9515 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9516 .tokens = { /* token list, NULL terminated */
9517 (void *)&cmd_dump_one_dump,
9518 (void *)&cmd_dump_one_name,
9523 /* *** Add/Del syn filter *** */
9524 struct cmd_syn_filter_result {
9525 cmdline_fixed_string_t filter;
9527 cmdline_fixed_string_t ops;
9528 cmdline_fixed_string_t priority;
9529 cmdline_fixed_string_t high;
9530 cmdline_fixed_string_t queue;
9535 cmd_syn_filter_parsed(void *parsed_result,
9536 __attribute__((unused)) struct cmdline *cl,
9537 __attribute__((unused)) void *data)
9539 struct cmd_syn_filter_result *res = parsed_result;
9540 struct rte_eth_syn_filter syn_filter;
9543 ret = rte_eth_dev_filter_supported(res->port_id,
9544 RTE_ETH_FILTER_SYN);
9546 printf("syn filter is not supported on port %u.\n",
9551 memset(&syn_filter, 0, sizeof(syn_filter));
9553 if (!strcmp(res->ops, "add")) {
9554 if (!strcmp(res->high, "high"))
9555 syn_filter.hig_pri = 1;
9557 syn_filter.hig_pri = 0;
9559 syn_filter.queue = res->queue_id;
9560 ret = rte_eth_dev_filter_ctrl(res->port_id,
9565 ret = rte_eth_dev_filter_ctrl(res->port_id,
9567 RTE_ETH_FILTER_DELETE,
9571 printf("syn filter programming error: (%s)\n",
9575 cmdline_parse_token_string_t cmd_syn_filter_filter =
9576 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9577 filter, "syn_filter");
9578 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9579 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9581 cmdline_parse_token_string_t cmd_syn_filter_ops =
9582 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9584 cmdline_parse_token_string_t cmd_syn_filter_priority =
9585 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9586 priority, "priority");
9587 cmdline_parse_token_string_t cmd_syn_filter_high =
9588 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9590 cmdline_parse_token_string_t cmd_syn_filter_queue =
9591 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9593 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9594 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9597 cmdline_parse_inst_t cmd_syn_filter = {
9598 .f = cmd_syn_filter_parsed,
9600 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9601 "<queue_id>: Add/Delete syn filter",
9603 (void *)&cmd_syn_filter_filter,
9604 (void *)&cmd_syn_filter_port_id,
9605 (void *)&cmd_syn_filter_ops,
9606 (void *)&cmd_syn_filter_priority,
9607 (void *)&cmd_syn_filter_high,
9608 (void *)&cmd_syn_filter_queue,
9609 (void *)&cmd_syn_filter_queue_id,
9614 /* *** queue region set *** */
9615 struct cmd_queue_region_result {
9616 cmdline_fixed_string_t set;
9617 cmdline_fixed_string_t port;
9619 cmdline_fixed_string_t cmd;
9620 cmdline_fixed_string_t region;
9622 cmdline_fixed_string_t queue_start_index;
9624 cmdline_fixed_string_t queue_num;
9625 uint8_t queue_num_value;
9629 cmd_queue_region_parsed(void *parsed_result,
9630 __attribute__((unused)) struct cmdline *cl,
9631 __attribute__((unused)) void *data)
9633 struct cmd_queue_region_result *res = parsed_result;
9635 #ifdef RTE_LIBRTE_I40E_PMD
9636 struct rte_pmd_i40e_queue_region_conf region_conf;
9637 enum rte_pmd_i40e_queue_region_op op_type;
9640 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9643 #ifdef RTE_LIBRTE_I40E_PMD
9644 memset(®ion_conf, 0, sizeof(region_conf));
9645 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9646 region_conf.region_id = res->region_id;
9647 region_conf.queue_num = res->queue_num_value;
9648 region_conf.queue_start_index = res->queue_id;
9650 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9651 op_type, ®ion_conf);
9658 printf("function not implemented or supported\n");
9661 printf("queue region config error: (%s)\n", strerror(-ret));
9665 cmdline_parse_token_string_t cmd_queue_region_set =
9666 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9668 cmdline_parse_token_string_t cmd_queue_region_port =
9669 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9670 cmdline_parse_token_num_t cmd_queue_region_port_id =
9671 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9673 cmdline_parse_token_string_t cmd_queue_region_cmd =
9674 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9675 cmd, "queue-region");
9676 cmdline_parse_token_string_t cmd_queue_region_id =
9677 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9678 region, "region_id");
9679 cmdline_parse_token_num_t cmd_queue_region_index =
9680 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9682 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9683 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9684 queue_start_index, "queue_start_index");
9685 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9686 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9688 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9689 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9690 queue_num, "queue_num");
9691 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9692 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9693 queue_num_value, UINT8);
9695 cmdline_parse_inst_t cmd_queue_region = {
9696 .f = cmd_queue_region_parsed,
9698 .help_str = "set port <port_id> queue-region region_id <value> "
9699 "queue_start_index <value> queue_num <value>: Set a queue region",
9701 (void *)&cmd_queue_region_set,
9702 (void *)&cmd_queue_region_port,
9703 (void *)&cmd_queue_region_port_id,
9704 (void *)&cmd_queue_region_cmd,
9705 (void *)&cmd_queue_region_id,
9706 (void *)&cmd_queue_region_index,
9707 (void *)&cmd_queue_region_queue_start_index,
9708 (void *)&cmd_queue_region_queue_id,
9709 (void *)&cmd_queue_region_queue_num,
9710 (void *)&cmd_queue_region_queue_num_value,
9715 /* *** queue region and flowtype set *** */
9716 struct cmd_region_flowtype_result {
9717 cmdline_fixed_string_t set;
9718 cmdline_fixed_string_t port;
9720 cmdline_fixed_string_t cmd;
9721 cmdline_fixed_string_t region;
9723 cmdline_fixed_string_t flowtype;
9724 uint8_t flowtype_id;
9728 cmd_region_flowtype_parsed(void *parsed_result,
9729 __attribute__((unused)) struct cmdline *cl,
9730 __attribute__((unused)) void *data)
9732 struct cmd_region_flowtype_result *res = parsed_result;
9734 #ifdef RTE_LIBRTE_I40E_PMD
9735 struct rte_pmd_i40e_queue_region_conf region_conf;
9736 enum rte_pmd_i40e_queue_region_op op_type;
9739 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9742 #ifdef RTE_LIBRTE_I40E_PMD
9743 memset(®ion_conf, 0, sizeof(region_conf));
9745 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9746 region_conf.region_id = res->region_id;
9747 region_conf.hw_flowtype = res->flowtype_id;
9749 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9750 op_type, ®ion_conf);
9757 printf("function not implemented or supported\n");
9760 printf("region flowtype config error: (%s)\n", strerror(-ret));
9764 cmdline_parse_token_string_t cmd_region_flowtype_set =
9765 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9767 cmdline_parse_token_string_t cmd_region_flowtype_port =
9768 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9770 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9771 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9773 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9774 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9775 cmd, "queue-region");
9776 cmdline_parse_token_string_t cmd_region_flowtype_index =
9777 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9778 region, "region_id");
9779 cmdline_parse_token_num_t cmd_region_flowtype_id =
9780 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9782 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9783 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9784 flowtype, "flowtype");
9785 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9786 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9787 flowtype_id, UINT8);
9788 cmdline_parse_inst_t cmd_region_flowtype = {
9789 .f = cmd_region_flowtype_parsed,
9791 .help_str = "set port <port_id> queue-region region_id <value> "
9792 "flowtype <value>: Set a flowtype region index",
9794 (void *)&cmd_region_flowtype_set,
9795 (void *)&cmd_region_flowtype_port,
9796 (void *)&cmd_region_flowtype_port_index,
9797 (void *)&cmd_region_flowtype_cmd,
9798 (void *)&cmd_region_flowtype_index,
9799 (void *)&cmd_region_flowtype_id,
9800 (void *)&cmd_region_flowtype_flow_index,
9801 (void *)&cmd_region_flowtype_flow_id,
9806 /* *** User Priority (UP) to queue region (region_id) set *** */
9807 struct cmd_user_priority_region_result {
9808 cmdline_fixed_string_t set;
9809 cmdline_fixed_string_t port;
9811 cmdline_fixed_string_t cmd;
9812 cmdline_fixed_string_t user_priority;
9813 uint8_t user_priority_id;
9814 cmdline_fixed_string_t region;
9819 cmd_user_priority_region_parsed(void *parsed_result,
9820 __attribute__((unused)) struct cmdline *cl,
9821 __attribute__((unused)) void *data)
9823 struct cmd_user_priority_region_result *res = parsed_result;
9825 #ifdef RTE_LIBRTE_I40E_PMD
9826 struct rte_pmd_i40e_queue_region_conf region_conf;
9827 enum rte_pmd_i40e_queue_region_op op_type;
9830 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9833 #ifdef RTE_LIBRTE_I40E_PMD
9834 memset(®ion_conf, 0, sizeof(region_conf));
9835 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9836 region_conf.user_priority = res->user_priority_id;
9837 region_conf.region_id = res->region_id;
9839 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9840 op_type, ®ion_conf);
9847 printf("function not implemented or supported\n");
9850 printf("user_priority region config error: (%s)\n",
9855 cmdline_parse_token_string_t cmd_user_priority_region_set =
9856 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9858 cmdline_parse_token_string_t cmd_user_priority_region_port =
9859 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9861 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9862 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9864 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9865 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9866 cmd, "queue-region");
9867 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9868 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9869 user_priority, "UP");
9870 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9871 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9872 user_priority_id, UINT8);
9873 cmdline_parse_token_string_t cmd_user_priority_region_region =
9874 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9875 region, "region_id");
9876 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9877 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9880 cmdline_parse_inst_t cmd_user_priority_region = {
9881 .f = cmd_user_priority_region_parsed,
9883 .help_str = "set port <port_id> queue-region UP <value> "
9884 "region_id <value>: Set the mapping of User Priority (UP) "
9885 "to queue region (region_id) ",
9887 (void *)&cmd_user_priority_region_set,
9888 (void *)&cmd_user_priority_region_port,
9889 (void *)&cmd_user_priority_region_port_index,
9890 (void *)&cmd_user_priority_region_cmd,
9891 (void *)&cmd_user_priority_region_UP,
9892 (void *)&cmd_user_priority_region_UP_id,
9893 (void *)&cmd_user_priority_region_region,
9894 (void *)&cmd_user_priority_region_region_id,
9899 /* *** flush all queue region related configuration *** */
9900 struct cmd_flush_queue_region_result {
9901 cmdline_fixed_string_t set;
9902 cmdline_fixed_string_t port;
9904 cmdline_fixed_string_t cmd;
9905 cmdline_fixed_string_t flush;
9906 cmdline_fixed_string_t what;
9910 cmd_flush_queue_region_parsed(void *parsed_result,
9911 __attribute__((unused)) struct cmdline *cl,
9912 __attribute__((unused)) void *data)
9914 struct cmd_flush_queue_region_result *res = parsed_result;
9916 #ifdef RTE_LIBRTE_I40E_PMD
9917 struct rte_pmd_i40e_queue_region_conf region_conf;
9918 enum rte_pmd_i40e_queue_region_op op_type;
9921 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9924 #ifdef RTE_LIBRTE_I40E_PMD
9925 memset(®ion_conf, 0, sizeof(region_conf));
9927 if (strcmp(res->what, "on") == 0)
9928 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9930 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9932 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9933 op_type, ®ion_conf);
9940 printf("function not implemented or supported\n");
9943 printf("queue region config flush error: (%s)\n",
9948 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9949 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9951 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9952 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9954 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9955 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9957 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9958 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9959 cmd, "queue-region");
9960 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9961 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9963 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9964 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9967 cmdline_parse_inst_t cmd_flush_queue_region = {
9968 .f = cmd_flush_queue_region_parsed,
9970 .help_str = "set port <port_id> queue-region flush on|off"
9971 ": flush all queue region related configuration",
9973 (void *)&cmd_flush_queue_region_set,
9974 (void *)&cmd_flush_queue_region_port,
9975 (void *)&cmd_flush_queue_region_port_index,
9976 (void *)&cmd_flush_queue_region_cmd,
9977 (void *)&cmd_flush_queue_region_flush,
9978 (void *)&cmd_flush_queue_region_what,
9983 /* *** get all queue region related configuration info *** */
9984 struct cmd_show_queue_region_info {
9985 cmdline_fixed_string_t show;
9986 cmdline_fixed_string_t port;
9988 cmdline_fixed_string_t cmd;
9992 cmd_show_queue_region_info_parsed(void *parsed_result,
9993 __attribute__((unused)) struct cmdline *cl,
9994 __attribute__((unused)) void *data)
9996 struct cmd_show_queue_region_info *res = parsed_result;
9998 #ifdef RTE_LIBRTE_I40E_PMD
9999 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10000 enum rte_pmd_i40e_queue_region_op op_type;
10003 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10006 #ifdef RTE_LIBRTE_I40E_PMD
10007 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10009 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10011 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10012 op_type, &rte_pmd_regions);
10014 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10021 printf("function not implemented or supported\n");
10024 printf("queue region config info show error: (%s)\n",
10029 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10030 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10032 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10033 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10035 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10036 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10038 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10039 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10040 cmd, "queue-region");
10042 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10043 .f = cmd_show_queue_region_info_parsed,
10045 .help_str = "show port <port_id> queue-region"
10046 ": show all queue region related configuration info",
10048 (void *)&cmd_show_queue_region_info_get,
10049 (void *)&cmd_show_queue_region_info_port,
10050 (void *)&cmd_show_queue_region_info_port_index,
10051 (void *)&cmd_show_queue_region_info_cmd,
10056 /* *** ADD/REMOVE A 2tuple FILTER *** */
10057 struct cmd_2tuple_filter_result {
10058 cmdline_fixed_string_t filter;
10060 cmdline_fixed_string_t ops;
10061 cmdline_fixed_string_t dst_port;
10062 uint16_t dst_port_value;
10063 cmdline_fixed_string_t protocol;
10064 uint8_t protocol_value;
10065 cmdline_fixed_string_t mask;
10066 uint8_t mask_value;
10067 cmdline_fixed_string_t tcp_flags;
10068 uint8_t tcp_flags_value;
10069 cmdline_fixed_string_t priority;
10070 uint8_t priority_value;
10071 cmdline_fixed_string_t queue;
10076 cmd_2tuple_filter_parsed(void *parsed_result,
10077 __attribute__((unused)) struct cmdline *cl,
10078 __attribute__((unused)) void *data)
10080 struct rte_eth_ntuple_filter filter;
10081 struct cmd_2tuple_filter_result *res = parsed_result;
10084 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10086 printf("ntuple filter is not supported on port %u.\n",
10091 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10093 filter.flags = RTE_2TUPLE_FLAGS;
10094 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10095 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10096 filter.proto = res->protocol_value;
10097 filter.priority = res->priority_value;
10098 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10099 printf("nonzero tcp_flags is only meaningful"
10100 " when protocol is TCP.\n");
10103 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10104 printf("invalid TCP flags.\n");
10108 if (res->tcp_flags_value != 0) {
10109 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10110 filter.tcp_flags = res->tcp_flags_value;
10113 /* need convert to big endian. */
10114 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10115 filter.queue = res->queue_id;
10117 if (!strcmp(res->ops, "add"))
10118 ret = rte_eth_dev_filter_ctrl(res->port_id,
10119 RTE_ETH_FILTER_NTUPLE,
10120 RTE_ETH_FILTER_ADD,
10123 ret = rte_eth_dev_filter_ctrl(res->port_id,
10124 RTE_ETH_FILTER_NTUPLE,
10125 RTE_ETH_FILTER_DELETE,
10128 printf("2tuple filter programming error: (%s)\n",
10133 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10134 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10135 filter, "2tuple_filter");
10136 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10137 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10139 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10140 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10142 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10143 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10144 dst_port, "dst_port");
10145 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10146 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10147 dst_port_value, UINT16);
10148 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10149 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10150 protocol, "protocol");
10151 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10152 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10153 protocol_value, UINT8);
10154 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10155 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10157 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10158 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10160 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10161 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10162 tcp_flags, "tcp_flags");
10163 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10164 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10165 tcp_flags_value, UINT8);
10166 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10167 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10168 priority, "priority");
10169 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10170 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10171 priority_value, UINT8);
10172 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10173 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10175 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10176 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10179 cmdline_parse_inst_t cmd_2tuple_filter = {
10180 .f = cmd_2tuple_filter_parsed,
10182 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10183 "<value> mask <value> tcp_flags <value> priority <value> queue "
10184 "<queue_id>: Add a 2tuple filter",
10186 (void *)&cmd_2tuple_filter_filter,
10187 (void *)&cmd_2tuple_filter_port_id,
10188 (void *)&cmd_2tuple_filter_ops,
10189 (void *)&cmd_2tuple_filter_dst_port,
10190 (void *)&cmd_2tuple_filter_dst_port_value,
10191 (void *)&cmd_2tuple_filter_protocol,
10192 (void *)&cmd_2tuple_filter_protocol_value,
10193 (void *)&cmd_2tuple_filter_mask,
10194 (void *)&cmd_2tuple_filter_mask_value,
10195 (void *)&cmd_2tuple_filter_tcp_flags,
10196 (void *)&cmd_2tuple_filter_tcp_flags_value,
10197 (void *)&cmd_2tuple_filter_priority,
10198 (void *)&cmd_2tuple_filter_priority_value,
10199 (void *)&cmd_2tuple_filter_queue,
10200 (void *)&cmd_2tuple_filter_queue_id,
10205 /* *** ADD/REMOVE A 5tuple FILTER *** */
10206 struct cmd_5tuple_filter_result {
10207 cmdline_fixed_string_t filter;
10209 cmdline_fixed_string_t ops;
10210 cmdline_fixed_string_t dst_ip;
10211 cmdline_ipaddr_t dst_ip_value;
10212 cmdline_fixed_string_t src_ip;
10213 cmdline_ipaddr_t src_ip_value;
10214 cmdline_fixed_string_t dst_port;
10215 uint16_t dst_port_value;
10216 cmdline_fixed_string_t src_port;
10217 uint16_t src_port_value;
10218 cmdline_fixed_string_t protocol;
10219 uint8_t protocol_value;
10220 cmdline_fixed_string_t mask;
10221 uint8_t mask_value;
10222 cmdline_fixed_string_t tcp_flags;
10223 uint8_t tcp_flags_value;
10224 cmdline_fixed_string_t priority;
10225 uint8_t priority_value;
10226 cmdline_fixed_string_t queue;
10231 cmd_5tuple_filter_parsed(void *parsed_result,
10232 __attribute__((unused)) struct cmdline *cl,
10233 __attribute__((unused)) void *data)
10235 struct rte_eth_ntuple_filter filter;
10236 struct cmd_5tuple_filter_result *res = parsed_result;
10239 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10241 printf("ntuple filter is not supported on port %u.\n",
10246 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10248 filter.flags = RTE_5TUPLE_FLAGS;
10249 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10250 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10251 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10252 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10253 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10254 filter.proto = res->protocol_value;
10255 filter.priority = res->priority_value;
10256 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10257 printf("nonzero tcp_flags is only meaningful"
10258 " when protocol is TCP.\n");
10261 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10262 printf("invalid TCP flags.\n");
10266 if (res->tcp_flags_value != 0) {
10267 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10268 filter.tcp_flags = res->tcp_flags_value;
10271 if (res->dst_ip_value.family == AF_INET)
10272 /* no need to convert, already big endian. */
10273 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10275 if (filter.dst_ip_mask == 0) {
10276 printf("can not support ipv6 involved compare.\n");
10282 if (res->src_ip_value.family == AF_INET)
10283 /* no need to convert, already big endian. */
10284 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10286 if (filter.src_ip_mask == 0) {
10287 printf("can not support ipv6 involved compare.\n");
10292 /* need convert to big endian. */
10293 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10294 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10295 filter.queue = res->queue_id;
10297 if (!strcmp(res->ops, "add"))
10298 ret = rte_eth_dev_filter_ctrl(res->port_id,
10299 RTE_ETH_FILTER_NTUPLE,
10300 RTE_ETH_FILTER_ADD,
10303 ret = rte_eth_dev_filter_ctrl(res->port_id,
10304 RTE_ETH_FILTER_NTUPLE,
10305 RTE_ETH_FILTER_DELETE,
10308 printf("5tuple filter programming error: (%s)\n",
10312 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10313 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10314 filter, "5tuple_filter");
10315 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10316 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10318 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10319 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10321 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10322 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10324 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10325 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10327 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10328 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10330 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10331 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10333 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10334 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10335 dst_port, "dst_port");
10336 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10337 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10338 dst_port_value, UINT16);
10339 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10340 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10341 src_port, "src_port");
10342 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10343 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10344 src_port_value, UINT16);
10345 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10346 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10347 protocol, "protocol");
10348 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10349 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10350 protocol_value, UINT8);
10351 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10352 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10354 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10355 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10357 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10358 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10359 tcp_flags, "tcp_flags");
10360 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10361 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10362 tcp_flags_value, UINT8);
10363 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10364 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10365 priority, "priority");
10366 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10367 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10368 priority_value, UINT8);
10369 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10370 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10372 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10373 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10376 cmdline_parse_inst_t cmd_5tuple_filter = {
10377 .f = cmd_5tuple_filter_parsed,
10379 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10380 "src_ip <value> dst_port <value> src_port <value> "
10381 "protocol <value> mask <value> tcp_flags <value> "
10382 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10384 (void *)&cmd_5tuple_filter_filter,
10385 (void *)&cmd_5tuple_filter_port_id,
10386 (void *)&cmd_5tuple_filter_ops,
10387 (void *)&cmd_5tuple_filter_dst_ip,
10388 (void *)&cmd_5tuple_filter_dst_ip_value,
10389 (void *)&cmd_5tuple_filter_src_ip,
10390 (void *)&cmd_5tuple_filter_src_ip_value,
10391 (void *)&cmd_5tuple_filter_dst_port,
10392 (void *)&cmd_5tuple_filter_dst_port_value,
10393 (void *)&cmd_5tuple_filter_src_port,
10394 (void *)&cmd_5tuple_filter_src_port_value,
10395 (void *)&cmd_5tuple_filter_protocol,
10396 (void *)&cmd_5tuple_filter_protocol_value,
10397 (void *)&cmd_5tuple_filter_mask,
10398 (void *)&cmd_5tuple_filter_mask_value,
10399 (void *)&cmd_5tuple_filter_tcp_flags,
10400 (void *)&cmd_5tuple_filter_tcp_flags_value,
10401 (void *)&cmd_5tuple_filter_priority,
10402 (void *)&cmd_5tuple_filter_priority_value,
10403 (void *)&cmd_5tuple_filter_queue,
10404 (void *)&cmd_5tuple_filter_queue_id,
10409 /* *** ADD/REMOVE A flex FILTER *** */
10410 struct cmd_flex_filter_result {
10411 cmdline_fixed_string_t filter;
10412 cmdline_fixed_string_t ops;
10414 cmdline_fixed_string_t len;
10416 cmdline_fixed_string_t bytes;
10417 cmdline_fixed_string_t bytes_value;
10418 cmdline_fixed_string_t mask;
10419 cmdline_fixed_string_t mask_value;
10420 cmdline_fixed_string_t priority;
10421 uint8_t priority_value;
10422 cmdline_fixed_string_t queue;
10426 static int xdigit2val(unsigned char c)
10431 else if (isupper(c))
10432 val = c - 'A' + 10;
10434 val = c - 'a' + 10;
10439 cmd_flex_filter_parsed(void *parsed_result,
10440 __attribute__((unused)) struct cmdline *cl,
10441 __attribute__((unused)) void *data)
10444 struct rte_eth_flex_filter filter;
10445 struct cmd_flex_filter_result *res = parsed_result;
10446 char *bytes_ptr, *mask_ptr;
10447 uint16_t len, i, j = 0;
10452 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10453 printf("the len exceed the max length 128\n");
10456 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10457 filter.len = res->len_value;
10458 filter.priority = res->priority_value;
10459 filter.queue = res->queue_id;
10460 bytes_ptr = res->bytes_value;
10461 mask_ptr = res->mask_value;
10463 /* translate bytes string to array. */
10464 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10465 (bytes_ptr[1] == 'X')))
10467 len = strnlen(bytes_ptr, res->len_value * 2);
10468 if (len == 0 || (len % 8 != 0)) {
10469 printf("please check len and bytes input\n");
10472 for (i = 0; i < len; i++) {
10474 if (isxdigit(c) == 0) {
10475 /* invalid characters. */
10476 printf("invalid input\n");
10479 val = xdigit2val(c);
10482 filter.bytes[j] = byte;
10483 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10490 /* translate mask string to uint8_t array. */
10491 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10492 (mask_ptr[1] == 'X')))
10494 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10496 printf("invalid input\n");
10501 for (i = 0; i < len; i++) {
10503 if (isxdigit(c) == 0) {
10504 /* invalid characters. */
10505 printf("invalid input\n");
10508 val = xdigit2val(c);
10511 filter.mask[j] = byte;
10512 printf("mask[%d]:%02x ", j, filter.mask[j]);
10520 if (!strcmp(res->ops, "add"))
10521 ret = rte_eth_dev_filter_ctrl(res->port_id,
10522 RTE_ETH_FILTER_FLEXIBLE,
10523 RTE_ETH_FILTER_ADD,
10526 ret = rte_eth_dev_filter_ctrl(res->port_id,
10527 RTE_ETH_FILTER_FLEXIBLE,
10528 RTE_ETH_FILTER_DELETE,
10532 printf("flex filter setting error: (%s)\n", strerror(-ret));
10535 cmdline_parse_token_string_t cmd_flex_filter_filter =
10536 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10537 filter, "flex_filter");
10538 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10539 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10541 cmdline_parse_token_string_t cmd_flex_filter_ops =
10542 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10544 cmdline_parse_token_string_t cmd_flex_filter_len =
10545 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10547 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10548 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10550 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10551 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10553 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10554 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10555 bytes_value, NULL);
10556 cmdline_parse_token_string_t cmd_flex_filter_mask =
10557 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10559 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10560 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10562 cmdline_parse_token_string_t cmd_flex_filter_priority =
10563 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10564 priority, "priority");
10565 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10566 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10567 priority_value, UINT8);
10568 cmdline_parse_token_string_t cmd_flex_filter_queue =
10569 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10571 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10572 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10574 cmdline_parse_inst_t cmd_flex_filter = {
10575 .f = cmd_flex_filter_parsed,
10577 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10578 "<value> mask <value> priority <value> queue <queue_id>: "
10579 "Add/Del a flex filter",
10581 (void *)&cmd_flex_filter_filter,
10582 (void *)&cmd_flex_filter_port_id,
10583 (void *)&cmd_flex_filter_ops,
10584 (void *)&cmd_flex_filter_len,
10585 (void *)&cmd_flex_filter_len_value,
10586 (void *)&cmd_flex_filter_bytes,
10587 (void *)&cmd_flex_filter_bytes_value,
10588 (void *)&cmd_flex_filter_mask,
10589 (void *)&cmd_flex_filter_mask_value,
10590 (void *)&cmd_flex_filter_priority,
10591 (void *)&cmd_flex_filter_priority_value,
10592 (void *)&cmd_flex_filter_queue,
10593 (void *)&cmd_flex_filter_queue_id,
10598 /* *** Filters Control *** */
10600 /* *** deal with ethertype filter *** */
10601 struct cmd_ethertype_filter_result {
10602 cmdline_fixed_string_t filter;
10604 cmdline_fixed_string_t ops;
10605 cmdline_fixed_string_t mac;
10606 struct rte_ether_addr mac_addr;
10607 cmdline_fixed_string_t ethertype;
10608 uint16_t ethertype_value;
10609 cmdline_fixed_string_t drop;
10610 cmdline_fixed_string_t queue;
10614 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10615 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10616 filter, "ethertype_filter");
10617 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10618 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10620 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10621 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10623 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10624 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10625 mac, "mac_addr#mac_ignr");
10626 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10627 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10629 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10630 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10631 ethertype, "ethertype");
10632 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10633 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10634 ethertype_value, UINT16);
10635 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10636 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10638 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10639 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10641 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10642 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10646 cmd_ethertype_filter_parsed(void *parsed_result,
10647 __attribute__((unused)) struct cmdline *cl,
10648 __attribute__((unused)) void *data)
10650 struct cmd_ethertype_filter_result *res = parsed_result;
10651 struct rte_eth_ethertype_filter filter;
10654 ret = rte_eth_dev_filter_supported(res->port_id,
10655 RTE_ETH_FILTER_ETHERTYPE);
10657 printf("ethertype filter is not supported on port %u.\n",
10662 memset(&filter, 0, sizeof(filter));
10663 if (!strcmp(res->mac, "mac_addr")) {
10664 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10665 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10666 sizeof(struct rte_ether_addr));
10668 if (!strcmp(res->drop, "drop"))
10669 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10670 filter.ether_type = res->ethertype_value;
10671 filter.queue = res->queue_id;
10673 if (!strcmp(res->ops, "add"))
10674 ret = rte_eth_dev_filter_ctrl(res->port_id,
10675 RTE_ETH_FILTER_ETHERTYPE,
10676 RTE_ETH_FILTER_ADD,
10679 ret = rte_eth_dev_filter_ctrl(res->port_id,
10680 RTE_ETH_FILTER_ETHERTYPE,
10681 RTE_ETH_FILTER_DELETE,
10684 printf("ethertype filter programming error: (%s)\n",
10688 cmdline_parse_inst_t cmd_ethertype_filter = {
10689 .f = cmd_ethertype_filter_parsed,
10691 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10692 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10693 "Add or delete an ethertype filter entry",
10695 (void *)&cmd_ethertype_filter_filter,
10696 (void *)&cmd_ethertype_filter_port_id,
10697 (void *)&cmd_ethertype_filter_ops,
10698 (void *)&cmd_ethertype_filter_mac,
10699 (void *)&cmd_ethertype_filter_mac_addr,
10700 (void *)&cmd_ethertype_filter_ethertype,
10701 (void *)&cmd_ethertype_filter_ethertype_value,
10702 (void *)&cmd_ethertype_filter_drop,
10703 (void *)&cmd_ethertype_filter_queue,
10704 (void *)&cmd_ethertype_filter_queue_id,
10709 /* *** deal with flow director filter *** */
10710 struct cmd_flow_director_result {
10711 cmdline_fixed_string_t flow_director_filter;
10713 cmdline_fixed_string_t mode;
10714 cmdline_fixed_string_t mode_value;
10715 cmdline_fixed_string_t ops;
10716 cmdline_fixed_string_t flow;
10717 cmdline_fixed_string_t flow_type;
10718 cmdline_fixed_string_t ether;
10719 uint16_t ether_type;
10720 cmdline_fixed_string_t src;
10721 cmdline_ipaddr_t ip_src;
10723 cmdline_fixed_string_t dst;
10724 cmdline_ipaddr_t ip_dst;
10726 cmdline_fixed_string_t verify_tag;
10727 uint32_t verify_tag_value;
10728 cmdline_fixed_string_t tos;
10730 cmdline_fixed_string_t proto;
10731 uint8_t proto_value;
10732 cmdline_fixed_string_t ttl;
10734 cmdline_fixed_string_t vlan;
10735 uint16_t vlan_value;
10736 cmdline_fixed_string_t flexbytes;
10737 cmdline_fixed_string_t flexbytes_value;
10738 cmdline_fixed_string_t pf_vf;
10739 cmdline_fixed_string_t drop;
10740 cmdline_fixed_string_t queue;
10742 cmdline_fixed_string_t fd_id;
10743 uint32_t fd_id_value;
10744 cmdline_fixed_string_t mac;
10745 struct rte_ether_addr mac_addr;
10746 cmdline_fixed_string_t tunnel;
10747 cmdline_fixed_string_t tunnel_type;
10748 cmdline_fixed_string_t tunnel_id;
10749 uint32_t tunnel_id_value;
10750 cmdline_fixed_string_t packet;
10755 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10758 const char *p, *p0 = q_arg;
10760 unsigned long int_fld;
10761 char *str_fld[max_num];
10766 p = strchr(p0, '(');
10770 p0 = strchr(p, ')');
10775 if (size >= sizeof(s))
10778 snprintf(s, sizeof(s), "%.*s", size, p);
10779 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10780 if (ret < 0 || ret > max_num)
10782 for (i = 0; i < ret; i++) {
10784 int_fld = strtoul(str_fld[i], &end, 0);
10785 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10787 flexbytes[i] = (uint8_t)int_fld;
10793 str2flowtype(char *string)
10796 static const struct {
10799 } flowtype_str[] = {
10800 {"raw", RTE_ETH_FLOW_RAW},
10801 {"ipv4", RTE_ETH_FLOW_IPV4},
10802 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10803 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10804 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10805 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10806 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10807 {"ipv6", RTE_ETH_FLOW_IPV6},
10808 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10809 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10810 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10811 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10812 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10813 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10816 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10817 if (!strcmp(flowtype_str[i].str, string))
10818 return flowtype_str[i].type;
10821 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10822 return (uint16_t)atoi(string);
10824 return RTE_ETH_FLOW_UNKNOWN;
10827 static enum rte_eth_fdir_tunnel_type
10828 str2fdir_tunneltype(char *string)
10832 static const struct {
10834 enum rte_eth_fdir_tunnel_type type;
10835 } tunneltype_str[] = {
10836 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10837 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10840 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10841 if (!strcmp(tunneltype_str[i].str, string))
10842 return tunneltype_str[i].type;
10844 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10847 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10849 if ((ip_addr).family == AF_INET) \
10850 (ip) = (ip_addr).addr.ipv4.s_addr; \
10852 printf("invalid parameter.\n"); \
10857 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10859 if ((ip_addr).family == AF_INET6) \
10860 rte_memcpy(&(ip), \
10861 &((ip_addr).addr.ipv6), \
10862 sizeof(struct in6_addr)); \
10864 printf("invalid parameter.\n"); \
10870 cmd_flow_director_filter_parsed(void *parsed_result,
10871 __attribute__((unused)) struct cmdline *cl,
10872 __attribute__((unused)) void *data)
10874 struct cmd_flow_director_result *res = parsed_result;
10875 struct rte_eth_fdir_filter entry;
10876 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10878 unsigned long vf_id;
10881 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10883 printf("flow director is not supported on port %u.\n",
10887 memset(flexbytes, 0, sizeof(flexbytes));
10888 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10890 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10891 if (strcmp(res->mode_value, "MAC-VLAN")) {
10892 printf("Please set mode to MAC-VLAN.\n");
10895 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10896 if (strcmp(res->mode_value, "Tunnel")) {
10897 printf("Please set mode to Tunnel.\n");
10901 if (!strcmp(res->mode_value, "raw")) {
10902 #ifdef RTE_LIBRTE_I40E_PMD
10903 struct rte_pmd_i40e_flow_type_mapping
10904 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10905 struct rte_pmd_i40e_pkt_template_conf conf;
10906 uint16_t flow_type = str2flowtype(res->flow_type);
10907 uint16_t i, port = res->port_id;
10910 memset(&conf, 0, sizeof(conf));
10912 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10913 printf("Invalid flow type specified.\n");
10916 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10920 if (mapping[flow_type].pctype == 0ULL) {
10921 printf("Invalid flow type specified.\n");
10924 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10925 if (mapping[flow_type].pctype & (1ULL << i)) {
10926 conf.input.pctype = i;
10931 conf.input.packet = open_file(res->filepath,
10932 &conf.input.length);
10933 if (!conf.input.packet)
10935 if (!strcmp(res->drop, "drop"))
10936 conf.action.behavior =
10937 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10939 conf.action.behavior =
10940 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10941 conf.action.report_status =
10942 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10943 conf.action.rx_queue = res->queue_id;
10944 conf.soft_id = res->fd_id_value;
10945 add = strcmp(res->ops, "del") ? 1 : 0;
10946 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10950 printf("flow director config error: (%s)\n",
10952 close_file(conf.input.packet);
10955 } else if (strcmp(res->mode_value, "IP")) {
10956 printf("Please set mode to IP or raw.\n");
10959 entry.input.flow_type = str2flowtype(res->flow_type);
10962 ret = parse_flexbytes(res->flexbytes_value,
10964 RTE_ETH_FDIR_MAX_FLEXLEN);
10966 printf("error: Cannot parse flexbytes input.\n");
10970 switch (entry.input.flow_type) {
10971 case RTE_ETH_FLOW_FRAG_IPV4:
10972 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10973 entry.input.flow.ip4_flow.proto = res->proto_value;
10975 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10976 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10977 IPV4_ADDR_TO_UINT(res->ip_dst,
10978 entry.input.flow.ip4_flow.dst_ip);
10979 IPV4_ADDR_TO_UINT(res->ip_src,
10980 entry.input.flow.ip4_flow.src_ip);
10981 entry.input.flow.ip4_flow.tos = res->tos_value;
10982 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10983 /* need convert to big endian. */
10984 entry.input.flow.udp4_flow.dst_port =
10985 rte_cpu_to_be_16(res->port_dst);
10986 entry.input.flow.udp4_flow.src_port =
10987 rte_cpu_to_be_16(res->port_src);
10989 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10990 IPV4_ADDR_TO_UINT(res->ip_dst,
10991 entry.input.flow.sctp4_flow.ip.dst_ip);
10992 IPV4_ADDR_TO_UINT(res->ip_src,
10993 entry.input.flow.sctp4_flow.ip.src_ip);
10994 entry.input.flow.ip4_flow.tos = res->tos_value;
10995 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10996 /* need convert to big endian. */
10997 entry.input.flow.sctp4_flow.dst_port =
10998 rte_cpu_to_be_16(res->port_dst);
10999 entry.input.flow.sctp4_flow.src_port =
11000 rte_cpu_to_be_16(res->port_src);
11001 entry.input.flow.sctp4_flow.verify_tag =
11002 rte_cpu_to_be_32(res->verify_tag_value);
11004 case RTE_ETH_FLOW_FRAG_IPV6:
11005 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11006 entry.input.flow.ipv6_flow.proto = res->proto_value;
11008 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11009 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11010 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11011 entry.input.flow.ipv6_flow.dst_ip);
11012 IPV6_ADDR_TO_ARRAY(res->ip_src,
11013 entry.input.flow.ipv6_flow.src_ip);
11014 entry.input.flow.ipv6_flow.tc = res->tos_value;
11015 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11016 /* need convert to big endian. */
11017 entry.input.flow.udp6_flow.dst_port =
11018 rte_cpu_to_be_16(res->port_dst);
11019 entry.input.flow.udp6_flow.src_port =
11020 rte_cpu_to_be_16(res->port_src);
11022 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11023 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11024 entry.input.flow.sctp6_flow.ip.dst_ip);
11025 IPV6_ADDR_TO_ARRAY(res->ip_src,
11026 entry.input.flow.sctp6_flow.ip.src_ip);
11027 entry.input.flow.ipv6_flow.tc = res->tos_value;
11028 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11029 /* need convert to big endian. */
11030 entry.input.flow.sctp6_flow.dst_port =
11031 rte_cpu_to_be_16(res->port_dst);
11032 entry.input.flow.sctp6_flow.src_port =
11033 rte_cpu_to_be_16(res->port_src);
11034 entry.input.flow.sctp6_flow.verify_tag =
11035 rte_cpu_to_be_32(res->verify_tag_value);
11037 case RTE_ETH_FLOW_L2_PAYLOAD:
11038 entry.input.flow.l2_flow.ether_type =
11039 rte_cpu_to_be_16(res->ether_type);
11045 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11046 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11048 sizeof(struct rte_ether_addr));
11050 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11051 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11053 sizeof(struct rte_ether_addr));
11054 entry.input.flow.tunnel_flow.tunnel_type =
11055 str2fdir_tunneltype(res->tunnel_type);
11056 entry.input.flow.tunnel_flow.tunnel_id =
11057 rte_cpu_to_be_32(res->tunnel_id_value);
11060 rte_memcpy(entry.input.flow_ext.flexbytes,
11062 RTE_ETH_FDIR_MAX_FLEXLEN);
11064 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11066 entry.action.flex_off = 0; /*use 0 by default */
11067 if (!strcmp(res->drop, "drop"))
11068 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11070 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11072 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11073 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11074 if (!strcmp(res->pf_vf, "pf"))
11075 entry.input.flow_ext.is_vf = 0;
11076 else if (!strncmp(res->pf_vf, "vf", 2)) {
11077 struct rte_eth_dev_info dev_info;
11079 memset(&dev_info, 0, sizeof(dev_info));
11080 rte_eth_dev_info_get(res->port_id, &dev_info);
11082 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11083 if (errno != 0 || *end != '\0' ||
11084 vf_id >= dev_info.max_vfs) {
11085 printf("invalid parameter %s.\n", res->pf_vf);
11088 entry.input.flow_ext.is_vf = 1;
11089 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11091 printf("invalid parameter %s.\n", res->pf_vf);
11096 /* set to report FD ID by default */
11097 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11098 entry.action.rx_queue = res->queue_id;
11099 entry.soft_id = res->fd_id_value;
11100 if (!strcmp(res->ops, "add"))
11101 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11102 RTE_ETH_FILTER_ADD, &entry);
11103 else if (!strcmp(res->ops, "del"))
11104 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11105 RTE_ETH_FILTER_DELETE, &entry);
11107 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11108 RTE_ETH_FILTER_UPDATE, &entry);
11110 printf("flow director programming error: (%s)\n",
11114 cmdline_parse_token_string_t cmd_flow_director_filter =
11115 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11116 flow_director_filter, "flow_director_filter");
11117 cmdline_parse_token_num_t cmd_flow_director_port_id =
11118 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11120 cmdline_parse_token_string_t cmd_flow_director_ops =
11121 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11122 ops, "add#del#update");
11123 cmdline_parse_token_string_t cmd_flow_director_flow =
11124 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11126 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11127 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11129 cmdline_parse_token_string_t cmd_flow_director_ether =
11130 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11132 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11133 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11134 ether_type, UINT16);
11135 cmdline_parse_token_string_t cmd_flow_director_src =
11136 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11138 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11139 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11141 cmdline_parse_token_num_t cmd_flow_director_port_src =
11142 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11144 cmdline_parse_token_string_t cmd_flow_director_dst =
11145 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11147 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11148 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11150 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11151 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11153 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11154 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11155 verify_tag, "verify_tag");
11156 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11157 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11158 verify_tag_value, UINT32);
11159 cmdline_parse_token_string_t cmd_flow_director_tos =
11160 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11162 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11163 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11165 cmdline_parse_token_string_t cmd_flow_director_proto =
11166 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11168 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11169 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11170 proto_value, UINT8);
11171 cmdline_parse_token_string_t cmd_flow_director_ttl =
11172 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11174 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11175 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11177 cmdline_parse_token_string_t cmd_flow_director_vlan =
11178 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11180 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11181 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11182 vlan_value, UINT16);
11183 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11184 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11185 flexbytes, "flexbytes");
11186 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11187 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11188 flexbytes_value, NULL);
11189 cmdline_parse_token_string_t cmd_flow_director_drop =
11190 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11192 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11193 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11195 cmdline_parse_token_string_t cmd_flow_director_queue =
11196 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11198 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11199 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11201 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11202 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11204 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11205 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11206 fd_id_value, UINT32);
11208 cmdline_parse_token_string_t cmd_flow_director_mode =
11209 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11211 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11212 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11214 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11215 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11216 mode_value, "MAC-VLAN");
11217 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11218 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11219 mode_value, "Tunnel");
11220 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11221 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11222 mode_value, "raw");
11223 cmdline_parse_token_string_t cmd_flow_director_mac =
11224 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11226 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11227 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11229 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11230 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11232 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11233 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11234 tunnel_type, "NVGRE#VxLAN");
11235 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11236 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11237 tunnel_id, "tunnel-id");
11238 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11239 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11240 tunnel_id_value, UINT32);
11241 cmdline_parse_token_string_t cmd_flow_director_packet =
11242 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11244 cmdline_parse_token_string_t cmd_flow_director_filepath =
11245 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11248 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11249 .f = cmd_flow_director_filter_parsed,
11251 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11252 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11253 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11254 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11255 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11256 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11257 "fd_id <fd_id_value>: "
11258 "Add or delete an ip flow director entry on NIC",
11260 (void *)&cmd_flow_director_filter,
11261 (void *)&cmd_flow_director_port_id,
11262 (void *)&cmd_flow_director_mode,
11263 (void *)&cmd_flow_director_mode_ip,
11264 (void *)&cmd_flow_director_ops,
11265 (void *)&cmd_flow_director_flow,
11266 (void *)&cmd_flow_director_flow_type,
11267 (void *)&cmd_flow_director_src,
11268 (void *)&cmd_flow_director_ip_src,
11269 (void *)&cmd_flow_director_dst,
11270 (void *)&cmd_flow_director_ip_dst,
11271 (void *)&cmd_flow_director_tos,
11272 (void *)&cmd_flow_director_tos_value,
11273 (void *)&cmd_flow_director_proto,
11274 (void *)&cmd_flow_director_proto_value,
11275 (void *)&cmd_flow_director_ttl,
11276 (void *)&cmd_flow_director_ttl_value,
11277 (void *)&cmd_flow_director_vlan,
11278 (void *)&cmd_flow_director_vlan_value,
11279 (void *)&cmd_flow_director_flexbytes,
11280 (void *)&cmd_flow_director_flexbytes_value,
11281 (void *)&cmd_flow_director_drop,
11282 (void *)&cmd_flow_director_pf_vf,
11283 (void *)&cmd_flow_director_queue,
11284 (void *)&cmd_flow_director_queue_id,
11285 (void *)&cmd_flow_director_fd_id,
11286 (void *)&cmd_flow_director_fd_id_value,
11291 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11292 .f = cmd_flow_director_filter_parsed,
11294 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11295 "director entry on NIC",
11297 (void *)&cmd_flow_director_filter,
11298 (void *)&cmd_flow_director_port_id,
11299 (void *)&cmd_flow_director_mode,
11300 (void *)&cmd_flow_director_mode_ip,
11301 (void *)&cmd_flow_director_ops,
11302 (void *)&cmd_flow_director_flow,
11303 (void *)&cmd_flow_director_flow_type,
11304 (void *)&cmd_flow_director_src,
11305 (void *)&cmd_flow_director_ip_src,
11306 (void *)&cmd_flow_director_port_src,
11307 (void *)&cmd_flow_director_dst,
11308 (void *)&cmd_flow_director_ip_dst,
11309 (void *)&cmd_flow_director_port_dst,
11310 (void *)&cmd_flow_director_tos,
11311 (void *)&cmd_flow_director_tos_value,
11312 (void *)&cmd_flow_director_ttl,
11313 (void *)&cmd_flow_director_ttl_value,
11314 (void *)&cmd_flow_director_vlan,
11315 (void *)&cmd_flow_director_vlan_value,
11316 (void *)&cmd_flow_director_flexbytes,
11317 (void *)&cmd_flow_director_flexbytes_value,
11318 (void *)&cmd_flow_director_drop,
11319 (void *)&cmd_flow_director_pf_vf,
11320 (void *)&cmd_flow_director_queue,
11321 (void *)&cmd_flow_director_queue_id,
11322 (void *)&cmd_flow_director_fd_id,
11323 (void *)&cmd_flow_director_fd_id_value,
11328 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11329 .f = cmd_flow_director_filter_parsed,
11331 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11332 "director entry on NIC",
11334 (void *)&cmd_flow_director_filter,
11335 (void *)&cmd_flow_director_port_id,
11336 (void *)&cmd_flow_director_mode,
11337 (void *)&cmd_flow_director_mode_ip,
11338 (void *)&cmd_flow_director_ops,
11339 (void *)&cmd_flow_director_flow,
11340 (void *)&cmd_flow_director_flow_type,
11341 (void *)&cmd_flow_director_src,
11342 (void *)&cmd_flow_director_ip_src,
11343 (void *)&cmd_flow_director_port_src,
11344 (void *)&cmd_flow_director_dst,
11345 (void *)&cmd_flow_director_ip_dst,
11346 (void *)&cmd_flow_director_port_dst,
11347 (void *)&cmd_flow_director_verify_tag,
11348 (void *)&cmd_flow_director_verify_tag_value,
11349 (void *)&cmd_flow_director_tos,
11350 (void *)&cmd_flow_director_tos_value,
11351 (void *)&cmd_flow_director_ttl,
11352 (void *)&cmd_flow_director_ttl_value,
11353 (void *)&cmd_flow_director_vlan,
11354 (void *)&cmd_flow_director_vlan_value,
11355 (void *)&cmd_flow_director_flexbytes,
11356 (void *)&cmd_flow_director_flexbytes_value,
11357 (void *)&cmd_flow_director_drop,
11358 (void *)&cmd_flow_director_pf_vf,
11359 (void *)&cmd_flow_director_queue,
11360 (void *)&cmd_flow_director_queue_id,
11361 (void *)&cmd_flow_director_fd_id,
11362 (void *)&cmd_flow_director_fd_id_value,
11367 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11368 .f = cmd_flow_director_filter_parsed,
11370 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11371 "director entry on NIC",
11373 (void *)&cmd_flow_director_filter,
11374 (void *)&cmd_flow_director_port_id,
11375 (void *)&cmd_flow_director_mode,
11376 (void *)&cmd_flow_director_mode_ip,
11377 (void *)&cmd_flow_director_ops,
11378 (void *)&cmd_flow_director_flow,
11379 (void *)&cmd_flow_director_flow_type,
11380 (void *)&cmd_flow_director_ether,
11381 (void *)&cmd_flow_director_ether_type,
11382 (void *)&cmd_flow_director_flexbytes,
11383 (void *)&cmd_flow_director_flexbytes_value,
11384 (void *)&cmd_flow_director_drop,
11385 (void *)&cmd_flow_director_pf_vf,
11386 (void *)&cmd_flow_director_queue,
11387 (void *)&cmd_flow_director_queue_id,
11388 (void *)&cmd_flow_director_fd_id,
11389 (void *)&cmd_flow_director_fd_id_value,
11394 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11395 .f = cmd_flow_director_filter_parsed,
11397 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11398 "director entry on NIC",
11400 (void *)&cmd_flow_director_filter,
11401 (void *)&cmd_flow_director_port_id,
11402 (void *)&cmd_flow_director_mode,
11403 (void *)&cmd_flow_director_mode_mac_vlan,
11404 (void *)&cmd_flow_director_ops,
11405 (void *)&cmd_flow_director_mac,
11406 (void *)&cmd_flow_director_mac_addr,
11407 (void *)&cmd_flow_director_vlan,
11408 (void *)&cmd_flow_director_vlan_value,
11409 (void *)&cmd_flow_director_flexbytes,
11410 (void *)&cmd_flow_director_flexbytes_value,
11411 (void *)&cmd_flow_director_drop,
11412 (void *)&cmd_flow_director_queue,
11413 (void *)&cmd_flow_director_queue_id,
11414 (void *)&cmd_flow_director_fd_id,
11415 (void *)&cmd_flow_director_fd_id_value,
11420 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11421 .f = cmd_flow_director_filter_parsed,
11423 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11424 "director entry on NIC",
11426 (void *)&cmd_flow_director_filter,
11427 (void *)&cmd_flow_director_port_id,
11428 (void *)&cmd_flow_director_mode,
11429 (void *)&cmd_flow_director_mode_tunnel,
11430 (void *)&cmd_flow_director_ops,
11431 (void *)&cmd_flow_director_mac,
11432 (void *)&cmd_flow_director_mac_addr,
11433 (void *)&cmd_flow_director_vlan,
11434 (void *)&cmd_flow_director_vlan_value,
11435 (void *)&cmd_flow_director_tunnel,
11436 (void *)&cmd_flow_director_tunnel_type,
11437 (void *)&cmd_flow_director_tunnel_id,
11438 (void *)&cmd_flow_director_tunnel_id_value,
11439 (void *)&cmd_flow_director_flexbytes,
11440 (void *)&cmd_flow_director_flexbytes_value,
11441 (void *)&cmd_flow_director_drop,
11442 (void *)&cmd_flow_director_queue,
11443 (void *)&cmd_flow_director_queue_id,
11444 (void *)&cmd_flow_director_fd_id,
11445 (void *)&cmd_flow_director_fd_id_value,
11450 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11451 .f = cmd_flow_director_filter_parsed,
11453 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11454 "director entry on NIC",
11456 (void *)&cmd_flow_director_filter,
11457 (void *)&cmd_flow_director_port_id,
11458 (void *)&cmd_flow_director_mode,
11459 (void *)&cmd_flow_director_mode_raw,
11460 (void *)&cmd_flow_director_ops,
11461 (void *)&cmd_flow_director_flow,
11462 (void *)&cmd_flow_director_flow_type,
11463 (void *)&cmd_flow_director_drop,
11464 (void *)&cmd_flow_director_queue,
11465 (void *)&cmd_flow_director_queue_id,
11466 (void *)&cmd_flow_director_fd_id,
11467 (void *)&cmd_flow_director_fd_id_value,
11468 (void *)&cmd_flow_director_packet,
11469 (void *)&cmd_flow_director_filepath,
11474 struct cmd_flush_flow_director_result {
11475 cmdline_fixed_string_t flush_flow_director;
11479 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11480 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11481 flush_flow_director, "flush_flow_director");
11482 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11483 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11487 cmd_flush_flow_director_parsed(void *parsed_result,
11488 __attribute__((unused)) struct cmdline *cl,
11489 __attribute__((unused)) void *data)
11491 struct cmd_flow_director_result *res = parsed_result;
11494 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11496 printf("flow director is not supported on port %u.\n",
11501 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11502 RTE_ETH_FILTER_FLUSH, NULL);
11504 printf("flow director table flushing error: (%s)\n",
11508 cmdline_parse_inst_t cmd_flush_flow_director = {
11509 .f = cmd_flush_flow_director_parsed,
11511 .help_str = "flush_flow_director <port_id>: "
11512 "Flush all flow director entries of a device on NIC",
11514 (void *)&cmd_flush_flow_director_flush,
11515 (void *)&cmd_flush_flow_director_port_id,
11520 /* *** deal with flow director mask *** */
11521 struct cmd_flow_director_mask_result {
11522 cmdline_fixed_string_t flow_director_mask;
11524 cmdline_fixed_string_t mode;
11525 cmdline_fixed_string_t mode_value;
11526 cmdline_fixed_string_t vlan;
11527 uint16_t vlan_mask;
11528 cmdline_fixed_string_t src_mask;
11529 cmdline_ipaddr_t ipv4_src;
11530 cmdline_ipaddr_t ipv6_src;
11532 cmdline_fixed_string_t dst_mask;
11533 cmdline_ipaddr_t ipv4_dst;
11534 cmdline_ipaddr_t ipv6_dst;
11536 cmdline_fixed_string_t mac;
11537 uint8_t mac_addr_byte_mask;
11538 cmdline_fixed_string_t tunnel_id;
11539 uint32_t tunnel_id_mask;
11540 cmdline_fixed_string_t tunnel_type;
11541 uint8_t tunnel_type_mask;
11545 cmd_flow_director_mask_parsed(void *parsed_result,
11546 __attribute__((unused)) struct cmdline *cl,
11547 __attribute__((unused)) void *data)
11549 struct cmd_flow_director_mask_result *res = parsed_result;
11550 struct rte_eth_fdir_masks *mask;
11551 struct rte_port *port;
11553 port = &ports[res->port_id];
11554 /** Check if the port is not started **/
11555 if (port->port_status != RTE_PORT_STOPPED) {
11556 printf("Please stop port %d first\n", res->port_id);
11560 mask = &port->dev_conf.fdir_conf.mask;
11562 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11563 if (strcmp(res->mode_value, "MAC-VLAN")) {
11564 printf("Please set mode to MAC-VLAN.\n");
11568 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11569 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11570 if (strcmp(res->mode_value, "Tunnel")) {
11571 printf("Please set mode to Tunnel.\n");
11575 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11576 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11577 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11578 mask->tunnel_type_mask = res->tunnel_type_mask;
11580 if (strcmp(res->mode_value, "IP")) {
11581 printf("Please set mode to IP.\n");
11585 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11586 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11587 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11588 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11589 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11590 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11591 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11594 cmd_reconfig_device_queue(res->port_id, 1, 1);
11597 cmdline_parse_token_string_t cmd_flow_director_mask =
11598 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11599 flow_director_mask, "flow_director_mask");
11600 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11601 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11603 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11604 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11606 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11607 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11608 vlan_mask, UINT16);
11609 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11610 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11611 src_mask, "src_mask");
11612 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11613 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11615 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11616 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11618 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11619 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11621 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11622 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11623 dst_mask, "dst_mask");
11624 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11625 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11627 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11628 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11630 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11631 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11634 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11635 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11637 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11638 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11640 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11641 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11642 mode_value, "MAC-VLAN");
11643 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11644 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11645 mode_value, "Tunnel");
11646 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11647 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11649 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11650 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11651 mac_addr_byte_mask, UINT8);
11652 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11653 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11654 tunnel_type, "tunnel-type");
11655 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11656 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11657 tunnel_type_mask, UINT8);
11658 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11659 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11660 tunnel_id, "tunnel-id");
11661 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11662 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11663 tunnel_id_mask, UINT32);
11665 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11666 .f = cmd_flow_director_mask_parsed,
11668 .help_str = "flow_director_mask ... : "
11669 "Set IP mode flow director's mask on NIC",
11671 (void *)&cmd_flow_director_mask,
11672 (void *)&cmd_flow_director_mask_port_id,
11673 (void *)&cmd_flow_director_mask_mode,
11674 (void *)&cmd_flow_director_mask_mode_ip,
11675 (void *)&cmd_flow_director_mask_vlan,
11676 (void *)&cmd_flow_director_mask_vlan_value,
11677 (void *)&cmd_flow_director_mask_src,
11678 (void *)&cmd_flow_director_mask_ipv4_src,
11679 (void *)&cmd_flow_director_mask_ipv6_src,
11680 (void *)&cmd_flow_director_mask_port_src,
11681 (void *)&cmd_flow_director_mask_dst,
11682 (void *)&cmd_flow_director_mask_ipv4_dst,
11683 (void *)&cmd_flow_director_mask_ipv6_dst,
11684 (void *)&cmd_flow_director_mask_port_dst,
11689 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11690 .f = cmd_flow_director_mask_parsed,
11692 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11693 "flow director's mask on NIC",
11695 (void *)&cmd_flow_director_mask,
11696 (void *)&cmd_flow_director_mask_port_id,
11697 (void *)&cmd_flow_director_mask_mode,
11698 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11699 (void *)&cmd_flow_director_mask_vlan,
11700 (void *)&cmd_flow_director_mask_vlan_value,
11705 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11706 .f = cmd_flow_director_mask_parsed,
11708 .help_str = "flow_director_mask ... : Set tunnel mode "
11709 "flow director's mask on NIC",
11711 (void *)&cmd_flow_director_mask,
11712 (void *)&cmd_flow_director_mask_port_id,
11713 (void *)&cmd_flow_director_mask_mode,
11714 (void *)&cmd_flow_director_mask_mode_tunnel,
11715 (void *)&cmd_flow_director_mask_vlan,
11716 (void *)&cmd_flow_director_mask_vlan_value,
11717 (void *)&cmd_flow_director_mask_mac,
11718 (void *)&cmd_flow_director_mask_mac_value,
11719 (void *)&cmd_flow_director_mask_tunnel_type,
11720 (void *)&cmd_flow_director_mask_tunnel_type_value,
11721 (void *)&cmd_flow_director_mask_tunnel_id,
11722 (void *)&cmd_flow_director_mask_tunnel_id_value,
11727 /* *** deal with flow director mask on flexible payload *** */
11728 struct cmd_flow_director_flex_mask_result {
11729 cmdline_fixed_string_t flow_director_flexmask;
11731 cmdline_fixed_string_t flow;
11732 cmdline_fixed_string_t flow_type;
11733 cmdline_fixed_string_t mask;
11737 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11738 __attribute__((unused)) struct cmdline *cl,
11739 __attribute__((unused)) void *data)
11741 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11742 struct rte_eth_fdir_info fdir_info;
11743 struct rte_eth_fdir_flex_mask flex_mask;
11744 struct rte_port *port;
11745 uint64_t flow_type_mask;
11749 port = &ports[res->port_id];
11750 /** Check if the port is not started **/
11751 if (port->port_status != RTE_PORT_STOPPED) {
11752 printf("Please stop port %d first\n", res->port_id);
11756 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11757 ret = parse_flexbytes(res->mask,
11759 RTE_ETH_FDIR_MAX_FLEXLEN);
11761 printf("error: Cannot parse mask input.\n");
11765 memset(&fdir_info, 0, sizeof(fdir_info));
11766 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11767 RTE_ETH_FILTER_INFO, &fdir_info);
11769 printf("Cannot get FDir filter info\n");
11773 if (!strcmp(res->flow_type, "none")) {
11774 /* means don't specify the flow type */
11775 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11776 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11777 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11778 0, sizeof(struct rte_eth_fdir_flex_mask));
11779 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11780 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11782 sizeof(struct rte_eth_fdir_flex_mask));
11783 cmd_reconfig_device_queue(res->port_id, 1, 1);
11786 flow_type_mask = fdir_info.flow_types_mask[0];
11787 if (!strcmp(res->flow_type, "all")) {
11788 if (!flow_type_mask) {
11789 printf("No flow type supported\n");
11792 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11793 if (flow_type_mask & (1ULL << i)) {
11794 flex_mask.flow_type = i;
11795 fdir_set_flex_mask(res->port_id, &flex_mask);
11798 cmd_reconfig_device_queue(res->port_id, 1, 1);
11801 flex_mask.flow_type = str2flowtype(res->flow_type);
11802 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11803 printf("Flow type %s not supported on port %d\n",
11804 res->flow_type, res->port_id);
11807 fdir_set_flex_mask(res->port_id, &flex_mask);
11808 cmd_reconfig_device_queue(res->port_id, 1, 1);
11811 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11812 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11813 flow_director_flexmask,
11814 "flow_director_flex_mask");
11815 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11816 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11818 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11819 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11821 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11822 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11823 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11824 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11825 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11826 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11829 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11830 .f = cmd_flow_director_flex_mask_parsed,
11832 .help_str = "flow_director_flex_mask ... : "
11833 "Set flow director's flex mask on NIC",
11835 (void *)&cmd_flow_director_flexmask,
11836 (void *)&cmd_flow_director_flexmask_port_id,
11837 (void *)&cmd_flow_director_flexmask_flow,
11838 (void *)&cmd_flow_director_flexmask_flow_type,
11839 (void *)&cmd_flow_director_flexmask_mask,
11844 /* *** deal with flow director flexible payload configuration *** */
11845 struct cmd_flow_director_flexpayload_result {
11846 cmdline_fixed_string_t flow_director_flexpayload;
11848 cmdline_fixed_string_t payload_layer;
11849 cmdline_fixed_string_t payload_cfg;
11853 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11856 const char *p, *p0 = q_arg;
11858 unsigned long int_fld;
11859 char *str_fld[max_num];
11864 p = strchr(p0, '(');
11868 p0 = strchr(p, ')');
11873 if (size >= sizeof(s))
11876 snprintf(s, sizeof(s), "%.*s", size, p);
11877 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11878 if (ret < 0 || ret > max_num)
11880 for (i = 0; i < ret; i++) {
11882 int_fld = strtoul(str_fld[i], &end, 0);
11883 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11885 offsets[i] = (uint16_t)int_fld;
11891 cmd_flow_director_flxpld_parsed(void *parsed_result,
11892 __attribute__((unused)) struct cmdline *cl,
11893 __attribute__((unused)) void *data)
11895 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11896 struct rte_eth_flex_payload_cfg flex_cfg;
11897 struct rte_port *port;
11900 port = &ports[res->port_id];
11901 /** Check if the port is not started **/
11902 if (port->port_status != RTE_PORT_STOPPED) {
11903 printf("Please stop port %d first\n", res->port_id);
11907 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11909 if (!strcmp(res->payload_layer, "raw"))
11910 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11911 else if (!strcmp(res->payload_layer, "l2"))
11912 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11913 else if (!strcmp(res->payload_layer, "l3"))
11914 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11915 else if (!strcmp(res->payload_layer, "l4"))
11916 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11918 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11919 RTE_ETH_FDIR_MAX_FLEXLEN);
11921 printf("error: Cannot parse flex payload input.\n");
11925 fdir_set_flex_payload(res->port_id, &flex_cfg);
11926 cmd_reconfig_device_queue(res->port_id, 1, 1);
11929 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11930 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11931 flow_director_flexpayload,
11932 "flow_director_flex_payload");
11933 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11934 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11936 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11937 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11938 payload_layer, "raw#l2#l3#l4");
11939 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11940 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11941 payload_cfg, NULL);
11943 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11944 .f = cmd_flow_director_flxpld_parsed,
11946 .help_str = "flow_director_flexpayload ... : "
11947 "Set flow director's flex payload on NIC",
11949 (void *)&cmd_flow_director_flexpayload,
11950 (void *)&cmd_flow_director_flexpayload_port_id,
11951 (void *)&cmd_flow_director_flexpayload_payload_layer,
11952 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11957 /* Generic flow interface command. */
11958 extern cmdline_parse_inst_t cmd_flow;
11960 /* *** Classification Filters Control *** */
11961 /* *** Get symmetric hash enable per port *** */
11962 struct cmd_get_sym_hash_ena_per_port_result {
11963 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11968 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11969 __rte_unused struct cmdline *cl,
11970 __rte_unused void *data)
11972 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11973 struct rte_eth_hash_filter_info info;
11976 if (rte_eth_dev_filter_supported(res->port_id,
11977 RTE_ETH_FILTER_HASH) < 0) {
11978 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11983 memset(&info, 0, sizeof(info));
11984 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11985 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11986 RTE_ETH_FILTER_GET, &info);
11989 printf("Cannot get symmetric hash enable per port "
11990 "on port %u\n", res->port_id);
11994 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11995 "enabled" : "disabled", res->port_id);
11998 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11999 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12000 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12001 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12002 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12005 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12006 .f = cmd_get_sym_hash_per_port_parsed,
12008 .help_str = "get_sym_hash_ena_per_port <port_id>",
12010 (void *)&cmd_get_sym_hash_ena_per_port_all,
12011 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12016 /* *** Set symmetric hash enable per port *** */
12017 struct cmd_set_sym_hash_ena_per_port_result {
12018 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12019 cmdline_fixed_string_t enable;
12024 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12025 __rte_unused struct cmdline *cl,
12026 __rte_unused void *data)
12028 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12029 struct rte_eth_hash_filter_info info;
12032 if (rte_eth_dev_filter_supported(res->port_id,
12033 RTE_ETH_FILTER_HASH) < 0) {
12034 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12039 memset(&info, 0, sizeof(info));
12040 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12041 if (!strcmp(res->enable, "enable"))
12042 info.info.enable = 1;
12043 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12044 RTE_ETH_FILTER_SET, &info);
12046 printf("Cannot set symmetric hash enable per port on "
12047 "port %u\n", res->port_id);
12050 printf("Symmetric hash has been set to %s on port %u\n",
12051 res->enable, res->port_id);
12054 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12055 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12056 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12057 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12058 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12060 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12061 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12062 enable, "enable#disable");
12064 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12065 .f = cmd_set_sym_hash_per_port_parsed,
12067 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12069 (void *)&cmd_set_sym_hash_ena_per_port_all,
12070 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12071 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12076 /* Get global config of hash function */
12077 struct cmd_get_hash_global_config_result {
12078 cmdline_fixed_string_t get_hash_global_config;
12083 flowtype_to_str(uint16_t ftype)
12089 } ftype_table[] = {
12090 {"ipv4", RTE_ETH_FLOW_IPV4},
12091 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12092 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12093 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12094 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12095 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12096 {"ipv6", RTE_ETH_FLOW_IPV6},
12097 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12098 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12099 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12100 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12101 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12102 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12103 {"port", RTE_ETH_FLOW_PORT},
12104 {"vxlan", RTE_ETH_FLOW_VXLAN},
12105 {"geneve", RTE_ETH_FLOW_GENEVE},
12106 {"nvgre", RTE_ETH_FLOW_NVGRE},
12107 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12110 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12111 if (ftype_table[i].ftype == ftype)
12112 return ftype_table[i].str;
12119 cmd_get_hash_global_config_parsed(void *parsed_result,
12120 __rte_unused struct cmdline *cl,
12121 __rte_unused void *data)
12123 struct cmd_get_hash_global_config_result *res = parsed_result;
12124 struct rte_eth_hash_filter_info info;
12125 uint32_t idx, offset;
12130 if (rte_eth_dev_filter_supported(res->port_id,
12131 RTE_ETH_FILTER_HASH) < 0) {
12132 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12137 memset(&info, 0, sizeof(info));
12138 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12139 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12140 RTE_ETH_FILTER_GET, &info);
12142 printf("Cannot get hash global configurations by port %d\n",
12147 switch (info.info.global_conf.hash_func) {
12148 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12149 printf("Hash function is Toeplitz\n");
12151 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12152 printf("Hash function is Simple XOR\n");
12155 printf("Unknown hash function\n");
12159 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12160 idx = i / UINT64_BIT;
12161 offset = i % UINT64_BIT;
12162 if (!(info.info.global_conf.valid_bit_mask[idx] &
12165 str = flowtype_to_str(i);
12168 printf("Symmetric hash is %s globally for flow type %s "
12170 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12171 (1ULL << offset)) ? "enabled" : "disabled"), str,
12176 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12177 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12178 get_hash_global_config, "get_hash_global_config");
12179 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12180 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12183 cmdline_parse_inst_t cmd_get_hash_global_config = {
12184 .f = cmd_get_hash_global_config_parsed,
12186 .help_str = "get_hash_global_config <port_id>",
12188 (void *)&cmd_get_hash_global_config_all,
12189 (void *)&cmd_get_hash_global_config_port_id,
12194 /* Set global config of hash function */
12195 struct cmd_set_hash_global_config_result {
12196 cmdline_fixed_string_t set_hash_global_config;
12198 cmdline_fixed_string_t hash_func;
12199 cmdline_fixed_string_t flow_type;
12200 cmdline_fixed_string_t enable;
12204 cmd_set_hash_global_config_parsed(void *parsed_result,
12205 __rte_unused struct cmdline *cl,
12206 __rte_unused void *data)
12208 struct cmd_set_hash_global_config_result *res = parsed_result;
12209 struct rte_eth_hash_filter_info info;
12210 uint32_t ftype, idx, offset;
12213 if (rte_eth_dev_filter_supported(res->port_id,
12214 RTE_ETH_FILTER_HASH) < 0) {
12215 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12219 memset(&info, 0, sizeof(info));
12220 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12221 if (!strcmp(res->hash_func, "toeplitz"))
12222 info.info.global_conf.hash_func =
12223 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12224 else if (!strcmp(res->hash_func, "simple_xor"))
12225 info.info.global_conf.hash_func =
12226 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12227 else if (!strcmp(res->hash_func, "default"))
12228 info.info.global_conf.hash_func =
12229 RTE_ETH_HASH_FUNCTION_DEFAULT;
12231 ftype = str2flowtype(res->flow_type);
12232 idx = ftype / UINT64_BIT;
12233 offset = ftype % UINT64_BIT;
12234 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12235 if (!strcmp(res->enable, "enable"))
12236 info.info.global_conf.sym_hash_enable_mask[idx] |=
12238 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12239 RTE_ETH_FILTER_SET, &info);
12241 printf("Cannot set global hash configurations by port %d\n",
12244 printf("Global hash configurations have been set "
12245 "successfully by port %d\n", res->port_id);
12248 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12249 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12250 set_hash_global_config, "set_hash_global_config");
12251 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12252 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12254 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12255 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12256 hash_func, "toeplitz#simple_xor#default");
12257 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12258 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12260 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12261 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12262 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12263 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12264 enable, "enable#disable");
12266 cmdline_parse_inst_t cmd_set_hash_global_config = {
12267 .f = cmd_set_hash_global_config_parsed,
12269 .help_str = "set_hash_global_config <port_id> "
12270 "toeplitz|simple_xor|default "
12271 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12272 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12273 "l2_payload enable|disable",
12275 (void *)&cmd_set_hash_global_config_all,
12276 (void *)&cmd_set_hash_global_config_port_id,
12277 (void *)&cmd_set_hash_global_config_hash_func,
12278 (void *)&cmd_set_hash_global_config_flow_type,
12279 (void *)&cmd_set_hash_global_config_enable,
12284 /* Set hash input set */
12285 struct cmd_set_hash_input_set_result {
12286 cmdline_fixed_string_t set_hash_input_set;
12288 cmdline_fixed_string_t flow_type;
12289 cmdline_fixed_string_t inset_field;
12290 cmdline_fixed_string_t select;
12293 static enum rte_eth_input_set_field
12294 str2inset(char *string)
12298 static const struct {
12300 enum rte_eth_input_set_field inset;
12301 } inset_table[] = {
12302 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12303 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12304 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12305 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12306 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12307 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12308 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12309 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12310 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12311 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12312 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12313 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12314 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12315 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12316 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12317 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12318 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12319 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12320 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12321 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12322 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12323 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12324 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12325 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12326 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12327 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12328 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12329 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12330 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12331 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12332 {"none", RTE_ETH_INPUT_SET_NONE},
12335 for (i = 0; i < RTE_DIM(inset_table); i++) {
12336 if (!strcmp(string, inset_table[i].str))
12337 return inset_table[i].inset;
12340 return RTE_ETH_INPUT_SET_UNKNOWN;
12344 cmd_set_hash_input_set_parsed(void *parsed_result,
12345 __rte_unused struct cmdline *cl,
12346 __rte_unused void *data)
12348 struct cmd_set_hash_input_set_result *res = parsed_result;
12349 struct rte_eth_hash_filter_info info;
12351 memset(&info, 0, sizeof(info));
12352 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12353 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12354 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12355 info.info.input_set_conf.inset_size = 1;
12356 if (!strcmp(res->select, "select"))
12357 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12358 else if (!strcmp(res->select, "add"))
12359 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12360 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12361 RTE_ETH_FILTER_SET, &info);
12364 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12365 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12366 set_hash_input_set, "set_hash_input_set");
12367 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12368 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12370 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12371 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12373 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12374 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12376 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12377 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12378 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12379 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12380 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12382 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12383 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12384 select, "select#add");
12386 cmdline_parse_inst_t cmd_set_hash_input_set = {
12387 .f = cmd_set_hash_input_set_parsed,
12389 .help_str = "set_hash_input_set <port_id> "
12390 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12391 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12392 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12393 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12394 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12395 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12396 "fld-7th|fld-8th|none select|add",
12398 (void *)&cmd_set_hash_input_set_cmd,
12399 (void *)&cmd_set_hash_input_set_port_id,
12400 (void *)&cmd_set_hash_input_set_flow_type,
12401 (void *)&cmd_set_hash_input_set_field,
12402 (void *)&cmd_set_hash_input_set_select,
12407 /* Set flow director input set */
12408 struct cmd_set_fdir_input_set_result {
12409 cmdline_fixed_string_t set_fdir_input_set;
12411 cmdline_fixed_string_t flow_type;
12412 cmdline_fixed_string_t inset_field;
12413 cmdline_fixed_string_t select;
12417 cmd_set_fdir_input_set_parsed(void *parsed_result,
12418 __rte_unused struct cmdline *cl,
12419 __rte_unused void *data)
12421 struct cmd_set_fdir_input_set_result *res = parsed_result;
12422 struct rte_eth_fdir_filter_info info;
12424 memset(&info, 0, sizeof(info));
12425 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12426 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12427 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12428 info.info.input_set_conf.inset_size = 1;
12429 if (!strcmp(res->select, "select"))
12430 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12431 else if (!strcmp(res->select, "add"))
12432 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12433 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12434 RTE_ETH_FILTER_SET, &info);
12437 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12438 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12439 set_fdir_input_set, "set_fdir_input_set");
12440 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12441 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12443 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12444 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12446 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12447 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12448 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12449 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12451 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12452 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12453 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12454 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12455 "sctp-veri-tag#none");
12456 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12457 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12458 select, "select#add");
12460 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12461 .f = cmd_set_fdir_input_set_parsed,
12463 .help_str = "set_fdir_input_set <port_id> "
12464 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12465 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12466 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12467 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12468 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12469 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12470 "sctp-veri-tag|none select|add",
12472 (void *)&cmd_set_fdir_input_set_cmd,
12473 (void *)&cmd_set_fdir_input_set_port_id,
12474 (void *)&cmd_set_fdir_input_set_flow_type,
12475 (void *)&cmd_set_fdir_input_set_field,
12476 (void *)&cmd_set_fdir_input_set_select,
12481 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12482 struct cmd_mcast_addr_result {
12483 cmdline_fixed_string_t mcast_addr_cmd;
12484 cmdline_fixed_string_t what;
12486 struct rte_ether_addr mc_addr;
12489 static void cmd_mcast_addr_parsed(void *parsed_result,
12490 __attribute__((unused)) struct cmdline *cl,
12491 __attribute__((unused)) void *data)
12493 struct cmd_mcast_addr_result *res = parsed_result;
12495 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12496 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12497 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12498 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12499 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12502 if (strcmp(res->what, "add") == 0)
12503 mcast_addr_add(res->port_num, &res->mc_addr);
12505 mcast_addr_remove(res->port_num, &res->mc_addr);
12508 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12509 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12510 mcast_addr_cmd, "mcast_addr");
12511 cmdline_parse_token_string_t cmd_mcast_addr_what =
12512 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12514 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12515 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12516 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12517 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12519 cmdline_parse_inst_t cmd_mcast_addr = {
12520 .f = cmd_mcast_addr_parsed,
12522 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12523 "Add/Remove multicast MAC address on port_id",
12525 (void *)&cmd_mcast_addr_cmd,
12526 (void *)&cmd_mcast_addr_what,
12527 (void *)&cmd_mcast_addr_portnum,
12528 (void *)&cmd_mcast_addr_addr,
12533 /* l2 tunnel config
12534 * only support E-tag now.
12537 /* Ether type config */
12538 struct cmd_config_l2_tunnel_eth_type_result {
12539 cmdline_fixed_string_t port;
12540 cmdline_fixed_string_t config;
12541 cmdline_fixed_string_t all;
12543 cmdline_fixed_string_t l2_tunnel;
12544 cmdline_fixed_string_t l2_tunnel_type;
12545 cmdline_fixed_string_t eth_type;
12546 uint16_t eth_type_val;
12549 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12550 TOKEN_STRING_INITIALIZER
12551 (struct cmd_config_l2_tunnel_eth_type_result,
12553 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12554 TOKEN_STRING_INITIALIZER
12555 (struct cmd_config_l2_tunnel_eth_type_result,
12557 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12558 TOKEN_STRING_INITIALIZER
12559 (struct cmd_config_l2_tunnel_eth_type_result,
12561 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12562 TOKEN_NUM_INITIALIZER
12563 (struct cmd_config_l2_tunnel_eth_type_result,
12565 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12566 TOKEN_STRING_INITIALIZER
12567 (struct cmd_config_l2_tunnel_eth_type_result,
12568 l2_tunnel, "l2-tunnel");
12569 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12570 TOKEN_STRING_INITIALIZER
12571 (struct cmd_config_l2_tunnel_eth_type_result,
12572 l2_tunnel_type, "E-tag");
12573 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12574 TOKEN_STRING_INITIALIZER
12575 (struct cmd_config_l2_tunnel_eth_type_result,
12576 eth_type, "ether-type");
12577 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12578 TOKEN_NUM_INITIALIZER
12579 (struct cmd_config_l2_tunnel_eth_type_result,
12580 eth_type_val, UINT16);
12582 static enum rte_eth_tunnel_type
12583 str2fdir_l2_tunnel_type(char *string)
12587 static const struct {
12589 enum rte_eth_tunnel_type type;
12590 } l2_tunnel_type_str[] = {
12591 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12594 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12595 if (!strcmp(l2_tunnel_type_str[i].str, string))
12596 return l2_tunnel_type_str[i].type;
12598 return RTE_TUNNEL_TYPE_NONE;
12601 /* ether type config for all ports */
12603 cmd_config_l2_tunnel_eth_type_all_parsed
12604 (void *parsed_result,
12605 __attribute__((unused)) struct cmdline *cl,
12606 __attribute__((unused)) void *data)
12608 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12609 struct rte_eth_l2_tunnel_conf entry;
12612 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12613 entry.ether_type = res->eth_type_val;
12615 RTE_ETH_FOREACH_DEV(pid) {
12616 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12620 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12621 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12623 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12625 (void *)&cmd_config_l2_tunnel_eth_type_port,
12626 (void *)&cmd_config_l2_tunnel_eth_type_config,
12627 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12628 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12629 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12630 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12631 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12636 /* ether type config for a specific port */
12638 cmd_config_l2_tunnel_eth_type_specific_parsed(
12639 void *parsed_result,
12640 __attribute__((unused)) struct cmdline *cl,
12641 __attribute__((unused)) void *data)
12643 struct cmd_config_l2_tunnel_eth_type_result *res =
12645 struct rte_eth_l2_tunnel_conf entry;
12647 if (port_id_is_invalid(res->id, ENABLED_WARN))
12650 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12651 entry.ether_type = res->eth_type_val;
12653 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12656 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12657 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12659 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12661 (void *)&cmd_config_l2_tunnel_eth_type_port,
12662 (void *)&cmd_config_l2_tunnel_eth_type_config,
12663 (void *)&cmd_config_l2_tunnel_eth_type_id,
12664 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12665 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12666 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12667 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12672 /* Enable/disable l2 tunnel */
12673 struct cmd_config_l2_tunnel_en_dis_result {
12674 cmdline_fixed_string_t port;
12675 cmdline_fixed_string_t config;
12676 cmdline_fixed_string_t all;
12678 cmdline_fixed_string_t l2_tunnel;
12679 cmdline_fixed_string_t l2_tunnel_type;
12680 cmdline_fixed_string_t en_dis;
12683 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12684 TOKEN_STRING_INITIALIZER
12685 (struct cmd_config_l2_tunnel_en_dis_result,
12687 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12688 TOKEN_STRING_INITIALIZER
12689 (struct cmd_config_l2_tunnel_en_dis_result,
12691 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12692 TOKEN_STRING_INITIALIZER
12693 (struct cmd_config_l2_tunnel_en_dis_result,
12695 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12696 TOKEN_NUM_INITIALIZER
12697 (struct cmd_config_l2_tunnel_en_dis_result,
12699 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12700 TOKEN_STRING_INITIALIZER
12701 (struct cmd_config_l2_tunnel_en_dis_result,
12702 l2_tunnel, "l2-tunnel");
12703 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12704 TOKEN_STRING_INITIALIZER
12705 (struct cmd_config_l2_tunnel_en_dis_result,
12706 l2_tunnel_type, "E-tag");
12707 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12708 TOKEN_STRING_INITIALIZER
12709 (struct cmd_config_l2_tunnel_en_dis_result,
12710 en_dis, "enable#disable");
12712 /* enable/disable l2 tunnel for all ports */
12714 cmd_config_l2_tunnel_en_dis_all_parsed(
12715 void *parsed_result,
12716 __attribute__((unused)) struct cmdline *cl,
12717 __attribute__((unused)) void *data)
12719 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12720 struct rte_eth_l2_tunnel_conf entry;
12724 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12726 if (!strcmp("enable", res->en_dis))
12731 RTE_ETH_FOREACH_DEV(pid) {
12732 rte_eth_dev_l2_tunnel_offload_set(pid,
12734 ETH_L2_TUNNEL_ENABLE_MASK,
12739 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12740 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12742 .help_str = "port config all l2-tunnel E-tag enable|disable",
12744 (void *)&cmd_config_l2_tunnel_en_dis_port,
12745 (void *)&cmd_config_l2_tunnel_en_dis_config,
12746 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12747 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12748 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12749 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12754 /* enable/disable l2 tunnel for a port */
12756 cmd_config_l2_tunnel_en_dis_specific_parsed(
12757 void *parsed_result,
12758 __attribute__((unused)) struct cmdline *cl,
12759 __attribute__((unused)) void *data)
12761 struct cmd_config_l2_tunnel_en_dis_result *res =
12763 struct rte_eth_l2_tunnel_conf entry;
12765 if (port_id_is_invalid(res->id, ENABLED_WARN))
12768 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12770 if (!strcmp("enable", res->en_dis))
12771 rte_eth_dev_l2_tunnel_offload_set(res->id,
12773 ETH_L2_TUNNEL_ENABLE_MASK,
12776 rte_eth_dev_l2_tunnel_offload_set(res->id,
12778 ETH_L2_TUNNEL_ENABLE_MASK,
12782 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12783 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12785 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12787 (void *)&cmd_config_l2_tunnel_en_dis_port,
12788 (void *)&cmd_config_l2_tunnel_en_dis_config,
12789 (void *)&cmd_config_l2_tunnel_en_dis_id,
12790 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12791 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12792 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12797 /* E-tag configuration */
12799 /* Common result structure for all E-tag configuration */
12800 struct cmd_config_e_tag_result {
12801 cmdline_fixed_string_t e_tag;
12802 cmdline_fixed_string_t set;
12803 cmdline_fixed_string_t insertion;
12804 cmdline_fixed_string_t stripping;
12805 cmdline_fixed_string_t forwarding;
12806 cmdline_fixed_string_t filter;
12807 cmdline_fixed_string_t add;
12808 cmdline_fixed_string_t del;
12809 cmdline_fixed_string_t on;
12810 cmdline_fixed_string_t off;
12811 cmdline_fixed_string_t on_off;
12812 cmdline_fixed_string_t port_tag_id;
12813 uint32_t port_tag_id_val;
12814 cmdline_fixed_string_t e_tag_id;
12815 uint16_t e_tag_id_val;
12816 cmdline_fixed_string_t dst_pool;
12817 uint8_t dst_pool_val;
12818 cmdline_fixed_string_t port;
12820 cmdline_fixed_string_t vf;
12824 /* Common CLI fields for all E-tag configuration */
12825 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12826 TOKEN_STRING_INITIALIZER
12827 (struct cmd_config_e_tag_result,
12829 cmdline_parse_token_string_t cmd_config_e_tag_set =
12830 TOKEN_STRING_INITIALIZER
12831 (struct cmd_config_e_tag_result,
12833 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12834 TOKEN_STRING_INITIALIZER
12835 (struct cmd_config_e_tag_result,
12836 insertion, "insertion");
12837 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12838 TOKEN_STRING_INITIALIZER
12839 (struct cmd_config_e_tag_result,
12840 stripping, "stripping");
12841 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12842 TOKEN_STRING_INITIALIZER
12843 (struct cmd_config_e_tag_result,
12844 forwarding, "forwarding");
12845 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12846 TOKEN_STRING_INITIALIZER
12847 (struct cmd_config_e_tag_result,
12849 cmdline_parse_token_string_t cmd_config_e_tag_add =
12850 TOKEN_STRING_INITIALIZER
12851 (struct cmd_config_e_tag_result,
12853 cmdline_parse_token_string_t cmd_config_e_tag_del =
12854 TOKEN_STRING_INITIALIZER
12855 (struct cmd_config_e_tag_result,
12857 cmdline_parse_token_string_t cmd_config_e_tag_on =
12858 TOKEN_STRING_INITIALIZER
12859 (struct cmd_config_e_tag_result,
12861 cmdline_parse_token_string_t cmd_config_e_tag_off =
12862 TOKEN_STRING_INITIALIZER
12863 (struct cmd_config_e_tag_result,
12865 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12866 TOKEN_STRING_INITIALIZER
12867 (struct cmd_config_e_tag_result,
12869 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12870 TOKEN_STRING_INITIALIZER
12871 (struct cmd_config_e_tag_result,
12872 port_tag_id, "port-tag-id");
12873 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12874 TOKEN_NUM_INITIALIZER
12875 (struct cmd_config_e_tag_result,
12876 port_tag_id_val, UINT32);
12877 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12878 TOKEN_STRING_INITIALIZER
12879 (struct cmd_config_e_tag_result,
12880 e_tag_id, "e-tag-id");
12881 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12882 TOKEN_NUM_INITIALIZER
12883 (struct cmd_config_e_tag_result,
12884 e_tag_id_val, UINT16);
12885 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12886 TOKEN_STRING_INITIALIZER
12887 (struct cmd_config_e_tag_result,
12888 dst_pool, "dst-pool");
12889 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12890 TOKEN_NUM_INITIALIZER
12891 (struct cmd_config_e_tag_result,
12892 dst_pool_val, UINT8);
12893 cmdline_parse_token_string_t cmd_config_e_tag_port =
12894 TOKEN_STRING_INITIALIZER
12895 (struct cmd_config_e_tag_result,
12897 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12898 TOKEN_NUM_INITIALIZER
12899 (struct cmd_config_e_tag_result,
12901 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12902 TOKEN_STRING_INITIALIZER
12903 (struct cmd_config_e_tag_result,
12905 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12906 TOKEN_NUM_INITIALIZER
12907 (struct cmd_config_e_tag_result,
12910 /* E-tag insertion configuration */
12912 cmd_config_e_tag_insertion_en_parsed(
12913 void *parsed_result,
12914 __attribute__((unused)) struct cmdline *cl,
12915 __attribute__((unused)) void *data)
12917 struct cmd_config_e_tag_result *res =
12919 struct rte_eth_l2_tunnel_conf entry;
12921 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12924 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12925 entry.tunnel_id = res->port_tag_id_val;
12926 entry.vf_id = res->vf_id;
12927 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12929 ETH_L2_TUNNEL_INSERTION_MASK,
12934 cmd_config_e_tag_insertion_dis_parsed(
12935 void *parsed_result,
12936 __attribute__((unused)) struct cmdline *cl,
12937 __attribute__((unused)) void *data)
12939 struct cmd_config_e_tag_result *res =
12941 struct rte_eth_l2_tunnel_conf entry;
12943 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12946 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12947 entry.vf_id = res->vf_id;
12949 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12951 ETH_L2_TUNNEL_INSERTION_MASK,
12955 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12956 .f = cmd_config_e_tag_insertion_en_parsed,
12958 .help_str = "E-tag ... : E-tag insertion enable",
12960 (void *)&cmd_config_e_tag_e_tag,
12961 (void *)&cmd_config_e_tag_set,
12962 (void *)&cmd_config_e_tag_insertion,
12963 (void *)&cmd_config_e_tag_on,
12964 (void *)&cmd_config_e_tag_port_tag_id,
12965 (void *)&cmd_config_e_tag_port_tag_id_val,
12966 (void *)&cmd_config_e_tag_port,
12967 (void *)&cmd_config_e_tag_port_id,
12968 (void *)&cmd_config_e_tag_vf,
12969 (void *)&cmd_config_e_tag_vf_id,
12974 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12975 .f = cmd_config_e_tag_insertion_dis_parsed,
12977 .help_str = "E-tag ... : E-tag insertion disable",
12979 (void *)&cmd_config_e_tag_e_tag,
12980 (void *)&cmd_config_e_tag_set,
12981 (void *)&cmd_config_e_tag_insertion,
12982 (void *)&cmd_config_e_tag_off,
12983 (void *)&cmd_config_e_tag_port,
12984 (void *)&cmd_config_e_tag_port_id,
12985 (void *)&cmd_config_e_tag_vf,
12986 (void *)&cmd_config_e_tag_vf_id,
12991 /* E-tag stripping configuration */
12993 cmd_config_e_tag_stripping_parsed(
12994 void *parsed_result,
12995 __attribute__((unused)) struct cmdline *cl,
12996 __attribute__((unused)) void *data)
12998 struct cmd_config_e_tag_result *res =
13000 struct rte_eth_l2_tunnel_conf entry;
13002 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13005 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13007 if (!strcmp(res->on_off, "on"))
13008 rte_eth_dev_l2_tunnel_offload_set
13011 ETH_L2_TUNNEL_STRIPPING_MASK,
13014 rte_eth_dev_l2_tunnel_offload_set
13017 ETH_L2_TUNNEL_STRIPPING_MASK,
13021 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13022 .f = cmd_config_e_tag_stripping_parsed,
13024 .help_str = "E-tag ... : E-tag stripping enable/disable",
13026 (void *)&cmd_config_e_tag_e_tag,
13027 (void *)&cmd_config_e_tag_set,
13028 (void *)&cmd_config_e_tag_stripping,
13029 (void *)&cmd_config_e_tag_on_off,
13030 (void *)&cmd_config_e_tag_port,
13031 (void *)&cmd_config_e_tag_port_id,
13036 /* E-tag forwarding configuration */
13038 cmd_config_e_tag_forwarding_parsed(
13039 void *parsed_result,
13040 __attribute__((unused)) struct cmdline *cl,
13041 __attribute__((unused)) void *data)
13043 struct cmd_config_e_tag_result *res = parsed_result;
13044 struct rte_eth_l2_tunnel_conf entry;
13046 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13049 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13051 if (!strcmp(res->on_off, "on"))
13052 rte_eth_dev_l2_tunnel_offload_set
13055 ETH_L2_TUNNEL_FORWARDING_MASK,
13058 rte_eth_dev_l2_tunnel_offload_set
13061 ETH_L2_TUNNEL_FORWARDING_MASK,
13065 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13066 .f = cmd_config_e_tag_forwarding_parsed,
13068 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13070 (void *)&cmd_config_e_tag_e_tag,
13071 (void *)&cmd_config_e_tag_set,
13072 (void *)&cmd_config_e_tag_forwarding,
13073 (void *)&cmd_config_e_tag_on_off,
13074 (void *)&cmd_config_e_tag_port,
13075 (void *)&cmd_config_e_tag_port_id,
13080 /* E-tag filter configuration */
13082 cmd_config_e_tag_filter_add_parsed(
13083 void *parsed_result,
13084 __attribute__((unused)) struct cmdline *cl,
13085 __attribute__((unused)) void *data)
13087 struct cmd_config_e_tag_result *res = parsed_result;
13088 struct rte_eth_l2_tunnel_conf entry;
13091 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13094 if (res->e_tag_id_val > 0x3fff) {
13095 printf("e-tag-id must be equal or less than 0x3fff.\n");
13099 ret = rte_eth_dev_filter_supported(res->port_id,
13100 RTE_ETH_FILTER_L2_TUNNEL);
13102 printf("E-tag filter is not supported on port %u.\n",
13107 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13108 entry.tunnel_id = res->e_tag_id_val;
13109 entry.pool = res->dst_pool_val;
13111 ret = rte_eth_dev_filter_ctrl(res->port_id,
13112 RTE_ETH_FILTER_L2_TUNNEL,
13113 RTE_ETH_FILTER_ADD,
13116 printf("E-tag filter programming error: (%s)\n",
13120 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13121 .f = cmd_config_e_tag_filter_add_parsed,
13123 .help_str = "E-tag ... : E-tag filter add",
13125 (void *)&cmd_config_e_tag_e_tag,
13126 (void *)&cmd_config_e_tag_set,
13127 (void *)&cmd_config_e_tag_filter,
13128 (void *)&cmd_config_e_tag_add,
13129 (void *)&cmd_config_e_tag_e_tag_id,
13130 (void *)&cmd_config_e_tag_e_tag_id_val,
13131 (void *)&cmd_config_e_tag_dst_pool,
13132 (void *)&cmd_config_e_tag_dst_pool_val,
13133 (void *)&cmd_config_e_tag_port,
13134 (void *)&cmd_config_e_tag_port_id,
13140 cmd_config_e_tag_filter_del_parsed(
13141 void *parsed_result,
13142 __attribute__((unused)) struct cmdline *cl,
13143 __attribute__((unused)) void *data)
13145 struct cmd_config_e_tag_result *res = parsed_result;
13146 struct rte_eth_l2_tunnel_conf entry;
13149 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13152 if (res->e_tag_id_val > 0x3fff) {
13153 printf("e-tag-id must be less than 0x3fff.\n");
13157 ret = rte_eth_dev_filter_supported(res->port_id,
13158 RTE_ETH_FILTER_L2_TUNNEL);
13160 printf("E-tag filter is not supported on port %u.\n",
13165 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13166 entry.tunnel_id = res->e_tag_id_val;
13168 ret = rte_eth_dev_filter_ctrl(res->port_id,
13169 RTE_ETH_FILTER_L2_TUNNEL,
13170 RTE_ETH_FILTER_DELETE,
13173 printf("E-tag filter programming error: (%s)\n",
13177 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13178 .f = cmd_config_e_tag_filter_del_parsed,
13180 .help_str = "E-tag ... : E-tag filter delete",
13182 (void *)&cmd_config_e_tag_e_tag,
13183 (void *)&cmd_config_e_tag_set,
13184 (void *)&cmd_config_e_tag_filter,
13185 (void *)&cmd_config_e_tag_del,
13186 (void *)&cmd_config_e_tag_e_tag_id,
13187 (void *)&cmd_config_e_tag_e_tag_id_val,
13188 (void *)&cmd_config_e_tag_port,
13189 (void *)&cmd_config_e_tag_port_id,
13194 /* vf vlan anti spoof configuration */
13196 /* Common result structure for vf vlan anti spoof */
13197 struct cmd_vf_vlan_anti_spoof_result {
13198 cmdline_fixed_string_t set;
13199 cmdline_fixed_string_t vf;
13200 cmdline_fixed_string_t vlan;
13201 cmdline_fixed_string_t antispoof;
13204 cmdline_fixed_string_t on_off;
13207 /* Common CLI fields for vf vlan anti spoof enable disable */
13208 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13209 TOKEN_STRING_INITIALIZER
13210 (struct cmd_vf_vlan_anti_spoof_result,
13212 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13213 TOKEN_STRING_INITIALIZER
13214 (struct cmd_vf_vlan_anti_spoof_result,
13216 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13217 TOKEN_STRING_INITIALIZER
13218 (struct cmd_vf_vlan_anti_spoof_result,
13220 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13221 TOKEN_STRING_INITIALIZER
13222 (struct cmd_vf_vlan_anti_spoof_result,
13223 antispoof, "antispoof");
13224 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13225 TOKEN_NUM_INITIALIZER
13226 (struct cmd_vf_vlan_anti_spoof_result,
13228 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13229 TOKEN_NUM_INITIALIZER
13230 (struct cmd_vf_vlan_anti_spoof_result,
13232 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13233 TOKEN_STRING_INITIALIZER
13234 (struct cmd_vf_vlan_anti_spoof_result,
13238 cmd_set_vf_vlan_anti_spoof_parsed(
13239 void *parsed_result,
13240 __attribute__((unused)) struct cmdline *cl,
13241 __attribute__((unused)) void *data)
13243 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13244 int ret = -ENOTSUP;
13246 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13248 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13251 #ifdef RTE_LIBRTE_IXGBE_PMD
13252 if (ret == -ENOTSUP)
13253 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13254 res->vf_id, is_on);
13256 #ifdef RTE_LIBRTE_I40E_PMD
13257 if (ret == -ENOTSUP)
13258 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13259 res->vf_id, is_on);
13261 #ifdef RTE_LIBRTE_BNXT_PMD
13262 if (ret == -ENOTSUP)
13263 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13264 res->vf_id, is_on);
13271 printf("invalid vf_id %d\n", res->vf_id);
13274 printf("invalid port_id %d\n", res->port_id);
13277 printf("function not implemented\n");
13280 printf("programming error: (%s)\n", strerror(-ret));
13284 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13285 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13287 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13289 (void *)&cmd_vf_vlan_anti_spoof_set,
13290 (void *)&cmd_vf_vlan_anti_spoof_vf,
13291 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13292 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13293 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13294 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13295 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13300 /* vf mac anti spoof configuration */
13302 /* Common result structure for vf mac anti spoof */
13303 struct cmd_vf_mac_anti_spoof_result {
13304 cmdline_fixed_string_t set;
13305 cmdline_fixed_string_t vf;
13306 cmdline_fixed_string_t mac;
13307 cmdline_fixed_string_t antispoof;
13310 cmdline_fixed_string_t on_off;
13313 /* Common CLI fields for vf mac anti spoof enable disable */
13314 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13315 TOKEN_STRING_INITIALIZER
13316 (struct cmd_vf_mac_anti_spoof_result,
13318 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13319 TOKEN_STRING_INITIALIZER
13320 (struct cmd_vf_mac_anti_spoof_result,
13322 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13323 TOKEN_STRING_INITIALIZER
13324 (struct cmd_vf_mac_anti_spoof_result,
13326 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13327 TOKEN_STRING_INITIALIZER
13328 (struct cmd_vf_mac_anti_spoof_result,
13329 antispoof, "antispoof");
13330 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13331 TOKEN_NUM_INITIALIZER
13332 (struct cmd_vf_mac_anti_spoof_result,
13334 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13335 TOKEN_NUM_INITIALIZER
13336 (struct cmd_vf_mac_anti_spoof_result,
13338 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13339 TOKEN_STRING_INITIALIZER
13340 (struct cmd_vf_mac_anti_spoof_result,
13344 cmd_set_vf_mac_anti_spoof_parsed(
13345 void *parsed_result,
13346 __attribute__((unused)) struct cmdline *cl,
13347 __attribute__((unused)) void *data)
13349 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13350 int ret = -ENOTSUP;
13352 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13354 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13357 #ifdef RTE_LIBRTE_IXGBE_PMD
13358 if (ret == -ENOTSUP)
13359 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13360 res->vf_id, is_on);
13362 #ifdef RTE_LIBRTE_I40E_PMD
13363 if (ret == -ENOTSUP)
13364 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13365 res->vf_id, is_on);
13367 #ifdef RTE_LIBRTE_BNXT_PMD
13368 if (ret == -ENOTSUP)
13369 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13370 res->vf_id, is_on);
13377 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13380 printf("invalid port_id %d\n", res->port_id);
13383 printf("function not implemented\n");
13386 printf("programming error: (%s)\n", strerror(-ret));
13390 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13391 .f = cmd_set_vf_mac_anti_spoof_parsed,
13393 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13395 (void *)&cmd_vf_mac_anti_spoof_set,
13396 (void *)&cmd_vf_mac_anti_spoof_vf,
13397 (void *)&cmd_vf_mac_anti_spoof_mac,
13398 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13399 (void *)&cmd_vf_mac_anti_spoof_port_id,
13400 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13401 (void *)&cmd_vf_mac_anti_spoof_on_off,
13406 /* vf vlan strip queue configuration */
13408 /* Common result structure for vf mac anti spoof */
13409 struct cmd_vf_vlan_stripq_result {
13410 cmdline_fixed_string_t set;
13411 cmdline_fixed_string_t vf;
13412 cmdline_fixed_string_t vlan;
13413 cmdline_fixed_string_t stripq;
13416 cmdline_fixed_string_t on_off;
13419 /* Common CLI fields for vf vlan strip enable disable */
13420 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13421 TOKEN_STRING_INITIALIZER
13422 (struct cmd_vf_vlan_stripq_result,
13424 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13425 TOKEN_STRING_INITIALIZER
13426 (struct cmd_vf_vlan_stripq_result,
13428 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13429 TOKEN_STRING_INITIALIZER
13430 (struct cmd_vf_vlan_stripq_result,
13432 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13433 TOKEN_STRING_INITIALIZER
13434 (struct cmd_vf_vlan_stripq_result,
13436 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13437 TOKEN_NUM_INITIALIZER
13438 (struct cmd_vf_vlan_stripq_result,
13440 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13441 TOKEN_NUM_INITIALIZER
13442 (struct cmd_vf_vlan_stripq_result,
13444 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13445 TOKEN_STRING_INITIALIZER
13446 (struct cmd_vf_vlan_stripq_result,
13450 cmd_set_vf_vlan_stripq_parsed(
13451 void *parsed_result,
13452 __attribute__((unused)) struct cmdline *cl,
13453 __attribute__((unused)) void *data)
13455 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13456 int ret = -ENOTSUP;
13458 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13460 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13463 #ifdef RTE_LIBRTE_IXGBE_PMD
13464 if (ret == -ENOTSUP)
13465 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13466 res->vf_id, is_on);
13468 #ifdef RTE_LIBRTE_I40E_PMD
13469 if (ret == -ENOTSUP)
13470 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13471 res->vf_id, is_on);
13473 #ifdef RTE_LIBRTE_BNXT_PMD
13474 if (ret == -ENOTSUP)
13475 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13476 res->vf_id, is_on);
13483 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13486 printf("invalid port_id %d\n", res->port_id);
13489 printf("function not implemented\n");
13492 printf("programming error: (%s)\n", strerror(-ret));
13496 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13497 .f = cmd_set_vf_vlan_stripq_parsed,
13499 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13501 (void *)&cmd_vf_vlan_stripq_set,
13502 (void *)&cmd_vf_vlan_stripq_vf,
13503 (void *)&cmd_vf_vlan_stripq_vlan,
13504 (void *)&cmd_vf_vlan_stripq_stripq,
13505 (void *)&cmd_vf_vlan_stripq_port_id,
13506 (void *)&cmd_vf_vlan_stripq_vf_id,
13507 (void *)&cmd_vf_vlan_stripq_on_off,
13512 /* vf vlan insert configuration */
13514 /* Common result structure for vf vlan insert */
13515 struct cmd_vf_vlan_insert_result {
13516 cmdline_fixed_string_t set;
13517 cmdline_fixed_string_t vf;
13518 cmdline_fixed_string_t vlan;
13519 cmdline_fixed_string_t insert;
13525 /* Common CLI fields for vf vlan insert enable disable */
13526 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13527 TOKEN_STRING_INITIALIZER
13528 (struct cmd_vf_vlan_insert_result,
13530 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13531 TOKEN_STRING_INITIALIZER
13532 (struct cmd_vf_vlan_insert_result,
13534 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13535 TOKEN_STRING_INITIALIZER
13536 (struct cmd_vf_vlan_insert_result,
13538 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13539 TOKEN_STRING_INITIALIZER
13540 (struct cmd_vf_vlan_insert_result,
13542 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13543 TOKEN_NUM_INITIALIZER
13544 (struct cmd_vf_vlan_insert_result,
13546 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13547 TOKEN_NUM_INITIALIZER
13548 (struct cmd_vf_vlan_insert_result,
13550 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13551 TOKEN_NUM_INITIALIZER
13552 (struct cmd_vf_vlan_insert_result,
13556 cmd_set_vf_vlan_insert_parsed(
13557 void *parsed_result,
13558 __attribute__((unused)) struct cmdline *cl,
13559 __attribute__((unused)) void *data)
13561 struct cmd_vf_vlan_insert_result *res = parsed_result;
13562 int ret = -ENOTSUP;
13564 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13567 #ifdef RTE_LIBRTE_IXGBE_PMD
13568 if (ret == -ENOTSUP)
13569 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13572 #ifdef RTE_LIBRTE_I40E_PMD
13573 if (ret == -ENOTSUP)
13574 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13577 #ifdef RTE_LIBRTE_BNXT_PMD
13578 if (ret == -ENOTSUP)
13579 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13587 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13590 printf("invalid port_id %d\n", res->port_id);
13593 printf("function not implemented\n");
13596 printf("programming error: (%s)\n", strerror(-ret));
13600 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13601 .f = cmd_set_vf_vlan_insert_parsed,
13603 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13605 (void *)&cmd_vf_vlan_insert_set,
13606 (void *)&cmd_vf_vlan_insert_vf,
13607 (void *)&cmd_vf_vlan_insert_vlan,
13608 (void *)&cmd_vf_vlan_insert_insert,
13609 (void *)&cmd_vf_vlan_insert_port_id,
13610 (void *)&cmd_vf_vlan_insert_vf_id,
13611 (void *)&cmd_vf_vlan_insert_vlan_id,
13616 /* tx loopback configuration */
13618 /* Common result structure for tx loopback */
13619 struct cmd_tx_loopback_result {
13620 cmdline_fixed_string_t set;
13621 cmdline_fixed_string_t tx;
13622 cmdline_fixed_string_t loopback;
13624 cmdline_fixed_string_t on_off;
13627 /* Common CLI fields for tx loopback enable disable */
13628 cmdline_parse_token_string_t cmd_tx_loopback_set =
13629 TOKEN_STRING_INITIALIZER
13630 (struct cmd_tx_loopback_result,
13632 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13633 TOKEN_STRING_INITIALIZER
13634 (struct cmd_tx_loopback_result,
13636 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13637 TOKEN_STRING_INITIALIZER
13638 (struct cmd_tx_loopback_result,
13639 loopback, "loopback");
13640 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13641 TOKEN_NUM_INITIALIZER
13642 (struct cmd_tx_loopback_result,
13644 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13645 TOKEN_STRING_INITIALIZER
13646 (struct cmd_tx_loopback_result,
13650 cmd_set_tx_loopback_parsed(
13651 void *parsed_result,
13652 __attribute__((unused)) struct cmdline *cl,
13653 __attribute__((unused)) void *data)
13655 struct cmd_tx_loopback_result *res = parsed_result;
13656 int ret = -ENOTSUP;
13658 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13660 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13663 #ifdef RTE_LIBRTE_IXGBE_PMD
13664 if (ret == -ENOTSUP)
13665 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13667 #ifdef RTE_LIBRTE_I40E_PMD
13668 if (ret == -ENOTSUP)
13669 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13671 #ifdef RTE_LIBRTE_BNXT_PMD
13672 if (ret == -ENOTSUP)
13673 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13675 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13676 if (ret == -ENOTSUP)
13677 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13684 printf("invalid is_on %d\n", is_on);
13687 printf("invalid port_id %d\n", res->port_id);
13690 printf("function not implemented\n");
13693 printf("programming error: (%s)\n", strerror(-ret));
13697 cmdline_parse_inst_t cmd_set_tx_loopback = {
13698 .f = cmd_set_tx_loopback_parsed,
13700 .help_str = "set tx loopback <port_id> on|off",
13702 (void *)&cmd_tx_loopback_set,
13703 (void *)&cmd_tx_loopback_tx,
13704 (void *)&cmd_tx_loopback_loopback,
13705 (void *)&cmd_tx_loopback_port_id,
13706 (void *)&cmd_tx_loopback_on_off,
13711 /* all queues drop enable configuration */
13713 /* Common result structure for all queues drop enable */
13714 struct cmd_all_queues_drop_en_result {
13715 cmdline_fixed_string_t set;
13716 cmdline_fixed_string_t all;
13717 cmdline_fixed_string_t queues;
13718 cmdline_fixed_string_t drop;
13720 cmdline_fixed_string_t on_off;
13723 /* Common CLI fields for tx loopback enable disable */
13724 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13725 TOKEN_STRING_INITIALIZER
13726 (struct cmd_all_queues_drop_en_result,
13728 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13729 TOKEN_STRING_INITIALIZER
13730 (struct cmd_all_queues_drop_en_result,
13732 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13733 TOKEN_STRING_INITIALIZER
13734 (struct cmd_all_queues_drop_en_result,
13736 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13737 TOKEN_STRING_INITIALIZER
13738 (struct cmd_all_queues_drop_en_result,
13740 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13741 TOKEN_NUM_INITIALIZER
13742 (struct cmd_all_queues_drop_en_result,
13744 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13745 TOKEN_STRING_INITIALIZER
13746 (struct cmd_all_queues_drop_en_result,
13750 cmd_set_all_queues_drop_en_parsed(
13751 void *parsed_result,
13752 __attribute__((unused)) struct cmdline *cl,
13753 __attribute__((unused)) void *data)
13755 struct cmd_all_queues_drop_en_result *res = parsed_result;
13756 int ret = -ENOTSUP;
13757 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13759 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13762 #ifdef RTE_LIBRTE_IXGBE_PMD
13763 if (ret == -ENOTSUP)
13764 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13766 #ifdef RTE_LIBRTE_BNXT_PMD
13767 if (ret == -ENOTSUP)
13768 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13774 printf("invalid is_on %d\n", is_on);
13777 printf("invalid port_id %d\n", res->port_id);
13780 printf("function not implemented\n");
13783 printf("programming error: (%s)\n", strerror(-ret));
13787 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13788 .f = cmd_set_all_queues_drop_en_parsed,
13790 .help_str = "set all queues drop <port_id> on|off",
13792 (void *)&cmd_all_queues_drop_en_set,
13793 (void *)&cmd_all_queues_drop_en_all,
13794 (void *)&cmd_all_queues_drop_en_queues,
13795 (void *)&cmd_all_queues_drop_en_drop,
13796 (void *)&cmd_all_queues_drop_en_port_id,
13797 (void *)&cmd_all_queues_drop_en_on_off,
13802 /* vf split drop enable configuration */
13804 /* Common result structure for vf split drop enable */
13805 struct cmd_vf_split_drop_en_result {
13806 cmdline_fixed_string_t set;
13807 cmdline_fixed_string_t vf;
13808 cmdline_fixed_string_t split;
13809 cmdline_fixed_string_t drop;
13812 cmdline_fixed_string_t on_off;
13815 /* Common CLI fields for vf split drop enable disable */
13816 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13817 TOKEN_STRING_INITIALIZER
13818 (struct cmd_vf_split_drop_en_result,
13820 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13821 TOKEN_STRING_INITIALIZER
13822 (struct cmd_vf_split_drop_en_result,
13824 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13825 TOKEN_STRING_INITIALIZER
13826 (struct cmd_vf_split_drop_en_result,
13828 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13829 TOKEN_STRING_INITIALIZER
13830 (struct cmd_vf_split_drop_en_result,
13832 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13833 TOKEN_NUM_INITIALIZER
13834 (struct cmd_vf_split_drop_en_result,
13836 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13837 TOKEN_NUM_INITIALIZER
13838 (struct cmd_vf_split_drop_en_result,
13840 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13841 TOKEN_STRING_INITIALIZER
13842 (struct cmd_vf_split_drop_en_result,
13846 cmd_set_vf_split_drop_en_parsed(
13847 void *parsed_result,
13848 __attribute__((unused)) struct cmdline *cl,
13849 __attribute__((unused)) void *data)
13851 struct cmd_vf_split_drop_en_result *res = parsed_result;
13852 int ret = -ENOTSUP;
13853 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13855 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13858 #ifdef RTE_LIBRTE_IXGBE_PMD
13859 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13866 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13869 printf("invalid port_id %d\n", res->port_id);
13872 printf("not supported on port %d\n", res->port_id);
13875 printf("programming error: (%s)\n", strerror(-ret));
13879 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13880 .f = cmd_set_vf_split_drop_en_parsed,
13882 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13884 (void *)&cmd_vf_split_drop_en_set,
13885 (void *)&cmd_vf_split_drop_en_vf,
13886 (void *)&cmd_vf_split_drop_en_split,
13887 (void *)&cmd_vf_split_drop_en_drop,
13888 (void *)&cmd_vf_split_drop_en_port_id,
13889 (void *)&cmd_vf_split_drop_en_vf_id,
13890 (void *)&cmd_vf_split_drop_en_on_off,
13895 /* vf mac address configuration */
13897 /* Common result structure for vf mac address */
13898 struct cmd_set_vf_mac_addr_result {
13899 cmdline_fixed_string_t set;
13900 cmdline_fixed_string_t vf;
13901 cmdline_fixed_string_t mac;
13902 cmdline_fixed_string_t addr;
13905 struct rte_ether_addr mac_addr;
13909 /* Common CLI fields for vf split drop enable disable */
13910 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13911 TOKEN_STRING_INITIALIZER
13912 (struct cmd_set_vf_mac_addr_result,
13914 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13915 TOKEN_STRING_INITIALIZER
13916 (struct cmd_set_vf_mac_addr_result,
13918 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13919 TOKEN_STRING_INITIALIZER
13920 (struct cmd_set_vf_mac_addr_result,
13922 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13923 TOKEN_STRING_INITIALIZER
13924 (struct cmd_set_vf_mac_addr_result,
13926 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13927 TOKEN_NUM_INITIALIZER
13928 (struct cmd_set_vf_mac_addr_result,
13930 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13931 TOKEN_NUM_INITIALIZER
13932 (struct cmd_set_vf_mac_addr_result,
13934 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13935 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13939 cmd_set_vf_mac_addr_parsed(
13940 void *parsed_result,
13941 __attribute__((unused)) struct cmdline *cl,
13942 __attribute__((unused)) void *data)
13944 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13945 int ret = -ENOTSUP;
13947 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13950 #ifdef RTE_LIBRTE_IXGBE_PMD
13951 if (ret == -ENOTSUP)
13952 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13955 #ifdef RTE_LIBRTE_I40E_PMD
13956 if (ret == -ENOTSUP)
13957 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13960 #ifdef RTE_LIBRTE_BNXT_PMD
13961 if (ret == -ENOTSUP)
13962 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13970 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13973 printf("invalid port_id %d\n", res->port_id);
13976 printf("function not implemented\n");
13979 printf("programming error: (%s)\n", strerror(-ret));
13983 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13984 .f = cmd_set_vf_mac_addr_parsed,
13986 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13988 (void *)&cmd_set_vf_mac_addr_set,
13989 (void *)&cmd_set_vf_mac_addr_vf,
13990 (void *)&cmd_set_vf_mac_addr_mac,
13991 (void *)&cmd_set_vf_mac_addr_addr,
13992 (void *)&cmd_set_vf_mac_addr_port_id,
13993 (void *)&cmd_set_vf_mac_addr_vf_id,
13994 (void *)&cmd_set_vf_mac_addr_mac_addr,
13999 /* MACsec configuration */
14001 /* Common result structure for MACsec offload enable */
14002 struct cmd_macsec_offload_on_result {
14003 cmdline_fixed_string_t set;
14004 cmdline_fixed_string_t macsec;
14005 cmdline_fixed_string_t offload;
14007 cmdline_fixed_string_t on;
14008 cmdline_fixed_string_t encrypt;
14009 cmdline_fixed_string_t en_on_off;
14010 cmdline_fixed_string_t replay_protect;
14011 cmdline_fixed_string_t rp_on_off;
14014 /* Common CLI fields for MACsec offload disable */
14015 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14016 TOKEN_STRING_INITIALIZER
14017 (struct cmd_macsec_offload_on_result,
14019 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14020 TOKEN_STRING_INITIALIZER
14021 (struct cmd_macsec_offload_on_result,
14023 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14024 TOKEN_STRING_INITIALIZER
14025 (struct cmd_macsec_offload_on_result,
14026 offload, "offload");
14027 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14028 TOKEN_NUM_INITIALIZER
14029 (struct cmd_macsec_offload_on_result,
14031 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14032 TOKEN_STRING_INITIALIZER
14033 (struct cmd_macsec_offload_on_result,
14035 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14036 TOKEN_STRING_INITIALIZER
14037 (struct cmd_macsec_offload_on_result,
14038 encrypt, "encrypt");
14039 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14040 TOKEN_STRING_INITIALIZER
14041 (struct cmd_macsec_offload_on_result,
14042 en_on_off, "on#off");
14043 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14044 TOKEN_STRING_INITIALIZER
14045 (struct cmd_macsec_offload_on_result,
14046 replay_protect, "replay-protect");
14047 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14048 TOKEN_STRING_INITIALIZER
14049 (struct cmd_macsec_offload_on_result,
14050 rp_on_off, "on#off");
14053 cmd_set_macsec_offload_on_parsed(
14054 void *parsed_result,
14055 __attribute__((unused)) struct cmdline *cl,
14056 __attribute__((unused)) void *data)
14058 struct cmd_macsec_offload_on_result *res = parsed_result;
14059 int ret = -ENOTSUP;
14060 portid_t port_id = res->port_id;
14061 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14062 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14063 struct rte_eth_dev_info dev_info;
14065 if (port_id_is_invalid(port_id, ENABLED_WARN))
14067 if (!port_is_stopped(port_id)) {
14068 printf("Please stop port %d first\n", port_id);
14072 rte_eth_dev_info_get(port_id, &dev_info);
14073 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14074 #ifdef RTE_LIBRTE_IXGBE_PMD
14075 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14083 ports[port_id].dev_conf.txmode.offloads |=
14084 DEV_TX_OFFLOAD_MACSEC_INSERT;
14085 cmd_reconfig_device_queue(port_id, 1, 1);
14088 printf("invalid port_id %d\n", port_id);
14091 printf("not supported on port %d\n", port_id);
14094 printf("programming error: (%s)\n", strerror(-ret));
14098 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14099 .f = cmd_set_macsec_offload_on_parsed,
14101 .help_str = "set macsec offload <port_id> on "
14102 "encrypt on|off replay-protect on|off",
14104 (void *)&cmd_macsec_offload_on_set,
14105 (void *)&cmd_macsec_offload_on_macsec,
14106 (void *)&cmd_macsec_offload_on_offload,
14107 (void *)&cmd_macsec_offload_on_port_id,
14108 (void *)&cmd_macsec_offload_on_on,
14109 (void *)&cmd_macsec_offload_on_encrypt,
14110 (void *)&cmd_macsec_offload_on_en_on_off,
14111 (void *)&cmd_macsec_offload_on_replay_protect,
14112 (void *)&cmd_macsec_offload_on_rp_on_off,
14117 /* Common result structure for MACsec offload disable */
14118 struct cmd_macsec_offload_off_result {
14119 cmdline_fixed_string_t set;
14120 cmdline_fixed_string_t macsec;
14121 cmdline_fixed_string_t offload;
14123 cmdline_fixed_string_t off;
14126 /* Common CLI fields for MACsec offload disable */
14127 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14128 TOKEN_STRING_INITIALIZER
14129 (struct cmd_macsec_offload_off_result,
14131 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14132 TOKEN_STRING_INITIALIZER
14133 (struct cmd_macsec_offload_off_result,
14135 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14136 TOKEN_STRING_INITIALIZER
14137 (struct cmd_macsec_offload_off_result,
14138 offload, "offload");
14139 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14140 TOKEN_NUM_INITIALIZER
14141 (struct cmd_macsec_offload_off_result,
14143 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14144 TOKEN_STRING_INITIALIZER
14145 (struct cmd_macsec_offload_off_result,
14149 cmd_set_macsec_offload_off_parsed(
14150 void *parsed_result,
14151 __attribute__((unused)) struct cmdline *cl,
14152 __attribute__((unused)) void *data)
14154 struct cmd_macsec_offload_off_result *res = parsed_result;
14155 int ret = -ENOTSUP;
14156 struct rte_eth_dev_info dev_info;
14157 portid_t port_id = res->port_id;
14159 if (port_id_is_invalid(port_id, ENABLED_WARN))
14161 if (!port_is_stopped(port_id)) {
14162 printf("Please stop port %d first\n", port_id);
14166 rte_eth_dev_info_get(port_id, &dev_info);
14167 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14168 #ifdef RTE_LIBRTE_IXGBE_PMD
14169 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14174 ports[port_id].dev_conf.txmode.offloads &=
14175 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14176 cmd_reconfig_device_queue(port_id, 1, 1);
14179 printf("invalid port_id %d\n", port_id);
14182 printf("not supported on port %d\n", port_id);
14185 printf("programming error: (%s)\n", strerror(-ret));
14189 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14190 .f = cmd_set_macsec_offload_off_parsed,
14192 .help_str = "set macsec offload <port_id> off",
14194 (void *)&cmd_macsec_offload_off_set,
14195 (void *)&cmd_macsec_offload_off_macsec,
14196 (void *)&cmd_macsec_offload_off_offload,
14197 (void *)&cmd_macsec_offload_off_port_id,
14198 (void *)&cmd_macsec_offload_off_off,
14203 /* Common result structure for MACsec secure connection configure */
14204 struct cmd_macsec_sc_result {
14205 cmdline_fixed_string_t set;
14206 cmdline_fixed_string_t macsec;
14207 cmdline_fixed_string_t sc;
14208 cmdline_fixed_string_t tx_rx;
14210 struct rte_ether_addr mac;
14214 /* Common CLI fields for MACsec secure connection configure */
14215 cmdline_parse_token_string_t cmd_macsec_sc_set =
14216 TOKEN_STRING_INITIALIZER
14217 (struct cmd_macsec_sc_result,
14219 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14220 TOKEN_STRING_INITIALIZER
14221 (struct cmd_macsec_sc_result,
14223 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14224 TOKEN_STRING_INITIALIZER
14225 (struct cmd_macsec_sc_result,
14227 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14228 TOKEN_STRING_INITIALIZER
14229 (struct cmd_macsec_sc_result,
14231 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14232 TOKEN_NUM_INITIALIZER
14233 (struct cmd_macsec_sc_result,
14235 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14236 TOKEN_ETHERADDR_INITIALIZER
14237 (struct cmd_macsec_sc_result,
14239 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14240 TOKEN_NUM_INITIALIZER
14241 (struct cmd_macsec_sc_result,
14245 cmd_set_macsec_sc_parsed(
14246 void *parsed_result,
14247 __attribute__((unused)) struct cmdline *cl,
14248 __attribute__((unused)) void *data)
14250 struct cmd_macsec_sc_result *res = parsed_result;
14251 int ret = -ENOTSUP;
14252 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14254 #ifdef RTE_LIBRTE_IXGBE_PMD
14256 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14257 res->mac.addr_bytes) :
14258 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14259 res->mac.addr_bytes, res->pi);
14261 RTE_SET_USED(is_tx);
14267 printf("invalid port_id %d\n", res->port_id);
14270 printf("not supported on port %d\n", res->port_id);
14273 printf("programming error: (%s)\n", strerror(-ret));
14277 cmdline_parse_inst_t cmd_set_macsec_sc = {
14278 .f = cmd_set_macsec_sc_parsed,
14280 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14282 (void *)&cmd_macsec_sc_set,
14283 (void *)&cmd_macsec_sc_macsec,
14284 (void *)&cmd_macsec_sc_sc,
14285 (void *)&cmd_macsec_sc_tx_rx,
14286 (void *)&cmd_macsec_sc_port_id,
14287 (void *)&cmd_macsec_sc_mac,
14288 (void *)&cmd_macsec_sc_pi,
14293 /* Common result structure for MACsec secure connection configure */
14294 struct cmd_macsec_sa_result {
14295 cmdline_fixed_string_t set;
14296 cmdline_fixed_string_t macsec;
14297 cmdline_fixed_string_t sa;
14298 cmdline_fixed_string_t tx_rx;
14303 cmdline_fixed_string_t key;
14306 /* Common CLI fields for MACsec secure connection configure */
14307 cmdline_parse_token_string_t cmd_macsec_sa_set =
14308 TOKEN_STRING_INITIALIZER
14309 (struct cmd_macsec_sa_result,
14311 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14312 TOKEN_STRING_INITIALIZER
14313 (struct cmd_macsec_sa_result,
14315 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14316 TOKEN_STRING_INITIALIZER
14317 (struct cmd_macsec_sa_result,
14319 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14320 TOKEN_STRING_INITIALIZER
14321 (struct cmd_macsec_sa_result,
14323 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14324 TOKEN_NUM_INITIALIZER
14325 (struct cmd_macsec_sa_result,
14327 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14328 TOKEN_NUM_INITIALIZER
14329 (struct cmd_macsec_sa_result,
14331 cmdline_parse_token_num_t cmd_macsec_sa_an =
14332 TOKEN_NUM_INITIALIZER
14333 (struct cmd_macsec_sa_result,
14335 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14336 TOKEN_NUM_INITIALIZER
14337 (struct cmd_macsec_sa_result,
14339 cmdline_parse_token_string_t cmd_macsec_sa_key =
14340 TOKEN_STRING_INITIALIZER
14341 (struct cmd_macsec_sa_result,
14345 cmd_set_macsec_sa_parsed(
14346 void *parsed_result,
14347 __attribute__((unused)) struct cmdline *cl,
14348 __attribute__((unused)) void *data)
14350 struct cmd_macsec_sa_result *res = parsed_result;
14351 int ret = -ENOTSUP;
14352 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14353 uint8_t key[16] = { 0 };
14359 key_len = strlen(res->key) / 2;
14363 for (i = 0; i < key_len; i++) {
14364 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14367 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14370 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14373 #ifdef RTE_LIBRTE_IXGBE_PMD
14375 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14376 res->idx, res->an, res->pn, key) :
14377 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14378 res->idx, res->an, res->pn, key);
14380 RTE_SET_USED(is_tx);
14387 printf("invalid idx %d or an %d\n", res->idx, res->an);
14390 printf("invalid port_id %d\n", res->port_id);
14393 printf("not supported on port %d\n", res->port_id);
14396 printf("programming error: (%s)\n", strerror(-ret));
14400 cmdline_parse_inst_t cmd_set_macsec_sa = {
14401 .f = cmd_set_macsec_sa_parsed,
14403 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14405 (void *)&cmd_macsec_sa_set,
14406 (void *)&cmd_macsec_sa_macsec,
14407 (void *)&cmd_macsec_sa_sa,
14408 (void *)&cmd_macsec_sa_tx_rx,
14409 (void *)&cmd_macsec_sa_port_id,
14410 (void *)&cmd_macsec_sa_idx,
14411 (void *)&cmd_macsec_sa_an,
14412 (void *)&cmd_macsec_sa_pn,
14413 (void *)&cmd_macsec_sa_key,
14418 /* VF unicast promiscuous mode configuration */
14420 /* Common result structure for VF unicast promiscuous mode */
14421 struct cmd_vf_promisc_result {
14422 cmdline_fixed_string_t set;
14423 cmdline_fixed_string_t vf;
14424 cmdline_fixed_string_t promisc;
14427 cmdline_fixed_string_t on_off;
14430 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14431 cmdline_parse_token_string_t cmd_vf_promisc_set =
14432 TOKEN_STRING_INITIALIZER
14433 (struct cmd_vf_promisc_result,
14435 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14436 TOKEN_STRING_INITIALIZER
14437 (struct cmd_vf_promisc_result,
14439 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14440 TOKEN_STRING_INITIALIZER
14441 (struct cmd_vf_promisc_result,
14442 promisc, "promisc");
14443 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14444 TOKEN_NUM_INITIALIZER
14445 (struct cmd_vf_promisc_result,
14447 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14448 TOKEN_NUM_INITIALIZER
14449 (struct cmd_vf_promisc_result,
14451 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14452 TOKEN_STRING_INITIALIZER
14453 (struct cmd_vf_promisc_result,
14457 cmd_set_vf_promisc_parsed(
14458 void *parsed_result,
14459 __attribute__((unused)) struct cmdline *cl,
14460 __attribute__((unused)) void *data)
14462 struct cmd_vf_promisc_result *res = parsed_result;
14463 int ret = -ENOTSUP;
14465 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14467 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14470 #ifdef RTE_LIBRTE_I40E_PMD
14471 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14472 res->vf_id, is_on);
14479 printf("invalid vf_id %d\n", res->vf_id);
14482 printf("invalid port_id %d\n", res->port_id);
14485 printf("function not implemented\n");
14488 printf("programming error: (%s)\n", strerror(-ret));
14492 cmdline_parse_inst_t cmd_set_vf_promisc = {
14493 .f = cmd_set_vf_promisc_parsed,
14495 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14496 "Set unicast promiscuous mode for a VF from the PF",
14498 (void *)&cmd_vf_promisc_set,
14499 (void *)&cmd_vf_promisc_vf,
14500 (void *)&cmd_vf_promisc_promisc,
14501 (void *)&cmd_vf_promisc_port_id,
14502 (void *)&cmd_vf_promisc_vf_id,
14503 (void *)&cmd_vf_promisc_on_off,
14508 /* VF multicast promiscuous mode configuration */
14510 /* Common result structure for VF multicast promiscuous mode */
14511 struct cmd_vf_allmulti_result {
14512 cmdline_fixed_string_t set;
14513 cmdline_fixed_string_t vf;
14514 cmdline_fixed_string_t allmulti;
14517 cmdline_fixed_string_t on_off;
14520 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14521 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14522 TOKEN_STRING_INITIALIZER
14523 (struct cmd_vf_allmulti_result,
14525 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14526 TOKEN_STRING_INITIALIZER
14527 (struct cmd_vf_allmulti_result,
14529 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14530 TOKEN_STRING_INITIALIZER
14531 (struct cmd_vf_allmulti_result,
14532 allmulti, "allmulti");
14533 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14534 TOKEN_NUM_INITIALIZER
14535 (struct cmd_vf_allmulti_result,
14537 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14538 TOKEN_NUM_INITIALIZER
14539 (struct cmd_vf_allmulti_result,
14541 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14542 TOKEN_STRING_INITIALIZER
14543 (struct cmd_vf_allmulti_result,
14547 cmd_set_vf_allmulti_parsed(
14548 void *parsed_result,
14549 __attribute__((unused)) struct cmdline *cl,
14550 __attribute__((unused)) void *data)
14552 struct cmd_vf_allmulti_result *res = parsed_result;
14553 int ret = -ENOTSUP;
14555 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14557 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14560 #ifdef RTE_LIBRTE_I40E_PMD
14561 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14562 res->vf_id, is_on);
14569 printf("invalid vf_id %d\n", res->vf_id);
14572 printf("invalid port_id %d\n", res->port_id);
14575 printf("function not implemented\n");
14578 printf("programming error: (%s)\n", strerror(-ret));
14582 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14583 .f = cmd_set_vf_allmulti_parsed,
14585 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14586 "Set multicast promiscuous mode for a VF from the PF",
14588 (void *)&cmd_vf_allmulti_set,
14589 (void *)&cmd_vf_allmulti_vf,
14590 (void *)&cmd_vf_allmulti_allmulti,
14591 (void *)&cmd_vf_allmulti_port_id,
14592 (void *)&cmd_vf_allmulti_vf_id,
14593 (void *)&cmd_vf_allmulti_on_off,
14598 /* vf broadcast mode configuration */
14600 /* Common result structure for vf broadcast */
14601 struct cmd_set_vf_broadcast_result {
14602 cmdline_fixed_string_t set;
14603 cmdline_fixed_string_t vf;
14604 cmdline_fixed_string_t broadcast;
14607 cmdline_fixed_string_t on_off;
14610 /* Common CLI fields for vf broadcast enable disable */
14611 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14612 TOKEN_STRING_INITIALIZER
14613 (struct cmd_set_vf_broadcast_result,
14615 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14616 TOKEN_STRING_INITIALIZER
14617 (struct cmd_set_vf_broadcast_result,
14619 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14620 TOKEN_STRING_INITIALIZER
14621 (struct cmd_set_vf_broadcast_result,
14622 broadcast, "broadcast");
14623 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14624 TOKEN_NUM_INITIALIZER
14625 (struct cmd_set_vf_broadcast_result,
14627 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14628 TOKEN_NUM_INITIALIZER
14629 (struct cmd_set_vf_broadcast_result,
14631 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14632 TOKEN_STRING_INITIALIZER
14633 (struct cmd_set_vf_broadcast_result,
14637 cmd_set_vf_broadcast_parsed(
14638 void *parsed_result,
14639 __attribute__((unused)) struct cmdline *cl,
14640 __attribute__((unused)) void *data)
14642 struct cmd_set_vf_broadcast_result *res = parsed_result;
14643 int ret = -ENOTSUP;
14645 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14647 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14650 #ifdef RTE_LIBRTE_I40E_PMD
14651 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14652 res->vf_id, is_on);
14659 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14662 printf("invalid port_id %d\n", res->port_id);
14665 printf("function not implemented\n");
14668 printf("programming error: (%s)\n", strerror(-ret));
14672 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14673 .f = cmd_set_vf_broadcast_parsed,
14675 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14677 (void *)&cmd_set_vf_broadcast_set,
14678 (void *)&cmd_set_vf_broadcast_vf,
14679 (void *)&cmd_set_vf_broadcast_broadcast,
14680 (void *)&cmd_set_vf_broadcast_port_id,
14681 (void *)&cmd_set_vf_broadcast_vf_id,
14682 (void *)&cmd_set_vf_broadcast_on_off,
14687 /* vf vlan tag configuration */
14689 /* Common result structure for vf vlan tag */
14690 struct cmd_set_vf_vlan_tag_result {
14691 cmdline_fixed_string_t set;
14692 cmdline_fixed_string_t vf;
14693 cmdline_fixed_string_t vlan;
14694 cmdline_fixed_string_t tag;
14697 cmdline_fixed_string_t on_off;
14700 /* Common CLI fields for vf vlan tag enable disable */
14701 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14702 TOKEN_STRING_INITIALIZER
14703 (struct cmd_set_vf_vlan_tag_result,
14705 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14706 TOKEN_STRING_INITIALIZER
14707 (struct cmd_set_vf_vlan_tag_result,
14709 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14710 TOKEN_STRING_INITIALIZER
14711 (struct cmd_set_vf_vlan_tag_result,
14713 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14714 TOKEN_STRING_INITIALIZER
14715 (struct cmd_set_vf_vlan_tag_result,
14717 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14718 TOKEN_NUM_INITIALIZER
14719 (struct cmd_set_vf_vlan_tag_result,
14721 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14722 TOKEN_NUM_INITIALIZER
14723 (struct cmd_set_vf_vlan_tag_result,
14725 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14726 TOKEN_STRING_INITIALIZER
14727 (struct cmd_set_vf_vlan_tag_result,
14731 cmd_set_vf_vlan_tag_parsed(
14732 void *parsed_result,
14733 __attribute__((unused)) struct cmdline *cl,
14734 __attribute__((unused)) void *data)
14736 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14737 int ret = -ENOTSUP;
14739 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14741 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14744 #ifdef RTE_LIBRTE_I40E_PMD
14745 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14746 res->vf_id, is_on);
14753 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14756 printf("invalid port_id %d\n", res->port_id);
14759 printf("function not implemented\n");
14762 printf("programming error: (%s)\n", strerror(-ret));
14766 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14767 .f = cmd_set_vf_vlan_tag_parsed,
14769 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14771 (void *)&cmd_set_vf_vlan_tag_set,
14772 (void *)&cmd_set_vf_vlan_tag_vf,
14773 (void *)&cmd_set_vf_vlan_tag_vlan,
14774 (void *)&cmd_set_vf_vlan_tag_tag,
14775 (void *)&cmd_set_vf_vlan_tag_port_id,
14776 (void *)&cmd_set_vf_vlan_tag_vf_id,
14777 (void *)&cmd_set_vf_vlan_tag_on_off,
14782 /* Common definition of VF and TC TX bandwidth configuration */
14783 struct cmd_vf_tc_bw_result {
14784 cmdline_fixed_string_t set;
14785 cmdline_fixed_string_t vf;
14786 cmdline_fixed_string_t tc;
14787 cmdline_fixed_string_t tx;
14788 cmdline_fixed_string_t min_bw;
14789 cmdline_fixed_string_t max_bw;
14790 cmdline_fixed_string_t strict_link_prio;
14795 cmdline_fixed_string_t bw_list;
14799 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14800 TOKEN_STRING_INITIALIZER
14801 (struct cmd_vf_tc_bw_result,
14803 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14804 TOKEN_STRING_INITIALIZER
14805 (struct cmd_vf_tc_bw_result,
14807 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14808 TOKEN_STRING_INITIALIZER
14809 (struct cmd_vf_tc_bw_result,
14811 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14812 TOKEN_STRING_INITIALIZER
14813 (struct cmd_vf_tc_bw_result,
14815 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14816 TOKEN_STRING_INITIALIZER
14817 (struct cmd_vf_tc_bw_result,
14818 strict_link_prio, "strict-link-priority");
14819 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14820 TOKEN_STRING_INITIALIZER
14821 (struct cmd_vf_tc_bw_result,
14822 min_bw, "min-bandwidth");
14823 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14824 TOKEN_STRING_INITIALIZER
14825 (struct cmd_vf_tc_bw_result,
14826 max_bw, "max-bandwidth");
14827 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14828 TOKEN_NUM_INITIALIZER
14829 (struct cmd_vf_tc_bw_result,
14831 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14832 TOKEN_NUM_INITIALIZER
14833 (struct cmd_vf_tc_bw_result,
14835 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14836 TOKEN_NUM_INITIALIZER
14837 (struct cmd_vf_tc_bw_result,
14839 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14840 TOKEN_NUM_INITIALIZER
14841 (struct cmd_vf_tc_bw_result,
14843 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14844 TOKEN_STRING_INITIALIZER
14845 (struct cmd_vf_tc_bw_result,
14847 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14848 TOKEN_NUM_INITIALIZER
14849 (struct cmd_vf_tc_bw_result,
14852 /* VF max bandwidth setting */
14854 cmd_vf_max_bw_parsed(
14855 void *parsed_result,
14856 __attribute__((unused)) struct cmdline *cl,
14857 __attribute__((unused)) void *data)
14859 struct cmd_vf_tc_bw_result *res = parsed_result;
14860 int ret = -ENOTSUP;
14862 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14865 #ifdef RTE_LIBRTE_I40E_PMD
14866 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14867 res->vf_id, res->bw);
14874 printf("invalid vf_id %d or bandwidth %d\n",
14875 res->vf_id, res->bw);
14878 printf("invalid port_id %d\n", res->port_id);
14881 printf("function not implemented\n");
14884 printf("programming error: (%s)\n", strerror(-ret));
14888 cmdline_parse_inst_t cmd_vf_max_bw = {
14889 .f = cmd_vf_max_bw_parsed,
14891 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14893 (void *)&cmd_vf_tc_bw_set,
14894 (void *)&cmd_vf_tc_bw_vf,
14895 (void *)&cmd_vf_tc_bw_tx,
14896 (void *)&cmd_vf_tc_bw_max_bw,
14897 (void *)&cmd_vf_tc_bw_port_id,
14898 (void *)&cmd_vf_tc_bw_vf_id,
14899 (void *)&cmd_vf_tc_bw_bw,
14905 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14910 const char *p, *p0 = str;
14917 p = strchr(p0, '(');
14919 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14923 p0 = strchr(p, ')');
14925 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14929 if (size >= sizeof(s)) {
14930 printf("The string size exceeds the internal buffer size\n");
14933 snprintf(s, sizeof(s), "%.*s", size, p);
14934 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14936 printf("Failed to get the bandwidth list. ");
14940 for (i = 0; i < ret; i++)
14941 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14946 /* TC min bandwidth setting */
14948 cmd_vf_tc_min_bw_parsed(
14949 void *parsed_result,
14950 __attribute__((unused)) struct cmdline *cl,
14951 __attribute__((unused)) void *data)
14953 struct cmd_vf_tc_bw_result *res = parsed_result;
14956 int ret = -ENOTSUP;
14958 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14961 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14965 #ifdef RTE_LIBRTE_I40E_PMD
14966 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14974 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14977 printf("invalid port_id %d\n", res->port_id);
14980 printf("function not implemented\n");
14983 printf("programming error: (%s)\n", strerror(-ret));
14987 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14988 .f = cmd_vf_tc_min_bw_parsed,
14990 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14991 " <bw1, bw2, ...>",
14993 (void *)&cmd_vf_tc_bw_set,
14994 (void *)&cmd_vf_tc_bw_vf,
14995 (void *)&cmd_vf_tc_bw_tc,
14996 (void *)&cmd_vf_tc_bw_tx,
14997 (void *)&cmd_vf_tc_bw_min_bw,
14998 (void *)&cmd_vf_tc_bw_port_id,
14999 (void *)&cmd_vf_tc_bw_vf_id,
15000 (void *)&cmd_vf_tc_bw_bw_list,
15006 cmd_tc_min_bw_parsed(
15007 void *parsed_result,
15008 __attribute__((unused)) struct cmdline *cl,
15009 __attribute__((unused)) void *data)
15011 struct cmd_vf_tc_bw_result *res = parsed_result;
15012 struct rte_port *port;
15015 int ret = -ENOTSUP;
15017 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15020 port = &ports[res->port_id];
15021 /** Check if the port is not started **/
15022 if (port->port_status != RTE_PORT_STOPPED) {
15023 printf("Please stop port %d first\n", res->port_id);
15027 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15031 #ifdef RTE_LIBRTE_IXGBE_PMD
15032 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15039 printf("invalid bandwidth\n");
15042 printf("invalid port_id %d\n", res->port_id);
15045 printf("function not implemented\n");
15048 printf("programming error: (%s)\n", strerror(-ret));
15052 cmdline_parse_inst_t cmd_tc_min_bw = {
15053 .f = cmd_tc_min_bw_parsed,
15055 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15057 (void *)&cmd_vf_tc_bw_set,
15058 (void *)&cmd_vf_tc_bw_tc,
15059 (void *)&cmd_vf_tc_bw_tx,
15060 (void *)&cmd_vf_tc_bw_min_bw,
15061 (void *)&cmd_vf_tc_bw_port_id,
15062 (void *)&cmd_vf_tc_bw_bw_list,
15067 /* TC max bandwidth setting */
15069 cmd_vf_tc_max_bw_parsed(
15070 void *parsed_result,
15071 __attribute__((unused)) struct cmdline *cl,
15072 __attribute__((unused)) void *data)
15074 struct cmd_vf_tc_bw_result *res = parsed_result;
15075 int ret = -ENOTSUP;
15077 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15080 #ifdef RTE_LIBRTE_I40E_PMD
15081 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15082 res->tc_no, res->bw);
15089 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15090 res->vf_id, res->tc_no, res->bw);
15093 printf("invalid port_id %d\n", res->port_id);
15096 printf("function not implemented\n");
15099 printf("programming error: (%s)\n", strerror(-ret));
15103 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15104 .f = cmd_vf_tc_max_bw_parsed,
15106 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15109 (void *)&cmd_vf_tc_bw_set,
15110 (void *)&cmd_vf_tc_bw_vf,
15111 (void *)&cmd_vf_tc_bw_tc,
15112 (void *)&cmd_vf_tc_bw_tx,
15113 (void *)&cmd_vf_tc_bw_max_bw,
15114 (void *)&cmd_vf_tc_bw_port_id,
15115 (void *)&cmd_vf_tc_bw_vf_id,
15116 (void *)&cmd_vf_tc_bw_tc_no,
15117 (void *)&cmd_vf_tc_bw_bw,
15123 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15125 /* *** Set Port default Traffic Management Hierarchy *** */
15126 struct cmd_set_port_tm_hierarchy_default_result {
15127 cmdline_fixed_string_t set;
15128 cmdline_fixed_string_t port;
15129 cmdline_fixed_string_t tm;
15130 cmdline_fixed_string_t hierarchy;
15131 cmdline_fixed_string_t def;
15135 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15136 TOKEN_STRING_INITIALIZER(
15137 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15138 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15139 TOKEN_STRING_INITIALIZER(
15140 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15141 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15142 TOKEN_STRING_INITIALIZER(
15143 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15144 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15145 TOKEN_STRING_INITIALIZER(
15146 struct cmd_set_port_tm_hierarchy_default_result,
15147 hierarchy, "hierarchy");
15148 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15149 TOKEN_STRING_INITIALIZER(
15150 struct cmd_set_port_tm_hierarchy_default_result,
15152 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15153 TOKEN_NUM_INITIALIZER(
15154 struct cmd_set_port_tm_hierarchy_default_result,
15157 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15158 __attribute__((unused)) struct cmdline *cl,
15159 __attribute__((unused)) void *data)
15161 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15162 struct rte_port *p;
15163 portid_t port_id = res->port_id;
15165 if (port_id_is_invalid(port_id, ENABLED_WARN))
15168 p = &ports[port_id];
15170 /* Forward mode: tm */
15171 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15172 printf(" softnicfwd mode not enabled(error)\n");
15176 /* Set the default tm hierarchy */
15177 p->softport.default_tm_hierarchy_enable = 1;
15180 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15181 .f = cmd_set_port_tm_hierarchy_default_parsed,
15183 .help_str = "set port tm hierarchy default <port_id>",
15185 (void *)&cmd_set_port_tm_hierarchy_default_set,
15186 (void *)&cmd_set_port_tm_hierarchy_default_port,
15187 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15188 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15189 (void *)&cmd_set_port_tm_hierarchy_default_default,
15190 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15196 /** Set VXLAN encapsulation details */
15197 struct cmd_set_vxlan_result {
15198 cmdline_fixed_string_t set;
15199 cmdline_fixed_string_t vxlan;
15200 cmdline_fixed_string_t pos_token;
15201 cmdline_fixed_string_t ip_version;
15202 uint32_t vlan_present:1;
15206 cmdline_ipaddr_t ip_src;
15207 cmdline_ipaddr_t ip_dst;
15211 struct rte_ether_addr eth_src;
15212 struct rte_ether_addr eth_dst;
15215 cmdline_parse_token_string_t cmd_set_vxlan_set =
15216 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15217 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15218 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15219 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15220 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15222 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15223 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15224 "vxlan-with-vlan");
15225 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15226 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15228 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15229 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15231 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15232 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15234 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15235 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15236 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15237 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15239 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15240 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15241 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15242 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15244 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15245 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15246 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15247 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15249 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15250 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15251 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15252 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15254 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15255 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15256 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15257 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15259 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15260 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15261 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15262 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15264 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15265 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15266 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15267 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15269 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15270 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15271 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15272 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15274 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15275 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15276 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15277 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15279 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15280 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15282 static void cmd_set_vxlan_parsed(void *parsed_result,
15283 __attribute__((unused)) struct cmdline *cl,
15284 __attribute__((unused)) void *data)
15286 struct cmd_set_vxlan_result *res = parsed_result;
15291 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15294 vxlan_encap_conf.select_tos_ttl = 0;
15295 if (strcmp(res->vxlan, "vxlan") == 0)
15296 vxlan_encap_conf.select_vlan = 0;
15297 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15298 vxlan_encap_conf.select_vlan = 1;
15299 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15300 vxlan_encap_conf.select_vlan = 0;
15301 vxlan_encap_conf.select_tos_ttl = 1;
15303 if (strcmp(res->ip_version, "ipv4") == 0)
15304 vxlan_encap_conf.select_ipv4 = 1;
15305 else if (strcmp(res->ip_version, "ipv6") == 0)
15306 vxlan_encap_conf.select_ipv4 = 0;
15309 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15310 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15311 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15312 vxlan_encap_conf.ip_tos = res->tos;
15313 vxlan_encap_conf.ip_ttl = res->ttl;
15314 if (vxlan_encap_conf.select_ipv4) {
15315 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15316 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15318 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15319 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15321 if (vxlan_encap_conf.select_vlan)
15322 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15323 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15324 RTE_ETHER_ADDR_LEN);
15325 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15326 RTE_ETHER_ADDR_LEN);
15329 cmdline_parse_inst_t cmd_set_vxlan = {
15330 .f = cmd_set_vxlan_parsed,
15332 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15333 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15334 " eth-src <eth-src> eth-dst <eth-dst>",
15336 (void *)&cmd_set_vxlan_set,
15337 (void *)&cmd_set_vxlan_vxlan,
15338 (void *)&cmd_set_vxlan_ip_version,
15339 (void *)&cmd_set_vxlan_ip_version_value,
15340 (void *)&cmd_set_vxlan_vni,
15341 (void *)&cmd_set_vxlan_vni_value,
15342 (void *)&cmd_set_vxlan_udp_src,
15343 (void *)&cmd_set_vxlan_udp_src_value,
15344 (void *)&cmd_set_vxlan_udp_dst,
15345 (void *)&cmd_set_vxlan_udp_dst_value,
15346 (void *)&cmd_set_vxlan_ip_src,
15347 (void *)&cmd_set_vxlan_ip_src_value,
15348 (void *)&cmd_set_vxlan_ip_dst,
15349 (void *)&cmd_set_vxlan_ip_dst_value,
15350 (void *)&cmd_set_vxlan_eth_src,
15351 (void *)&cmd_set_vxlan_eth_src_value,
15352 (void *)&cmd_set_vxlan_eth_dst,
15353 (void *)&cmd_set_vxlan_eth_dst_value,
15358 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15359 .f = cmd_set_vxlan_parsed,
15361 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15362 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15363 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15364 " eth-dst <eth-dst>",
15366 (void *)&cmd_set_vxlan_set,
15367 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15368 (void *)&cmd_set_vxlan_ip_version,
15369 (void *)&cmd_set_vxlan_ip_version_value,
15370 (void *)&cmd_set_vxlan_vni,
15371 (void *)&cmd_set_vxlan_vni_value,
15372 (void *)&cmd_set_vxlan_udp_src,
15373 (void *)&cmd_set_vxlan_udp_src_value,
15374 (void *)&cmd_set_vxlan_udp_dst,
15375 (void *)&cmd_set_vxlan_udp_dst_value,
15376 (void *)&cmd_set_vxlan_ip_tos,
15377 (void *)&cmd_set_vxlan_ip_tos_value,
15378 (void *)&cmd_set_vxlan_ip_ttl,
15379 (void *)&cmd_set_vxlan_ip_ttl_value,
15380 (void *)&cmd_set_vxlan_ip_src,
15381 (void *)&cmd_set_vxlan_ip_src_value,
15382 (void *)&cmd_set_vxlan_ip_dst,
15383 (void *)&cmd_set_vxlan_ip_dst_value,
15384 (void *)&cmd_set_vxlan_eth_src,
15385 (void *)&cmd_set_vxlan_eth_src_value,
15386 (void *)&cmd_set_vxlan_eth_dst,
15387 (void *)&cmd_set_vxlan_eth_dst_value,
15392 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15393 .f = cmd_set_vxlan_parsed,
15395 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15396 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15397 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15400 (void *)&cmd_set_vxlan_set,
15401 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15402 (void *)&cmd_set_vxlan_ip_version,
15403 (void *)&cmd_set_vxlan_ip_version_value,
15404 (void *)&cmd_set_vxlan_vni,
15405 (void *)&cmd_set_vxlan_vni_value,
15406 (void *)&cmd_set_vxlan_udp_src,
15407 (void *)&cmd_set_vxlan_udp_src_value,
15408 (void *)&cmd_set_vxlan_udp_dst,
15409 (void *)&cmd_set_vxlan_udp_dst_value,
15410 (void *)&cmd_set_vxlan_ip_src,
15411 (void *)&cmd_set_vxlan_ip_src_value,
15412 (void *)&cmd_set_vxlan_ip_dst,
15413 (void *)&cmd_set_vxlan_ip_dst_value,
15414 (void *)&cmd_set_vxlan_vlan,
15415 (void *)&cmd_set_vxlan_vlan_value,
15416 (void *)&cmd_set_vxlan_eth_src,
15417 (void *)&cmd_set_vxlan_eth_src_value,
15418 (void *)&cmd_set_vxlan_eth_dst,
15419 (void *)&cmd_set_vxlan_eth_dst_value,
15424 /** Set NVGRE encapsulation details */
15425 struct cmd_set_nvgre_result {
15426 cmdline_fixed_string_t set;
15427 cmdline_fixed_string_t nvgre;
15428 cmdline_fixed_string_t pos_token;
15429 cmdline_fixed_string_t ip_version;
15431 cmdline_ipaddr_t ip_src;
15432 cmdline_ipaddr_t ip_dst;
15434 struct rte_ether_addr eth_src;
15435 struct rte_ether_addr eth_dst;
15438 cmdline_parse_token_string_t cmd_set_nvgre_set =
15439 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15440 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15441 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15442 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15443 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15444 "nvgre-with-vlan");
15445 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15446 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15448 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15449 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15451 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15452 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15454 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15455 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15456 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15457 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15459 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15460 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15461 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15462 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15464 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15465 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15466 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15467 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15469 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15470 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15471 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15472 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15474 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15475 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15476 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15477 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15479 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15480 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15482 static void cmd_set_nvgre_parsed(void *parsed_result,
15483 __attribute__((unused)) struct cmdline *cl,
15484 __attribute__((unused)) void *data)
15486 struct cmd_set_nvgre_result *res = parsed_result;
15488 uint32_t nvgre_tni;
15491 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15494 if (strcmp(res->nvgre, "nvgre") == 0)
15495 nvgre_encap_conf.select_vlan = 0;
15496 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15497 nvgre_encap_conf.select_vlan = 1;
15498 if (strcmp(res->ip_version, "ipv4") == 0)
15499 nvgre_encap_conf.select_ipv4 = 1;
15500 else if (strcmp(res->ip_version, "ipv6") == 0)
15501 nvgre_encap_conf.select_ipv4 = 0;
15504 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15505 if (nvgre_encap_conf.select_ipv4) {
15506 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15507 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15509 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15510 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15512 if (nvgre_encap_conf.select_vlan)
15513 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15514 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15515 RTE_ETHER_ADDR_LEN);
15516 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15517 RTE_ETHER_ADDR_LEN);
15520 cmdline_parse_inst_t cmd_set_nvgre = {
15521 .f = cmd_set_nvgre_parsed,
15523 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15524 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15525 " eth-dst <eth-dst>",
15527 (void *)&cmd_set_nvgre_set,
15528 (void *)&cmd_set_nvgre_nvgre,
15529 (void *)&cmd_set_nvgre_ip_version,
15530 (void *)&cmd_set_nvgre_ip_version_value,
15531 (void *)&cmd_set_nvgre_tni,
15532 (void *)&cmd_set_nvgre_tni_value,
15533 (void *)&cmd_set_nvgre_ip_src,
15534 (void *)&cmd_set_nvgre_ip_src_value,
15535 (void *)&cmd_set_nvgre_ip_dst,
15536 (void *)&cmd_set_nvgre_ip_dst_value,
15537 (void *)&cmd_set_nvgre_eth_src,
15538 (void *)&cmd_set_nvgre_eth_src_value,
15539 (void *)&cmd_set_nvgre_eth_dst,
15540 (void *)&cmd_set_nvgre_eth_dst_value,
15545 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15546 .f = cmd_set_nvgre_parsed,
15548 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15549 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15550 " eth-src <eth-src> eth-dst <eth-dst>",
15552 (void *)&cmd_set_nvgre_set,
15553 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15554 (void *)&cmd_set_nvgre_ip_version,
15555 (void *)&cmd_set_nvgre_ip_version_value,
15556 (void *)&cmd_set_nvgre_tni,
15557 (void *)&cmd_set_nvgre_tni_value,
15558 (void *)&cmd_set_nvgre_ip_src,
15559 (void *)&cmd_set_nvgre_ip_src_value,
15560 (void *)&cmd_set_nvgre_ip_dst,
15561 (void *)&cmd_set_nvgre_ip_dst_value,
15562 (void *)&cmd_set_nvgre_vlan,
15563 (void *)&cmd_set_nvgre_vlan_value,
15564 (void *)&cmd_set_nvgre_eth_src,
15565 (void *)&cmd_set_nvgre_eth_src_value,
15566 (void *)&cmd_set_nvgre_eth_dst,
15567 (void *)&cmd_set_nvgre_eth_dst_value,
15572 /** Set L2 encapsulation details */
15573 struct cmd_set_l2_encap_result {
15574 cmdline_fixed_string_t set;
15575 cmdline_fixed_string_t l2_encap;
15576 cmdline_fixed_string_t pos_token;
15577 cmdline_fixed_string_t ip_version;
15578 uint32_t vlan_present:1;
15580 struct rte_ether_addr eth_src;
15581 struct rte_ether_addr eth_dst;
15584 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15585 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15586 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15587 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15588 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15589 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15590 "l2_encap-with-vlan");
15591 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15592 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15594 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15595 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15597 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15598 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15600 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15601 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15602 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15603 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15605 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15606 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15607 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15608 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15610 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15611 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15613 static void cmd_set_l2_encap_parsed(void *parsed_result,
15614 __attribute__((unused)) struct cmdline *cl,
15615 __attribute__((unused)) void *data)
15617 struct cmd_set_l2_encap_result *res = parsed_result;
15619 if (strcmp(res->l2_encap, "l2_encap") == 0)
15620 l2_encap_conf.select_vlan = 0;
15621 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15622 l2_encap_conf.select_vlan = 1;
15623 if (strcmp(res->ip_version, "ipv4") == 0)
15624 l2_encap_conf.select_ipv4 = 1;
15625 else if (strcmp(res->ip_version, "ipv6") == 0)
15626 l2_encap_conf.select_ipv4 = 0;
15629 if (l2_encap_conf.select_vlan)
15630 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15631 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15632 RTE_ETHER_ADDR_LEN);
15633 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15634 RTE_ETHER_ADDR_LEN);
15637 cmdline_parse_inst_t cmd_set_l2_encap = {
15638 .f = cmd_set_l2_encap_parsed,
15640 .help_str = "set l2_encap ip-version ipv4|ipv6"
15641 " eth-src <eth-src> eth-dst <eth-dst>",
15643 (void *)&cmd_set_l2_encap_set,
15644 (void *)&cmd_set_l2_encap_l2_encap,
15645 (void *)&cmd_set_l2_encap_ip_version,
15646 (void *)&cmd_set_l2_encap_ip_version_value,
15647 (void *)&cmd_set_l2_encap_eth_src,
15648 (void *)&cmd_set_l2_encap_eth_src_value,
15649 (void *)&cmd_set_l2_encap_eth_dst,
15650 (void *)&cmd_set_l2_encap_eth_dst_value,
15655 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15656 .f = cmd_set_l2_encap_parsed,
15658 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15659 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15661 (void *)&cmd_set_l2_encap_set,
15662 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15663 (void *)&cmd_set_l2_encap_ip_version,
15664 (void *)&cmd_set_l2_encap_ip_version_value,
15665 (void *)&cmd_set_l2_encap_vlan,
15666 (void *)&cmd_set_l2_encap_vlan_value,
15667 (void *)&cmd_set_l2_encap_eth_src,
15668 (void *)&cmd_set_l2_encap_eth_src_value,
15669 (void *)&cmd_set_l2_encap_eth_dst,
15670 (void *)&cmd_set_l2_encap_eth_dst_value,
15675 /** Set L2 decapsulation details */
15676 struct cmd_set_l2_decap_result {
15677 cmdline_fixed_string_t set;
15678 cmdline_fixed_string_t l2_decap;
15679 cmdline_fixed_string_t pos_token;
15680 uint32_t vlan_present:1;
15683 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15684 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15685 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15686 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15688 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15689 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15690 "l2_decap-with-vlan");
15692 static void cmd_set_l2_decap_parsed(void *parsed_result,
15693 __attribute__((unused)) struct cmdline *cl,
15694 __attribute__((unused)) void *data)
15696 struct cmd_set_l2_decap_result *res = parsed_result;
15698 if (strcmp(res->l2_decap, "l2_decap") == 0)
15699 l2_decap_conf.select_vlan = 0;
15700 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15701 l2_decap_conf.select_vlan = 1;
15704 cmdline_parse_inst_t cmd_set_l2_decap = {
15705 .f = cmd_set_l2_decap_parsed,
15707 .help_str = "set l2_decap",
15709 (void *)&cmd_set_l2_decap_set,
15710 (void *)&cmd_set_l2_decap_l2_decap,
15715 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15716 .f = cmd_set_l2_decap_parsed,
15718 .help_str = "set l2_decap-with-vlan",
15720 (void *)&cmd_set_l2_decap_set,
15721 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15726 /** Set MPLSoGRE encapsulation details */
15727 struct cmd_set_mplsogre_encap_result {
15728 cmdline_fixed_string_t set;
15729 cmdline_fixed_string_t mplsogre;
15730 cmdline_fixed_string_t pos_token;
15731 cmdline_fixed_string_t ip_version;
15732 uint32_t vlan_present:1;
15734 cmdline_ipaddr_t ip_src;
15735 cmdline_ipaddr_t ip_dst;
15737 struct rte_ether_addr eth_src;
15738 struct rte_ether_addr eth_dst;
15741 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15742 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15744 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15745 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15747 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15748 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15749 mplsogre, "mplsogre_encap-with-vlan");
15750 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15751 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15752 pos_token, "ip-version");
15753 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15754 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15755 ip_version, "ipv4#ipv6");
15756 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15757 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15758 pos_token, "label");
15759 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15760 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15762 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15763 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15764 pos_token, "ip-src");
15765 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15766 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15767 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15768 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15769 pos_token, "ip-dst");
15770 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15771 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15772 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15773 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15774 pos_token, "vlan-tci");
15775 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15776 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15778 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15779 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15780 pos_token, "eth-src");
15781 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15782 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15784 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15785 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15786 pos_token, "eth-dst");
15787 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15788 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15791 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15792 __attribute__((unused)) struct cmdline *cl,
15793 __attribute__((unused)) void *data)
15795 struct cmd_set_mplsogre_encap_result *res = parsed_result;
15797 uint32_t mplsogre_label;
15800 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15803 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15804 mplsogre_encap_conf.select_vlan = 0;
15805 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15806 mplsogre_encap_conf.select_vlan = 1;
15807 if (strcmp(res->ip_version, "ipv4") == 0)
15808 mplsogre_encap_conf.select_ipv4 = 1;
15809 else if (strcmp(res->ip_version, "ipv6") == 0)
15810 mplsogre_encap_conf.select_ipv4 = 0;
15813 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15814 if (mplsogre_encap_conf.select_ipv4) {
15815 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15816 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15818 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15819 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15821 if (mplsogre_encap_conf.select_vlan)
15822 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15823 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15824 RTE_ETHER_ADDR_LEN);
15825 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15826 RTE_ETHER_ADDR_LEN);
15829 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15830 .f = cmd_set_mplsogre_encap_parsed,
15832 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15833 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15834 " eth-dst <eth-dst>",
15836 (void *)&cmd_set_mplsogre_encap_set,
15837 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15838 (void *)&cmd_set_mplsogre_encap_ip_version,
15839 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15840 (void *)&cmd_set_mplsogre_encap_label,
15841 (void *)&cmd_set_mplsogre_encap_label_value,
15842 (void *)&cmd_set_mplsogre_encap_ip_src,
15843 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15844 (void *)&cmd_set_mplsogre_encap_ip_dst,
15845 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15846 (void *)&cmd_set_mplsogre_encap_eth_src,
15847 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15848 (void *)&cmd_set_mplsogre_encap_eth_dst,
15849 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15854 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
15855 .f = cmd_set_mplsogre_encap_parsed,
15857 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
15858 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
15859 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15861 (void *)&cmd_set_mplsogre_encap_set,
15862 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
15863 (void *)&cmd_set_mplsogre_encap_ip_version,
15864 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15865 (void *)&cmd_set_mplsogre_encap_label,
15866 (void *)&cmd_set_mplsogre_encap_label_value,
15867 (void *)&cmd_set_mplsogre_encap_ip_src,
15868 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15869 (void *)&cmd_set_mplsogre_encap_ip_dst,
15870 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15871 (void *)&cmd_set_mplsogre_encap_vlan,
15872 (void *)&cmd_set_mplsogre_encap_vlan_value,
15873 (void *)&cmd_set_mplsogre_encap_eth_src,
15874 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15875 (void *)&cmd_set_mplsogre_encap_eth_dst,
15876 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15881 /** Set MPLSoGRE decapsulation details */
15882 struct cmd_set_mplsogre_decap_result {
15883 cmdline_fixed_string_t set;
15884 cmdline_fixed_string_t mplsogre;
15885 cmdline_fixed_string_t pos_token;
15886 cmdline_fixed_string_t ip_version;
15887 uint32_t vlan_present:1;
15890 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
15891 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
15893 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
15894 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
15896 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
15897 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15898 mplsogre, "mplsogre_decap-with-vlan");
15899 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
15900 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15901 pos_token, "ip-version");
15902 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
15903 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15904 ip_version, "ipv4#ipv6");
15906 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
15907 __attribute__((unused)) struct cmdline *cl,
15908 __attribute__((unused)) void *data)
15910 struct cmd_set_mplsogre_decap_result *res = parsed_result;
15912 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
15913 mplsogre_decap_conf.select_vlan = 0;
15914 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
15915 mplsogre_decap_conf.select_vlan = 1;
15916 if (strcmp(res->ip_version, "ipv4") == 0)
15917 mplsogre_decap_conf.select_ipv4 = 1;
15918 else if (strcmp(res->ip_version, "ipv6") == 0)
15919 mplsogre_decap_conf.select_ipv4 = 0;
15922 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
15923 .f = cmd_set_mplsogre_decap_parsed,
15925 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
15927 (void *)&cmd_set_mplsogre_decap_set,
15928 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
15929 (void *)&cmd_set_mplsogre_decap_ip_version,
15930 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15935 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
15936 .f = cmd_set_mplsogre_decap_parsed,
15938 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
15940 (void *)&cmd_set_mplsogre_decap_set,
15941 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
15942 (void *)&cmd_set_mplsogre_decap_ip_version,
15943 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15948 /** Set MPLSoUDP encapsulation details */
15949 struct cmd_set_mplsoudp_encap_result {
15950 cmdline_fixed_string_t set;
15951 cmdline_fixed_string_t mplsoudp;
15952 cmdline_fixed_string_t pos_token;
15953 cmdline_fixed_string_t ip_version;
15954 uint32_t vlan_present:1;
15958 cmdline_ipaddr_t ip_src;
15959 cmdline_ipaddr_t ip_dst;
15961 struct rte_ether_addr eth_src;
15962 struct rte_ether_addr eth_dst;
15965 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
15966 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
15968 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
15969 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
15971 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
15972 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15973 mplsoudp, "mplsoudp_encap-with-vlan");
15974 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
15975 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15976 pos_token, "ip-version");
15977 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
15978 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15979 ip_version, "ipv4#ipv6");
15980 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
15981 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15982 pos_token, "label");
15983 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
15984 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
15986 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
15987 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15988 pos_token, "udp-src");
15989 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
15990 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
15992 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
15993 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15994 pos_token, "udp-dst");
15995 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
15996 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
15998 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
15999 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16000 pos_token, "ip-src");
16001 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16002 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16003 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16004 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16005 pos_token, "ip-dst");
16006 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16007 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16008 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16009 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16010 pos_token, "vlan-tci");
16011 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16012 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16014 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16015 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16016 pos_token, "eth-src");
16017 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16018 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16020 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16021 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16022 pos_token, "eth-dst");
16023 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16024 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16027 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16028 __attribute__((unused)) struct cmdline *cl,
16029 __attribute__((unused)) void *data)
16031 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16033 uint32_t mplsoudp_label;
16036 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16039 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16040 mplsoudp_encap_conf.select_vlan = 0;
16041 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16042 mplsoudp_encap_conf.select_vlan = 1;
16043 if (strcmp(res->ip_version, "ipv4") == 0)
16044 mplsoudp_encap_conf.select_ipv4 = 1;
16045 else if (strcmp(res->ip_version, "ipv6") == 0)
16046 mplsoudp_encap_conf.select_ipv4 = 0;
16049 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16050 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16051 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16052 if (mplsoudp_encap_conf.select_ipv4) {
16053 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16054 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16056 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16057 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16059 if (mplsoudp_encap_conf.select_vlan)
16060 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16061 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16062 RTE_ETHER_ADDR_LEN);
16063 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16064 RTE_ETHER_ADDR_LEN);
16067 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16068 .f = cmd_set_mplsoudp_encap_parsed,
16070 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16071 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16072 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16074 (void *)&cmd_set_mplsoudp_encap_set,
16075 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16076 (void *)&cmd_set_mplsoudp_encap_ip_version,
16077 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16078 (void *)&cmd_set_mplsoudp_encap_label,
16079 (void *)&cmd_set_mplsoudp_encap_label_value,
16080 (void *)&cmd_set_mplsoudp_encap_udp_src,
16081 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16082 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16083 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16084 (void *)&cmd_set_mplsoudp_encap_ip_src,
16085 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16086 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16087 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16088 (void *)&cmd_set_mplsoudp_encap_eth_src,
16089 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16090 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16091 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16096 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16097 .f = cmd_set_mplsoudp_encap_parsed,
16099 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16100 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16101 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16102 " eth-src <eth-src> eth-dst <eth-dst>",
16104 (void *)&cmd_set_mplsoudp_encap_set,
16105 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16106 (void *)&cmd_set_mplsoudp_encap_ip_version,
16107 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16108 (void *)&cmd_set_mplsoudp_encap_label,
16109 (void *)&cmd_set_mplsoudp_encap_label_value,
16110 (void *)&cmd_set_mplsoudp_encap_udp_src,
16111 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16112 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16113 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16114 (void *)&cmd_set_mplsoudp_encap_ip_src,
16115 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16116 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16117 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16118 (void *)&cmd_set_mplsoudp_encap_vlan,
16119 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16120 (void *)&cmd_set_mplsoudp_encap_eth_src,
16121 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16122 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16123 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16128 /** Set MPLSoUDP decapsulation details */
16129 struct cmd_set_mplsoudp_decap_result {
16130 cmdline_fixed_string_t set;
16131 cmdline_fixed_string_t mplsoudp;
16132 cmdline_fixed_string_t pos_token;
16133 cmdline_fixed_string_t ip_version;
16134 uint32_t vlan_present:1;
16137 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16138 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16140 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16141 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16143 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16144 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16145 mplsoudp, "mplsoudp_decap-with-vlan");
16146 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16147 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16148 pos_token, "ip-version");
16149 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16150 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16151 ip_version, "ipv4#ipv6");
16153 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16154 __attribute__((unused)) struct cmdline *cl,
16155 __attribute__((unused)) void *data)
16157 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16159 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16160 mplsoudp_decap_conf.select_vlan = 0;
16161 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16162 mplsoudp_decap_conf.select_vlan = 1;
16163 if (strcmp(res->ip_version, "ipv4") == 0)
16164 mplsoudp_decap_conf.select_ipv4 = 1;
16165 else if (strcmp(res->ip_version, "ipv6") == 0)
16166 mplsoudp_decap_conf.select_ipv4 = 0;
16169 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16170 .f = cmd_set_mplsoudp_decap_parsed,
16172 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16174 (void *)&cmd_set_mplsoudp_decap_set,
16175 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16176 (void *)&cmd_set_mplsoudp_decap_ip_version,
16177 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16182 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16183 .f = cmd_set_mplsoudp_decap_parsed,
16185 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16187 (void *)&cmd_set_mplsoudp_decap_set,
16188 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16189 (void *)&cmd_set_mplsoudp_decap_ip_version,
16190 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16195 /* Strict link priority scheduling mode setting */
16197 cmd_strict_link_prio_parsed(
16198 void *parsed_result,
16199 __attribute__((unused)) struct cmdline *cl,
16200 __attribute__((unused)) void *data)
16202 struct cmd_vf_tc_bw_result *res = parsed_result;
16203 int ret = -ENOTSUP;
16205 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16208 #ifdef RTE_LIBRTE_I40E_PMD
16209 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16216 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16219 printf("invalid port_id %d\n", res->port_id);
16222 printf("function not implemented\n");
16225 printf("programming error: (%s)\n", strerror(-ret));
16229 cmdline_parse_inst_t cmd_strict_link_prio = {
16230 .f = cmd_strict_link_prio_parsed,
16232 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16234 (void *)&cmd_vf_tc_bw_set,
16235 (void *)&cmd_vf_tc_bw_tx,
16236 (void *)&cmd_vf_tc_bw_strict_link_prio,
16237 (void *)&cmd_vf_tc_bw_port_id,
16238 (void *)&cmd_vf_tc_bw_tc_map,
16243 /* Load dynamic device personalization*/
16244 struct cmd_ddp_add_result {
16245 cmdline_fixed_string_t ddp;
16246 cmdline_fixed_string_t add;
16251 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16252 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16253 cmdline_parse_token_string_t cmd_ddp_add_add =
16254 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16255 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16256 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16257 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16258 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16261 cmd_ddp_add_parsed(
16262 void *parsed_result,
16263 __attribute__((unused)) struct cmdline *cl,
16264 __attribute__((unused)) void *data)
16266 struct cmd_ddp_add_result *res = parsed_result;
16272 int ret = -ENOTSUP;
16274 if (!all_ports_stopped()) {
16275 printf("Please stop all ports first\n");
16279 filepath = strdup(res->filepath);
16280 if (filepath == NULL) {
16281 printf("Failed to allocate memory\n");
16284 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16286 buff = open_file(file_fld[0], &size);
16288 free((void *)filepath);
16292 #ifdef RTE_LIBRTE_I40E_PMD
16293 if (ret == -ENOTSUP)
16294 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16296 RTE_PMD_I40E_PKG_OP_WR_ADD);
16299 if (ret == -EEXIST)
16300 printf("Profile has already existed.\n");
16302 printf("Failed to load profile.\n");
16303 else if (file_num == 2)
16304 save_file(file_fld[1], buff, size);
16307 free((void *)filepath);
16310 cmdline_parse_inst_t cmd_ddp_add = {
16311 .f = cmd_ddp_add_parsed,
16313 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16315 (void *)&cmd_ddp_add_ddp,
16316 (void *)&cmd_ddp_add_add,
16317 (void *)&cmd_ddp_add_port_id,
16318 (void *)&cmd_ddp_add_filepath,
16323 /* Delete dynamic device personalization*/
16324 struct cmd_ddp_del_result {
16325 cmdline_fixed_string_t ddp;
16326 cmdline_fixed_string_t del;
16331 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16332 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16333 cmdline_parse_token_string_t cmd_ddp_del_del =
16334 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16335 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16336 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16337 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16338 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16341 cmd_ddp_del_parsed(
16342 void *parsed_result,
16343 __attribute__((unused)) struct cmdline *cl,
16344 __attribute__((unused)) void *data)
16346 struct cmd_ddp_del_result *res = parsed_result;
16349 int ret = -ENOTSUP;
16351 if (!all_ports_stopped()) {
16352 printf("Please stop all ports first\n");
16356 buff = open_file(res->filepath, &size);
16360 #ifdef RTE_LIBRTE_I40E_PMD
16361 if (ret == -ENOTSUP)
16362 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16364 RTE_PMD_I40E_PKG_OP_WR_DEL);
16367 if (ret == -EACCES)
16368 printf("Profile does not exist.\n");
16370 printf("Failed to delete profile.\n");
16375 cmdline_parse_inst_t cmd_ddp_del = {
16376 .f = cmd_ddp_del_parsed,
16378 .help_str = "ddp del <port_id> <backup_profile_path>",
16380 (void *)&cmd_ddp_del_ddp,
16381 (void *)&cmd_ddp_del_del,
16382 (void *)&cmd_ddp_del_port_id,
16383 (void *)&cmd_ddp_del_filepath,
16388 /* Get dynamic device personalization profile info */
16389 struct cmd_ddp_info_result {
16390 cmdline_fixed_string_t ddp;
16391 cmdline_fixed_string_t get;
16392 cmdline_fixed_string_t info;
16396 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16397 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16398 cmdline_parse_token_string_t cmd_ddp_info_get =
16399 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16400 cmdline_parse_token_string_t cmd_ddp_info_info =
16401 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16402 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16403 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16406 cmd_ddp_info_parsed(
16407 void *parsed_result,
16408 __attribute__((unused)) struct cmdline *cl,
16409 __attribute__((unused)) void *data)
16411 struct cmd_ddp_info_result *res = parsed_result;
16414 int ret = -ENOTSUP;
16415 #ifdef RTE_LIBRTE_I40E_PMD
16418 uint32_t buff_size = 0;
16419 struct rte_pmd_i40e_profile_info info;
16420 uint32_t dev_num = 0;
16421 struct rte_pmd_i40e_ddp_device_id *devs;
16422 uint32_t proto_num = 0;
16423 struct rte_pmd_i40e_proto_info *proto = NULL;
16424 uint32_t pctype_num = 0;
16425 struct rte_pmd_i40e_ptype_info *pctype;
16426 uint32_t ptype_num = 0;
16427 struct rte_pmd_i40e_ptype_info *ptype;
16432 pkg = open_file(res->filepath, &pkg_size);
16436 #ifdef RTE_LIBRTE_I40E_PMD
16437 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16438 (uint8_t *)&info, sizeof(info),
16439 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16441 printf("Global Track id: 0x%x\n", info.track_id);
16442 printf("Global Version: %d.%d.%d.%d\n",
16443 info.version.major,
16444 info.version.minor,
16445 info.version.update,
16446 info.version.draft);
16447 printf("Global Package name: %s\n\n", info.name);
16450 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16451 (uint8_t *)&info, sizeof(info),
16452 RTE_PMD_I40E_PKG_INFO_HEADER);
16454 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16455 printf("i40e Profile Version: %d.%d.%d.%d\n",
16456 info.version.major,
16457 info.version.minor,
16458 info.version.update,
16459 info.version.draft);
16460 printf("i40e Profile name: %s\n\n", info.name);
16463 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16464 (uint8_t *)&buff_size, sizeof(buff_size),
16465 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16466 if (!ret && buff_size) {
16467 buff = (uint8_t *)malloc(buff_size);
16469 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16471 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16473 printf("Package Notes:\n%s\n\n", buff);
16478 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16479 (uint8_t *)&dev_num, sizeof(dev_num),
16480 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16481 if (!ret && dev_num) {
16482 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16483 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16485 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16486 (uint8_t *)devs, buff_size,
16487 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16489 printf("List of supported devices:\n");
16490 for (i = 0; i < dev_num; i++) {
16491 printf(" %04X:%04X %04X:%04X\n",
16492 devs[i].vendor_dev_id >> 16,
16493 devs[i].vendor_dev_id & 0xFFFF,
16494 devs[i].sub_vendor_dev_id >> 16,
16495 devs[i].sub_vendor_dev_id & 0xFFFF);
16503 /* get information about protocols and packet types */
16504 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16505 (uint8_t *)&proto_num, sizeof(proto_num),
16506 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16507 if (ret || !proto_num)
16508 goto no_print_return;
16510 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16511 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16513 goto no_print_return;
16515 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16517 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16519 printf("List of used protocols:\n");
16520 for (i = 0; i < proto_num; i++)
16521 printf(" %2u: %s\n", proto[i].proto_id,
16525 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16526 (uint8_t *)&pctype_num, sizeof(pctype_num),
16527 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16528 if (ret || !pctype_num)
16529 goto no_print_pctypes;
16531 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16532 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16534 goto no_print_pctypes;
16536 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16538 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16541 goto no_print_pctypes;
16544 printf("List of defined packet classification types:\n");
16545 for (i = 0; i < pctype_num; i++) {
16546 printf(" %2u:", pctype[i].ptype_id);
16547 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16548 proto_id = pctype[i].protocols[j];
16549 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16550 for (n = 0; n < proto_num; n++) {
16551 if (proto[n].proto_id == proto_id) {
16552 printf(" %s", proto[n].name);
16565 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16567 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16568 if (ret || !ptype_num)
16569 goto no_print_return;
16571 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16572 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16574 goto no_print_return;
16576 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16578 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16581 goto no_print_return;
16583 printf("List of defined packet types:\n");
16584 for (i = 0; i < ptype_num; i++) {
16585 printf(" %2u:", ptype[i].ptype_id);
16586 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16587 proto_id = ptype[i].protocols[j];
16588 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16589 for (n = 0; n < proto_num; n++) {
16590 if (proto[n].proto_id == proto_id) {
16591 printf(" %s", proto[n].name);
16607 if (ret == -ENOTSUP)
16608 printf("Function not supported in PMD driver\n");
16612 cmdline_parse_inst_t cmd_ddp_get_info = {
16613 .f = cmd_ddp_info_parsed,
16615 .help_str = "ddp get info <profile_path>",
16617 (void *)&cmd_ddp_info_ddp,
16618 (void *)&cmd_ddp_info_get,
16619 (void *)&cmd_ddp_info_info,
16620 (void *)&cmd_ddp_info_filepath,
16625 /* Get dynamic device personalization profile info list*/
16626 #define PROFILE_INFO_SIZE 48
16627 #define MAX_PROFILE_NUM 16
16629 struct cmd_ddp_get_list_result {
16630 cmdline_fixed_string_t ddp;
16631 cmdline_fixed_string_t get;
16632 cmdline_fixed_string_t list;
16636 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16637 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16638 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16639 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16640 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16641 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16642 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16643 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16646 cmd_ddp_get_list_parsed(
16647 __attribute__((unused)) void *parsed_result,
16648 __attribute__((unused)) struct cmdline *cl,
16649 __attribute__((unused)) void *data)
16651 #ifdef RTE_LIBRTE_I40E_PMD
16652 struct cmd_ddp_get_list_result *res = parsed_result;
16653 struct rte_pmd_i40e_profile_list *p_list;
16654 struct rte_pmd_i40e_profile_info *p_info;
16659 int ret = -ENOTSUP;
16661 #ifdef RTE_LIBRTE_I40E_PMD
16662 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16663 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16665 printf("%s: Failed to malloc buffer\n", __func__);
16667 if (ret == -ENOTSUP)
16668 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16669 (uint8_t *)p_list, size);
16672 p_num = p_list->p_count;
16673 printf("Profile number is: %d\n\n", p_num);
16675 for (i = 0; i < p_num; i++) {
16676 p_info = &p_list->p_info[i];
16677 printf("Profile %d:\n", i);
16678 printf("Track id: 0x%x\n", p_info->track_id);
16679 printf("Version: %d.%d.%d.%d\n",
16680 p_info->version.major,
16681 p_info->version.minor,
16682 p_info->version.update,
16683 p_info->version.draft);
16684 printf("Profile name: %s\n\n", p_info->name);
16692 printf("Failed to get ddp list\n");
16695 cmdline_parse_inst_t cmd_ddp_get_list = {
16696 .f = cmd_ddp_get_list_parsed,
16698 .help_str = "ddp get list <port_id>",
16700 (void *)&cmd_ddp_get_list_ddp,
16701 (void *)&cmd_ddp_get_list_get,
16702 (void *)&cmd_ddp_get_list_list,
16703 (void *)&cmd_ddp_get_list_port_id,
16708 /* Configure input set */
16709 struct cmd_cfg_input_set_result {
16710 cmdline_fixed_string_t port;
16711 cmdline_fixed_string_t cfg;
16713 cmdline_fixed_string_t pctype;
16715 cmdline_fixed_string_t inset_type;
16716 cmdline_fixed_string_t opt;
16717 cmdline_fixed_string_t field;
16722 cmd_cfg_input_set_parsed(
16723 __attribute__((unused)) void *parsed_result,
16724 __attribute__((unused)) struct cmdline *cl,
16725 __attribute__((unused)) void *data)
16727 #ifdef RTE_LIBRTE_I40E_PMD
16728 struct cmd_cfg_input_set_result *res = parsed_result;
16729 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16730 struct rte_pmd_i40e_inset inset;
16732 int ret = -ENOTSUP;
16734 if (!all_ports_stopped()) {
16735 printf("Please stop all ports first\n");
16739 #ifdef RTE_LIBRTE_I40E_PMD
16740 if (!strcmp(res->inset_type, "hash_inset"))
16741 inset_type = INSET_HASH;
16742 else if (!strcmp(res->inset_type, "fdir_inset"))
16743 inset_type = INSET_FDIR;
16744 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16745 inset_type = INSET_FDIR_FLX;
16746 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16747 &inset, inset_type);
16749 printf("Failed to get input set.\n");
16753 if (!strcmp(res->opt, "get")) {
16754 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16757 printf("Field index %d is enabled.\n", res->field_idx);
16759 printf("Field index %d is disabled.\n", res->field_idx);
16761 } else if (!strcmp(res->opt, "set"))
16762 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16764 else if (!strcmp(res->opt, "clear"))
16765 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16768 printf("Failed to configure input set field.\n");
16772 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16773 &inset, inset_type);
16775 printf("Failed to set input set.\n");
16780 if (ret == -ENOTSUP)
16781 printf("Function not supported\n");
16784 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16785 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16787 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16788 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16790 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16791 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16793 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16794 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16796 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16797 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16799 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16800 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16802 "hash_inset#fdir_inset#fdir_flx_inset");
16803 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16804 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16805 opt, "get#set#clear");
16806 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16807 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16809 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16810 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16813 cmdline_parse_inst_t cmd_cfg_input_set = {
16814 .f = cmd_cfg_input_set_parsed,
16816 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16817 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16819 (void *)&cmd_cfg_input_set_port,
16820 (void *)&cmd_cfg_input_set_cfg,
16821 (void *)&cmd_cfg_input_set_port_id,
16822 (void *)&cmd_cfg_input_set_pctype,
16823 (void *)&cmd_cfg_input_set_pctype_id,
16824 (void *)&cmd_cfg_input_set_inset_type,
16825 (void *)&cmd_cfg_input_set_opt,
16826 (void *)&cmd_cfg_input_set_field,
16827 (void *)&cmd_cfg_input_set_field_idx,
16832 /* Clear input set */
16833 struct cmd_clear_input_set_result {
16834 cmdline_fixed_string_t port;
16835 cmdline_fixed_string_t cfg;
16837 cmdline_fixed_string_t pctype;
16839 cmdline_fixed_string_t inset_type;
16840 cmdline_fixed_string_t clear;
16841 cmdline_fixed_string_t all;
16845 cmd_clear_input_set_parsed(
16846 __attribute__((unused)) void *parsed_result,
16847 __attribute__((unused)) struct cmdline *cl,
16848 __attribute__((unused)) void *data)
16850 #ifdef RTE_LIBRTE_I40E_PMD
16851 struct cmd_clear_input_set_result *res = parsed_result;
16852 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16853 struct rte_pmd_i40e_inset inset;
16855 int ret = -ENOTSUP;
16857 if (!all_ports_stopped()) {
16858 printf("Please stop all ports first\n");
16862 #ifdef RTE_LIBRTE_I40E_PMD
16863 if (!strcmp(res->inset_type, "hash_inset"))
16864 inset_type = INSET_HASH;
16865 else if (!strcmp(res->inset_type, "fdir_inset"))
16866 inset_type = INSET_FDIR;
16867 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16868 inset_type = INSET_FDIR_FLX;
16870 memset(&inset, 0, sizeof(inset));
16872 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16873 &inset, inset_type);
16875 printf("Failed to clear input set.\n");
16881 if (ret == -ENOTSUP)
16882 printf("Function not supported\n");
16885 cmdline_parse_token_string_t cmd_clear_input_set_port =
16886 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16888 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
16889 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16891 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
16892 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16894 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
16895 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16897 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
16898 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16900 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
16901 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16903 "hash_inset#fdir_inset#fdir_flx_inset");
16904 cmdline_parse_token_string_t cmd_clear_input_set_clear =
16905 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16907 cmdline_parse_token_string_t cmd_clear_input_set_all =
16908 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16911 cmdline_parse_inst_t cmd_clear_input_set = {
16912 .f = cmd_clear_input_set_parsed,
16914 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16915 "fdir_inset|fdir_flx_inset clear all",
16917 (void *)&cmd_clear_input_set_port,
16918 (void *)&cmd_clear_input_set_cfg,
16919 (void *)&cmd_clear_input_set_port_id,
16920 (void *)&cmd_clear_input_set_pctype,
16921 (void *)&cmd_clear_input_set_pctype_id,
16922 (void *)&cmd_clear_input_set_inset_type,
16923 (void *)&cmd_clear_input_set_clear,
16924 (void *)&cmd_clear_input_set_all,
16929 /* show vf stats */
16931 /* Common result structure for show vf stats */
16932 struct cmd_show_vf_stats_result {
16933 cmdline_fixed_string_t show;
16934 cmdline_fixed_string_t vf;
16935 cmdline_fixed_string_t stats;
16940 /* Common CLI fields show vf stats*/
16941 cmdline_parse_token_string_t cmd_show_vf_stats_show =
16942 TOKEN_STRING_INITIALIZER
16943 (struct cmd_show_vf_stats_result,
16945 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
16946 TOKEN_STRING_INITIALIZER
16947 (struct cmd_show_vf_stats_result,
16949 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
16950 TOKEN_STRING_INITIALIZER
16951 (struct cmd_show_vf_stats_result,
16953 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
16954 TOKEN_NUM_INITIALIZER
16955 (struct cmd_show_vf_stats_result,
16957 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
16958 TOKEN_NUM_INITIALIZER
16959 (struct cmd_show_vf_stats_result,
16963 cmd_show_vf_stats_parsed(
16964 void *parsed_result,
16965 __attribute__((unused)) struct cmdline *cl,
16966 __attribute__((unused)) void *data)
16968 struct cmd_show_vf_stats_result *res = parsed_result;
16969 struct rte_eth_stats stats;
16970 int ret = -ENOTSUP;
16971 static const char *nic_stats_border = "########################";
16973 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16976 memset(&stats, 0, sizeof(stats));
16978 #ifdef RTE_LIBRTE_I40E_PMD
16979 if (ret == -ENOTSUP)
16980 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
16984 #ifdef RTE_LIBRTE_BNXT_PMD
16985 if (ret == -ENOTSUP)
16986 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
16995 printf("invalid vf_id %d\n", res->vf_id);
16998 printf("invalid port_id %d\n", res->port_id);
17001 printf("function not implemented\n");
17004 printf("programming error: (%s)\n", strerror(-ret));
17007 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17008 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17010 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17012 stats.ipackets, stats.imissed, stats.ibytes);
17013 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17014 printf(" RX-nombuf: %-10"PRIu64"\n",
17016 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17018 stats.opackets, stats.oerrors, stats.obytes);
17020 printf(" %s############################%s\n",
17021 nic_stats_border, nic_stats_border);
17024 cmdline_parse_inst_t cmd_show_vf_stats = {
17025 .f = cmd_show_vf_stats_parsed,
17027 .help_str = "show vf stats <port_id> <vf_id>",
17029 (void *)&cmd_show_vf_stats_show,
17030 (void *)&cmd_show_vf_stats_vf,
17031 (void *)&cmd_show_vf_stats_stats,
17032 (void *)&cmd_show_vf_stats_port_id,
17033 (void *)&cmd_show_vf_stats_vf_id,
17038 /* clear vf stats */
17040 /* Common result structure for clear vf stats */
17041 struct cmd_clear_vf_stats_result {
17042 cmdline_fixed_string_t clear;
17043 cmdline_fixed_string_t vf;
17044 cmdline_fixed_string_t stats;
17049 /* Common CLI fields clear vf stats*/
17050 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17051 TOKEN_STRING_INITIALIZER
17052 (struct cmd_clear_vf_stats_result,
17054 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17055 TOKEN_STRING_INITIALIZER
17056 (struct cmd_clear_vf_stats_result,
17058 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17059 TOKEN_STRING_INITIALIZER
17060 (struct cmd_clear_vf_stats_result,
17062 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17063 TOKEN_NUM_INITIALIZER
17064 (struct cmd_clear_vf_stats_result,
17066 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17067 TOKEN_NUM_INITIALIZER
17068 (struct cmd_clear_vf_stats_result,
17072 cmd_clear_vf_stats_parsed(
17073 void *parsed_result,
17074 __attribute__((unused)) struct cmdline *cl,
17075 __attribute__((unused)) void *data)
17077 struct cmd_clear_vf_stats_result *res = parsed_result;
17078 int ret = -ENOTSUP;
17080 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17083 #ifdef RTE_LIBRTE_I40E_PMD
17084 if (ret == -ENOTSUP)
17085 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17088 #ifdef RTE_LIBRTE_BNXT_PMD
17089 if (ret == -ENOTSUP)
17090 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17098 printf("invalid vf_id %d\n", res->vf_id);
17101 printf("invalid port_id %d\n", res->port_id);
17104 printf("function not implemented\n");
17107 printf("programming error: (%s)\n", strerror(-ret));
17111 cmdline_parse_inst_t cmd_clear_vf_stats = {
17112 .f = cmd_clear_vf_stats_parsed,
17114 .help_str = "clear vf stats <port_id> <vf_id>",
17116 (void *)&cmd_clear_vf_stats_clear,
17117 (void *)&cmd_clear_vf_stats_vf,
17118 (void *)&cmd_clear_vf_stats_stats,
17119 (void *)&cmd_clear_vf_stats_port_id,
17120 (void *)&cmd_clear_vf_stats_vf_id,
17125 /* port config pctype mapping reset */
17127 /* Common result structure for port config pctype mapping reset */
17128 struct cmd_pctype_mapping_reset_result {
17129 cmdline_fixed_string_t port;
17130 cmdline_fixed_string_t config;
17132 cmdline_fixed_string_t pctype;
17133 cmdline_fixed_string_t mapping;
17134 cmdline_fixed_string_t reset;
17137 /* Common CLI fields for port config pctype mapping reset*/
17138 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17139 TOKEN_STRING_INITIALIZER
17140 (struct cmd_pctype_mapping_reset_result,
17142 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17143 TOKEN_STRING_INITIALIZER
17144 (struct cmd_pctype_mapping_reset_result,
17146 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17147 TOKEN_NUM_INITIALIZER
17148 (struct cmd_pctype_mapping_reset_result,
17150 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17151 TOKEN_STRING_INITIALIZER
17152 (struct cmd_pctype_mapping_reset_result,
17154 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17155 TOKEN_STRING_INITIALIZER
17156 (struct cmd_pctype_mapping_reset_result,
17157 mapping, "mapping");
17158 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17159 TOKEN_STRING_INITIALIZER
17160 (struct cmd_pctype_mapping_reset_result,
17164 cmd_pctype_mapping_reset_parsed(
17165 void *parsed_result,
17166 __attribute__((unused)) struct cmdline *cl,
17167 __attribute__((unused)) void *data)
17169 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17170 int ret = -ENOTSUP;
17172 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17175 #ifdef RTE_LIBRTE_I40E_PMD
17176 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17183 printf("invalid port_id %d\n", res->port_id);
17186 printf("function not implemented\n");
17189 printf("programming error: (%s)\n", strerror(-ret));
17193 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17194 .f = cmd_pctype_mapping_reset_parsed,
17196 .help_str = "port config <port_id> pctype mapping reset",
17198 (void *)&cmd_pctype_mapping_reset_port,
17199 (void *)&cmd_pctype_mapping_reset_config,
17200 (void *)&cmd_pctype_mapping_reset_port_id,
17201 (void *)&cmd_pctype_mapping_reset_pctype,
17202 (void *)&cmd_pctype_mapping_reset_mapping,
17203 (void *)&cmd_pctype_mapping_reset_reset,
17208 /* show port pctype mapping */
17210 /* Common result structure for show port pctype mapping */
17211 struct cmd_pctype_mapping_get_result {
17212 cmdline_fixed_string_t show;
17213 cmdline_fixed_string_t port;
17215 cmdline_fixed_string_t pctype;
17216 cmdline_fixed_string_t mapping;
17219 /* Common CLI fields for pctype mapping get */
17220 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17221 TOKEN_STRING_INITIALIZER
17222 (struct cmd_pctype_mapping_get_result,
17224 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17225 TOKEN_STRING_INITIALIZER
17226 (struct cmd_pctype_mapping_get_result,
17228 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17229 TOKEN_NUM_INITIALIZER
17230 (struct cmd_pctype_mapping_get_result,
17232 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17233 TOKEN_STRING_INITIALIZER
17234 (struct cmd_pctype_mapping_get_result,
17236 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17237 TOKEN_STRING_INITIALIZER
17238 (struct cmd_pctype_mapping_get_result,
17239 mapping, "mapping");
17242 cmd_pctype_mapping_get_parsed(
17243 void *parsed_result,
17244 __attribute__((unused)) struct cmdline *cl,
17245 __attribute__((unused)) void *data)
17247 struct cmd_pctype_mapping_get_result *res = parsed_result;
17248 int ret = -ENOTSUP;
17249 #ifdef RTE_LIBRTE_I40E_PMD
17250 struct rte_pmd_i40e_flow_type_mapping
17251 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17252 int i, j, first_pctype;
17255 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17258 #ifdef RTE_LIBRTE_I40E_PMD
17259 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17266 printf("invalid port_id %d\n", res->port_id);
17269 printf("function not implemented\n");
17272 printf("programming error: (%s)\n", strerror(-ret));
17276 #ifdef RTE_LIBRTE_I40E_PMD
17277 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17278 if (mapping[i].pctype != 0ULL) {
17281 printf("pctype: ");
17282 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17283 if (mapping[i].pctype & (1ULL << j)) {
17284 printf(first_pctype ?
17285 "%02d" : ",%02d", j);
17289 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17295 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17296 .f = cmd_pctype_mapping_get_parsed,
17298 .help_str = "show port <port_id> pctype mapping",
17300 (void *)&cmd_pctype_mapping_get_show,
17301 (void *)&cmd_pctype_mapping_get_port,
17302 (void *)&cmd_pctype_mapping_get_port_id,
17303 (void *)&cmd_pctype_mapping_get_pctype,
17304 (void *)&cmd_pctype_mapping_get_mapping,
17309 /* port config pctype mapping update */
17311 /* Common result structure for port config pctype mapping update */
17312 struct cmd_pctype_mapping_update_result {
17313 cmdline_fixed_string_t port;
17314 cmdline_fixed_string_t config;
17316 cmdline_fixed_string_t pctype;
17317 cmdline_fixed_string_t mapping;
17318 cmdline_fixed_string_t update;
17319 cmdline_fixed_string_t pctype_list;
17320 uint16_t flow_type;
17323 /* Common CLI fields for pctype mapping update*/
17324 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17325 TOKEN_STRING_INITIALIZER
17326 (struct cmd_pctype_mapping_update_result,
17328 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17329 TOKEN_STRING_INITIALIZER
17330 (struct cmd_pctype_mapping_update_result,
17332 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17333 TOKEN_NUM_INITIALIZER
17334 (struct cmd_pctype_mapping_update_result,
17336 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17337 TOKEN_STRING_INITIALIZER
17338 (struct cmd_pctype_mapping_update_result,
17340 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17341 TOKEN_STRING_INITIALIZER
17342 (struct cmd_pctype_mapping_update_result,
17343 mapping, "mapping");
17344 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17345 TOKEN_STRING_INITIALIZER
17346 (struct cmd_pctype_mapping_update_result,
17348 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17349 TOKEN_STRING_INITIALIZER
17350 (struct cmd_pctype_mapping_update_result,
17351 pctype_list, NULL);
17352 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17353 TOKEN_NUM_INITIALIZER
17354 (struct cmd_pctype_mapping_update_result,
17355 flow_type, UINT16);
17358 cmd_pctype_mapping_update_parsed(
17359 void *parsed_result,
17360 __attribute__((unused)) struct cmdline *cl,
17361 __attribute__((unused)) void *data)
17363 struct cmd_pctype_mapping_update_result *res = parsed_result;
17364 int ret = -ENOTSUP;
17365 #ifdef RTE_LIBRTE_I40E_PMD
17366 struct rte_pmd_i40e_flow_type_mapping mapping;
17368 unsigned int nb_item;
17369 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17372 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17375 #ifdef RTE_LIBRTE_I40E_PMD
17376 nb_item = parse_item_list(res->pctype_list, "pctypes",
17377 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17378 mapping.flow_type = res->flow_type;
17379 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17380 mapping.pctype |= (1ULL << pctype_list[i]);
17381 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17391 printf("invalid pctype or flow type\n");
17394 printf("invalid port_id %d\n", res->port_id);
17397 printf("function not implemented\n");
17400 printf("programming error: (%s)\n", strerror(-ret));
17404 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17405 .f = cmd_pctype_mapping_update_parsed,
17407 .help_str = "port config <port_id> pctype mapping update"
17408 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17410 (void *)&cmd_pctype_mapping_update_port,
17411 (void *)&cmd_pctype_mapping_update_config,
17412 (void *)&cmd_pctype_mapping_update_port_id,
17413 (void *)&cmd_pctype_mapping_update_pctype,
17414 (void *)&cmd_pctype_mapping_update_mapping,
17415 (void *)&cmd_pctype_mapping_update_update,
17416 (void *)&cmd_pctype_mapping_update_pc_type,
17417 (void *)&cmd_pctype_mapping_update_flow_type,
17422 /* ptype mapping get */
17424 /* Common result structure for ptype mapping get */
17425 struct cmd_ptype_mapping_get_result {
17426 cmdline_fixed_string_t ptype;
17427 cmdline_fixed_string_t mapping;
17428 cmdline_fixed_string_t get;
17430 uint8_t valid_only;
17433 /* Common CLI fields for ptype mapping get */
17434 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17435 TOKEN_STRING_INITIALIZER
17436 (struct cmd_ptype_mapping_get_result,
17438 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17439 TOKEN_STRING_INITIALIZER
17440 (struct cmd_ptype_mapping_get_result,
17441 mapping, "mapping");
17442 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17443 TOKEN_STRING_INITIALIZER
17444 (struct cmd_ptype_mapping_get_result,
17446 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17447 TOKEN_NUM_INITIALIZER
17448 (struct cmd_ptype_mapping_get_result,
17450 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17451 TOKEN_NUM_INITIALIZER
17452 (struct cmd_ptype_mapping_get_result,
17453 valid_only, UINT8);
17456 cmd_ptype_mapping_get_parsed(
17457 void *parsed_result,
17458 __attribute__((unused)) struct cmdline *cl,
17459 __attribute__((unused)) void *data)
17461 struct cmd_ptype_mapping_get_result *res = parsed_result;
17462 int ret = -ENOTSUP;
17463 #ifdef RTE_LIBRTE_I40E_PMD
17464 int max_ptype_num = 256;
17465 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17470 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17473 #ifdef RTE_LIBRTE_I40E_PMD
17474 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17485 printf("invalid port_id %d\n", res->port_id);
17488 printf("function not implemented\n");
17491 printf("programming error: (%s)\n", strerror(-ret));
17494 #ifdef RTE_LIBRTE_I40E_PMD
17496 for (i = 0; i < count; i++)
17497 printf("%3d\t0x%08x\n",
17498 mapping[i].hw_ptype, mapping[i].sw_ptype);
17503 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17504 .f = cmd_ptype_mapping_get_parsed,
17506 .help_str = "ptype mapping get <port_id> <valid_only>",
17508 (void *)&cmd_ptype_mapping_get_ptype,
17509 (void *)&cmd_ptype_mapping_get_mapping,
17510 (void *)&cmd_ptype_mapping_get_get,
17511 (void *)&cmd_ptype_mapping_get_port_id,
17512 (void *)&cmd_ptype_mapping_get_valid_only,
17517 /* ptype mapping replace */
17519 /* Common result structure for ptype mapping replace */
17520 struct cmd_ptype_mapping_replace_result {
17521 cmdline_fixed_string_t ptype;
17522 cmdline_fixed_string_t mapping;
17523 cmdline_fixed_string_t replace;
17530 /* Common CLI fields for ptype mapping replace */
17531 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17532 TOKEN_STRING_INITIALIZER
17533 (struct cmd_ptype_mapping_replace_result,
17535 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17536 TOKEN_STRING_INITIALIZER
17537 (struct cmd_ptype_mapping_replace_result,
17538 mapping, "mapping");
17539 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17540 TOKEN_STRING_INITIALIZER
17541 (struct cmd_ptype_mapping_replace_result,
17542 replace, "replace");
17543 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17544 TOKEN_NUM_INITIALIZER
17545 (struct cmd_ptype_mapping_replace_result,
17547 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17548 TOKEN_NUM_INITIALIZER
17549 (struct cmd_ptype_mapping_replace_result,
17551 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17552 TOKEN_NUM_INITIALIZER
17553 (struct cmd_ptype_mapping_replace_result,
17555 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17556 TOKEN_NUM_INITIALIZER
17557 (struct cmd_ptype_mapping_replace_result,
17561 cmd_ptype_mapping_replace_parsed(
17562 void *parsed_result,
17563 __attribute__((unused)) struct cmdline *cl,
17564 __attribute__((unused)) void *data)
17566 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17567 int ret = -ENOTSUP;
17569 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17572 #ifdef RTE_LIBRTE_I40E_PMD
17573 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17583 printf("invalid ptype 0x%8x or 0x%8x\n",
17584 res->target, res->pkt_type);
17587 printf("invalid port_id %d\n", res->port_id);
17590 printf("function not implemented\n");
17593 printf("programming error: (%s)\n", strerror(-ret));
17597 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17598 .f = cmd_ptype_mapping_replace_parsed,
17601 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17603 (void *)&cmd_ptype_mapping_replace_ptype,
17604 (void *)&cmd_ptype_mapping_replace_mapping,
17605 (void *)&cmd_ptype_mapping_replace_replace,
17606 (void *)&cmd_ptype_mapping_replace_port_id,
17607 (void *)&cmd_ptype_mapping_replace_target,
17608 (void *)&cmd_ptype_mapping_replace_mask,
17609 (void *)&cmd_ptype_mapping_replace_pkt_type,
17614 /* ptype mapping reset */
17616 /* Common result structure for ptype mapping reset */
17617 struct cmd_ptype_mapping_reset_result {
17618 cmdline_fixed_string_t ptype;
17619 cmdline_fixed_string_t mapping;
17620 cmdline_fixed_string_t reset;
17624 /* Common CLI fields for ptype mapping reset*/
17625 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17626 TOKEN_STRING_INITIALIZER
17627 (struct cmd_ptype_mapping_reset_result,
17629 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17630 TOKEN_STRING_INITIALIZER
17631 (struct cmd_ptype_mapping_reset_result,
17632 mapping, "mapping");
17633 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17634 TOKEN_STRING_INITIALIZER
17635 (struct cmd_ptype_mapping_reset_result,
17637 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17638 TOKEN_NUM_INITIALIZER
17639 (struct cmd_ptype_mapping_reset_result,
17643 cmd_ptype_mapping_reset_parsed(
17644 void *parsed_result,
17645 __attribute__((unused)) struct cmdline *cl,
17646 __attribute__((unused)) void *data)
17648 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17649 int ret = -ENOTSUP;
17651 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17654 #ifdef RTE_LIBRTE_I40E_PMD
17655 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17662 printf("invalid port_id %d\n", res->port_id);
17665 printf("function not implemented\n");
17668 printf("programming error: (%s)\n", strerror(-ret));
17672 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17673 .f = cmd_ptype_mapping_reset_parsed,
17675 .help_str = "ptype mapping reset <port_id>",
17677 (void *)&cmd_ptype_mapping_reset_ptype,
17678 (void *)&cmd_ptype_mapping_reset_mapping,
17679 (void *)&cmd_ptype_mapping_reset_reset,
17680 (void *)&cmd_ptype_mapping_reset_port_id,
17685 /* ptype mapping update */
17687 /* Common result structure for ptype mapping update */
17688 struct cmd_ptype_mapping_update_result {
17689 cmdline_fixed_string_t ptype;
17690 cmdline_fixed_string_t mapping;
17691 cmdline_fixed_string_t reset;
17697 /* Common CLI fields for ptype mapping update*/
17698 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17699 TOKEN_STRING_INITIALIZER
17700 (struct cmd_ptype_mapping_update_result,
17702 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17703 TOKEN_STRING_INITIALIZER
17704 (struct cmd_ptype_mapping_update_result,
17705 mapping, "mapping");
17706 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17707 TOKEN_STRING_INITIALIZER
17708 (struct cmd_ptype_mapping_update_result,
17710 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17711 TOKEN_NUM_INITIALIZER
17712 (struct cmd_ptype_mapping_update_result,
17714 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17715 TOKEN_NUM_INITIALIZER
17716 (struct cmd_ptype_mapping_update_result,
17718 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17719 TOKEN_NUM_INITIALIZER
17720 (struct cmd_ptype_mapping_update_result,
17724 cmd_ptype_mapping_update_parsed(
17725 void *parsed_result,
17726 __attribute__((unused)) struct cmdline *cl,
17727 __attribute__((unused)) void *data)
17729 struct cmd_ptype_mapping_update_result *res = parsed_result;
17730 int ret = -ENOTSUP;
17731 #ifdef RTE_LIBRTE_I40E_PMD
17732 struct rte_pmd_i40e_ptype_mapping mapping;
17734 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17737 #ifdef RTE_LIBRTE_I40E_PMD
17738 mapping.hw_ptype = res->hw_ptype;
17739 mapping.sw_ptype = res->sw_ptype;
17740 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17750 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17753 printf("invalid port_id %d\n", res->port_id);
17756 printf("function not implemented\n");
17759 printf("programming error: (%s)\n", strerror(-ret));
17763 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17764 .f = cmd_ptype_mapping_update_parsed,
17766 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17768 (void *)&cmd_ptype_mapping_update_ptype,
17769 (void *)&cmd_ptype_mapping_update_mapping,
17770 (void *)&cmd_ptype_mapping_update_update,
17771 (void *)&cmd_ptype_mapping_update_port_id,
17772 (void *)&cmd_ptype_mapping_update_hw_ptype,
17773 (void *)&cmd_ptype_mapping_update_sw_ptype,
17778 /* Common result structure for file commands */
17779 struct cmd_cmdfile_result {
17780 cmdline_fixed_string_t load;
17781 cmdline_fixed_string_t filename;
17784 /* Common CLI fields for file commands */
17785 cmdline_parse_token_string_t cmd_load_cmdfile =
17786 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17787 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17788 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17791 cmd_load_from_file_parsed(
17792 void *parsed_result,
17793 __attribute__((unused)) struct cmdline *cl,
17794 __attribute__((unused)) void *data)
17796 struct cmd_cmdfile_result *res = parsed_result;
17798 cmdline_read_from_file(res->filename);
17801 cmdline_parse_inst_t cmd_load_from_file = {
17802 .f = cmd_load_from_file_parsed,
17804 .help_str = "load <filename>",
17806 (void *)&cmd_load_cmdfile,
17807 (void *)&cmd_load_cmdfile_filename,
17812 /* Get Rx offloads capabilities */
17813 struct cmd_rx_offload_get_capa_result {
17814 cmdline_fixed_string_t show;
17815 cmdline_fixed_string_t port;
17817 cmdline_fixed_string_t rx_offload;
17818 cmdline_fixed_string_t capabilities;
17821 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17822 TOKEN_STRING_INITIALIZER
17823 (struct cmd_rx_offload_get_capa_result,
17825 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17826 TOKEN_STRING_INITIALIZER
17827 (struct cmd_rx_offload_get_capa_result,
17829 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17830 TOKEN_NUM_INITIALIZER
17831 (struct cmd_rx_offload_get_capa_result,
17833 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17834 TOKEN_STRING_INITIALIZER
17835 (struct cmd_rx_offload_get_capa_result,
17836 rx_offload, "rx_offload");
17837 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17838 TOKEN_STRING_INITIALIZER
17839 (struct cmd_rx_offload_get_capa_result,
17840 capabilities, "capabilities");
17843 print_rx_offloads(uint64_t offloads)
17845 uint64_t single_offload;
17853 begin = __builtin_ctzll(offloads);
17854 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17856 single_offload = 1ULL << begin;
17857 for (bit = begin; bit < end; bit++) {
17858 if (offloads & single_offload)
17860 rte_eth_dev_rx_offload_name(single_offload));
17861 single_offload <<= 1;
17866 cmd_rx_offload_get_capa_parsed(
17867 void *parsed_result,
17868 __attribute__((unused)) struct cmdline *cl,
17869 __attribute__((unused)) void *data)
17871 struct cmd_rx_offload_get_capa_result *res = parsed_result;
17872 struct rte_eth_dev_info dev_info;
17873 portid_t port_id = res->port_id;
17874 uint64_t queue_offloads;
17875 uint64_t port_offloads;
17877 rte_eth_dev_info_get(port_id, &dev_info);
17878 queue_offloads = dev_info.rx_queue_offload_capa;
17879 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
17881 printf("Rx Offloading Capabilities of port %d :\n", port_id);
17882 printf(" Per Queue :");
17883 print_rx_offloads(queue_offloads);
17886 printf(" Per Port :");
17887 print_rx_offloads(port_offloads);
17891 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
17892 .f = cmd_rx_offload_get_capa_parsed,
17894 .help_str = "show port <port_id> rx_offload capabilities",
17896 (void *)&cmd_rx_offload_get_capa_show,
17897 (void *)&cmd_rx_offload_get_capa_port,
17898 (void *)&cmd_rx_offload_get_capa_port_id,
17899 (void *)&cmd_rx_offload_get_capa_rx_offload,
17900 (void *)&cmd_rx_offload_get_capa_capabilities,
17905 /* Get Rx offloads configuration */
17906 struct cmd_rx_offload_get_configuration_result {
17907 cmdline_fixed_string_t show;
17908 cmdline_fixed_string_t port;
17910 cmdline_fixed_string_t rx_offload;
17911 cmdline_fixed_string_t configuration;
17914 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
17915 TOKEN_STRING_INITIALIZER
17916 (struct cmd_rx_offload_get_configuration_result,
17918 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
17919 TOKEN_STRING_INITIALIZER
17920 (struct cmd_rx_offload_get_configuration_result,
17922 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
17923 TOKEN_NUM_INITIALIZER
17924 (struct cmd_rx_offload_get_configuration_result,
17926 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
17927 TOKEN_STRING_INITIALIZER
17928 (struct cmd_rx_offload_get_configuration_result,
17929 rx_offload, "rx_offload");
17930 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
17931 TOKEN_STRING_INITIALIZER
17932 (struct cmd_rx_offload_get_configuration_result,
17933 configuration, "configuration");
17936 cmd_rx_offload_get_configuration_parsed(
17937 void *parsed_result,
17938 __attribute__((unused)) struct cmdline *cl,
17939 __attribute__((unused)) void *data)
17941 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
17942 struct rte_eth_dev_info dev_info;
17943 portid_t port_id = res->port_id;
17944 struct rte_port *port = &ports[port_id];
17945 uint64_t port_offloads;
17946 uint64_t queue_offloads;
17947 uint16_t nb_rx_queues;
17950 printf("Rx Offloading Configuration of port %d :\n", port_id);
17952 port_offloads = port->dev_conf.rxmode.offloads;
17954 print_rx_offloads(port_offloads);
17957 rte_eth_dev_info_get(port_id, &dev_info);
17958 nb_rx_queues = dev_info.nb_rx_queues;
17959 for (q = 0; q < nb_rx_queues; q++) {
17960 queue_offloads = port->rx_conf[q].offloads;
17961 printf(" Queue[%2d] :", q);
17962 print_rx_offloads(queue_offloads);
17968 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
17969 .f = cmd_rx_offload_get_configuration_parsed,
17971 .help_str = "show port <port_id> rx_offload configuration",
17973 (void *)&cmd_rx_offload_get_configuration_show,
17974 (void *)&cmd_rx_offload_get_configuration_port,
17975 (void *)&cmd_rx_offload_get_configuration_port_id,
17976 (void *)&cmd_rx_offload_get_configuration_rx_offload,
17977 (void *)&cmd_rx_offload_get_configuration_configuration,
17982 /* Enable/Disable a per port offloading */
17983 struct cmd_config_per_port_rx_offload_result {
17984 cmdline_fixed_string_t port;
17985 cmdline_fixed_string_t config;
17987 cmdline_fixed_string_t rx_offload;
17988 cmdline_fixed_string_t offload;
17989 cmdline_fixed_string_t on_off;
17992 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
17993 TOKEN_STRING_INITIALIZER
17994 (struct cmd_config_per_port_rx_offload_result,
17996 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
17997 TOKEN_STRING_INITIALIZER
17998 (struct cmd_config_per_port_rx_offload_result,
18000 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18001 TOKEN_NUM_INITIALIZER
18002 (struct cmd_config_per_port_rx_offload_result,
18004 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18005 TOKEN_STRING_INITIALIZER
18006 (struct cmd_config_per_port_rx_offload_result,
18007 rx_offload, "rx_offload");
18008 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18009 TOKEN_STRING_INITIALIZER
18010 (struct cmd_config_per_port_rx_offload_result,
18011 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18012 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18013 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18014 "crc_strip#scatter#timestamp#security#keep_crc");
18015 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18016 TOKEN_STRING_INITIALIZER
18017 (struct cmd_config_per_port_rx_offload_result,
18021 search_rx_offload(const char *name)
18023 uint64_t single_offload;
18024 const char *single_name;
18028 single_offload = 1;
18029 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18030 single_name = rte_eth_dev_rx_offload_name(single_offload);
18031 if (!strcasecmp(single_name, name)) {
18035 single_offload <<= 1;
18039 return single_offload;
18045 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18046 __attribute__((unused)) struct cmdline *cl,
18047 __attribute__((unused)) void *data)
18049 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18050 portid_t port_id = res->port_id;
18051 struct rte_eth_dev_info dev_info;
18052 struct rte_port *port = &ports[port_id];
18053 uint64_t single_offload;
18054 uint16_t nb_rx_queues;
18057 if (port->port_status != RTE_PORT_STOPPED) {
18058 printf("Error: Can't config offload when Port %d "
18059 "is not stopped\n", port_id);
18063 single_offload = search_rx_offload(res->offload);
18064 if (single_offload == 0) {
18065 printf("Unknown offload name: %s\n", res->offload);
18069 rte_eth_dev_info_get(port_id, &dev_info);
18070 nb_rx_queues = dev_info.nb_rx_queues;
18071 if (!strcmp(res->on_off, "on")) {
18072 port->dev_conf.rxmode.offloads |= single_offload;
18073 for (q = 0; q < nb_rx_queues; q++)
18074 port->rx_conf[q].offloads |= single_offload;
18076 port->dev_conf.rxmode.offloads &= ~single_offload;
18077 for (q = 0; q < nb_rx_queues; q++)
18078 port->rx_conf[q].offloads &= ~single_offload;
18081 cmd_reconfig_device_queue(port_id, 1, 1);
18084 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18085 .f = cmd_config_per_port_rx_offload_parsed,
18087 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18088 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18089 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18090 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
18093 (void *)&cmd_config_per_port_rx_offload_result_port,
18094 (void *)&cmd_config_per_port_rx_offload_result_config,
18095 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18096 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18097 (void *)&cmd_config_per_port_rx_offload_result_offload,
18098 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18103 /* Enable/Disable a per queue offloading */
18104 struct cmd_config_per_queue_rx_offload_result {
18105 cmdline_fixed_string_t port;
18107 cmdline_fixed_string_t rxq;
18109 cmdline_fixed_string_t rx_offload;
18110 cmdline_fixed_string_t offload;
18111 cmdline_fixed_string_t on_off;
18114 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18115 TOKEN_STRING_INITIALIZER
18116 (struct cmd_config_per_queue_rx_offload_result,
18118 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18119 TOKEN_NUM_INITIALIZER
18120 (struct cmd_config_per_queue_rx_offload_result,
18122 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18123 TOKEN_STRING_INITIALIZER
18124 (struct cmd_config_per_queue_rx_offload_result,
18126 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18127 TOKEN_NUM_INITIALIZER
18128 (struct cmd_config_per_queue_rx_offload_result,
18130 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18131 TOKEN_STRING_INITIALIZER
18132 (struct cmd_config_per_queue_rx_offload_result,
18133 rx_offload, "rx_offload");
18134 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18135 TOKEN_STRING_INITIALIZER
18136 (struct cmd_config_per_queue_rx_offload_result,
18137 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18138 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18139 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18140 "crc_strip#scatter#timestamp#security#keep_crc");
18141 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18142 TOKEN_STRING_INITIALIZER
18143 (struct cmd_config_per_queue_rx_offload_result,
18147 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18148 __attribute__((unused)) struct cmdline *cl,
18149 __attribute__((unused)) void *data)
18151 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18152 struct rte_eth_dev_info dev_info;
18153 portid_t port_id = res->port_id;
18154 uint16_t queue_id = res->queue_id;
18155 struct rte_port *port = &ports[port_id];
18156 uint64_t single_offload;
18158 if (port->port_status != RTE_PORT_STOPPED) {
18159 printf("Error: Can't config offload when Port %d "
18160 "is not stopped\n", port_id);
18164 rte_eth_dev_info_get(port_id, &dev_info);
18165 if (queue_id >= dev_info.nb_rx_queues) {
18166 printf("Error: input queue_id should be 0 ... "
18167 "%d\n", dev_info.nb_rx_queues - 1);
18171 single_offload = search_rx_offload(res->offload);
18172 if (single_offload == 0) {
18173 printf("Unknown offload name: %s\n", res->offload);
18177 if (!strcmp(res->on_off, "on"))
18178 port->rx_conf[queue_id].offloads |= single_offload;
18180 port->rx_conf[queue_id].offloads &= ~single_offload;
18182 cmd_reconfig_device_queue(port_id, 1, 1);
18185 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18186 .f = cmd_config_per_queue_rx_offload_parsed,
18188 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18189 "vlan_strip|ipv4_cksum|"
18190 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18191 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18192 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
18195 (void *)&cmd_config_per_queue_rx_offload_result_port,
18196 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18197 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18198 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18199 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18200 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18201 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18206 /* Get Tx offloads capabilities */
18207 struct cmd_tx_offload_get_capa_result {
18208 cmdline_fixed_string_t show;
18209 cmdline_fixed_string_t port;
18211 cmdline_fixed_string_t tx_offload;
18212 cmdline_fixed_string_t capabilities;
18215 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18216 TOKEN_STRING_INITIALIZER
18217 (struct cmd_tx_offload_get_capa_result,
18219 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18220 TOKEN_STRING_INITIALIZER
18221 (struct cmd_tx_offload_get_capa_result,
18223 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18224 TOKEN_NUM_INITIALIZER
18225 (struct cmd_tx_offload_get_capa_result,
18227 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18228 TOKEN_STRING_INITIALIZER
18229 (struct cmd_tx_offload_get_capa_result,
18230 tx_offload, "tx_offload");
18231 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18232 TOKEN_STRING_INITIALIZER
18233 (struct cmd_tx_offload_get_capa_result,
18234 capabilities, "capabilities");
18237 print_tx_offloads(uint64_t offloads)
18239 uint64_t single_offload;
18247 begin = __builtin_ctzll(offloads);
18248 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18250 single_offload = 1ULL << begin;
18251 for (bit = begin; bit < end; bit++) {
18252 if (offloads & single_offload)
18254 rte_eth_dev_tx_offload_name(single_offload));
18255 single_offload <<= 1;
18260 cmd_tx_offload_get_capa_parsed(
18261 void *parsed_result,
18262 __attribute__((unused)) struct cmdline *cl,
18263 __attribute__((unused)) void *data)
18265 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18266 struct rte_eth_dev_info dev_info;
18267 portid_t port_id = res->port_id;
18268 uint64_t queue_offloads;
18269 uint64_t port_offloads;
18271 rte_eth_dev_info_get(port_id, &dev_info);
18272 queue_offloads = dev_info.tx_queue_offload_capa;
18273 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18275 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18276 printf(" Per Queue :");
18277 print_tx_offloads(queue_offloads);
18280 printf(" Per Port :");
18281 print_tx_offloads(port_offloads);
18285 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18286 .f = cmd_tx_offload_get_capa_parsed,
18288 .help_str = "show port <port_id> tx_offload capabilities",
18290 (void *)&cmd_tx_offload_get_capa_show,
18291 (void *)&cmd_tx_offload_get_capa_port,
18292 (void *)&cmd_tx_offload_get_capa_port_id,
18293 (void *)&cmd_tx_offload_get_capa_tx_offload,
18294 (void *)&cmd_tx_offload_get_capa_capabilities,
18299 /* Get Tx offloads configuration */
18300 struct cmd_tx_offload_get_configuration_result {
18301 cmdline_fixed_string_t show;
18302 cmdline_fixed_string_t port;
18304 cmdline_fixed_string_t tx_offload;
18305 cmdline_fixed_string_t configuration;
18308 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18309 TOKEN_STRING_INITIALIZER
18310 (struct cmd_tx_offload_get_configuration_result,
18312 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18313 TOKEN_STRING_INITIALIZER
18314 (struct cmd_tx_offload_get_configuration_result,
18316 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18317 TOKEN_NUM_INITIALIZER
18318 (struct cmd_tx_offload_get_configuration_result,
18320 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18321 TOKEN_STRING_INITIALIZER
18322 (struct cmd_tx_offload_get_configuration_result,
18323 tx_offload, "tx_offload");
18324 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18325 TOKEN_STRING_INITIALIZER
18326 (struct cmd_tx_offload_get_configuration_result,
18327 configuration, "configuration");
18330 cmd_tx_offload_get_configuration_parsed(
18331 void *parsed_result,
18332 __attribute__((unused)) struct cmdline *cl,
18333 __attribute__((unused)) void *data)
18335 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18336 struct rte_eth_dev_info dev_info;
18337 portid_t port_id = res->port_id;
18338 struct rte_port *port = &ports[port_id];
18339 uint64_t port_offloads;
18340 uint64_t queue_offloads;
18341 uint16_t nb_tx_queues;
18344 printf("Tx Offloading Configuration of port %d :\n", port_id);
18346 port_offloads = port->dev_conf.txmode.offloads;
18348 print_tx_offloads(port_offloads);
18351 rte_eth_dev_info_get(port_id, &dev_info);
18352 nb_tx_queues = dev_info.nb_tx_queues;
18353 for (q = 0; q < nb_tx_queues; q++) {
18354 queue_offloads = port->tx_conf[q].offloads;
18355 printf(" Queue[%2d] :", q);
18356 print_tx_offloads(queue_offloads);
18362 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18363 .f = cmd_tx_offload_get_configuration_parsed,
18365 .help_str = "show port <port_id> tx_offload configuration",
18367 (void *)&cmd_tx_offload_get_configuration_show,
18368 (void *)&cmd_tx_offload_get_configuration_port,
18369 (void *)&cmd_tx_offload_get_configuration_port_id,
18370 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18371 (void *)&cmd_tx_offload_get_configuration_configuration,
18376 /* Enable/Disable a per port offloading */
18377 struct cmd_config_per_port_tx_offload_result {
18378 cmdline_fixed_string_t port;
18379 cmdline_fixed_string_t config;
18381 cmdline_fixed_string_t tx_offload;
18382 cmdline_fixed_string_t offload;
18383 cmdline_fixed_string_t on_off;
18386 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18387 TOKEN_STRING_INITIALIZER
18388 (struct cmd_config_per_port_tx_offload_result,
18390 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18391 TOKEN_STRING_INITIALIZER
18392 (struct cmd_config_per_port_tx_offload_result,
18394 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18395 TOKEN_NUM_INITIALIZER
18396 (struct cmd_config_per_port_tx_offload_result,
18398 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18399 TOKEN_STRING_INITIALIZER
18400 (struct cmd_config_per_port_tx_offload_result,
18401 tx_offload, "tx_offload");
18402 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18403 TOKEN_STRING_INITIALIZER
18404 (struct cmd_config_per_port_tx_offload_result,
18405 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18406 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18407 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18408 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18409 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18411 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18412 TOKEN_STRING_INITIALIZER
18413 (struct cmd_config_per_port_tx_offload_result,
18417 search_tx_offload(const char *name)
18419 uint64_t single_offload;
18420 const char *single_name;
18424 single_offload = 1;
18425 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18426 single_name = rte_eth_dev_tx_offload_name(single_offload);
18427 if (single_name == NULL)
18429 if (!strcasecmp(single_name, name)) {
18432 } else if (!strcasecmp(single_name, "UNKNOWN"))
18434 single_offload <<= 1;
18438 return single_offload;
18444 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18445 __attribute__((unused)) struct cmdline *cl,
18446 __attribute__((unused)) void *data)
18448 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18449 portid_t port_id = res->port_id;
18450 struct rte_eth_dev_info dev_info;
18451 struct rte_port *port = &ports[port_id];
18452 uint64_t single_offload;
18453 uint16_t nb_tx_queues;
18456 if (port->port_status != RTE_PORT_STOPPED) {
18457 printf("Error: Can't config offload when Port %d "
18458 "is not stopped\n", port_id);
18462 single_offload = search_tx_offload(res->offload);
18463 if (single_offload == 0) {
18464 printf("Unknown offload name: %s\n", res->offload);
18468 rte_eth_dev_info_get(port_id, &dev_info);
18469 nb_tx_queues = dev_info.nb_tx_queues;
18470 if (!strcmp(res->on_off, "on")) {
18471 port->dev_conf.txmode.offloads |= single_offload;
18472 for (q = 0; q < nb_tx_queues; q++)
18473 port->tx_conf[q].offloads |= single_offload;
18475 port->dev_conf.txmode.offloads &= ~single_offload;
18476 for (q = 0; q < nb_tx_queues; q++)
18477 port->tx_conf[q].offloads &= ~single_offload;
18480 cmd_reconfig_device_queue(port_id, 1, 1);
18483 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18484 .f = cmd_config_per_port_tx_offload_parsed,
18486 .help_str = "port config <port_id> tx_offload "
18487 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18488 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18489 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18490 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18491 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18492 "match_metadata on|off",
18494 (void *)&cmd_config_per_port_tx_offload_result_port,
18495 (void *)&cmd_config_per_port_tx_offload_result_config,
18496 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18497 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18498 (void *)&cmd_config_per_port_tx_offload_result_offload,
18499 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18504 /* Enable/Disable a per queue offloading */
18505 struct cmd_config_per_queue_tx_offload_result {
18506 cmdline_fixed_string_t port;
18508 cmdline_fixed_string_t txq;
18510 cmdline_fixed_string_t tx_offload;
18511 cmdline_fixed_string_t offload;
18512 cmdline_fixed_string_t on_off;
18515 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18516 TOKEN_STRING_INITIALIZER
18517 (struct cmd_config_per_queue_tx_offload_result,
18519 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18520 TOKEN_NUM_INITIALIZER
18521 (struct cmd_config_per_queue_tx_offload_result,
18523 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18524 TOKEN_STRING_INITIALIZER
18525 (struct cmd_config_per_queue_tx_offload_result,
18527 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18528 TOKEN_NUM_INITIALIZER
18529 (struct cmd_config_per_queue_tx_offload_result,
18531 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18532 TOKEN_STRING_INITIALIZER
18533 (struct cmd_config_per_queue_tx_offload_result,
18534 tx_offload, "tx_offload");
18535 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18536 TOKEN_STRING_INITIALIZER
18537 (struct cmd_config_per_queue_tx_offload_result,
18538 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18539 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18540 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18541 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18542 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18543 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18544 TOKEN_STRING_INITIALIZER
18545 (struct cmd_config_per_queue_tx_offload_result,
18549 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18550 __attribute__((unused)) struct cmdline *cl,
18551 __attribute__((unused)) void *data)
18553 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18554 struct rte_eth_dev_info dev_info;
18555 portid_t port_id = res->port_id;
18556 uint16_t queue_id = res->queue_id;
18557 struct rte_port *port = &ports[port_id];
18558 uint64_t single_offload;
18560 if (port->port_status != RTE_PORT_STOPPED) {
18561 printf("Error: Can't config offload when Port %d "
18562 "is not stopped\n", port_id);
18566 rte_eth_dev_info_get(port_id, &dev_info);
18567 if (queue_id >= dev_info.nb_tx_queues) {
18568 printf("Error: input queue_id should be 0 ... "
18569 "%d\n", dev_info.nb_tx_queues - 1);
18573 single_offload = search_tx_offload(res->offload);
18574 if (single_offload == 0) {
18575 printf("Unknown offload name: %s\n", res->offload);
18579 if (!strcmp(res->on_off, "on"))
18580 port->tx_conf[queue_id].offloads |= single_offload;
18582 port->tx_conf[queue_id].offloads &= ~single_offload;
18584 cmd_reconfig_device_queue(port_id, 1, 1);
18587 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18588 .f = cmd_config_per_queue_tx_offload_parsed,
18590 .help_str = "port <port_id> txq <queue_id> tx_offload "
18591 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18592 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18593 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18594 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18595 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18598 (void *)&cmd_config_per_queue_tx_offload_result_port,
18599 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18600 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18601 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18602 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18603 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18604 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18609 /* *** configure tx_metadata for specific port *** */
18610 struct cmd_config_tx_metadata_specific_result {
18611 cmdline_fixed_string_t port;
18612 cmdline_fixed_string_t keyword;
18614 cmdline_fixed_string_t item;
18619 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18620 __attribute__((unused)) struct cmdline *cl,
18621 __attribute__((unused)) void *data)
18623 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18625 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18627 ports[res->port_id].tx_metadata = rte_cpu_to_be_32(res->value);
18628 /* Add/remove callback to insert valid metadata in every Tx packet. */
18629 if (ports[res->port_id].tx_metadata)
18630 add_tx_md_callback(res->port_id);
18632 remove_tx_md_callback(res->port_id);
18635 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18636 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18638 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18639 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18640 keyword, "config");
18641 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18642 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18644 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18645 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18646 item, "tx_metadata");
18647 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18648 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18651 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18652 .f = cmd_config_tx_metadata_specific_parsed,
18654 .help_str = "port config <port_id> tx_metadata <value>",
18656 (void *)&cmd_config_tx_metadata_specific_port,
18657 (void *)&cmd_config_tx_metadata_specific_keyword,
18658 (void *)&cmd_config_tx_metadata_specific_id,
18659 (void *)&cmd_config_tx_metadata_specific_item,
18660 (void *)&cmd_config_tx_metadata_specific_value,
18665 /* *** display tx_metadata per port configuration *** */
18666 struct cmd_show_tx_metadata_result {
18667 cmdline_fixed_string_t cmd_show;
18668 cmdline_fixed_string_t cmd_port;
18669 cmdline_fixed_string_t cmd_keyword;
18674 cmd_show_tx_metadata_parsed(void *parsed_result,
18675 __attribute__((unused)) struct cmdline *cl,
18676 __attribute__((unused)) void *data)
18678 struct cmd_show_tx_metadata_result *res = parsed_result;
18680 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18681 printf("invalid port id %u\n", res->cmd_pid);
18684 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18685 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18686 rte_be_to_cpu_32(ports[res->cmd_pid].tx_metadata));
18690 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18691 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18693 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18694 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18696 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18697 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18699 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18700 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18701 cmd_keyword, "tx_metadata");
18703 cmdline_parse_inst_t cmd_show_tx_metadata = {
18704 .f = cmd_show_tx_metadata_parsed,
18706 .help_str = "show port <port_id> tx_metadata",
18708 (void *)&cmd_show_tx_metadata_show,
18709 (void *)&cmd_show_tx_metadata_port,
18710 (void *)&cmd_show_tx_metadata_pid,
18711 (void *)&cmd_show_tx_metadata_keyword,
18716 /* ******************************************************************************** */
18718 /* list of instructions */
18719 cmdline_parse_ctx_t main_ctx[] = {
18720 (cmdline_parse_inst_t *)&cmd_help_brief,
18721 (cmdline_parse_inst_t *)&cmd_help_long,
18722 (cmdline_parse_inst_t *)&cmd_quit,
18723 (cmdline_parse_inst_t *)&cmd_load_from_file,
18724 (cmdline_parse_inst_t *)&cmd_showport,
18725 (cmdline_parse_inst_t *)&cmd_showqueue,
18726 (cmdline_parse_inst_t *)&cmd_showportall,
18727 (cmdline_parse_inst_t *)&cmd_showcfg,
18728 (cmdline_parse_inst_t *)&cmd_showfwdall,
18729 (cmdline_parse_inst_t *)&cmd_start,
18730 (cmdline_parse_inst_t *)&cmd_start_tx_first,
18731 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
18732 (cmdline_parse_inst_t *)&cmd_set_link_up,
18733 (cmdline_parse_inst_t *)&cmd_set_link_down,
18734 (cmdline_parse_inst_t *)&cmd_reset,
18735 (cmdline_parse_inst_t *)&cmd_set_numbers,
18736 (cmdline_parse_inst_t *)&cmd_set_log,
18737 (cmdline_parse_inst_t *)&cmd_set_txpkts,
18738 (cmdline_parse_inst_t *)&cmd_set_txsplit,
18739 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
18740 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
18741 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
18742 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
18743 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
18744 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
18745 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
18746 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
18747 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
18748 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
18749 (cmdline_parse_inst_t *)&cmd_set_link_check,
18750 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
18751 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
18752 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
18753 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
18754 #ifdef RTE_LIBRTE_PMD_BOND
18755 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
18756 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
18757 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
18758 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
18759 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
18760 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
18761 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
18762 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
18763 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
18764 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
18765 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
18767 (cmdline_parse_inst_t *)&cmd_vlan_offload,
18768 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
18769 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
18770 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
18771 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
18772 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
18773 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
18774 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
18775 (cmdline_parse_inst_t *)&cmd_csum_set,
18776 (cmdline_parse_inst_t *)&cmd_csum_show,
18777 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
18778 (cmdline_parse_inst_t *)&cmd_tso_set,
18779 (cmdline_parse_inst_t *)&cmd_tso_show,
18780 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
18781 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
18782 (cmdline_parse_inst_t *)&cmd_gro_enable,
18783 (cmdline_parse_inst_t *)&cmd_gro_flush,
18784 (cmdline_parse_inst_t *)&cmd_gro_show,
18785 (cmdline_parse_inst_t *)&cmd_gso_enable,
18786 (cmdline_parse_inst_t *)&cmd_gso_size,
18787 (cmdline_parse_inst_t *)&cmd_gso_show,
18788 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
18789 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
18790 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
18791 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
18792 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
18793 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
18794 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
18795 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
18796 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
18797 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
18798 (cmdline_parse_inst_t *)&cmd_config_dcb,
18799 (cmdline_parse_inst_t *)&cmd_read_reg,
18800 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
18801 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
18802 (cmdline_parse_inst_t *)&cmd_write_reg,
18803 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
18804 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
18805 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
18806 (cmdline_parse_inst_t *)&cmd_stop,
18807 (cmdline_parse_inst_t *)&cmd_mac_addr,
18808 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
18809 (cmdline_parse_inst_t *)&cmd_set_qmap,
18810 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
18811 (cmdline_parse_inst_t *)&cmd_operate_port,
18812 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
18813 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
18814 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
18815 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
18816 (cmdline_parse_inst_t *)&cmd_config_speed_all,
18817 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
18818 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
18819 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
18820 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
18821 (cmdline_parse_inst_t *)&cmd_config_mtu,
18822 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
18823 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
18824 (cmdline_parse_inst_t *)&cmd_config_rss,
18825 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
18826 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
18827 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
18828 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
18829 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
18830 (cmdline_parse_inst_t *)&cmd_showport_reta,
18831 (cmdline_parse_inst_t *)&cmd_config_burst,
18832 (cmdline_parse_inst_t *)&cmd_config_thresh,
18833 (cmdline_parse_inst_t *)&cmd_config_threshold,
18834 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
18835 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
18836 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
18837 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
18838 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
18839 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
18840 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
18841 (cmdline_parse_inst_t *)&cmd_global_config,
18842 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
18843 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
18844 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
18845 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
18846 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
18847 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
18848 (cmdline_parse_inst_t *)&cmd_dump,
18849 (cmdline_parse_inst_t *)&cmd_dump_one,
18850 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
18851 (cmdline_parse_inst_t *)&cmd_syn_filter,
18852 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
18853 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
18854 (cmdline_parse_inst_t *)&cmd_flex_filter,
18855 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
18856 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
18857 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
18858 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
18859 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
18860 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
18861 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
18862 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
18863 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
18864 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
18865 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
18866 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
18867 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
18868 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
18869 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
18870 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
18871 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
18872 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
18873 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
18874 (cmdline_parse_inst_t *)&cmd_flow,
18875 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
18876 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
18877 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
18878 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
18879 (cmdline_parse_inst_t *)&cmd_create_port_meter,
18880 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
18881 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
18882 (cmdline_parse_inst_t *)&cmd_del_port_meter,
18883 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
18884 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
18885 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
18886 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
18887 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
18888 (cmdline_parse_inst_t *)&cmd_mcast_addr,
18889 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
18890 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
18891 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
18892 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
18893 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
18894 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
18895 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
18896 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
18897 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
18898 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
18899 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
18900 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
18901 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
18902 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
18903 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
18904 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
18905 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
18906 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
18907 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
18908 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
18909 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
18910 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
18911 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
18912 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
18913 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
18914 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
18915 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
18916 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
18917 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
18918 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
18919 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
18920 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
18921 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
18922 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
18923 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
18924 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
18925 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
18927 (cmdline_parse_inst_t *)&cmd_set_vxlan,
18928 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
18929 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
18930 (cmdline_parse_inst_t *)&cmd_set_nvgre,
18931 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
18932 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
18933 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
18934 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
18935 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
18936 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
18937 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
18938 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
18939 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
18940 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
18941 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
18942 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
18943 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
18944 (cmdline_parse_inst_t *)&cmd_ddp_add,
18945 (cmdline_parse_inst_t *)&cmd_ddp_del,
18946 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
18947 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
18948 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
18949 (cmdline_parse_inst_t *)&cmd_clear_input_set,
18950 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
18951 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
18952 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
18953 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
18954 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
18955 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
18957 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
18958 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
18959 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
18960 (cmdline_parse_inst_t *)&cmd_queue_region,
18961 (cmdline_parse_inst_t *)&cmd_region_flowtype,
18962 (cmdline_parse_inst_t *)&cmd_user_priority_region,
18963 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
18964 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
18965 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
18966 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
18967 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
18968 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
18969 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
18970 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
18971 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
18972 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
18973 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
18974 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
18975 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
18976 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
18977 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
18978 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
18979 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
18980 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
18981 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
18982 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
18983 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
18984 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
18985 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
18986 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
18987 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
18988 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
18989 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
18990 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
18991 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
18992 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
18993 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
18994 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
18995 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
18996 #ifdef RTE_LIBRTE_BPF
18997 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
18998 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19000 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19001 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19005 /* read cmdline commands from file */
19007 cmdline_read_from_file(const char *filename)
19009 struct cmdline *cl;
19011 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19013 printf("Failed to create file based cmdline context: %s\n",
19018 cmdline_interact(cl);
19023 printf("Read CLI commands from %s\n", filename);
19026 /* prompt function, called from main on MASTER lcore */
19030 /* initialize non-constant commands */
19031 cmd_set_fwd_mode_init();
19032 cmd_set_fwd_retry_mode_init();
19034 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19035 if (testpmd_cl == NULL)
19037 cmdline_interact(testpmd_cl);
19038 cmdline_stdin_exit(testpmd_cl);
19044 if (testpmd_cl != NULL)
19045 cmdline_quit(testpmd_cl);
19049 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19051 if (id == (portid_t)RTE_PORT_ALL) {
19054 RTE_ETH_FOREACH_DEV(pid) {
19055 /* check if need_reconfig has been set to 1 */
19056 if (ports[pid].need_reconfig == 0)
19057 ports[pid].need_reconfig = dev;
19058 /* check if need_reconfig_queues has been set to 1 */
19059 if (ports[pid].need_reconfig_queues == 0)
19060 ports[pid].need_reconfig_queues = queue;
19062 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19063 /* check if need_reconfig has been set to 1 */
19064 if (ports[id].need_reconfig == 0)
19065 ports[id].need_reconfig = dev;
19066 /* check if need_reconfig_queues has been set to 1 */
19067 if (ports[id].need_reconfig_queues == 0)
19068 ports[id].need_reconfig_queues = queue;