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"
1141 "set raw_encap {flow items}\n"
1142 " Configure the encapsulation with raw data.\n\n"
1144 "set raw_decap {flow items}\n"
1145 " Configure the decapsulation with raw data.\n\n"
1150 if (show_all || !strcmp(res->section, "traffic_management")) {
1154 "Traffic Management:\n"
1156 "show port tm cap (port_id)\n"
1157 " Display the port TM capability.\n\n"
1159 "show port tm level cap (port_id) (level_id)\n"
1160 " Display the port TM hierarchical level capability.\n\n"
1162 "show port tm node cap (port_id) (node_id)\n"
1163 " Display the port TM node capability.\n\n"
1165 "show port tm node type (port_id) (node_id)\n"
1166 " Display the port TM node type.\n\n"
1168 "show port tm node stats (port_id) (node_id) (clear)\n"
1169 " Display the port TM node stats.\n\n"
1171 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
1172 "set port tm hierarchy default (port_id)\n"
1173 " Set default traffic Management hierarchy on a port\n\n"
1176 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1177 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1178 " (packet_length_adjust)\n"
1179 " Add port tm node private shaper profile.\n\n"
1181 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1182 " Delete port tm node private shaper profile.\n\n"
1184 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1185 " (shaper_profile_id)\n"
1186 " Add/update port tm node shared shaper.\n\n"
1188 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1189 " Delete port tm node shared shaper.\n\n"
1191 "set port tm node shaper profile (port_id) (node_id)"
1192 " (shaper_profile_id)\n"
1193 " Set port tm node shaper profile.\n\n"
1195 "add port tm node wred profile (port_id) (wred_profile_id)"
1196 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1197 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1198 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1199 " Add port tm node wred profile.\n\n"
1201 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1202 " Delete port tm node wred profile.\n\n"
1204 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1205 " (priority) (weight) (level_id) (shaper_profile_id)"
1206 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1207 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1208 " Add port tm nonleaf node.\n\n"
1210 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1211 " (priority) (weight) (level_id) (shaper_profile_id)"
1212 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1213 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1214 " Add port tm leaf node.\n\n"
1216 "del port tm node (port_id) (node_id)\n"
1217 " Delete port tm node.\n\n"
1219 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1220 " (priority) (weight)\n"
1221 " Set port tm node parent.\n\n"
1223 "suspend port tm node (port_id) (node_id)"
1224 " Suspend tm node.\n\n"
1226 "resume port tm node (port_id) (node_id)"
1227 " Resume tm node.\n\n"
1229 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1230 " Commit tm hierarchy.\n\n"
1232 "set port tm mark ip_ecn (port) (green) (yellow)"
1234 " Enables/Disables the traffic management marking"
1235 " for IP ECN (Explicit Congestion Notification)"
1236 " packets on a given port\n\n"
1238 "set port tm mark ip_dscp (port) (green) (yellow)"
1240 " Enables/Disables the traffic management marking"
1241 " on the port for IP dscp packets\n\n"
1243 "set port tm mark vlan_dei (port) (green) (yellow)"
1245 " Enables/Disables the traffic management marking"
1246 " on the port for VLAN packets with DEI enabled\n\n"
1252 cmdline_parse_token_string_t cmd_help_long_help =
1253 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1255 cmdline_parse_token_string_t cmd_help_long_section =
1256 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1257 "all#control#display#config#"
1258 "ports#registers#filters#traffic_management");
1260 cmdline_parse_inst_t cmd_help_long = {
1261 .f = cmd_help_long_parsed,
1263 .help_str = "help all|control|display|config|ports|register|"
1264 "filters|traffic_management: "
1267 (void *)&cmd_help_long_help,
1268 (void *)&cmd_help_long_section,
1274 /* *** start/stop/close all ports *** */
1275 struct cmd_operate_port_result {
1276 cmdline_fixed_string_t keyword;
1277 cmdline_fixed_string_t name;
1278 cmdline_fixed_string_t value;
1281 static void cmd_operate_port_parsed(void *parsed_result,
1282 __attribute__((unused)) struct cmdline *cl,
1283 __attribute__((unused)) void *data)
1285 struct cmd_operate_port_result *res = parsed_result;
1287 if (!strcmp(res->name, "start"))
1288 start_port(RTE_PORT_ALL);
1289 else if (!strcmp(res->name, "stop"))
1290 stop_port(RTE_PORT_ALL);
1291 else if (!strcmp(res->name, "close"))
1292 close_port(RTE_PORT_ALL);
1293 else if (!strcmp(res->name, "reset"))
1294 reset_port(RTE_PORT_ALL);
1296 printf("Unknown parameter\n");
1299 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1300 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1302 cmdline_parse_token_string_t cmd_operate_port_all_port =
1303 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1304 "start#stop#close#reset");
1305 cmdline_parse_token_string_t cmd_operate_port_all_all =
1306 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1308 cmdline_parse_inst_t cmd_operate_port = {
1309 .f = cmd_operate_port_parsed,
1311 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1313 (void *)&cmd_operate_port_all_cmd,
1314 (void *)&cmd_operate_port_all_port,
1315 (void *)&cmd_operate_port_all_all,
1320 /* *** start/stop/close specific port *** */
1321 struct cmd_operate_specific_port_result {
1322 cmdline_fixed_string_t keyword;
1323 cmdline_fixed_string_t name;
1327 static void cmd_operate_specific_port_parsed(void *parsed_result,
1328 __attribute__((unused)) struct cmdline *cl,
1329 __attribute__((unused)) void *data)
1331 struct cmd_operate_specific_port_result *res = parsed_result;
1333 if (!strcmp(res->name, "start"))
1334 start_port(res->value);
1335 else if (!strcmp(res->name, "stop"))
1336 stop_port(res->value);
1337 else if (!strcmp(res->name, "close"))
1338 close_port(res->value);
1339 else if (!strcmp(res->name, "reset"))
1340 reset_port(res->value);
1342 printf("Unknown parameter\n");
1345 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1346 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1348 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1349 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1350 name, "start#stop#close#reset");
1351 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1352 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1355 cmdline_parse_inst_t cmd_operate_specific_port = {
1356 .f = cmd_operate_specific_port_parsed,
1358 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1360 (void *)&cmd_operate_specific_port_cmd,
1361 (void *)&cmd_operate_specific_port_port,
1362 (void *)&cmd_operate_specific_port_id,
1367 /* *** enable port setup (after attach) via iterator or event *** */
1368 struct cmd_set_port_setup_on_result {
1369 cmdline_fixed_string_t set;
1370 cmdline_fixed_string_t port;
1371 cmdline_fixed_string_t setup;
1372 cmdline_fixed_string_t on;
1373 cmdline_fixed_string_t mode;
1376 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1377 __attribute__((unused)) struct cmdline *cl,
1378 __attribute__((unused)) void *data)
1380 struct cmd_set_port_setup_on_result *res = parsed_result;
1382 if (strcmp(res->mode, "event") == 0)
1383 setup_on_probe_event = true;
1384 else if (strcmp(res->mode, "iterator") == 0)
1385 setup_on_probe_event = false;
1387 printf("Unknown mode\n");
1390 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1391 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1393 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1394 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1396 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1397 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1399 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1400 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1402 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1403 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1404 mode, "iterator#event");
1406 cmdline_parse_inst_t cmd_set_port_setup_on = {
1407 .f = cmd_set_port_setup_on_parsed,
1409 .help_str = "set port setup on iterator|event",
1411 (void *)&cmd_set_port_setup_on_set,
1412 (void *)&cmd_set_port_setup_on_port,
1413 (void *)&cmd_set_port_setup_on_setup,
1414 (void *)&cmd_set_port_setup_on_on,
1415 (void *)&cmd_set_port_setup_on_mode,
1420 /* *** attach a specified port *** */
1421 struct cmd_operate_attach_port_result {
1422 cmdline_fixed_string_t port;
1423 cmdline_fixed_string_t keyword;
1424 cmdline_fixed_string_t identifier;
1427 static void cmd_operate_attach_port_parsed(void *parsed_result,
1428 __attribute__((unused)) struct cmdline *cl,
1429 __attribute__((unused)) void *data)
1431 struct cmd_operate_attach_port_result *res = parsed_result;
1433 if (!strcmp(res->keyword, "attach"))
1434 attach_port(res->identifier);
1436 printf("Unknown parameter\n");
1439 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1440 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1442 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1443 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1445 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1446 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1449 cmdline_parse_inst_t cmd_operate_attach_port = {
1450 .f = cmd_operate_attach_port_parsed,
1452 .help_str = "port attach <identifier>: "
1453 "(identifier: pci address or virtual dev name)",
1455 (void *)&cmd_operate_attach_port_port,
1456 (void *)&cmd_operate_attach_port_keyword,
1457 (void *)&cmd_operate_attach_port_identifier,
1462 /* *** detach a specified port *** */
1463 struct cmd_operate_detach_port_result {
1464 cmdline_fixed_string_t port;
1465 cmdline_fixed_string_t keyword;
1469 static void cmd_operate_detach_port_parsed(void *parsed_result,
1470 __attribute__((unused)) struct cmdline *cl,
1471 __attribute__((unused)) void *data)
1473 struct cmd_operate_detach_port_result *res = parsed_result;
1475 if (!strcmp(res->keyword, "detach"))
1476 detach_port_device(res->port_id);
1478 printf("Unknown parameter\n");
1481 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1482 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1484 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1485 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1487 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1488 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1491 cmdline_parse_inst_t cmd_operate_detach_port = {
1492 .f = cmd_operate_detach_port_parsed,
1494 .help_str = "port detach <port_id>",
1496 (void *)&cmd_operate_detach_port_port,
1497 (void *)&cmd_operate_detach_port_keyword,
1498 (void *)&cmd_operate_detach_port_port_id,
1503 /* *** configure speed for all ports *** */
1504 struct cmd_config_speed_all {
1505 cmdline_fixed_string_t port;
1506 cmdline_fixed_string_t keyword;
1507 cmdline_fixed_string_t all;
1508 cmdline_fixed_string_t item1;
1509 cmdline_fixed_string_t item2;
1510 cmdline_fixed_string_t value1;
1511 cmdline_fixed_string_t value2;
1515 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1520 if (!strcmp(duplexstr, "half")) {
1521 duplex = ETH_LINK_HALF_DUPLEX;
1522 } else if (!strcmp(duplexstr, "full")) {
1523 duplex = ETH_LINK_FULL_DUPLEX;
1524 } else if (!strcmp(duplexstr, "auto")) {
1525 duplex = ETH_LINK_FULL_DUPLEX;
1527 printf("Unknown duplex parameter\n");
1531 if (!strcmp(speedstr, "10")) {
1532 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1533 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1534 } else if (!strcmp(speedstr, "100")) {
1535 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1536 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1538 if (duplex != ETH_LINK_FULL_DUPLEX) {
1539 printf("Invalid speed/duplex parameters\n");
1542 if (!strcmp(speedstr, "1000")) {
1543 *speed = ETH_LINK_SPEED_1G;
1544 } else if (!strcmp(speedstr, "10000")) {
1545 *speed = ETH_LINK_SPEED_10G;
1546 } else if (!strcmp(speedstr, "25000")) {
1547 *speed = ETH_LINK_SPEED_25G;
1548 } else if (!strcmp(speedstr, "40000")) {
1549 *speed = ETH_LINK_SPEED_40G;
1550 } else if (!strcmp(speedstr, "50000")) {
1551 *speed = ETH_LINK_SPEED_50G;
1552 } else if (!strcmp(speedstr, "100000")) {
1553 *speed = ETH_LINK_SPEED_100G;
1554 } else if (!strcmp(speedstr, "auto")) {
1555 *speed = ETH_LINK_SPEED_AUTONEG;
1557 printf("Unknown speed parameter\n");
1566 cmd_config_speed_all_parsed(void *parsed_result,
1567 __attribute__((unused)) struct cmdline *cl,
1568 __attribute__((unused)) void *data)
1570 struct cmd_config_speed_all *res = parsed_result;
1571 uint32_t link_speed;
1574 if (!all_ports_stopped()) {
1575 printf("Please stop all ports first\n");
1579 if (parse_and_check_speed_duplex(res->value1, res->value2,
1583 RTE_ETH_FOREACH_DEV(pid) {
1584 ports[pid].dev_conf.link_speeds = link_speed;
1587 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1590 cmdline_parse_token_string_t cmd_config_speed_all_port =
1591 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1592 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1593 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1595 cmdline_parse_token_string_t cmd_config_speed_all_all =
1596 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1597 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1598 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1599 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1600 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1601 "10#100#1000#10000#25000#40000#50000#100000#auto");
1602 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1603 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1604 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1605 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1608 cmdline_parse_inst_t cmd_config_speed_all = {
1609 .f = cmd_config_speed_all_parsed,
1611 .help_str = "port config all speed "
1612 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1615 (void *)&cmd_config_speed_all_port,
1616 (void *)&cmd_config_speed_all_keyword,
1617 (void *)&cmd_config_speed_all_all,
1618 (void *)&cmd_config_speed_all_item1,
1619 (void *)&cmd_config_speed_all_value1,
1620 (void *)&cmd_config_speed_all_item2,
1621 (void *)&cmd_config_speed_all_value2,
1626 /* *** configure speed for specific port *** */
1627 struct cmd_config_speed_specific {
1628 cmdline_fixed_string_t port;
1629 cmdline_fixed_string_t keyword;
1631 cmdline_fixed_string_t item1;
1632 cmdline_fixed_string_t item2;
1633 cmdline_fixed_string_t value1;
1634 cmdline_fixed_string_t value2;
1638 cmd_config_speed_specific_parsed(void *parsed_result,
1639 __attribute__((unused)) struct cmdline *cl,
1640 __attribute__((unused)) void *data)
1642 struct cmd_config_speed_specific *res = parsed_result;
1643 uint32_t link_speed;
1645 if (!all_ports_stopped()) {
1646 printf("Please stop all ports first\n");
1650 if (port_id_is_invalid(res->id, ENABLED_WARN))
1653 if (parse_and_check_speed_duplex(res->value1, res->value2,
1657 ports[res->id].dev_conf.link_speeds = link_speed;
1659 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1663 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1664 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1666 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1667 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1669 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1670 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1671 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1672 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1674 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1675 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1676 "10#100#1000#10000#25000#40000#50000#100000#auto");
1677 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1678 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1680 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1681 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1684 cmdline_parse_inst_t cmd_config_speed_specific = {
1685 .f = cmd_config_speed_specific_parsed,
1687 .help_str = "port config <port_id> speed "
1688 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1691 (void *)&cmd_config_speed_specific_port,
1692 (void *)&cmd_config_speed_specific_keyword,
1693 (void *)&cmd_config_speed_specific_id,
1694 (void *)&cmd_config_speed_specific_item1,
1695 (void *)&cmd_config_speed_specific_value1,
1696 (void *)&cmd_config_speed_specific_item2,
1697 (void *)&cmd_config_speed_specific_value2,
1702 /* *** configure loopback for all ports *** */
1703 struct cmd_config_loopback_all {
1704 cmdline_fixed_string_t port;
1705 cmdline_fixed_string_t keyword;
1706 cmdline_fixed_string_t all;
1707 cmdline_fixed_string_t item;
1712 cmd_config_loopback_all_parsed(void *parsed_result,
1713 __attribute__((unused)) struct cmdline *cl,
1714 __attribute__((unused)) void *data)
1716 struct cmd_config_loopback_all *res = parsed_result;
1719 if (!all_ports_stopped()) {
1720 printf("Please stop all ports first\n");
1724 RTE_ETH_FOREACH_DEV(pid) {
1725 ports[pid].dev_conf.lpbk_mode = res->mode;
1728 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1731 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1732 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1733 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1734 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1736 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1737 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1738 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1739 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1741 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1742 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1744 cmdline_parse_inst_t cmd_config_loopback_all = {
1745 .f = cmd_config_loopback_all_parsed,
1747 .help_str = "port config all loopback <mode>",
1749 (void *)&cmd_config_loopback_all_port,
1750 (void *)&cmd_config_loopback_all_keyword,
1751 (void *)&cmd_config_loopback_all_all,
1752 (void *)&cmd_config_loopback_all_item,
1753 (void *)&cmd_config_loopback_all_mode,
1758 /* *** configure loopback for specific port *** */
1759 struct cmd_config_loopback_specific {
1760 cmdline_fixed_string_t port;
1761 cmdline_fixed_string_t keyword;
1763 cmdline_fixed_string_t item;
1768 cmd_config_loopback_specific_parsed(void *parsed_result,
1769 __attribute__((unused)) struct cmdline *cl,
1770 __attribute__((unused)) void *data)
1772 struct cmd_config_loopback_specific *res = parsed_result;
1774 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1777 if (!port_is_stopped(res->port_id)) {
1778 printf("Please stop port %u first\n", res->port_id);
1782 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1784 cmd_reconfig_device_queue(res->port_id, 1, 1);
1788 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1789 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1791 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1792 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1794 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1795 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1797 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1798 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1800 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1801 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1804 cmdline_parse_inst_t cmd_config_loopback_specific = {
1805 .f = cmd_config_loopback_specific_parsed,
1807 .help_str = "port config <port_id> loopback <mode>",
1809 (void *)&cmd_config_loopback_specific_port,
1810 (void *)&cmd_config_loopback_specific_keyword,
1811 (void *)&cmd_config_loopback_specific_id,
1812 (void *)&cmd_config_loopback_specific_item,
1813 (void *)&cmd_config_loopback_specific_mode,
1818 /* *** configure txq/rxq, txd/rxd *** */
1819 struct cmd_config_rx_tx {
1820 cmdline_fixed_string_t port;
1821 cmdline_fixed_string_t keyword;
1822 cmdline_fixed_string_t all;
1823 cmdline_fixed_string_t name;
1828 cmd_config_rx_tx_parsed(void *parsed_result,
1829 __attribute__((unused)) struct cmdline *cl,
1830 __attribute__((unused)) void *data)
1832 struct cmd_config_rx_tx *res = parsed_result;
1834 if (!all_ports_stopped()) {
1835 printf("Please stop all ports first\n");
1838 if (!strcmp(res->name, "rxq")) {
1839 if (!res->value && !nb_txq) {
1840 printf("Warning: Either rx or tx queues should be non zero\n");
1843 if (check_nb_rxq(res->value) != 0)
1845 nb_rxq = res->value;
1847 else if (!strcmp(res->name, "txq")) {
1848 if (!res->value && !nb_rxq) {
1849 printf("Warning: Either rx or tx queues should be non zero\n");
1852 if (check_nb_txq(res->value) != 0)
1854 nb_txq = res->value;
1856 else if (!strcmp(res->name, "rxd")) {
1857 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1858 printf("rxd %d invalid - must be > 0 && <= %d\n",
1859 res->value, RTE_TEST_RX_DESC_MAX);
1862 nb_rxd = res->value;
1863 } else if (!strcmp(res->name, "txd")) {
1864 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1865 printf("txd %d invalid - must be > 0 && <= %d\n",
1866 res->value, RTE_TEST_TX_DESC_MAX);
1869 nb_txd = res->value;
1871 printf("Unknown parameter\n");
1879 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1882 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1883 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1884 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1885 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1886 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1887 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1888 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1889 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1891 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1892 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1894 cmdline_parse_inst_t cmd_config_rx_tx = {
1895 .f = cmd_config_rx_tx_parsed,
1897 .help_str = "port config all rxq|txq|rxd|txd <value>",
1899 (void *)&cmd_config_rx_tx_port,
1900 (void *)&cmd_config_rx_tx_keyword,
1901 (void *)&cmd_config_rx_tx_all,
1902 (void *)&cmd_config_rx_tx_name,
1903 (void *)&cmd_config_rx_tx_value,
1908 /* *** config max packet length *** */
1909 struct cmd_config_max_pkt_len_result {
1910 cmdline_fixed_string_t port;
1911 cmdline_fixed_string_t keyword;
1912 cmdline_fixed_string_t all;
1913 cmdline_fixed_string_t name;
1918 cmd_config_max_pkt_len_parsed(void *parsed_result,
1919 __attribute__((unused)) struct cmdline *cl,
1920 __attribute__((unused)) void *data)
1922 struct cmd_config_max_pkt_len_result *res = parsed_result;
1925 if (!all_ports_stopped()) {
1926 printf("Please stop all ports first\n");
1930 RTE_ETH_FOREACH_DEV(pid) {
1931 struct rte_port *port = &ports[pid];
1932 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1934 if (!strcmp(res->name, "max-pkt-len")) {
1935 if (res->value < RTE_ETHER_MIN_LEN) {
1936 printf("max-pkt-len can not be less than %d\n",
1940 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1943 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1944 if (res->value > RTE_ETHER_MAX_LEN)
1945 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1947 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1948 port->dev_conf.rxmode.offloads = rx_offloads;
1950 printf("Unknown parameter\n");
1957 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1960 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1961 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1963 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1964 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1966 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1967 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1969 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1970 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1972 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1973 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1976 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1977 .f = cmd_config_max_pkt_len_parsed,
1979 .help_str = "port config all max-pkt-len <value>",
1981 (void *)&cmd_config_max_pkt_len_port,
1982 (void *)&cmd_config_max_pkt_len_keyword,
1983 (void *)&cmd_config_max_pkt_len_all,
1984 (void *)&cmd_config_max_pkt_len_name,
1985 (void *)&cmd_config_max_pkt_len_value,
1990 /* *** configure port MTU *** */
1991 struct cmd_config_mtu_result {
1992 cmdline_fixed_string_t port;
1993 cmdline_fixed_string_t keyword;
1994 cmdline_fixed_string_t mtu;
2000 cmd_config_mtu_parsed(void *parsed_result,
2001 __attribute__((unused)) struct cmdline *cl,
2002 __attribute__((unused)) void *data)
2004 struct cmd_config_mtu_result *res = parsed_result;
2006 if (res->value < RTE_ETHER_MIN_LEN) {
2007 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2010 port_mtu_set(res->port_id, res->value);
2013 cmdline_parse_token_string_t cmd_config_mtu_port =
2014 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2016 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2017 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2019 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2020 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2022 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2023 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2024 cmdline_parse_token_num_t cmd_config_mtu_value =
2025 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2027 cmdline_parse_inst_t cmd_config_mtu = {
2028 .f = cmd_config_mtu_parsed,
2030 .help_str = "port config mtu <port_id> <value>",
2032 (void *)&cmd_config_mtu_port,
2033 (void *)&cmd_config_mtu_keyword,
2034 (void *)&cmd_config_mtu_mtu,
2035 (void *)&cmd_config_mtu_port_id,
2036 (void *)&cmd_config_mtu_value,
2041 /* *** configure rx mode *** */
2042 struct cmd_config_rx_mode_flag {
2043 cmdline_fixed_string_t port;
2044 cmdline_fixed_string_t keyword;
2045 cmdline_fixed_string_t all;
2046 cmdline_fixed_string_t name;
2047 cmdline_fixed_string_t value;
2051 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2052 __attribute__((unused)) struct cmdline *cl,
2053 __attribute__((unused)) void *data)
2055 struct cmd_config_rx_mode_flag *res = parsed_result;
2059 if (!all_ports_stopped()) {
2060 printf("Please stop all ports first\n");
2064 RTE_ETH_FOREACH_DEV(pid) {
2065 struct rte_port *port;
2066 uint64_t rx_offloads;
2069 rx_offloads = port->dev_conf.rxmode.offloads;
2070 if (!strcmp(res->name, "crc-strip")) {
2071 if (!strcmp(res->value, "on")) {
2072 rx_offloads &= ~DEV_RX_OFFLOAD_KEEP_CRC;
2073 } else if (!strcmp(res->value, "off")) {
2074 rx_offloads |= DEV_RX_OFFLOAD_KEEP_CRC;
2076 printf("Unknown parameter\n");
2079 } else if (!strcmp(res->name, "scatter")) {
2080 if (!strcmp(res->value, "on")) {
2081 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
2082 } else if (!strcmp(res->value, "off")) {
2083 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
2085 printf("Unknown parameter\n");
2088 } else if (!strcmp(res->name, "rx-cksum")) {
2089 if (!strcmp(res->value, "on"))
2090 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
2091 else if (!strcmp(res->value, "off"))
2092 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
2094 printf("Unknown parameter\n");
2097 } else if (!strcmp(res->name, "rx-timestamp")) {
2098 if (!strcmp(res->value, "on"))
2099 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
2100 else if (!strcmp(res->value, "off"))
2101 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
2103 printf("Unknown parameter\n");
2106 } else if (!strcmp(res->name, "hw-vlan")) {
2107 if (!strcmp(res->value, "on")) {
2108 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
2109 DEV_RX_OFFLOAD_VLAN_STRIP);
2110 } else if (!strcmp(res->value, "off")) {
2111 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
2112 DEV_RX_OFFLOAD_VLAN_STRIP);
2114 printf("Unknown parameter\n");
2117 } else if (!strcmp(res->name, "hw-vlan-filter")) {
2118 if (!strcmp(res->value, "on"))
2119 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
2120 else if (!strcmp(res->value, "off"))
2121 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
2123 printf("Unknown parameter\n");
2126 } else if (!strcmp(res->name, "hw-vlan-strip")) {
2127 if (!strcmp(res->value, "on"))
2128 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
2129 else if (!strcmp(res->value, "off"))
2130 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
2132 printf("Unknown parameter\n");
2135 } else if (!strcmp(res->name, "hw-vlan-extend")) {
2136 if (!strcmp(res->value, "on"))
2137 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
2138 else if (!strcmp(res->value, "off"))
2139 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
2141 printf("Unknown parameter\n");
2144 } else if (!strcmp(res->name, "drop-en")) {
2145 if (!strcmp(res->value, "on"))
2147 else if (!strcmp(res->value, "off"))
2150 printf("Unknown parameter\n");
2154 printf("Unknown parameter\n");
2157 port->dev_conf.rxmode.offloads = rx_offloads;
2158 /* Apply Rx offloads configuration */
2159 for (k = 0; k < port->dev_info.max_rx_queues; k++)
2160 port->rx_conf[k].offloads =
2161 port->dev_conf.rxmode.offloads;
2166 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2169 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2170 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2171 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2172 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2174 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2175 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2176 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2177 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2178 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
2179 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
2180 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2181 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2184 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2185 .f = cmd_config_rx_mode_flag_parsed,
2187 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
2188 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
2190 (void *)&cmd_config_rx_mode_flag_port,
2191 (void *)&cmd_config_rx_mode_flag_keyword,
2192 (void *)&cmd_config_rx_mode_flag_all,
2193 (void *)&cmd_config_rx_mode_flag_name,
2194 (void *)&cmd_config_rx_mode_flag_value,
2199 /* *** configure rss *** */
2200 struct cmd_config_rss {
2201 cmdline_fixed_string_t port;
2202 cmdline_fixed_string_t keyword;
2203 cmdline_fixed_string_t all;
2204 cmdline_fixed_string_t name;
2205 cmdline_fixed_string_t value;
2209 cmd_config_rss_parsed(void *parsed_result,
2210 __attribute__((unused)) struct cmdline *cl,
2211 __attribute__((unused)) void *data)
2213 struct cmd_config_rss *res = parsed_result;
2214 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2215 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2216 int use_default = 0;
2217 int all_updated = 1;
2221 if (!strcmp(res->value, "all"))
2222 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2223 ETH_RSS_UDP | ETH_RSS_SCTP |
2225 else if (!strcmp(res->value, "ip"))
2226 rss_conf.rss_hf = ETH_RSS_IP;
2227 else if (!strcmp(res->value, "udp"))
2228 rss_conf.rss_hf = ETH_RSS_UDP;
2229 else if (!strcmp(res->value, "tcp"))
2230 rss_conf.rss_hf = ETH_RSS_TCP;
2231 else if (!strcmp(res->value, "sctp"))
2232 rss_conf.rss_hf = ETH_RSS_SCTP;
2233 else if (!strcmp(res->value, "ether"))
2234 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2235 else if (!strcmp(res->value, "port"))
2236 rss_conf.rss_hf = ETH_RSS_PORT;
2237 else if (!strcmp(res->value, "vxlan"))
2238 rss_conf.rss_hf = ETH_RSS_VXLAN;
2239 else if (!strcmp(res->value, "geneve"))
2240 rss_conf.rss_hf = ETH_RSS_GENEVE;
2241 else if (!strcmp(res->value, "nvgre"))
2242 rss_conf.rss_hf = ETH_RSS_NVGRE;
2243 else if (!strcmp(res->value, "none"))
2244 rss_conf.rss_hf = 0;
2245 else if (!strcmp(res->value, "default"))
2247 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2248 atoi(res->value) < 64)
2249 rss_conf.rss_hf = 1ULL << atoi(res->value);
2251 printf("Unknown parameter\n");
2254 rss_conf.rss_key = NULL;
2255 /* Update global configuration for RSS types. */
2256 RTE_ETH_FOREACH_DEV(i) {
2257 struct rte_eth_rss_conf local_rss_conf;
2259 rte_eth_dev_info_get(i, &dev_info);
2261 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2263 local_rss_conf = rss_conf;
2264 local_rss_conf.rss_hf = rss_conf.rss_hf &
2265 dev_info.flow_type_rss_offloads;
2266 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2267 printf("Port %u modified RSS hash function based on hardware support,"
2268 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2269 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2271 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2274 printf("Configuration of RSS hash at ethernet port %d "
2275 "failed with error (%d): %s.\n",
2276 i, -diag, strerror(-diag));
2279 if (all_updated && !use_default)
2280 rss_hf = rss_conf.rss_hf;
2283 cmdline_parse_token_string_t cmd_config_rss_port =
2284 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2285 cmdline_parse_token_string_t cmd_config_rss_keyword =
2286 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2287 cmdline_parse_token_string_t cmd_config_rss_all =
2288 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2289 cmdline_parse_token_string_t cmd_config_rss_name =
2290 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2291 cmdline_parse_token_string_t cmd_config_rss_value =
2292 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2294 cmdline_parse_inst_t cmd_config_rss = {
2295 .f = cmd_config_rss_parsed,
2297 .help_str = "port config all rss "
2298 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|<flowtype_id>",
2300 (void *)&cmd_config_rss_port,
2301 (void *)&cmd_config_rss_keyword,
2302 (void *)&cmd_config_rss_all,
2303 (void *)&cmd_config_rss_name,
2304 (void *)&cmd_config_rss_value,
2309 /* *** configure rss hash key *** */
2310 struct cmd_config_rss_hash_key {
2311 cmdline_fixed_string_t port;
2312 cmdline_fixed_string_t config;
2314 cmdline_fixed_string_t rss_hash_key;
2315 cmdline_fixed_string_t rss_type;
2316 cmdline_fixed_string_t key;
2320 hexa_digit_to_value(char hexa_digit)
2322 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2323 return (uint8_t) (hexa_digit - '0');
2324 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2325 return (uint8_t) ((hexa_digit - 'a') + 10);
2326 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2327 return (uint8_t) ((hexa_digit - 'A') + 10);
2328 /* Invalid hexa digit */
2333 parse_and_check_key_hexa_digit(char *key, int idx)
2337 hexa_v = hexa_digit_to_value(key[idx]);
2339 printf("invalid key: character %c at position %d is not a "
2340 "valid hexa digit\n", key[idx], idx);
2345 cmd_config_rss_hash_key_parsed(void *parsed_result,
2346 __attribute__((unused)) struct cmdline *cl,
2347 __attribute__((unused)) void *data)
2349 struct cmd_config_rss_hash_key *res = parsed_result;
2350 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2354 struct rte_eth_dev_info dev_info;
2355 uint8_t hash_key_size;
2358 memset(&dev_info, 0, sizeof(dev_info));
2359 rte_eth_dev_info_get(res->port_id, &dev_info);
2360 if (dev_info.hash_key_size > 0 &&
2361 dev_info.hash_key_size <= sizeof(hash_key))
2362 hash_key_size = dev_info.hash_key_size;
2364 printf("dev_info did not provide a valid hash key size\n");
2367 /* Check the length of the RSS hash key */
2368 key_len = strlen(res->key);
2369 if (key_len != (hash_key_size * 2)) {
2370 printf("key length: %d invalid - key must be a string of %d"
2371 " hexa-decimal numbers\n",
2372 (int) key_len, hash_key_size * 2);
2375 /* Translate RSS hash key into binary representation */
2376 for (i = 0; i < hash_key_size; i++) {
2377 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2380 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2383 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2385 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2389 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2390 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2391 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2392 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2394 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2395 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2396 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2397 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2398 rss_hash_key, "rss-hash-key");
2399 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2400 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2401 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2402 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2403 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2404 "ipv6-tcp-ex#ipv6-udp-ex");
2405 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2406 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2408 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2409 .f = cmd_config_rss_hash_key_parsed,
2411 .help_str = "port config <port_id> rss-hash-key "
2412 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2413 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2414 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2415 "<string of hex digits (variable length, NIC dependent)>",
2417 (void *)&cmd_config_rss_hash_key_port,
2418 (void *)&cmd_config_rss_hash_key_config,
2419 (void *)&cmd_config_rss_hash_key_port_id,
2420 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2421 (void *)&cmd_config_rss_hash_key_rss_type,
2422 (void *)&cmd_config_rss_hash_key_value,
2427 /* *** configure port rxq/txq ring size *** */
2428 struct cmd_config_rxtx_ring_size {
2429 cmdline_fixed_string_t port;
2430 cmdline_fixed_string_t config;
2432 cmdline_fixed_string_t rxtxq;
2434 cmdline_fixed_string_t rsize;
2439 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2440 __attribute__((unused)) struct cmdline *cl,
2441 __attribute__((unused)) void *data)
2443 struct cmd_config_rxtx_ring_size *res = parsed_result;
2444 struct rte_port *port;
2447 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2450 if (res->portid == (portid_t)RTE_PORT_ALL) {
2451 printf("Invalid port id\n");
2455 port = &ports[res->portid];
2457 if (!strcmp(res->rxtxq, "rxq"))
2459 else if (!strcmp(res->rxtxq, "txq"))
2462 printf("Unknown parameter\n");
2466 if (isrx && rx_queue_id_is_invalid(res->qid))
2468 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2471 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2472 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2478 port->nb_rx_desc[res->qid] = res->size;
2480 port->nb_tx_desc[res->qid] = res->size;
2482 cmd_reconfig_device_queue(res->portid, 0, 1);
2485 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2486 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2488 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2489 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2491 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2492 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2494 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2495 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2497 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2498 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2500 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2501 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2502 rsize, "ring_size");
2503 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2504 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2507 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2508 .f = cmd_config_rxtx_ring_size_parsed,
2510 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2512 (void *)&cmd_config_rxtx_ring_size_port,
2513 (void *)&cmd_config_rxtx_ring_size_config,
2514 (void *)&cmd_config_rxtx_ring_size_portid,
2515 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2516 (void *)&cmd_config_rxtx_ring_size_qid,
2517 (void *)&cmd_config_rxtx_ring_size_rsize,
2518 (void *)&cmd_config_rxtx_ring_size_size,
2523 /* *** configure port rxq/txq start/stop *** */
2524 struct cmd_config_rxtx_queue {
2525 cmdline_fixed_string_t port;
2527 cmdline_fixed_string_t rxtxq;
2529 cmdline_fixed_string_t opname;
2533 cmd_config_rxtx_queue_parsed(void *parsed_result,
2534 __attribute__((unused)) struct cmdline *cl,
2535 __attribute__((unused)) void *data)
2537 struct cmd_config_rxtx_queue *res = parsed_result;
2542 if (test_done == 0) {
2543 printf("Please stop forwarding first\n");
2547 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2550 if (port_is_started(res->portid) != 1) {
2551 printf("Please start port %u first\n", res->portid);
2555 if (!strcmp(res->rxtxq, "rxq"))
2557 else if (!strcmp(res->rxtxq, "txq"))
2560 printf("Unknown parameter\n");
2564 if (isrx && rx_queue_id_is_invalid(res->qid))
2566 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2569 if (!strcmp(res->opname, "start"))
2571 else if (!strcmp(res->opname, "stop"))
2574 printf("Unknown parameter\n");
2578 if (isstart && isrx)
2579 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2580 else if (!isstart && isrx)
2581 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2582 else if (isstart && !isrx)
2583 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2585 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2587 if (ret == -ENOTSUP)
2588 printf("Function not supported in PMD driver\n");
2591 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2592 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2593 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2594 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2595 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2596 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2597 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2598 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2599 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2600 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2603 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2604 .f = cmd_config_rxtx_queue_parsed,
2606 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2608 (void *)&cmd_config_rxtx_queue_port,
2609 (void *)&cmd_config_rxtx_queue_portid,
2610 (void *)&cmd_config_rxtx_queue_rxtxq,
2611 (void *)&cmd_config_rxtx_queue_qid,
2612 (void *)&cmd_config_rxtx_queue_opname,
2617 /* *** configure port rxq/txq deferred start on/off *** */
2618 struct cmd_config_deferred_start_rxtx_queue {
2619 cmdline_fixed_string_t port;
2621 cmdline_fixed_string_t rxtxq;
2623 cmdline_fixed_string_t opname;
2624 cmdline_fixed_string_t state;
2628 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2629 __attribute__((unused)) struct cmdline *cl,
2630 __attribute__((unused)) void *data)
2632 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2633 struct rte_port *port;
2636 uint8_t needreconfig = 0;
2638 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2641 if (port_is_started(res->port_id) != 0) {
2642 printf("Please stop port %u first\n", res->port_id);
2646 port = &ports[res->port_id];
2648 isrx = !strcmp(res->rxtxq, "rxq");
2650 if (isrx && rx_queue_id_is_invalid(res->qid))
2652 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2655 ison = !strcmp(res->state, "on");
2657 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2658 port->rx_conf[res->qid].rx_deferred_start = ison;
2660 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2661 port->tx_conf[res->qid].tx_deferred_start = ison;
2666 cmd_reconfig_device_queue(res->port_id, 0, 1);
2669 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2670 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2672 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2673 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2675 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2676 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2678 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2679 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2681 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2682 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2683 opname, "deferred_start");
2684 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2685 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2688 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2689 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2691 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2693 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2694 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2695 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2696 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2697 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2698 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2703 /* *** configure port rxq/txq setup *** */
2704 struct cmd_setup_rxtx_queue {
2705 cmdline_fixed_string_t port;
2707 cmdline_fixed_string_t rxtxq;
2709 cmdline_fixed_string_t setup;
2712 /* Common CLI fields for queue setup */
2713 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2714 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2715 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2716 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2717 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2718 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2719 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2720 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2721 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2722 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2725 cmd_setup_rxtx_queue_parsed(
2726 void *parsed_result,
2727 __attribute__((unused)) struct cmdline *cl,
2728 __attribute__((unused)) void *data)
2730 struct cmd_setup_rxtx_queue *res = parsed_result;
2731 struct rte_port *port;
2732 struct rte_mempool *mp;
2733 unsigned int socket_id;
2737 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2740 if (res->portid == (portid_t)RTE_PORT_ALL) {
2741 printf("Invalid port id\n");
2745 if (!strcmp(res->rxtxq, "rxq"))
2747 else if (!strcmp(res->rxtxq, "txq"))
2750 printf("Unknown parameter\n");
2754 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2755 printf("Invalid rx queue\n");
2757 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2758 printf("Invalid tx queue\n");
2762 port = &ports[res->portid];
2764 socket_id = rxring_numa[res->portid];
2765 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2766 socket_id = port->socket_id;
2768 mp = mbuf_pool_find(socket_id);
2770 printf("Failed to setup RX queue: "
2771 "No mempool allocation"
2772 " on the socket %d\n",
2773 rxring_numa[res->portid]);
2776 ret = rte_eth_rx_queue_setup(res->portid,
2778 port->nb_rx_desc[res->qid],
2780 &port->rx_conf[res->qid],
2783 printf("Failed to setup RX queue\n");
2785 socket_id = txring_numa[res->portid];
2786 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2787 socket_id = port->socket_id;
2789 ret = rte_eth_tx_queue_setup(res->portid,
2791 port->nb_tx_desc[res->qid],
2793 &port->tx_conf[res->qid]);
2795 printf("Failed to setup TX queue\n");
2799 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2800 .f = cmd_setup_rxtx_queue_parsed,
2802 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2804 (void *)&cmd_setup_rxtx_queue_port,
2805 (void *)&cmd_setup_rxtx_queue_portid,
2806 (void *)&cmd_setup_rxtx_queue_rxtxq,
2807 (void *)&cmd_setup_rxtx_queue_qid,
2808 (void *)&cmd_setup_rxtx_queue_setup,
2814 /* *** Configure RSS RETA *** */
2815 struct cmd_config_rss_reta {
2816 cmdline_fixed_string_t port;
2817 cmdline_fixed_string_t keyword;
2819 cmdline_fixed_string_t name;
2820 cmdline_fixed_string_t list_name;
2821 cmdline_fixed_string_t list_of_items;
2825 parse_reta_config(const char *str,
2826 struct rte_eth_rss_reta_entry64 *reta_conf,
2827 uint16_t nb_entries)
2831 uint16_t hash_index, idx, shift;
2834 const char *p, *p0 = str;
2841 unsigned long int_fld[_NUM_FLD];
2842 char *str_fld[_NUM_FLD];
2844 while ((p = strchr(p0,'(')) != NULL) {
2846 if((p0 = strchr(p,')')) == NULL)
2850 if(size >= sizeof(s))
2853 snprintf(s, sizeof(s), "%.*s", size, p);
2854 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2856 for (i = 0; i < _NUM_FLD; i++) {
2858 int_fld[i] = strtoul(str_fld[i], &end, 0);
2859 if (errno != 0 || end == str_fld[i] ||
2864 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2865 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2867 if (hash_index >= nb_entries) {
2868 printf("Invalid RETA hash index=%d\n", hash_index);
2872 idx = hash_index / RTE_RETA_GROUP_SIZE;
2873 shift = hash_index % RTE_RETA_GROUP_SIZE;
2874 reta_conf[idx].mask |= (1ULL << shift);
2875 reta_conf[idx].reta[shift] = nb_queue;
2882 cmd_set_rss_reta_parsed(void *parsed_result,
2883 __attribute__((unused)) struct cmdline *cl,
2884 __attribute__((unused)) void *data)
2887 struct rte_eth_dev_info dev_info;
2888 struct rte_eth_rss_reta_entry64 reta_conf[8];
2889 struct cmd_config_rss_reta *res = parsed_result;
2891 memset(&dev_info, 0, sizeof(dev_info));
2892 rte_eth_dev_info_get(res->port_id, &dev_info);
2893 if (dev_info.reta_size == 0) {
2894 printf("Redirection table size is 0 which is "
2895 "invalid for RSS\n");
2898 printf("The reta size of port %d is %u\n",
2899 res->port_id, dev_info.reta_size);
2900 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2901 printf("Currently do not support more than %u entries of "
2902 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2906 memset(reta_conf, 0, sizeof(reta_conf));
2907 if (!strcmp(res->list_name, "reta")) {
2908 if (parse_reta_config(res->list_of_items, reta_conf,
2909 dev_info.reta_size)) {
2910 printf("Invalid RSS Redirection Table "
2911 "config entered\n");
2914 ret = rte_eth_dev_rss_reta_update(res->port_id,
2915 reta_conf, dev_info.reta_size);
2917 printf("Bad redirection table parameter, "
2918 "return code = %d \n", ret);
2922 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2923 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2924 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2925 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2926 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2927 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2928 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2929 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2930 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2931 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2932 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2933 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2935 cmdline_parse_inst_t cmd_config_rss_reta = {
2936 .f = cmd_set_rss_reta_parsed,
2938 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2940 (void *)&cmd_config_rss_reta_port,
2941 (void *)&cmd_config_rss_reta_keyword,
2942 (void *)&cmd_config_rss_reta_port_id,
2943 (void *)&cmd_config_rss_reta_name,
2944 (void *)&cmd_config_rss_reta_list_name,
2945 (void *)&cmd_config_rss_reta_list_of_items,
2950 /* *** SHOW PORT RETA INFO *** */
2951 struct cmd_showport_reta {
2952 cmdline_fixed_string_t show;
2953 cmdline_fixed_string_t port;
2955 cmdline_fixed_string_t rss;
2956 cmdline_fixed_string_t reta;
2958 cmdline_fixed_string_t list_of_items;
2962 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2963 uint16_t nb_entries,
2967 const char *p, *p0 = str;
2972 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2973 RTE_RETA_GROUP_SIZE;
2976 p = strchr(p0, '(');
2980 p0 = strchr(p, ')');
2984 if (size >= sizeof(s)) {
2985 printf("The string size exceeds the internal buffer size\n");
2988 snprintf(s, sizeof(s), "%.*s", size, p);
2989 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2990 if (ret <= 0 || ret != num) {
2991 printf("The bits of masks do not match the number of "
2992 "reta entries: %u\n", num);
2995 for (i = 0; i < ret; i++)
2996 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3002 cmd_showport_reta_parsed(void *parsed_result,
3003 __attribute__((unused)) struct cmdline *cl,
3004 __attribute__((unused)) void *data)
3006 struct cmd_showport_reta *res = parsed_result;
3007 struct rte_eth_rss_reta_entry64 reta_conf[8];
3008 struct rte_eth_dev_info dev_info;
3009 uint16_t max_reta_size;
3011 memset(&dev_info, 0, sizeof(dev_info));
3012 rte_eth_dev_info_get(res->port_id, &dev_info);
3013 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3014 if (res->size == 0 || res->size > max_reta_size) {
3015 printf("Invalid redirection table size: %u (1-%u)\n",
3016 res->size, max_reta_size);
3020 memset(reta_conf, 0, sizeof(reta_conf));
3021 if (showport_parse_reta_config(reta_conf, res->size,
3022 res->list_of_items) < 0) {
3023 printf("Invalid string: %s for reta masks\n",
3024 res->list_of_items);
3027 port_rss_reta_info(res->port_id, reta_conf, res->size);
3030 cmdline_parse_token_string_t cmd_showport_reta_show =
3031 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3032 cmdline_parse_token_string_t cmd_showport_reta_port =
3033 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3034 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3035 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3036 cmdline_parse_token_string_t cmd_showport_reta_rss =
3037 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3038 cmdline_parse_token_string_t cmd_showport_reta_reta =
3039 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3040 cmdline_parse_token_num_t cmd_showport_reta_size =
3041 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3042 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3043 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3044 list_of_items, NULL);
3046 cmdline_parse_inst_t cmd_showport_reta = {
3047 .f = cmd_showport_reta_parsed,
3049 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3051 (void *)&cmd_showport_reta_show,
3052 (void *)&cmd_showport_reta_port,
3053 (void *)&cmd_showport_reta_port_id,
3054 (void *)&cmd_showport_reta_rss,
3055 (void *)&cmd_showport_reta_reta,
3056 (void *)&cmd_showport_reta_size,
3057 (void *)&cmd_showport_reta_list_of_items,
3062 /* *** Show RSS hash configuration *** */
3063 struct cmd_showport_rss_hash {
3064 cmdline_fixed_string_t show;
3065 cmdline_fixed_string_t port;
3067 cmdline_fixed_string_t rss_hash;
3068 cmdline_fixed_string_t rss_type;
3069 cmdline_fixed_string_t key; /* optional argument */
3072 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3073 __attribute__((unused)) struct cmdline *cl,
3076 struct cmd_showport_rss_hash *res = parsed_result;
3078 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3081 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3082 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3083 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3084 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3085 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3086 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3087 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3088 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3090 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3091 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3093 cmdline_parse_inst_t cmd_showport_rss_hash = {
3094 .f = cmd_showport_rss_hash_parsed,
3096 .help_str = "show port <port_id> rss-hash",
3098 (void *)&cmd_showport_rss_hash_show,
3099 (void *)&cmd_showport_rss_hash_port,
3100 (void *)&cmd_showport_rss_hash_port_id,
3101 (void *)&cmd_showport_rss_hash_rss_hash,
3106 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3107 .f = cmd_showport_rss_hash_parsed,
3109 .help_str = "show port <port_id> rss-hash key",
3111 (void *)&cmd_showport_rss_hash_show,
3112 (void *)&cmd_showport_rss_hash_port,
3113 (void *)&cmd_showport_rss_hash_port_id,
3114 (void *)&cmd_showport_rss_hash_rss_hash,
3115 (void *)&cmd_showport_rss_hash_rss_key,
3120 /* *** Configure DCB *** */
3121 struct cmd_config_dcb {
3122 cmdline_fixed_string_t port;
3123 cmdline_fixed_string_t config;
3125 cmdline_fixed_string_t dcb;
3126 cmdline_fixed_string_t vt;
3127 cmdline_fixed_string_t vt_en;
3129 cmdline_fixed_string_t pfc;
3130 cmdline_fixed_string_t pfc_en;
3134 cmd_config_dcb_parsed(void *parsed_result,
3135 __attribute__((unused)) struct cmdline *cl,
3136 __attribute__((unused)) void *data)
3138 struct cmd_config_dcb *res = parsed_result;
3139 portid_t port_id = res->port_id;
3140 struct rte_port *port;
3144 port = &ports[port_id];
3145 /** Check if the port is not started **/
3146 if (port->port_status != RTE_PORT_STOPPED) {
3147 printf("Please stop port %d first\n", port_id);
3151 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3152 printf("The invalid number of traffic class,"
3153 " only 4 or 8 allowed.\n");
3157 if (nb_fwd_lcores < res->num_tcs) {
3158 printf("nb_cores shouldn't be less than number of TCs.\n");
3161 if (!strncmp(res->pfc_en, "on", 2))
3166 /* DCB in VT mode */
3167 if (!strncmp(res->vt_en, "on", 2))
3168 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3169 (enum rte_eth_nb_tcs)res->num_tcs,
3172 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3173 (enum rte_eth_nb_tcs)res->num_tcs,
3178 printf("Cannot initialize network ports.\n");
3182 cmd_reconfig_device_queue(port_id, 1, 1);
3185 cmdline_parse_token_string_t cmd_config_dcb_port =
3186 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3187 cmdline_parse_token_string_t cmd_config_dcb_config =
3188 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3189 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3190 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3191 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3192 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3193 cmdline_parse_token_string_t cmd_config_dcb_vt =
3194 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3195 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3196 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3197 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3198 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3199 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3200 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3201 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3202 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3204 cmdline_parse_inst_t cmd_config_dcb = {
3205 .f = cmd_config_dcb_parsed,
3207 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3209 (void *)&cmd_config_dcb_port,
3210 (void *)&cmd_config_dcb_config,
3211 (void *)&cmd_config_dcb_port_id,
3212 (void *)&cmd_config_dcb_dcb,
3213 (void *)&cmd_config_dcb_vt,
3214 (void *)&cmd_config_dcb_vt_en,
3215 (void *)&cmd_config_dcb_num_tcs,
3216 (void *)&cmd_config_dcb_pfc,
3217 (void *)&cmd_config_dcb_pfc_en,
3222 /* *** configure number of packets per burst *** */
3223 struct cmd_config_burst {
3224 cmdline_fixed_string_t port;
3225 cmdline_fixed_string_t keyword;
3226 cmdline_fixed_string_t all;
3227 cmdline_fixed_string_t name;
3232 cmd_config_burst_parsed(void *parsed_result,
3233 __attribute__((unused)) struct cmdline *cl,
3234 __attribute__((unused)) void *data)
3236 struct cmd_config_burst *res = parsed_result;
3237 struct rte_eth_dev_info dev_info;
3238 uint16_t rec_nb_pkts;
3240 if (!all_ports_stopped()) {
3241 printf("Please stop all ports first\n");
3245 if (!strcmp(res->name, "burst")) {
3246 if (res->value == 0) {
3247 /* If user gives a value of zero, query the PMD for
3248 * its recommended Rx burst size. Testpmd uses a single
3249 * size for all ports, so assume all ports are the same
3250 * NIC model and use the values from Port 0.
3252 rte_eth_dev_info_get(0, &dev_info);
3253 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3255 if (rec_nb_pkts == 0) {
3256 printf("PMD does not recommend a burst size.\n"
3257 "User provided value must be between"
3258 " 1 and %d\n", MAX_PKT_BURST);
3260 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3261 printf("PMD recommended burst size of %d"
3262 " exceeds maximum value of %d\n",
3263 rec_nb_pkts, MAX_PKT_BURST);
3266 printf("Using PMD-provided burst value of %d\n",
3268 nb_pkt_per_burst = rec_nb_pkts;
3269 } else if (res->value > MAX_PKT_BURST) {
3270 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3273 nb_pkt_per_burst = res->value;
3275 printf("Unknown parameter\n");
3281 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3284 cmdline_parse_token_string_t cmd_config_burst_port =
3285 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3286 cmdline_parse_token_string_t cmd_config_burst_keyword =
3287 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3288 cmdline_parse_token_string_t cmd_config_burst_all =
3289 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3290 cmdline_parse_token_string_t cmd_config_burst_name =
3291 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3292 cmdline_parse_token_num_t cmd_config_burst_value =
3293 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3295 cmdline_parse_inst_t cmd_config_burst = {
3296 .f = cmd_config_burst_parsed,
3298 .help_str = "port config all burst <value>",
3300 (void *)&cmd_config_burst_port,
3301 (void *)&cmd_config_burst_keyword,
3302 (void *)&cmd_config_burst_all,
3303 (void *)&cmd_config_burst_name,
3304 (void *)&cmd_config_burst_value,
3309 /* *** configure rx/tx queues *** */
3310 struct cmd_config_thresh {
3311 cmdline_fixed_string_t port;
3312 cmdline_fixed_string_t keyword;
3313 cmdline_fixed_string_t all;
3314 cmdline_fixed_string_t name;
3319 cmd_config_thresh_parsed(void *parsed_result,
3320 __attribute__((unused)) struct cmdline *cl,
3321 __attribute__((unused)) void *data)
3323 struct cmd_config_thresh *res = parsed_result;
3325 if (!all_ports_stopped()) {
3326 printf("Please stop all ports first\n");
3330 if (!strcmp(res->name, "txpt"))
3331 tx_pthresh = res->value;
3332 else if(!strcmp(res->name, "txht"))
3333 tx_hthresh = res->value;
3334 else if(!strcmp(res->name, "txwt"))
3335 tx_wthresh = res->value;
3336 else if(!strcmp(res->name, "rxpt"))
3337 rx_pthresh = res->value;
3338 else if(!strcmp(res->name, "rxht"))
3339 rx_hthresh = res->value;
3340 else if(!strcmp(res->name, "rxwt"))
3341 rx_wthresh = res->value;
3343 printf("Unknown parameter\n");
3349 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3352 cmdline_parse_token_string_t cmd_config_thresh_port =
3353 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3354 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3355 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3356 cmdline_parse_token_string_t cmd_config_thresh_all =
3357 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3358 cmdline_parse_token_string_t cmd_config_thresh_name =
3359 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3360 "txpt#txht#txwt#rxpt#rxht#rxwt");
3361 cmdline_parse_token_num_t cmd_config_thresh_value =
3362 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3364 cmdline_parse_inst_t cmd_config_thresh = {
3365 .f = cmd_config_thresh_parsed,
3367 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3369 (void *)&cmd_config_thresh_port,
3370 (void *)&cmd_config_thresh_keyword,
3371 (void *)&cmd_config_thresh_all,
3372 (void *)&cmd_config_thresh_name,
3373 (void *)&cmd_config_thresh_value,
3378 /* *** configure free/rs threshold *** */
3379 struct cmd_config_threshold {
3380 cmdline_fixed_string_t port;
3381 cmdline_fixed_string_t keyword;
3382 cmdline_fixed_string_t all;
3383 cmdline_fixed_string_t name;
3388 cmd_config_threshold_parsed(void *parsed_result,
3389 __attribute__((unused)) struct cmdline *cl,
3390 __attribute__((unused)) void *data)
3392 struct cmd_config_threshold *res = parsed_result;
3394 if (!all_ports_stopped()) {
3395 printf("Please stop all ports first\n");
3399 if (!strcmp(res->name, "txfreet"))
3400 tx_free_thresh = res->value;
3401 else if (!strcmp(res->name, "txrst"))
3402 tx_rs_thresh = res->value;
3403 else if (!strcmp(res->name, "rxfreet"))
3404 rx_free_thresh = res->value;
3406 printf("Unknown parameter\n");
3412 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3415 cmdline_parse_token_string_t cmd_config_threshold_port =
3416 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3417 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3418 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3420 cmdline_parse_token_string_t cmd_config_threshold_all =
3421 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3422 cmdline_parse_token_string_t cmd_config_threshold_name =
3423 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3424 "txfreet#txrst#rxfreet");
3425 cmdline_parse_token_num_t cmd_config_threshold_value =
3426 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3428 cmdline_parse_inst_t cmd_config_threshold = {
3429 .f = cmd_config_threshold_parsed,
3431 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3433 (void *)&cmd_config_threshold_port,
3434 (void *)&cmd_config_threshold_keyword,
3435 (void *)&cmd_config_threshold_all,
3436 (void *)&cmd_config_threshold_name,
3437 (void *)&cmd_config_threshold_value,
3443 struct cmd_stop_result {
3444 cmdline_fixed_string_t stop;
3447 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3448 __attribute__((unused)) struct cmdline *cl,
3449 __attribute__((unused)) void *data)
3451 stop_packet_forwarding();
3454 cmdline_parse_token_string_t cmd_stop_stop =
3455 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3457 cmdline_parse_inst_t cmd_stop = {
3458 .f = cmd_stop_parsed,
3460 .help_str = "stop: Stop packet forwarding",
3462 (void *)&cmd_stop_stop,
3467 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3470 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3471 unsigned int *parsed_items, int check_unique_values)
3473 unsigned int nb_item;
3481 * First parse all items in the list and store their value.
3486 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3488 if ((c >= '0') && (c <= '9')) {
3489 value = (unsigned int) (value * 10 + (c - '0'));
3494 printf("character %c is not a decimal digit\n", c);
3498 printf("No valid value before comma\n");
3501 if (nb_item < max_items) {
3502 parsed_items[nb_item] = value;
3508 if (nb_item >= max_items) {
3509 printf("Number of %s = %u > %u (maximum items)\n",
3510 item_name, nb_item + 1, max_items);
3513 parsed_items[nb_item++] = value;
3514 if (! check_unique_values)
3518 * Then, check that all values in the list are differents.
3519 * No optimization here...
3521 for (i = 0; i < nb_item; i++) {
3522 for (j = i + 1; j < nb_item; j++) {
3523 if (parsed_items[j] == parsed_items[i]) {
3524 printf("duplicated %s %u at index %u and %u\n",
3525 item_name, parsed_items[i], i, j);
3533 struct cmd_set_list_result {
3534 cmdline_fixed_string_t cmd_keyword;
3535 cmdline_fixed_string_t list_name;
3536 cmdline_fixed_string_t list_of_items;
3539 static void cmd_set_list_parsed(void *parsed_result,
3540 __attribute__((unused)) struct cmdline *cl,
3541 __attribute__((unused)) void *data)
3543 struct cmd_set_list_result *res;
3545 unsigned int lcorelist[RTE_MAX_LCORE];
3546 unsigned int portlist[RTE_MAX_ETHPORTS];
3548 unsigned int nb_item;
3550 if (test_done == 0) {
3551 printf("Please stop forwarding first\n");
3555 res = parsed_result;
3556 if (!strcmp(res->list_name, "corelist")) {
3557 nb_item = parse_item_list(res->list_of_items, "core",
3559 parsed_items.lcorelist, 1);
3561 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3566 if (!strcmp(res->list_name, "portlist")) {
3567 nb_item = parse_item_list(res->list_of_items, "port",
3569 parsed_items.portlist, 1);
3571 set_fwd_ports_list(parsed_items.portlist, nb_item);
3577 cmdline_parse_token_string_t cmd_set_list_keyword =
3578 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3580 cmdline_parse_token_string_t cmd_set_list_name =
3581 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3582 "corelist#portlist");
3583 cmdline_parse_token_string_t cmd_set_list_of_items =
3584 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3587 cmdline_parse_inst_t cmd_set_fwd_list = {
3588 .f = cmd_set_list_parsed,
3590 .help_str = "set corelist|portlist <list0[,list1]*>",
3592 (void *)&cmd_set_list_keyword,
3593 (void *)&cmd_set_list_name,
3594 (void *)&cmd_set_list_of_items,
3599 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3601 struct cmd_setmask_result {
3602 cmdline_fixed_string_t set;
3603 cmdline_fixed_string_t mask;
3607 static void cmd_set_mask_parsed(void *parsed_result,
3608 __attribute__((unused)) struct cmdline *cl,
3609 __attribute__((unused)) void *data)
3611 struct cmd_setmask_result *res = parsed_result;
3613 if (test_done == 0) {
3614 printf("Please stop forwarding first\n");
3617 if (!strcmp(res->mask, "coremask")) {
3618 set_fwd_lcores_mask(res->hexavalue);
3620 } else if (!strcmp(res->mask, "portmask")) {
3621 set_fwd_ports_mask(res->hexavalue);
3626 cmdline_parse_token_string_t cmd_setmask_set =
3627 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3628 cmdline_parse_token_string_t cmd_setmask_mask =
3629 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3630 "coremask#portmask");
3631 cmdline_parse_token_num_t cmd_setmask_value =
3632 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3634 cmdline_parse_inst_t cmd_set_fwd_mask = {
3635 .f = cmd_set_mask_parsed,
3637 .help_str = "set coremask|portmask <hexadecimal value>",
3639 (void *)&cmd_setmask_set,
3640 (void *)&cmd_setmask_mask,
3641 (void *)&cmd_setmask_value,
3647 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3649 struct cmd_set_result {
3650 cmdline_fixed_string_t set;
3651 cmdline_fixed_string_t what;
3655 static void cmd_set_parsed(void *parsed_result,
3656 __attribute__((unused)) struct cmdline *cl,
3657 __attribute__((unused)) void *data)
3659 struct cmd_set_result *res = parsed_result;
3660 if (!strcmp(res->what, "nbport")) {
3661 set_fwd_ports_number(res->value);
3663 } else if (!strcmp(res->what, "nbcore")) {
3664 set_fwd_lcores_number(res->value);
3666 } else if (!strcmp(res->what, "burst"))
3667 set_nb_pkt_per_burst(res->value);
3668 else if (!strcmp(res->what, "verbose"))
3669 set_verbose_level(res->value);
3672 cmdline_parse_token_string_t cmd_set_set =
3673 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3674 cmdline_parse_token_string_t cmd_set_what =
3675 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3676 "nbport#nbcore#burst#verbose");
3677 cmdline_parse_token_num_t cmd_set_value =
3678 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3680 cmdline_parse_inst_t cmd_set_numbers = {
3681 .f = cmd_set_parsed,
3683 .help_str = "set nbport|nbcore|burst|verbose <value>",
3685 (void *)&cmd_set_set,
3686 (void *)&cmd_set_what,
3687 (void *)&cmd_set_value,
3692 /* *** SET LOG LEVEL CONFIGURATION *** */
3694 struct cmd_set_log_result {
3695 cmdline_fixed_string_t set;
3696 cmdline_fixed_string_t log;
3697 cmdline_fixed_string_t type;
3702 cmd_set_log_parsed(void *parsed_result,
3703 __attribute__((unused)) struct cmdline *cl,
3704 __attribute__((unused)) void *data)
3706 struct cmd_set_log_result *res;
3709 res = parsed_result;
3710 if (!strcmp(res->type, "global"))
3711 rte_log_set_global_level(res->level);
3713 ret = rte_log_set_level_regexp(res->type, res->level);
3715 printf("Unable to set log level\n");
3719 cmdline_parse_token_string_t cmd_set_log_set =
3720 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3721 cmdline_parse_token_string_t cmd_set_log_log =
3722 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3723 cmdline_parse_token_string_t cmd_set_log_type =
3724 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3725 cmdline_parse_token_num_t cmd_set_log_level =
3726 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3728 cmdline_parse_inst_t cmd_set_log = {
3729 .f = cmd_set_log_parsed,
3731 .help_str = "set log global|<type> <level>",
3733 (void *)&cmd_set_log_set,
3734 (void *)&cmd_set_log_log,
3735 (void *)&cmd_set_log_type,
3736 (void *)&cmd_set_log_level,
3741 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3743 struct cmd_set_txpkts_result {
3744 cmdline_fixed_string_t cmd_keyword;
3745 cmdline_fixed_string_t txpkts;
3746 cmdline_fixed_string_t seg_lengths;
3750 cmd_set_txpkts_parsed(void *parsed_result,
3751 __attribute__((unused)) struct cmdline *cl,
3752 __attribute__((unused)) void *data)
3754 struct cmd_set_txpkts_result *res;
3755 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3756 unsigned int nb_segs;
3758 res = parsed_result;
3759 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3760 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3762 set_tx_pkt_segments(seg_lengths, nb_segs);
3765 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3766 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3767 cmd_keyword, "set");
3768 cmdline_parse_token_string_t cmd_set_txpkts_name =
3769 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3771 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3772 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3775 cmdline_parse_inst_t cmd_set_txpkts = {
3776 .f = cmd_set_txpkts_parsed,
3778 .help_str = "set txpkts <len0[,len1]*>",
3780 (void *)&cmd_set_txpkts_keyword,
3781 (void *)&cmd_set_txpkts_name,
3782 (void *)&cmd_set_txpkts_lengths,
3787 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3789 struct cmd_set_txsplit_result {
3790 cmdline_fixed_string_t cmd_keyword;
3791 cmdline_fixed_string_t txsplit;
3792 cmdline_fixed_string_t mode;
3796 cmd_set_txsplit_parsed(void *parsed_result,
3797 __attribute__((unused)) struct cmdline *cl,
3798 __attribute__((unused)) void *data)
3800 struct cmd_set_txsplit_result *res;
3802 res = parsed_result;
3803 set_tx_pkt_split(res->mode);
3806 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3807 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3808 cmd_keyword, "set");
3809 cmdline_parse_token_string_t cmd_set_txsplit_name =
3810 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3811 txsplit, "txsplit");
3812 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3813 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3816 cmdline_parse_inst_t cmd_set_txsplit = {
3817 .f = cmd_set_txsplit_parsed,
3819 .help_str = "set txsplit on|off|rand",
3821 (void *)&cmd_set_txsplit_keyword,
3822 (void *)&cmd_set_txsplit_name,
3823 (void *)&cmd_set_txsplit_mode,
3828 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3829 struct cmd_rx_vlan_filter_all_result {
3830 cmdline_fixed_string_t rx_vlan;
3831 cmdline_fixed_string_t what;
3832 cmdline_fixed_string_t all;
3837 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3838 __attribute__((unused)) struct cmdline *cl,
3839 __attribute__((unused)) void *data)
3841 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3843 if (!strcmp(res->what, "add"))
3844 rx_vlan_all_filter_set(res->port_id, 1);
3846 rx_vlan_all_filter_set(res->port_id, 0);
3849 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3850 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3851 rx_vlan, "rx_vlan");
3852 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3853 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3855 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3856 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3858 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3859 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3862 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3863 .f = cmd_rx_vlan_filter_all_parsed,
3865 .help_str = "rx_vlan add|rm all <port_id>: "
3866 "Add/Remove all identifiers to/from the set of VLAN "
3867 "identifiers filtered by a port",
3869 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3870 (void *)&cmd_rx_vlan_filter_all_what,
3871 (void *)&cmd_rx_vlan_filter_all_all,
3872 (void *)&cmd_rx_vlan_filter_all_portid,
3877 /* *** VLAN OFFLOAD SET ON A PORT *** */
3878 struct cmd_vlan_offload_result {
3879 cmdline_fixed_string_t vlan;
3880 cmdline_fixed_string_t set;
3881 cmdline_fixed_string_t vlan_type;
3882 cmdline_fixed_string_t what;
3883 cmdline_fixed_string_t on;
3884 cmdline_fixed_string_t port_id;
3888 cmd_vlan_offload_parsed(void *parsed_result,
3889 __attribute__((unused)) struct cmdline *cl,
3890 __attribute__((unused)) void *data)
3893 struct cmd_vlan_offload_result *res = parsed_result;
3896 portid_t port_id = 0;
3900 len = strnlen(str, STR_TOKEN_SIZE);
3902 /* Get port_id first */
3910 tmp = strtoul(str, NULL, 0);
3911 /* If port_id greater that what portid_t can represent, return */
3912 if(tmp >= RTE_MAX_ETHPORTS)
3914 port_id = (portid_t)tmp;
3916 if (!strcmp(res->on, "on"))
3921 if (!strcmp(res->what, "strip"))
3922 rx_vlan_strip_set(port_id, on);
3923 else if(!strcmp(res->what, "stripq")){
3924 uint16_t queue_id = 0;
3926 /* No queue_id, return */
3928 printf("must specify (port,queue_id)\n");
3931 tmp = strtoul(str + i + 1, NULL, 0);
3932 /* If queue_id greater that what 16-bits can represent, return */
3936 queue_id = (uint16_t)tmp;
3937 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3939 else if (!strcmp(res->what, "filter"))
3940 rx_vlan_filter_set(port_id, on);
3942 vlan_extend_set(port_id, on);
3947 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3948 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3950 cmdline_parse_token_string_t cmd_vlan_offload_set =
3951 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3953 cmdline_parse_token_string_t cmd_vlan_offload_what =
3954 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3955 what, "strip#filter#qinq#stripq");
3956 cmdline_parse_token_string_t cmd_vlan_offload_on =
3957 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3959 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3960 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3963 cmdline_parse_inst_t cmd_vlan_offload = {
3964 .f = cmd_vlan_offload_parsed,
3966 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3967 "<port_id[,queue_id]>: "
3968 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3970 (void *)&cmd_vlan_offload_vlan,
3971 (void *)&cmd_vlan_offload_set,
3972 (void *)&cmd_vlan_offload_what,
3973 (void *)&cmd_vlan_offload_on,
3974 (void *)&cmd_vlan_offload_portid,
3979 /* *** VLAN TPID SET ON A PORT *** */
3980 struct cmd_vlan_tpid_result {
3981 cmdline_fixed_string_t vlan;
3982 cmdline_fixed_string_t set;
3983 cmdline_fixed_string_t vlan_type;
3984 cmdline_fixed_string_t what;
3990 cmd_vlan_tpid_parsed(void *parsed_result,
3991 __attribute__((unused)) struct cmdline *cl,
3992 __attribute__((unused)) void *data)
3994 struct cmd_vlan_tpid_result *res = parsed_result;
3995 enum rte_vlan_type vlan_type;
3997 if (!strcmp(res->vlan_type, "inner"))
3998 vlan_type = ETH_VLAN_TYPE_INNER;
3999 else if (!strcmp(res->vlan_type, "outer"))
4000 vlan_type = ETH_VLAN_TYPE_OUTER;
4002 printf("Unknown vlan type\n");
4005 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4008 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4009 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4011 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4012 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4014 cmdline_parse_token_string_t cmd_vlan_type =
4015 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4016 vlan_type, "inner#outer");
4017 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4018 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4020 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4021 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4023 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4024 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4027 cmdline_parse_inst_t cmd_vlan_tpid = {
4028 .f = cmd_vlan_tpid_parsed,
4030 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4031 "Set the VLAN Ether type",
4033 (void *)&cmd_vlan_tpid_vlan,
4034 (void *)&cmd_vlan_tpid_set,
4035 (void *)&cmd_vlan_type,
4036 (void *)&cmd_vlan_tpid_what,
4037 (void *)&cmd_vlan_tpid_tpid,
4038 (void *)&cmd_vlan_tpid_portid,
4043 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4044 struct cmd_rx_vlan_filter_result {
4045 cmdline_fixed_string_t rx_vlan;
4046 cmdline_fixed_string_t what;
4052 cmd_rx_vlan_filter_parsed(void *parsed_result,
4053 __attribute__((unused)) struct cmdline *cl,
4054 __attribute__((unused)) void *data)
4056 struct cmd_rx_vlan_filter_result *res = parsed_result;
4058 if (!strcmp(res->what, "add"))
4059 rx_vft_set(res->port_id, res->vlan_id, 1);
4061 rx_vft_set(res->port_id, res->vlan_id, 0);
4064 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4065 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4066 rx_vlan, "rx_vlan");
4067 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4068 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4070 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4071 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4073 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4074 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4077 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4078 .f = cmd_rx_vlan_filter_parsed,
4080 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4081 "Add/Remove a VLAN identifier to/from the set of VLAN "
4082 "identifiers filtered by a port",
4084 (void *)&cmd_rx_vlan_filter_rx_vlan,
4085 (void *)&cmd_rx_vlan_filter_what,
4086 (void *)&cmd_rx_vlan_filter_vlanid,
4087 (void *)&cmd_rx_vlan_filter_portid,
4092 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4093 struct cmd_tx_vlan_set_result {
4094 cmdline_fixed_string_t tx_vlan;
4095 cmdline_fixed_string_t set;
4101 cmd_tx_vlan_set_parsed(void *parsed_result,
4102 __attribute__((unused)) struct cmdline *cl,
4103 __attribute__((unused)) void *data)
4105 struct cmd_tx_vlan_set_result *res = parsed_result;
4107 if (!port_is_stopped(res->port_id)) {
4108 printf("Please stop port %d first\n", res->port_id);
4112 tx_vlan_set(res->port_id, res->vlan_id);
4114 cmd_reconfig_device_queue(res->port_id, 1, 1);
4117 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4118 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4119 tx_vlan, "tx_vlan");
4120 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4121 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4123 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4124 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4126 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4127 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4130 cmdline_parse_inst_t cmd_tx_vlan_set = {
4131 .f = cmd_tx_vlan_set_parsed,
4133 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4134 "Enable hardware insertion of a single VLAN header "
4135 "with a given TAG Identifier in packets sent on a port",
4137 (void *)&cmd_tx_vlan_set_tx_vlan,
4138 (void *)&cmd_tx_vlan_set_set,
4139 (void *)&cmd_tx_vlan_set_portid,
4140 (void *)&cmd_tx_vlan_set_vlanid,
4145 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4146 struct cmd_tx_vlan_set_qinq_result {
4147 cmdline_fixed_string_t tx_vlan;
4148 cmdline_fixed_string_t set;
4151 uint16_t vlan_id_outer;
4155 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4156 __attribute__((unused)) struct cmdline *cl,
4157 __attribute__((unused)) void *data)
4159 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4161 if (!port_is_stopped(res->port_id)) {
4162 printf("Please stop port %d first\n", res->port_id);
4166 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4168 cmd_reconfig_device_queue(res->port_id, 1, 1);
4171 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4172 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4173 tx_vlan, "tx_vlan");
4174 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4175 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4177 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4178 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4180 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4181 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4183 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4184 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4185 vlan_id_outer, UINT16);
4187 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4188 .f = cmd_tx_vlan_set_qinq_parsed,
4190 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4191 "Enable hardware insertion of double VLAN header "
4192 "with given TAG Identifiers in packets sent on a port",
4194 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4195 (void *)&cmd_tx_vlan_set_qinq_set,
4196 (void *)&cmd_tx_vlan_set_qinq_portid,
4197 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4198 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4203 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4204 struct cmd_tx_vlan_set_pvid_result {
4205 cmdline_fixed_string_t tx_vlan;
4206 cmdline_fixed_string_t set;
4207 cmdline_fixed_string_t pvid;
4210 cmdline_fixed_string_t mode;
4214 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4215 __attribute__((unused)) struct cmdline *cl,
4216 __attribute__((unused)) void *data)
4218 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4220 if (strcmp(res->mode, "on") == 0)
4221 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4223 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4226 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4227 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4228 tx_vlan, "tx_vlan");
4229 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4230 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4232 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4233 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4235 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4236 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4238 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4239 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4241 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4242 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4245 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4246 .f = cmd_tx_vlan_set_pvid_parsed,
4248 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4250 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4251 (void *)&cmd_tx_vlan_set_pvid_set,
4252 (void *)&cmd_tx_vlan_set_pvid_pvid,
4253 (void *)&cmd_tx_vlan_set_pvid_port_id,
4254 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4255 (void *)&cmd_tx_vlan_set_pvid_mode,
4260 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4261 struct cmd_tx_vlan_reset_result {
4262 cmdline_fixed_string_t tx_vlan;
4263 cmdline_fixed_string_t reset;
4268 cmd_tx_vlan_reset_parsed(void *parsed_result,
4269 __attribute__((unused)) struct cmdline *cl,
4270 __attribute__((unused)) void *data)
4272 struct cmd_tx_vlan_reset_result *res = parsed_result;
4274 if (!port_is_stopped(res->port_id)) {
4275 printf("Please stop port %d first\n", res->port_id);
4279 tx_vlan_reset(res->port_id);
4281 cmd_reconfig_device_queue(res->port_id, 1, 1);
4284 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4285 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4286 tx_vlan, "tx_vlan");
4287 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4288 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4290 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4291 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4294 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4295 .f = cmd_tx_vlan_reset_parsed,
4297 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4298 "VLAN header in packets sent on a port",
4300 (void *)&cmd_tx_vlan_reset_tx_vlan,
4301 (void *)&cmd_tx_vlan_reset_reset,
4302 (void *)&cmd_tx_vlan_reset_portid,
4308 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4309 struct cmd_csum_result {
4310 cmdline_fixed_string_t csum;
4311 cmdline_fixed_string_t mode;
4312 cmdline_fixed_string_t proto;
4313 cmdline_fixed_string_t hwsw;
4318 csum_show(int port_id)
4320 struct rte_eth_dev_info dev_info;
4321 uint64_t tx_offloads;
4323 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4324 printf("Parse tunnel is %s\n",
4325 (ports[port_id].parse_tunnel) ? "on" : "off");
4326 printf("IP checksum offload is %s\n",
4327 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4328 printf("UDP checksum offload is %s\n",
4329 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4330 printf("TCP checksum offload is %s\n",
4331 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4332 printf("SCTP checksum offload is %s\n",
4333 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4334 printf("Outer-Ip checksum offload is %s\n",
4335 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4336 printf("Outer-Udp checksum offload is %s\n",
4337 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4339 /* display warnings if configuration is not supported by the NIC */
4340 rte_eth_dev_info_get(port_id, &dev_info);
4341 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4342 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4343 printf("Warning: hardware IP checksum enabled but not "
4344 "supported by port %d\n", port_id);
4346 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4347 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4348 printf("Warning: hardware UDP checksum enabled but not "
4349 "supported by port %d\n", port_id);
4351 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4352 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4353 printf("Warning: hardware TCP checksum enabled but not "
4354 "supported by port %d\n", port_id);
4356 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4357 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4358 printf("Warning: hardware SCTP checksum enabled but not "
4359 "supported by port %d\n", port_id);
4361 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4362 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4363 printf("Warning: hardware outer IP checksum enabled but not "
4364 "supported by port %d\n", port_id);
4366 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4367 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4369 printf("Warning: hardware outer UDP checksum enabled but not "
4370 "supported by port %d\n", port_id);
4375 cmd_config_queue_tx_offloads(struct rte_port *port)
4379 /* Apply queue tx offloads configuration */
4380 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4381 port->tx_conf[k].offloads =
4382 port->dev_conf.txmode.offloads;
4386 cmd_csum_parsed(void *parsed_result,
4387 __attribute__((unused)) struct cmdline *cl,
4388 __attribute__((unused)) void *data)
4390 struct cmd_csum_result *res = parsed_result;
4392 uint64_t csum_offloads = 0;
4393 struct rte_eth_dev_info dev_info;
4395 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4396 printf("invalid port %d\n", res->port_id);
4399 if (!port_is_stopped(res->port_id)) {
4400 printf("Please stop port %d first\n", res->port_id);
4404 rte_eth_dev_info_get(res->port_id, &dev_info);
4405 if (!strcmp(res->mode, "set")) {
4407 if (!strcmp(res->hwsw, "hw"))
4410 if (!strcmp(res->proto, "ip")) {
4411 if (hw == 0 || (dev_info.tx_offload_capa &
4412 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4413 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4415 printf("IP checksum offload is not supported "
4416 "by port %u\n", res->port_id);
4418 } else if (!strcmp(res->proto, "udp")) {
4419 if (hw == 0 || (dev_info.tx_offload_capa &
4420 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4421 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4423 printf("UDP checksum offload is not supported "
4424 "by port %u\n", res->port_id);
4426 } else if (!strcmp(res->proto, "tcp")) {
4427 if (hw == 0 || (dev_info.tx_offload_capa &
4428 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4429 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4431 printf("TCP checksum offload is not supported "
4432 "by port %u\n", res->port_id);
4434 } else if (!strcmp(res->proto, "sctp")) {
4435 if (hw == 0 || (dev_info.tx_offload_capa &
4436 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4437 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4439 printf("SCTP checksum offload is not supported "
4440 "by port %u\n", res->port_id);
4442 } else if (!strcmp(res->proto, "outer-ip")) {
4443 if (hw == 0 || (dev_info.tx_offload_capa &
4444 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4446 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4448 printf("Outer IP checksum offload is not "
4449 "supported by port %u\n", res->port_id);
4451 } else if (!strcmp(res->proto, "outer-udp")) {
4452 if (hw == 0 || (dev_info.tx_offload_capa &
4453 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4455 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4457 printf("Outer UDP checksum offload is not "
4458 "supported by port %u\n", res->port_id);
4463 ports[res->port_id].dev_conf.txmode.offloads |=
4466 ports[res->port_id].dev_conf.txmode.offloads &=
4469 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4471 csum_show(res->port_id);
4473 cmd_reconfig_device_queue(res->port_id, 1, 1);
4476 cmdline_parse_token_string_t cmd_csum_csum =
4477 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4479 cmdline_parse_token_string_t cmd_csum_mode =
4480 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4482 cmdline_parse_token_string_t cmd_csum_proto =
4483 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4484 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4485 cmdline_parse_token_string_t cmd_csum_hwsw =
4486 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4488 cmdline_parse_token_num_t cmd_csum_portid =
4489 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4492 cmdline_parse_inst_t cmd_csum_set = {
4493 .f = cmd_csum_parsed,
4495 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4496 "Enable/Disable hardware calculation of L3/L4 checksum when "
4497 "using csum forward engine",
4499 (void *)&cmd_csum_csum,
4500 (void *)&cmd_csum_mode,
4501 (void *)&cmd_csum_proto,
4502 (void *)&cmd_csum_hwsw,
4503 (void *)&cmd_csum_portid,
4508 cmdline_parse_token_string_t cmd_csum_mode_show =
4509 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4512 cmdline_parse_inst_t cmd_csum_show = {
4513 .f = cmd_csum_parsed,
4515 .help_str = "csum show <port_id>: Show checksum offload configuration",
4517 (void *)&cmd_csum_csum,
4518 (void *)&cmd_csum_mode_show,
4519 (void *)&cmd_csum_portid,
4524 /* Enable/disable tunnel parsing */
4525 struct cmd_csum_tunnel_result {
4526 cmdline_fixed_string_t csum;
4527 cmdline_fixed_string_t parse;
4528 cmdline_fixed_string_t onoff;
4533 cmd_csum_tunnel_parsed(void *parsed_result,
4534 __attribute__((unused)) struct cmdline *cl,
4535 __attribute__((unused)) void *data)
4537 struct cmd_csum_tunnel_result *res = parsed_result;
4539 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4542 if (!strcmp(res->onoff, "on"))
4543 ports[res->port_id].parse_tunnel = 1;
4545 ports[res->port_id].parse_tunnel = 0;
4547 csum_show(res->port_id);
4550 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4551 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4553 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4554 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4555 parse, "parse-tunnel");
4556 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4557 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4559 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4560 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4563 cmdline_parse_inst_t cmd_csum_tunnel = {
4564 .f = cmd_csum_tunnel_parsed,
4566 .help_str = "csum parse-tunnel on|off <port_id>: "
4567 "Enable/Disable parsing of tunnels for csum engine",
4569 (void *)&cmd_csum_tunnel_csum,
4570 (void *)&cmd_csum_tunnel_parse,
4571 (void *)&cmd_csum_tunnel_onoff,
4572 (void *)&cmd_csum_tunnel_portid,
4577 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4578 struct cmd_tso_set_result {
4579 cmdline_fixed_string_t tso;
4580 cmdline_fixed_string_t mode;
4586 cmd_tso_set_parsed(void *parsed_result,
4587 __attribute__((unused)) struct cmdline *cl,
4588 __attribute__((unused)) void *data)
4590 struct cmd_tso_set_result *res = parsed_result;
4591 struct rte_eth_dev_info dev_info;
4593 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4595 if (!port_is_stopped(res->port_id)) {
4596 printf("Please stop port %d first\n", res->port_id);
4600 if (!strcmp(res->mode, "set"))
4601 ports[res->port_id].tso_segsz = res->tso_segsz;
4603 rte_eth_dev_info_get(res->port_id, &dev_info);
4604 if ((ports[res->port_id].tso_segsz != 0) &&
4605 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4606 printf("Error: TSO is not supported by port %d\n",
4611 if (ports[res->port_id].tso_segsz == 0) {
4612 ports[res->port_id].dev_conf.txmode.offloads &=
4613 ~DEV_TX_OFFLOAD_TCP_TSO;
4614 printf("TSO for non-tunneled packets is disabled\n");
4616 ports[res->port_id].dev_conf.txmode.offloads |=
4617 DEV_TX_OFFLOAD_TCP_TSO;
4618 printf("TSO segment size for non-tunneled packets is %d\n",
4619 ports[res->port_id].tso_segsz);
4621 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4623 /* display warnings if configuration is not supported by the NIC */
4624 rte_eth_dev_info_get(res->port_id, &dev_info);
4625 if ((ports[res->port_id].tso_segsz != 0) &&
4626 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4627 printf("Warning: TSO enabled but not "
4628 "supported by port %d\n", res->port_id);
4631 cmd_reconfig_device_queue(res->port_id, 1, 1);
4634 cmdline_parse_token_string_t cmd_tso_set_tso =
4635 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4637 cmdline_parse_token_string_t cmd_tso_set_mode =
4638 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4640 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4641 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4643 cmdline_parse_token_num_t cmd_tso_set_portid =
4644 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4647 cmdline_parse_inst_t cmd_tso_set = {
4648 .f = cmd_tso_set_parsed,
4650 .help_str = "tso set <tso_segsz> <port_id>: "
4651 "Set TSO segment size of non-tunneled packets for csum engine "
4654 (void *)&cmd_tso_set_tso,
4655 (void *)&cmd_tso_set_mode,
4656 (void *)&cmd_tso_set_tso_segsz,
4657 (void *)&cmd_tso_set_portid,
4662 cmdline_parse_token_string_t cmd_tso_show_mode =
4663 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4667 cmdline_parse_inst_t cmd_tso_show = {
4668 .f = cmd_tso_set_parsed,
4670 .help_str = "tso show <port_id>: "
4671 "Show TSO segment size of non-tunneled packets for csum engine",
4673 (void *)&cmd_tso_set_tso,
4674 (void *)&cmd_tso_show_mode,
4675 (void *)&cmd_tso_set_portid,
4680 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4681 struct cmd_tunnel_tso_set_result {
4682 cmdline_fixed_string_t tso;
4683 cmdline_fixed_string_t mode;
4688 static struct rte_eth_dev_info
4689 check_tunnel_tso_nic_support(portid_t port_id)
4691 struct rte_eth_dev_info dev_info;
4693 rte_eth_dev_info_get(port_id, &dev_info);
4694 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4695 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4696 "not enabled for port %d\n", port_id);
4697 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4698 printf("Warning: GRE TUNNEL TSO not supported therefore "
4699 "not enabled for port %d\n", port_id);
4700 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4701 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4702 "not enabled for port %d\n", port_id);
4703 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4704 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4705 "not enabled for port %d\n", port_id);
4706 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4707 printf("Warning: IP TUNNEL TSO not supported therefore "
4708 "not enabled for port %d\n", port_id);
4709 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4710 printf("Warning: UDP TUNNEL TSO not supported therefore "
4711 "not enabled for port %d\n", port_id);
4716 cmd_tunnel_tso_set_parsed(void *parsed_result,
4717 __attribute__((unused)) struct cmdline *cl,
4718 __attribute__((unused)) void *data)
4720 struct cmd_tunnel_tso_set_result *res = parsed_result;
4721 struct rte_eth_dev_info dev_info;
4723 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4725 if (!port_is_stopped(res->port_id)) {
4726 printf("Please stop port %d first\n", res->port_id);
4730 if (!strcmp(res->mode, "set"))
4731 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4733 dev_info = check_tunnel_tso_nic_support(res->port_id);
4734 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4735 ports[res->port_id].dev_conf.txmode.offloads &=
4736 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4737 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4738 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4739 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4740 DEV_TX_OFFLOAD_IP_TNL_TSO |
4741 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4742 printf("TSO for tunneled packets is disabled\n");
4744 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4745 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4746 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4747 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4748 DEV_TX_OFFLOAD_IP_TNL_TSO |
4749 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4751 ports[res->port_id].dev_conf.txmode.offloads |=
4752 (tso_offloads & dev_info.tx_offload_capa);
4753 printf("TSO segment size for tunneled packets is %d\n",
4754 ports[res->port_id].tunnel_tso_segsz);
4756 /* Below conditions are needed to make it work:
4757 * (1) tunnel TSO is supported by the NIC;
4758 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4760 * (3) for tunneled pkts with outer L3 of IPv4,
4761 * "csum set outer-ip" must be set to hw, because after tso,
4762 * total_len of outer IP header is changed, and the checksum
4763 * of outer IP header calculated by sw should be wrong; that
4764 * is not necessary for IPv6 tunneled pkts because there's no
4765 * checksum in IP header anymore.
4768 if (!ports[res->port_id].parse_tunnel)
4769 printf("Warning: csum parse_tunnel must be set "
4770 "so that tunneled packets are recognized\n");
4771 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4772 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4773 printf("Warning: csum set outer-ip must be set to hw "
4774 "if outer L3 is IPv4; not necessary for IPv6\n");
4777 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4778 cmd_reconfig_device_queue(res->port_id, 1, 1);
4781 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4782 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4784 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4785 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4787 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4788 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4790 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4791 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4794 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4795 .f = cmd_tunnel_tso_set_parsed,
4797 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4798 "Set TSO segment size of tunneled packets for csum engine "
4801 (void *)&cmd_tunnel_tso_set_tso,
4802 (void *)&cmd_tunnel_tso_set_mode,
4803 (void *)&cmd_tunnel_tso_set_tso_segsz,
4804 (void *)&cmd_tunnel_tso_set_portid,
4809 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4810 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4814 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4815 .f = cmd_tunnel_tso_set_parsed,
4817 .help_str = "tunnel_tso show <port_id> "
4818 "Show TSO segment size of tunneled packets for csum engine",
4820 (void *)&cmd_tunnel_tso_set_tso,
4821 (void *)&cmd_tunnel_tso_show_mode,
4822 (void *)&cmd_tunnel_tso_set_portid,
4827 /* *** SET GRO FOR A PORT *** */
4828 struct cmd_gro_enable_result {
4829 cmdline_fixed_string_t cmd_set;
4830 cmdline_fixed_string_t cmd_port;
4831 cmdline_fixed_string_t cmd_keyword;
4832 cmdline_fixed_string_t cmd_onoff;
4837 cmd_gro_enable_parsed(void *parsed_result,
4838 __attribute__((unused)) struct cmdline *cl,
4839 __attribute__((unused)) void *data)
4841 struct cmd_gro_enable_result *res;
4843 res = parsed_result;
4844 if (!strcmp(res->cmd_keyword, "gro"))
4845 setup_gro(res->cmd_onoff, res->cmd_pid);
4848 cmdline_parse_token_string_t cmd_gro_enable_set =
4849 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4851 cmdline_parse_token_string_t cmd_gro_enable_port =
4852 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4853 cmd_keyword, "port");
4854 cmdline_parse_token_num_t cmd_gro_enable_pid =
4855 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4857 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4858 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4859 cmd_keyword, "gro");
4860 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4861 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4862 cmd_onoff, "on#off");
4864 cmdline_parse_inst_t cmd_gro_enable = {
4865 .f = cmd_gro_enable_parsed,
4867 .help_str = "set port <port_id> gro on|off",
4869 (void *)&cmd_gro_enable_set,
4870 (void *)&cmd_gro_enable_port,
4871 (void *)&cmd_gro_enable_pid,
4872 (void *)&cmd_gro_enable_keyword,
4873 (void *)&cmd_gro_enable_onoff,
4878 /* *** DISPLAY GRO CONFIGURATION *** */
4879 struct cmd_gro_show_result {
4880 cmdline_fixed_string_t cmd_show;
4881 cmdline_fixed_string_t cmd_port;
4882 cmdline_fixed_string_t cmd_keyword;
4887 cmd_gro_show_parsed(void *parsed_result,
4888 __attribute__((unused)) struct cmdline *cl,
4889 __attribute__((unused)) void *data)
4891 struct cmd_gro_show_result *res;
4893 res = parsed_result;
4894 if (!strcmp(res->cmd_keyword, "gro"))
4895 show_gro(res->cmd_pid);
4898 cmdline_parse_token_string_t cmd_gro_show_show =
4899 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4901 cmdline_parse_token_string_t cmd_gro_show_port =
4902 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4904 cmdline_parse_token_num_t cmd_gro_show_pid =
4905 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4907 cmdline_parse_token_string_t cmd_gro_show_keyword =
4908 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4909 cmd_keyword, "gro");
4911 cmdline_parse_inst_t cmd_gro_show = {
4912 .f = cmd_gro_show_parsed,
4914 .help_str = "show port <port_id> gro",
4916 (void *)&cmd_gro_show_show,
4917 (void *)&cmd_gro_show_port,
4918 (void *)&cmd_gro_show_pid,
4919 (void *)&cmd_gro_show_keyword,
4924 /* *** SET FLUSH CYCLES FOR GRO *** */
4925 struct cmd_gro_flush_result {
4926 cmdline_fixed_string_t cmd_set;
4927 cmdline_fixed_string_t cmd_keyword;
4928 cmdline_fixed_string_t cmd_flush;
4933 cmd_gro_flush_parsed(void *parsed_result,
4934 __attribute__((unused)) struct cmdline *cl,
4935 __attribute__((unused)) void *data)
4937 struct cmd_gro_flush_result *res;
4939 res = parsed_result;
4940 if ((!strcmp(res->cmd_keyword, "gro")) &&
4941 (!strcmp(res->cmd_flush, "flush")))
4942 setup_gro_flush_cycles(res->cmd_cycles);
4945 cmdline_parse_token_string_t cmd_gro_flush_set =
4946 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4948 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4949 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4950 cmd_keyword, "gro");
4951 cmdline_parse_token_string_t cmd_gro_flush_flush =
4952 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4953 cmd_flush, "flush");
4954 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4955 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4958 cmdline_parse_inst_t cmd_gro_flush = {
4959 .f = cmd_gro_flush_parsed,
4961 .help_str = "set gro flush <cycles>",
4963 (void *)&cmd_gro_flush_set,
4964 (void *)&cmd_gro_flush_keyword,
4965 (void *)&cmd_gro_flush_flush,
4966 (void *)&cmd_gro_flush_cycles,
4971 /* *** ENABLE/DISABLE GSO *** */
4972 struct cmd_gso_enable_result {
4973 cmdline_fixed_string_t cmd_set;
4974 cmdline_fixed_string_t cmd_port;
4975 cmdline_fixed_string_t cmd_keyword;
4976 cmdline_fixed_string_t cmd_mode;
4981 cmd_gso_enable_parsed(void *parsed_result,
4982 __attribute__((unused)) struct cmdline *cl,
4983 __attribute__((unused)) void *data)
4985 struct cmd_gso_enable_result *res;
4987 res = parsed_result;
4988 if (!strcmp(res->cmd_keyword, "gso"))
4989 setup_gso(res->cmd_mode, res->cmd_pid);
4992 cmdline_parse_token_string_t cmd_gso_enable_set =
4993 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4995 cmdline_parse_token_string_t cmd_gso_enable_port =
4996 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4998 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4999 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5000 cmd_keyword, "gso");
5001 cmdline_parse_token_string_t cmd_gso_enable_mode =
5002 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5003 cmd_mode, "on#off");
5004 cmdline_parse_token_num_t cmd_gso_enable_pid =
5005 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5008 cmdline_parse_inst_t cmd_gso_enable = {
5009 .f = cmd_gso_enable_parsed,
5011 .help_str = "set port <port_id> gso on|off",
5013 (void *)&cmd_gso_enable_set,
5014 (void *)&cmd_gso_enable_port,
5015 (void *)&cmd_gso_enable_pid,
5016 (void *)&cmd_gso_enable_keyword,
5017 (void *)&cmd_gso_enable_mode,
5022 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5023 struct cmd_gso_size_result {
5024 cmdline_fixed_string_t cmd_set;
5025 cmdline_fixed_string_t cmd_keyword;
5026 cmdline_fixed_string_t cmd_segsz;
5031 cmd_gso_size_parsed(void *parsed_result,
5032 __attribute__((unused)) struct cmdline *cl,
5033 __attribute__((unused)) void *data)
5035 struct cmd_gso_size_result *res = parsed_result;
5037 if (test_done == 0) {
5038 printf("Before setting GSO segsz, please first"
5039 " stop fowarding\n");
5043 if (!strcmp(res->cmd_keyword, "gso") &&
5044 !strcmp(res->cmd_segsz, "segsz")) {
5045 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5046 printf("gso_size should be larger than %zu."
5047 " Please input a legal value\n",
5048 RTE_GSO_SEG_SIZE_MIN);
5050 gso_max_segment_size = res->cmd_size;
5054 cmdline_parse_token_string_t cmd_gso_size_set =
5055 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5057 cmdline_parse_token_string_t cmd_gso_size_keyword =
5058 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5059 cmd_keyword, "gso");
5060 cmdline_parse_token_string_t cmd_gso_size_segsz =
5061 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5062 cmd_segsz, "segsz");
5063 cmdline_parse_token_num_t cmd_gso_size_size =
5064 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5067 cmdline_parse_inst_t cmd_gso_size = {
5068 .f = cmd_gso_size_parsed,
5070 .help_str = "set gso segsz <length>",
5072 (void *)&cmd_gso_size_set,
5073 (void *)&cmd_gso_size_keyword,
5074 (void *)&cmd_gso_size_segsz,
5075 (void *)&cmd_gso_size_size,
5080 /* *** SHOW GSO CONFIGURATION *** */
5081 struct cmd_gso_show_result {
5082 cmdline_fixed_string_t cmd_show;
5083 cmdline_fixed_string_t cmd_port;
5084 cmdline_fixed_string_t cmd_keyword;
5089 cmd_gso_show_parsed(void *parsed_result,
5090 __attribute__((unused)) struct cmdline *cl,
5091 __attribute__((unused)) void *data)
5093 struct cmd_gso_show_result *res = parsed_result;
5095 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5096 printf("invalid port id %u\n", res->cmd_pid);
5099 if (!strcmp(res->cmd_keyword, "gso")) {
5100 if (gso_ports[res->cmd_pid].enable) {
5101 printf("Max GSO'd packet size: %uB\n"
5102 "Supported GSO types: TCP/IPv4, "
5103 "UDP/IPv4, VxLAN with inner "
5104 "TCP/IPv4 packet, GRE with inner "
5105 "TCP/IPv4 packet\n",
5106 gso_max_segment_size);
5108 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5112 cmdline_parse_token_string_t cmd_gso_show_show =
5113 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5115 cmdline_parse_token_string_t cmd_gso_show_port =
5116 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5118 cmdline_parse_token_string_t cmd_gso_show_keyword =
5119 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5120 cmd_keyword, "gso");
5121 cmdline_parse_token_num_t cmd_gso_show_pid =
5122 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5125 cmdline_parse_inst_t cmd_gso_show = {
5126 .f = cmd_gso_show_parsed,
5128 .help_str = "show port <port_id> gso",
5130 (void *)&cmd_gso_show_show,
5131 (void *)&cmd_gso_show_port,
5132 (void *)&cmd_gso_show_pid,
5133 (void *)&cmd_gso_show_keyword,
5138 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5139 struct cmd_set_flush_rx {
5140 cmdline_fixed_string_t set;
5141 cmdline_fixed_string_t flush_rx;
5142 cmdline_fixed_string_t mode;
5146 cmd_set_flush_rx_parsed(void *parsed_result,
5147 __attribute__((unused)) struct cmdline *cl,
5148 __attribute__((unused)) void *data)
5150 struct cmd_set_flush_rx *res = parsed_result;
5151 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5154 cmdline_parse_token_string_t cmd_setflushrx_set =
5155 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5157 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5158 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5159 flush_rx, "flush_rx");
5160 cmdline_parse_token_string_t cmd_setflushrx_mode =
5161 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5165 cmdline_parse_inst_t cmd_set_flush_rx = {
5166 .f = cmd_set_flush_rx_parsed,
5167 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5170 (void *)&cmd_setflushrx_set,
5171 (void *)&cmd_setflushrx_flush_rx,
5172 (void *)&cmd_setflushrx_mode,
5177 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5178 struct cmd_set_link_check {
5179 cmdline_fixed_string_t set;
5180 cmdline_fixed_string_t link_check;
5181 cmdline_fixed_string_t mode;
5185 cmd_set_link_check_parsed(void *parsed_result,
5186 __attribute__((unused)) struct cmdline *cl,
5187 __attribute__((unused)) void *data)
5189 struct cmd_set_link_check *res = parsed_result;
5190 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5193 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5194 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5196 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5197 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5198 link_check, "link_check");
5199 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5200 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5204 cmdline_parse_inst_t cmd_set_link_check = {
5205 .f = cmd_set_link_check_parsed,
5206 .help_str = "set link_check on|off: Enable/Disable link status check "
5207 "when starting/stopping a port",
5210 (void *)&cmd_setlinkcheck_set,
5211 (void *)&cmd_setlinkcheck_link_check,
5212 (void *)&cmd_setlinkcheck_mode,
5217 /* *** SET NIC BYPASS MODE *** */
5218 struct cmd_set_bypass_mode_result {
5219 cmdline_fixed_string_t set;
5220 cmdline_fixed_string_t bypass;
5221 cmdline_fixed_string_t mode;
5222 cmdline_fixed_string_t value;
5227 cmd_set_bypass_mode_parsed(void *parsed_result,
5228 __attribute__((unused)) struct cmdline *cl,
5229 __attribute__((unused)) void *data)
5231 struct cmd_set_bypass_mode_result *res = parsed_result;
5232 portid_t port_id = res->port_id;
5233 int32_t rc = -EINVAL;
5235 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5236 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5238 if (!strcmp(res->value, "bypass"))
5239 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5240 else if (!strcmp(res->value, "isolate"))
5241 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5243 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5245 /* Set the bypass mode for the relevant port. */
5246 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5249 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5252 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5253 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5255 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5256 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5258 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5259 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5261 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5262 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5263 value, "normal#bypass#isolate");
5264 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5265 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5268 cmdline_parse_inst_t cmd_set_bypass_mode = {
5269 .f = cmd_set_bypass_mode_parsed,
5270 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5271 "Set the NIC bypass mode for port_id",
5274 (void *)&cmd_setbypass_mode_set,
5275 (void *)&cmd_setbypass_mode_bypass,
5276 (void *)&cmd_setbypass_mode_mode,
5277 (void *)&cmd_setbypass_mode_value,
5278 (void *)&cmd_setbypass_mode_port,
5283 /* *** SET NIC BYPASS EVENT *** */
5284 struct cmd_set_bypass_event_result {
5285 cmdline_fixed_string_t set;
5286 cmdline_fixed_string_t bypass;
5287 cmdline_fixed_string_t event;
5288 cmdline_fixed_string_t event_value;
5289 cmdline_fixed_string_t mode;
5290 cmdline_fixed_string_t mode_value;
5295 cmd_set_bypass_event_parsed(void *parsed_result,
5296 __attribute__((unused)) struct cmdline *cl,
5297 __attribute__((unused)) void *data)
5299 int32_t rc = -EINVAL;
5300 struct cmd_set_bypass_event_result *res = parsed_result;
5301 portid_t port_id = res->port_id;
5303 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5304 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5305 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5307 if (!strcmp(res->event_value, "timeout"))
5308 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5309 else if (!strcmp(res->event_value, "os_on"))
5310 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5311 else if (!strcmp(res->event_value, "os_off"))
5312 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5313 else if (!strcmp(res->event_value, "power_on"))
5314 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5315 else if (!strcmp(res->event_value, "power_off"))
5316 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5318 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5320 if (!strcmp(res->mode_value, "bypass"))
5321 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5322 else if (!strcmp(res->mode_value, "isolate"))
5323 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5325 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5327 /* Set the watchdog timeout. */
5328 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5331 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5332 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5336 printf("Failed to set timeout value %u "
5337 "for port %d, errto code: %d.\n",
5338 bypass_timeout, port_id, rc);
5342 /* Set the bypass event to transition to bypass mode. */
5343 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5348 printf("\t Failed to set bypass event for port = %d.\n",
5352 cmdline_parse_token_string_t cmd_setbypass_event_set =
5353 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5355 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5356 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5358 cmdline_parse_token_string_t cmd_setbypass_event_event =
5359 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5361 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5362 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5363 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5364 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5365 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5367 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5368 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5369 mode_value, "normal#bypass#isolate");
5370 cmdline_parse_token_num_t cmd_setbypass_event_port =
5371 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5374 cmdline_parse_inst_t cmd_set_bypass_event = {
5375 .f = cmd_set_bypass_event_parsed,
5376 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5377 "power_off mode normal|bypass|isolate <port_id>: "
5378 "Set the NIC bypass event mode for port_id",
5381 (void *)&cmd_setbypass_event_set,
5382 (void *)&cmd_setbypass_event_bypass,
5383 (void *)&cmd_setbypass_event_event,
5384 (void *)&cmd_setbypass_event_event_value,
5385 (void *)&cmd_setbypass_event_mode,
5386 (void *)&cmd_setbypass_event_mode_value,
5387 (void *)&cmd_setbypass_event_port,
5393 /* *** SET NIC BYPASS TIMEOUT *** */
5394 struct cmd_set_bypass_timeout_result {
5395 cmdline_fixed_string_t set;
5396 cmdline_fixed_string_t bypass;
5397 cmdline_fixed_string_t timeout;
5398 cmdline_fixed_string_t value;
5402 cmd_set_bypass_timeout_parsed(void *parsed_result,
5403 __attribute__((unused)) struct cmdline *cl,
5404 __attribute__((unused)) void *data)
5406 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5408 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5409 if (!strcmp(res->value, "1.5"))
5410 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5411 else if (!strcmp(res->value, "2"))
5412 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5413 else if (!strcmp(res->value, "3"))
5414 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5415 else if (!strcmp(res->value, "4"))
5416 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5417 else if (!strcmp(res->value, "8"))
5418 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5419 else if (!strcmp(res->value, "16"))
5420 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5421 else if (!strcmp(res->value, "32"))
5422 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5424 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5428 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5429 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5431 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5432 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5434 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5435 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5436 timeout, "timeout");
5437 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5438 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5439 value, "0#1.5#2#3#4#8#16#32");
5441 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5442 .f = cmd_set_bypass_timeout_parsed,
5443 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5444 "Set the NIC bypass watchdog timeout in seconds",
5447 (void *)&cmd_setbypass_timeout_set,
5448 (void *)&cmd_setbypass_timeout_bypass,
5449 (void *)&cmd_setbypass_timeout_timeout,
5450 (void *)&cmd_setbypass_timeout_value,
5455 /* *** SHOW NIC BYPASS MODE *** */
5456 struct cmd_show_bypass_config_result {
5457 cmdline_fixed_string_t show;
5458 cmdline_fixed_string_t bypass;
5459 cmdline_fixed_string_t config;
5464 cmd_show_bypass_config_parsed(void *parsed_result,
5465 __attribute__((unused)) struct cmdline *cl,
5466 __attribute__((unused)) void *data)
5468 struct cmd_show_bypass_config_result *res = parsed_result;
5469 portid_t port_id = res->port_id;
5471 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5472 uint32_t event_mode;
5473 uint32_t bypass_mode;
5474 uint32_t timeout = bypass_timeout;
5477 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5478 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5479 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5480 {"UNKNOWN", "normal", "bypass", "isolate"};
5481 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5488 int num_events = (sizeof events) / (sizeof events[0]);
5490 /* Display the bypass mode.*/
5491 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5492 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5496 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5497 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5499 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5502 /* Display the bypass timeout.*/
5503 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5504 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5506 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5508 /* Display the bypass events and associated modes. */
5509 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5511 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5512 printf("\tFailed to get bypass mode for event = %s\n",
5515 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5516 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5518 printf("\tbypass event: %-16s = %s\n", events[i],
5524 printf("\tFailed to get bypass configuration for port = %d\n",
5528 cmdline_parse_token_string_t cmd_showbypass_config_show =
5529 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5531 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5532 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5534 cmdline_parse_token_string_t cmd_showbypass_config_config =
5535 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5537 cmdline_parse_token_num_t cmd_showbypass_config_port =
5538 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5541 cmdline_parse_inst_t cmd_show_bypass_config = {
5542 .f = cmd_show_bypass_config_parsed,
5543 .help_str = "show bypass config <port_id>: "
5544 "Show the NIC bypass config for port_id",
5547 (void *)&cmd_showbypass_config_show,
5548 (void *)&cmd_showbypass_config_bypass,
5549 (void *)&cmd_showbypass_config_config,
5550 (void *)&cmd_showbypass_config_port,
5555 #ifdef RTE_LIBRTE_PMD_BOND
5556 /* *** SET BONDING MODE *** */
5557 struct cmd_set_bonding_mode_result {
5558 cmdline_fixed_string_t set;
5559 cmdline_fixed_string_t bonding;
5560 cmdline_fixed_string_t mode;
5565 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5566 __attribute__((unused)) struct cmdline *cl,
5567 __attribute__((unused)) void *data)
5569 struct cmd_set_bonding_mode_result *res = parsed_result;
5570 portid_t port_id = res->port_id;
5572 /* Set the bonding mode for the relevant port. */
5573 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5574 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5577 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5578 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5580 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5581 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5582 bonding, "bonding");
5583 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5584 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5586 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5587 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5589 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5590 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5593 cmdline_parse_inst_t cmd_set_bonding_mode = {
5594 .f = cmd_set_bonding_mode_parsed,
5595 .help_str = "set bonding mode <mode_value> <port_id>: "
5596 "Set the bonding mode for port_id",
5599 (void *) &cmd_setbonding_mode_set,
5600 (void *) &cmd_setbonding_mode_bonding,
5601 (void *) &cmd_setbonding_mode_mode,
5602 (void *) &cmd_setbonding_mode_value,
5603 (void *) &cmd_setbonding_mode_port,
5608 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5609 struct cmd_set_bonding_lacp_dedicated_queues_result {
5610 cmdline_fixed_string_t set;
5611 cmdline_fixed_string_t bonding;
5612 cmdline_fixed_string_t lacp;
5613 cmdline_fixed_string_t dedicated_queues;
5615 cmdline_fixed_string_t mode;
5618 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5619 __attribute__((unused)) struct cmdline *cl,
5620 __attribute__((unused)) void *data)
5622 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5623 portid_t port_id = res->port_id;
5624 struct rte_port *port;
5626 port = &ports[port_id];
5628 /** Check if the port is not started **/
5629 if (port->port_status != RTE_PORT_STOPPED) {
5630 printf("Please stop port %d first\n", port_id);
5634 if (!strcmp(res->mode, "enable")) {
5635 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5636 printf("Dedicate queues for LACP control packets"
5639 printf("Enabling dedicate queues for LACP control "
5640 "packets on port %d failed\n", port_id);
5641 } else if (!strcmp(res->mode, "disable")) {
5642 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5643 printf("Dedicated queues for LACP control packets "
5646 printf("Disabling dedicated queues for LACP control "
5647 "traffic on port %d failed\n", port_id);
5651 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5652 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5654 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5655 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5656 bonding, "bonding");
5657 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5658 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5660 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5661 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5662 dedicated_queues, "dedicated_queues");
5663 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5664 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5666 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5667 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5668 mode, "enable#disable");
5670 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5671 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5672 .help_str = "set bonding lacp dedicated_queues <port_id> "
5674 "Enable/disable dedicated queues for LACP control traffic for port_id",
5677 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5678 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5679 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5680 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5681 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5682 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5687 /* *** SET BALANCE XMIT POLICY *** */
5688 struct cmd_set_bonding_balance_xmit_policy_result {
5689 cmdline_fixed_string_t set;
5690 cmdline_fixed_string_t bonding;
5691 cmdline_fixed_string_t balance_xmit_policy;
5693 cmdline_fixed_string_t policy;
5696 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5697 __attribute__((unused)) struct cmdline *cl,
5698 __attribute__((unused)) void *data)
5700 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5701 portid_t port_id = res->port_id;
5704 if (!strcmp(res->policy, "l2")) {
5705 policy = BALANCE_XMIT_POLICY_LAYER2;
5706 } else if (!strcmp(res->policy, "l23")) {
5707 policy = BALANCE_XMIT_POLICY_LAYER23;
5708 } else if (!strcmp(res->policy, "l34")) {
5709 policy = BALANCE_XMIT_POLICY_LAYER34;
5711 printf("\t Invalid xmit policy selection");
5715 /* Set the bonding mode for the relevant port. */
5716 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5717 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5722 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5723 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5725 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5726 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5727 bonding, "bonding");
5728 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5729 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5730 balance_xmit_policy, "balance_xmit_policy");
5731 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5732 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5734 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5735 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5736 policy, "l2#l23#l34");
5738 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5739 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5740 .help_str = "set bonding balance_xmit_policy <port_id> "
5742 "Set the bonding balance_xmit_policy for port_id",
5745 (void *)&cmd_setbonding_balance_xmit_policy_set,
5746 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5747 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5748 (void *)&cmd_setbonding_balance_xmit_policy_port,
5749 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5754 /* *** SHOW NIC BONDING CONFIGURATION *** */
5755 struct cmd_show_bonding_config_result {
5756 cmdline_fixed_string_t show;
5757 cmdline_fixed_string_t bonding;
5758 cmdline_fixed_string_t config;
5762 static void cmd_show_bonding_config_parsed(void *parsed_result,
5763 __attribute__((unused)) struct cmdline *cl,
5764 __attribute__((unused)) void *data)
5766 struct cmd_show_bonding_config_result *res = parsed_result;
5767 int bonding_mode, agg_mode;
5768 portid_t slaves[RTE_MAX_ETHPORTS];
5769 int num_slaves, num_active_slaves;
5772 portid_t port_id = res->port_id;
5774 /* Display the bonding mode.*/
5775 bonding_mode = rte_eth_bond_mode_get(port_id);
5776 if (bonding_mode < 0) {
5777 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5780 printf("\tBonding mode: %d\n", bonding_mode);
5782 if (bonding_mode == BONDING_MODE_BALANCE) {
5783 int balance_xmit_policy;
5785 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5786 if (balance_xmit_policy < 0) {
5787 printf("\tFailed to get balance xmit policy for port = %d\n",
5791 printf("\tBalance Xmit Policy: ");
5793 switch (balance_xmit_policy) {
5794 case BALANCE_XMIT_POLICY_LAYER2:
5795 printf("BALANCE_XMIT_POLICY_LAYER2");
5797 case BALANCE_XMIT_POLICY_LAYER23:
5798 printf("BALANCE_XMIT_POLICY_LAYER23");
5800 case BALANCE_XMIT_POLICY_LAYER34:
5801 printf("BALANCE_XMIT_POLICY_LAYER34");
5808 if (bonding_mode == BONDING_MODE_8023AD) {
5809 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5810 printf("\tIEEE802.3AD Aggregator Mode: ");
5813 printf("bandwidth");
5825 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5827 if (num_slaves < 0) {
5828 printf("\tFailed to get slave list for port = %d\n", port_id);
5831 if (num_slaves > 0) {
5832 printf("\tSlaves (%d): [", num_slaves);
5833 for (i = 0; i < num_slaves - 1; i++)
5834 printf("%d ", slaves[i]);
5836 printf("%d]\n", slaves[num_slaves - 1]);
5838 printf("\tSlaves: []\n");
5842 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5845 if (num_active_slaves < 0) {
5846 printf("\tFailed to get active slave list for port = %d\n", port_id);
5849 if (num_active_slaves > 0) {
5850 printf("\tActive Slaves (%d): [", num_active_slaves);
5851 for (i = 0; i < num_active_slaves - 1; i++)
5852 printf("%d ", slaves[i]);
5854 printf("%d]\n", slaves[num_active_slaves - 1]);
5857 printf("\tActive Slaves: []\n");
5861 primary_id = rte_eth_bond_primary_get(port_id);
5862 if (primary_id < 0) {
5863 printf("\tFailed to get primary slave for port = %d\n", port_id);
5866 printf("\tPrimary: [%d]\n", primary_id);
5870 cmdline_parse_token_string_t cmd_showbonding_config_show =
5871 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5873 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5874 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5875 bonding, "bonding");
5876 cmdline_parse_token_string_t cmd_showbonding_config_config =
5877 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5879 cmdline_parse_token_num_t cmd_showbonding_config_port =
5880 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5883 cmdline_parse_inst_t cmd_show_bonding_config = {
5884 .f = cmd_show_bonding_config_parsed,
5885 .help_str = "show bonding config <port_id>: "
5886 "Show the bonding config for port_id",
5889 (void *)&cmd_showbonding_config_show,
5890 (void *)&cmd_showbonding_config_bonding,
5891 (void *)&cmd_showbonding_config_config,
5892 (void *)&cmd_showbonding_config_port,
5897 /* *** SET BONDING PRIMARY *** */
5898 struct cmd_set_bonding_primary_result {
5899 cmdline_fixed_string_t set;
5900 cmdline_fixed_string_t bonding;
5901 cmdline_fixed_string_t primary;
5906 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5907 __attribute__((unused)) struct cmdline *cl,
5908 __attribute__((unused)) void *data)
5910 struct cmd_set_bonding_primary_result *res = parsed_result;
5911 portid_t master_port_id = res->port_id;
5912 portid_t slave_port_id = res->slave_id;
5914 /* Set the primary slave for a bonded device. */
5915 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5916 printf("\t Failed to set primary slave for port = %d.\n",
5923 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5924 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5926 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5927 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5928 bonding, "bonding");
5929 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5930 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5931 primary, "primary");
5932 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5933 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5935 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5936 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5939 cmdline_parse_inst_t cmd_set_bonding_primary = {
5940 .f = cmd_set_bonding_primary_parsed,
5941 .help_str = "set bonding primary <slave_id> <port_id>: "
5942 "Set the primary slave for port_id",
5945 (void *)&cmd_setbonding_primary_set,
5946 (void *)&cmd_setbonding_primary_bonding,
5947 (void *)&cmd_setbonding_primary_primary,
5948 (void *)&cmd_setbonding_primary_slave,
5949 (void *)&cmd_setbonding_primary_port,
5954 /* *** ADD SLAVE *** */
5955 struct cmd_add_bonding_slave_result {
5956 cmdline_fixed_string_t add;
5957 cmdline_fixed_string_t bonding;
5958 cmdline_fixed_string_t slave;
5963 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5964 __attribute__((unused)) struct cmdline *cl,
5965 __attribute__((unused)) void *data)
5967 struct cmd_add_bonding_slave_result *res = parsed_result;
5968 portid_t master_port_id = res->port_id;
5969 portid_t slave_port_id = res->slave_id;
5971 /* add the slave for a bonded device. */
5972 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5973 printf("\t Failed to add slave %d to master port = %d.\n",
5974 slave_port_id, master_port_id);
5978 set_port_slave_flag(slave_port_id);
5981 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5982 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5984 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5985 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5986 bonding, "bonding");
5987 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5988 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5990 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5991 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5993 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5994 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5997 cmdline_parse_inst_t cmd_add_bonding_slave = {
5998 .f = cmd_add_bonding_slave_parsed,
5999 .help_str = "add bonding slave <slave_id> <port_id>: "
6000 "Add a slave device to a bonded device",
6003 (void *)&cmd_addbonding_slave_add,
6004 (void *)&cmd_addbonding_slave_bonding,
6005 (void *)&cmd_addbonding_slave_slave,
6006 (void *)&cmd_addbonding_slave_slaveid,
6007 (void *)&cmd_addbonding_slave_port,
6012 /* *** REMOVE SLAVE *** */
6013 struct cmd_remove_bonding_slave_result {
6014 cmdline_fixed_string_t remove;
6015 cmdline_fixed_string_t bonding;
6016 cmdline_fixed_string_t slave;
6021 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6022 __attribute__((unused)) struct cmdline *cl,
6023 __attribute__((unused)) void *data)
6025 struct cmd_remove_bonding_slave_result *res = parsed_result;
6026 portid_t master_port_id = res->port_id;
6027 portid_t slave_port_id = res->slave_id;
6029 /* remove the slave from a bonded device. */
6030 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6031 printf("\t Failed to remove slave %d from master port = %d.\n",
6032 slave_port_id, master_port_id);
6036 clear_port_slave_flag(slave_port_id);
6039 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6040 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6042 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6043 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6044 bonding, "bonding");
6045 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6046 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6048 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6049 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6051 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6052 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6055 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6056 .f = cmd_remove_bonding_slave_parsed,
6057 .help_str = "remove bonding slave <slave_id> <port_id>: "
6058 "Remove a slave device from a bonded device",
6061 (void *)&cmd_removebonding_slave_remove,
6062 (void *)&cmd_removebonding_slave_bonding,
6063 (void *)&cmd_removebonding_slave_slave,
6064 (void *)&cmd_removebonding_slave_slaveid,
6065 (void *)&cmd_removebonding_slave_port,
6070 /* *** CREATE BONDED DEVICE *** */
6071 struct cmd_create_bonded_device_result {
6072 cmdline_fixed_string_t create;
6073 cmdline_fixed_string_t bonded;
6074 cmdline_fixed_string_t device;
6079 static int bond_dev_num = 0;
6081 static void cmd_create_bonded_device_parsed(void *parsed_result,
6082 __attribute__((unused)) struct cmdline *cl,
6083 __attribute__((unused)) void *data)
6085 struct cmd_create_bonded_device_result *res = parsed_result;
6086 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6089 if (test_done == 0) {
6090 printf("Please stop forwarding first\n");
6094 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6097 /* Create a new bonded device. */
6098 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6100 printf("\t Failed to create bonded device.\n");
6103 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6106 /* Update number of ports */
6107 nb_ports = rte_eth_dev_count_avail();
6108 reconfig(port_id, res->socket);
6109 rte_eth_promiscuous_enable(port_id);
6110 ports[port_id].need_setup = 0;
6111 ports[port_id].port_status = RTE_PORT_STOPPED;
6116 cmdline_parse_token_string_t cmd_createbonded_device_create =
6117 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6119 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6120 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6122 cmdline_parse_token_string_t cmd_createbonded_device_device =
6123 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6125 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6126 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6128 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6129 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6132 cmdline_parse_inst_t cmd_create_bonded_device = {
6133 .f = cmd_create_bonded_device_parsed,
6134 .help_str = "create bonded device <mode> <socket>: "
6135 "Create a new bonded device with specific bonding mode and socket",
6138 (void *)&cmd_createbonded_device_create,
6139 (void *)&cmd_createbonded_device_bonded,
6140 (void *)&cmd_createbonded_device_device,
6141 (void *)&cmd_createbonded_device_mode,
6142 (void *)&cmd_createbonded_device_socket,
6147 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6148 struct cmd_set_bond_mac_addr_result {
6149 cmdline_fixed_string_t set;
6150 cmdline_fixed_string_t bonding;
6151 cmdline_fixed_string_t mac_addr;
6153 struct rte_ether_addr address;
6156 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6157 __attribute__((unused)) struct cmdline *cl,
6158 __attribute__((unused)) void *data)
6160 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6163 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6166 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6168 /* check the return value and print it if is < 0 */
6170 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6173 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6174 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6175 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6176 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6178 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6179 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6181 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6182 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6184 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6185 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6187 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6188 .f = cmd_set_bond_mac_addr_parsed,
6190 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6192 (void *)&cmd_set_bond_mac_addr_set,
6193 (void *)&cmd_set_bond_mac_addr_bonding,
6194 (void *)&cmd_set_bond_mac_addr_mac,
6195 (void *)&cmd_set_bond_mac_addr_portnum,
6196 (void *)&cmd_set_bond_mac_addr_addr,
6202 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6203 struct cmd_set_bond_mon_period_result {
6204 cmdline_fixed_string_t set;
6205 cmdline_fixed_string_t bonding;
6206 cmdline_fixed_string_t mon_period;
6211 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6212 __attribute__((unused)) struct cmdline *cl,
6213 __attribute__((unused)) void *data)
6215 struct cmd_set_bond_mon_period_result *res = parsed_result;
6218 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6220 /* check the return value and print it if is < 0 */
6222 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6225 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6226 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6228 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6229 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6230 bonding, "bonding");
6231 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6232 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6233 mon_period, "mon_period");
6234 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6235 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6237 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6238 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6241 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6242 .f = cmd_set_bond_mon_period_parsed,
6244 .help_str = "set bonding mon_period <port_id> <period_ms>",
6246 (void *)&cmd_set_bond_mon_period_set,
6247 (void *)&cmd_set_bond_mon_period_bonding,
6248 (void *)&cmd_set_bond_mon_period_mon_period,
6249 (void *)&cmd_set_bond_mon_period_portnum,
6250 (void *)&cmd_set_bond_mon_period_period_ms,
6257 struct cmd_set_bonding_agg_mode_policy_result {
6258 cmdline_fixed_string_t set;
6259 cmdline_fixed_string_t bonding;
6260 cmdline_fixed_string_t agg_mode;
6262 cmdline_fixed_string_t policy;
6267 cmd_set_bonding_agg_mode(void *parsed_result,
6268 __attribute__((unused)) struct cmdline *cl,
6269 __attribute__((unused)) void *data)
6271 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6272 uint8_t policy = AGG_BANDWIDTH;
6274 if (!strcmp(res->policy, "bandwidth"))
6275 policy = AGG_BANDWIDTH;
6276 else if (!strcmp(res->policy, "stable"))
6277 policy = AGG_STABLE;
6278 else if (!strcmp(res->policy, "count"))
6281 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6285 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6286 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6288 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6289 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6290 bonding, "bonding");
6292 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6293 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6294 agg_mode, "agg_mode");
6296 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6297 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6300 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6301 TOKEN_STRING_INITIALIZER(
6302 struct cmd_set_bonding_balance_xmit_policy_result,
6303 policy, "stable#bandwidth#count");
6305 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6306 .f = cmd_set_bonding_agg_mode,
6308 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6310 (void *)&cmd_set_bonding_agg_mode_set,
6311 (void *)&cmd_set_bonding_agg_mode_bonding,
6312 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6313 (void *)&cmd_set_bonding_agg_mode_portnum,
6314 (void *)&cmd_set_bonding_agg_mode_policy_string,
6320 #endif /* RTE_LIBRTE_PMD_BOND */
6322 /* *** SET FORWARDING MODE *** */
6323 struct cmd_set_fwd_mode_result {
6324 cmdline_fixed_string_t set;
6325 cmdline_fixed_string_t fwd;
6326 cmdline_fixed_string_t mode;
6329 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6330 __attribute__((unused)) struct cmdline *cl,
6331 __attribute__((unused)) void *data)
6333 struct cmd_set_fwd_mode_result *res = parsed_result;
6336 set_pkt_forwarding_mode(res->mode);
6339 cmdline_parse_token_string_t cmd_setfwd_set =
6340 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6341 cmdline_parse_token_string_t cmd_setfwd_fwd =
6342 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6343 cmdline_parse_token_string_t cmd_setfwd_mode =
6344 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6345 "" /* defined at init */);
6347 cmdline_parse_inst_t cmd_set_fwd_mode = {
6348 .f = cmd_set_fwd_mode_parsed,
6350 .help_str = NULL, /* defined at init */
6352 (void *)&cmd_setfwd_set,
6353 (void *)&cmd_setfwd_fwd,
6354 (void *)&cmd_setfwd_mode,
6359 static void cmd_set_fwd_mode_init(void)
6362 static char token[128];
6363 static char help[256];
6364 cmdline_parse_token_string_t *token_struct;
6366 modes = list_pkt_forwarding_modes();
6367 snprintf(help, sizeof(help), "set fwd %s: "
6368 "Set packet forwarding mode", modes);
6369 cmd_set_fwd_mode.help_str = help;
6371 /* string token separator is # */
6372 for (c = token; *modes != '\0'; modes++)
6377 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6378 token_struct->string_data.str = token;
6381 /* *** SET RETRY FORWARDING MODE *** */
6382 struct cmd_set_fwd_retry_mode_result {
6383 cmdline_fixed_string_t set;
6384 cmdline_fixed_string_t fwd;
6385 cmdline_fixed_string_t mode;
6386 cmdline_fixed_string_t retry;
6389 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6390 __attribute__((unused)) struct cmdline *cl,
6391 __attribute__((unused)) void *data)
6393 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6396 set_pkt_forwarding_mode(res->mode);
6399 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6400 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6402 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6403 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6405 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6406 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6408 "" /* defined at init */);
6409 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6410 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6413 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6414 .f = cmd_set_fwd_retry_mode_parsed,
6416 .help_str = NULL, /* defined at init */
6418 (void *)&cmd_setfwd_retry_set,
6419 (void *)&cmd_setfwd_retry_fwd,
6420 (void *)&cmd_setfwd_retry_mode,
6421 (void *)&cmd_setfwd_retry_retry,
6426 static void cmd_set_fwd_retry_mode_init(void)
6429 static char token[128];
6430 static char help[256];
6431 cmdline_parse_token_string_t *token_struct;
6433 modes = list_pkt_forwarding_retry_modes();
6434 snprintf(help, sizeof(help), "set fwd %s retry: "
6435 "Set packet forwarding mode with retry", modes);
6436 cmd_set_fwd_retry_mode.help_str = help;
6438 /* string token separator is # */
6439 for (c = token; *modes != '\0'; modes++)
6444 token_struct = (cmdline_parse_token_string_t *)
6445 cmd_set_fwd_retry_mode.tokens[2];
6446 token_struct->string_data.str = token;
6449 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6450 struct cmd_set_burst_tx_retry_result {
6451 cmdline_fixed_string_t set;
6452 cmdline_fixed_string_t burst;
6453 cmdline_fixed_string_t tx;
6454 cmdline_fixed_string_t delay;
6456 cmdline_fixed_string_t retry;
6460 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6461 __attribute__((unused)) struct cmdline *cl,
6462 __attribute__((unused)) void *data)
6464 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6466 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6467 && !strcmp(res->tx, "tx")) {
6468 if (!strcmp(res->delay, "delay"))
6469 burst_tx_delay_time = res->time;
6470 if (!strcmp(res->retry, "retry"))
6471 burst_tx_retry_num = res->retry_num;
6476 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6477 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6478 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6479 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6481 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6482 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6483 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6484 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6485 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6486 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6487 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6488 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6489 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6490 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6492 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6493 .f = cmd_set_burst_tx_retry_parsed,
6494 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6496 (void *)&cmd_set_burst_tx_retry_set,
6497 (void *)&cmd_set_burst_tx_retry_burst,
6498 (void *)&cmd_set_burst_tx_retry_tx,
6499 (void *)&cmd_set_burst_tx_retry_delay,
6500 (void *)&cmd_set_burst_tx_retry_time,
6501 (void *)&cmd_set_burst_tx_retry_retry,
6502 (void *)&cmd_set_burst_tx_retry_retry_num,
6507 /* *** SET PROMISC MODE *** */
6508 struct cmd_set_promisc_mode_result {
6509 cmdline_fixed_string_t set;
6510 cmdline_fixed_string_t promisc;
6511 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6512 uint16_t port_num; /* valid if "allports" argument == 0 */
6513 cmdline_fixed_string_t mode;
6516 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6517 __attribute__((unused)) struct cmdline *cl,
6520 struct cmd_set_promisc_mode_result *res = parsed_result;
6524 if (!strcmp(res->mode, "on"))
6531 RTE_ETH_FOREACH_DEV(i) {
6533 rte_eth_promiscuous_enable(i);
6535 rte_eth_promiscuous_disable(i);
6540 rte_eth_promiscuous_enable(res->port_num);
6542 rte_eth_promiscuous_disable(res->port_num);
6546 cmdline_parse_token_string_t cmd_setpromisc_set =
6547 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6548 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6549 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6551 cmdline_parse_token_string_t cmd_setpromisc_portall =
6552 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6554 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6555 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6557 cmdline_parse_token_string_t cmd_setpromisc_mode =
6558 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6561 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6562 .f = cmd_set_promisc_mode_parsed,
6564 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6566 (void *)&cmd_setpromisc_set,
6567 (void *)&cmd_setpromisc_promisc,
6568 (void *)&cmd_setpromisc_portall,
6569 (void *)&cmd_setpromisc_mode,
6574 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6575 .f = cmd_set_promisc_mode_parsed,
6577 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6579 (void *)&cmd_setpromisc_set,
6580 (void *)&cmd_setpromisc_promisc,
6581 (void *)&cmd_setpromisc_portnum,
6582 (void *)&cmd_setpromisc_mode,
6587 /* *** SET ALLMULTI MODE *** */
6588 struct cmd_set_allmulti_mode_result {
6589 cmdline_fixed_string_t set;
6590 cmdline_fixed_string_t allmulti;
6591 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6592 uint16_t port_num; /* valid if "allports" argument == 0 */
6593 cmdline_fixed_string_t mode;
6596 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6597 __attribute__((unused)) struct cmdline *cl,
6600 struct cmd_set_allmulti_mode_result *res = parsed_result;
6604 if (!strcmp(res->mode, "on"))
6611 RTE_ETH_FOREACH_DEV(i) {
6613 rte_eth_allmulticast_enable(i);
6615 rte_eth_allmulticast_disable(i);
6620 rte_eth_allmulticast_enable(res->port_num);
6622 rte_eth_allmulticast_disable(res->port_num);
6626 cmdline_parse_token_string_t cmd_setallmulti_set =
6627 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6628 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6629 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6631 cmdline_parse_token_string_t cmd_setallmulti_portall =
6632 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6634 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6635 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6637 cmdline_parse_token_string_t cmd_setallmulti_mode =
6638 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6641 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6642 .f = cmd_set_allmulti_mode_parsed,
6644 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6646 (void *)&cmd_setallmulti_set,
6647 (void *)&cmd_setallmulti_allmulti,
6648 (void *)&cmd_setallmulti_portall,
6649 (void *)&cmd_setallmulti_mode,
6654 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6655 .f = cmd_set_allmulti_mode_parsed,
6657 .help_str = "set allmulti <port_id> on|off: "
6658 "Set allmulti mode on port_id",
6660 (void *)&cmd_setallmulti_set,
6661 (void *)&cmd_setallmulti_allmulti,
6662 (void *)&cmd_setallmulti_portnum,
6663 (void *)&cmd_setallmulti_mode,
6668 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6669 struct cmd_link_flow_ctrl_set_result {
6670 cmdline_fixed_string_t set;
6671 cmdline_fixed_string_t flow_ctrl;
6672 cmdline_fixed_string_t rx;
6673 cmdline_fixed_string_t rx_lfc_mode;
6674 cmdline_fixed_string_t tx;
6675 cmdline_fixed_string_t tx_lfc_mode;
6676 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6677 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6678 cmdline_fixed_string_t autoneg_str;
6679 cmdline_fixed_string_t autoneg;
6680 cmdline_fixed_string_t hw_str;
6681 uint32_t high_water;
6682 cmdline_fixed_string_t lw_str;
6684 cmdline_fixed_string_t pt_str;
6685 uint16_t pause_time;
6686 cmdline_fixed_string_t xon_str;
6691 cmdline_parse_token_string_t cmd_lfc_set_set =
6692 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6694 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6695 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6696 flow_ctrl, "flow_ctrl");
6697 cmdline_parse_token_string_t cmd_lfc_set_rx =
6698 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6700 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6701 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6702 rx_lfc_mode, "on#off");
6703 cmdline_parse_token_string_t cmd_lfc_set_tx =
6704 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6706 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6707 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6708 tx_lfc_mode, "on#off");
6709 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6710 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6711 hw_str, "high_water");
6712 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6713 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6714 high_water, UINT32);
6715 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6716 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6717 lw_str, "low_water");
6718 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6719 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6721 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6722 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6723 pt_str, "pause_time");
6724 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6725 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6726 pause_time, UINT16);
6727 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6728 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6729 xon_str, "send_xon");
6730 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6731 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6733 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6734 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6735 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6736 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6737 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6738 mac_ctrl_frame_fwd_mode, "on#off");
6739 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6740 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6741 autoneg_str, "autoneg");
6742 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6743 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6745 cmdline_parse_token_num_t cmd_lfc_set_portid =
6746 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6749 /* forward declaration */
6751 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6754 cmdline_parse_inst_t cmd_link_flow_control_set = {
6755 .f = cmd_link_flow_ctrl_set_parsed,
6757 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6758 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6759 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6761 (void *)&cmd_lfc_set_set,
6762 (void *)&cmd_lfc_set_flow_ctrl,
6763 (void *)&cmd_lfc_set_rx,
6764 (void *)&cmd_lfc_set_rx_mode,
6765 (void *)&cmd_lfc_set_tx,
6766 (void *)&cmd_lfc_set_tx_mode,
6767 (void *)&cmd_lfc_set_high_water,
6768 (void *)&cmd_lfc_set_low_water,
6769 (void *)&cmd_lfc_set_pause_time,
6770 (void *)&cmd_lfc_set_send_xon,
6771 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6772 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6773 (void *)&cmd_lfc_set_autoneg_str,
6774 (void *)&cmd_lfc_set_autoneg,
6775 (void *)&cmd_lfc_set_portid,
6780 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6781 .f = cmd_link_flow_ctrl_set_parsed,
6782 .data = (void *)&cmd_link_flow_control_set_rx,
6783 .help_str = "set flow_ctrl rx on|off <port_id>: "
6784 "Change rx flow control parameter",
6786 (void *)&cmd_lfc_set_set,
6787 (void *)&cmd_lfc_set_flow_ctrl,
6788 (void *)&cmd_lfc_set_rx,
6789 (void *)&cmd_lfc_set_rx_mode,
6790 (void *)&cmd_lfc_set_portid,
6795 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6796 .f = cmd_link_flow_ctrl_set_parsed,
6797 .data = (void *)&cmd_link_flow_control_set_tx,
6798 .help_str = "set flow_ctrl tx on|off <port_id>: "
6799 "Change tx flow control parameter",
6801 (void *)&cmd_lfc_set_set,
6802 (void *)&cmd_lfc_set_flow_ctrl,
6803 (void *)&cmd_lfc_set_tx,
6804 (void *)&cmd_lfc_set_tx_mode,
6805 (void *)&cmd_lfc_set_portid,
6810 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6811 .f = cmd_link_flow_ctrl_set_parsed,
6812 .data = (void *)&cmd_link_flow_control_set_hw,
6813 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6814 "Change high water flow control parameter",
6816 (void *)&cmd_lfc_set_set,
6817 (void *)&cmd_lfc_set_flow_ctrl,
6818 (void *)&cmd_lfc_set_high_water_str,
6819 (void *)&cmd_lfc_set_high_water,
6820 (void *)&cmd_lfc_set_portid,
6825 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6826 .f = cmd_link_flow_ctrl_set_parsed,
6827 .data = (void *)&cmd_link_flow_control_set_lw,
6828 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6829 "Change low water flow control parameter",
6831 (void *)&cmd_lfc_set_set,
6832 (void *)&cmd_lfc_set_flow_ctrl,
6833 (void *)&cmd_lfc_set_low_water_str,
6834 (void *)&cmd_lfc_set_low_water,
6835 (void *)&cmd_lfc_set_portid,
6840 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6841 .f = cmd_link_flow_ctrl_set_parsed,
6842 .data = (void *)&cmd_link_flow_control_set_pt,
6843 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6844 "Change pause time flow control parameter",
6846 (void *)&cmd_lfc_set_set,
6847 (void *)&cmd_lfc_set_flow_ctrl,
6848 (void *)&cmd_lfc_set_pause_time_str,
6849 (void *)&cmd_lfc_set_pause_time,
6850 (void *)&cmd_lfc_set_portid,
6855 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6856 .f = cmd_link_flow_ctrl_set_parsed,
6857 .data = (void *)&cmd_link_flow_control_set_xon,
6858 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6859 "Change send_xon flow control parameter",
6861 (void *)&cmd_lfc_set_set,
6862 (void *)&cmd_lfc_set_flow_ctrl,
6863 (void *)&cmd_lfc_set_send_xon_str,
6864 (void *)&cmd_lfc_set_send_xon,
6865 (void *)&cmd_lfc_set_portid,
6870 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6871 .f = cmd_link_flow_ctrl_set_parsed,
6872 .data = (void *)&cmd_link_flow_control_set_macfwd,
6873 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6874 "Change mac ctrl fwd flow control parameter",
6876 (void *)&cmd_lfc_set_set,
6877 (void *)&cmd_lfc_set_flow_ctrl,
6878 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6879 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6880 (void *)&cmd_lfc_set_portid,
6885 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6886 .f = cmd_link_flow_ctrl_set_parsed,
6887 .data = (void *)&cmd_link_flow_control_set_autoneg,
6888 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6889 "Change autoneg flow control parameter",
6891 (void *)&cmd_lfc_set_set,
6892 (void *)&cmd_lfc_set_flow_ctrl,
6893 (void *)&cmd_lfc_set_autoneg_str,
6894 (void *)&cmd_lfc_set_autoneg,
6895 (void *)&cmd_lfc_set_portid,
6901 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6902 __attribute__((unused)) struct cmdline *cl,
6905 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6906 cmdline_parse_inst_t *cmd = data;
6907 struct rte_eth_fc_conf fc_conf;
6913 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6914 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6915 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6916 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6918 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6919 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6922 /* Partial command line, retrieve current configuration */
6924 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6926 printf("cannot get current flow ctrl parameters, return"
6927 "code = %d\n", ret);
6931 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6932 (fc_conf.mode == RTE_FC_FULL))
6934 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6935 (fc_conf.mode == RTE_FC_FULL))
6939 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6940 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6942 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6943 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6945 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6947 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6948 fc_conf.high_water = res->high_water;
6950 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6951 fc_conf.low_water = res->low_water;
6953 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6954 fc_conf.pause_time = res->pause_time;
6956 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6957 fc_conf.send_xon = res->send_xon;
6959 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6960 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6961 fc_conf.mac_ctrl_frame_fwd = 1;
6963 fc_conf.mac_ctrl_frame_fwd = 0;
6966 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6967 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6969 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6971 printf("bad flow contrl parameter, return code = %d \n", ret);
6974 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6975 struct cmd_priority_flow_ctrl_set_result {
6976 cmdline_fixed_string_t set;
6977 cmdline_fixed_string_t pfc_ctrl;
6978 cmdline_fixed_string_t rx;
6979 cmdline_fixed_string_t rx_pfc_mode;
6980 cmdline_fixed_string_t tx;
6981 cmdline_fixed_string_t tx_pfc_mode;
6982 uint32_t high_water;
6984 uint16_t pause_time;
6990 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6991 __attribute__((unused)) struct cmdline *cl,
6992 __attribute__((unused)) void *data)
6994 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6995 struct rte_eth_pfc_conf pfc_conf;
6996 int rx_fc_enable, tx_fc_enable;
7000 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7001 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7002 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7003 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7005 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7006 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
7009 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7010 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7011 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7012 pfc_conf.fc.high_water = res->high_water;
7013 pfc_conf.fc.low_water = res->low_water;
7014 pfc_conf.fc.pause_time = res->pause_time;
7015 pfc_conf.priority = res->priority;
7017 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7019 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7022 cmdline_parse_token_string_t cmd_pfc_set_set =
7023 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7025 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7026 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7027 pfc_ctrl, "pfc_ctrl");
7028 cmdline_parse_token_string_t cmd_pfc_set_rx =
7029 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7031 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7032 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7033 rx_pfc_mode, "on#off");
7034 cmdline_parse_token_string_t cmd_pfc_set_tx =
7035 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7037 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7038 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7039 tx_pfc_mode, "on#off");
7040 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7041 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7042 high_water, UINT32);
7043 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7044 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7046 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7047 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7048 pause_time, UINT16);
7049 cmdline_parse_token_num_t cmd_pfc_set_priority =
7050 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7052 cmdline_parse_token_num_t cmd_pfc_set_portid =
7053 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7056 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7057 .f = cmd_priority_flow_ctrl_set_parsed,
7059 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7060 "<pause_time> <priority> <port_id>: "
7061 "Configure the Ethernet priority flow control",
7063 (void *)&cmd_pfc_set_set,
7064 (void *)&cmd_pfc_set_flow_ctrl,
7065 (void *)&cmd_pfc_set_rx,
7066 (void *)&cmd_pfc_set_rx_mode,
7067 (void *)&cmd_pfc_set_tx,
7068 (void *)&cmd_pfc_set_tx_mode,
7069 (void *)&cmd_pfc_set_high_water,
7070 (void *)&cmd_pfc_set_low_water,
7071 (void *)&cmd_pfc_set_pause_time,
7072 (void *)&cmd_pfc_set_priority,
7073 (void *)&cmd_pfc_set_portid,
7078 /* *** RESET CONFIGURATION *** */
7079 struct cmd_reset_result {
7080 cmdline_fixed_string_t reset;
7081 cmdline_fixed_string_t def;
7084 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
7086 __attribute__((unused)) void *data)
7088 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7089 set_def_fwd_config();
7092 cmdline_parse_token_string_t cmd_reset_set =
7093 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7094 cmdline_parse_token_string_t cmd_reset_def =
7095 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7098 cmdline_parse_inst_t cmd_reset = {
7099 .f = cmd_reset_parsed,
7101 .help_str = "set default: Reset default forwarding configuration",
7103 (void *)&cmd_reset_set,
7104 (void *)&cmd_reset_def,
7109 /* *** START FORWARDING *** */
7110 struct cmd_start_result {
7111 cmdline_fixed_string_t start;
7114 cmdline_parse_token_string_t cmd_start_start =
7115 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7117 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
7118 __attribute__((unused)) struct cmdline *cl,
7119 __attribute__((unused)) void *data)
7121 start_packet_forwarding(0);
7124 cmdline_parse_inst_t cmd_start = {
7125 .f = cmd_start_parsed,
7127 .help_str = "start: Start packet forwarding",
7129 (void *)&cmd_start_start,
7134 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7135 struct cmd_start_tx_first_result {
7136 cmdline_fixed_string_t start;
7137 cmdline_fixed_string_t tx_first;
7141 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
7142 __attribute__((unused)) struct cmdline *cl,
7143 __attribute__((unused)) void *data)
7145 start_packet_forwarding(1);
7148 cmdline_parse_token_string_t cmd_start_tx_first_start =
7149 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7151 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7152 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7153 tx_first, "tx_first");
7155 cmdline_parse_inst_t cmd_start_tx_first = {
7156 .f = cmd_start_tx_first_parsed,
7158 .help_str = "start tx_first: Start packet forwarding, "
7159 "after sending 1 burst of packets",
7161 (void *)&cmd_start_tx_first_start,
7162 (void *)&cmd_start_tx_first_tx_first,
7167 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7168 struct cmd_start_tx_first_n_result {
7169 cmdline_fixed_string_t start;
7170 cmdline_fixed_string_t tx_first;
7175 cmd_start_tx_first_n_parsed(void *parsed_result,
7176 __attribute__((unused)) struct cmdline *cl,
7177 __attribute__((unused)) void *data)
7179 struct cmd_start_tx_first_n_result *res = parsed_result;
7181 start_packet_forwarding(res->tx_num);
7184 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7185 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7187 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7188 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7189 tx_first, "tx_first");
7190 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7191 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7194 cmdline_parse_inst_t cmd_start_tx_first_n = {
7195 .f = cmd_start_tx_first_n_parsed,
7197 .help_str = "start tx_first <num>: "
7198 "packet forwarding, after sending <num> bursts of packets",
7200 (void *)&cmd_start_tx_first_n_start,
7201 (void *)&cmd_start_tx_first_n_tx_first,
7202 (void *)&cmd_start_tx_first_n_tx_num,
7207 /* *** SET LINK UP *** */
7208 struct cmd_set_link_up_result {
7209 cmdline_fixed_string_t set;
7210 cmdline_fixed_string_t link_up;
7211 cmdline_fixed_string_t port;
7215 cmdline_parse_token_string_t cmd_set_link_up_set =
7216 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7217 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7218 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7220 cmdline_parse_token_string_t cmd_set_link_up_port =
7221 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7222 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7223 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7225 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
7226 __attribute__((unused)) struct cmdline *cl,
7227 __attribute__((unused)) void *data)
7229 struct cmd_set_link_up_result *res = parsed_result;
7230 dev_set_link_up(res->port_id);
7233 cmdline_parse_inst_t cmd_set_link_up = {
7234 .f = cmd_set_link_up_parsed,
7236 .help_str = "set link-up port <port id>",
7238 (void *)&cmd_set_link_up_set,
7239 (void *)&cmd_set_link_up_link_up,
7240 (void *)&cmd_set_link_up_port,
7241 (void *)&cmd_set_link_up_port_id,
7246 /* *** SET LINK DOWN *** */
7247 struct cmd_set_link_down_result {
7248 cmdline_fixed_string_t set;
7249 cmdline_fixed_string_t link_down;
7250 cmdline_fixed_string_t port;
7254 cmdline_parse_token_string_t cmd_set_link_down_set =
7255 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7256 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7257 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7259 cmdline_parse_token_string_t cmd_set_link_down_port =
7260 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7261 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7262 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7264 static void cmd_set_link_down_parsed(
7265 __attribute__((unused)) void *parsed_result,
7266 __attribute__((unused)) struct cmdline *cl,
7267 __attribute__((unused)) void *data)
7269 struct cmd_set_link_down_result *res = parsed_result;
7270 dev_set_link_down(res->port_id);
7273 cmdline_parse_inst_t cmd_set_link_down = {
7274 .f = cmd_set_link_down_parsed,
7276 .help_str = "set link-down port <port id>",
7278 (void *)&cmd_set_link_down_set,
7279 (void *)&cmd_set_link_down_link_down,
7280 (void *)&cmd_set_link_down_port,
7281 (void *)&cmd_set_link_down_port_id,
7286 /* *** SHOW CFG *** */
7287 struct cmd_showcfg_result {
7288 cmdline_fixed_string_t show;
7289 cmdline_fixed_string_t cfg;
7290 cmdline_fixed_string_t what;
7293 static void cmd_showcfg_parsed(void *parsed_result,
7294 __attribute__((unused)) struct cmdline *cl,
7295 __attribute__((unused)) void *data)
7297 struct cmd_showcfg_result *res = parsed_result;
7298 if (!strcmp(res->what, "rxtx"))
7299 rxtx_config_display();
7300 else if (!strcmp(res->what, "cores"))
7301 fwd_lcores_config_display();
7302 else if (!strcmp(res->what, "fwd"))
7303 pkt_fwd_config_display(&cur_fwd_config);
7304 else if (!strcmp(res->what, "txpkts"))
7305 show_tx_pkt_segments();
7308 cmdline_parse_token_string_t cmd_showcfg_show =
7309 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7310 cmdline_parse_token_string_t cmd_showcfg_port =
7311 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7312 cmdline_parse_token_string_t cmd_showcfg_what =
7313 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7314 "rxtx#cores#fwd#txpkts");
7316 cmdline_parse_inst_t cmd_showcfg = {
7317 .f = cmd_showcfg_parsed,
7319 .help_str = "show config rxtx|cores|fwd|txpkts",
7321 (void *)&cmd_showcfg_show,
7322 (void *)&cmd_showcfg_port,
7323 (void *)&cmd_showcfg_what,
7328 /* *** SHOW ALL PORT INFO *** */
7329 struct cmd_showportall_result {
7330 cmdline_fixed_string_t show;
7331 cmdline_fixed_string_t port;
7332 cmdline_fixed_string_t what;
7333 cmdline_fixed_string_t all;
7336 static void cmd_showportall_parsed(void *parsed_result,
7337 __attribute__((unused)) struct cmdline *cl,
7338 __attribute__((unused)) void *data)
7342 struct cmd_showportall_result *res = parsed_result;
7343 if (!strcmp(res->show, "clear")) {
7344 if (!strcmp(res->what, "stats"))
7345 RTE_ETH_FOREACH_DEV(i)
7347 else if (!strcmp(res->what, "xstats"))
7348 RTE_ETH_FOREACH_DEV(i)
7349 nic_xstats_clear(i);
7350 } else if (!strcmp(res->what, "info"))
7351 RTE_ETH_FOREACH_DEV(i)
7352 port_infos_display(i);
7353 else if (!strcmp(res->what, "summary")) {
7354 port_summary_header_display();
7355 RTE_ETH_FOREACH_DEV(i)
7356 port_summary_display(i);
7358 else if (!strcmp(res->what, "stats"))
7359 RTE_ETH_FOREACH_DEV(i)
7360 nic_stats_display(i);
7361 else if (!strcmp(res->what, "xstats"))
7362 RTE_ETH_FOREACH_DEV(i)
7363 nic_xstats_display(i);
7364 else if (!strcmp(res->what, "fdir"))
7365 RTE_ETH_FOREACH_DEV(i)
7367 else if (!strcmp(res->what, "stat_qmap"))
7368 RTE_ETH_FOREACH_DEV(i)
7369 nic_stats_mapping_display(i);
7370 else if (!strcmp(res->what, "dcb_tc"))
7371 RTE_ETH_FOREACH_DEV(i)
7372 port_dcb_info_display(i);
7373 else if (!strcmp(res->what, "cap"))
7374 RTE_ETH_FOREACH_DEV(i)
7375 port_offload_cap_display(i);
7378 cmdline_parse_token_string_t cmd_showportall_show =
7379 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7381 cmdline_parse_token_string_t cmd_showportall_port =
7382 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7383 cmdline_parse_token_string_t cmd_showportall_what =
7384 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7385 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7386 cmdline_parse_token_string_t cmd_showportall_all =
7387 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7388 cmdline_parse_inst_t cmd_showportall = {
7389 .f = cmd_showportall_parsed,
7391 .help_str = "show|clear port "
7392 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7394 (void *)&cmd_showportall_show,
7395 (void *)&cmd_showportall_port,
7396 (void *)&cmd_showportall_what,
7397 (void *)&cmd_showportall_all,
7402 /* *** SHOW PORT INFO *** */
7403 struct cmd_showport_result {
7404 cmdline_fixed_string_t show;
7405 cmdline_fixed_string_t port;
7406 cmdline_fixed_string_t what;
7410 static void cmd_showport_parsed(void *parsed_result,
7411 __attribute__((unused)) struct cmdline *cl,
7412 __attribute__((unused)) void *data)
7414 struct cmd_showport_result *res = parsed_result;
7415 if (!strcmp(res->show, "clear")) {
7416 if (!strcmp(res->what, "stats"))
7417 nic_stats_clear(res->portnum);
7418 else if (!strcmp(res->what, "xstats"))
7419 nic_xstats_clear(res->portnum);
7420 } else if (!strcmp(res->what, "info"))
7421 port_infos_display(res->portnum);
7422 else if (!strcmp(res->what, "summary")) {
7423 port_summary_header_display();
7424 port_summary_display(res->portnum);
7426 else if (!strcmp(res->what, "stats"))
7427 nic_stats_display(res->portnum);
7428 else if (!strcmp(res->what, "xstats"))
7429 nic_xstats_display(res->portnum);
7430 else if (!strcmp(res->what, "fdir"))
7431 fdir_get_infos(res->portnum);
7432 else if (!strcmp(res->what, "stat_qmap"))
7433 nic_stats_mapping_display(res->portnum);
7434 else if (!strcmp(res->what, "dcb_tc"))
7435 port_dcb_info_display(res->portnum);
7436 else if (!strcmp(res->what, "cap"))
7437 port_offload_cap_display(res->portnum);
7440 cmdline_parse_token_string_t cmd_showport_show =
7441 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7443 cmdline_parse_token_string_t cmd_showport_port =
7444 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7445 cmdline_parse_token_string_t cmd_showport_what =
7446 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7447 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7448 cmdline_parse_token_num_t cmd_showport_portnum =
7449 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7451 cmdline_parse_inst_t cmd_showport = {
7452 .f = cmd_showport_parsed,
7454 .help_str = "show|clear port "
7455 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7458 (void *)&cmd_showport_show,
7459 (void *)&cmd_showport_port,
7460 (void *)&cmd_showport_what,
7461 (void *)&cmd_showport_portnum,
7466 /* *** SHOW QUEUE INFO *** */
7467 struct cmd_showqueue_result {
7468 cmdline_fixed_string_t show;
7469 cmdline_fixed_string_t type;
7470 cmdline_fixed_string_t what;
7476 cmd_showqueue_parsed(void *parsed_result,
7477 __attribute__((unused)) struct cmdline *cl,
7478 __attribute__((unused)) void *data)
7480 struct cmd_showqueue_result *res = parsed_result;
7482 if (!strcmp(res->type, "rxq"))
7483 rx_queue_infos_display(res->portnum, res->queuenum);
7484 else if (!strcmp(res->type, "txq"))
7485 tx_queue_infos_display(res->portnum, res->queuenum);
7488 cmdline_parse_token_string_t cmd_showqueue_show =
7489 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7490 cmdline_parse_token_string_t cmd_showqueue_type =
7491 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7492 cmdline_parse_token_string_t cmd_showqueue_what =
7493 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7494 cmdline_parse_token_num_t cmd_showqueue_portnum =
7495 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7496 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7497 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7499 cmdline_parse_inst_t cmd_showqueue = {
7500 .f = cmd_showqueue_parsed,
7502 .help_str = "show rxq|txq info <port_id> <queue_id>",
7504 (void *)&cmd_showqueue_show,
7505 (void *)&cmd_showqueue_type,
7506 (void *)&cmd_showqueue_what,
7507 (void *)&cmd_showqueue_portnum,
7508 (void *)&cmd_showqueue_queuenum,
7513 /* show/clear fwd engine statistics */
7515 cmdline_fixed_string_t action;
7516 cmdline_fixed_string_t fwd;
7517 cmdline_fixed_string_t stats;
7518 cmdline_fixed_string_t all;
7521 cmdline_parse_token_string_t cmd_fwd_action =
7522 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7523 cmdline_parse_token_string_t cmd_fwd_fwd =
7524 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7525 cmdline_parse_token_string_t cmd_fwd_stats =
7526 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7527 cmdline_parse_token_string_t cmd_fwd_all =
7528 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7531 cmd_showfwdall_parsed(void *parsed_result,
7532 __rte_unused struct cmdline *cl,
7533 __rte_unused void *data)
7535 struct fwd_result *res = parsed_result;
7537 if (!strcmp(res->action, "show"))
7538 fwd_stats_display();
7543 static cmdline_parse_inst_t cmd_showfwdall = {
7544 .f = cmd_showfwdall_parsed,
7546 .help_str = "show|clear fwd stats all",
7548 (void *)&cmd_fwd_action,
7549 (void *)&cmd_fwd_fwd,
7550 (void *)&cmd_fwd_stats,
7551 (void *)&cmd_fwd_all,
7556 /* *** READ PORT REGISTER *** */
7557 struct cmd_read_reg_result {
7558 cmdline_fixed_string_t read;
7559 cmdline_fixed_string_t reg;
7565 cmd_read_reg_parsed(void *parsed_result,
7566 __attribute__((unused)) struct cmdline *cl,
7567 __attribute__((unused)) void *data)
7569 struct cmd_read_reg_result *res = parsed_result;
7570 port_reg_display(res->port_id, res->reg_off);
7573 cmdline_parse_token_string_t cmd_read_reg_read =
7574 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7575 cmdline_parse_token_string_t cmd_read_reg_reg =
7576 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7577 cmdline_parse_token_num_t cmd_read_reg_port_id =
7578 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7579 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7580 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7582 cmdline_parse_inst_t cmd_read_reg = {
7583 .f = cmd_read_reg_parsed,
7585 .help_str = "read reg <port_id> <reg_off>",
7587 (void *)&cmd_read_reg_read,
7588 (void *)&cmd_read_reg_reg,
7589 (void *)&cmd_read_reg_port_id,
7590 (void *)&cmd_read_reg_reg_off,
7595 /* *** READ PORT REGISTER BIT FIELD *** */
7596 struct cmd_read_reg_bit_field_result {
7597 cmdline_fixed_string_t read;
7598 cmdline_fixed_string_t regfield;
7606 cmd_read_reg_bit_field_parsed(void *parsed_result,
7607 __attribute__((unused)) struct cmdline *cl,
7608 __attribute__((unused)) void *data)
7610 struct cmd_read_reg_bit_field_result *res = parsed_result;
7611 port_reg_bit_field_display(res->port_id, res->reg_off,
7612 res->bit1_pos, res->bit2_pos);
7615 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7616 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7618 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7619 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7620 regfield, "regfield");
7621 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7622 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7624 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7625 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7627 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7628 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7630 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7631 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7634 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7635 .f = cmd_read_reg_bit_field_parsed,
7637 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7638 "Read register bit field between bit_x and bit_y included",
7640 (void *)&cmd_read_reg_bit_field_read,
7641 (void *)&cmd_read_reg_bit_field_regfield,
7642 (void *)&cmd_read_reg_bit_field_port_id,
7643 (void *)&cmd_read_reg_bit_field_reg_off,
7644 (void *)&cmd_read_reg_bit_field_bit1_pos,
7645 (void *)&cmd_read_reg_bit_field_bit2_pos,
7650 /* *** READ PORT REGISTER BIT *** */
7651 struct cmd_read_reg_bit_result {
7652 cmdline_fixed_string_t read;
7653 cmdline_fixed_string_t regbit;
7660 cmd_read_reg_bit_parsed(void *parsed_result,
7661 __attribute__((unused)) struct cmdline *cl,
7662 __attribute__((unused)) void *data)
7664 struct cmd_read_reg_bit_result *res = parsed_result;
7665 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7668 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7669 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7670 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7671 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7673 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7674 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7675 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7676 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7677 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7678 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7680 cmdline_parse_inst_t cmd_read_reg_bit = {
7681 .f = cmd_read_reg_bit_parsed,
7683 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7685 (void *)&cmd_read_reg_bit_read,
7686 (void *)&cmd_read_reg_bit_regbit,
7687 (void *)&cmd_read_reg_bit_port_id,
7688 (void *)&cmd_read_reg_bit_reg_off,
7689 (void *)&cmd_read_reg_bit_bit_pos,
7694 /* *** WRITE PORT REGISTER *** */
7695 struct cmd_write_reg_result {
7696 cmdline_fixed_string_t write;
7697 cmdline_fixed_string_t reg;
7704 cmd_write_reg_parsed(void *parsed_result,
7705 __attribute__((unused)) struct cmdline *cl,
7706 __attribute__((unused)) void *data)
7708 struct cmd_write_reg_result *res = parsed_result;
7709 port_reg_set(res->port_id, res->reg_off, res->value);
7712 cmdline_parse_token_string_t cmd_write_reg_write =
7713 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7714 cmdline_parse_token_string_t cmd_write_reg_reg =
7715 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7716 cmdline_parse_token_num_t cmd_write_reg_port_id =
7717 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7718 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7719 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7720 cmdline_parse_token_num_t cmd_write_reg_value =
7721 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7723 cmdline_parse_inst_t cmd_write_reg = {
7724 .f = cmd_write_reg_parsed,
7726 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7728 (void *)&cmd_write_reg_write,
7729 (void *)&cmd_write_reg_reg,
7730 (void *)&cmd_write_reg_port_id,
7731 (void *)&cmd_write_reg_reg_off,
7732 (void *)&cmd_write_reg_value,
7737 /* *** WRITE PORT REGISTER BIT FIELD *** */
7738 struct cmd_write_reg_bit_field_result {
7739 cmdline_fixed_string_t write;
7740 cmdline_fixed_string_t regfield;
7749 cmd_write_reg_bit_field_parsed(void *parsed_result,
7750 __attribute__((unused)) struct cmdline *cl,
7751 __attribute__((unused)) void *data)
7753 struct cmd_write_reg_bit_field_result *res = parsed_result;
7754 port_reg_bit_field_set(res->port_id, res->reg_off,
7755 res->bit1_pos, res->bit2_pos, res->value);
7758 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7759 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7761 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7762 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7763 regfield, "regfield");
7764 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7765 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7767 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7768 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7770 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7771 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7773 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7774 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7776 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7777 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7780 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7781 .f = cmd_write_reg_bit_field_parsed,
7783 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7785 "Set register bit field between bit_x and bit_y included",
7787 (void *)&cmd_write_reg_bit_field_write,
7788 (void *)&cmd_write_reg_bit_field_regfield,
7789 (void *)&cmd_write_reg_bit_field_port_id,
7790 (void *)&cmd_write_reg_bit_field_reg_off,
7791 (void *)&cmd_write_reg_bit_field_bit1_pos,
7792 (void *)&cmd_write_reg_bit_field_bit2_pos,
7793 (void *)&cmd_write_reg_bit_field_value,
7798 /* *** WRITE PORT REGISTER BIT *** */
7799 struct cmd_write_reg_bit_result {
7800 cmdline_fixed_string_t write;
7801 cmdline_fixed_string_t regbit;
7809 cmd_write_reg_bit_parsed(void *parsed_result,
7810 __attribute__((unused)) struct cmdline *cl,
7811 __attribute__((unused)) void *data)
7813 struct cmd_write_reg_bit_result *res = parsed_result;
7814 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7817 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7818 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7820 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7821 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7823 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7824 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7825 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7826 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7827 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7828 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7829 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7830 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7832 cmdline_parse_inst_t cmd_write_reg_bit = {
7833 .f = cmd_write_reg_bit_parsed,
7835 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7838 (void *)&cmd_write_reg_bit_write,
7839 (void *)&cmd_write_reg_bit_regbit,
7840 (void *)&cmd_write_reg_bit_port_id,
7841 (void *)&cmd_write_reg_bit_reg_off,
7842 (void *)&cmd_write_reg_bit_bit_pos,
7843 (void *)&cmd_write_reg_bit_value,
7848 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7849 struct cmd_read_rxd_txd_result {
7850 cmdline_fixed_string_t read;
7851 cmdline_fixed_string_t rxd_txd;
7858 cmd_read_rxd_txd_parsed(void *parsed_result,
7859 __attribute__((unused)) struct cmdline *cl,
7860 __attribute__((unused)) void *data)
7862 struct cmd_read_rxd_txd_result *res = parsed_result;
7864 if (!strcmp(res->rxd_txd, "rxd"))
7865 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7866 else if (!strcmp(res->rxd_txd, "txd"))
7867 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7870 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7871 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7872 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7873 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7875 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7876 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7877 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7878 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7879 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7880 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7882 cmdline_parse_inst_t cmd_read_rxd_txd = {
7883 .f = cmd_read_rxd_txd_parsed,
7885 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7887 (void *)&cmd_read_rxd_txd_read,
7888 (void *)&cmd_read_rxd_txd_rxd_txd,
7889 (void *)&cmd_read_rxd_txd_port_id,
7890 (void *)&cmd_read_rxd_txd_queue_id,
7891 (void *)&cmd_read_rxd_txd_desc_id,
7897 struct cmd_quit_result {
7898 cmdline_fixed_string_t quit;
7901 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7903 __attribute__((unused)) void *data)
7908 cmdline_parse_token_string_t cmd_quit_quit =
7909 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7911 cmdline_parse_inst_t cmd_quit = {
7912 .f = cmd_quit_parsed,
7914 .help_str = "quit: Exit application",
7916 (void *)&cmd_quit_quit,
7921 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7922 struct cmd_mac_addr_result {
7923 cmdline_fixed_string_t mac_addr_cmd;
7924 cmdline_fixed_string_t what;
7926 struct rte_ether_addr address;
7929 static void cmd_mac_addr_parsed(void *parsed_result,
7930 __attribute__((unused)) struct cmdline *cl,
7931 __attribute__((unused)) void *data)
7933 struct cmd_mac_addr_result *res = parsed_result;
7936 if (strcmp(res->what, "add") == 0)
7937 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7938 else if (strcmp(res->what, "set") == 0)
7939 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7942 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7944 /* check the return value and print it if is < 0 */
7946 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7950 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7951 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7953 cmdline_parse_token_string_t cmd_mac_addr_what =
7954 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7956 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7957 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7959 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7960 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7962 cmdline_parse_inst_t cmd_mac_addr = {
7963 .f = cmd_mac_addr_parsed,
7965 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7966 "Add/Remove/Set MAC address on port_id",
7968 (void *)&cmd_mac_addr_cmd,
7969 (void *)&cmd_mac_addr_what,
7970 (void *)&cmd_mac_addr_portnum,
7971 (void *)&cmd_mac_addr_addr,
7976 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7977 struct cmd_eth_peer_result {
7978 cmdline_fixed_string_t set;
7979 cmdline_fixed_string_t eth_peer;
7981 cmdline_fixed_string_t peer_addr;
7984 static void cmd_set_eth_peer_parsed(void *parsed_result,
7985 __attribute__((unused)) struct cmdline *cl,
7986 __attribute__((unused)) void *data)
7988 struct cmd_eth_peer_result *res = parsed_result;
7990 if (test_done == 0) {
7991 printf("Please stop forwarding first\n");
7994 if (!strcmp(res->eth_peer, "eth-peer")) {
7995 set_fwd_eth_peer(res->port_id, res->peer_addr);
7999 cmdline_parse_token_string_t cmd_eth_peer_set =
8000 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8001 cmdline_parse_token_string_t cmd_eth_peer =
8002 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8003 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8004 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8005 cmdline_parse_token_string_t cmd_eth_peer_addr =
8006 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8008 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8009 .f = cmd_set_eth_peer_parsed,
8011 .help_str = "set eth-peer <port_id> <peer_mac>",
8013 (void *)&cmd_eth_peer_set,
8014 (void *)&cmd_eth_peer,
8015 (void *)&cmd_eth_peer_port_id,
8016 (void *)&cmd_eth_peer_addr,
8021 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8022 struct cmd_set_qmap_result {
8023 cmdline_fixed_string_t set;
8024 cmdline_fixed_string_t qmap;
8025 cmdline_fixed_string_t what;
8032 cmd_set_qmap_parsed(void *parsed_result,
8033 __attribute__((unused)) struct cmdline *cl,
8034 __attribute__((unused)) void *data)
8036 struct cmd_set_qmap_result *res = parsed_result;
8037 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8039 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8042 cmdline_parse_token_string_t cmd_setqmap_set =
8043 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8045 cmdline_parse_token_string_t cmd_setqmap_qmap =
8046 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8048 cmdline_parse_token_string_t cmd_setqmap_what =
8049 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8051 cmdline_parse_token_num_t cmd_setqmap_portid =
8052 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8054 cmdline_parse_token_num_t cmd_setqmap_queueid =
8055 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8057 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8058 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8061 cmdline_parse_inst_t cmd_set_qmap = {
8062 .f = cmd_set_qmap_parsed,
8064 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8065 "Set statistics mapping value on tx|rx queue_id of port_id",
8067 (void *)&cmd_setqmap_set,
8068 (void *)&cmd_setqmap_qmap,
8069 (void *)&cmd_setqmap_what,
8070 (void *)&cmd_setqmap_portid,
8071 (void *)&cmd_setqmap_queueid,
8072 (void *)&cmd_setqmap_mapvalue,
8077 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8078 struct cmd_set_xstats_hide_zero_result {
8079 cmdline_fixed_string_t keyword;
8080 cmdline_fixed_string_t name;
8081 cmdline_fixed_string_t on_off;
8085 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8086 __attribute__((unused)) struct cmdline *cl,
8087 __attribute__((unused)) void *data)
8089 struct cmd_set_xstats_hide_zero_result *res;
8090 uint16_t on_off = 0;
8092 res = parsed_result;
8093 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8094 set_xstats_hide_zero(on_off);
8097 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8098 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8100 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8101 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8102 name, "xstats-hide-zero");
8103 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8104 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8107 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8108 .f = cmd_set_xstats_hide_zero_parsed,
8110 .help_str = "set xstats-hide-zero on|off",
8112 (void *)&cmd_set_xstats_hide_zero_keyword,
8113 (void *)&cmd_set_xstats_hide_zero_name,
8114 (void *)&cmd_set_xstats_hide_zero_on_off,
8119 /* *** CONFIGURE UNICAST HASH TABLE *** */
8120 struct cmd_set_uc_hash_table {
8121 cmdline_fixed_string_t set;
8122 cmdline_fixed_string_t port;
8124 cmdline_fixed_string_t what;
8125 struct rte_ether_addr address;
8126 cmdline_fixed_string_t mode;
8130 cmd_set_uc_hash_parsed(void *parsed_result,
8131 __attribute__((unused)) struct cmdline *cl,
8132 __attribute__((unused)) void *data)
8135 struct cmd_set_uc_hash_table *res = parsed_result;
8137 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8139 if (strcmp(res->what, "uta") == 0)
8140 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8141 &res->address,(uint8_t)is_on);
8143 printf("bad unicast hash table parameter, return code = %d \n", ret);
8147 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8148 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8150 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8151 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8153 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8154 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8156 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8157 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8159 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8160 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8162 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8163 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8166 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8167 .f = cmd_set_uc_hash_parsed,
8169 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8171 (void *)&cmd_set_uc_hash_set,
8172 (void *)&cmd_set_uc_hash_port,
8173 (void *)&cmd_set_uc_hash_portid,
8174 (void *)&cmd_set_uc_hash_what,
8175 (void *)&cmd_set_uc_hash_mac,
8176 (void *)&cmd_set_uc_hash_mode,
8181 struct cmd_set_uc_all_hash_table {
8182 cmdline_fixed_string_t set;
8183 cmdline_fixed_string_t port;
8185 cmdline_fixed_string_t what;
8186 cmdline_fixed_string_t value;
8187 cmdline_fixed_string_t mode;
8191 cmd_set_uc_all_hash_parsed(void *parsed_result,
8192 __attribute__((unused)) struct cmdline *cl,
8193 __attribute__((unused)) void *data)
8196 struct cmd_set_uc_all_hash_table *res = parsed_result;
8198 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8200 if ((strcmp(res->what, "uta") == 0) &&
8201 (strcmp(res->value, "all") == 0))
8202 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8204 printf("bad unicast hash table parameter,"
8205 "return code = %d \n", ret);
8208 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8209 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8211 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8212 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8214 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8215 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8217 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8218 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8220 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8221 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8223 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8224 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8227 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8228 .f = cmd_set_uc_all_hash_parsed,
8230 .help_str = "set port <port_id> uta all on|off",
8232 (void *)&cmd_set_uc_all_hash_set,
8233 (void *)&cmd_set_uc_all_hash_port,
8234 (void *)&cmd_set_uc_all_hash_portid,
8235 (void *)&cmd_set_uc_all_hash_what,
8236 (void *)&cmd_set_uc_all_hash_value,
8237 (void *)&cmd_set_uc_all_hash_mode,
8242 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
8243 struct cmd_set_vf_macvlan_filter {
8244 cmdline_fixed_string_t set;
8245 cmdline_fixed_string_t port;
8247 cmdline_fixed_string_t vf;
8249 struct rte_ether_addr address;
8250 cmdline_fixed_string_t filter_type;
8251 cmdline_fixed_string_t mode;
8255 cmd_set_vf_macvlan_parsed(void *parsed_result,
8256 __attribute__((unused)) struct cmdline *cl,
8257 __attribute__((unused)) void *data)
8260 struct cmd_set_vf_macvlan_filter *res = parsed_result;
8261 struct rte_eth_mac_filter filter;
8263 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
8265 rte_memcpy(&filter.mac_addr, &res->address, RTE_ETHER_ADDR_LEN);
8267 /* set VF MAC filter */
8271 filter.dst_id = res->vf_id;
8273 if (!strcmp(res->filter_type, "exact-mac"))
8274 filter.filter_type = RTE_MAC_PERFECT_MATCH;
8275 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
8276 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
8277 else if (!strcmp(res->filter_type, "hashmac"))
8278 filter.filter_type = RTE_MAC_HASH_MATCH;
8279 else if (!strcmp(res->filter_type, "hashmac-vlan"))
8280 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
8282 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8285 ret = rte_eth_dev_filter_ctrl(res->port_id,
8286 RTE_ETH_FILTER_MACVLAN,
8290 ret = rte_eth_dev_filter_ctrl(res->port_id,
8291 RTE_ETH_FILTER_MACVLAN,
8292 RTE_ETH_FILTER_DELETE,
8296 printf("bad set MAC hash parameter, return code = %d\n", ret);
8300 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
8301 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8303 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
8304 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8306 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
8307 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8309 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
8310 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8312 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
8313 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8315 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
8316 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8318 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
8319 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8320 filter_type, "exact-mac#exact-mac-vlan"
8321 "#hashmac#hashmac-vlan");
8322 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
8323 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
8326 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
8327 .f = cmd_set_vf_macvlan_parsed,
8329 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8330 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8331 "Exact match rule: exact match of MAC or MAC and VLAN; "
8332 "hash match rule: hash match of MAC and exact match of VLAN",
8334 (void *)&cmd_set_vf_macvlan_set,
8335 (void *)&cmd_set_vf_macvlan_port,
8336 (void *)&cmd_set_vf_macvlan_portid,
8337 (void *)&cmd_set_vf_macvlan_vf,
8338 (void *)&cmd_set_vf_macvlan_vf_id,
8339 (void *)&cmd_set_vf_macvlan_mac,
8340 (void *)&cmd_set_vf_macvlan_filter_type,
8341 (void *)&cmd_set_vf_macvlan_mode,
8346 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8347 struct cmd_set_vf_traffic {
8348 cmdline_fixed_string_t set;
8349 cmdline_fixed_string_t port;
8351 cmdline_fixed_string_t vf;
8353 cmdline_fixed_string_t what;
8354 cmdline_fixed_string_t mode;
8358 cmd_set_vf_traffic_parsed(void *parsed_result,
8359 __attribute__((unused)) struct cmdline *cl,
8360 __attribute__((unused)) void *data)
8362 struct cmd_set_vf_traffic *res = parsed_result;
8363 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8364 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8366 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8369 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8370 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8372 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8373 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8375 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8376 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8378 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8379 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8381 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8382 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8384 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8385 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8387 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8388 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8391 cmdline_parse_inst_t cmd_set_vf_traffic = {
8392 .f = cmd_set_vf_traffic_parsed,
8394 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8396 (void *)&cmd_setvf_traffic_set,
8397 (void *)&cmd_setvf_traffic_port,
8398 (void *)&cmd_setvf_traffic_portid,
8399 (void *)&cmd_setvf_traffic_vf,
8400 (void *)&cmd_setvf_traffic_vfid,
8401 (void *)&cmd_setvf_traffic_what,
8402 (void *)&cmd_setvf_traffic_mode,
8407 /* *** CONFIGURE VF RECEIVE MODE *** */
8408 struct cmd_set_vf_rxmode {
8409 cmdline_fixed_string_t set;
8410 cmdline_fixed_string_t port;
8412 cmdline_fixed_string_t vf;
8414 cmdline_fixed_string_t what;
8415 cmdline_fixed_string_t mode;
8416 cmdline_fixed_string_t on;
8420 cmd_set_vf_rxmode_parsed(void *parsed_result,
8421 __attribute__((unused)) struct cmdline *cl,
8422 __attribute__((unused)) void *data)
8425 uint16_t rx_mode = 0;
8426 struct cmd_set_vf_rxmode *res = parsed_result;
8428 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8429 if (!strcmp(res->what,"rxmode")) {
8430 if (!strcmp(res->mode, "AUPE"))
8431 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
8432 else if (!strcmp(res->mode, "ROPE"))
8433 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
8434 else if (!strcmp(res->mode, "BAM"))
8435 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
8436 else if (!strncmp(res->mode, "MPE",3))
8437 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
8440 RTE_SET_USED(is_on);
8442 #ifdef RTE_LIBRTE_IXGBE_PMD
8443 if (ret == -ENOTSUP)
8444 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8445 rx_mode, (uint8_t)is_on);
8447 #ifdef RTE_LIBRTE_BNXT_PMD
8448 if (ret == -ENOTSUP)
8449 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8450 rx_mode, (uint8_t)is_on);
8453 printf("bad VF receive mode parameter, return code = %d \n",
8457 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8458 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8460 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8461 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8463 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8464 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8466 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8467 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8469 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8470 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8472 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8473 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8475 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8476 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8477 mode, "AUPE#ROPE#BAM#MPE");
8478 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8479 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8482 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8483 .f = cmd_set_vf_rxmode_parsed,
8485 .help_str = "set port <port_id> vf <vf_id> rxmode "
8486 "AUPE|ROPE|BAM|MPE on|off",
8488 (void *)&cmd_set_vf_rxmode_set,
8489 (void *)&cmd_set_vf_rxmode_port,
8490 (void *)&cmd_set_vf_rxmode_portid,
8491 (void *)&cmd_set_vf_rxmode_vf,
8492 (void *)&cmd_set_vf_rxmode_vfid,
8493 (void *)&cmd_set_vf_rxmode_what,
8494 (void *)&cmd_set_vf_rxmode_mode,
8495 (void *)&cmd_set_vf_rxmode_on,
8500 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8501 struct cmd_vf_mac_addr_result {
8502 cmdline_fixed_string_t mac_addr_cmd;
8503 cmdline_fixed_string_t what;
8504 cmdline_fixed_string_t port;
8506 cmdline_fixed_string_t vf;
8508 struct rte_ether_addr address;
8511 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8512 __attribute__((unused)) struct cmdline *cl,
8513 __attribute__((unused)) void *data)
8515 struct cmd_vf_mac_addr_result *res = parsed_result;
8518 if (strcmp(res->what, "add") != 0)
8521 #ifdef RTE_LIBRTE_I40E_PMD
8522 if (ret == -ENOTSUP)
8523 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8526 #ifdef RTE_LIBRTE_BNXT_PMD
8527 if (ret == -ENOTSUP)
8528 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8533 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8537 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8538 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8539 mac_addr_cmd,"mac_addr");
8540 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8541 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8543 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8544 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8546 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8547 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8549 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8550 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8552 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8553 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8555 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8556 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8559 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8560 .f = cmd_vf_mac_addr_parsed,
8562 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8563 "Add MAC address filtering for a VF on port_id",
8565 (void *)&cmd_vf_mac_addr_cmd,
8566 (void *)&cmd_vf_mac_addr_what,
8567 (void *)&cmd_vf_mac_addr_port,
8568 (void *)&cmd_vf_mac_addr_portnum,
8569 (void *)&cmd_vf_mac_addr_vf,
8570 (void *)&cmd_vf_mac_addr_vfnum,
8571 (void *)&cmd_vf_mac_addr_addr,
8576 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8577 struct cmd_vf_rx_vlan_filter {
8578 cmdline_fixed_string_t rx_vlan;
8579 cmdline_fixed_string_t what;
8581 cmdline_fixed_string_t port;
8583 cmdline_fixed_string_t vf;
8588 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8589 __attribute__((unused)) struct cmdline *cl,
8590 __attribute__((unused)) void *data)
8592 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8595 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8597 #ifdef RTE_LIBRTE_IXGBE_PMD
8598 if (ret == -ENOTSUP)
8599 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8600 res->vlan_id, res->vf_mask, is_add);
8602 #ifdef RTE_LIBRTE_I40E_PMD
8603 if (ret == -ENOTSUP)
8604 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8605 res->vlan_id, res->vf_mask, is_add);
8607 #ifdef RTE_LIBRTE_BNXT_PMD
8608 if (ret == -ENOTSUP)
8609 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8610 res->vlan_id, res->vf_mask, is_add);
8617 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8618 res->vlan_id, res->vf_mask);
8621 printf("invalid port_id %d\n", res->port_id);
8624 printf("function not implemented or supported\n");
8627 printf("programming error: (%s)\n", strerror(-ret));
8631 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8632 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8633 rx_vlan, "rx_vlan");
8634 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8635 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8637 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8638 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8640 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8641 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8643 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8644 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8646 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8647 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8649 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8650 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8653 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8654 .f = cmd_vf_rx_vlan_filter_parsed,
8656 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8657 "(vf_mask = hexadecimal VF mask)",
8659 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8660 (void *)&cmd_vf_rx_vlan_filter_what,
8661 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8662 (void *)&cmd_vf_rx_vlan_filter_port,
8663 (void *)&cmd_vf_rx_vlan_filter_portid,
8664 (void *)&cmd_vf_rx_vlan_filter_vf,
8665 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8670 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8671 struct cmd_queue_rate_limit_result {
8672 cmdline_fixed_string_t set;
8673 cmdline_fixed_string_t port;
8675 cmdline_fixed_string_t queue;
8677 cmdline_fixed_string_t rate;
8681 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8682 __attribute__((unused)) struct cmdline *cl,
8683 __attribute__((unused)) void *data)
8685 struct cmd_queue_rate_limit_result *res = parsed_result;
8688 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8689 && (strcmp(res->queue, "queue") == 0)
8690 && (strcmp(res->rate, "rate") == 0))
8691 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8694 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8698 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8699 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8701 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8702 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8704 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8705 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8707 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8708 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8710 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8711 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8713 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8714 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8716 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8717 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8720 cmdline_parse_inst_t cmd_queue_rate_limit = {
8721 .f = cmd_queue_rate_limit_parsed,
8723 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8724 "Set rate limit for a queue on port_id",
8726 (void *)&cmd_queue_rate_limit_set,
8727 (void *)&cmd_queue_rate_limit_port,
8728 (void *)&cmd_queue_rate_limit_portnum,
8729 (void *)&cmd_queue_rate_limit_queue,
8730 (void *)&cmd_queue_rate_limit_queuenum,
8731 (void *)&cmd_queue_rate_limit_rate,
8732 (void *)&cmd_queue_rate_limit_ratenum,
8737 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8738 struct cmd_vf_rate_limit_result {
8739 cmdline_fixed_string_t set;
8740 cmdline_fixed_string_t port;
8742 cmdline_fixed_string_t vf;
8744 cmdline_fixed_string_t rate;
8746 cmdline_fixed_string_t q_msk;
8750 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8751 __attribute__((unused)) struct cmdline *cl,
8752 __attribute__((unused)) void *data)
8754 struct cmd_vf_rate_limit_result *res = parsed_result;
8757 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8758 && (strcmp(res->vf, "vf") == 0)
8759 && (strcmp(res->rate, "rate") == 0)
8760 && (strcmp(res->q_msk, "queue_mask") == 0))
8761 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8762 res->rate_num, res->q_msk_val);
8764 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8768 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8769 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8771 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8772 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8774 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8775 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8777 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8778 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8780 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8781 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8783 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8784 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8786 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8787 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8789 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8790 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8791 q_msk, "queue_mask");
8792 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8793 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8796 cmdline_parse_inst_t cmd_vf_rate_limit = {
8797 .f = cmd_vf_rate_limit_parsed,
8799 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8800 "queue_mask <queue_mask_value>: "
8801 "Set rate limit for queues of VF on port_id",
8803 (void *)&cmd_vf_rate_limit_set,
8804 (void *)&cmd_vf_rate_limit_port,
8805 (void *)&cmd_vf_rate_limit_portnum,
8806 (void *)&cmd_vf_rate_limit_vf,
8807 (void *)&cmd_vf_rate_limit_vfnum,
8808 (void *)&cmd_vf_rate_limit_rate,
8809 (void *)&cmd_vf_rate_limit_ratenum,
8810 (void *)&cmd_vf_rate_limit_q_msk,
8811 (void *)&cmd_vf_rate_limit_q_msk_val,
8816 /* *** ADD TUNNEL FILTER OF A PORT *** */
8817 struct cmd_tunnel_filter_result {
8818 cmdline_fixed_string_t cmd;
8819 cmdline_fixed_string_t what;
8821 struct rte_ether_addr outer_mac;
8822 struct rte_ether_addr inner_mac;
8823 cmdline_ipaddr_t ip_value;
8824 uint16_t inner_vlan;
8825 cmdline_fixed_string_t tunnel_type;
8826 cmdline_fixed_string_t filter_type;
8832 cmd_tunnel_filter_parsed(void *parsed_result,
8833 __attribute__((unused)) struct cmdline *cl,
8834 __attribute__((unused)) void *data)
8836 struct cmd_tunnel_filter_result *res = parsed_result;
8837 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8840 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8842 rte_ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8843 rte_ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8844 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8846 if (res->ip_value.family == AF_INET) {
8847 tunnel_filter_conf.ip_addr.ipv4_addr =
8848 res->ip_value.addr.ipv4.s_addr;
8849 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8851 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8852 &(res->ip_value.addr.ipv6),
8853 sizeof(struct in6_addr));
8854 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8857 if (!strcmp(res->filter_type, "imac-ivlan"))
8858 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8859 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8860 tunnel_filter_conf.filter_type =
8861 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8862 else if (!strcmp(res->filter_type, "imac-tenid"))
8863 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8864 else if (!strcmp(res->filter_type, "imac"))
8865 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8866 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8867 tunnel_filter_conf.filter_type =
8868 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8869 else if (!strcmp(res->filter_type, "oip"))
8870 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8871 else if (!strcmp(res->filter_type, "iip"))
8872 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8874 printf("The filter type is not supported");
8878 if (!strcmp(res->tunnel_type, "vxlan"))
8879 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8880 else if (!strcmp(res->tunnel_type, "vxlan-gpe"))
8881 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
8882 else if (!strcmp(res->tunnel_type, "nvgre"))
8883 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8884 else if (!strcmp(res->tunnel_type, "ipingre"))
8885 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8887 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8891 tunnel_filter_conf.tenant_id = res->tenant_id;
8892 tunnel_filter_conf.queue_id = res->queue_num;
8893 if (!strcmp(res->what, "add"))
8894 ret = rte_eth_dev_filter_ctrl(res->port_id,
8895 RTE_ETH_FILTER_TUNNEL,
8897 &tunnel_filter_conf);
8899 ret = rte_eth_dev_filter_ctrl(res->port_id,
8900 RTE_ETH_FILTER_TUNNEL,
8901 RTE_ETH_FILTER_DELETE,
8902 &tunnel_filter_conf);
8904 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8908 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8909 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8910 cmd, "tunnel_filter");
8911 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8912 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8914 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8915 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8917 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8918 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8920 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8921 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8923 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8924 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8925 inner_vlan, UINT16);
8926 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8927 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8929 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8930 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8931 tunnel_type, "vxlan#nvgre#ipingre#vxlan-gpe");
8933 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8934 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8935 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8936 "imac#omac-imac-tenid");
8937 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8938 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8940 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8941 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8944 cmdline_parse_inst_t cmd_tunnel_filter = {
8945 .f = cmd_tunnel_filter_parsed,
8947 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8948 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8949 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8950 "<queue_id>: Add/Rm tunnel filter of a port",
8952 (void *)&cmd_tunnel_filter_cmd,
8953 (void *)&cmd_tunnel_filter_what,
8954 (void *)&cmd_tunnel_filter_port_id,
8955 (void *)&cmd_tunnel_filter_outer_mac,
8956 (void *)&cmd_tunnel_filter_inner_mac,
8957 (void *)&cmd_tunnel_filter_ip_value,
8958 (void *)&cmd_tunnel_filter_innner_vlan,
8959 (void *)&cmd_tunnel_filter_tunnel_type,
8960 (void *)&cmd_tunnel_filter_filter_type,
8961 (void *)&cmd_tunnel_filter_tenant_id,
8962 (void *)&cmd_tunnel_filter_queue_num,
8967 /* *** CONFIGURE TUNNEL UDP PORT *** */
8968 struct cmd_tunnel_udp_config {
8969 cmdline_fixed_string_t cmd;
8970 cmdline_fixed_string_t what;
8976 cmd_tunnel_udp_config_parsed(void *parsed_result,
8977 __attribute__((unused)) struct cmdline *cl,
8978 __attribute__((unused)) void *data)
8980 struct cmd_tunnel_udp_config *res = parsed_result;
8981 struct rte_eth_udp_tunnel tunnel_udp;
8984 tunnel_udp.udp_port = res->udp_port;
8986 if (!strcmp(res->cmd, "rx_vxlan_port"))
8987 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8989 if (!strcmp(res->what, "add"))
8990 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8993 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8997 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9000 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9001 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9002 cmd, "rx_vxlan_port");
9003 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9004 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9006 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9007 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9009 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9010 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9013 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9014 .f = cmd_tunnel_udp_config_parsed,
9016 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9017 "Add/Remove a tunneling UDP port filter",
9019 (void *)&cmd_tunnel_udp_config_cmd,
9020 (void *)&cmd_tunnel_udp_config_what,
9021 (void *)&cmd_tunnel_udp_config_udp_port,
9022 (void *)&cmd_tunnel_udp_config_port_id,
9027 struct cmd_config_tunnel_udp_port {
9028 cmdline_fixed_string_t port;
9029 cmdline_fixed_string_t config;
9031 cmdline_fixed_string_t udp_tunnel_port;
9032 cmdline_fixed_string_t action;
9033 cmdline_fixed_string_t tunnel_type;
9038 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9039 __attribute__((unused)) struct cmdline *cl,
9040 __attribute__((unused)) void *data)
9042 struct cmd_config_tunnel_udp_port *res = parsed_result;
9043 struct rte_eth_udp_tunnel tunnel_udp;
9046 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9049 tunnel_udp.udp_port = res->udp_port;
9051 if (!strcmp(res->tunnel_type, "vxlan")) {
9052 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9053 } else if (!strcmp(res->tunnel_type, "geneve")) {
9054 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9055 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9056 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9058 printf("Invalid tunnel type\n");
9062 if (!strcmp(res->action, "add"))
9063 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9066 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9070 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9073 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9074 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9076 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9077 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9079 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9080 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9082 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9083 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9086 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9087 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9089 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9090 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9091 "vxlan#geneve#vxlan-gpe");
9092 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9093 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9096 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9097 .f = cmd_cfg_tunnel_udp_port_parsed,
9099 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9101 (void *)&cmd_config_tunnel_udp_port_port,
9102 (void *)&cmd_config_tunnel_udp_port_config,
9103 (void *)&cmd_config_tunnel_udp_port_port_id,
9104 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9105 (void *)&cmd_config_tunnel_udp_port_action,
9106 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9107 (void *)&cmd_config_tunnel_udp_port_value,
9112 /* *** GLOBAL CONFIG *** */
9113 struct cmd_global_config_result {
9114 cmdline_fixed_string_t cmd;
9116 cmdline_fixed_string_t cfg_type;
9121 cmd_global_config_parsed(void *parsed_result,
9122 __attribute__((unused)) struct cmdline *cl,
9123 __attribute__((unused)) void *data)
9125 struct cmd_global_config_result *res = parsed_result;
9126 struct rte_eth_global_cfg conf;
9129 memset(&conf, 0, sizeof(conf));
9130 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
9131 conf.cfg.gre_key_len = res->len;
9132 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
9133 RTE_ETH_FILTER_SET, &conf);
9135 printf("Global config error\n");
9138 cmdline_parse_token_string_t cmd_global_config_cmd =
9139 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
9141 cmdline_parse_token_num_t cmd_global_config_port_id =
9142 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
9144 cmdline_parse_token_string_t cmd_global_config_type =
9145 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
9146 cfg_type, "gre-key-len");
9147 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
9148 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
9151 cmdline_parse_inst_t cmd_global_config = {
9152 .f = cmd_global_config_parsed,
9153 .data = (void *)NULL,
9154 .help_str = "global_config <port_id> gre-key-len <key_len>",
9156 (void *)&cmd_global_config_cmd,
9157 (void *)&cmd_global_config_port_id,
9158 (void *)&cmd_global_config_type,
9159 (void *)&cmd_global_config_gre_key_len,
9164 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9165 struct cmd_set_mirror_mask_result {
9166 cmdline_fixed_string_t set;
9167 cmdline_fixed_string_t port;
9169 cmdline_fixed_string_t mirror;
9171 cmdline_fixed_string_t what;
9172 cmdline_fixed_string_t value;
9173 cmdline_fixed_string_t dstpool;
9175 cmdline_fixed_string_t on;
9178 cmdline_parse_token_string_t cmd_mirror_mask_set =
9179 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9181 cmdline_parse_token_string_t cmd_mirror_mask_port =
9182 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9184 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9185 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9187 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9188 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9189 mirror, "mirror-rule");
9190 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9191 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9193 cmdline_parse_token_string_t cmd_mirror_mask_what =
9194 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9195 what, "pool-mirror-up#pool-mirror-down"
9197 cmdline_parse_token_string_t cmd_mirror_mask_value =
9198 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9200 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9201 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9202 dstpool, "dst-pool");
9203 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9204 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9206 cmdline_parse_token_string_t cmd_mirror_mask_on =
9207 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9211 cmd_set_mirror_mask_parsed(void *parsed_result,
9212 __attribute__((unused)) struct cmdline *cl,
9213 __attribute__((unused)) void *data)
9216 struct cmd_set_mirror_mask_result *res = parsed_result;
9217 struct rte_eth_mirror_conf mr_conf;
9219 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9221 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9223 mr_conf.dst_pool = res->dstpool_id;
9225 if (!strcmp(res->what, "pool-mirror-up")) {
9226 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9227 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9228 } else if (!strcmp(res->what, "pool-mirror-down")) {
9229 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9230 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9231 } else if (!strcmp(res->what, "vlan-mirror")) {
9232 mr_conf.rule_type = ETH_MIRROR_VLAN;
9233 nb_item = parse_item_list(res->value, "vlan",
9234 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9238 for (i = 0; i < nb_item; i++) {
9239 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9240 printf("Invalid vlan_id: must be < 4096\n");
9244 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9245 mr_conf.vlan.vlan_mask |= 1ULL << i;
9249 if (!strcmp(res->on, "on"))
9250 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9253 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9256 printf("mirror rule add error: (%s)\n", strerror(-ret));
9259 cmdline_parse_inst_t cmd_set_mirror_mask = {
9260 .f = cmd_set_mirror_mask_parsed,
9262 .help_str = "set port <port_id> mirror-rule <rule_id> "
9263 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9264 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9266 (void *)&cmd_mirror_mask_set,
9267 (void *)&cmd_mirror_mask_port,
9268 (void *)&cmd_mirror_mask_portid,
9269 (void *)&cmd_mirror_mask_mirror,
9270 (void *)&cmd_mirror_mask_ruleid,
9271 (void *)&cmd_mirror_mask_what,
9272 (void *)&cmd_mirror_mask_value,
9273 (void *)&cmd_mirror_mask_dstpool,
9274 (void *)&cmd_mirror_mask_poolid,
9275 (void *)&cmd_mirror_mask_on,
9280 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9281 struct cmd_set_mirror_link_result {
9282 cmdline_fixed_string_t set;
9283 cmdline_fixed_string_t port;
9285 cmdline_fixed_string_t mirror;
9287 cmdline_fixed_string_t what;
9288 cmdline_fixed_string_t dstpool;
9290 cmdline_fixed_string_t on;
9293 cmdline_parse_token_string_t cmd_mirror_link_set =
9294 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9296 cmdline_parse_token_string_t cmd_mirror_link_port =
9297 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9299 cmdline_parse_token_num_t cmd_mirror_link_portid =
9300 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9302 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9303 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9304 mirror, "mirror-rule");
9305 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9306 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9308 cmdline_parse_token_string_t cmd_mirror_link_what =
9309 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9310 what, "uplink-mirror#downlink-mirror");
9311 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9312 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9313 dstpool, "dst-pool");
9314 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9315 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9317 cmdline_parse_token_string_t cmd_mirror_link_on =
9318 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9322 cmd_set_mirror_link_parsed(void *parsed_result,
9323 __attribute__((unused)) struct cmdline *cl,
9324 __attribute__((unused)) void *data)
9327 struct cmd_set_mirror_link_result *res = parsed_result;
9328 struct rte_eth_mirror_conf mr_conf;
9330 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9331 if (!strcmp(res->what, "uplink-mirror"))
9332 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9334 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9336 mr_conf.dst_pool = res->dstpool_id;
9338 if (!strcmp(res->on, "on"))
9339 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9342 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9345 /* check the return value and print it if is < 0 */
9347 printf("mirror rule add error: (%s)\n", strerror(-ret));
9351 cmdline_parse_inst_t cmd_set_mirror_link = {
9352 .f = cmd_set_mirror_link_parsed,
9354 .help_str = "set port <port_id> mirror-rule <rule_id> "
9355 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9357 (void *)&cmd_mirror_link_set,
9358 (void *)&cmd_mirror_link_port,
9359 (void *)&cmd_mirror_link_portid,
9360 (void *)&cmd_mirror_link_mirror,
9361 (void *)&cmd_mirror_link_ruleid,
9362 (void *)&cmd_mirror_link_what,
9363 (void *)&cmd_mirror_link_dstpool,
9364 (void *)&cmd_mirror_link_poolid,
9365 (void *)&cmd_mirror_link_on,
9370 /* *** RESET VM MIRROR RULE *** */
9371 struct cmd_rm_mirror_rule_result {
9372 cmdline_fixed_string_t reset;
9373 cmdline_fixed_string_t port;
9375 cmdline_fixed_string_t mirror;
9379 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9380 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9382 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9383 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9385 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9386 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9388 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9389 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9390 mirror, "mirror-rule");
9391 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9392 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9396 cmd_reset_mirror_rule_parsed(void *parsed_result,
9397 __attribute__((unused)) struct cmdline *cl,
9398 __attribute__((unused)) void *data)
9401 struct cmd_set_mirror_link_result *res = parsed_result;
9403 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9405 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9408 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9409 .f = cmd_reset_mirror_rule_parsed,
9411 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9413 (void *)&cmd_rm_mirror_rule_reset,
9414 (void *)&cmd_rm_mirror_rule_port,
9415 (void *)&cmd_rm_mirror_rule_portid,
9416 (void *)&cmd_rm_mirror_rule_mirror,
9417 (void *)&cmd_rm_mirror_rule_ruleid,
9422 /* ******************************************************************************** */
9424 struct cmd_dump_result {
9425 cmdline_fixed_string_t dump;
9429 dump_struct_sizes(void)
9431 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9432 DUMP_SIZE(struct rte_mbuf);
9433 DUMP_SIZE(struct rte_mempool);
9434 DUMP_SIZE(struct rte_ring);
9438 static void cmd_dump_parsed(void *parsed_result,
9439 __attribute__((unused)) struct cmdline *cl,
9440 __attribute__((unused)) void *data)
9442 struct cmd_dump_result *res = parsed_result;
9444 if (!strcmp(res->dump, "dump_physmem"))
9445 rte_dump_physmem_layout(stdout);
9446 else if (!strcmp(res->dump, "dump_memzone"))
9447 rte_memzone_dump(stdout);
9448 else if (!strcmp(res->dump, "dump_struct_sizes"))
9449 dump_struct_sizes();
9450 else if (!strcmp(res->dump, "dump_ring"))
9451 rte_ring_list_dump(stdout);
9452 else if (!strcmp(res->dump, "dump_mempool"))
9453 rte_mempool_list_dump(stdout);
9454 else if (!strcmp(res->dump, "dump_devargs"))
9455 rte_devargs_dump(stdout);
9456 else if (!strcmp(res->dump, "dump_log_types"))
9457 rte_log_dump(stdout);
9460 cmdline_parse_token_string_t cmd_dump_dump =
9461 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9464 "dump_struct_sizes#"
9470 cmdline_parse_inst_t cmd_dump = {
9471 .f = cmd_dump_parsed, /* function to call */
9472 .data = NULL, /* 2nd arg of func */
9473 .help_str = "Dump status",
9474 .tokens = { /* token list, NULL terminated */
9475 (void *)&cmd_dump_dump,
9480 /* ******************************************************************************** */
9482 struct cmd_dump_one_result {
9483 cmdline_fixed_string_t dump;
9484 cmdline_fixed_string_t name;
9487 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9488 __attribute__((unused)) void *data)
9490 struct cmd_dump_one_result *res = parsed_result;
9492 if (!strcmp(res->dump, "dump_ring")) {
9494 r = rte_ring_lookup(res->name);
9496 cmdline_printf(cl, "Cannot find ring\n");
9499 rte_ring_dump(stdout, r);
9500 } else if (!strcmp(res->dump, "dump_mempool")) {
9501 struct rte_mempool *mp;
9502 mp = rte_mempool_lookup(res->name);
9504 cmdline_printf(cl, "Cannot find mempool\n");
9507 rte_mempool_dump(stdout, mp);
9511 cmdline_parse_token_string_t cmd_dump_one_dump =
9512 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9513 "dump_ring#dump_mempool");
9515 cmdline_parse_token_string_t cmd_dump_one_name =
9516 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9518 cmdline_parse_inst_t cmd_dump_one = {
9519 .f = cmd_dump_one_parsed, /* function to call */
9520 .data = NULL, /* 2nd arg of func */
9521 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9522 .tokens = { /* token list, NULL terminated */
9523 (void *)&cmd_dump_one_dump,
9524 (void *)&cmd_dump_one_name,
9529 /* *** Add/Del syn filter *** */
9530 struct cmd_syn_filter_result {
9531 cmdline_fixed_string_t filter;
9533 cmdline_fixed_string_t ops;
9534 cmdline_fixed_string_t priority;
9535 cmdline_fixed_string_t high;
9536 cmdline_fixed_string_t queue;
9541 cmd_syn_filter_parsed(void *parsed_result,
9542 __attribute__((unused)) struct cmdline *cl,
9543 __attribute__((unused)) void *data)
9545 struct cmd_syn_filter_result *res = parsed_result;
9546 struct rte_eth_syn_filter syn_filter;
9549 ret = rte_eth_dev_filter_supported(res->port_id,
9550 RTE_ETH_FILTER_SYN);
9552 printf("syn filter is not supported on port %u.\n",
9557 memset(&syn_filter, 0, sizeof(syn_filter));
9559 if (!strcmp(res->ops, "add")) {
9560 if (!strcmp(res->high, "high"))
9561 syn_filter.hig_pri = 1;
9563 syn_filter.hig_pri = 0;
9565 syn_filter.queue = res->queue_id;
9566 ret = rte_eth_dev_filter_ctrl(res->port_id,
9571 ret = rte_eth_dev_filter_ctrl(res->port_id,
9573 RTE_ETH_FILTER_DELETE,
9577 printf("syn filter programming error: (%s)\n",
9581 cmdline_parse_token_string_t cmd_syn_filter_filter =
9582 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9583 filter, "syn_filter");
9584 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9585 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9587 cmdline_parse_token_string_t cmd_syn_filter_ops =
9588 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9590 cmdline_parse_token_string_t cmd_syn_filter_priority =
9591 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9592 priority, "priority");
9593 cmdline_parse_token_string_t cmd_syn_filter_high =
9594 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9596 cmdline_parse_token_string_t cmd_syn_filter_queue =
9597 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9599 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9600 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9603 cmdline_parse_inst_t cmd_syn_filter = {
9604 .f = cmd_syn_filter_parsed,
9606 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9607 "<queue_id>: Add/Delete syn filter",
9609 (void *)&cmd_syn_filter_filter,
9610 (void *)&cmd_syn_filter_port_id,
9611 (void *)&cmd_syn_filter_ops,
9612 (void *)&cmd_syn_filter_priority,
9613 (void *)&cmd_syn_filter_high,
9614 (void *)&cmd_syn_filter_queue,
9615 (void *)&cmd_syn_filter_queue_id,
9620 /* *** queue region set *** */
9621 struct cmd_queue_region_result {
9622 cmdline_fixed_string_t set;
9623 cmdline_fixed_string_t port;
9625 cmdline_fixed_string_t cmd;
9626 cmdline_fixed_string_t region;
9628 cmdline_fixed_string_t queue_start_index;
9630 cmdline_fixed_string_t queue_num;
9631 uint8_t queue_num_value;
9635 cmd_queue_region_parsed(void *parsed_result,
9636 __attribute__((unused)) struct cmdline *cl,
9637 __attribute__((unused)) void *data)
9639 struct cmd_queue_region_result *res = parsed_result;
9641 #ifdef RTE_LIBRTE_I40E_PMD
9642 struct rte_pmd_i40e_queue_region_conf region_conf;
9643 enum rte_pmd_i40e_queue_region_op op_type;
9646 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9649 #ifdef RTE_LIBRTE_I40E_PMD
9650 memset(®ion_conf, 0, sizeof(region_conf));
9651 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9652 region_conf.region_id = res->region_id;
9653 region_conf.queue_num = res->queue_num_value;
9654 region_conf.queue_start_index = res->queue_id;
9656 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9657 op_type, ®ion_conf);
9664 printf("function not implemented or supported\n");
9667 printf("queue region config error: (%s)\n", strerror(-ret));
9671 cmdline_parse_token_string_t cmd_queue_region_set =
9672 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9674 cmdline_parse_token_string_t cmd_queue_region_port =
9675 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9676 cmdline_parse_token_num_t cmd_queue_region_port_id =
9677 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9679 cmdline_parse_token_string_t cmd_queue_region_cmd =
9680 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9681 cmd, "queue-region");
9682 cmdline_parse_token_string_t cmd_queue_region_id =
9683 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9684 region, "region_id");
9685 cmdline_parse_token_num_t cmd_queue_region_index =
9686 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9688 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9689 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9690 queue_start_index, "queue_start_index");
9691 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9692 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9694 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9695 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9696 queue_num, "queue_num");
9697 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9698 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9699 queue_num_value, UINT8);
9701 cmdline_parse_inst_t cmd_queue_region = {
9702 .f = cmd_queue_region_parsed,
9704 .help_str = "set port <port_id> queue-region region_id <value> "
9705 "queue_start_index <value> queue_num <value>: Set a queue region",
9707 (void *)&cmd_queue_region_set,
9708 (void *)&cmd_queue_region_port,
9709 (void *)&cmd_queue_region_port_id,
9710 (void *)&cmd_queue_region_cmd,
9711 (void *)&cmd_queue_region_id,
9712 (void *)&cmd_queue_region_index,
9713 (void *)&cmd_queue_region_queue_start_index,
9714 (void *)&cmd_queue_region_queue_id,
9715 (void *)&cmd_queue_region_queue_num,
9716 (void *)&cmd_queue_region_queue_num_value,
9721 /* *** queue region and flowtype set *** */
9722 struct cmd_region_flowtype_result {
9723 cmdline_fixed_string_t set;
9724 cmdline_fixed_string_t port;
9726 cmdline_fixed_string_t cmd;
9727 cmdline_fixed_string_t region;
9729 cmdline_fixed_string_t flowtype;
9730 uint8_t flowtype_id;
9734 cmd_region_flowtype_parsed(void *parsed_result,
9735 __attribute__((unused)) struct cmdline *cl,
9736 __attribute__((unused)) void *data)
9738 struct cmd_region_flowtype_result *res = parsed_result;
9740 #ifdef RTE_LIBRTE_I40E_PMD
9741 struct rte_pmd_i40e_queue_region_conf region_conf;
9742 enum rte_pmd_i40e_queue_region_op op_type;
9745 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9748 #ifdef RTE_LIBRTE_I40E_PMD
9749 memset(®ion_conf, 0, sizeof(region_conf));
9751 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9752 region_conf.region_id = res->region_id;
9753 region_conf.hw_flowtype = res->flowtype_id;
9755 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9756 op_type, ®ion_conf);
9763 printf("function not implemented or supported\n");
9766 printf("region flowtype config error: (%s)\n", strerror(-ret));
9770 cmdline_parse_token_string_t cmd_region_flowtype_set =
9771 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9773 cmdline_parse_token_string_t cmd_region_flowtype_port =
9774 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9776 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9777 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9779 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9780 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9781 cmd, "queue-region");
9782 cmdline_parse_token_string_t cmd_region_flowtype_index =
9783 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9784 region, "region_id");
9785 cmdline_parse_token_num_t cmd_region_flowtype_id =
9786 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9788 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9789 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9790 flowtype, "flowtype");
9791 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9792 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9793 flowtype_id, UINT8);
9794 cmdline_parse_inst_t cmd_region_flowtype = {
9795 .f = cmd_region_flowtype_parsed,
9797 .help_str = "set port <port_id> queue-region region_id <value> "
9798 "flowtype <value>: Set a flowtype region index",
9800 (void *)&cmd_region_flowtype_set,
9801 (void *)&cmd_region_flowtype_port,
9802 (void *)&cmd_region_flowtype_port_index,
9803 (void *)&cmd_region_flowtype_cmd,
9804 (void *)&cmd_region_flowtype_index,
9805 (void *)&cmd_region_flowtype_id,
9806 (void *)&cmd_region_flowtype_flow_index,
9807 (void *)&cmd_region_flowtype_flow_id,
9812 /* *** User Priority (UP) to queue region (region_id) set *** */
9813 struct cmd_user_priority_region_result {
9814 cmdline_fixed_string_t set;
9815 cmdline_fixed_string_t port;
9817 cmdline_fixed_string_t cmd;
9818 cmdline_fixed_string_t user_priority;
9819 uint8_t user_priority_id;
9820 cmdline_fixed_string_t region;
9825 cmd_user_priority_region_parsed(void *parsed_result,
9826 __attribute__((unused)) struct cmdline *cl,
9827 __attribute__((unused)) void *data)
9829 struct cmd_user_priority_region_result *res = parsed_result;
9831 #ifdef RTE_LIBRTE_I40E_PMD
9832 struct rte_pmd_i40e_queue_region_conf region_conf;
9833 enum rte_pmd_i40e_queue_region_op op_type;
9836 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9839 #ifdef RTE_LIBRTE_I40E_PMD
9840 memset(®ion_conf, 0, sizeof(region_conf));
9841 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9842 region_conf.user_priority = res->user_priority_id;
9843 region_conf.region_id = res->region_id;
9845 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9846 op_type, ®ion_conf);
9853 printf("function not implemented or supported\n");
9856 printf("user_priority region config error: (%s)\n",
9861 cmdline_parse_token_string_t cmd_user_priority_region_set =
9862 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9864 cmdline_parse_token_string_t cmd_user_priority_region_port =
9865 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9867 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9868 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9870 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9871 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9872 cmd, "queue-region");
9873 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9874 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9875 user_priority, "UP");
9876 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9877 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9878 user_priority_id, UINT8);
9879 cmdline_parse_token_string_t cmd_user_priority_region_region =
9880 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9881 region, "region_id");
9882 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9883 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9886 cmdline_parse_inst_t cmd_user_priority_region = {
9887 .f = cmd_user_priority_region_parsed,
9889 .help_str = "set port <port_id> queue-region UP <value> "
9890 "region_id <value>: Set the mapping of User Priority (UP) "
9891 "to queue region (region_id) ",
9893 (void *)&cmd_user_priority_region_set,
9894 (void *)&cmd_user_priority_region_port,
9895 (void *)&cmd_user_priority_region_port_index,
9896 (void *)&cmd_user_priority_region_cmd,
9897 (void *)&cmd_user_priority_region_UP,
9898 (void *)&cmd_user_priority_region_UP_id,
9899 (void *)&cmd_user_priority_region_region,
9900 (void *)&cmd_user_priority_region_region_id,
9905 /* *** flush all queue region related configuration *** */
9906 struct cmd_flush_queue_region_result {
9907 cmdline_fixed_string_t set;
9908 cmdline_fixed_string_t port;
9910 cmdline_fixed_string_t cmd;
9911 cmdline_fixed_string_t flush;
9912 cmdline_fixed_string_t what;
9916 cmd_flush_queue_region_parsed(void *parsed_result,
9917 __attribute__((unused)) struct cmdline *cl,
9918 __attribute__((unused)) void *data)
9920 struct cmd_flush_queue_region_result *res = parsed_result;
9922 #ifdef RTE_LIBRTE_I40E_PMD
9923 struct rte_pmd_i40e_queue_region_conf region_conf;
9924 enum rte_pmd_i40e_queue_region_op op_type;
9927 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9930 #ifdef RTE_LIBRTE_I40E_PMD
9931 memset(®ion_conf, 0, sizeof(region_conf));
9933 if (strcmp(res->what, "on") == 0)
9934 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9936 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9938 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9939 op_type, ®ion_conf);
9946 printf("function not implemented or supported\n");
9949 printf("queue region config flush error: (%s)\n",
9954 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9955 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9957 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9958 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9960 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9961 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9963 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9964 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9965 cmd, "queue-region");
9966 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9967 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9969 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9970 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9973 cmdline_parse_inst_t cmd_flush_queue_region = {
9974 .f = cmd_flush_queue_region_parsed,
9976 .help_str = "set port <port_id> queue-region flush on|off"
9977 ": flush all queue region related configuration",
9979 (void *)&cmd_flush_queue_region_set,
9980 (void *)&cmd_flush_queue_region_port,
9981 (void *)&cmd_flush_queue_region_port_index,
9982 (void *)&cmd_flush_queue_region_cmd,
9983 (void *)&cmd_flush_queue_region_flush,
9984 (void *)&cmd_flush_queue_region_what,
9989 /* *** get all queue region related configuration info *** */
9990 struct cmd_show_queue_region_info {
9991 cmdline_fixed_string_t show;
9992 cmdline_fixed_string_t port;
9994 cmdline_fixed_string_t cmd;
9998 cmd_show_queue_region_info_parsed(void *parsed_result,
9999 __attribute__((unused)) struct cmdline *cl,
10000 __attribute__((unused)) void *data)
10002 struct cmd_show_queue_region_info *res = parsed_result;
10003 int ret = -ENOTSUP;
10004 #ifdef RTE_LIBRTE_I40E_PMD
10005 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10006 enum rte_pmd_i40e_queue_region_op op_type;
10009 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10012 #ifdef RTE_LIBRTE_I40E_PMD
10013 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10015 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10017 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10018 op_type, &rte_pmd_regions);
10020 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10027 printf("function not implemented or supported\n");
10030 printf("queue region config info show error: (%s)\n",
10035 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10036 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10038 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10039 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10041 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10042 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10044 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10045 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10046 cmd, "queue-region");
10048 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10049 .f = cmd_show_queue_region_info_parsed,
10051 .help_str = "show port <port_id> queue-region"
10052 ": show all queue region related configuration info",
10054 (void *)&cmd_show_queue_region_info_get,
10055 (void *)&cmd_show_queue_region_info_port,
10056 (void *)&cmd_show_queue_region_info_port_index,
10057 (void *)&cmd_show_queue_region_info_cmd,
10062 /* *** ADD/REMOVE A 2tuple FILTER *** */
10063 struct cmd_2tuple_filter_result {
10064 cmdline_fixed_string_t filter;
10066 cmdline_fixed_string_t ops;
10067 cmdline_fixed_string_t dst_port;
10068 uint16_t dst_port_value;
10069 cmdline_fixed_string_t protocol;
10070 uint8_t protocol_value;
10071 cmdline_fixed_string_t mask;
10072 uint8_t mask_value;
10073 cmdline_fixed_string_t tcp_flags;
10074 uint8_t tcp_flags_value;
10075 cmdline_fixed_string_t priority;
10076 uint8_t priority_value;
10077 cmdline_fixed_string_t queue;
10082 cmd_2tuple_filter_parsed(void *parsed_result,
10083 __attribute__((unused)) struct cmdline *cl,
10084 __attribute__((unused)) void *data)
10086 struct rte_eth_ntuple_filter filter;
10087 struct cmd_2tuple_filter_result *res = parsed_result;
10090 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10092 printf("ntuple filter is not supported on port %u.\n",
10097 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10099 filter.flags = RTE_2TUPLE_FLAGS;
10100 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10101 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10102 filter.proto = res->protocol_value;
10103 filter.priority = res->priority_value;
10104 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10105 printf("nonzero tcp_flags is only meaningful"
10106 " when protocol is TCP.\n");
10109 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10110 printf("invalid TCP flags.\n");
10114 if (res->tcp_flags_value != 0) {
10115 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10116 filter.tcp_flags = res->tcp_flags_value;
10119 /* need convert to big endian. */
10120 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10121 filter.queue = res->queue_id;
10123 if (!strcmp(res->ops, "add"))
10124 ret = rte_eth_dev_filter_ctrl(res->port_id,
10125 RTE_ETH_FILTER_NTUPLE,
10126 RTE_ETH_FILTER_ADD,
10129 ret = rte_eth_dev_filter_ctrl(res->port_id,
10130 RTE_ETH_FILTER_NTUPLE,
10131 RTE_ETH_FILTER_DELETE,
10134 printf("2tuple filter programming error: (%s)\n",
10139 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
10140 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10141 filter, "2tuple_filter");
10142 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
10143 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10145 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
10146 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10148 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
10149 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10150 dst_port, "dst_port");
10151 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
10152 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10153 dst_port_value, UINT16);
10154 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
10155 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10156 protocol, "protocol");
10157 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
10158 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10159 protocol_value, UINT8);
10160 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
10161 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10163 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
10164 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10166 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
10167 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10168 tcp_flags, "tcp_flags");
10169 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
10170 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10171 tcp_flags_value, UINT8);
10172 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
10173 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10174 priority, "priority");
10175 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
10176 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10177 priority_value, UINT8);
10178 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
10179 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
10181 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
10182 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
10185 cmdline_parse_inst_t cmd_2tuple_filter = {
10186 .f = cmd_2tuple_filter_parsed,
10188 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
10189 "<value> mask <value> tcp_flags <value> priority <value> queue "
10190 "<queue_id>: Add a 2tuple filter",
10192 (void *)&cmd_2tuple_filter_filter,
10193 (void *)&cmd_2tuple_filter_port_id,
10194 (void *)&cmd_2tuple_filter_ops,
10195 (void *)&cmd_2tuple_filter_dst_port,
10196 (void *)&cmd_2tuple_filter_dst_port_value,
10197 (void *)&cmd_2tuple_filter_protocol,
10198 (void *)&cmd_2tuple_filter_protocol_value,
10199 (void *)&cmd_2tuple_filter_mask,
10200 (void *)&cmd_2tuple_filter_mask_value,
10201 (void *)&cmd_2tuple_filter_tcp_flags,
10202 (void *)&cmd_2tuple_filter_tcp_flags_value,
10203 (void *)&cmd_2tuple_filter_priority,
10204 (void *)&cmd_2tuple_filter_priority_value,
10205 (void *)&cmd_2tuple_filter_queue,
10206 (void *)&cmd_2tuple_filter_queue_id,
10211 /* *** ADD/REMOVE A 5tuple FILTER *** */
10212 struct cmd_5tuple_filter_result {
10213 cmdline_fixed_string_t filter;
10215 cmdline_fixed_string_t ops;
10216 cmdline_fixed_string_t dst_ip;
10217 cmdline_ipaddr_t dst_ip_value;
10218 cmdline_fixed_string_t src_ip;
10219 cmdline_ipaddr_t src_ip_value;
10220 cmdline_fixed_string_t dst_port;
10221 uint16_t dst_port_value;
10222 cmdline_fixed_string_t src_port;
10223 uint16_t src_port_value;
10224 cmdline_fixed_string_t protocol;
10225 uint8_t protocol_value;
10226 cmdline_fixed_string_t mask;
10227 uint8_t mask_value;
10228 cmdline_fixed_string_t tcp_flags;
10229 uint8_t tcp_flags_value;
10230 cmdline_fixed_string_t priority;
10231 uint8_t priority_value;
10232 cmdline_fixed_string_t queue;
10237 cmd_5tuple_filter_parsed(void *parsed_result,
10238 __attribute__((unused)) struct cmdline *cl,
10239 __attribute__((unused)) void *data)
10241 struct rte_eth_ntuple_filter filter;
10242 struct cmd_5tuple_filter_result *res = parsed_result;
10245 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
10247 printf("ntuple filter is not supported on port %u.\n",
10252 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
10254 filter.flags = RTE_5TUPLE_FLAGS;
10255 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
10256 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
10257 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
10258 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
10259 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
10260 filter.proto = res->protocol_value;
10261 filter.priority = res->priority_value;
10262 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
10263 printf("nonzero tcp_flags is only meaningful"
10264 " when protocol is TCP.\n");
10267 if (res->tcp_flags_value > RTE_NTUPLE_TCP_FLAGS_MASK) {
10268 printf("invalid TCP flags.\n");
10272 if (res->tcp_flags_value != 0) {
10273 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
10274 filter.tcp_flags = res->tcp_flags_value;
10277 if (res->dst_ip_value.family == AF_INET)
10278 /* no need to convert, already big endian. */
10279 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
10281 if (filter.dst_ip_mask == 0) {
10282 printf("can not support ipv6 involved compare.\n");
10288 if (res->src_ip_value.family == AF_INET)
10289 /* no need to convert, already big endian. */
10290 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
10292 if (filter.src_ip_mask == 0) {
10293 printf("can not support ipv6 involved compare.\n");
10298 /* need convert to big endian. */
10299 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
10300 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
10301 filter.queue = res->queue_id;
10303 if (!strcmp(res->ops, "add"))
10304 ret = rte_eth_dev_filter_ctrl(res->port_id,
10305 RTE_ETH_FILTER_NTUPLE,
10306 RTE_ETH_FILTER_ADD,
10309 ret = rte_eth_dev_filter_ctrl(res->port_id,
10310 RTE_ETH_FILTER_NTUPLE,
10311 RTE_ETH_FILTER_DELETE,
10314 printf("5tuple filter programming error: (%s)\n",
10318 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
10319 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10320 filter, "5tuple_filter");
10321 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
10322 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10324 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
10325 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10327 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
10328 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10330 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
10331 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10333 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10334 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10336 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10337 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10339 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10340 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10341 dst_port, "dst_port");
10342 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10343 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10344 dst_port_value, UINT16);
10345 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10346 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10347 src_port, "src_port");
10348 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10349 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10350 src_port_value, UINT16);
10351 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10352 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10353 protocol, "protocol");
10354 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10355 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10356 protocol_value, UINT8);
10357 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10358 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10360 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10361 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10363 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10364 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10365 tcp_flags, "tcp_flags");
10366 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10367 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10368 tcp_flags_value, UINT8);
10369 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10370 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10371 priority, "priority");
10372 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10373 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10374 priority_value, UINT8);
10375 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10376 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10378 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10379 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10382 cmdline_parse_inst_t cmd_5tuple_filter = {
10383 .f = cmd_5tuple_filter_parsed,
10385 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10386 "src_ip <value> dst_port <value> src_port <value> "
10387 "protocol <value> mask <value> tcp_flags <value> "
10388 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10390 (void *)&cmd_5tuple_filter_filter,
10391 (void *)&cmd_5tuple_filter_port_id,
10392 (void *)&cmd_5tuple_filter_ops,
10393 (void *)&cmd_5tuple_filter_dst_ip,
10394 (void *)&cmd_5tuple_filter_dst_ip_value,
10395 (void *)&cmd_5tuple_filter_src_ip,
10396 (void *)&cmd_5tuple_filter_src_ip_value,
10397 (void *)&cmd_5tuple_filter_dst_port,
10398 (void *)&cmd_5tuple_filter_dst_port_value,
10399 (void *)&cmd_5tuple_filter_src_port,
10400 (void *)&cmd_5tuple_filter_src_port_value,
10401 (void *)&cmd_5tuple_filter_protocol,
10402 (void *)&cmd_5tuple_filter_protocol_value,
10403 (void *)&cmd_5tuple_filter_mask,
10404 (void *)&cmd_5tuple_filter_mask_value,
10405 (void *)&cmd_5tuple_filter_tcp_flags,
10406 (void *)&cmd_5tuple_filter_tcp_flags_value,
10407 (void *)&cmd_5tuple_filter_priority,
10408 (void *)&cmd_5tuple_filter_priority_value,
10409 (void *)&cmd_5tuple_filter_queue,
10410 (void *)&cmd_5tuple_filter_queue_id,
10415 /* *** ADD/REMOVE A flex FILTER *** */
10416 struct cmd_flex_filter_result {
10417 cmdline_fixed_string_t filter;
10418 cmdline_fixed_string_t ops;
10420 cmdline_fixed_string_t len;
10422 cmdline_fixed_string_t bytes;
10423 cmdline_fixed_string_t bytes_value;
10424 cmdline_fixed_string_t mask;
10425 cmdline_fixed_string_t mask_value;
10426 cmdline_fixed_string_t priority;
10427 uint8_t priority_value;
10428 cmdline_fixed_string_t queue;
10432 static int xdigit2val(unsigned char c)
10437 else if (isupper(c))
10438 val = c - 'A' + 10;
10440 val = c - 'a' + 10;
10445 cmd_flex_filter_parsed(void *parsed_result,
10446 __attribute__((unused)) struct cmdline *cl,
10447 __attribute__((unused)) void *data)
10450 struct rte_eth_flex_filter filter;
10451 struct cmd_flex_filter_result *res = parsed_result;
10452 char *bytes_ptr, *mask_ptr;
10453 uint16_t len, i, j = 0;
10458 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10459 printf("the len exceed the max length 128\n");
10462 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10463 filter.len = res->len_value;
10464 filter.priority = res->priority_value;
10465 filter.queue = res->queue_id;
10466 bytes_ptr = res->bytes_value;
10467 mask_ptr = res->mask_value;
10469 /* translate bytes string to array. */
10470 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10471 (bytes_ptr[1] == 'X')))
10473 len = strnlen(bytes_ptr, res->len_value * 2);
10474 if (len == 0 || (len % 8 != 0)) {
10475 printf("please check len and bytes input\n");
10478 for (i = 0; i < len; i++) {
10480 if (isxdigit(c) == 0) {
10481 /* invalid characters. */
10482 printf("invalid input\n");
10485 val = xdigit2val(c);
10488 filter.bytes[j] = byte;
10489 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10496 /* translate mask string to uint8_t array. */
10497 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10498 (mask_ptr[1] == 'X')))
10500 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10502 printf("invalid input\n");
10507 for (i = 0; i < len; i++) {
10509 if (isxdigit(c) == 0) {
10510 /* invalid characters. */
10511 printf("invalid input\n");
10514 val = xdigit2val(c);
10517 filter.mask[j] = byte;
10518 printf("mask[%d]:%02x ", j, filter.mask[j]);
10526 if (!strcmp(res->ops, "add"))
10527 ret = rte_eth_dev_filter_ctrl(res->port_id,
10528 RTE_ETH_FILTER_FLEXIBLE,
10529 RTE_ETH_FILTER_ADD,
10532 ret = rte_eth_dev_filter_ctrl(res->port_id,
10533 RTE_ETH_FILTER_FLEXIBLE,
10534 RTE_ETH_FILTER_DELETE,
10538 printf("flex filter setting error: (%s)\n", strerror(-ret));
10541 cmdline_parse_token_string_t cmd_flex_filter_filter =
10542 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10543 filter, "flex_filter");
10544 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10545 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10547 cmdline_parse_token_string_t cmd_flex_filter_ops =
10548 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10550 cmdline_parse_token_string_t cmd_flex_filter_len =
10551 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10553 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10554 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10556 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10557 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10559 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10560 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10561 bytes_value, NULL);
10562 cmdline_parse_token_string_t cmd_flex_filter_mask =
10563 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10565 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10566 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10568 cmdline_parse_token_string_t cmd_flex_filter_priority =
10569 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10570 priority, "priority");
10571 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10572 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10573 priority_value, UINT8);
10574 cmdline_parse_token_string_t cmd_flex_filter_queue =
10575 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10577 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10578 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10580 cmdline_parse_inst_t cmd_flex_filter = {
10581 .f = cmd_flex_filter_parsed,
10583 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10584 "<value> mask <value> priority <value> queue <queue_id>: "
10585 "Add/Del a flex filter",
10587 (void *)&cmd_flex_filter_filter,
10588 (void *)&cmd_flex_filter_port_id,
10589 (void *)&cmd_flex_filter_ops,
10590 (void *)&cmd_flex_filter_len,
10591 (void *)&cmd_flex_filter_len_value,
10592 (void *)&cmd_flex_filter_bytes,
10593 (void *)&cmd_flex_filter_bytes_value,
10594 (void *)&cmd_flex_filter_mask,
10595 (void *)&cmd_flex_filter_mask_value,
10596 (void *)&cmd_flex_filter_priority,
10597 (void *)&cmd_flex_filter_priority_value,
10598 (void *)&cmd_flex_filter_queue,
10599 (void *)&cmd_flex_filter_queue_id,
10604 /* *** Filters Control *** */
10606 /* *** deal with ethertype filter *** */
10607 struct cmd_ethertype_filter_result {
10608 cmdline_fixed_string_t filter;
10610 cmdline_fixed_string_t ops;
10611 cmdline_fixed_string_t mac;
10612 struct rte_ether_addr mac_addr;
10613 cmdline_fixed_string_t ethertype;
10614 uint16_t ethertype_value;
10615 cmdline_fixed_string_t drop;
10616 cmdline_fixed_string_t queue;
10620 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10621 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10622 filter, "ethertype_filter");
10623 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10624 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10626 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10627 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10629 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10630 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10631 mac, "mac_addr#mac_ignr");
10632 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10633 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10635 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10636 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10637 ethertype, "ethertype");
10638 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10639 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10640 ethertype_value, UINT16);
10641 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10642 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10644 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10645 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10647 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10648 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10652 cmd_ethertype_filter_parsed(void *parsed_result,
10653 __attribute__((unused)) struct cmdline *cl,
10654 __attribute__((unused)) void *data)
10656 struct cmd_ethertype_filter_result *res = parsed_result;
10657 struct rte_eth_ethertype_filter filter;
10660 ret = rte_eth_dev_filter_supported(res->port_id,
10661 RTE_ETH_FILTER_ETHERTYPE);
10663 printf("ethertype filter is not supported on port %u.\n",
10668 memset(&filter, 0, sizeof(filter));
10669 if (!strcmp(res->mac, "mac_addr")) {
10670 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10671 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10672 sizeof(struct rte_ether_addr));
10674 if (!strcmp(res->drop, "drop"))
10675 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10676 filter.ether_type = res->ethertype_value;
10677 filter.queue = res->queue_id;
10679 if (!strcmp(res->ops, "add"))
10680 ret = rte_eth_dev_filter_ctrl(res->port_id,
10681 RTE_ETH_FILTER_ETHERTYPE,
10682 RTE_ETH_FILTER_ADD,
10685 ret = rte_eth_dev_filter_ctrl(res->port_id,
10686 RTE_ETH_FILTER_ETHERTYPE,
10687 RTE_ETH_FILTER_DELETE,
10690 printf("ethertype filter programming error: (%s)\n",
10694 cmdline_parse_inst_t cmd_ethertype_filter = {
10695 .f = cmd_ethertype_filter_parsed,
10697 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10698 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10699 "Add or delete an ethertype filter entry",
10701 (void *)&cmd_ethertype_filter_filter,
10702 (void *)&cmd_ethertype_filter_port_id,
10703 (void *)&cmd_ethertype_filter_ops,
10704 (void *)&cmd_ethertype_filter_mac,
10705 (void *)&cmd_ethertype_filter_mac_addr,
10706 (void *)&cmd_ethertype_filter_ethertype,
10707 (void *)&cmd_ethertype_filter_ethertype_value,
10708 (void *)&cmd_ethertype_filter_drop,
10709 (void *)&cmd_ethertype_filter_queue,
10710 (void *)&cmd_ethertype_filter_queue_id,
10715 /* *** deal with flow director filter *** */
10716 struct cmd_flow_director_result {
10717 cmdline_fixed_string_t flow_director_filter;
10719 cmdline_fixed_string_t mode;
10720 cmdline_fixed_string_t mode_value;
10721 cmdline_fixed_string_t ops;
10722 cmdline_fixed_string_t flow;
10723 cmdline_fixed_string_t flow_type;
10724 cmdline_fixed_string_t ether;
10725 uint16_t ether_type;
10726 cmdline_fixed_string_t src;
10727 cmdline_ipaddr_t ip_src;
10729 cmdline_fixed_string_t dst;
10730 cmdline_ipaddr_t ip_dst;
10732 cmdline_fixed_string_t verify_tag;
10733 uint32_t verify_tag_value;
10734 cmdline_fixed_string_t tos;
10736 cmdline_fixed_string_t proto;
10737 uint8_t proto_value;
10738 cmdline_fixed_string_t ttl;
10740 cmdline_fixed_string_t vlan;
10741 uint16_t vlan_value;
10742 cmdline_fixed_string_t flexbytes;
10743 cmdline_fixed_string_t flexbytes_value;
10744 cmdline_fixed_string_t pf_vf;
10745 cmdline_fixed_string_t drop;
10746 cmdline_fixed_string_t queue;
10748 cmdline_fixed_string_t fd_id;
10749 uint32_t fd_id_value;
10750 cmdline_fixed_string_t mac;
10751 struct rte_ether_addr mac_addr;
10752 cmdline_fixed_string_t tunnel;
10753 cmdline_fixed_string_t tunnel_type;
10754 cmdline_fixed_string_t tunnel_id;
10755 uint32_t tunnel_id_value;
10756 cmdline_fixed_string_t packet;
10761 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10764 const char *p, *p0 = q_arg;
10766 unsigned long int_fld;
10767 char *str_fld[max_num];
10772 p = strchr(p0, '(');
10776 p0 = strchr(p, ')');
10781 if (size >= sizeof(s))
10784 snprintf(s, sizeof(s), "%.*s", size, p);
10785 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10786 if (ret < 0 || ret > max_num)
10788 for (i = 0; i < ret; i++) {
10790 int_fld = strtoul(str_fld[i], &end, 0);
10791 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10793 flexbytes[i] = (uint8_t)int_fld;
10799 str2flowtype(char *string)
10802 static const struct {
10805 } flowtype_str[] = {
10806 {"raw", RTE_ETH_FLOW_RAW},
10807 {"ipv4", RTE_ETH_FLOW_IPV4},
10808 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10809 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10810 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10811 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10812 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10813 {"ipv6", RTE_ETH_FLOW_IPV6},
10814 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10815 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10816 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10817 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10818 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10819 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10822 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10823 if (!strcmp(flowtype_str[i].str, string))
10824 return flowtype_str[i].type;
10827 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10828 return (uint16_t)atoi(string);
10830 return RTE_ETH_FLOW_UNKNOWN;
10833 static enum rte_eth_fdir_tunnel_type
10834 str2fdir_tunneltype(char *string)
10838 static const struct {
10840 enum rte_eth_fdir_tunnel_type type;
10841 } tunneltype_str[] = {
10842 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10843 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10846 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10847 if (!strcmp(tunneltype_str[i].str, string))
10848 return tunneltype_str[i].type;
10850 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10853 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10855 if ((ip_addr).family == AF_INET) \
10856 (ip) = (ip_addr).addr.ipv4.s_addr; \
10858 printf("invalid parameter.\n"); \
10863 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10865 if ((ip_addr).family == AF_INET6) \
10866 rte_memcpy(&(ip), \
10867 &((ip_addr).addr.ipv6), \
10868 sizeof(struct in6_addr)); \
10870 printf("invalid parameter.\n"); \
10876 cmd_flow_director_filter_parsed(void *parsed_result,
10877 __attribute__((unused)) struct cmdline *cl,
10878 __attribute__((unused)) void *data)
10880 struct cmd_flow_director_result *res = parsed_result;
10881 struct rte_eth_fdir_filter entry;
10882 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10884 unsigned long vf_id;
10887 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10889 printf("flow director is not supported on port %u.\n",
10893 memset(flexbytes, 0, sizeof(flexbytes));
10894 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10896 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10897 if (strcmp(res->mode_value, "MAC-VLAN")) {
10898 printf("Please set mode to MAC-VLAN.\n");
10901 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10902 if (strcmp(res->mode_value, "Tunnel")) {
10903 printf("Please set mode to Tunnel.\n");
10907 if (!strcmp(res->mode_value, "raw")) {
10908 #ifdef RTE_LIBRTE_I40E_PMD
10909 struct rte_pmd_i40e_flow_type_mapping
10910 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10911 struct rte_pmd_i40e_pkt_template_conf conf;
10912 uint16_t flow_type = str2flowtype(res->flow_type);
10913 uint16_t i, port = res->port_id;
10916 memset(&conf, 0, sizeof(conf));
10918 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10919 printf("Invalid flow type specified.\n");
10922 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10926 if (mapping[flow_type].pctype == 0ULL) {
10927 printf("Invalid flow type specified.\n");
10930 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10931 if (mapping[flow_type].pctype & (1ULL << i)) {
10932 conf.input.pctype = i;
10937 conf.input.packet = open_file(res->filepath,
10938 &conf.input.length);
10939 if (!conf.input.packet)
10941 if (!strcmp(res->drop, "drop"))
10942 conf.action.behavior =
10943 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10945 conf.action.behavior =
10946 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10947 conf.action.report_status =
10948 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10949 conf.action.rx_queue = res->queue_id;
10950 conf.soft_id = res->fd_id_value;
10951 add = strcmp(res->ops, "del") ? 1 : 0;
10952 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10956 printf("flow director config error: (%s)\n",
10958 close_file(conf.input.packet);
10961 } else if (strcmp(res->mode_value, "IP")) {
10962 printf("Please set mode to IP or raw.\n");
10965 entry.input.flow_type = str2flowtype(res->flow_type);
10968 ret = parse_flexbytes(res->flexbytes_value,
10970 RTE_ETH_FDIR_MAX_FLEXLEN);
10972 printf("error: Cannot parse flexbytes input.\n");
10976 switch (entry.input.flow_type) {
10977 case RTE_ETH_FLOW_FRAG_IPV4:
10978 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10979 entry.input.flow.ip4_flow.proto = res->proto_value;
10981 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10982 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10983 IPV4_ADDR_TO_UINT(res->ip_dst,
10984 entry.input.flow.ip4_flow.dst_ip);
10985 IPV4_ADDR_TO_UINT(res->ip_src,
10986 entry.input.flow.ip4_flow.src_ip);
10987 entry.input.flow.ip4_flow.tos = res->tos_value;
10988 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10989 /* need convert to big endian. */
10990 entry.input.flow.udp4_flow.dst_port =
10991 rte_cpu_to_be_16(res->port_dst);
10992 entry.input.flow.udp4_flow.src_port =
10993 rte_cpu_to_be_16(res->port_src);
10995 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10996 IPV4_ADDR_TO_UINT(res->ip_dst,
10997 entry.input.flow.sctp4_flow.ip.dst_ip);
10998 IPV4_ADDR_TO_UINT(res->ip_src,
10999 entry.input.flow.sctp4_flow.ip.src_ip);
11000 entry.input.flow.ip4_flow.tos = res->tos_value;
11001 entry.input.flow.ip4_flow.ttl = res->ttl_value;
11002 /* need convert to big endian. */
11003 entry.input.flow.sctp4_flow.dst_port =
11004 rte_cpu_to_be_16(res->port_dst);
11005 entry.input.flow.sctp4_flow.src_port =
11006 rte_cpu_to_be_16(res->port_src);
11007 entry.input.flow.sctp4_flow.verify_tag =
11008 rte_cpu_to_be_32(res->verify_tag_value);
11010 case RTE_ETH_FLOW_FRAG_IPV6:
11011 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
11012 entry.input.flow.ipv6_flow.proto = res->proto_value;
11014 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
11015 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
11016 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11017 entry.input.flow.ipv6_flow.dst_ip);
11018 IPV6_ADDR_TO_ARRAY(res->ip_src,
11019 entry.input.flow.ipv6_flow.src_ip);
11020 entry.input.flow.ipv6_flow.tc = res->tos_value;
11021 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11022 /* need convert to big endian. */
11023 entry.input.flow.udp6_flow.dst_port =
11024 rte_cpu_to_be_16(res->port_dst);
11025 entry.input.flow.udp6_flow.src_port =
11026 rte_cpu_to_be_16(res->port_src);
11028 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
11029 IPV6_ADDR_TO_ARRAY(res->ip_dst,
11030 entry.input.flow.sctp6_flow.ip.dst_ip);
11031 IPV6_ADDR_TO_ARRAY(res->ip_src,
11032 entry.input.flow.sctp6_flow.ip.src_ip);
11033 entry.input.flow.ipv6_flow.tc = res->tos_value;
11034 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
11035 /* need convert to big endian. */
11036 entry.input.flow.sctp6_flow.dst_port =
11037 rte_cpu_to_be_16(res->port_dst);
11038 entry.input.flow.sctp6_flow.src_port =
11039 rte_cpu_to_be_16(res->port_src);
11040 entry.input.flow.sctp6_flow.verify_tag =
11041 rte_cpu_to_be_32(res->verify_tag_value);
11043 case RTE_ETH_FLOW_L2_PAYLOAD:
11044 entry.input.flow.l2_flow.ether_type =
11045 rte_cpu_to_be_16(res->ether_type);
11051 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
11052 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
11054 sizeof(struct rte_ether_addr));
11056 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11057 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
11059 sizeof(struct rte_ether_addr));
11060 entry.input.flow.tunnel_flow.tunnel_type =
11061 str2fdir_tunneltype(res->tunnel_type);
11062 entry.input.flow.tunnel_flow.tunnel_id =
11063 rte_cpu_to_be_32(res->tunnel_id_value);
11066 rte_memcpy(entry.input.flow_ext.flexbytes,
11068 RTE_ETH_FDIR_MAX_FLEXLEN);
11070 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
11072 entry.action.flex_off = 0; /*use 0 by default */
11073 if (!strcmp(res->drop, "drop"))
11074 entry.action.behavior = RTE_ETH_FDIR_REJECT;
11076 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
11078 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
11079 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
11080 if (!strcmp(res->pf_vf, "pf"))
11081 entry.input.flow_ext.is_vf = 0;
11082 else if (!strncmp(res->pf_vf, "vf", 2)) {
11083 struct rte_eth_dev_info dev_info;
11085 memset(&dev_info, 0, sizeof(dev_info));
11086 rte_eth_dev_info_get(res->port_id, &dev_info);
11088 vf_id = strtoul(res->pf_vf + 2, &end, 10);
11089 if (errno != 0 || *end != '\0' ||
11090 vf_id >= dev_info.max_vfs) {
11091 printf("invalid parameter %s.\n", res->pf_vf);
11094 entry.input.flow_ext.is_vf = 1;
11095 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
11097 printf("invalid parameter %s.\n", res->pf_vf);
11102 /* set to report FD ID by default */
11103 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
11104 entry.action.rx_queue = res->queue_id;
11105 entry.soft_id = res->fd_id_value;
11106 if (!strcmp(res->ops, "add"))
11107 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11108 RTE_ETH_FILTER_ADD, &entry);
11109 else if (!strcmp(res->ops, "del"))
11110 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11111 RTE_ETH_FILTER_DELETE, &entry);
11113 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11114 RTE_ETH_FILTER_UPDATE, &entry);
11116 printf("flow director programming error: (%s)\n",
11120 cmdline_parse_token_string_t cmd_flow_director_filter =
11121 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11122 flow_director_filter, "flow_director_filter");
11123 cmdline_parse_token_num_t cmd_flow_director_port_id =
11124 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11126 cmdline_parse_token_string_t cmd_flow_director_ops =
11127 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11128 ops, "add#del#update");
11129 cmdline_parse_token_string_t cmd_flow_director_flow =
11130 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11132 cmdline_parse_token_string_t cmd_flow_director_flow_type =
11133 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11135 cmdline_parse_token_string_t cmd_flow_director_ether =
11136 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11138 cmdline_parse_token_num_t cmd_flow_director_ether_type =
11139 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11140 ether_type, UINT16);
11141 cmdline_parse_token_string_t cmd_flow_director_src =
11142 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11144 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
11145 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11147 cmdline_parse_token_num_t cmd_flow_director_port_src =
11148 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11150 cmdline_parse_token_string_t cmd_flow_director_dst =
11151 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11153 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
11154 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
11156 cmdline_parse_token_num_t cmd_flow_director_port_dst =
11157 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11159 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
11160 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11161 verify_tag, "verify_tag");
11162 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
11163 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11164 verify_tag_value, UINT32);
11165 cmdline_parse_token_string_t cmd_flow_director_tos =
11166 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11168 cmdline_parse_token_num_t cmd_flow_director_tos_value =
11169 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11171 cmdline_parse_token_string_t cmd_flow_director_proto =
11172 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11174 cmdline_parse_token_num_t cmd_flow_director_proto_value =
11175 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11176 proto_value, UINT8);
11177 cmdline_parse_token_string_t cmd_flow_director_ttl =
11178 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11180 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
11181 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11183 cmdline_parse_token_string_t cmd_flow_director_vlan =
11184 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11186 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
11187 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11188 vlan_value, UINT16);
11189 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
11190 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11191 flexbytes, "flexbytes");
11192 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
11193 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11194 flexbytes_value, NULL);
11195 cmdline_parse_token_string_t cmd_flow_director_drop =
11196 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11198 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
11199 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11201 cmdline_parse_token_string_t cmd_flow_director_queue =
11202 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11204 cmdline_parse_token_num_t cmd_flow_director_queue_id =
11205 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11207 cmdline_parse_token_string_t cmd_flow_director_fd_id =
11208 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11210 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
11211 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11212 fd_id_value, UINT32);
11214 cmdline_parse_token_string_t cmd_flow_director_mode =
11215 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11217 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
11218 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11220 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
11221 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11222 mode_value, "MAC-VLAN");
11223 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
11224 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11225 mode_value, "Tunnel");
11226 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
11227 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11228 mode_value, "raw");
11229 cmdline_parse_token_string_t cmd_flow_director_mac =
11230 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11232 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
11233 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
11235 cmdline_parse_token_string_t cmd_flow_director_tunnel =
11236 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11238 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
11239 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11240 tunnel_type, "NVGRE#VxLAN");
11241 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
11242 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11243 tunnel_id, "tunnel-id");
11244 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
11245 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
11246 tunnel_id_value, UINT32);
11247 cmdline_parse_token_string_t cmd_flow_director_packet =
11248 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11250 cmdline_parse_token_string_t cmd_flow_director_filepath =
11251 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
11254 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
11255 .f = cmd_flow_director_filter_parsed,
11257 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
11258 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
11259 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
11260 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
11261 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
11262 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
11263 "fd_id <fd_id_value>: "
11264 "Add or delete an ip flow director entry on NIC",
11266 (void *)&cmd_flow_director_filter,
11267 (void *)&cmd_flow_director_port_id,
11268 (void *)&cmd_flow_director_mode,
11269 (void *)&cmd_flow_director_mode_ip,
11270 (void *)&cmd_flow_director_ops,
11271 (void *)&cmd_flow_director_flow,
11272 (void *)&cmd_flow_director_flow_type,
11273 (void *)&cmd_flow_director_src,
11274 (void *)&cmd_flow_director_ip_src,
11275 (void *)&cmd_flow_director_dst,
11276 (void *)&cmd_flow_director_ip_dst,
11277 (void *)&cmd_flow_director_tos,
11278 (void *)&cmd_flow_director_tos_value,
11279 (void *)&cmd_flow_director_proto,
11280 (void *)&cmd_flow_director_proto_value,
11281 (void *)&cmd_flow_director_ttl,
11282 (void *)&cmd_flow_director_ttl_value,
11283 (void *)&cmd_flow_director_vlan,
11284 (void *)&cmd_flow_director_vlan_value,
11285 (void *)&cmd_flow_director_flexbytes,
11286 (void *)&cmd_flow_director_flexbytes_value,
11287 (void *)&cmd_flow_director_drop,
11288 (void *)&cmd_flow_director_pf_vf,
11289 (void *)&cmd_flow_director_queue,
11290 (void *)&cmd_flow_director_queue_id,
11291 (void *)&cmd_flow_director_fd_id,
11292 (void *)&cmd_flow_director_fd_id_value,
11297 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
11298 .f = cmd_flow_director_filter_parsed,
11300 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
11301 "director entry on NIC",
11303 (void *)&cmd_flow_director_filter,
11304 (void *)&cmd_flow_director_port_id,
11305 (void *)&cmd_flow_director_mode,
11306 (void *)&cmd_flow_director_mode_ip,
11307 (void *)&cmd_flow_director_ops,
11308 (void *)&cmd_flow_director_flow,
11309 (void *)&cmd_flow_director_flow_type,
11310 (void *)&cmd_flow_director_src,
11311 (void *)&cmd_flow_director_ip_src,
11312 (void *)&cmd_flow_director_port_src,
11313 (void *)&cmd_flow_director_dst,
11314 (void *)&cmd_flow_director_ip_dst,
11315 (void *)&cmd_flow_director_port_dst,
11316 (void *)&cmd_flow_director_tos,
11317 (void *)&cmd_flow_director_tos_value,
11318 (void *)&cmd_flow_director_ttl,
11319 (void *)&cmd_flow_director_ttl_value,
11320 (void *)&cmd_flow_director_vlan,
11321 (void *)&cmd_flow_director_vlan_value,
11322 (void *)&cmd_flow_director_flexbytes,
11323 (void *)&cmd_flow_director_flexbytes_value,
11324 (void *)&cmd_flow_director_drop,
11325 (void *)&cmd_flow_director_pf_vf,
11326 (void *)&cmd_flow_director_queue,
11327 (void *)&cmd_flow_director_queue_id,
11328 (void *)&cmd_flow_director_fd_id,
11329 (void *)&cmd_flow_director_fd_id_value,
11334 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11335 .f = cmd_flow_director_filter_parsed,
11337 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11338 "director entry on NIC",
11340 (void *)&cmd_flow_director_filter,
11341 (void *)&cmd_flow_director_port_id,
11342 (void *)&cmd_flow_director_mode,
11343 (void *)&cmd_flow_director_mode_ip,
11344 (void *)&cmd_flow_director_ops,
11345 (void *)&cmd_flow_director_flow,
11346 (void *)&cmd_flow_director_flow_type,
11347 (void *)&cmd_flow_director_src,
11348 (void *)&cmd_flow_director_ip_src,
11349 (void *)&cmd_flow_director_port_src,
11350 (void *)&cmd_flow_director_dst,
11351 (void *)&cmd_flow_director_ip_dst,
11352 (void *)&cmd_flow_director_port_dst,
11353 (void *)&cmd_flow_director_verify_tag,
11354 (void *)&cmd_flow_director_verify_tag_value,
11355 (void *)&cmd_flow_director_tos,
11356 (void *)&cmd_flow_director_tos_value,
11357 (void *)&cmd_flow_director_ttl,
11358 (void *)&cmd_flow_director_ttl_value,
11359 (void *)&cmd_flow_director_vlan,
11360 (void *)&cmd_flow_director_vlan_value,
11361 (void *)&cmd_flow_director_flexbytes,
11362 (void *)&cmd_flow_director_flexbytes_value,
11363 (void *)&cmd_flow_director_drop,
11364 (void *)&cmd_flow_director_pf_vf,
11365 (void *)&cmd_flow_director_queue,
11366 (void *)&cmd_flow_director_queue_id,
11367 (void *)&cmd_flow_director_fd_id,
11368 (void *)&cmd_flow_director_fd_id_value,
11373 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11374 .f = cmd_flow_director_filter_parsed,
11376 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11377 "director entry on NIC",
11379 (void *)&cmd_flow_director_filter,
11380 (void *)&cmd_flow_director_port_id,
11381 (void *)&cmd_flow_director_mode,
11382 (void *)&cmd_flow_director_mode_ip,
11383 (void *)&cmd_flow_director_ops,
11384 (void *)&cmd_flow_director_flow,
11385 (void *)&cmd_flow_director_flow_type,
11386 (void *)&cmd_flow_director_ether,
11387 (void *)&cmd_flow_director_ether_type,
11388 (void *)&cmd_flow_director_flexbytes,
11389 (void *)&cmd_flow_director_flexbytes_value,
11390 (void *)&cmd_flow_director_drop,
11391 (void *)&cmd_flow_director_pf_vf,
11392 (void *)&cmd_flow_director_queue,
11393 (void *)&cmd_flow_director_queue_id,
11394 (void *)&cmd_flow_director_fd_id,
11395 (void *)&cmd_flow_director_fd_id_value,
11400 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11401 .f = cmd_flow_director_filter_parsed,
11403 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11404 "director entry on NIC",
11406 (void *)&cmd_flow_director_filter,
11407 (void *)&cmd_flow_director_port_id,
11408 (void *)&cmd_flow_director_mode,
11409 (void *)&cmd_flow_director_mode_mac_vlan,
11410 (void *)&cmd_flow_director_ops,
11411 (void *)&cmd_flow_director_mac,
11412 (void *)&cmd_flow_director_mac_addr,
11413 (void *)&cmd_flow_director_vlan,
11414 (void *)&cmd_flow_director_vlan_value,
11415 (void *)&cmd_flow_director_flexbytes,
11416 (void *)&cmd_flow_director_flexbytes_value,
11417 (void *)&cmd_flow_director_drop,
11418 (void *)&cmd_flow_director_queue,
11419 (void *)&cmd_flow_director_queue_id,
11420 (void *)&cmd_flow_director_fd_id,
11421 (void *)&cmd_flow_director_fd_id_value,
11426 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11427 .f = cmd_flow_director_filter_parsed,
11429 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11430 "director entry on NIC",
11432 (void *)&cmd_flow_director_filter,
11433 (void *)&cmd_flow_director_port_id,
11434 (void *)&cmd_flow_director_mode,
11435 (void *)&cmd_flow_director_mode_tunnel,
11436 (void *)&cmd_flow_director_ops,
11437 (void *)&cmd_flow_director_mac,
11438 (void *)&cmd_flow_director_mac_addr,
11439 (void *)&cmd_flow_director_vlan,
11440 (void *)&cmd_flow_director_vlan_value,
11441 (void *)&cmd_flow_director_tunnel,
11442 (void *)&cmd_flow_director_tunnel_type,
11443 (void *)&cmd_flow_director_tunnel_id,
11444 (void *)&cmd_flow_director_tunnel_id_value,
11445 (void *)&cmd_flow_director_flexbytes,
11446 (void *)&cmd_flow_director_flexbytes_value,
11447 (void *)&cmd_flow_director_drop,
11448 (void *)&cmd_flow_director_queue,
11449 (void *)&cmd_flow_director_queue_id,
11450 (void *)&cmd_flow_director_fd_id,
11451 (void *)&cmd_flow_director_fd_id_value,
11456 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11457 .f = cmd_flow_director_filter_parsed,
11459 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11460 "director entry on NIC",
11462 (void *)&cmd_flow_director_filter,
11463 (void *)&cmd_flow_director_port_id,
11464 (void *)&cmd_flow_director_mode,
11465 (void *)&cmd_flow_director_mode_raw,
11466 (void *)&cmd_flow_director_ops,
11467 (void *)&cmd_flow_director_flow,
11468 (void *)&cmd_flow_director_flow_type,
11469 (void *)&cmd_flow_director_drop,
11470 (void *)&cmd_flow_director_queue,
11471 (void *)&cmd_flow_director_queue_id,
11472 (void *)&cmd_flow_director_fd_id,
11473 (void *)&cmd_flow_director_fd_id_value,
11474 (void *)&cmd_flow_director_packet,
11475 (void *)&cmd_flow_director_filepath,
11480 struct cmd_flush_flow_director_result {
11481 cmdline_fixed_string_t flush_flow_director;
11485 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11486 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11487 flush_flow_director, "flush_flow_director");
11488 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11489 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11493 cmd_flush_flow_director_parsed(void *parsed_result,
11494 __attribute__((unused)) struct cmdline *cl,
11495 __attribute__((unused)) void *data)
11497 struct cmd_flow_director_result *res = parsed_result;
11500 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11502 printf("flow director is not supported on port %u.\n",
11507 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11508 RTE_ETH_FILTER_FLUSH, NULL);
11510 printf("flow director table flushing error: (%s)\n",
11514 cmdline_parse_inst_t cmd_flush_flow_director = {
11515 .f = cmd_flush_flow_director_parsed,
11517 .help_str = "flush_flow_director <port_id>: "
11518 "Flush all flow director entries of a device on NIC",
11520 (void *)&cmd_flush_flow_director_flush,
11521 (void *)&cmd_flush_flow_director_port_id,
11526 /* *** deal with flow director mask *** */
11527 struct cmd_flow_director_mask_result {
11528 cmdline_fixed_string_t flow_director_mask;
11530 cmdline_fixed_string_t mode;
11531 cmdline_fixed_string_t mode_value;
11532 cmdline_fixed_string_t vlan;
11533 uint16_t vlan_mask;
11534 cmdline_fixed_string_t src_mask;
11535 cmdline_ipaddr_t ipv4_src;
11536 cmdline_ipaddr_t ipv6_src;
11538 cmdline_fixed_string_t dst_mask;
11539 cmdline_ipaddr_t ipv4_dst;
11540 cmdline_ipaddr_t ipv6_dst;
11542 cmdline_fixed_string_t mac;
11543 uint8_t mac_addr_byte_mask;
11544 cmdline_fixed_string_t tunnel_id;
11545 uint32_t tunnel_id_mask;
11546 cmdline_fixed_string_t tunnel_type;
11547 uint8_t tunnel_type_mask;
11551 cmd_flow_director_mask_parsed(void *parsed_result,
11552 __attribute__((unused)) struct cmdline *cl,
11553 __attribute__((unused)) void *data)
11555 struct cmd_flow_director_mask_result *res = parsed_result;
11556 struct rte_eth_fdir_masks *mask;
11557 struct rte_port *port;
11559 port = &ports[res->port_id];
11560 /** Check if the port is not started **/
11561 if (port->port_status != RTE_PORT_STOPPED) {
11562 printf("Please stop port %d first\n", res->port_id);
11566 mask = &port->dev_conf.fdir_conf.mask;
11568 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11569 if (strcmp(res->mode_value, "MAC-VLAN")) {
11570 printf("Please set mode to MAC-VLAN.\n");
11574 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11575 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11576 if (strcmp(res->mode_value, "Tunnel")) {
11577 printf("Please set mode to Tunnel.\n");
11581 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11582 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11583 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11584 mask->tunnel_type_mask = res->tunnel_type_mask;
11586 if (strcmp(res->mode_value, "IP")) {
11587 printf("Please set mode to IP.\n");
11591 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11592 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11593 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11594 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11595 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11596 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11597 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11600 cmd_reconfig_device_queue(res->port_id, 1, 1);
11603 cmdline_parse_token_string_t cmd_flow_director_mask =
11604 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11605 flow_director_mask, "flow_director_mask");
11606 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11607 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11609 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11610 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11612 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11613 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11614 vlan_mask, UINT16);
11615 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11616 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11617 src_mask, "src_mask");
11618 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11619 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11621 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11622 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11624 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11625 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11627 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11628 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11629 dst_mask, "dst_mask");
11630 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11631 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11633 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11634 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11636 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11637 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11640 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11641 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11643 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11644 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11646 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11647 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11648 mode_value, "MAC-VLAN");
11649 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11650 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11651 mode_value, "Tunnel");
11652 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11653 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11655 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11656 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11657 mac_addr_byte_mask, UINT8);
11658 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11659 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11660 tunnel_type, "tunnel-type");
11661 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11662 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11663 tunnel_type_mask, UINT8);
11664 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11665 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11666 tunnel_id, "tunnel-id");
11667 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11668 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11669 tunnel_id_mask, UINT32);
11671 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11672 .f = cmd_flow_director_mask_parsed,
11674 .help_str = "flow_director_mask ... : "
11675 "Set IP mode flow director's mask on NIC",
11677 (void *)&cmd_flow_director_mask,
11678 (void *)&cmd_flow_director_mask_port_id,
11679 (void *)&cmd_flow_director_mask_mode,
11680 (void *)&cmd_flow_director_mask_mode_ip,
11681 (void *)&cmd_flow_director_mask_vlan,
11682 (void *)&cmd_flow_director_mask_vlan_value,
11683 (void *)&cmd_flow_director_mask_src,
11684 (void *)&cmd_flow_director_mask_ipv4_src,
11685 (void *)&cmd_flow_director_mask_ipv6_src,
11686 (void *)&cmd_flow_director_mask_port_src,
11687 (void *)&cmd_flow_director_mask_dst,
11688 (void *)&cmd_flow_director_mask_ipv4_dst,
11689 (void *)&cmd_flow_director_mask_ipv6_dst,
11690 (void *)&cmd_flow_director_mask_port_dst,
11695 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11696 .f = cmd_flow_director_mask_parsed,
11698 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11699 "flow director's mask on NIC",
11701 (void *)&cmd_flow_director_mask,
11702 (void *)&cmd_flow_director_mask_port_id,
11703 (void *)&cmd_flow_director_mask_mode,
11704 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11705 (void *)&cmd_flow_director_mask_vlan,
11706 (void *)&cmd_flow_director_mask_vlan_value,
11711 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11712 .f = cmd_flow_director_mask_parsed,
11714 .help_str = "flow_director_mask ... : Set tunnel mode "
11715 "flow director's mask on NIC",
11717 (void *)&cmd_flow_director_mask,
11718 (void *)&cmd_flow_director_mask_port_id,
11719 (void *)&cmd_flow_director_mask_mode,
11720 (void *)&cmd_flow_director_mask_mode_tunnel,
11721 (void *)&cmd_flow_director_mask_vlan,
11722 (void *)&cmd_flow_director_mask_vlan_value,
11723 (void *)&cmd_flow_director_mask_mac,
11724 (void *)&cmd_flow_director_mask_mac_value,
11725 (void *)&cmd_flow_director_mask_tunnel_type,
11726 (void *)&cmd_flow_director_mask_tunnel_type_value,
11727 (void *)&cmd_flow_director_mask_tunnel_id,
11728 (void *)&cmd_flow_director_mask_tunnel_id_value,
11733 /* *** deal with flow director mask on flexible payload *** */
11734 struct cmd_flow_director_flex_mask_result {
11735 cmdline_fixed_string_t flow_director_flexmask;
11737 cmdline_fixed_string_t flow;
11738 cmdline_fixed_string_t flow_type;
11739 cmdline_fixed_string_t mask;
11743 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11744 __attribute__((unused)) struct cmdline *cl,
11745 __attribute__((unused)) void *data)
11747 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11748 struct rte_eth_fdir_info fdir_info;
11749 struct rte_eth_fdir_flex_mask flex_mask;
11750 struct rte_port *port;
11751 uint64_t flow_type_mask;
11755 port = &ports[res->port_id];
11756 /** Check if the port is not started **/
11757 if (port->port_status != RTE_PORT_STOPPED) {
11758 printf("Please stop port %d first\n", res->port_id);
11762 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11763 ret = parse_flexbytes(res->mask,
11765 RTE_ETH_FDIR_MAX_FLEXLEN);
11767 printf("error: Cannot parse mask input.\n");
11771 memset(&fdir_info, 0, sizeof(fdir_info));
11772 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11773 RTE_ETH_FILTER_INFO, &fdir_info);
11775 printf("Cannot get FDir filter info\n");
11779 if (!strcmp(res->flow_type, "none")) {
11780 /* means don't specify the flow type */
11781 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11782 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11783 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11784 0, sizeof(struct rte_eth_fdir_flex_mask));
11785 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11786 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11788 sizeof(struct rte_eth_fdir_flex_mask));
11789 cmd_reconfig_device_queue(res->port_id, 1, 1);
11792 flow_type_mask = fdir_info.flow_types_mask[0];
11793 if (!strcmp(res->flow_type, "all")) {
11794 if (!flow_type_mask) {
11795 printf("No flow type supported\n");
11798 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11799 if (flow_type_mask & (1ULL << i)) {
11800 flex_mask.flow_type = i;
11801 fdir_set_flex_mask(res->port_id, &flex_mask);
11804 cmd_reconfig_device_queue(res->port_id, 1, 1);
11807 flex_mask.flow_type = str2flowtype(res->flow_type);
11808 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11809 printf("Flow type %s not supported on port %d\n",
11810 res->flow_type, res->port_id);
11813 fdir_set_flex_mask(res->port_id, &flex_mask);
11814 cmd_reconfig_device_queue(res->port_id, 1, 1);
11817 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11818 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11819 flow_director_flexmask,
11820 "flow_director_flex_mask");
11821 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11822 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11824 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11825 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11827 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11828 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11829 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11830 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11831 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11832 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11835 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11836 .f = cmd_flow_director_flex_mask_parsed,
11838 .help_str = "flow_director_flex_mask ... : "
11839 "Set flow director's flex mask on NIC",
11841 (void *)&cmd_flow_director_flexmask,
11842 (void *)&cmd_flow_director_flexmask_port_id,
11843 (void *)&cmd_flow_director_flexmask_flow,
11844 (void *)&cmd_flow_director_flexmask_flow_type,
11845 (void *)&cmd_flow_director_flexmask_mask,
11850 /* *** deal with flow director flexible payload configuration *** */
11851 struct cmd_flow_director_flexpayload_result {
11852 cmdline_fixed_string_t flow_director_flexpayload;
11854 cmdline_fixed_string_t payload_layer;
11855 cmdline_fixed_string_t payload_cfg;
11859 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11862 const char *p, *p0 = q_arg;
11864 unsigned long int_fld;
11865 char *str_fld[max_num];
11870 p = strchr(p0, '(');
11874 p0 = strchr(p, ')');
11879 if (size >= sizeof(s))
11882 snprintf(s, sizeof(s), "%.*s", size, p);
11883 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11884 if (ret < 0 || ret > max_num)
11886 for (i = 0; i < ret; i++) {
11888 int_fld = strtoul(str_fld[i], &end, 0);
11889 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11891 offsets[i] = (uint16_t)int_fld;
11897 cmd_flow_director_flxpld_parsed(void *parsed_result,
11898 __attribute__((unused)) struct cmdline *cl,
11899 __attribute__((unused)) void *data)
11901 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11902 struct rte_eth_flex_payload_cfg flex_cfg;
11903 struct rte_port *port;
11906 port = &ports[res->port_id];
11907 /** Check if the port is not started **/
11908 if (port->port_status != RTE_PORT_STOPPED) {
11909 printf("Please stop port %d first\n", res->port_id);
11913 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11915 if (!strcmp(res->payload_layer, "raw"))
11916 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11917 else if (!strcmp(res->payload_layer, "l2"))
11918 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11919 else if (!strcmp(res->payload_layer, "l3"))
11920 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11921 else if (!strcmp(res->payload_layer, "l4"))
11922 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11924 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11925 RTE_ETH_FDIR_MAX_FLEXLEN);
11927 printf("error: Cannot parse flex payload input.\n");
11931 fdir_set_flex_payload(res->port_id, &flex_cfg);
11932 cmd_reconfig_device_queue(res->port_id, 1, 1);
11935 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11936 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11937 flow_director_flexpayload,
11938 "flow_director_flex_payload");
11939 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11940 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11942 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11943 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11944 payload_layer, "raw#l2#l3#l4");
11945 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11946 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11947 payload_cfg, NULL);
11949 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11950 .f = cmd_flow_director_flxpld_parsed,
11952 .help_str = "flow_director_flexpayload ... : "
11953 "Set flow director's flex payload on NIC",
11955 (void *)&cmd_flow_director_flexpayload,
11956 (void *)&cmd_flow_director_flexpayload_port_id,
11957 (void *)&cmd_flow_director_flexpayload_payload_layer,
11958 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11963 /* Generic flow interface command. */
11964 extern cmdline_parse_inst_t cmd_flow;
11966 /* *** Classification Filters Control *** */
11967 /* *** Get symmetric hash enable per port *** */
11968 struct cmd_get_sym_hash_ena_per_port_result {
11969 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11974 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11975 __rte_unused struct cmdline *cl,
11976 __rte_unused void *data)
11978 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11979 struct rte_eth_hash_filter_info info;
11982 if (rte_eth_dev_filter_supported(res->port_id,
11983 RTE_ETH_FILTER_HASH) < 0) {
11984 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11989 memset(&info, 0, sizeof(info));
11990 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11991 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11992 RTE_ETH_FILTER_GET, &info);
11995 printf("Cannot get symmetric hash enable per port "
11996 "on port %u\n", res->port_id);
12000 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
12001 "enabled" : "disabled", res->port_id);
12004 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
12005 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12006 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
12007 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
12008 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
12011 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
12012 .f = cmd_get_sym_hash_per_port_parsed,
12014 .help_str = "get_sym_hash_ena_per_port <port_id>",
12016 (void *)&cmd_get_sym_hash_ena_per_port_all,
12017 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
12022 /* *** Set symmetric hash enable per port *** */
12023 struct cmd_set_sym_hash_ena_per_port_result {
12024 cmdline_fixed_string_t set_sym_hash_ena_per_port;
12025 cmdline_fixed_string_t enable;
12030 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
12031 __rte_unused struct cmdline *cl,
12032 __rte_unused void *data)
12034 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
12035 struct rte_eth_hash_filter_info info;
12038 if (rte_eth_dev_filter_supported(res->port_id,
12039 RTE_ETH_FILTER_HASH) < 0) {
12040 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
12045 memset(&info, 0, sizeof(info));
12046 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
12047 if (!strcmp(res->enable, "enable"))
12048 info.info.enable = 1;
12049 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12050 RTE_ETH_FILTER_SET, &info);
12052 printf("Cannot set symmetric hash enable per port on "
12053 "port %u\n", res->port_id);
12056 printf("Symmetric hash has been set to %s on port %u\n",
12057 res->enable, res->port_id);
12060 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
12061 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12062 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
12063 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
12064 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12066 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
12067 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
12068 enable, "enable#disable");
12070 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
12071 .f = cmd_set_sym_hash_per_port_parsed,
12073 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
12075 (void *)&cmd_set_sym_hash_ena_per_port_all,
12076 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
12077 (void *)&cmd_set_sym_hash_ena_per_port_enable,
12082 /* Get global config of hash function */
12083 struct cmd_get_hash_global_config_result {
12084 cmdline_fixed_string_t get_hash_global_config;
12089 flowtype_to_str(uint16_t ftype)
12095 } ftype_table[] = {
12096 {"ipv4", RTE_ETH_FLOW_IPV4},
12097 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
12098 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
12099 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
12100 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
12101 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
12102 {"ipv6", RTE_ETH_FLOW_IPV6},
12103 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
12104 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
12105 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
12106 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
12107 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
12108 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
12109 {"port", RTE_ETH_FLOW_PORT},
12110 {"vxlan", RTE_ETH_FLOW_VXLAN},
12111 {"geneve", RTE_ETH_FLOW_GENEVE},
12112 {"nvgre", RTE_ETH_FLOW_NVGRE},
12113 {"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
12116 for (i = 0; i < RTE_DIM(ftype_table); i++) {
12117 if (ftype_table[i].ftype == ftype)
12118 return ftype_table[i].str;
12125 cmd_get_hash_global_config_parsed(void *parsed_result,
12126 __rte_unused struct cmdline *cl,
12127 __rte_unused void *data)
12129 struct cmd_get_hash_global_config_result *res = parsed_result;
12130 struct rte_eth_hash_filter_info info;
12131 uint32_t idx, offset;
12136 if (rte_eth_dev_filter_supported(res->port_id,
12137 RTE_ETH_FILTER_HASH) < 0) {
12138 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12143 memset(&info, 0, sizeof(info));
12144 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12145 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12146 RTE_ETH_FILTER_GET, &info);
12148 printf("Cannot get hash global configurations by port %d\n",
12153 switch (info.info.global_conf.hash_func) {
12154 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
12155 printf("Hash function is Toeplitz\n");
12157 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
12158 printf("Hash function is Simple XOR\n");
12161 printf("Unknown hash function\n");
12165 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
12166 idx = i / UINT64_BIT;
12167 offset = i % UINT64_BIT;
12168 if (!(info.info.global_conf.valid_bit_mask[idx] &
12171 str = flowtype_to_str(i);
12174 printf("Symmetric hash is %s globally for flow type %s "
12176 ((info.info.global_conf.sym_hash_enable_mask[idx] &
12177 (1ULL << offset)) ? "enabled" : "disabled"), str,
12182 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
12183 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
12184 get_hash_global_config, "get_hash_global_config");
12185 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
12186 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
12189 cmdline_parse_inst_t cmd_get_hash_global_config = {
12190 .f = cmd_get_hash_global_config_parsed,
12192 .help_str = "get_hash_global_config <port_id>",
12194 (void *)&cmd_get_hash_global_config_all,
12195 (void *)&cmd_get_hash_global_config_port_id,
12200 /* Set global config of hash function */
12201 struct cmd_set_hash_global_config_result {
12202 cmdline_fixed_string_t set_hash_global_config;
12204 cmdline_fixed_string_t hash_func;
12205 cmdline_fixed_string_t flow_type;
12206 cmdline_fixed_string_t enable;
12210 cmd_set_hash_global_config_parsed(void *parsed_result,
12211 __rte_unused struct cmdline *cl,
12212 __rte_unused void *data)
12214 struct cmd_set_hash_global_config_result *res = parsed_result;
12215 struct rte_eth_hash_filter_info info;
12216 uint32_t ftype, idx, offset;
12219 if (rte_eth_dev_filter_supported(res->port_id,
12220 RTE_ETH_FILTER_HASH) < 0) {
12221 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
12225 memset(&info, 0, sizeof(info));
12226 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
12227 if (!strcmp(res->hash_func, "toeplitz"))
12228 info.info.global_conf.hash_func =
12229 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
12230 else if (!strcmp(res->hash_func, "simple_xor"))
12231 info.info.global_conf.hash_func =
12232 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
12233 else if (!strcmp(res->hash_func, "default"))
12234 info.info.global_conf.hash_func =
12235 RTE_ETH_HASH_FUNCTION_DEFAULT;
12237 ftype = str2flowtype(res->flow_type);
12238 idx = ftype / UINT64_BIT;
12239 offset = ftype % UINT64_BIT;
12240 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
12241 if (!strcmp(res->enable, "enable"))
12242 info.info.global_conf.sym_hash_enable_mask[idx] |=
12244 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12245 RTE_ETH_FILTER_SET, &info);
12247 printf("Cannot set global hash configurations by port %d\n",
12250 printf("Global hash configurations have been set "
12251 "successfully by port %d\n", res->port_id);
12254 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
12255 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12256 set_hash_global_config, "set_hash_global_config");
12257 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
12258 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
12260 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
12261 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12262 hash_func, "toeplitz#simple_xor#default");
12263 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
12264 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12266 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
12267 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12268 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
12269 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
12270 enable, "enable#disable");
12272 cmdline_parse_inst_t cmd_set_hash_global_config = {
12273 .f = cmd_set_hash_global_config_parsed,
12275 .help_str = "set_hash_global_config <port_id> "
12276 "toeplitz|simple_xor|default "
12277 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12278 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
12279 "l2_payload enable|disable",
12281 (void *)&cmd_set_hash_global_config_all,
12282 (void *)&cmd_set_hash_global_config_port_id,
12283 (void *)&cmd_set_hash_global_config_hash_func,
12284 (void *)&cmd_set_hash_global_config_flow_type,
12285 (void *)&cmd_set_hash_global_config_enable,
12290 /* Set hash input set */
12291 struct cmd_set_hash_input_set_result {
12292 cmdline_fixed_string_t set_hash_input_set;
12294 cmdline_fixed_string_t flow_type;
12295 cmdline_fixed_string_t inset_field;
12296 cmdline_fixed_string_t select;
12299 static enum rte_eth_input_set_field
12300 str2inset(char *string)
12304 static const struct {
12306 enum rte_eth_input_set_field inset;
12307 } inset_table[] = {
12308 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
12309 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
12310 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
12311 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
12312 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
12313 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
12314 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
12315 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
12316 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
12317 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
12318 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
12319 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
12320 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
12321 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
12322 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
12323 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
12324 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
12325 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
12326 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
12327 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
12328 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
12329 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
12330 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
12331 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
12332 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12333 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12334 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12335 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12336 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12337 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12338 {"none", RTE_ETH_INPUT_SET_NONE},
12341 for (i = 0; i < RTE_DIM(inset_table); i++) {
12342 if (!strcmp(string, inset_table[i].str))
12343 return inset_table[i].inset;
12346 return RTE_ETH_INPUT_SET_UNKNOWN;
12350 cmd_set_hash_input_set_parsed(void *parsed_result,
12351 __rte_unused struct cmdline *cl,
12352 __rte_unused void *data)
12354 struct cmd_set_hash_input_set_result *res = parsed_result;
12355 struct rte_eth_hash_filter_info info;
12357 memset(&info, 0, sizeof(info));
12358 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12359 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12360 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12361 info.info.input_set_conf.inset_size = 1;
12362 if (!strcmp(res->select, "select"))
12363 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12364 else if (!strcmp(res->select, "add"))
12365 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12366 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12367 RTE_ETH_FILTER_SET, &info);
12370 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12371 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12372 set_hash_input_set, "set_hash_input_set");
12373 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12374 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12376 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12377 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12379 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12380 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12382 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12383 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12384 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12385 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12386 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12388 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12389 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12390 select, "select#add");
12392 cmdline_parse_inst_t cmd_set_hash_input_set = {
12393 .f = cmd_set_hash_input_set_parsed,
12395 .help_str = "set_hash_input_set <port_id> "
12396 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12397 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12398 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12399 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12400 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12401 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12402 "fld-7th|fld-8th|none select|add",
12404 (void *)&cmd_set_hash_input_set_cmd,
12405 (void *)&cmd_set_hash_input_set_port_id,
12406 (void *)&cmd_set_hash_input_set_flow_type,
12407 (void *)&cmd_set_hash_input_set_field,
12408 (void *)&cmd_set_hash_input_set_select,
12413 /* Set flow director input set */
12414 struct cmd_set_fdir_input_set_result {
12415 cmdline_fixed_string_t set_fdir_input_set;
12417 cmdline_fixed_string_t flow_type;
12418 cmdline_fixed_string_t inset_field;
12419 cmdline_fixed_string_t select;
12423 cmd_set_fdir_input_set_parsed(void *parsed_result,
12424 __rte_unused struct cmdline *cl,
12425 __rte_unused void *data)
12427 struct cmd_set_fdir_input_set_result *res = parsed_result;
12428 struct rte_eth_fdir_filter_info info;
12430 memset(&info, 0, sizeof(info));
12431 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12432 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12433 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12434 info.info.input_set_conf.inset_size = 1;
12435 if (!strcmp(res->select, "select"))
12436 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12437 else if (!strcmp(res->select, "add"))
12438 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12439 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12440 RTE_ETH_FILTER_SET, &info);
12443 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12444 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12445 set_fdir_input_set, "set_fdir_input_set");
12446 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12447 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12449 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12450 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12452 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12453 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12454 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12455 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12457 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12458 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12459 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12460 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12461 "sctp-veri-tag#none");
12462 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12463 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12464 select, "select#add");
12466 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12467 .f = cmd_set_fdir_input_set_parsed,
12469 .help_str = "set_fdir_input_set <port_id> "
12470 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12471 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12472 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12473 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12474 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12475 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12476 "sctp-veri-tag|none select|add",
12478 (void *)&cmd_set_fdir_input_set_cmd,
12479 (void *)&cmd_set_fdir_input_set_port_id,
12480 (void *)&cmd_set_fdir_input_set_flow_type,
12481 (void *)&cmd_set_fdir_input_set_field,
12482 (void *)&cmd_set_fdir_input_set_select,
12487 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12488 struct cmd_mcast_addr_result {
12489 cmdline_fixed_string_t mcast_addr_cmd;
12490 cmdline_fixed_string_t what;
12492 struct rte_ether_addr mc_addr;
12495 static void cmd_mcast_addr_parsed(void *parsed_result,
12496 __attribute__((unused)) struct cmdline *cl,
12497 __attribute__((unused)) void *data)
12499 struct cmd_mcast_addr_result *res = parsed_result;
12501 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
12502 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12503 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12504 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12505 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12508 if (strcmp(res->what, "add") == 0)
12509 mcast_addr_add(res->port_num, &res->mc_addr);
12511 mcast_addr_remove(res->port_num, &res->mc_addr);
12514 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12515 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12516 mcast_addr_cmd, "mcast_addr");
12517 cmdline_parse_token_string_t cmd_mcast_addr_what =
12518 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12520 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12521 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12522 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12523 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12525 cmdline_parse_inst_t cmd_mcast_addr = {
12526 .f = cmd_mcast_addr_parsed,
12528 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12529 "Add/Remove multicast MAC address on port_id",
12531 (void *)&cmd_mcast_addr_cmd,
12532 (void *)&cmd_mcast_addr_what,
12533 (void *)&cmd_mcast_addr_portnum,
12534 (void *)&cmd_mcast_addr_addr,
12539 /* l2 tunnel config
12540 * only support E-tag now.
12543 /* Ether type config */
12544 struct cmd_config_l2_tunnel_eth_type_result {
12545 cmdline_fixed_string_t port;
12546 cmdline_fixed_string_t config;
12547 cmdline_fixed_string_t all;
12549 cmdline_fixed_string_t l2_tunnel;
12550 cmdline_fixed_string_t l2_tunnel_type;
12551 cmdline_fixed_string_t eth_type;
12552 uint16_t eth_type_val;
12555 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12556 TOKEN_STRING_INITIALIZER
12557 (struct cmd_config_l2_tunnel_eth_type_result,
12559 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12560 TOKEN_STRING_INITIALIZER
12561 (struct cmd_config_l2_tunnel_eth_type_result,
12563 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12564 TOKEN_STRING_INITIALIZER
12565 (struct cmd_config_l2_tunnel_eth_type_result,
12567 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12568 TOKEN_NUM_INITIALIZER
12569 (struct cmd_config_l2_tunnel_eth_type_result,
12571 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12572 TOKEN_STRING_INITIALIZER
12573 (struct cmd_config_l2_tunnel_eth_type_result,
12574 l2_tunnel, "l2-tunnel");
12575 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12576 TOKEN_STRING_INITIALIZER
12577 (struct cmd_config_l2_tunnel_eth_type_result,
12578 l2_tunnel_type, "E-tag");
12579 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12580 TOKEN_STRING_INITIALIZER
12581 (struct cmd_config_l2_tunnel_eth_type_result,
12582 eth_type, "ether-type");
12583 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12584 TOKEN_NUM_INITIALIZER
12585 (struct cmd_config_l2_tunnel_eth_type_result,
12586 eth_type_val, UINT16);
12588 static enum rte_eth_tunnel_type
12589 str2fdir_l2_tunnel_type(char *string)
12593 static const struct {
12595 enum rte_eth_tunnel_type type;
12596 } l2_tunnel_type_str[] = {
12597 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12600 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12601 if (!strcmp(l2_tunnel_type_str[i].str, string))
12602 return l2_tunnel_type_str[i].type;
12604 return RTE_TUNNEL_TYPE_NONE;
12607 /* ether type config for all ports */
12609 cmd_config_l2_tunnel_eth_type_all_parsed
12610 (void *parsed_result,
12611 __attribute__((unused)) struct cmdline *cl,
12612 __attribute__((unused)) void *data)
12614 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12615 struct rte_eth_l2_tunnel_conf entry;
12618 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12619 entry.ether_type = res->eth_type_val;
12621 RTE_ETH_FOREACH_DEV(pid) {
12622 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12626 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12627 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12629 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12631 (void *)&cmd_config_l2_tunnel_eth_type_port,
12632 (void *)&cmd_config_l2_tunnel_eth_type_config,
12633 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12634 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12635 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12636 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12637 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12642 /* ether type config for a specific port */
12644 cmd_config_l2_tunnel_eth_type_specific_parsed(
12645 void *parsed_result,
12646 __attribute__((unused)) struct cmdline *cl,
12647 __attribute__((unused)) void *data)
12649 struct cmd_config_l2_tunnel_eth_type_result *res =
12651 struct rte_eth_l2_tunnel_conf entry;
12653 if (port_id_is_invalid(res->id, ENABLED_WARN))
12656 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12657 entry.ether_type = res->eth_type_val;
12659 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12662 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12663 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12665 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12667 (void *)&cmd_config_l2_tunnel_eth_type_port,
12668 (void *)&cmd_config_l2_tunnel_eth_type_config,
12669 (void *)&cmd_config_l2_tunnel_eth_type_id,
12670 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12671 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12672 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12673 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12678 /* Enable/disable l2 tunnel */
12679 struct cmd_config_l2_tunnel_en_dis_result {
12680 cmdline_fixed_string_t port;
12681 cmdline_fixed_string_t config;
12682 cmdline_fixed_string_t all;
12684 cmdline_fixed_string_t l2_tunnel;
12685 cmdline_fixed_string_t l2_tunnel_type;
12686 cmdline_fixed_string_t en_dis;
12689 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12690 TOKEN_STRING_INITIALIZER
12691 (struct cmd_config_l2_tunnel_en_dis_result,
12693 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12694 TOKEN_STRING_INITIALIZER
12695 (struct cmd_config_l2_tunnel_en_dis_result,
12697 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12698 TOKEN_STRING_INITIALIZER
12699 (struct cmd_config_l2_tunnel_en_dis_result,
12701 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12702 TOKEN_NUM_INITIALIZER
12703 (struct cmd_config_l2_tunnel_en_dis_result,
12705 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12706 TOKEN_STRING_INITIALIZER
12707 (struct cmd_config_l2_tunnel_en_dis_result,
12708 l2_tunnel, "l2-tunnel");
12709 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12710 TOKEN_STRING_INITIALIZER
12711 (struct cmd_config_l2_tunnel_en_dis_result,
12712 l2_tunnel_type, "E-tag");
12713 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12714 TOKEN_STRING_INITIALIZER
12715 (struct cmd_config_l2_tunnel_en_dis_result,
12716 en_dis, "enable#disable");
12718 /* enable/disable l2 tunnel for all ports */
12720 cmd_config_l2_tunnel_en_dis_all_parsed(
12721 void *parsed_result,
12722 __attribute__((unused)) struct cmdline *cl,
12723 __attribute__((unused)) void *data)
12725 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12726 struct rte_eth_l2_tunnel_conf entry;
12730 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12732 if (!strcmp("enable", res->en_dis))
12737 RTE_ETH_FOREACH_DEV(pid) {
12738 rte_eth_dev_l2_tunnel_offload_set(pid,
12740 ETH_L2_TUNNEL_ENABLE_MASK,
12745 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12746 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12748 .help_str = "port config all l2-tunnel E-tag enable|disable",
12750 (void *)&cmd_config_l2_tunnel_en_dis_port,
12751 (void *)&cmd_config_l2_tunnel_en_dis_config,
12752 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12753 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12754 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12755 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12760 /* enable/disable l2 tunnel for a port */
12762 cmd_config_l2_tunnel_en_dis_specific_parsed(
12763 void *parsed_result,
12764 __attribute__((unused)) struct cmdline *cl,
12765 __attribute__((unused)) void *data)
12767 struct cmd_config_l2_tunnel_en_dis_result *res =
12769 struct rte_eth_l2_tunnel_conf entry;
12771 if (port_id_is_invalid(res->id, ENABLED_WARN))
12774 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12776 if (!strcmp("enable", res->en_dis))
12777 rte_eth_dev_l2_tunnel_offload_set(res->id,
12779 ETH_L2_TUNNEL_ENABLE_MASK,
12782 rte_eth_dev_l2_tunnel_offload_set(res->id,
12784 ETH_L2_TUNNEL_ENABLE_MASK,
12788 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12789 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12791 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12793 (void *)&cmd_config_l2_tunnel_en_dis_port,
12794 (void *)&cmd_config_l2_tunnel_en_dis_config,
12795 (void *)&cmd_config_l2_tunnel_en_dis_id,
12796 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12797 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12798 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12803 /* E-tag configuration */
12805 /* Common result structure for all E-tag configuration */
12806 struct cmd_config_e_tag_result {
12807 cmdline_fixed_string_t e_tag;
12808 cmdline_fixed_string_t set;
12809 cmdline_fixed_string_t insertion;
12810 cmdline_fixed_string_t stripping;
12811 cmdline_fixed_string_t forwarding;
12812 cmdline_fixed_string_t filter;
12813 cmdline_fixed_string_t add;
12814 cmdline_fixed_string_t del;
12815 cmdline_fixed_string_t on;
12816 cmdline_fixed_string_t off;
12817 cmdline_fixed_string_t on_off;
12818 cmdline_fixed_string_t port_tag_id;
12819 uint32_t port_tag_id_val;
12820 cmdline_fixed_string_t e_tag_id;
12821 uint16_t e_tag_id_val;
12822 cmdline_fixed_string_t dst_pool;
12823 uint8_t dst_pool_val;
12824 cmdline_fixed_string_t port;
12826 cmdline_fixed_string_t vf;
12830 /* Common CLI fields for all E-tag configuration */
12831 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12832 TOKEN_STRING_INITIALIZER
12833 (struct cmd_config_e_tag_result,
12835 cmdline_parse_token_string_t cmd_config_e_tag_set =
12836 TOKEN_STRING_INITIALIZER
12837 (struct cmd_config_e_tag_result,
12839 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12840 TOKEN_STRING_INITIALIZER
12841 (struct cmd_config_e_tag_result,
12842 insertion, "insertion");
12843 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12844 TOKEN_STRING_INITIALIZER
12845 (struct cmd_config_e_tag_result,
12846 stripping, "stripping");
12847 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12848 TOKEN_STRING_INITIALIZER
12849 (struct cmd_config_e_tag_result,
12850 forwarding, "forwarding");
12851 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12852 TOKEN_STRING_INITIALIZER
12853 (struct cmd_config_e_tag_result,
12855 cmdline_parse_token_string_t cmd_config_e_tag_add =
12856 TOKEN_STRING_INITIALIZER
12857 (struct cmd_config_e_tag_result,
12859 cmdline_parse_token_string_t cmd_config_e_tag_del =
12860 TOKEN_STRING_INITIALIZER
12861 (struct cmd_config_e_tag_result,
12863 cmdline_parse_token_string_t cmd_config_e_tag_on =
12864 TOKEN_STRING_INITIALIZER
12865 (struct cmd_config_e_tag_result,
12867 cmdline_parse_token_string_t cmd_config_e_tag_off =
12868 TOKEN_STRING_INITIALIZER
12869 (struct cmd_config_e_tag_result,
12871 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12872 TOKEN_STRING_INITIALIZER
12873 (struct cmd_config_e_tag_result,
12875 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12876 TOKEN_STRING_INITIALIZER
12877 (struct cmd_config_e_tag_result,
12878 port_tag_id, "port-tag-id");
12879 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12880 TOKEN_NUM_INITIALIZER
12881 (struct cmd_config_e_tag_result,
12882 port_tag_id_val, UINT32);
12883 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12884 TOKEN_STRING_INITIALIZER
12885 (struct cmd_config_e_tag_result,
12886 e_tag_id, "e-tag-id");
12887 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12888 TOKEN_NUM_INITIALIZER
12889 (struct cmd_config_e_tag_result,
12890 e_tag_id_val, UINT16);
12891 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12892 TOKEN_STRING_INITIALIZER
12893 (struct cmd_config_e_tag_result,
12894 dst_pool, "dst-pool");
12895 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12896 TOKEN_NUM_INITIALIZER
12897 (struct cmd_config_e_tag_result,
12898 dst_pool_val, UINT8);
12899 cmdline_parse_token_string_t cmd_config_e_tag_port =
12900 TOKEN_STRING_INITIALIZER
12901 (struct cmd_config_e_tag_result,
12903 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12904 TOKEN_NUM_INITIALIZER
12905 (struct cmd_config_e_tag_result,
12907 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12908 TOKEN_STRING_INITIALIZER
12909 (struct cmd_config_e_tag_result,
12911 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12912 TOKEN_NUM_INITIALIZER
12913 (struct cmd_config_e_tag_result,
12916 /* E-tag insertion configuration */
12918 cmd_config_e_tag_insertion_en_parsed(
12919 void *parsed_result,
12920 __attribute__((unused)) struct cmdline *cl,
12921 __attribute__((unused)) void *data)
12923 struct cmd_config_e_tag_result *res =
12925 struct rte_eth_l2_tunnel_conf entry;
12927 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12930 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12931 entry.tunnel_id = res->port_tag_id_val;
12932 entry.vf_id = res->vf_id;
12933 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12935 ETH_L2_TUNNEL_INSERTION_MASK,
12940 cmd_config_e_tag_insertion_dis_parsed(
12941 void *parsed_result,
12942 __attribute__((unused)) struct cmdline *cl,
12943 __attribute__((unused)) void *data)
12945 struct cmd_config_e_tag_result *res =
12947 struct rte_eth_l2_tunnel_conf entry;
12949 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12952 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12953 entry.vf_id = res->vf_id;
12955 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12957 ETH_L2_TUNNEL_INSERTION_MASK,
12961 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12962 .f = cmd_config_e_tag_insertion_en_parsed,
12964 .help_str = "E-tag ... : E-tag insertion enable",
12966 (void *)&cmd_config_e_tag_e_tag,
12967 (void *)&cmd_config_e_tag_set,
12968 (void *)&cmd_config_e_tag_insertion,
12969 (void *)&cmd_config_e_tag_on,
12970 (void *)&cmd_config_e_tag_port_tag_id,
12971 (void *)&cmd_config_e_tag_port_tag_id_val,
12972 (void *)&cmd_config_e_tag_port,
12973 (void *)&cmd_config_e_tag_port_id,
12974 (void *)&cmd_config_e_tag_vf,
12975 (void *)&cmd_config_e_tag_vf_id,
12980 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12981 .f = cmd_config_e_tag_insertion_dis_parsed,
12983 .help_str = "E-tag ... : E-tag insertion disable",
12985 (void *)&cmd_config_e_tag_e_tag,
12986 (void *)&cmd_config_e_tag_set,
12987 (void *)&cmd_config_e_tag_insertion,
12988 (void *)&cmd_config_e_tag_off,
12989 (void *)&cmd_config_e_tag_port,
12990 (void *)&cmd_config_e_tag_port_id,
12991 (void *)&cmd_config_e_tag_vf,
12992 (void *)&cmd_config_e_tag_vf_id,
12997 /* E-tag stripping configuration */
12999 cmd_config_e_tag_stripping_parsed(
13000 void *parsed_result,
13001 __attribute__((unused)) struct cmdline *cl,
13002 __attribute__((unused)) void *data)
13004 struct cmd_config_e_tag_result *res =
13006 struct rte_eth_l2_tunnel_conf entry;
13008 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13011 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13013 if (!strcmp(res->on_off, "on"))
13014 rte_eth_dev_l2_tunnel_offload_set
13017 ETH_L2_TUNNEL_STRIPPING_MASK,
13020 rte_eth_dev_l2_tunnel_offload_set
13023 ETH_L2_TUNNEL_STRIPPING_MASK,
13027 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
13028 .f = cmd_config_e_tag_stripping_parsed,
13030 .help_str = "E-tag ... : E-tag stripping enable/disable",
13032 (void *)&cmd_config_e_tag_e_tag,
13033 (void *)&cmd_config_e_tag_set,
13034 (void *)&cmd_config_e_tag_stripping,
13035 (void *)&cmd_config_e_tag_on_off,
13036 (void *)&cmd_config_e_tag_port,
13037 (void *)&cmd_config_e_tag_port_id,
13042 /* E-tag forwarding configuration */
13044 cmd_config_e_tag_forwarding_parsed(
13045 void *parsed_result,
13046 __attribute__((unused)) struct cmdline *cl,
13047 __attribute__((unused)) void *data)
13049 struct cmd_config_e_tag_result *res = parsed_result;
13050 struct rte_eth_l2_tunnel_conf entry;
13052 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13055 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13057 if (!strcmp(res->on_off, "on"))
13058 rte_eth_dev_l2_tunnel_offload_set
13061 ETH_L2_TUNNEL_FORWARDING_MASK,
13064 rte_eth_dev_l2_tunnel_offload_set
13067 ETH_L2_TUNNEL_FORWARDING_MASK,
13071 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
13072 .f = cmd_config_e_tag_forwarding_parsed,
13074 .help_str = "E-tag ... : E-tag forwarding enable/disable",
13076 (void *)&cmd_config_e_tag_e_tag,
13077 (void *)&cmd_config_e_tag_set,
13078 (void *)&cmd_config_e_tag_forwarding,
13079 (void *)&cmd_config_e_tag_on_off,
13080 (void *)&cmd_config_e_tag_port,
13081 (void *)&cmd_config_e_tag_port_id,
13086 /* E-tag filter configuration */
13088 cmd_config_e_tag_filter_add_parsed(
13089 void *parsed_result,
13090 __attribute__((unused)) struct cmdline *cl,
13091 __attribute__((unused)) void *data)
13093 struct cmd_config_e_tag_result *res = parsed_result;
13094 struct rte_eth_l2_tunnel_conf entry;
13097 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13100 if (res->e_tag_id_val > 0x3fff) {
13101 printf("e-tag-id must be equal or less than 0x3fff.\n");
13105 ret = rte_eth_dev_filter_supported(res->port_id,
13106 RTE_ETH_FILTER_L2_TUNNEL);
13108 printf("E-tag filter is not supported on port %u.\n",
13113 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13114 entry.tunnel_id = res->e_tag_id_val;
13115 entry.pool = res->dst_pool_val;
13117 ret = rte_eth_dev_filter_ctrl(res->port_id,
13118 RTE_ETH_FILTER_L2_TUNNEL,
13119 RTE_ETH_FILTER_ADD,
13122 printf("E-tag filter programming error: (%s)\n",
13126 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
13127 .f = cmd_config_e_tag_filter_add_parsed,
13129 .help_str = "E-tag ... : E-tag filter add",
13131 (void *)&cmd_config_e_tag_e_tag,
13132 (void *)&cmd_config_e_tag_set,
13133 (void *)&cmd_config_e_tag_filter,
13134 (void *)&cmd_config_e_tag_add,
13135 (void *)&cmd_config_e_tag_e_tag_id,
13136 (void *)&cmd_config_e_tag_e_tag_id_val,
13137 (void *)&cmd_config_e_tag_dst_pool,
13138 (void *)&cmd_config_e_tag_dst_pool_val,
13139 (void *)&cmd_config_e_tag_port,
13140 (void *)&cmd_config_e_tag_port_id,
13146 cmd_config_e_tag_filter_del_parsed(
13147 void *parsed_result,
13148 __attribute__((unused)) struct cmdline *cl,
13149 __attribute__((unused)) void *data)
13151 struct cmd_config_e_tag_result *res = parsed_result;
13152 struct rte_eth_l2_tunnel_conf entry;
13155 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13158 if (res->e_tag_id_val > 0x3fff) {
13159 printf("e-tag-id must be less than 0x3fff.\n");
13163 ret = rte_eth_dev_filter_supported(res->port_id,
13164 RTE_ETH_FILTER_L2_TUNNEL);
13166 printf("E-tag filter is not supported on port %u.\n",
13171 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
13172 entry.tunnel_id = res->e_tag_id_val;
13174 ret = rte_eth_dev_filter_ctrl(res->port_id,
13175 RTE_ETH_FILTER_L2_TUNNEL,
13176 RTE_ETH_FILTER_DELETE,
13179 printf("E-tag filter programming error: (%s)\n",
13183 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
13184 .f = cmd_config_e_tag_filter_del_parsed,
13186 .help_str = "E-tag ... : E-tag filter delete",
13188 (void *)&cmd_config_e_tag_e_tag,
13189 (void *)&cmd_config_e_tag_set,
13190 (void *)&cmd_config_e_tag_filter,
13191 (void *)&cmd_config_e_tag_del,
13192 (void *)&cmd_config_e_tag_e_tag_id,
13193 (void *)&cmd_config_e_tag_e_tag_id_val,
13194 (void *)&cmd_config_e_tag_port,
13195 (void *)&cmd_config_e_tag_port_id,
13200 /* vf vlan anti spoof configuration */
13202 /* Common result structure for vf vlan anti spoof */
13203 struct cmd_vf_vlan_anti_spoof_result {
13204 cmdline_fixed_string_t set;
13205 cmdline_fixed_string_t vf;
13206 cmdline_fixed_string_t vlan;
13207 cmdline_fixed_string_t antispoof;
13210 cmdline_fixed_string_t on_off;
13213 /* Common CLI fields for vf vlan anti spoof enable disable */
13214 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
13215 TOKEN_STRING_INITIALIZER
13216 (struct cmd_vf_vlan_anti_spoof_result,
13218 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
13219 TOKEN_STRING_INITIALIZER
13220 (struct cmd_vf_vlan_anti_spoof_result,
13222 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
13223 TOKEN_STRING_INITIALIZER
13224 (struct cmd_vf_vlan_anti_spoof_result,
13226 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
13227 TOKEN_STRING_INITIALIZER
13228 (struct cmd_vf_vlan_anti_spoof_result,
13229 antispoof, "antispoof");
13230 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
13231 TOKEN_NUM_INITIALIZER
13232 (struct cmd_vf_vlan_anti_spoof_result,
13234 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
13235 TOKEN_NUM_INITIALIZER
13236 (struct cmd_vf_vlan_anti_spoof_result,
13238 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
13239 TOKEN_STRING_INITIALIZER
13240 (struct cmd_vf_vlan_anti_spoof_result,
13244 cmd_set_vf_vlan_anti_spoof_parsed(
13245 void *parsed_result,
13246 __attribute__((unused)) struct cmdline *cl,
13247 __attribute__((unused)) void *data)
13249 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
13250 int ret = -ENOTSUP;
13252 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13254 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13257 #ifdef RTE_LIBRTE_IXGBE_PMD
13258 if (ret == -ENOTSUP)
13259 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
13260 res->vf_id, is_on);
13262 #ifdef RTE_LIBRTE_I40E_PMD
13263 if (ret == -ENOTSUP)
13264 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
13265 res->vf_id, is_on);
13267 #ifdef RTE_LIBRTE_BNXT_PMD
13268 if (ret == -ENOTSUP)
13269 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
13270 res->vf_id, is_on);
13277 printf("invalid vf_id %d\n", res->vf_id);
13280 printf("invalid port_id %d\n", res->port_id);
13283 printf("function not implemented\n");
13286 printf("programming error: (%s)\n", strerror(-ret));
13290 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
13291 .f = cmd_set_vf_vlan_anti_spoof_parsed,
13293 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
13295 (void *)&cmd_vf_vlan_anti_spoof_set,
13296 (void *)&cmd_vf_vlan_anti_spoof_vf,
13297 (void *)&cmd_vf_vlan_anti_spoof_vlan,
13298 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
13299 (void *)&cmd_vf_vlan_anti_spoof_port_id,
13300 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
13301 (void *)&cmd_vf_vlan_anti_spoof_on_off,
13306 /* vf mac anti spoof configuration */
13308 /* Common result structure for vf mac anti spoof */
13309 struct cmd_vf_mac_anti_spoof_result {
13310 cmdline_fixed_string_t set;
13311 cmdline_fixed_string_t vf;
13312 cmdline_fixed_string_t mac;
13313 cmdline_fixed_string_t antispoof;
13316 cmdline_fixed_string_t on_off;
13319 /* Common CLI fields for vf mac anti spoof enable disable */
13320 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
13321 TOKEN_STRING_INITIALIZER
13322 (struct cmd_vf_mac_anti_spoof_result,
13324 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
13325 TOKEN_STRING_INITIALIZER
13326 (struct cmd_vf_mac_anti_spoof_result,
13328 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
13329 TOKEN_STRING_INITIALIZER
13330 (struct cmd_vf_mac_anti_spoof_result,
13332 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13333 TOKEN_STRING_INITIALIZER
13334 (struct cmd_vf_mac_anti_spoof_result,
13335 antispoof, "antispoof");
13336 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13337 TOKEN_NUM_INITIALIZER
13338 (struct cmd_vf_mac_anti_spoof_result,
13340 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13341 TOKEN_NUM_INITIALIZER
13342 (struct cmd_vf_mac_anti_spoof_result,
13344 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13345 TOKEN_STRING_INITIALIZER
13346 (struct cmd_vf_mac_anti_spoof_result,
13350 cmd_set_vf_mac_anti_spoof_parsed(
13351 void *parsed_result,
13352 __attribute__((unused)) struct cmdline *cl,
13353 __attribute__((unused)) void *data)
13355 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13356 int ret = -ENOTSUP;
13358 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13360 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13363 #ifdef RTE_LIBRTE_IXGBE_PMD
13364 if (ret == -ENOTSUP)
13365 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13366 res->vf_id, is_on);
13368 #ifdef RTE_LIBRTE_I40E_PMD
13369 if (ret == -ENOTSUP)
13370 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13371 res->vf_id, is_on);
13373 #ifdef RTE_LIBRTE_BNXT_PMD
13374 if (ret == -ENOTSUP)
13375 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13376 res->vf_id, is_on);
13383 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13386 printf("invalid port_id %d\n", res->port_id);
13389 printf("function not implemented\n");
13392 printf("programming error: (%s)\n", strerror(-ret));
13396 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13397 .f = cmd_set_vf_mac_anti_spoof_parsed,
13399 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13401 (void *)&cmd_vf_mac_anti_spoof_set,
13402 (void *)&cmd_vf_mac_anti_spoof_vf,
13403 (void *)&cmd_vf_mac_anti_spoof_mac,
13404 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13405 (void *)&cmd_vf_mac_anti_spoof_port_id,
13406 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13407 (void *)&cmd_vf_mac_anti_spoof_on_off,
13412 /* vf vlan strip queue configuration */
13414 /* Common result structure for vf mac anti spoof */
13415 struct cmd_vf_vlan_stripq_result {
13416 cmdline_fixed_string_t set;
13417 cmdline_fixed_string_t vf;
13418 cmdline_fixed_string_t vlan;
13419 cmdline_fixed_string_t stripq;
13422 cmdline_fixed_string_t on_off;
13425 /* Common CLI fields for vf vlan strip enable disable */
13426 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13427 TOKEN_STRING_INITIALIZER
13428 (struct cmd_vf_vlan_stripq_result,
13430 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13431 TOKEN_STRING_INITIALIZER
13432 (struct cmd_vf_vlan_stripq_result,
13434 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13435 TOKEN_STRING_INITIALIZER
13436 (struct cmd_vf_vlan_stripq_result,
13438 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13439 TOKEN_STRING_INITIALIZER
13440 (struct cmd_vf_vlan_stripq_result,
13442 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13443 TOKEN_NUM_INITIALIZER
13444 (struct cmd_vf_vlan_stripq_result,
13446 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13447 TOKEN_NUM_INITIALIZER
13448 (struct cmd_vf_vlan_stripq_result,
13450 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13451 TOKEN_STRING_INITIALIZER
13452 (struct cmd_vf_vlan_stripq_result,
13456 cmd_set_vf_vlan_stripq_parsed(
13457 void *parsed_result,
13458 __attribute__((unused)) struct cmdline *cl,
13459 __attribute__((unused)) void *data)
13461 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13462 int ret = -ENOTSUP;
13464 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13466 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13469 #ifdef RTE_LIBRTE_IXGBE_PMD
13470 if (ret == -ENOTSUP)
13471 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13472 res->vf_id, is_on);
13474 #ifdef RTE_LIBRTE_I40E_PMD
13475 if (ret == -ENOTSUP)
13476 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13477 res->vf_id, is_on);
13479 #ifdef RTE_LIBRTE_BNXT_PMD
13480 if (ret == -ENOTSUP)
13481 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13482 res->vf_id, is_on);
13489 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13492 printf("invalid port_id %d\n", res->port_id);
13495 printf("function not implemented\n");
13498 printf("programming error: (%s)\n", strerror(-ret));
13502 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13503 .f = cmd_set_vf_vlan_stripq_parsed,
13505 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13507 (void *)&cmd_vf_vlan_stripq_set,
13508 (void *)&cmd_vf_vlan_stripq_vf,
13509 (void *)&cmd_vf_vlan_stripq_vlan,
13510 (void *)&cmd_vf_vlan_stripq_stripq,
13511 (void *)&cmd_vf_vlan_stripq_port_id,
13512 (void *)&cmd_vf_vlan_stripq_vf_id,
13513 (void *)&cmd_vf_vlan_stripq_on_off,
13518 /* vf vlan insert configuration */
13520 /* Common result structure for vf vlan insert */
13521 struct cmd_vf_vlan_insert_result {
13522 cmdline_fixed_string_t set;
13523 cmdline_fixed_string_t vf;
13524 cmdline_fixed_string_t vlan;
13525 cmdline_fixed_string_t insert;
13531 /* Common CLI fields for vf vlan insert enable disable */
13532 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13533 TOKEN_STRING_INITIALIZER
13534 (struct cmd_vf_vlan_insert_result,
13536 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13537 TOKEN_STRING_INITIALIZER
13538 (struct cmd_vf_vlan_insert_result,
13540 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13541 TOKEN_STRING_INITIALIZER
13542 (struct cmd_vf_vlan_insert_result,
13544 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13545 TOKEN_STRING_INITIALIZER
13546 (struct cmd_vf_vlan_insert_result,
13548 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13549 TOKEN_NUM_INITIALIZER
13550 (struct cmd_vf_vlan_insert_result,
13552 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13553 TOKEN_NUM_INITIALIZER
13554 (struct cmd_vf_vlan_insert_result,
13556 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13557 TOKEN_NUM_INITIALIZER
13558 (struct cmd_vf_vlan_insert_result,
13562 cmd_set_vf_vlan_insert_parsed(
13563 void *parsed_result,
13564 __attribute__((unused)) struct cmdline *cl,
13565 __attribute__((unused)) void *data)
13567 struct cmd_vf_vlan_insert_result *res = parsed_result;
13568 int ret = -ENOTSUP;
13570 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13573 #ifdef RTE_LIBRTE_IXGBE_PMD
13574 if (ret == -ENOTSUP)
13575 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13578 #ifdef RTE_LIBRTE_I40E_PMD
13579 if (ret == -ENOTSUP)
13580 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13583 #ifdef RTE_LIBRTE_BNXT_PMD
13584 if (ret == -ENOTSUP)
13585 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13593 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13596 printf("invalid port_id %d\n", res->port_id);
13599 printf("function not implemented\n");
13602 printf("programming error: (%s)\n", strerror(-ret));
13606 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13607 .f = cmd_set_vf_vlan_insert_parsed,
13609 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13611 (void *)&cmd_vf_vlan_insert_set,
13612 (void *)&cmd_vf_vlan_insert_vf,
13613 (void *)&cmd_vf_vlan_insert_vlan,
13614 (void *)&cmd_vf_vlan_insert_insert,
13615 (void *)&cmd_vf_vlan_insert_port_id,
13616 (void *)&cmd_vf_vlan_insert_vf_id,
13617 (void *)&cmd_vf_vlan_insert_vlan_id,
13622 /* tx loopback configuration */
13624 /* Common result structure for tx loopback */
13625 struct cmd_tx_loopback_result {
13626 cmdline_fixed_string_t set;
13627 cmdline_fixed_string_t tx;
13628 cmdline_fixed_string_t loopback;
13630 cmdline_fixed_string_t on_off;
13633 /* Common CLI fields for tx loopback enable disable */
13634 cmdline_parse_token_string_t cmd_tx_loopback_set =
13635 TOKEN_STRING_INITIALIZER
13636 (struct cmd_tx_loopback_result,
13638 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13639 TOKEN_STRING_INITIALIZER
13640 (struct cmd_tx_loopback_result,
13642 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13643 TOKEN_STRING_INITIALIZER
13644 (struct cmd_tx_loopback_result,
13645 loopback, "loopback");
13646 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13647 TOKEN_NUM_INITIALIZER
13648 (struct cmd_tx_loopback_result,
13650 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13651 TOKEN_STRING_INITIALIZER
13652 (struct cmd_tx_loopback_result,
13656 cmd_set_tx_loopback_parsed(
13657 void *parsed_result,
13658 __attribute__((unused)) struct cmdline *cl,
13659 __attribute__((unused)) void *data)
13661 struct cmd_tx_loopback_result *res = parsed_result;
13662 int ret = -ENOTSUP;
13664 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13666 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13669 #ifdef RTE_LIBRTE_IXGBE_PMD
13670 if (ret == -ENOTSUP)
13671 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13673 #ifdef RTE_LIBRTE_I40E_PMD
13674 if (ret == -ENOTSUP)
13675 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13677 #ifdef RTE_LIBRTE_BNXT_PMD
13678 if (ret == -ENOTSUP)
13679 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13681 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13682 if (ret == -ENOTSUP)
13683 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13690 printf("invalid is_on %d\n", is_on);
13693 printf("invalid port_id %d\n", res->port_id);
13696 printf("function not implemented\n");
13699 printf("programming error: (%s)\n", strerror(-ret));
13703 cmdline_parse_inst_t cmd_set_tx_loopback = {
13704 .f = cmd_set_tx_loopback_parsed,
13706 .help_str = "set tx loopback <port_id> on|off",
13708 (void *)&cmd_tx_loopback_set,
13709 (void *)&cmd_tx_loopback_tx,
13710 (void *)&cmd_tx_loopback_loopback,
13711 (void *)&cmd_tx_loopback_port_id,
13712 (void *)&cmd_tx_loopback_on_off,
13717 /* all queues drop enable configuration */
13719 /* Common result structure for all queues drop enable */
13720 struct cmd_all_queues_drop_en_result {
13721 cmdline_fixed_string_t set;
13722 cmdline_fixed_string_t all;
13723 cmdline_fixed_string_t queues;
13724 cmdline_fixed_string_t drop;
13726 cmdline_fixed_string_t on_off;
13729 /* Common CLI fields for tx loopback enable disable */
13730 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13731 TOKEN_STRING_INITIALIZER
13732 (struct cmd_all_queues_drop_en_result,
13734 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13735 TOKEN_STRING_INITIALIZER
13736 (struct cmd_all_queues_drop_en_result,
13738 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13739 TOKEN_STRING_INITIALIZER
13740 (struct cmd_all_queues_drop_en_result,
13742 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13743 TOKEN_STRING_INITIALIZER
13744 (struct cmd_all_queues_drop_en_result,
13746 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13747 TOKEN_NUM_INITIALIZER
13748 (struct cmd_all_queues_drop_en_result,
13750 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13751 TOKEN_STRING_INITIALIZER
13752 (struct cmd_all_queues_drop_en_result,
13756 cmd_set_all_queues_drop_en_parsed(
13757 void *parsed_result,
13758 __attribute__((unused)) struct cmdline *cl,
13759 __attribute__((unused)) void *data)
13761 struct cmd_all_queues_drop_en_result *res = parsed_result;
13762 int ret = -ENOTSUP;
13763 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13765 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13768 #ifdef RTE_LIBRTE_IXGBE_PMD
13769 if (ret == -ENOTSUP)
13770 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13772 #ifdef RTE_LIBRTE_BNXT_PMD
13773 if (ret == -ENOTSUP)
13774 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13780 printf("invalid is_on %d\n", is_on);
13783 printf("invalid port_id %d\n", res->port_id);
13786 printf("function not implemented\n");
13789 printf("programming error: (%s)\n", strerror(-ret));
13793 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13794 .f = cmd_set_all_queues_drop_en_parsed,
13796 .help_str = "set all queues drop <port_id> on|off",
13798 (void *)&cmd_all_queues_drop_en_set,
13799 (void *)&cmd_all_queues_drop_en_all,
13800 (void *)&cmd_all_queues_drop_en_queues,
13801 (void *)&cmd_all_queues_drop_en_drop,
13802 (void *)&cmd_all_queues_drop_en_port_id,
13803 (void *)&cmd_all_queues_drop_en_on_off,
13808 /* vf split drop enable configuration */
13810 /* Common result structure for vf split drop enable */
13811 struct cmd_vf_split_drop_en_result {
13812 cmdline_fixed_string_t set;
13813 cmdline_fixed_string_t vf;
13814 cmdline_fixed_string_t split;
13815 cmdline_fixed_string_t drop;
13818 cmdline_fixed_string_t on_off;
13821 /* Common CLI fields for vf split drop enable disable */
13822 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13823 TOKEN_STRING_INITIALIZER
13824 (struct cmd_vf_split_drop_en_result,
13826 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13827 TOKEN_STRING_INITIALIZER
13828 (struct cmd_vf_split_drop_en_result,
13830 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13831 TOKEN_STRING_INITIALIZER
13832 (struct cmd_vf_split_drop_en_result,
13834 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13835 TOKEN_STRING_INITIALIZER
13836 (struct cmd_vf_split_drop_en_result,
13838 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13839 TOKEN_NUM_INITIALIZER
13840 (struct cmd_vf_split_drop_en_result,
13842 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13843 TOKEN_NUM_INITIALIZER
13844 (struct cmd_vf_split_drop_en_result,
13846 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13847 TOKEN_STRING_INITIALIZER
13848 (struct cmd_vf_split_drop_en_result,
13852 cmd_set_vf_split_drop_en_parsed(
13853 void *parsed_result,
13854 __attribute__((unused)) struct cmdline *cl,
13855 __attribute__((unused)) void *data)
13857 struct cmd_vf_split_drop_en_result *res = parsed_result;
13858 int ret = -ENOTSUP;
13859 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13861 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13864 #ifdef RTE_LIBRTE_IXGBE_PMD
13865 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13872 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13875 printf("invalid port_id %d\n", res->port_id);
13878 printf("not supported on port %d\n", res->port_id);
13881 printf("programming error: (%s)\n", strerror(-ret));
13885 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13886 .f = cmd_set_vf_split_drop_en_parsed,
13888 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13890 (void *)&cmd_vf_split_drop_en_set,
13891 (void *)&cmd_vf_split_drop_en_vf,
13892 (void *)&cmd_vf_split_drop_en_split,
13893 (void *)&cmd_vf_split_drop_en_drop,
13894 (void *)&cmd_vf_split_drop_en_port_id,
13895 (void *)&cmd_vf_split_drop_en_vf_id,
13896 (void *)&cmd_vf_split_drop_en_on_off,
13901 /* vf mac address configuration */
13903 /* Common result structure for vf mac address */
13904 struct cmd_set_vf_mac_addr_result {
13905 cmdline_fixed_string_t set;
13906 cmdline_fixed_string_t vf;
13907 cmdline_fixed_string_t mac;
13908 cmdline_fixed_string_t addr;
13911 struct rte_ether_addr mac_addr;
13915 /* Common CLI fields for vf split drop enable disable */
13916 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13917 TOKEN_STRING_INITIALIZER
13918 (struct cmd_set_vf_mac_addr_result,
13920 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13921 TOKEN_STRING_INITIALIZER
13922 (struct cmd_set_vf_mac_addr_result,
13924 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13925 TOKEN_STRING_INITIALIZER
13926 (struct cmd_set_vf_mac_addr_result,
13928 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13929 TOKEN_STRING_INITIALIZER
13930 (struct cmd_set_vf_mac_addr_result,
13932 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13933 TOKEN_NUM_INITIALIZER
13934 (struct cmd_set_vf_mac_addr_result,
13936 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13937 TOKEN_NUM_INITIALIZER
13938 (struct cmd_set_vf_mac_addr_result,
13940 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13941 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13945 cmd_set_vf_mac_addr_parsed(
13946 void *parsed_result,
13947 __attribute__((unused)) struct cmdline *cl,
13948 __attribute__((unused)) void *data)
13950 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13951 int ret = -ENOTSUP;
13953 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13956 #ifdef RTE_LIBRTE_IXGBE_PMD
13957 if (ret == -ENOTSUP)
13958 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13961 #ifdef RTE_LIBRTE_I40E_PMD
13962 if (ret == -ENOTSUP)
13963 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13966 #ifdef RTE_LIBRTE_BNXT_PMD
13967 if (ret == -ENOTSUP)
13968 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13976 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13979 printf("invalid port_id %d\n", res->port_id);
13982 printf("function not implemented\n");
13985 printf("programming error: (%s)\n", strerror(-ret));
13989 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13990 .f = cmd_set_vf_mac_addr_parsed,
13992 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13994 (void *)&cmd_set_vf_mac_addr_set,
13995 (void *)&cmd_set_vf_mac_addr_vf,
13996 (void *)&cmd_set_vf_mac_addr_mac,
13997 (void *)&cmd_set_vf_mac_addr_addr,
13998 (void *)&cmd_set_vf_mac_addr_port_id,
13999 (void *)&cmd_set_vf_mac_addr_vf_id,
14000 (void *)&cmd_set_vf_mac_addr_mac_addr,
14005 /* MACsec configuration */
14007 /* Common result structure for MACsec offload enable */
14008 struct cmd_macsec_offload_on_result {
14009 cmdline_fixed_string_t set;
14010 cmdline_fixed_string_t macsec;
14011 cmdline_fixed_string_t offload;
14013 cmdline_fixed_string_t on;
14014 cmdline_fixed_string_t encrypt;
14015 cmdline_fixed_string_t en_on_off;
14016 cmdline_fixed_string_t replay_protect;
14017 cmdline_fixed_string_t rp_on_off;
14020 /* Common CLI fields for MACsec offload disable */
14021 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
14022 TOKEN_STRING_INITIALIZER
14023 (struct cmd_macsec_offload_on_result,
14025 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
14026 TOKEN_STRING_INITIALIZER
14027 (struct cmd_macsec_offload_on_result,
14029 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
14030 TOKEN_STRING_INITIALIZER
14031 (struct cmd_macsec_offload_on_result,
14032 offload, "offload");
14033 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
14034 TOKEN_NUM_INITIALIZER
14035 (struct cmd_macsec_offload_on_result,
14037 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
14038 TOKEN_STRING_INITIALIZER
14039 (struct cmd_macsec_offload_on_result,
14041 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
14042 TOKEN_STRING_INITIALIZER
14043 (struct cmd_macsec_offload_on_result,
14044 encrypt, "encrypt");
14045 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
14046 TOKEN_STRING_INITIALIZER
14047 (struct cmd_macsec_offload_on_result,
14048 en_on_off, "on#off");
14049 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
14050 TOKEN_STRING_INITIALIZER
14051 (struct cmd_macsec_offload_on_result,
14052 replay_protect, "replay-protect");
14053 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
14054 TOKEN_STRING_INITIALIZER
14055 (struct cmd_macsec_offload_on_result,
14056 rp_on_off, "on#off");
14059 cmd_set_macsec_offload_on_parsed(
14060 void *parsed_result,
14061 __attribute__((unused)) struct cmdline *cl,
14062 __attribute__((unused)) void *data)
14064 struct cmd_macsec_offload_on_result *res = parsed_result;
14065 int ret = -ENOTSUP;
14066 portid_t port_id = res->port_id;
14067 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
14068 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
14069 struct rte_eth_dev_info dev_info;
14071 if (port_id_is_invalid(port_id, ENABLED_WARN))
14073 if (!port_is_stopped(port_id)) {
14074 printf("Please stop port %d first\n", port_id);
14078 rte_eth_dev_info_get(port_id, &dev_info);
14079 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14080 #ifdef RTE_LIBRTE_IXGBE_PMD
14081 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
14089 ports[port_id].dev_conf.txmode.offloads |=
14090 DEV_TX_OFFLOAD_MACSEC_INSERT;
14091 cmd_reconfig_device_queue(port_id, 1, 1);
14094 printf("invalid port_id %d\n", port_id);
14097 printf("not supported on port %d\n", port_id);
14100 printf("programming error: (%s)\n", strerror(-ret));
14104 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
14105 .f = cmd_set_macsec_offload_on_parsed,
14107 .help_str = "set macsec offload <port_id> on "
14108 "encrypt on|off replay-protect on|off",
14110 (void *)&cmd_macsec_offload_on_set,
14111 (void *)&cmd_macsec_offload_on_macsec,
14112 (void *)&cmd_macsec_offload_on_offload,
14113 (void *)&cmd_macsec_offload_on_port_id,
14114 (void *)&cmd_macsec_offload_on_on,
14115 (void *)&cmd_macsec_offload_on_encrypt,
14116 (void *)&cmd_macsec_offload_on_en_on_off,
14117 (void *)&cmd_macsec_offload_on_replay_protect,
14118 (void *)&cmd_macsec_offload_on_rp_on_off,
14123 /* Common result structure for MACsec offload disable */
14124 struct cmd_macsec_offload_off_result {
14125 cmdline_fixed_string_t set;
14126 cmdline_fixed_string_t macsec;
14127 cmdline_fixed_string_t offload;
14129 cmdline_fixed_string_t off;
14132 /* Common CLI fields for MACsec offload disable */
14133 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
14134 TOKEN_STRING_INITIALIZER
14135 (struct cmd_macsec_offload_off_result,
14137 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
14138 TOKEN_STRING_INITIALIZER
14139 (struct cmd_macsec_offload_off_result,
14141 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
14142 TOKEN_STRING_INITIALIZER
14143 (struct cmd_macsec_offload_off_result,
14144 offload, "offload");
14145 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
14146 TOKEN_NUM_INITIALIZER
14147 (struct cmd_macsec_offload_off_result,
14149 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
14150 TOKEN_STRING_INITIALIZER
14151 (struct cmd_macsec_offload_off_result,
14155 cmd_set_macsec_offload_off_parsed(
14156 void *parsed_result,
14157 __attribute__((unused)) struct cmdline *cl,
14158 __attribute__((unused)) void *data)
14160 struct cmd_macsec_offload_off_result *res = parsed_result;
14161 int ret = -ENOTSUP;
14162 struct rte_eth_dev_info dev_info;
14163 portid_t port_id = res->port_id;
14165 if (port_id_is_invalid(port_id, ENABLED_WARN))
14167 if (!port_is_stopped(port_id)) {
14168 printf("Please stop port %d first\n", port_id);
14172 rte_eth_dev_info_get(port_id, &dev_info);
14173 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
14174 #ifdef RTE_LIBRTE_IXGBE_PMD
14175 ret = rte_pmd_ixgbe_macsec_disable(port_id);
14180 ports[port_id].dev_conf.txmode.offloads &=
14181 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
14182 cmd_reconfig_device_queue(port_id, 1, 1);
14185 printf("invalid port_id %d\n", port_id);
14188 printf("not supported on port %d\n", port_id);
14191 printf("programming error: (%s)\n", strerror(-ret));
14195 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
14196 .f = cmd_set_macsec_offload_off_parsed,
14198 .help_str = "set macsec offload <port_id> off",
14200 (void *)&cmd_macsec_offload_off_set,
14201 (void *)&cmd_macsec_offload_off_macsec,
14202 (void *)&cmd_macsec_offload_off_offload,
14203 (void *)&cmd_macsec_offload_off_port_id,
14204 (void *)&cmd_macsec_offload_off_off,
14209 /* Common result structure for MACsec secure connection configure */
14210 struct cmd_macsec_sc_result {
14211 cmdline_fixed_string_t set;
14212 cmdline_fixed_string_t macsec;
14213 cmdline_fixed_string_t sc;
14214 cmdline_fixed_string_t tx_rx;
14216 struct rte_ether_addr mac;
14220 /* Common CLI fields for MACsec secure connection configure */
14221 cmdline_parse_token_string_t cmd_macsec_sc_set =
14222 TOKEN_STRING_INITIALIZER
14223 (struct cmd_macsec_sc_result,
14225 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
14226 TOKEN_STRING_INITIALIZER
14227 (struct cmd_macsec_sc_result,
14229 cmdline_parse_token_string_t cmd_macsec_sc_sc =
14230 TOKEN_STRING_INITIALIZER
14231 (struct cmd_macsec_sc_result,
14233 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
14234 TOKEN_STRING_INITIALIZER
14235 (struct cmd_macsec_sc_result,
14237 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
14238 TOKEN_NUM_INITIALIZER
14239 (struct cmd_macsec_sc_result,
14241 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
14242 TOKEN_ETHERADDR_INITIALIZER
14243 (struct cmd_macsec_sc_result,
14245 cmdline_parse_token_num_t cmd_macsec_sc_pi =
14246 TOKEN_NUM_INITIALIZER
14247 (struct cmd_macsec_sc_result,
14251 cmd_set_macsec_sc_parsed(
14252 void *parsed_result,
14253 __attribute__((unused)) struct cmdline *cl,
14254 __attribute__((unused)) void *data)
14256 struct cmd_macsec_sc_result *res = parsed_result;
14257 int ret = -ENOTSUP;
14258 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14260 #ifdef RTE_LIBRTE_IXGBE_PMD
14262 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
14263 res->mac.addr_bytes) :
14264 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
14265 res->mac.addr_bytes, res->pi);
14267 RTE_SET_USED(is_tx);
14273 printf("invalid port_id %d\n", res->port_id);
14276 printf("not supported on port %d\n", res->port_id);
14279 printf("programming error: (%s)\n", strerror(-ret));
14283 cmdline_parse_inst_t cmd_set_macsec_sc = {
14284 .f = cmd_set_macsec_sc_parsed,
14286 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
14288 (void *)&cmd_macsec_sc_set,
14289 (void *)&cmd_macsec_sc_macsec,
14290 (void *)&cmd_macsec_sc_sc,
14291 (void *)&cmd_macsec_sc_tx_rx,
14292 (void *)&cmd_macsec_sc_port_id,
14293 (void *)&cmd_macsec_sc_mac,
14294 (void *)&cmd_macsec_sc_pi,
14299 /* Common result structure for MACsec secure connection configure */
14300 struct cmd_macsec_sa_result {
14301 cmdline_fixed_string_t set;
14302 cmdline_fixed_string_t macsec;
14303 cmdline_fixed_string_t sa;
14304 cmdline_fixed_string_t tx_rx;
14309 cmdline_fixed_string_t key;
14312 /* Common CLI fields for MACsec secure connection configure */
14313 cmdline_parse_token_string_t cmd_macsec_sa_set =
14314 TOKEN_STRING_INITIALIZER
14315 (struct cmd_macsec_sa_result,
14317 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
14318 TOKEN_STRING_INITIALIZER
14319 (struct cmd_macsec_sa_result,
14321 cmdline_parse_token_string_t cmd_macsec_sa_sa =
14322 TOKEN_STRING_INITIALIZER
14323 (struct cmd_macsec_sa_result,
14325 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
14326 TOKEN_STRING_INITIALIZER
14327 (struct cmd_macsec_sa_result,
14329 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
14330 TOKEN_NUM_INITIALIZER
14331 (struct cmd_macsec_sa_result,
14333 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14334 TOKEN_NUM_INITIALIZER
14335 (struct cmd_macsec_sa_result,
14337 cmdline_parse_token_num_t cmd_macsec_sa_an =
14338 TOKEN_NUM_INITIALIZER
14339 (struct cmd_macsec_sa_result,
14341 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14342 TOKEN_NUM_INITIALIZER
14343 (struct cmd_macsec_sa_result,
14345 cmdline_parse_token_string_t cmd_macsec_sa_key =
14346 TOKEN_STRING_INITIALIZER
14347 (struct cmd_macsec_sa_result,
14351 cmd_set_macsec_sa_parsed(
14352 void *parsed_result,
14353 __attribute__((unused)) struct cmdline *cl,
14354 __attribute__((unused)) void *data)
14356 struct cmd_macsec_sa_result *res = parsed_result;
14357 int ret = -ENOTSUP;
14358 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14359 uint8_t key[16] = { 0 };
14365 key_len = strlen(res->key) / 2;
14369 for (i = 0; i < key_len; i++) {
14370 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14373 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14376 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14379 #ifdef RTE_LIBRTE_IXGBE_PMD
14381 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14382 res->idx, res->an, res->pn, key) :
14383 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14384 res->idx, res->an, res->pn, key);
14386 RTE_SET_USED(is_tx);
14393 printf("invalid idx %d or an %d\n", res->idx, res->an);
14396 printf("invalid port_id %d\n", res->port_id);
14399 printf("not supported on port %d\n", res->port_id);
14402 printf("programming error: (%s)\n", strerror(-ret));
14406 cmdline_parse_inst_t cmd_set_macsec_sa = {
14407 .f = cmd_set_macsec_sa_parsed,
14409 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14411 (void *)&cmd_macsec_sa_set,
14412 (void *)&cmd_macsec_sa_macsec,
14413 (void *)&cmd_macsec_sa_sa,
14414 (void *)&cmd_macsec_sa_tx_rx,
14415 (void *)&cmd_macsec_sa_port_id,
14416 (void *)&cmd_macsec_sa_idx,
14417 (void *)&cmd_macsec_sa_an,
14418 (void *)&cmd_macsec_sa_pn,
14419 (void *)&cmd_macsec_sa_key,
14424 /* VF unicast promiscuous mode configuration */
14426 /* Common result structure for VF unicast promiscuous mode */
14427 struct cmd_vf_promisc_result {
14428 cmdline_fixed_string_t set;
14429 cmdline_fixed_string_t vf;
14430 cmdline_fixed_string_t promisc;
14433 cmdline_fixed_string_t on_off;
14436 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14437 cmdline_parse_token_string_t cmd_vf_promisc_set =
14438 TOKEN_STRING_INITIALIZER
14439 (struct cmd_vf_promisc_result,
14441 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14442 TOKEN_STRING_INITIALIZER
14443 (struct cmd_vf_promisc_result,
14445 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14446 TOKEN_STRING_INITIALIZER
14447 (struct cmd_vf_promisc_result,
14448 promisc, "promisc");
14449 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14450 TOKEN_NUM_INITIALIZER
14451 (struct cmd_vf_promisc_result,
14453 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14454 TOKEN_NUM_INITIALIZER
14455 (struct cmd_vf_promisc_result,
14457 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14458 TOKEN_STRING_INITIALIZER
14459 (struct cmd_vf_promisc_result,
14463 cmd_set_vf_promisc_parsed(
14464 void *parsed_result,
14465 __attribute__((unused)) struct cmdline *cl,
14466 __attribute__((unused)) void *data)
14468 struct cmd_vf_promisc_result *res = parsed_result;
14469 int ret = -ENOTSUP;
14471 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14473 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14476 #ifdef RTE_LIBRTE_I40E_PMD
14477 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14478 res->vf_id, is_on);
14485 printf("invalid vf_id %d\n", res->vf_id);
14488 printf("invalid port_id %d\n", res->port_id);
14491 printf("function not implemented\n");
14494 printf("programming error: (%s)\n", strerror(-ret));
14498 cmdline_parse_inst_t cmd_set_vf_promisc = {
14499 .f = cmd_set_vf_promisc_parsed,
14501 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14502 "Set unicast promiscuous mode for a VF from the PF",
14504 (void *)&cmd_vf_promisc_set,
14505 (void *)&cmd_vf_promisc_vf,
14506 (void *)&cmd_vf_promisc_promisc,
14507 (void *)&cmd_vf_promisc_port_id,
14508 (void *)&cmd_vf_promisc_vf_id,
14509 (void *)&cmd_vf_promisc_on_off,
14514 /* VF multicast promiscuous mode configuration */
14516 /* Common result structure for VF multicast promiscuous mode */
14517 struct cmd_vf_allmulti_result {
14518 cmdline_fixed_string_t set;
14519 cmdline_fixed_string_t vf;
14520 cmdline_fixed_string_t allmulti;
14523 cmdline_fixed_string_t on_off;
14526 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14527 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14528 TOKEN_STRING_INITIALIZER
14529 (struct cmd_vf_allmulti_result,
14531 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14532 TOKEN_STRING_INITIALIZER
14533 (struct cmd_vf_allmulti_result,
14535 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14536 TOKEN_STRING_INITIALIZER
14537 (struct cmd_vf_allmulti_result,
14538 allmulti, "allmulti");
14539 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14540 TOKEN_NUM_INITIALIZER
14541 (struct cmd_vf_allmulti_result,
14543 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14544 TOKEN_NUM_INITIALIZER
14545 (struct cmd_vf_allmulti_result,
14547 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14548 TOKEN_STRING_INITIALIZER
14549 (struct cmd_vf_allmulti_result,
14553 cmd_set_vf_allmulti_parsed(
14554 void *parsed_result,
14555 __attribute__((unused)) struct cmdline *cl,
14556 __attribute__((unused)) void *data)
14558 struct cmd_vf_allmulti_result *res = parsed_result;
14559 int ret = -ENOTSUP;
14561 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14563 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14566 #ifdef RTE_LIBRTE_I40E_PMD
14567 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14568 res->vf_id, is_on);
14575 printf("invalid vf_id %d\n", res->vf_id);
14578 printf("invalid port_id %d\n", res->port_id);
14581 printf("function not implemented\n");
14584 printf("programming error: (%s)\n", strerror(-ret));
14588 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14589 .f = cmd_set_vf_allmulti_parsed,
14591 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14592 "Set multicast promiscuous mode for a VF from the PF",
14594 (void *)&cmd_vf_allmulti_set,
14595 (void *)&cmd_vf_allmulti_vf,
14596 (void *)&cmd_vf_allmulti_allmulti,
14597 (void *)&cmd_vf_allmulti_port_id,
14598 (void *)&cmd_vf_allmulti_vf_id,
14599 (void *)&cmd_vf_allmulti_on_off,
14604 /* vf broadcast mode configuration */
14606 /* Common result structure for vf broadcast */
14607 struct cmd_set_vf_broadcast_result {
14608 cmdline_fixed_string_t set;
14609 cmdline_fixed_string_t vf;
14610 cmdline_fixed_string_t broadcast;
14613 cmdline_fixed_string_t on_off;
14616 /* Common CLI fields for vf broadcast enable disable */
14617 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14618 TOKEN_STRING_INITIALIZER
14619 (struct cmd_set_vf_broadcast_result,
14621 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14622 TOKEN_STRING_INITIALIZER
14623 (struct cmd_set_vf_broadcast_result,
14625 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14626 TOKEN_STRING_INITIALIZER
14627 (struct cmd_set_vf_broadcast_result,
14628 broadcast, "broadcast");
14629 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14630 TOKEN_NUM_INITIALIZER
14631 (struct cmd_set_vf_broadcast_result,
14633 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14634 TOKEN_NUM_INITIALIZER
14635 (struct cmd_set_vf_broadcast_result,
14637 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14638 TOKEN_STRING_INITIALIZER
14639 (struct cmd_set_vf_broadcast_result,
14643 cmd_set_vf_broadcast_parsed(
14644 void *parsed_result,
14645 __attribute__((unused)) struct cmdline *cl,
14646 __attribute__((unused)) void *data)
14648 struct cmd_set_vf_broadcast_result *res = parsed_result;
14649 int ret = -ENOTSUP;
14651 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14653 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14656 #ifdef RTE_LIBRTE_I40E_PMD
14657 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14658 res->vf_id, is_on);
14665 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14668 printf("invalid port_id %d\n", res->port_id);
14671 printf("function not implemented\n");
14674 printf("programming error: (%s)\n", strerror(-ret));
14678 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14679 .f = cmd_set_vf_broadcast_parsed,
14681 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14683 (void *)&cmd_set_vf_broadcast_set,
14684 (void *)&cmd_set_vf_broadcast_vf,
14685 (void *)&cmd_set_vf_broadcast_broadcast,
14686 (void *)&cmd_set_vf_broadcast_port_id,
14687 (void *)&cmd_set_vf_broadcast_vf_id,
14688 (void *)&cmd_set_vf_broadcast_on_off,
14693 /* vf vlan tag configuration */
14695 /* Common result structure for vf vlan tag */
14696 struct cmd_set_vf_vlan_tag_result {
14697 cmdline_fixed_string_t set;
14698 cmdline_fixed_string_t vf;
14699 cmdline_fixed_string_t vlan;
14700 cmdline_fixed_string_t tag;
14703 cmdline_fixed_string_t on_off;
14706 /* Common CLI fields for vf vlan tag enable disable */
14707 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14708 TOKEN_STRING_INITIALIZER
14709 (struct cmd_set_vf_vlan_tag_result,
14711 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14712 TOKEN_STRING_INITIALIZER
14713 (struct cmd_set_vf_vlan_tag_result,
14715 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14716 TOKEN_STRING_INITIALIZER
14717 (struct cmd_set_vf_vlan_tag_result,
14719 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14720 TOKEN_STRING_INITIALIZER
14721 (struct cmd_set_vf_vlan_tag_result,
14723 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14724 TOKEN_NUM_INITIALIZER
14725 (struct cmd_set_vf_vlan_tag_result,
14727 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14728 TOKEN_NUM_INITIALIZER
14729 (struct cmd_set_vf_vlan_tag_result,
14731 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14732 TOKEN_STRING_INITIALIZER
14733 (struct cmd_set_vf_vlan_tag_result,
14737 cmd_set_vf_vlan_tag_parsed(
14738 void *parsed_result,
14739 __attribute__((unused)) struct cmdline *cl,
14740 __attribute__((unused)) void *data)
14742 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14743 int ret = -ENOTSUP;
14745 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14747 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14750 #ifdef RTE_LIBRTE_I40E_PMD
14751 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14752 res->vf_id, is_on);
14759 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14762 printf("invalid port_id %d\n", res->port_id);
14765 printf("function not implemented\n");
14768 printf("programming error: (%s)\n", strerror(-ret));
14772 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14773 .f = cmd_set_vf_vlan_tag_parsed,
14775 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14777 (void *)&cmd_set_vf_vlan_tag_set,
14778 (void *)&cmd_set_vf_vlan_tag_vf,
14779 (void *)&cmd_set_vf_vlan_tag_vlan,
14780 (void *)&cmd_set_vf_vlan_tag_tag,
14781 (void *)&cmd_set_vf_vlan_tag_port_id,
14782 (void *)&cmd_set_vf_vlan_tag_vf_id,
14783 (void *)&cmd_set_vf_vlan_tag_on_off,
14788 /* Common definition of VF and TC TX bandwidth configuration */
14789 struct cmd_vf_tc_bw_result {
14790 cmdline_fixed_string_t set;
14791 cmdline_fixed_string_t vf;
14792 cmdline_fixed_string_t tc;
14793 cmdline_fixed_string_t tx;
14794 cmdline_fixed_string_t min_bw;
14795 cmdline_fixed_string_t max_bw;
14796 cmdline_fixed_string_t strict_link_prio;
14801 cmdline_fixed_string_t bw_list;
14805 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14806 TOKEN_STRING_INITIALIZER
14807 (struct cmd_vf_tc_bw_result,
14809 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14810 TOKEN_STRING_INITIALIZER
14811 (struct cmd_vf_tc_bw_result,
14813 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14814 TOKEN_STRING_INITIALIZER
14815 (struct cmd_vf_tc_bw_result,
14817 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14818 TOKEN_STRING_INITIALIZER
14819 (struct cmd_vf_tc_bw_result,
14821 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14822 TOKEN_STRING_INITIALIZER
14823 (struct cmd_vf_tc_bw_result,
14824 strict_link_prio, "strict-link-priority");
14825 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14826 TOKEN_STRING_INITIALIZER
14827 (struct cmd_vf_tc_bw_result,
14828 min_bw, "min-bandwidth");
14829 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14830 TOKEN_STRING_INITIALIZER
14831 (struct cmd_vf_tc_bw_result,
14832 max_bw, "max-bandwidth");
14833 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14834 TOKEN_NUM_INITIALIZER
14835 (struct cmd_vf_tc_bw_result,
14837 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14838 TOKEN_NUM_INITIALIZER
14839 (struct cmd_vf_tc_bw_result,
14841 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14842 TOKEN_NUM_INITIALIZER
14843 (struct cmd_vf_tc_bw_result,
14845 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14846 TOKEN_NUM_INITIALIZER
14847 (struct cmd_vf_tc_bw_result,
14849 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14850 TOKEN_STRING_INITIALIZER
14851 (struct cmd_vf_tc_bw_result,
14853 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14854 TOKEN_NUM_INITIALIZER
14855 (struct cmd_vf_tc_bw_result,
14858 /* VF max bandwidth setting */
14860 cmd_vf_max_bw_parsed(
14861 void *parsed_result,
14862 __attribute__((unused)) struct cmdline *cl,
14863 __attribute__((unused)) void *data)
14865 struct cmd_vf_tc_bw_result *res = parsed_result;
14866 int ret = -ENOTSUP;
14868 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14871 #ifdef RTE_LIBRTE_I40E_PMD
14872 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14873 res->vf_id, res->bw);
14880 printf("invalid vf_id %d or bandwidth %d\n",
14881 res->vf_id, res->bw);
14884 printf("invalid port_id %d\n", res->port_id);
14887 printf("function not implemented\n");
14890 printf("programming error: (%s)\n", strerror(-ret));
14894 cmdline_parse_inst_t cmd_vf_max_bw = {
14895 .f = cmd_vf_max_bw_parsed,
14897 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14899 (void *)&cmd_vf_tc_bw_set,
14900 (void *)&cmd_vf_tc_bw_vf,
14901 (void *)&cmd_vf_tc_bw_tx,
14902 (void *)&cmd_vf_tc_bw_max_bw,
14903 (void *)&cmd_vf_tc_bw_port_id,
14904 (void *)&cmd_vf_tc_bw_vf_id,
14905 (void *)&cmd_vf_tc_bw_bw,
14911 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14916 const char *p, *p0 = str;
14923 p = strchr(p0, '(');
14925 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14929 p0 = strchr(p, ')');
14931 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14935 if (size >= sizeof(s)) {
14936 printf("The string size exceeds the internal buffer size\n");
14939 snprintf(s, sizeof(s), "%.*s", size, p);
14940 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14942 printf("Failed to get the bandwidth list. ");
14946 for (i = 0; i < ret; i++)
14947 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14952 /* TC min bandwidth setting */
14954 cmd_vf_tc_min_bw_parsed(
14955 void *parsed_result,
14956 __attribute__((unused)) struct cmdline *cl,
14957 __attribute__((unused)) void *data)
14959 struct cmd_vf_tc_bw_result *res = parsed_result;
14962 int ret = -ENOTSUP;
14964 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14967 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14971 #ifdef RTE_LIBRTE_I40E_PMD
14972 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14980 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14983 printf("invalid port_id %d\n", res->port_id);
14986 printf("function not implemented\n");
14989 printf("programming error: (%s)\n", strerror(-ret));
14993 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14994 .f = cmd_vf_tc_min_bw_parsed,
14996 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14997 " <bw1, bw2, ...>",
14999 (void *)&cmd_vf_tc_bw_set,
15000 (void *)&cmd_vf_tc_bw_vf,
15001 (void *)&cmd_vf_tc_bw_tc,
15002 (void *)&cmd_vf_tc_bw_tx,
15003 (void *)&cmd_vf_tc_bw_min_bw,
15004 (void *)&cmd_vf_tc_bw_port_id,
15005 (void *)&cmd_vf_tc_bw_vf_id,
15006 (void *)&cmd_vf_tc_bw_bw_list,
15012 cmd_tc_min_bw_parsed(
15013 void *parsed_result,
15014 __attribute__((unused)) struct cmdline *cl,
15015 __attribute__((unused)) void *data)
15017 struct cmd_vf_tc_bw_result *res = parsed_result;
15018 struct rte_port *port;
15021 int ret = -ENOTSUP;
15023 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15026 port = &ports[res->port_id];
15027 /** Check if the port is not started **/
15028 if (port->port_status != RTE_PORT_STOPPED) {
15029 printf("Please stop port %d first\n", res->port_id);
15033 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
15037 #ifdef RTE_LIBRTE_IXGBE_PMD
15038 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
15045 printf("invalid bandwidth\n");
15048 printf("invalid port_id %d\n", res->port_id);
15051 printf("function not implemented\n");
15054 printf("programming error: (%s)\n", strerror(-ret));
15058 cmdline_parse_inst_t cmd_tc_min_bw = {
15059 .f = cmd_tc_min_bw_parsed,
15061 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
15063 (void *)&cmd_vf_tc_bw_set,
15064 (void *)&cmd_vf_tc_bw_tc,
15065 (void *)&cmd_vf_tc_bw_tx,
15066 (void *)&cmd_vf_tc_bw_min_bw,
15067 (void *)&cmd_vf_tc_bw_port_id,
15068 (void *)&cmd_vf_tc_bw_bw_list,
15073 /* TC max bandwidth setting */
15075 cmd_vf_tc_max_bw_parsed(
15076 void *parsed_result,
15077 __attribute__((unused)) struct cmdline *cl,
15078 __attribute__((unused)) void *data)
15080 struct cmd_vf_tc_bw_result *res = parsed_result;
15081 int ret = -ENOTSUP;
15083 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15086 #ifdef RTE_LIBRTE_I40E_PMD
15087 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
15088 res->tc_no, res->bw);
15095 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
15096 res->vf_id, res->tc_no, res->bw);
15099 printf("invalid port_id %d\n", res->port_id);
15102 printf("function not implemented\n");
15105 printf("programming error: (%s)\n", strerror(-ret));
15109 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
15110 .f = cmd_vf_tc_max_bw_parsed,
15112 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
15115 (void *)&cmd_vf_tc_bw_set,
15116 (void *)&cmd_vf_tc_bw_vf,
15117 (void *)&cmd_vf_tc_bw_tc,
15118 (void *)&cmd_vf_tc_bw_tx,
15119 (void *)&cmd_vf_tc_bw_max_bw,
15120 (void *)&cmd_vf_tc_bw_port_id,
15121 (void *)&cmd_vf_tc_bw_vf_id,
15122 (void *)&cmd_vf_tc_bw_tc_no,
15123 (void *)&cmd_vf_tc_bw_bw,
15129 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
15131 /* *** Set Port default Traffic Management Hierarchy *** */
15132 struct cmd_set_port_tm_hierarchy_default_result {
15133 cmdline_fixed_string_t set;
15134 cmdline_fixed_string_t port;
15135 cmdline_fixed_string_t tm;
15136 cmdline_fixed_string_t hierarchy;
15137 cmdline_fixed_string_t def;
15141 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
15142 TOKEN_STRING_INITIALIZER(
15143 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
15144 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
15145 TOKEN_STRING_INITIALIZER(
15146 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
15147 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
15148 TOKEN_STRING_INITIALIZER(
15149 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
15150 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
15151 TOKEN_STRING_INITIALIZER(
15152 struct cmd_set_port_tm_hierarchy_default_result,
15153 hierarchy, "hierarchy");
15154 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
15155 TOKEN_STRING_INITIALIZER(
15156 struct cmd_set_port_tm_hierarchy_default_result,
15158 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
15159 TOKEN_NUM_INITIALIZER(
15160 struct cmd_set_port_tm_hierarchy_default_result,
15163 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
15164 __attribute__((unused)) struct cmdline *cl,
15165 __attribute__((unused)) void *data)
15167 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
15168 struct rte_port *p;
15169 portid_t port_id = res->port_id;
15171 if (port_id_is_invalid(port_id, ENABLED_WARN))
15174 p = &ports[port_id];
15176 /* Forward mode: tm */
15177 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
15178 printf(" softnicfwd mode not enabled(error)\n");
15182 /* Set the default tm hierarchy */
15183 p->softport.default_tm_hierarchy_enable = 1;
15186 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
15187 .f = cmd_set_port_tm_hierarchy_default_parsed,
15189 .help_str = "set port tm hierarchy default <port_id>",
15191 (void *)&cmd_set_port_tm_hierarchy_default_set,
15192 (void *)&cmd_set_port_tm_hierarchy_default_port,
15193 (void *)&cmd_set_port_tm_hierarchy_default_tm,
15194 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
15195 (void *)&cmd_set_port_tm_hierarchy_default_default,
15196 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
15202 /** Set VXLAN encapsulation details */
15203 struct cmd_set_vxlan_result {
15204 cmdline_fixed_string_t set;
15205 cmdline_fixed_string_t vxlan;
15206 cmdline_fixed_string_t pos_token;
15207 cmdline_fixed_string_t ip_version;
15208 uint32_t vlan_present:1;
15212 cmdline_ipaddr_t ip_src;
15213 cmdline_ipaddr_t ip_dst;
15217 struct rte_ether_addr eth_src;
15218 struct rte_ether_addr eth_dst;
15221 cmdline_parse_token_string_t cmd_set_vxlan_set =
15222 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
15223 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
15224 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
15225 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
15226 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15228 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
15229 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
15230 "vxlan-with-vlan");
15231 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
15232 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15234 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
15235 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
15237 cmdline_parse_token_string_t cmd_set_vxlan_vni =
15238 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15240 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
15241 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
15242 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
15243 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15245 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
15246 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
15247 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
15248 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15250 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
15251 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
15252 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
15253 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15255 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
15256 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
15257 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
15258 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15260 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
15261 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
15262 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
15263 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15265 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
15266 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
15267 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
15268 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15270 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
15271 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
15272 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
15273 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15275 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
15276 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
15277 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
15278 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15280 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
15281 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
15282 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
15283 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
15285 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
15286 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
15288 static void cmd_set_vxlan_parsed(void *parsed_result,
15289 __attribute__((unused)) struct cmdline *cl,
15290 __attribute__((unused)) void *data)
15292 struct cmd_set_vxlan_result *res = parsed_result;
15297 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
15300 vxlan_encap_conf.select_tos_ttl = 0;
15301 if (strcmp(res->vxlan, "vxlan") == 0)
15302 vxlan_encap_conf.select_vlan = 0;
15303 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
15304 vxlan_encap_conf.select_vlan = 1;
15305 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
15306 vxlan_encap_conf.select_vlan = 0;
15307 vxlan_encap_conf.select_tos_ttl = 1;
15309 if (strcmp(res->ip_version, "ipv4") == 0)
15310 vxlan_encap_conf.select_ipv4 = 1;
15311 else if (strcmp(res->ip_version, "ipv6") == 0)
15312 vxlan_encap_conf.select_ipv4 = 0;
15315 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
15316 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
15317 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
15318 vxlan_encap_conf.ip_tos = res->tos;
15319 vxlan_encap_conf.ip_ttl = res->ttl;
15320 if (vxlan_encap_conf.select_ipv4) {
15321 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
15322 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
15324 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
15325 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
15327 if (vxlan_encap_conf.select_vlan)
15328 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15329 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
15330 RTE_ETHER_ADDR_LEN);
15331 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15332 RTE_ETHER_ADDR_LEN);
15335 cmdline_parse_inst_t cmd_set_vxlan = {
15336 .f = cmd_set_vxlan_parsed,
15338 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
15339 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
15340 " eth-src <eth-src> eth-dst <eth-dst>",
15342 (void *)&cmd_set_vxlan_set,
15343 (void *)&cmd_set_vxlan_vxlan,
15344 (void *)&cmd_set_vxlan_ip_version,
15345 (void *)&cmd_set_vxlan_ip_version_value,
15346 (void *)&cmd_set_vxlan_vni,
15347 (void *)&cmd_set_vxlan_vni_value,
15348 (void *)&cmd_set_vxlan_udp_src,
15349 (void *)&cmd_set_vxlan_udp_src_value,
15350 (void *)&cmd_set_vxlan_udp_dst,
15351 (void *)&cmd_set_vxlan_udp_dst_value,
15352 (void *)&cmd_set_vxlan_ip_src,
15353 (void *)&cmd_set_vxlan_ip_src_value,
15354 (void *)&cmd_set_vxlan_ip_dst,
15355 (void *)&cmd_set_vxlan_ip_dst_value,
15356 (void *)&cmd_set_vxlan_eth_src,
15357 (void *)&cmd_set_vxlan_eth_src_value,
15358 (void *)&cmd_set_vxlan_eth_dst,
15359 (void *)&cmd_set_vxlan_eth_dst_value,
15364 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
15365 .f = cmd_set_vxlan_parsed,
15367 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
15368 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
15369 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15370 " eth-dst <eth-dst>",
15372 (void *)&cmd_set_vxlan_set,
15373 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
15374 (void *)&cmd_set_vxlan_ip_version,
15375 (void *)&cmd_set_vxlan_ip_version_value,
15376 (void *)&cmd_set_vxlan_vni,
15377 (void *)&cmd_set_vxlan_vni_value,
15378 (void *)&cmd_set_vxlan_udp_src,
15379 (void *)&cmd_set_vxlan_udp_src_value,
15380 (void *)&cmd_set_vxlan_udp_dst,
15381 (void *)&cmd_set_vxlan_udp_dst_value,
15382 (void *)&cmd_set_vxlan_ip_tos,
15383 (void *)&cmd_set_vxlan_ip_tos_value,
15384 (void *)&cmd_set_vxlan_ip_ttl,
15385 (void *)&cmd_set_vxlan_ip_ttl_value,
15386 (void *)&cmd_set_vxlan_ip_src,
15387 (void *)&cmd_set_vxlan_ip_src_value,
15388 (void *)&cmd_set_vxlan_ip_dst,
15389 (void *)&cmd_set_vxlan_ip_dst_value,
15390 (void *)&cmd_set_vxlan_eth_src,
15391 (void *)&cmd_set_vxlan_eth_src_value,
15392 (void *)&cmd_set_vxlan_eth_dst,
15393 (void *)&cmd_set_vxlan_eth_dst_value,
15398 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15399 .f = cmd_set_vxlan_parsed,
15401 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15402 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15403 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15406 (void *)&cmd_set_vxlan_set,
15407 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15408 (void *)&cmd_set_vxlan_ip_version,
15409 (void *)&cmd_set_vxlan_ip_version_value,
15410 (void *)&cmd_set_vxlan_vni,
15411 (void *)&cmd_set_vxlan_vni_value,
15412 (void *)&cmd_set_vxlan_udp_src,
15413 (void *)&cmd_set_vxlan_udp_src_value,
15414 (void *)&cmd_set_vxlan_udp_dst,
15415 (void *)&cmd_set_vxlan_udp_dst_value,
15416 (void *)&cmd_set_vxlan_ip_src,
15417 (void *)&cmd_set_vxlan_ip_src_value,
15418 (void *)&cmd_set_vxlan_ip_dst,
15419 (void *)&cmd_set_vxlan_ip_dst_value,
15420 (void *)&cmd_set_vxlan_vlan,
15421 (void *)&cmd_set_vxlan_vlan_value,
15422 (void *)&cmd_set_vxlan_eth_src,
15423 (void *)&cmd_set_vxlan_eth_src_value,
15424 (void *)&cmd_set_vxlan_eth_dst,
15425 (void *)&cmd_set_vxlan_eth_dst_value,
15430 /** Set NVGRE encapsulation details */
15431 struct cmd_set_nvgre_result {
15432 cmdline_fixed_string_t set;
15433 cmdline_fixed_string_t nvgre;
15434 cmdline_fixed_string_t pos_token;
15435 cmdline_fixed_string_t ip_version;
15437 cmdline_ipaddr_t ip_src;
15438 cmdline_ipaddr_t ip_dst;
15440 struct rte_ether_addr eth_src;
15441 struct rte_ether_addr eth_dst;
15444 cmdline_parse_token_string_t cmd_set_nvgre_set =
15445 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15446 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15447 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15448 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15449 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15450 "nvgre-with-vlan");
15451 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15452 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15454 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15455 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15457 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15458 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15460 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15461 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15462 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15463 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15465 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15466 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15467 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15468 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15470 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15471 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15472 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15473 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15475 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15476 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15477 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15478 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15480 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15481 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15482 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15483 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15485 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15486 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15488 static void cmd_set_nvgre_parsed(void *parsed_result,
15489 __attribute__((unused)) struct cmdline *cl,
15490 __attribute__((unused)) void *data)
15492 struct cmd_set_nvgre_result *res = parsed_result;
15494 uint32_t nvgre_tni;
15497 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15500 if (strcmp(res->nvgre, "nvgre") == 0)
15501 nvgre_encap_conf.select_vlan = 0;
15502 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15503 nvgre_encap_conf.select_vlan = 1;
15504 if (strcmp(res->ip_version, "ipv4") == 0)
15505 nvgre_encap_conf.select_ipv4 = 1;
15506 else if (strcmp(res->ip_version, "ipv6") == 0)
15507 nvgre_encap_conf.select_ipv4 = 0;
15510 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15511 if (nvgre_encap_conf.select_ipv4) {
15512 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15513 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15515 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15516 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15518 if (nvgre_encap_conf.select_vlan)
15519 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15520 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15521 RTE_ETHER_ADDR_LEN);
15522 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15523 RTE_ETHER_ADDR_LEN);
15526 cmdline_parse_inst_t cmd_set_nvgre = {
15527 .f = cmd_set_nvgre_parsed,
15529 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15530 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15531 " eth-dst <eth-dst>",
15533 (void *)&cmd_set_nvgre_set,
15534 (void *)&cmd_set_nvgre_nvgre,
15535 (void *)&cmd_set_nvgre_ip_version,
15536 (void *)&cmd_set_nvgre_ip_version_value,
15537 (void *)&cmd_set_nvgre_tni,
15538 (void *)&cmd_set_nvgre_tni_value,
15539 (void *)&cmd_set_nvgre_ip_src,
15540 (void *)&cmd_set_nvgre_ip_src_value,
15541 (void *)&cmd_set_nvgre_ip_dst,
15542 (void *)&cmd_set_nvgre_ip_dst_value,
15543 (void *)&cmd_set_nvgre_eth_src,
15544 (void *)&cmd_set_nvgre_eth_src_value,
15545 (void *)&cmd_set_nvgre_eth_dst,
15546 (void *)&cmd_set_nvgre_eth_dst_value,
15551 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15552 .f = cmd_set_nvgre_parsed,
15554 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15555 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15556 " eth-src <eth-src> eth-dst <eth-dst>",
15558 (void *)&cmd_set_nvgre_set,
15559 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15560 (void *)&cmd_set_nvgre_ip_version,
15561 (void *)&cmd_set_nvgre_ip_version_value,
15562 (void *)&cmd_set_nvgre_tni,
15563 (void *)&cmd_set_nvgre_tni_value,
15564 (void *)&cmd_set_nvgre_ip_src,
15565 (void *)&cmd_set_nvgre_ip_src_value,
15566 (void *)&cmd_set_nvgre_ip_dst,
15567 (void *)&cmd_set_nvgre_ip_dst_value,
15568 (void *)&cmd_set_nvgre_vlan,
15569 (void *)&cmd_set_nvgre_vlan_value,
15570 (void *)&cmd_set_nvgre_eth_src,
15571 (void *)&cmd_set_nvgre_eth_src_value,
15572 (void *)&cmd_set_nvgre_eth_dst,
15573 (void *)&cmd_set_nvgre_eth_dst_value,
15578 /** Set L2 encapsulation details */
15579 struct cmd_set_l2_encap_result {
15580 cmdline_fixed_string_t set;
15581 cmdline_fixed_string_t l2_encap;
15582 cmdline_fixed_string_t pos_token;
15583 cmdline_fixed_string_t ip_version;
15584 uint32_t vlan_present:1;
15586 struct rte_ether_addr eth_src;
15587 struct rte_ether_addr eth_dst;
15590 cmdline_parse_token_string_t cmd_set_l2_encap_set =
15591 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
15592 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
15593 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
15594 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
15595 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
15596 "l2_encap-with-vlan");
15597 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
15598 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15600 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
15601 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
15603 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
15604 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15606 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
15607 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
15608 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
15609 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15611 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
15612 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
15613 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
15614 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
15616 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
15617 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
15619 static void cmd_set_l2_encap_parsed(void *parsed_result,
15620 __attribute__((unused)) struct cmdline *cl,
15621 __attribute__((unused)) void *data)
15623 struct cmd_set_l2_encap_result *res = parsed_result;
15625 if (strcmp(res->l2_encap, "l2_encap") == 0)
15626 l2_encap_conf.select_vlan = 0;
15627 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
15628 l2_encap_conf.select_vlan = 1;
15629 if (strcmp(res->ip_version, "ipv4") == 0)
15630 l2_encap_conf.select_ipv4 = 1;
15631 else if (strcmp(res->ip_version, "ipv6") == 0)
15632 l2_encap_conf.select_ipv4 = 0;
15635 if (l2_encap_conf.select_vlan)
15636 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15637 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
15638 RTE_ETHER_ADDR_LEN);
15639 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15640 RTE_ETHER_ADDR_LEN);
15643 cmdline_parse_inst_t cmd_set_l2_encap = {
15644 .f = cmd_set_l2_encap_parsed,
15646 .help_str = "set l2_encap ip-version ipv4|ipv6"
15647 " eth-src <eth-src> eth-dst <eth-dst>",
15649 (void *)&cmd_set_l2_encap_set,
15650 (void *)&cmd_set_l2_encap_l2_encap,
15651 (void *)&cmd_set_l2_encap_ip_version,
15652 (void *)&cmd_set_l2_encap_ip_version_value,
15653 (void *)&cmd_set_l2_encap_eth_src,
15654 (void *)&cmd_set_l2_encap_eth_src_value,
15655 (void *)&cmd_set_l2_encap_eth_dst,
15656 (void *)&cmd_set_l2_encap_eth_dst_value,
15661 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
15662 .f = cmd_set_l2_encap_parsed,
15664 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
15665 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15667 (void *)&cmd_set_l2_encap_set,
15668 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
15669 (void *)&cmd_set_l2_encap_ip_version,
15670 (void *)&cmd_set_l2_encap_ip_version_value,
15671 (void *)&cmd_set_l2_encap_vlan,
15672 (void *)&cmd_set_l2_encap_vlan_value,
15673 (void *)&cmd_set_l2_encap_eth_src,
15674 (void *)&cmd_set_l2_encap_eth_src_value,
15675 (void *)&cmd_set_l2_encap_eth_dst,
15676 (void *)&cmd_set_l2_encap_eth_dst_value,
15681 /** Set L2 decapsulation details */
15682 struct cmd_set_l2_decap_result {
15683 cmdline_fixed_string_t set;
15684 cmdline_fixed_string_t l2_decap;
15685 cmdline_fixed_string_t pos_token;
15686 uint32_t vlan_present:1;
15689 cmdline_parse_token_string_t cmd_set_l2_decap_set =
15690 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
15691 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
15692 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15694 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
15695 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
15696 "l2_decap-with-vlan");
15698 static void cmd_set_l2_decap_parsed(void *parsed_result,
15699 __attribute__((unused)) struct cmdline *cl,
15700 __attribute__((unused)) void *data)
15702 struct cmd_set_l2_decap_result *res = parsed_result;
15704 if (strcmp(res->l2_decap, "l2_decap") == 0)
15705 l2_decap_conf.select_vlan = 0;
15706 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
15707 l2_decap_conf.select_vlan = 1;
15710 cmdline_parse_inst_t cmd_set_l2_decap = {
15711 .f = cmd_set_l2_decap_parsed,
15713 .help_str = "set l2_decap",
15715 (void *)&cmd_set_l2_decap_set,
15716 (void *)&cmd_set_l2_decap_l2_decap,
15721 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
15722 .f = cmd_set_l2_decap_parsed,
15724 .help_str = "set l2_decap-with-vlan",
15726 (void *)&cmd_set_l2_decap_set,
15727 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
15732 /** Set MPLSoGRE encapsulation details */
15733 struct cmd_set_mplsogre_encap_result {
15734 cmdline_fixed_string_t set;
15735 cmdline_fixed_string_t mplsogre;
15736 cmdline_fixed_string_t pos_token;
15737 cmdline_fixed_string_t ip_version;
15738 uint32_t vlan_present:1;
15740 cmdline_ipaddr_t ip_src;
15741 cmdline_ipaddr_t ip_dst;
15743 struct rte_ether_addr eth_src;
15744 struct rte_ether_addr eth_dst;
15747 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
15748 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
15750 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
15751 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
15753 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
15754 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15755 mplsogre, "mplsogre_encap-with-vlan");
15756 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
15757 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15758 pos_token, "ip-version");
15759 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
15760 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15761 ip_version, "ipv4#ipv6");
15762 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
15763 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15764 pos_token, "label");
15765 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
15766 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
15768 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
15769 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15770 pos_token, "ip-src");
15771 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
15772 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
15773 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
15774 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15775 pos_token, "ip-dst");
15776 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
15777 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
15778 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
15779 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15780 pos_token, "vlan-tci");
15781 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
15782 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
15784 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
15785 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15786 pos_token, "eth-src");
15787 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
15788 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15790 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
15791 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15792 pos_token, "eth-dst");
15793 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
15794 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
15797 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
15798 __attribute__((unused)) struct cmdline *cl,
15799 __attribute__((unused)) void *data)
15801 struct cmd_set_mplsogre_encap_result *res = parsed_result;
15803 uint32_t mplsogre_label;
15806 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
15809 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
15810 mplsogre_encap_conf.select_vlan = 0;
15811 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
15812 mplsogre_encap_conf.select_vlan = 1;
15813 if (strcmp(res->ip_version, "ipv4") == 0)
15814 mplsogre_encap_conf.select_ipv4 = 1;
15815 else if (strcmp(res->ip_version, "ipv6") == 0)
15816 mplsogre_encap_conf.select_ipv4 = 0;
15819 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
15820 if (mplsogre_encap_conf.select_ipv4) {
15821 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
15822 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
15824 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
15825 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
15827 if (mplsogre_encap_conf.select_vlan)
15828 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15829 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
15830 RTE_ETHER_ADDR_LEN);
15831 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15832 RTE_ETHER_ADDR_LEN);
15835 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
15836 .f = cmd_set_mplsogre_encap_parsed,
15838 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
15839 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15840 " eth-dst <eth-dst>",
15842 (void *)&cmd_set_mplsogre_encap_set,
15843 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
15844 (void *)&cmd_set_mplsogre_encap_ip_version,
15845 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15846 (void *)&cmd_set_mplsogre_encap_label,
15847 (void *)&cmd_set_mplsogre_encap_label_value,
15848 (void *)&cmd_set_mplsogre_encap_ip_src,
15849 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15850 (void *)&cmd_set_mplsogre_encap_ip_dst,
15851 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15852 (void *)&cmd_set_mplsogre_encap_eth_src,
15853 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15854 (void *)&cmd_set_mplsogre_encap_eth_dst,
15855 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15860 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
15861 .f = cmd_set_mplsogre_encap_parsed,
15863 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
15864 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
15865 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
15867 (void *)&cmd_set_mplsogre_encap_set,
15868 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
15869 (void *)&cmd_set_mplsogre_encap_ip_version,
15870 (void *)&cmd_set_mplsogre_encap_ip_version_value,
15871 (void *)&cmd_set_mplsogre_encap_label,
15872 (void *)&cmd_set_mplsogre_encap_label_value,
15873 (void *)&cmd_set_mplsogre_encap_ip_src,
15874 (void *)&cmd_set_mplsogre_encap_ip_src_value,
15875 (void *)&cmd_set_mplsogre_encap_ip_dst,
15876 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
15877 (void *)&cmd_set_mplsogre_encap_vlan,
15878 (void *)&cmd_set_mplsogre_encap_vlan_value,
15879 (void *)&cmd_set_mplsogre_encap_eth_src,
15880 (void *)&cmd_set_mplsogre_encap_eth_src_value,
15881 (void *)&cmd_set_mplsogre_encap_eth_dst,
15882 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
15887 /** Set MPLSoGRE decapsulation details */
15888 struct cmd_set_mplsogre_decap_result {
15889 cmdline_fixed_string_t set;
15890 cmdline_fixed_string_t mplsogre;
15891 cmdline_fixed_string_t pos_token;
15892 cmdline_fixed_string_t ip_version;
15893 uint32_t vlan_present:1;
15896 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
15897 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
15899 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
15900 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
15902 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
15903 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15904 mplsogre, "mplsogre_decap-with-vlan");
15905 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
15906 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15907 pos_token, "ip-version");
15908 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
15909 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
15910 ip_version, "ipv4#ipv6");
15912 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
15913 __attribute__((unused)) struct cmdline *cl,
15914 __attribute__((unused)) void *data)
15916 struct cmd_set_mplsogre_decap_result *res = parsed_result;
15918 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
15919 mplsogre_decap_conf.select_vlan = 0;
15920 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
15921 mplsogre_decap_conf.select_vlan = 1;
15922 if (strcmp(res->ip_version, "ipv4") == 0)
15923 mplsogre_decap_conf.select_ipv4 = 1;
15924 else if (strcmp(res->ip_version, "ipv6") == 0)
15925 mplsogre_decap_conf.select_ipv4 = 0;
15928 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
15929 .f = cmd_set_mplsogre_decap_parsed,
15931 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
15933 (void *)&cmd_set_mplsogre_decap_set,
15934 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
15935 (void *)&cmd_set_mplsogre_decap_ip_version,
15936 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15941 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
15942 .f = cmd_set_mplsogre_decap_parsed,
15944 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
15946 (void *)&cmd_set_mplsogre_decap_set,
15947 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
15948 (void *)&cmd_set_mplsogre_decap_ip_version,
15949 (void *)&cmd_set_mplsogre_decap_ip_version_value,
15954 /** Set MPLSoUDP encapsulation details */
15955 struct cmd_set_mplsoudp_encap_result {
15956 cmdline_fixed_string_t set;
15957 cmdline_fixed_string_t mplsoudp;
15958 cmdline_fixed_string_t pos_token;
15959 cmdline_fixed_string_t ip_version;
15960 uint32_t vlan_present:1;
15964 cmdline_ipaddr_t ip_src;
15965 cmdline_ipaddr_t ip_dst;
15967 struct rte_ether_addr eth_src;
15968 struct rte_ether_addr eth_dst;
15971 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
15972 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
15974 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
15975 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
15977 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
15978 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15979 mplsoudp, "mplsoudp_encap-with-vlan");
15980 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
15981 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15982 pos_token, "ip-version");
15983 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
15984 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15985 ip_version, "ipv4#ipv6");
15986 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
15987 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15988 pos_token, "label");
15989 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
15990 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
15992 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
15993 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
15994 pos_token, "udp-src");
15995 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
15996 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
15998 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
15999 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16000 pos_token, "udp-dst");
16001 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
16002 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
16004 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
16005 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16006 pos_token, "ip-src");
16007 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
16008 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
16009 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
16010 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16011 pos_token, "ip-dst");
16012 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
16013 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
16014 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
16015 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16016 pos_token, "vlan-tci");
16017 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
16018 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
16020 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
16021 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16022 pos_token, "eth-src");
16023 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
16024 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16026 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
16027 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16028 pos_token, "eth-dst");
16029 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
16030 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
16033 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
16034 __attribute__((unused)) struct cmdline *cl,
16035 __attribute__((unused)) void *data)
16037 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
16039 uint32_t mplsoudp_label;
16042 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
16045 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
16046 mplsoudp_encap_conf.select_vlan = 0;
16047 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
16048 mplsoudp_encap_conf.select_vlan = 1;
16049 if (strcmp(res->ip_version, "ipv4") == 0)
16050 mplsoudp_encap_conf.select_ipv4 = 1;
16051 else if (strcmp(res->ip_version, "ipv6") == 0)
16052 mplsoudp_encap_conf.select_ipv4 = 0;
16055 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
16056 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
16057 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
16058 if (mplsoudp_encap_conf.select_ipv4) {
16059 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
16060 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
16062 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
16063 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
16065 if (mplsoudp_encap_conf.select_vlan)
16066 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
16067 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
16068 RTE_ETHER_ADDR_LEN);
16069 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
16070 RTE_ETHER_ADDR_LEN);
16073 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
16074 .f = cmd_set_mplsoudp_encap_parsed,
16076 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
16077 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
16078 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
16080 (void *)&cmd_set_mplsoudp_encap_set,
16081 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
16082 (void *)&cmd_set_mplsoudp_encap_ip_version,
16083 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16084 (void *)&cmd_set_mplsoudp_encap_label,
16085 (void *)&cmd_set_mplsoudp_encap_label_value,
16086 (void *)&cmd_set_mplsoudp_encap_udp_src,
16087 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16088 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16089 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16090 (void *)&cmd_set_mplsoudp_encap_ip_src,
16091 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16092 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16093 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16094 (void *)&cmd_set_mplsoudp_encap_eth_src,
16095 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16096 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16097 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16102 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
16103 .f = cmd_set_mplsoudp_encap_parsed,
16105 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
16106 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
16107 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
16108 " eth-src <eth-src> eth-dst <eth-dst>",
16110 (void *)&cmd_set_mplsoudp_encap_set,
16111 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
16112 (void *)&cmd_set_mplsoudp_encap_ip_version,
16113 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
16114 (void *)&cmd_set_mplsoudp_encap_label,
16115 (void *)&cmd_set_mplsoudp_encap_label_value,
16116 (void *)&cmd_set_mplsoudp_encap_udp_src,
16117 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
16118 (void *)&cmd_set_mplsoudp_encap_udp_dst,
16119 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
16120 (void *)&cmd_set_mplsoudp_encap_ip_src,
16121 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
16122 (void *)&cmd_set_mplsoudp_encap_ip_dst,
16123 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
16124 (void *)&cmd_set_mplsoudp_encap_vlan,
16125 (void *)&cmd_set_mplsoudp_encap_vlan_value,
16126 (void *)&cmd_set_mplsoudp_encap_eth_src,
16127 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
16128 (void *)&cmd_set_mplsoudp_encap_eth_dst,
16129 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
16134 /** Set MPLSoUDP decapsulation details */
16135 struct cmd_set_mplsoudp_decap_result {
16136 cmdline_fixed_string_t set;
16137 cmdline_fixed_string_t mplsoudp;
16138 cmdline_fixed_string_t pos_token;
16139 cmdline_fixed_string_t ip_version;
16140 uint32_t vlan_present:1;
16143 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
16144 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
16146 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
16147 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
16149 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
16150 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16151 mplsoudp, "mplsoudp_decap-with-vlan");
16152 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
16153 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16154 pos_token, "ip-version");
16155 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
16156 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
16157 ip_version, "ipv4#ipv6");
16159 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
16160 __attribute__((unused)) struct cmdline *cl,
16161 __attribute__((unused)) void *data)
16163 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
16165 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
16166 mplsoudp_decap_conf.select_vlan = 0;
16167 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
16168 mplsoudp_decap_conf.select_vlan = 1;
16169 if (strcmp(res->ip_version, "ipv4") == 0)
16170 mplsoudp_decap_conf.select_ipv4 = 1;
16171 else if (strcmp(res->ip_version, "ipv6") == 0)
16172 mplsoudp_decap_conf.select_ipv4 = 0;
16175 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
16176 .f = cmd_set_mplsoudp_decap_parsed,
16178 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
16180 (void *)&cmd_set_mplsoudp_decap_set,
16181 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
16182 (void *)&cmd_set_mplsoudp_decap_ip_version,
16183 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16188 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
16189 .f = cmd_set_mplsoudp_decap_parsed,
16191 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
16193 (void *)&cmd_set_mplsoudp_decap_set,
16194 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
16195 (void *)&cmd_set_mplsoudp_decap_ip_version,
16196 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
16201 /* Strict link priority scheduling mode setting */
16203 cmd_strict_link_prio_parsed(
16204 void *parsed_result,
16205 __attribute__((unused)) struct cmdline *cl,
16206 __attribute__((unused)) void *data)
16208 struct cmd_vf_tc_bw_result *res = parsed_result;
16209 int ret = -ENOTSUP;
16211 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16214 #ifdef RTE_LIBRTE_I40E_PMD
16215 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
16222 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
16225 printf("invalid port_id %d\n", res->port_id);
16228 printf("function not implemented\n");
16231 printf("programming error: (%s)\n", strerror(-ret));
16235 cmdline_parse_inst_t cmd_strict_link_prio = {
16236 .f = cmd_strict_link_prio_parsed,
16238 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
16240 (void *)&cmd_vf_tc_bw_set,
16241 (void *)&cmd_vf_tc_bw_tx,
16242 (void *)&cmd_vf_tc_bw_strict_link_prio,
16243 (void *)&cmd_vf_tc_bw_port_id,
16244 (void *)&cmd_vf_tc_bw_tc_map,
16249 /* Load dynamic device personalization*/
16250 struct cmd_ddp_add_result {
16251 cmdline_fixed_string_t ddp;
16252 cmdline_fixed_string_t add;
16257 cmdline_parse_token_string_t cmd_ddp_add_ddp =
16258 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
16259 cmdline_parse_token_string_t cmd_ddp_add_add =
16260 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
16261 cmdline_parse_token_num_t cmd_ddp_add_port_id =
16262 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
16263 cmdline_parse_token_string_t cmd_ddp_add_filepath =
16264 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
16267 cmd_ddp_add_parsed(
16268 void *parsed_result,
16269 __attribute__((unused)) struct cmdline *cl,
16270 __attribute__((unused)) void *data)
16272 struct cmd_ddp_add_result *res = parsed_result;
16278 int ret = -ENOTSUP;
16280 if (!all_ports_stopped()) {
16281 printf("Please stop all ports first\n");
16285 filepath = strdup(res->filepath);
16286 if (filepath == NULL) {
16287 printf("Failed to allocate memory\n");
16290 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
16292 buff = open_file(file_fld[0], &size);
16294 free((void *)filepath);
16298 #ifdef RTE_LIBRTE_I40E_PMD
16299 if (ret == -ENOTSUP)
16300 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16302 RTE_PMD_I40E_PKG_OP_WR_ADD);
16305 if (ret == -EEXIST)
16306 printf("Profile has already existed.\n");
16308 printf("Failed to load profile.\n");
16309 else if (file_num == 2)
16310 save_file(file_fld[1], buff, size);
16313 free((void *)filepath);
16316 cmdline_parse_inst_t cmd_ddp_add = {
16317 .f = cmd_ddp_add_parsed,
16319 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
16321 (void *)&cmd_ddp_add_ddp,
16322 (void *)&cmd_ddp_add_add,
16323 (void *)&cmd_ddp_add_port_id,
16324 (void *)&cmd_ddp_add_filepath,
16329 /* Delete dynamic device personalization*/
16330 struct cmd_ddp_del_result {
16331 cmdline_fixed_string_t ddp;
16332 cmdline_fixed_string_t del;
16337 cmdline_parse_token_string_t cmd_ddp_del_ddp =
16338 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
16339 cmdline_parse_token_string_t cmd_ddp_del_del =
16340 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
16341 cmdline_parse_token_num_t cmd_ddp_del_port_id =
16342 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
16343 cmdline_parse_token_string_t cmd_ddp_del_filepath =
16344 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
16347 cmd_ddp_del_parsed(
16348 void *parsed_result,
16349 __attribute__((unused)) struct cmdline *cl,
16350 __attribute__((unused)) void *data)
16352 struct cmd_ddp_del_result *res = parsed_result;
16355 int ret = -ENOTSUP;
16357 if (!all_ports_stopped()) {
16358 printf("Please stop all ports first\n");
16362 buff = open_file(res->filepath, &size);
16366 #ifdef RTE_LIBRTE_I40E_PMD
16367 if (ret == -ENOTSUP)
16368 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
16370 RTE_PMD_I40E_PKG_OP_WR_DEL);
16373 if (ret == -EACCES)
16374 printf("Profile does not exist.\n");
16376 printf("Failed to delete profile.\n");
16381 cmdline_parse_inst_t cmd_ddp_del = {
16382 .f = cmd_ddp_del_parsed,
16384 .help_str = "ddp del <port_id> <backup_profile_path>",
16386 (void *)&cmd_ddp_del_ddp,
16387 (void *)&cmd_ddp_del_del,
16388 (void *)&cmd_ddp_del_port_id,
16389 (void *)&cmd_ddp_del_filepath,
16394 /* Get dynamic device personalization profile info */
16395 struct cmd_ddp_info_result {
16396 cmdline_fixed_string_t ddp;
16397 cmdline_fixed_string_t get;
16398 cmdline_fixed_string_t info;
16402 cmdline_parse_token_string_t cmd_ddp_info_ddp =
16403 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
16404 cmdline_parse_token_string_t cmd_ddp_info_get =
16405 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
16406 cmdline_parse_token_string_t cmd_ddp_info_info =
16407 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
16408 cmdline_parse_token_string_t cmd_ddp_info_filepath =
16409 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
16412 cmd_ddp_info_parsed(
16413 void *parsed_result,
16414 __attribute__((unused)) struct cmdline *cl,
16415 __attribute__((unused)) void *data)
16417 struct cmd_ddp_info_result *res = parsed_result;
16420 int ret = -ENOTSUP;
16421 #ifdef RTE_LIBRTE_I40E_PMD
16424 uint32_t buff_size = 0;
16425 struct rte_pmd_i40e_profile_info info;
16426 uint32_t dev_num = 0;
16427 struct rte_pmd_i40e_ddp_device_id *devs;
16428 uint32_t proto_num = 0;
16429 struct rte_pmd_i40e_proto_info *proto = NULL;
16430 uint32_t pctype_num = 0;
16431 struct rte_pmd_i40e_ptype_info *pctype;
16432 uint32_t ptype_num = 0;
16433 struct rte_pmd_i40e_ptype_info *ptype;
16438 pkg = open_file(res->filepath, &pkg_size);
16442 #ifdef RTE_LIBRTE_I40E_PMD
16443 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16444 (uint8_t *)&info, sizeof(info),
16445 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
16447 printf("Global Track id: 0x%x\n", info.track_id);
16448 printf("Global Version: %d.%d.%d.%d\n",
16449 info.version.major,
16450 info.version.minor,
16451 info.version.update,
16452 info.version.draft);
16453 printf("Global Package name: %s\n\n", info.name);
16456 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16457 (uint8_t *)&info, sizeof(info),
16458 RTE_PMD_I40E_PKG_INFO_HEADER);
16460 printf("i40e Profile Track id: 0x%x\n", info.track_id);
16461 printf("i40e Profile Version: %d.%d.%d.%d\n",
16462 info.version.major,
16463 info.version.minor,
16464 info.version.update,
16465 info.version.draft);
16466 printf("i40e Profile name: %s\n\n", info.name);
16469 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16470 (uint8_t *)&buff_size, sizeof(buff_size),
16471 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
16472 if (!ret && buff_size) {
16473 buff = (uint8_t *)malloc(buff_size);
16475 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16477 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
16479 printf("Package Notes:\n%s\n\n", buff);
16484 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16485 (uint8_t *)&dev_num, sizeof(dev_num),
16486 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
16487 if (!ret && dev_num) {
16488 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
16489 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
16491 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16492 (uint8_t *)devs, buff_size,
16493 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
16495 printf("List of supported devices:\n");
16496 for (i = 0; i < dev_num; i++) {
16497 printf(" %04X:%04X %04X:%04X\n",
16498 devs[i].vendor_dev_id >> 16,
16499 devs[i].vendor_dev_id & 0xFFFF,
16500 devs[i].sub_vendor_dev_id >> 16,
16501 devs[i].sub_vendor_dev_id & 0xFFFF);
16509 /* get information about protocols and packet types */
16510 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16511 (uint8_t *)&proto_num, sizeof(proto_num),
16512 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
16513 if (ret || !proto_num)
16514 goto no_print_return;
16516 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
16517 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
16519 goto no_print_return;
16521 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
16523 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
16525 printf("List of used protocols:\n");
16526 for (i = 0; i < proto_num; i++)
16527 printf(" %2u: %s\n", proto[i].proto_id,
16531 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
16532 (uint8_t *)&pctype_num, sizeof(pctype_num),
16533 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
16534 if (ret || !pctype_num)
16535 goto no_print_pctypes;
16537 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16538 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16540 goto no_print_pctypes;
16542 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
16544 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
16547 goto no_print_pctypes;
16550 printf("List of defined packet classification types:\n");
16551 for (i = 0; i < pctype_num; i++) {
16552 printf(" %2u:", pctype[i].ptype_id);
16553 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16554 proto_id = pctype[i].protocols[j];
16555 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16556 for (n = 0; n < proto_num; n++) {
16557 if (proto[n].proto_id == proto_id) {
16558 printf(" %s", proto[n].name);
16571 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
16573 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
16574 if (ret || !ptype_num)
16575 goto no_print_return;
16577 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
16578 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
16580 goto no_print_return;
16582 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
16584 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
16587 goto no_print_return;
16589 printf("List of defined packet types:\n");
16590 for (i = 0; i < ptype_num; i++) {
16591 printf(" %2u:", ptype[i].ptype_id);
16592 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
16593 proto_id = ptype[i].protocols[j];
16594 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
16595 for (n = 0; n < proto_num; n++) {
16596 if (proto[n].proto_id == proto_id) {
16597 printf(" %s", proto[n].name);
16613 if (ret == -ENOTSUP)
16614 printf("Function not supported in PMD driver\n");
16618 cmdline_parse_inst_t cmd_ddp_get_info = {
16619 .f = cmd_ddp_info_parsed,
16621 .help_str = "ddp get info <profile_path>",
16623 (void *)&cmd_ddp_info_ddp,
16624 (void *)&cmd_ddp_info_get,
16625 (void *)&cmd_ddp_info_info,
16626 (void *)&cmd_ddp_info_filepath,
16631 /* Get dynamic device personalization profile info list*/
16632 #define PROFILE_INFO_SIZE 48
16633 #define MAX_PROFILE_NUM 16
16635 struct cmd_ddp_get_list_result {
16636 cmdline_fixed_string_t ddp;
16637 cmdline_fixed_string_t get;
16638 cmdline_fixed_string_t list;
16642 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
16643 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
16644 cmdline_parse_token_string_t cmd_ddp_get_list_get =
16645 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
16646 cmdline_parse_token_string_t cmd_ddp_get_list_list =
16647 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
16648 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
16649 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
16652 cmd_ddp_get_list_parsed(
16653 __attribute__((unused)) void *parsed_result,
16654 __attribute__((unused)) struct cmdline *cl,
16655 __attribute__((unused)) void *data)
16657 #ifdef RTE_LIBRTE_I40E_PMD
16658 struct cmd_ddp_get_list_result *res = parsed_result;
16659 struct rte_pmd_i40e_profile_list *p_list;
16660 struct rte_pmd_i40e_profile_info *p_info;
16665 int ret = -ENOTSUP;
16667 #ifdef RTE_LIBRTE_I40E_PMD
16668 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
16669 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
16671 printf("%s: Failed to malloc buffer\n", __func__);
16673 if (ret == -ENOTSUP)
16674 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
16675 (uint8_t *)p_list, size);
16678 p_num = p_list->p_count;
16679 printf("Profile number is: %d\n\n", p_num);
16681 for (i = 0; i < p_num; i++) {
16682 p_info = &p_list->p_info[i];
16683 printf("Profile %d:\n", i);
16684 printf("Track id: 0x%x\n", p_info->track_id);
16685 printf("Version: %d.%d.%d.%d\n",
16686 p_info->version.major,
16687 p_info->version.minor,
16688 p_info->version.update,
16689 p_info->version.draft);
16690 printf("Profile name: %s\n\n", p_info->name);
16698 printf("Failed to get ddp list\n");
16701 cmdline_parse_inst_t cmd_ddp_get_list = {
16702 .f = cmd_ddp_get_list_parsed,
16704 .help_str = "ddp get list <port_id>",
16706 (void *)&cmd_ddp_get_list_ddp,
16707 (void *)&cmd_ddp_get_list_get,
16708 (void *)&cmd_ddp_get_list_list,
16709 (void *)&cmd_ddp_get_list_port_id,
16714 /* Configure input set */
16715 struct cmd_cfg_input_set_result {
16716 cmdline_fixed_string_t port;
16717 cmdline_fixed_string_t cfg;
16719 cmdline_fixed_string_t pctype;
16721 cmdline_fixed_string_t inset_type;
16722 cmdline_fixed_string_t opt;
16723 cmdline_fixed_string_t field;
16728 cmd_cfg_input_set_parsed(
16729 __attribute__((unused)) void *parsed_result,
16730 __attribute__((unused)) struct cmdline *cl,
16731 __attribute__((unused)) void *data)
16733 #ifdef RTE_LIBRTE_I40E_PMD
16734 struct cmd_cfg_input_set_result *res = parsed_result;
16735 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16736 struct rte_pmd_i40e_inset inset;
16738 int ret = -ENOTSUP;
16740 if (!all_ports_stopped()) {
16741 printf("Please stop all ports first\n");
16745 #ifdef RTE_LIBRTE_I40E_PMD
16746 if (!strcmp(res->inset_type, "hash_inset"))
16747 inset_type = INSET_HASH;
16748 else if (!strcmp(res->inset_type, "fdir_inset"))
16749 inset_type = INSET_FDIR;
16750 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16751 inset_type = INSET_FDIR_FLX;
16752 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
16753 &inset, inset_type);
16755 printf("Failed to get input set.\n");
16759 if (!strcmp(res->opt, "get")) {
16760 ret = rte_pmd_i40e_inset_field_get(inset.inset,
16763 printf("Field index %d is enabled.\n", res->field_idx);
16765 printf("Field index %d is disabled.\n", res->field_idx);
16767 } else if (!strcmp(res->opt, "set"))
16768 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
16770 else if (!strcmp(res->opt, "clear"))
16771 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
16774 printf("Failed to configure input set field.\n");
16778 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16779 &inset, inset_type);
16781 printf("Failed to set input set.\n");
16786 if (ret == -ENOTSUP)
16787 printf("Function not supported\n");
16790 cmdline_parse_token_string_t cmd_cfg_input_set_port =
16791 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16793 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
16794 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16796 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
16797 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16799 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
16800 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16802 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
16803 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16805 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
16806 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16808 "hash_inset#fdir_inset#fdir_flx_inset");
16809 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
16810 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16811 opt, "get#set#clear");
16812 cmdline_parse_token_string_t cmd_cfg_input_set_field =
16813 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
16815 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
16816 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
16819 cmdline_parse_inst_t cmd_cfg_input_set = {
16820 .f = cmd_cfg_input_set_parsed,
16822 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16823 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
16825 (void *)&cmd_cfg_input_set_port,
16826 (void *)&cmd_cfg_input_set_cfg,
16827 (void *)&cmd_cfg_input_set_port_id,
16828 (void *)&cmd_cfg_input_set_pctype,
16829 (void *)&cmd_cfg_input_set_pctype_id,
16830 (void *)&cmd_cfg_input_set_inset_type,
16831 (void *)&cmd_cfg_input_set_opt,
16832 (void *)&cmd_cfg_input_set_field,
16833 (void *)&cmd_cfg_input_set_field_idx,
16838 /* Clear input set */
16839 struct cmd_clear_input_set_result {
16840 cmdline_fixed_string_t port;
16841 cmdline_fixed_string_t cfg;
16843 cmdline_fixed_string_t pctype;
16845 cmdline_fixed_string_t inset_type;
16846 cmdline_fixed_string_t clear;
16847 cmdline_fixed_string_t all;
16851 cmd_clear_input_set_parsed(
16852 __attribute__((unused)) void *parsed_result,
16853 __attribute__((unused)) struct cmdline *cl,
16854 __attribute__((unused)) void *data)
16856 #ifdef RTE_LIBRTE_I40E_PMD
16857 struct cmd_clear_input_set_result *res = parsed_result;
16858 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
16859 struct rte_pmd_i40e_inset inset;
16861 int ret = -ENOTSUP;
16863 if (!all_ports_stopped()) {
16864 printf("Please stop all ports first\n");
16868 #ifdef RTE_LIBRTE_I40E_PMD
16869 if (!strcmp(res->inset_type, "hash_inset"))
16870 inset_type = INSET_HASH;
16871 else if (!strcmp(res->inset_type, "fdir_inset"))
16872 inset_type = INSET_FDIR;
16873 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
16874 inset_type = INSET_FDIR_FLX;
16876 memset(&inset, 0, sizeof(inset));
16878 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
16879 &inset, inset_type);
16881 printf("Failed to clear input set.\n");
16887 if (ret == -ENOTSUP)
16888 printf("Function not supported\n");
16891 cmdline_parse_token_string_t cmd_clear_input_set_port =
16892 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16894 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
16895 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16897 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
16898 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16900 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
16901 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16903 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
16904 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
16906 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
16907 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16909 "hash_inset#fdir_inset#fdir_flx_inset");
16910 cmdline_parse_token_string_t cmd_clear_input_set_clear =
16911 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16913 cmdline_parse_token_string_t cmd_clear_input_set_all =
16914 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
16917 cmdline_parse_inst_t cmd_clear_input_set = {
16918 .f = cmd_clear_input_set_parsed,
16920 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
16921 "fdir_inset|fdir_flx_inset clear all",
16923 (void *)&cmd_clear_input_set_port,
16924 (void *)&cmd_clear_input_set_cfg,
16925 (void *)&cmd_clear_input_set_port_id,
16926 (void *)&cmd_clear_input_set_pctype,
16927 (void *)&cmd_clear_input_set_pctype_id,
16928 (void *)&cmd_clear_input_set_inset_type,
16929 (void *)&cmd_clear_input_set_clear,
16930 (void *)&cmd_clear_input_set_all,
16935 /* show vf stats */
16937 /* Common result structure for show vf stats */
16938 struct cmd_show_vf_stats_result {
16939 cmdline_fixed_string_t show;
16940 cmdline_fixed_string_t vf;
16941 cmdline_fixed_string_t stats;
16946 /* Common CLI fields show vf stats*/
16947 cmdline_parse_token_string_t cmd_show_vf_stats_show =
16948 TOKEN_STRING_INITIALIZER
16949 (struct cmd_show_vf_stats_result,
16951 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
16952 TOKEN_STRING_INITIALIZER
16953 (struct cmd_show_vf_stats_result,
16955 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
16956 TOKEN_STRING_INITIALIZER
16957 (struct cmd_show_vf_stats_result,
16959 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
16960 TOKEN_NUM_INITIALIZER
16961 (struct cmd_show_vf_stats_result,
16963 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
16964 TOKEN_NUM_INITIALIZER
16965 (struct cmd_show_vf_stats_result,
16969 cmd_show_vf_stats_parsed(
16970 void *parsed_result,
16971 __attribute__((unused)) struct cmdline *cl,
16972 __attribute__((unused)) void *data)
16974 struct cmd_show_vf_stats_result *res = parsed_result;
16975 struct rte_eth_stats stats;
16976 int ret = -ENOTSUP;
16977 static const char *nic_stats_border = "########################";
16979 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16982 memset(&stats, 0, sizeof(stats));
16984 #ifdef RTE_LIBRTE_I40E_PMD
16985 if (ret == -ENOTSUP)
16986 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
16990 #ifdef RTE_LIBRTE_BNXT_PMD
16991 if (ret == -ENOTSUP)
16992 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
17001 printf("invalid vf_id %d\n", res->vf_id);
17004 printf("invalid port_id %d\n", res->port_id);
17007 printf("function not implemented\n");
17010 printf("programming error: (%s)\n", strerror(-ret));
17013 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
17014 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
17016 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
17018 stats.ipackets, stats.imissed, stats.ibytes);
17019 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
17020 printf(" RX-nombuf: %-10"PRIu64"\n",
17022 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
17024 stats.opackets, stats.oerrors, stats.obytes);
17026 printf(" %s############################%s\n",
17027 nic_stats_border, nic_stats_border);
17030 cmdline_parse_inst_t cmd_show_vf_stats = {
17031 .f = cmd_show_vf_stats_parsed,
17033 .help_str = "show vf stats <port_id> <vf_id>",
17035 (void *)&cmd_show_vf_stats_show,
17036 (void *)&cmd_show_vf_stats_vf,
17037 (void *)&cmd_show_vf_stats_stats,
17038 (void *)&cmd_show_vf_stats_port_id,
17039 (void *)&cmd_show_vf_stats_vf_id,
17044 /* clear vf stats */
17046 /* Common result structure for clear vf stats */
17047 struct cmd_clear_vf_stats_result {
17048 cmdline_fixed_string_t clear;
17049 cmdline_fixed_string_t vf;
17050 cmdline_fixed_string_t stats;
17055 /* Common CLI fields clear vf stats*/
17056 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
17057 TOKEN_STRING_INITIALIZER
17058 (struct cmd_clear_vf_stats_result,
17060 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
17061 TOKEN_STRING_INITIALIZER
17062 (struct cmd_clear_vf_stats_result,
17064 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
17065 TOKEN_STRING_INITIALIZER
17066 (struct cmd_clear_vf_stats_result,
17068 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
17069 TOKEN_NUM_INITIALIZER
17070 (struct cmd_clear_vf_stats_result,
17072 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
17073 TOKEN_NUM_INITIALIZER
17074 (struct cmd_clear_vf_stats_result,
17078 cmd_clear_vf_stats_parsed(
17079 void *parsed_result,
17080 __attribute__((unused)) struct cmdline *cl,
17081 __attribute__((unused)) void *data)
17083 struct cmd_clear_vf_stats_result *res = parsed_result;
17084 int ret = -ENOTSUP;
17086 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17089 #ifdef RTE_LIBRTE_I40E_PMD
17090 if (ret == -ENOTSUP)
17091 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
17094 #ifdef RTE_LIBRTE_BNXT_PMD
17095 if (ret == -ENOTSUP)
17096 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
17104 printf("invalid vf_id %d\n", res->vf_id);
17107 printf("invalid port_id %d\n", res->port_id);
17110 printf("function not implemented\n");
17113 printf("programming error: (%s)\n", strerror(-ret));
17117 cmdline_parse_inst_t cmd_clear_vf_stats = {
17118 .f = cmd_clear_vf_stats_parsed,
17120 .help_str = "clear vf stats <port_id> <vf_id>",
17122 (void *)&cmd_clear_vf_stats_clear,
17123 (void *)&cmd_clear_vf_stats_vf,
17124 (void *)&cmd_clear_vf_stats_stats,
17125 (void *)&cmd_clear_vf_stats_port_id,
17126 (void *)&cmd_clear_vf_stats_vf_id,
17131 /* port config pctype mapping reset */
17133 /* Common result structure for port config pctype mapping reset */
17134 struct cmd_pctype_mapping_reset_result {
17135 cmdline_fixed_string_t port;
17136 cmdline_fixed_string_t config;
17138 cmdline_fixed_string_t pctype;
17139 cmdline_fixed_string_t mapping;
17140 cmdline_fixed_string_t reset;
17143 /* Common CLI fields for port config pctype mapping reset*/
17144 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
17145 TOKEN_STRING_INITIALIZER
17146 (struct cmd_pctype_mapping_reset_result,
17148 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
17149 TOKEN_STRING_INITIALIZER
17150 (struct cmd_pctype_mapping_reset_result,
17152 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
17153 TOKEN_NUM_INITIALIZER
17154 (struct cmd_pctype_mapping_reset_result,
17156 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
17157 TOKEN_STRING_INITIALIZER
17158 (struct cmd_pctype_mapping_reset_result,
17160 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
17161 TOKEN_STRING_INITIALIZER
17162 (struct cmd_pctype_mapping_reset_result,
17163 mapping, "mapping");
17164 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
17165 TOKEN_STRING_INITIALIZER
17166 (struct cmd_pctype_mapping_reset_result,
17170 cmd_pctype_mapping_reset_parsed(
17171 void *parsed_result,
17172 __attribute__((unused)) struct cmdline *cl,
17173 __attribute__((unused)) void *data)
17175 struct cmd_pctype_mapping_reset_result *res = parsed_result;
17176 int ret = -ENOTSUP;
17178 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17181 #ifdef RTE_LIBRTE_I40E_PMD
17182 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
17189 printf("invalid port_id %d\n", res->port_id);
17192 printf("function not implemented\n");
17195 printf("programming error: (%s)\n", strerror(-ret));
17199 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
17200 .f = cmd_pctype_mapping_reset_parsed,
17202 .help_str = "port config <port_id> pctype mapping reset",
17204 (void *)&cmd_pctype_mapping_reset_port,
17205 (void *)&cmd_pctype_mapping_reset_config,
17206 (void *)&cmd_pctype_mapping_reset_port_id,
17207 (void *)&cmd_pctype_mapping_reset_pctype,
17208 (void *)&cmd_pctype_mapping_reset_mapping,
17209 (void *)&cmd_pctype_mapping_reset_reset,
17214 /* show port pctype mapping */
17216 /* Common result structure for show port pctype mapping */
17217 struct cmd_pctype_mapping_get_result {
17218 cmdline_fixed_string_t show;
17219 cmdline_fixed_string_t port;
17221 cmdline_fixed_string_t pctype;
17222 cmdline_fixed_string_t mapping;
17225 /* Common CLI fields for pctype mapping get */
17226 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
17227 TOKEN_STRING_INITIALIZER
17228 (struct cmd_pctype_mapping_get_result,
17230 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
17231 TOKEN_STRING_INITIALIZER
17232 (struct cmd_pctype_mapping_get_result,
17234 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
17235 TOKEN_NUM_INITIALIZER
17236 (struct cmd_pctype_mapping_get_result,
17238 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
17239 TOKEN_STRING_INITIALIZER
17240 (struct cmd_pctype_mapping_get_result,
17242 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
17243 TOKEN_STRING_INITIALIZER
17244 (struct cmd_pctype_mapping_get_result,
17245 mapping, "mapping");
17248 cmd_pctype_mapping_get_parsed(
17249 void *parsed_result,
17250 __attribute__((unused)) struct cmdline *cl,
17251 __attribute__((unused)) void *data)
17253 struct cmd_pctype_mapping_get_result *res = parsed_result;
17254 int ret = -ENOTSUP;
17255 #ifdef RTE_LIBRTE_I40E_PMD
17256 struct rte_pmd_i40e_flow_type_mapping
17257 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
17258 int i, j, first_pctype;
17261 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17264 #ifdef RTE_LIBRTE_I40E_PMD
17265 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
17272 printf("invalid port_id %d\n", res->port_id);
17275 printf("function not implemented\n");
17278 printf("programming error: (%s)\n", strerror(-ret));
17282 #ifdef RTE_LIBRTE_I40E_PMD
17283 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
17284 if (mapping[i].pctype != 0ULL) {
17287 printf("pctype: ");
17288 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
17289 if (mapping[i].pctype & (1ULL << j)) {
17290 printf(first_pctype ?
17291 "%02d" : ",%02d", j);
17295 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
17301 cmdline_parse_inst_t cmd_pctype_mapping_get = {
17302 .f = cmd_pctype_mapping_get_parsed,
17304 .help_str = "show port <port_id> pctype mapping",
17306 (void *)&cmd_pctype_mapping_get_show,
17307 (void *)&cmd_pctype_mapping_get_port,
17308 (void *)&cmd_pctype_mapping_get_port_id,
17309 (void *)&cmd_pctype_mapping_get_pctype,
17310 (void *)&cmd_pctype_mapping_get_mapping,
17315 /* port config pctype mapping update */
17317 /* Common result structure for port config pctype mapping update */
17318 struct cmd_pctype_mapping_update_result {
17319 cmdline_fixed_string_t port;
17320 cmdline_fixed_string_t config;
17322 cmdline_fixed_string_t pctype;
17323 cmdline_fixed_string_t mapping;
17324 cmdline_fixed_string_t update;
17325 cmdline_fixed_string_t pctype_list;
17326 uint16_t flow_type;
17329 /* Common CLI fields for pctype mapping update*/
17330 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
17331 TOKEN_STRING_INITIALIZER
17332 (struct cmd_pctype_mapping_update_result,
17334 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
17335 TOKEN_STRING_INITIALIZER
17336 (struct cmd_pctype_mapping_update_result,
17338 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
17339 TOKEN_NUM_INITIALIZER
17340 (struct cmd_pctype_mapping_update_result,
17342 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
17343 TOKEN_STRING_INITIALIZER
17344 (struct cmd_pctype_mapping_update_result,
17346 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
17347 TOKEN_STRING_INITIALIZER
17348 (struct cmd_pctype_mapping_update_result,
17349 mapping, "mapping");
17350 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
17351 TOKEN_STRING_INITIALIZER
17352 (struct cmd_pctype_mapping_update_result,
17354 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
17355 TOKEN_STRING_INITIALIZER
17356 (struct cmd_pctype_mapping_update_result,
17357 pctype_list, NULL);
17358 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
17359 TOKEN_NUM_INITIALIZER
17360 (struct cmd_pctype_mapping_update_result,
17361 flow_type, UINT16);
17364 cmd_pctype_mapping_update_parsed(
17365 void *parsed_result,
17366 __attribute__((unused)) struct cmdline *cl,
17367 __attribute__((unused)) void *data)
17369 struct cmd_pctype_mapping_update_result *res = parsed_result;
17370 int ret = -ENOTSUP;
17371 #ifdef RTE_LIBRTE_I40E_PMD
17372 struct rte_pmd_i40e_flow_type_mapping mapping;
17374 unsigned int nb_item;
17375 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
17378 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17381 #ifdef RTE_LIBRTE_I40E_PMD
17382 nb_item = parse_item_list(res->pctype_list, "pctypes",
17383 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
17384 mapping.flow_type = res->flow_type;
17385 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
17386 mapping.pctype |= (1ULL << pctype_list[i]);
17387 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
17397 printf("invalid pctype or flow type\n");
17400 printf("invalid port_id %d\n", res->port_id);
17403 printf("function not implemented\n");
17406 printf("programming error: (%s)\n", strerror(-ret));
17410 cmdline_parse_inst_t cmd_pctype_mapping_update = {
17411 .f = cmd_pctype_mapping_update_parsed,
17413 .help_str = "port config <port_id> pctype mapping update"
17414 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
17416 (void *)&cmd_pctype_mapping_update_port,
17417 (void *)&cmd_pctype_mapping_update_config,
17418 (void *)&cmd_pctype_mapping_update_port_id,
17419 (void *)&cmd_pctype_mapping_update_pctype,
17420 (void *)&cmd_pctype_mapping_update_mapping,
17421 (void *)&cmd_pctype_mapping_update_update,
17422 (void *)&cmd_pctype_mapping_update_pc_type,
17423 (void *)&cmd_pctype_mapping_update_flow_type,
17428 /* ptype mapping get */
17430 /* Common result structure for ptype mapping get */
17431 struct cmd_ptype_mapping_get_result {
17432 cmdline_fixed_string_t ptype;
17433 cmdline_fixed_string_t mapping;
17434 cmdline_fixed_string_t get;
17436 uint8_t valid_only;
17439 /* Common CLI fields for ptype mapping get */
17440 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
17441 TOKEN_STRING_INITIALIZER
17442 (struct cmd_ptype_mapping_get_result,
17444 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
17445 TOKEN_STRING_INITIALIZER
17446 (struct cmd_ptype_mapping_get_result,
17447 mapping, "mapping");
17448 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
17449 TOKEN_STRING_INITIALIZER
17450 (struct cmd_ptype_mapping_get_result,
17452 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
17453 TOKEN_NUM_INITIALIZER
17454 (struct cmd_ptype_mapping_get_result,
17456 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
17457 TOKEN_NUM_INITIALIZER
17458 (struct cmd_ptype_mapping_get_result,
17459 valid_only, UINT8);
17462 cmd_ptype_mapping_get_parsed(
17463 void *parsed_result,
17464 __attribute__((unused)) struct cmdline *cl,
17465 __attribute__((unused)) void *data)
17467 struct cmd_ptype_mapping_get_result *res = parsed_result;
17468 int ret = -ENOTSUP;
17469 #ifdef RTE_LIBRTE_I40E_PMD
17470 int max_ptype_num = 256;
17471 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
17476 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17479 #ifdef RTE_LIBRTE_I40E_PMD
17480 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
17491 printf("invalid port_id %d\n", res->port_id);
17494 printf("function not implemented\n");
17497 printf("programming error: (%s)\n", strerror(-ret));
17500 #ifdef RTE_LIBRTE_I40E_PMD
17502 for (i = 0; i < count; i++)
17503 printf("%3d\t0x%08x\n",
17504 mapping[i].hw_ptype, mapping[i].sw_ptype);
17509 cmdline_parse_inst_t cmd_ptype_mapping_get = {
17510 .f = cmd_ptype_mapping_get_parsed,
17512 .help_str = "ptype mapping get <port_id> <valid_only>",
17514 (void *)&cmd_ptype_mapping_get_ptype,
17515 (void *)&cmd_ptype_mapping_get_mapping,
17516 (void *)&cmd_ptype_mapping_get_get,
17517 (void *)&cmd_ptype_mapping_get_port_id,
17518 (void *)&cmd_ptype_mapping_get_valid_only,
17523 /* ptype mapping replace */
17525 /* Common result structure for ptype mapping replace */
17526 struct cmd_ptype_mapping_replace_result {
17527 cmdline_fixed_string_t ptype;
17528 cmdline_fixed_string_t mapping;
17529 cmdline_fixed_string_t replace;
17536 /* Common CLI fields for ptype mapping replace */
17537 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
17538 TOKEN_STRING_INITIALIZER
17539 (struct cmd_ptype_mapping_replace_result,
17541 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
17542 TOKEN_STRING_INITIALIZER
17543 (struct cmd_ptype_mapping_replace_result,
17544 mapping, "mapping");
17545 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
17546 TOKEN_STRING_INITIALIZER
17547 (struct cmd_ptype_mapping_replace_result,
17548 replace, "replace");
17549 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
17550 TOKEN_NUM_INITIALIZER
17551 (struct cmd_ptype_mapping_replace_result,
17553 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
17554 TOKEN_NUM_INITIALIZER
17555 (struct cmd_ptype_mapping_replace_result,
17557 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
17558 TOKEN_NUM_INITIALIZER
17559 (struct cmd_ptype_mapping_replace_result,
17561 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
17562 TOKEN_NUM_INITIALIZER
17563 (struct cmd_ptype_mapping_replace_result,
17567 cmd_ptype_mapping_replace_parsed(
17568 void *parsed_result,
17569 __attribute__((unused)) struct cmdline *cl,
17570 __attribute__((unused)) void *data)
17572 struct cmd_ptype_mapping_replace_result *res = parsed_result;
17573 int ret = -ENOTSUP;
17575 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17578 #ifdef RTE_LIBRTE_I40E_PMD
17579 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
17589 printf("invalid ptype 0x%8x or 0x%8x\n",
17590 res->target, res->pkt_type);
17593 printf("invalid port_id %d\n", res->port_id);
17596 printf("function not implemented\n");
17599 printf("programming error: (%s)\n", strerror(-ret));
17603 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
17604 .f = cmd_ptype_mapping_replace_parsed,
17607 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
17609 (void *)&cmd_ptype_mapping_replace_ptype,
17610 (void *)&cmd_ptype_mapping_replace_mapping,
17611 (void *)&cmd_ptype_mapping_replace_replace,
17612 (void *)&cmd_ptype_mapping_replace_port_id,
17613 (void *)&cmd_ptype_mapping_replace_target,
17614 (void *)&cmd_ptype_mapping_replace_mask,
17615 (void *)&cmd_ptype_mapping_replace_pkt_type,
17620 /* ptype mapping reset */
17622 /* Common result structure for ptype mapping reset */
17623 struct cmd_ptype_mapping_reset_result {
17624 cmdline_fixed_string_t ptype;
17625 cmdline_fixed_string_t mapping;
17626 cmdline_fixed_string_t reset;
17630 /* Common CLI fields for ptype mapping reset*/
17631 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
17632 TOKEN_STRING_INITIALIZER
17633 (struct cmd_ptype_mapping_reset_result,
17635 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
17636 TOKEN_STRING_INITIALIZER
17637 (struct cmd_ptype_mapping_reset_result,
17638 mapping, "mapping");
17639 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
17640 TOKEN_STRING_INITIALIZER
17641 (struct cmd_ptype_mapping_reset_result,
17643 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
17644 TOKEN_NUM_INITIALIZER
17645 (struct cmd_ptype_mapping_reset_result,
17649 cmd_ptype_mapping_reset_parsed(
17650 void *parsed_result,
17651 __attribute__((unused)) struct cmdline *cl,
17652 __attribute__((unused)) void *data)
17654 struct cmd_ptype_mapping_reset_result *res = parsed_result;
17655 int ret = -ENOTSUP;
17657 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17660 #ifdef RTE_LIBRTE_I40E_PMD
17661 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
17668 printf("invalid port_id %d\n", res->port_id);
17671 printf("function not implemented\n");
17674 printf("programming error: (%s)\n", strerror(-ret));
17678 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
17679 .f = cmd_ptype_mapping_reset_parsed,
17681 .help_str = "ptype mapping reset <port_id>",
17683 (void *)&cmd_ptype_mapping_reset_ptype,
17684 (void *)&cmd_ptype_mapping_reset_mapping,
17685 (void *)&cmd_ptype_mapping_reset_reset,
17686 (void *)&cmd_ptype_mapping_reset_port_id,
17691 /* ptype mapping update */
17693 /* Common result structure for ptype mapping update */
17694 struct cmd_ptype_mapping_update_result {
17695 cmdline_fixed_string_t ptype;
17696 cmdline_fixed_string_t mapping;
17697 cmdline_fixed_string_t reset;
17703 /* Common CLI fields for ptype mapping update*/
17704 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
17705 TOKEN_STRING_INITIALIZER
17706 (struct cmd_ptype_mapping_update_result,
17708 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
17709 TOKEN_STRING_INITIALIZER
17710 (struct cmd_ptype_mapping_update_result,
17711 mapping, "mapping");
17712 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
17713 TOKEN_STRING_INITIALIZER
17714 (struct cmd_ptype_mapping_update_result,
17716 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
17717 TOKEN_NUM_INITIALIZER
17718 (struct cmd_ptype_mapping_update_result,
17720 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
17721 TOKEN_NUM_INITIALIZER
17722 (struct cmd_ptype_mapping_update_result,
17724 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
17725 TOKEN_NUM_INITIALIZER
17726 (struct cmd_ptype_mapping_update_result,
17730 cmd_ptype_mapping_update_parsed(
17731 void *parsed_result,
17732 __attribute__((unused)) struct cmdline *cl,
17733 __attribute__((unused)) void *data)
17735 struct cmd_ptype_mapping_update_result *res = parsed_result;
17736 int ret = -ENOTSUP;
17737 #ifdef RTE_LIBRTE_I40E_PMD
17738 struct rte_pmd_i40e_ptype_mapping mapping;
17740 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
17743 #ifdef RTE_LIBRTE_I40E_PMD
17744 mapping.hw_ptype = res->hw_ptype;
17745 mapping.sw_ptype = res->sw_ptype;
17746 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
17756 printf("invalid ptype 0x%8x\n", res->sw_ptype);
17759 printf("invalid port_id %d\n", res->port_id);
17762 printf("function not implemented\n");
17765 printf("programming error: (%s)\n", strerror(-ret));
17769 cmdline_parse_inst_t cmd_ptype_mapping_update = {
17770 .f = cmd_ptype_mapping_update_parsed,
17772 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
17774 (void *)&cmd_ptype_mapping_update_ptype,
17775 (void *)&cmd_ptype_mapping_update_mapping,
17776 (void *)&cmd_ptype_mapping_update_update,
17777 (void *)&cmd_ptype_mapping_update_port_id,
17778 (void *)&cmd_ptype_mapping_update_hw_ptype,
17779 (void *)&cmd_ptype_mapping_update_sw_ptype,
17784 /* Common result structure for file commands */
17785 struct cmd_cmdfile_result {
17786 cmdline_fixed_string_t load;
17787 cmdline_fixed_string_t filename;
17790 /* Common CLI fields for file commands */
17791 cmdline_parse_token_string_t cmd_load_cmdfile =
17792 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
17793 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
17794 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
17797 cmd_load_from_file_parsed(
17798 void *parsed_result,
17799 __attribute__((unused)) struct cmdline *cl,
17800 __attribute__((unused)) void *data)
17802 struct cmd_cmdfile_result *res = parsed_result;
17804 cmdline_read_from_file(res->filename);
17807 cmdline_parse_inst_t cmd_load_from_file = {
17808 .f = cmd_load_from_file_parsed,
17810 .help_str = "load <filename>",
17812 (void *)&cmd_load_cmdfile,
17813 (void *)&cmd_load_cmdfile_filename,
17818 /* Get Rx offloads capabilities */
17819 struct cmd_rx_offload_get_capa_result {
17820 cmdline_fixed_string_t show;
17821 cmdline_fixed_string_t port;
17823 cmdline_fixed_string_t rx_offload;
17824 cmdline_fixed_string_t capabilities;
17827 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
17828 TOKEN_STRING_INITIALIZER
17829 (struct cmd_rx_offload_get_capa_result,
17831 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
17832 TOKEN_STRING_INITIALIZER
17833 (struct cmd_rx_offload_get_capa_result,
17835 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
17836 TOKEN_NUM_INITIALIZER
17837 (struct cmd_rx_offload_get_capa_result,
17839 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
17840 TOKEN_STRING_INITIALIZER
17841 (struct cmd_rx_offload_get_capa_result,
17842 rx_offload, "rx_offload");
17843 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
17844 TOKEN_STRING_INITIALIZER
17845 (struct cmd_rx_offload_get_capa_result,
17846 capabilities, "capabilities");
17849 print_rx_offloads(uint64_t offloads)
17851 uint64_t single_offload;
17859 begin = __builtin_ctzll(offloads);
17860 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17862 single_offload = 1ULL << begin;
17863 for (bit = begin; bit < end; bit++) {
17864 if (offloads & single_offload)
17866 rte_eth_dev_rx_offload_name(single_offload));
17867 single_offload <<= 1;
17872 cmd_rx_offload_get_capa_parsed(
17873 void *parsed_result,
17874 __attribute__((unused)) struct cmdline *cl,
17875 __attribute__((unused)) void *data)
17877 struct cmd_rx_offload_get_capa_result *res = parsed_result;
17878 struct rte_eth_dev_info dev_info;
17879 portid_t port_id = res->port_id;
17880 uint64_t queue_offloads;
17881 uint64_t port_offloads;
17883 rte_eth_dev_info_get(port_id, &dev_info);
17884 queue_offloads = dev_info.rx_queue_offload_capa;
17885 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
17887 printf("Rx Offloading Capabilities of port %d :\n", port_id);
17888 printf(" Per Queue :");
17889 print_rx_offloads(queue_offloads);
17892 printf(" Per Port :");
17893 print_rx_offloads(port_offloads);
17897 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
17898 .f = cmd_rx_offload_get_capa_parsed,
17900 .help_str = "show port <port_id> rx_offload capabilities",
17902 (void *)&cmd_rx_offload_get_capa_show,
17903 (void *)&cmd_rx_offload_get_capa_port,
17904 (void *)&cmd_rx_offload_get_capa_port_id,
17905 (void *)&cmd_rx_offload_get_capa_rx_offload,
17906 (void *)&cmd_rx_offload_get_capa_capabilities,
17911 /* Get Rx offloads configuration */
17912 struct cmd_rx_offload_get_configuration_result {
17913 cmdline_fixed_string_t show;
17914 cmdline_fixed_string_t port;
17916 cmdline_fixed_string_t rx_offload;
17917 cmdline_fixed_string_t configuration;
17920 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
17921 TOKEN_STRING_INITIALIZER
17922 (struct cmd_rx_offload_get_configuration_result,
17924 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
17925 TOKEN_STRING_INITIALIZER
17926 (struct cmd_rx_offload_get_configuration_result,
17928 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
17929 TOKEN_NUM_INITIALIZER
17930 (struct cmd_rx_offload_get_configuration_result,
17932 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
17933 TOKEN_STRING_INITIALIZER
17934 (struct cmd_rx_offload_get_configuration_result,
17935 rx_offload, "rx_offload");
17936 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
17937 TOKEN_STRING_INITIALIZER
17938 (struct cmd_rx_offload_get_configuration_result,
17939 configuration, "configuration");
17942 cmd_rx_offload_get_configuration_parsed(
17943 void *parsed_result,
17944 __attribute__((unused)) struct cmdline *cl,
17945 __attribute__((unused)) void *data)
17947 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
17948 struct rte_eth_dev_info dev_info;
17949 portid_t port_id = res->port_id;
17950 struct rte_port *port = &ports[port_id];
17951 uint64_t port_offloads;
17952 uint64_t queue_offloads;
17953 uint16_t nb_rx_queues;
17956 printf("Rx Offloading Configuration of port %d :\n", port_id);
17958 port_offloads = port->dev_conf.rxmode.offloads;
17960 print_rx_offloads(port_offloads);
17963 rte_eth_dev_info_get(port_id, &dev_info);
17964 nb_rx_queues = dev_info.nb_rx_queues;
17965 for (q = 0; q < nb_rx_queues; q++) {
17966 queue_offloads = port->rx_conf[q].offloads;
17967 printf(" Queue[%2d] :", q);
17968 print_rx_offloads(queue_offloads);
17974 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
17975 .f = cmd_rx_offload_get_configuration_parsed,
17977 .help_str = "show port <port_id> rx_offload configuration",
17979 (void *)&cmd_rx_offload_get_configuration_show,
17980 (void *)&cmd_rx_offload_get_configuration_port,
17981 (void *)&cmd_rx_offload_get_configuration_port_id,
17982 (void *)&cmd_rx_offload_get_configuration_rx_offload,
17983 (void *)&cmd_rx_offload_get_configuration_configuration,
17988 /* Enable/Disable a per port offloading */
17989 struct cmd_config_per_port_rx_offload_result {
17990 cmdline_fixed_string_t port;
17991 cmdline_fixed_string_t config;
17993 cmdline_fixed_string_t rx_offload;
17994 cmdline_fixed_string_t offload;
17995 cmdline_fixed_string_t on_off;
17998 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
17999 TOKEN_STRING_INITIALIZER
18000 (struct cmd_config_per_port_rx_offload_result,
18002 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
18003 TOKEN_STRING_INITIALIZER
18004 (struct cmd_config_per_port_rx_offload_result,
18006 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
18007 TOKEN_NUM_INITIALIZER
18008 (struct cmd_config_per_port_rx_offload_result,
18010 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
18011 TOKEN_STRING_INITIALIZER
18012 (struct cmd_config_per_port_rx_offload_result,
18013 rx_offload, "rx_offload");
18014 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
18015 TOKEN_STRING_INITIALIZER
18016 (struct cmd_config_per_port_rx_offload_result,
18017 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18018 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18019 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18020 "crc_strip#scatter#timestamp#security#keep_crc");
18021 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
18022 TOKEN_STRING_INITIALIZER
18023 (struct cmd_config_per_port_rx_offload_result,
18027 search_rx_offload(const char *name)
18029 uint64_t single_offload;
18030 const char *single_name;
18034 single_offload = 1;
18035 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18036 single_name = rte_eth_dev_rx_offload_name(single_offload);
18037 if (!strcasecmp(single_name, name)) {
18041 single_offload <<= 1;
18045 return single_offload;
18051 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
18052 __attribute__((unused)) struct cmdline *cl,
18053 __attribute__((unused)) void *data)
18055 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
18056 portid_t port_id = res->port_id;
18057 struct rte_eth_dev_info dev_info;
18058 struct rte_port *port = &ports[port_id];
18059 uint64_t single_offload;
18060 uint16_t nb_rx_queues;
18063 if (port->port_status != RTE_PORT_STOPPED) {
18064 printf("Error: Can't config offload when Port %d "
18065 "is not stopped\n", port_id);
18069 single_offload = search_rx_offload(res->offload);
18070 if (single_offload == 0) {
18071 printf("Unknown offload name: %s\n", res->offload);
18075 rte_eth_dev_info_get(port_id, &dev_info);
18076 nb_rx_queues = dev_info.nb_rx_queues;
18077 if (!strcmp(res->on_off, "on")) {
18078 port->dev_conf.rxmode.offloads |= single_offload;
18079 for (q = 0; q < nb_rx_queues; q++)
18080 port->rx_conf[q].offloads |= single_offload;
18082 port->dev_conf.rxmode.offloads &= ~single_offload;
18083 for (q = 0; q < nb_rx_queues; q++)
18084 port->rx_conf[q].offloads &= ~single_offload;
18087 cmd_reconfig_device_queue(port_id, 1, 1);
18090 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
18091 .f = cmd_config_per_port_rx_offload_parsed,
18093 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
18094 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18095 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18096 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
18099 (void *)&cmd_config_per_port_rx_offload_result_port,
18100 (void *)&cmd_config_per_port_rx_offload_result_config,
18101 (void *)&cmd_config_per_port_rx_offload_result_port_id,
18102 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
18103 (void *)&cmd_config_per_port_rx_offload_result_offload,
18104 (void *)&cmd_config_per_port_rx_offload_result_on_off,
18109 /* Enable/Disable a per queue offloading */
18110 struct cmd_config_per_queue_rx_offload_result {
18111 cmdline_fixed_string_t port;
18113 cmdline_fixed_string_t rxq;
18115 cmdline_fixed_string_t rx_offload;
18116 cmdline_fixed_string_t offload;
18117 cmdline_fixed_string_t on_off;
18120 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
18121 TOKEN_STRING_INITIALIZER
18122 (struct cmd_config_per_queue_rx_offload_result,
18124 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
18125 TOKEN_NUM_INITIALIZER
18126 (struct cmd_config_per_queue_rx_offload_result,
18128 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
18129 TOKEN_STRING_INITIALIZER
18130 (struct cmd_config_per_queue_rx_offload_result,
18132 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
18133 TOKEN_NUM_INITIALIZER
18134 (struct cmd_config_per_queue_rx_offload_result,
18136 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
18137 TOKEN_STRING_INITIALIZER
18138 (struct cmd_config_per_queue_rx_offload_result,
18139 rx_offload, "rx_offload");
18140 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
18141 TOKEN_STRING_INITIALIZER
18142 (struct cmd_config_per_queue_rx_offload_result,
18143 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
18144 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
18145 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
18146 "crc_strip#scatter#timestamp#security#keep_crc");
18147 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
18148 TOKEN_STRING_INITIALIZER
18149 (struct cmd_config_per_queue_rx_offload_result,
18153 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
18154 __attribute__((unused)) struct cmdline *cl,
18155 __attribute__((unused)) void *data)
18157 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
18158 struct rte_eth_dev_info dev_info;
18159 portid_t port_id = res->port_id;
18160 uint16_t queue_id = res->queue_id;
18161 struct rte_port *port = &ports[port_id];
18162 uint64_t single_offload;
18164 if (port->port_status != RTE_PORT_STOPPED) {
18165 printf("Error: Can't config offload when Port %d "
18166 "is not stopped\n", port_id);
18170 rte_eth_dev_info_get(port_id, &dev_info);
18171 if (queue_id >= dev_info.nb_rx_queues) {
18172 printf("Error: input queue_id should be 0 ... "
18173 "%d\n", dev_info.nb_rx_queues - 1);
18177 single_offload = search_rx_offload(res->offload);
18178 if (single_offload == 0) {
18179 printf("Unknown offload name: %s\n", res->offload);
18183 if (!strcmp(res->on_off, "on"))
18184 port->rx_conf[queue_id].offloads |= single_offload;
18186 port->rx_conf[queue_id].offloads &= ~single_offload;
18188 cmd_reconfig_device_queue(port_id, 1, 1);
18191 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
18192 .f = cmd_config_per_queue_rx_offload_parsed,
18194 .help_str = "port <port_id> rxq <queue_id> rx_offload "
18195 "vlan_strip|ipv4_cksum|"
18196 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
18197 "macsec_strip|header_split|vlan_filter|vlan_extend|"
18198 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc "
18201 (void *)&cmd_config_per_queue_rx_offload_result_port,
18202 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
18203 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
18204 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
18205 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
18206 (void *)&cmd_config_per_queue_rx_offload_result_offload,
18207 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
18212 /* Get Tx offloads capabilities */
18213 struct cmd_tx_offload_get_capa_result {
18214 cmdline_fixed_string_t show;
18215 cmdline_fixed_string_t port;
18217 cmdline_fixed_string_t tx_offload;
18218 cmdline_fixed_string_t capabilities;
18221 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
18222 TOKEN_STRING_INITIALIZER
18223 (struct cmd_tx_offload_get_capa_result,
18225 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
18226 TOKEN_STRING_INITIALIZER
18227 (struct cmd_tx_offload_get_capa_result,
18229 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
18230 TOKEN_NUM_INITIALIZER
18231 (struct cmd_tx_offload_get_capa_result,
18233 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
18234 TOKEN_STRING_INITIALIZER
18235 (struct cmd_tx_offload_get_capa_result,
18236 tx_offload, "tx_offload");
18237 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
18238 TOKEN_STRING_INITIALIZER
18239 (struct cmd_tx_offload_get_capa_result,
18240 capabilities, "capabilities");
18243 print_tx_offloads(uint64_t offloads)
18245 uint64_t single_offload;
18253 begin = __builtin_ctzll(offloads);
18254 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
18256 single_offload = 1ULL << begin;
18257 for (bit = begin; bit < end; bit++) {
18258 if (offloads & single_offload)
18260 rte_eth_dev_tx_offload_name(single_offload));
18261 single_offload <<= 1;
18266 cmd_tx_offload_get_capa_parsed(
18267 void *parsed_result,
18268 __attribute__((unused)) struct cmdline *cl,
18269 __attribute__((unused)) void *data)
18271 struct cmd_tx_offload_get_capa_result *res = parsed_result;
18272 struct rte_eth_dev_info dev_info;
18273 portid_t port_id = res->port_id;
18274 uint64_t queue_offloads;
18275 uint64_t port_offloads;
18277 rte_eth_dev_info_get(port_id, &dev_info);
18278 queue_offloads = dev_info.tx_queue_offload_capa;
18279 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
18281 printf("Tx Offloading Capabilities of port %d :\n", port_id);
18282 printf(" Per Queue :");
18283 print_tx_offloads(queue_offloads);
18286 printf(" Per Port :");
18287 print_tx_offloads(port_offloads);
18291 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
18292 .f = cmd_tx_offload_get_capa_parsed,
18294 .help_str = "show port <port_id> tx_offload capabilities",
18296 (void *)&cmd_tx_offload_get_capa_show,
18297 (void *)&cmd_tx_offload_get_capa_port,
18298 (void *)&cmd_tx_offload_get_capa_port_id,
18299 (void *)&cmd_tx_offload_get_capa_tx_offload,
18300 (void *)&cmd_tx_offload_get_capa_capabilities,
18305 /* Get Tx offloads configuration */
18306 struct cmd_tx_offload_get_configuration_result {
18307 cmdline_fixed_string_t show;
18308 cmdline_fixed_string_t port;
18310 cmdline_fixed_string_t tx_offload;
18311 cmdline_fixed_string_t configuration;
18314 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
18315 TOKEN_STRING_INITIALIZER
18316 (struct cmd_tx_offload_get_configuration_result,
18318 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
18319 TOKEN_STRING_INITIALIZER
18320 (struct cmd_tx_offload_get_configuration_result,
18322 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
18323 TOKEN_NUM_INITIALIZER
18324 (struct cmd_tx_offload_get_configuration_result,
18326 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
18327 TOKEN_STRING_INITIALIZER
18328 (struct cmd_tx_offload_get_configuration_result,
18329 tx_offload, "tx_offload");
18330 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
18331 TOKEN_STRING_INITIALIZER
18332 (struct cmd_tx_offload_get_configuration_result,
18333 configuration, "configuration");
18336 cmd_tx_offload_get_configuration_parsed(
18337 void *parsed_result,
18338 __attribute__((unused)) struct cmdline *cl,
18339 __attribute__((unused)) void *data)
18341 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
18342 struct rte_eth_dev_info dev_info;
18343 portid_t port_id = res->port_id;
18344 struct rte_port *port = &ports[port_id];
18345 uint64_t port_offloads;
18346 uint64_t queue_offloads;
18347 uint16_t nb_tx_queues;
18350 printf("Tx Offloading Configuration of port %d :\n", port_id);
18352 port_offloads = port->dev_conf.txmode.offloads;
18354 print_tx_offloads(port_offloads);
18357 rte_eth_dev_info_get(port_id, &dev_info);
18358 nb_tx_queues = dev_info.nb_tx_queues;
18359 for (q = 0; q < nb_tx_queues; q++) {
18360 queue_offloads = port->tx_conf[q].offloads;
18361 printf(" Queue[%2d] :", q);
18362 print_tx_offloads(queue_offloads);
18368 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
18369 .f = cmd_tx_offload_get_configuration_parsed,
18371 .help_str = "show port <port_id> tx_offload configuration",
18373 (void *)&cmd_tx_offload_get_configuration_show,
18374 (void *)&cmd_tx_offload_get_configuration_port,
18375 (void *)&cmd_tx_offload_get_configuration_port_id,
18376 (void *)&cmd_tx_offload_get_configuration_tx_offload,
18377 (void *)&cmd_tx_offload_get_configuration_configuration,
18382 /* Enable/Disable a per port offloading */
18383 struct cmd_config_per_port_tx_offload_result {
18384 cmdline_fixed_string_t port;
18385 cmdline_fixed_string_t config;
18387 cmdline_fixed_string_t tx_offload;
18388 cmdline_fixed_string_t offload;
18389 cmdline_fixed_string_t on_off;
18392 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
18393 TOKEN_STRING_INITIALIZER
18394 (struct cmd_config_per_port_tx_offload_result,
18396 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
18397 TOKEN_STRING_INITIALIZER
18398 (struct cmd_config_per_port_tx_offload_result,
18400 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
18401 TOKEN_NUM_INITIALIZER
18402 (struct cmd_config_per_port_tx_offload_result,
18404 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
18405 TOKEN_STRING_INITIALIZER
18406 (struct cmd_config_per_port_tx_offload_result,
18407 tx_offload, "tx_offload");
18408 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
18409 TOKEN_STRING_INITIALIZER
18410 (struct cmd_config_per_port_tx_offload_result,
18411 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18412 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18413 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18414 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18415 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
18417 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
18418 TOKEN_STRING_INITIALIZER
18419 (struct cmd_config_per_port_tx_offload_result,
18423 search_tx_offload(const char *name)
18425 uint64_t single_offload;
18426 const char *single_name;
18430 single_offload = 1;
18431 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
18432 single_name = rte_eth_dev_tx_offload_name(single_offload);
18433 if (single_name == NULL)
18435 if (!strcasecmp(single_name, name)) {
18438 } else if (!strcasecmp(single_name, "UNKNOWN"))
18440 single_offload <<= 1;
18444 return single_offload;
18450 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
18451 __attribute__((unused)) struct cmdline *cl,
18452 __attribute__((unused)) void *data)
18454 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
18455 portid_t port_id = res->port_id;
18456 struct rte_eth_dev_info dev_info;
18457 struct rte_port *port = &ports[port_id];
18458 uint64_t single_offload;
18459 uint16_t nb_tx_queues;
18462 if (port->port_status != RTE_PORT_STOPPED) {
18463 printf("Error: Can't config offload when Port %d "
18464 "is not stopped\n", port_id);
18468 single_offload = search_tx_offload(res->offload);
18469 if (single_offload == 0) {
18470 printf("Unknown offload name: %s\n", res->offload);
18474 rte_eth_dev_info_get(port_id, &dev_info);
18475 nb_tx_queues = dev_info.nb_tx_queues;
18476 if (!strcmp(res->on_off, "on")) {
18477 port->dev_conf.txmode.offloads |= single_offload;
18478 for (q = 0; q < nb_tx_queues; q++)
18479 port->tx_conf[q].offloads |= single_offload;
18481 port->dev_conf.txmode.offloads &= ~single_offload;
18482 for (q = 0; q < nb_tx_queues; q++)
18483 port->tx_conf[q].offloads &= ~single_offload;
18486 cmd_reconfig_device_queue(port_id, 1, 1);
18489 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
18490 .f = cmd_config_per_port_tx_offload_parsed,
18492 .help_str = "port config <port_id> tx_offload "
18493 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18494 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18495 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18496 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18497 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
18498 "match_metadata on|off",
18500 (void *)&cmd_config_per_port_tx_offload_result_port,
18501 (void *)&cmd_config_per_port_tx_offload_result_config,
18502 (void *)&cmd_config_per_port_tx_offload_result_port_id,
18503 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
18504 (void *)&cmd_config_per_port_tx_offload_result_offload,
18505 (void *)&cmd_config_per_port_tx_offload_result_on_off,
18510 /* Enable/Disable a per queue offloading */
18511 struct cmd_config_per_queue_tx_offload_result {
18512 cmdline_fixed_string_t port;
18514 cmdline_fixed_string_t txq;
18516 cmdline_fixed_string_t tx_offload;
18517 cmdline_fixed_string_t offload;
18518 cmdline_fixed_string_t on_off;
18521 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
18522 TOKEN_STRING_INITIALIZER
18523 (struct cmd_config_per_queue_tx_offload_result,
18525 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
18526 TOKEN_NUM_INITIALIZER
18527 (struct cmd_config_per_queue_tx_offload_result,
18529 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
18530 TOKEN_STRING_INITIALIZER
18531 (struct cmd_config_per_queue_tx_offload_result,
18533 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
18534 TOKEN_NUM_INITIALIZER
18535 (struct cmd_config_per_queue_tx_offload_result,
18537 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
18538 TOKEN_STRING_INITIALIZER
18539 (struct cmd_config_per_queue_tx_offload_result,
18540 tx_offload, "tx_offload");
18541 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
18542 TOKEN_STRING_INITIALIZER
18543 (struct cmd_config_per_queue_tx_offload_result,
18544 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
18545 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
18546 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
18547 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
18548 "mt_lockfree#multi_segs#mbuf_fast_free#security");
18549 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
18550 TOKEN_STRING_INITIALIZER
18551 (struct cmd_config_per_queue_tx_offload_result,
18555 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
18556 __attribute__((unused)) struct cmdline *cl,
18557 __attribute__((unused)) void *data)
18559 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
18560 struct rte_eth_dev_info dev_info;
18561 portid_t port_id = res->port_id;
18562 uint16_t queue_id = res->queue_id;
18563 struct rte_port *port = &ports[port_id];
18564 uint64_t single_offload;
18566 if (port->port_status != RTE_PORT_STOPPED) {
18567 printf("Error: Can't config offload when Port %d "
18568 "is not stopped\n", port_id);
18572 rte_eth_dev_info_get(port_id, &dev_info);
18573 if (queue_id >= dev_info.nb_tx_queues) {
18574 printf("Error: input queue_id should be 0 ... "
18575 "%d\n", dev_info.nb_tx_queues - 1);
18579 single_offload = search_tx_offload(res->offload);
18580 if (single_offload == 0) {
18581 printf("Unknown offload name: %s\n", res->offload);
18585 if (!strcmp(res->on_off, "on"))
18586 port->tx_conf[queue_id].offloads |= single_offload;
18588 port->tx_conf[queue_id].offloads &= ~single_offload;
18590 cmd_reconfig_device_queue(port_id, 1, 1);
18593 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
18594 .f = cmd_config_per_queue_tx_offload_parsed,
18596 .help_str = "port <port_id> txq <queue_id> tx_offload "
18597 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
18598 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
18599 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
18600 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
18601 "mt_lockfree|multi_segs|mbuf_fast_free|security "
18604 (void *)&cmd_config_per_queue_tx_offload_result_port,
18605 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
18606 (void *)&cmd_config_per_queue_tx_offload_result_txq,
18607 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
18608 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
18609 (void *)&cmd_config_per_queue_tx_offload_result_offload,
18610 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
18615 /* *** configure tx_metadata for specific port *** */
18616 struct cmd_config_tx_metadata_specific_result {
18617 cmdline_fixed_string_t port;
18618 cmdline_fixed_string_t keyword;
18620 cmdline_fixed_string_t item;
18625 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
18626 __attribute__((unused)) struct cmdline *cl,
18627 __attribute__((unused)) void *data)
18629 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
18631 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
18633 ports[res->port_id].tx_metadata = rte_cpu_to_be_32(res->value);
18634 /* Add/remove callback to insert valid metadata in every Tx packet. */
18635 if (ports[res->port_id].tx_metadata)
18636 add_tx_md_callback(res->port_id);
18638 remove_tx_md_callback(res->port_id);
18641 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
18642 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18644 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
18645 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18646 keyword, "config");
18647 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
18648 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18650 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
18651 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18652 item, "tx_metadata");
18653 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
18654 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
18657 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
18658 .f = cmd_config_tx_metadata_specific_parsed,
18660 .help_str = "port config <port_id> tx_metadata <value>",
18662 (void *)&cmd_config_tx_metadata_specific_port,
18663 (void *)&cmd_config_tx_metadata_specific_keyword,
18664 (void *)&cmd_config_tx_metadata_specific_id,
18665 (void *)&cmd_config_tx_metadata_specific_item,
18666 (void *)&cmd_config_tx_metadata_specific_value,
18671 /* *** display tx_metadata per port configuration *** */
18672 struct cmd_show_tx_metadata_result {
18673 cmdline_fixed_string_t cmd_show;
18674 cmdline_fixed_string_t cmd_port;
18675 cmdline_fixed_string_t cmd_keyword;
18680 cmd_show_tx_metadata_parsed(void *parsed_result,
18681 __attribute__((unused)) struct cmdline *cl,
18682 __attribute__((unused)) void *data)
18684 struct cmd_show_tx_metadata_result *res = parsed_result;
18686 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
18687 printf("invalid port id %u\n", res->cmd_pid);
18690 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
18691 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
18692 rte_be_to_cpu_32(ports[res->cmd_pid].tx_metadata));
18696 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
18697 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18699 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
18700 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18702 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
18703 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
18705 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
18706 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
18707 cmd_keyword, "tx_metadata");
18709 cmdline_parse_inst_t cmd_show_tx_metadata = {
18710 .f = cmd_show_tx_metadata_parsed,
18712 .help_str = "show port <port_id> tx_metadata",
18714 (void *)&cmd_show_tx_metadata_show,
18715 (void *)&cmd_show_tx_metadata_port,
18716 (void *)&cmd_show_tx_metadata_pid,
18717 (void *)&cmd_show_tx_metadata_keyword,
18722 /* ******************************************************************************** */
18724 /* list of instructions */
18725 cmdline_parse_ctx_t main_ctx[] = {
18726 (cmdline_parse_inst_t *)&cmd_help_brief,
18727 (cmdline_parse_inst_t *)&cmd_help_long,
18728 (cmdline_parse_inst_t *)&cmd_quit,
18729 (cmdline_parse_inst_t *)&cmd_load_from_file,
18730 (cmdline_parse_inst_t *)&cmd_showport,
18731 (cmdline_parse_inst_t *)&cmd_showqueue,
18732 (cmdline_parse_inst_t *)&cmd_showportall,
18733 (cmdline_parse_inst_t *)&cmd_showcfg,
18734 (cmdline_parse_inst_t *)&cmd_showfwdall,
18735 (cmdline_parse_inst_t *)&cmd_start,
18736 (cmdline_parse_inst_t *)&cmd_start_tx_first,
18737 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
18738 (cmdline_parse_inst_t *)&cmd_set_link_up,
18739 (cmdline_parse_inst_t *)&cmd_set_link_down,
18740 (cmdline_parse_inst_t *)&cmd_reset,
18741 (cmdline_parse_inst_t *)&cmd_set_numbers,
18742 (cmdline_parse_inst_t *)&cmd_set_log,
18743 (cmdline_parse_inst_t *)&cmd_set_txpkts,
18744 (cmdline_parse_inst_t *)&cmd_set_txsplit,
18745 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
18746 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
18747 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
18748 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
18749 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
18750 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
18751 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
18752 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
18753 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
18754 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
18755 (cmdline_parse_inst_t *)&cmd_set_link_check,
18756 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
18757 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
18758 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
18759 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
18760 #ifdef RTE_LIBRTE_PMD_BOND
18761 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
18762 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
18763 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
18764 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
18765 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
18766 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
18767 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
18768 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
18769 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
18770 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
18771 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
18773 (cmdline_parse_inst_t *)&cmd_vlan_offload,
18774 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
18775 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
18776 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
18777 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
18778 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
18779 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
18780 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
18781 (cmdline_parse_inst_t *)&cmd_csum_set,
18782 (cmdline_parse_inst_t *)&cmd_csum_show,
18783 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
18784 (cmdline_parse_inst_t *)&cmd_tso_set,
18785 (cmdline_parse_inst_t *)&cmd_tso_show,
18786 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
18787 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
18788 (cmdline_parse_inst_t *)&cmd_gro_enable,
18789 (cmdline_parse_inst_t *)&cmd_gro_flush,
18790 (cmdline_parse_inst_t *)&cmd_gro_show,
18791 (cmdline_parse_inst_t *)&cmd_gso_enable,
18792 (cmdline_parse_inst_t *)&cmd_gso_size,
18793 (cmdline_parse_inst_t *)&cmd_gso_show,
18794 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
18795 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
18796 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
18797 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
18798 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
18799 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
18800 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
18801 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
18802 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
18803 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
18804 (cmdline_parse_inst_t *)&cmd_config_dcb,
18805 (cmdline_parse_inst_t *)&cmd_read_reg,
18806 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
18807 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
18808 (cmdline_parse_inst_t *)&cmd_write_reg,
18809 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
18810 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
18811 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
18812 (cmdline_parse_inst_t *)&cmd_stop,
18813 (cmdline_parse_inst_t *)&cmd_mac_addr,
18814 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
18815 (cmdline_parse_inst_t *)&cmd_set_qmap,
18816 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
18817 (cmdline_parse_inst_t *)&cmd_operate_port,
18818 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
18819 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
18820 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
18821 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
18822 (cmdline_parse_inst_t *)&cmd_config_speed_all,
18823 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
18824 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
18825 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
18826 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
18827 (cmdline_parse_inst_t *)&cmd_config_mtu,
18828 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
18829 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
18830 (cmdline_parse_inst_t *)&cmd_config_rss,
18831 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
18832 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
18833 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
18834 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
18835 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
18836 (cmdline_parse_inst_t *)&cmd_showport_reta,
18837 (cmdline_parse_inst_t *)&cmd_config_burst,
18838 (cmdline_parse_inst_t *)&cmd_config_thresh,
18839 (cmdline_parse_inst_t *)&cmd_config_threshold,
18840 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
18841 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
18842 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
18843 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
18844 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
18845 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
18846 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
18847 (cmdline_parse_inst_t *)&cmd_global_config,
18848 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
18849 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
18850 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
18851 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
18852 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
18853 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
18854 (cmdline_parse_inst_t *)&cmd_dump,
18855 (cmdline_parse_inst_t *)&cmd_dump_one,
18856 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
18857 (cmdline_parse_inst_t *)&cmd_syn_filter,
18858 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
18859 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
18860 (cmdline_parse_inst_t *)&cmd_flex_filter,
18861 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
18862 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
18863 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
18864 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
18865 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
18866 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
18867 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
18868 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
18869 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
18870 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
18871 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
18872 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
18873 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
18874 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
18875 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
18876 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
18877 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
18878 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
18879 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
18880 (cmdline_parse_inst_t *)&cmd_flow,
18881 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
18882 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
18883 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
18884 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
18885 (cmdline_parse_inst_t *)&cmd_create_port_meter,
18886 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
18887 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
18888 (cmdline_parse_inst_t *)&cmd_del_port_meter,
18889 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
18890 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
18891 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
18892 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
18893 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
18894 (cmdline_parse_inst_t *)&cmd_mcast_addr,
18895 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
18896 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
18897 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
18898 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
18899 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
18900 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
18901 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
18902 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
18903 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
18904 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
18905 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
18906 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
18907 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
18908 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
18909 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
18910 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
18911 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
18912 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
18913 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
18914 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
18915 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
18916 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
18917 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
18918 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
18919 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
18920 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
18921 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
18922 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
18923 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
18924 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
18925 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
18926 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
18927 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
18928 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
18929 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
18930 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
18931 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
18933 (cmdline_parse_inst_t *)&cmd_set_vxlan,
18934 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
18935 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
18936 (cmdline_parse_inst_t *)&cmd_set_nvgre,
18937 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
18938 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
18939 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
18940 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
18941 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
18942 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
18943 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
18944 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
18945 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
18946 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
18947 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
18948 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
18949 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
18950 (cmdline_parse_inst_t *)&cmd_ddp_add,
18951 (cmdline_parse_inst_t *)&cmd_ddp_del,
18952 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
18953 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
18954 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
18955 (cmdline_parse_inst_t *)&cmd_clear_input_set,
18956 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
18957 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
18958 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
18959 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
18960 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
18961 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
18963 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
18964 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
18965 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
18966 (cmdline_parse_inst_t *)&cmd_queue_region,
18967 (cmdline_parse_inst_t *)&cmd_region_flowtype,
18968 (cmdline_parse_inst_t *)&cmd_user_priority_region,
18969 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
18970 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
18971 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
18972 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
18973 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
18974 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
18975 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
18976 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
18977 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
18978 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
18979 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
18980 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
18981 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
18982 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
18983 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
18984 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
18985 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
18986 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
18987 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
18988 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
18989 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
18990 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
18991 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
18992 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
18993 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
18994 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
18995 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
18996 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
18997 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
18998 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
18999 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
19000 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
19001 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
19002 #ifdef RTE_LIBRTE_BPF
19003 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
19004 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
19006 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
19007 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
19008 (cmdline_parse_inst_t *)&cmd_set_raw,
19012 /* read cmdline commands from file */
19014 cmdline_read_from_file(const char *filename)
19016 struct cmdline *cl;
19018 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
19020 printf("Failed to create file based cmdline context: %s\n",
19025 cmdline_interact(cl);
19030 printf("Read CLI commands from %s\n", filename);
19033 /* prompt function, called from main on MASTER lcore */
19037 /* initialize non-constant commands */
19038 cmd_set_fwd_mode_init();
19039 cmd_set_fwd_retry_mode_init();
19041 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
19042 if (testpmd_cl == NULL)
19044 cmdline_interact(testpmd_cl);
19045 cmdline_stdin_exit(testpmd_cl);
19051 if (testpmd_cl != NULL)
19052 cmdline_quit(testpmd_cl);
19056 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
19058 if (id == (portid_t)RTE_PORT_ALL) {
19061 RTE_ETH_FOREACH_DEV(pid) {
19062 /* check if need_reconfig has been set to 1 */
19063 if (ports[pid].need_reconfig == 0)
19064 ports[pid].need_reconfig = dev;
19065 /* check if need_reconfig_queues has been set to 1 */
19066 if (ports[pid].need_reconfig_queues == 0)
19067 ports[pid].need_reconfig_queues = queue;
19069 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
19070 /* check if need_reconfig has been set to 1 */
19071 if (ports[id].need_reconfig == 0)
19072 ports[id].need_reconfig = dev;
19073 /* check if need_reconfig_queues has been set to 1 */
19074 if (ports[id].need_reconfig_queues == 0)
19075 ports[id].need_reconfig_queues = queue;